akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
//#include <regex>

/* g++ -g -std=c++0x */
/* g++ -g -std=c++11 */

using namespace std;

// freopen("input.txt", "rt", stdin);
// freopen("output.txt", "wt", stdout);

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

int main()
{
/* #ifndef ONLINE_JUDGE */
/*     freopen("foo", "rt", stdin); */
/* #endif */
    std::ios::sync_with_stdio(false);

    int A,B;
    while (cin >> A >> B) {
        int C = A+B;
        int D = A-B;
        int E = A*B;
        int ans = C;
        if (ans < D)
            ans = D;
        if (ans < E)
            ans = E;
        cout << ans << endl;
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdlib>
#include<string>
#include<vector>
#include<map>
#include<unordered_map>
#include<queue>
#include<algorithm>
#include<iomanip>
#include<typeinfo>
#include<complex>
using namespace std;
using ll = long long int;
const int mod = 1e9 + 7;
#define rep(i, a, b) for(ll i = a;i < b; i++)
const long double PI = (acos(-1));


int main() {

	int a, b, k;
	cin >> a >> b >> k;

	int x = min(a, b) + 1;
	while (k > 0) {
		x--;
		if (a % x == 0 && b % x == 0) k--;
	}
	cout << x << endl;

	return 0;
}

Measured memory_bytes: 256
N = int(input())
X = []
Y = []
H = []
for i in range(N):
  x, y, h = map(int, input().split())
  X.append(x)
  Y.append(y)
  H.append(h)
tmp = max(H)
for cx in range(101):
  for cy in range(101):
    for i, h in enumerate(H):
      if h != 0:
        ch = abs(cx - X[i]) + abs(cy - Y[i]) + H[i]
        break
    for i in range(N):
      if H[i] != max(ch - abs(cx - X[i]) - abs(cy - Y[i]), 0):
        break
    else:
      print(cx, cy, ch)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int a = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());
		int diff = b - a;
		int length = 0;
		for (int i = 0; i <= diff; i++) {
			length += i;
		}
		System.out.println(length - b);
		sc.close();
	}
}

Measured memory_bytes: 22228
#include <iostream>
using namespace std;

int main(){
  int n;
    int a,b,c,t;

  cin >> n;

  if (n==2){
      cin >> a >> b;
        if (a>b){
      t=a;
      a=b;
      b=t;
    }
    for (int i=1;i<=a;i++)
      if (a%i==0 && b%i==0) cout << i << endl;
    
  }else if (n==3){
      cin >> a >> b >> c;
      if (a>b){
      t=a;
      a=b;
      b=t;
    }
    if (b>c){
      t=b;
      b=c;
      c=t;
      if (a>b){
	t=a;
	a=b;
	b=t;
      }
    }
    
    for (int i=1;i<=a;i++)
      if (a%i==0 && b%i==0 && c%i==0) cout << i << endl;
    
  }
  return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define FOR(i,l,r) for(i=l;i<r;i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define P pair<ll,ll>
#define F first
#define S second
signed main(){
  ll N,i,ans=0;cin>>N;
  FOR(i,1,N)ans+=(N-1)/i;
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>

using namespace std;

int main()
{
	int s;
	cin>>s;
	int n = s%10;
	int a=s/10%10;
	int b=s/100%10;
	int c=s/1000%10;
	if(n==a||a==b||b==c)
		cout <<"Bad"<<endl;
	else
		cout<<"Good"<<endl;
	return 0;
}
			

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;

long long mod = 1e9 + 7;
long long N, K;
long long ans = 1;
vector<vector<long long>> es(1e5, vector<long long>());
vector<bool> visited(1e5 + 1 + 10, false);
vector<long long> gs(1e5 + 1 + 10, 0);

void rec(long long v, long long bf)
{
    visited.at(v) = true;
    gs.at(v)++;
    gs.at(bf)++;

    ans = ans * (K - gs.at(bf)) % mod;
    for (long long nv : es.at(v))
    {
        if (visited.at(nv) == false)
        {
            rec(nv, v);
        }
    }
}

int main()
{
    cin >> N >> K;
    for (long long i = 0; i < N - 1; i++)
    {
        long long a, b;
        cin >> a >> b;
        a--;
        b--;
        es.at(a).push_back(b);
        es.at(b).push_back(a);
    }
    // rec(0, N)で、呼び出された頂点とその親の次数を増やすが、
    // 最初に呼ばれた頂点はこの操作で次数0になるように-1/-1とする
    gs.at(0) = -1;
    gs.at(N) = -1;
    rec(0, N);
    cout << ans << endl;
}


Measured memory_bytes: 9984
#include <bits/stdc++.h>

#define ft first
#define sd second

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;










int main() {
	int a[3], k;
	cin >> a[0] >> a[1] >> a[2] >> k;
	sort(a, a + 3);
	cout << (a[0] + a[1] + (a[2] << k));
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

int main(){
	int n;
	cin>>n;
	int a[111]={},dp[2][11100]={};
	FOR(i,0,n)cin>>a[i];
	int idx=0;
	dp[idx][0]=1;
	FOR(i,0,n){
		FOR(j,0,100*i+1){
			if(dp[idx][j]==0)continue;
			dp[idx^1][j+a[i]]++;
			dp[idx^1][j]++;
			dp[idx][j]=0;
		}
		idx^=1;
	}
	FORD(i,100*n+1,0){
		if(i%10!=0&&dp[idx][i]!=0){
			cout<<i<<endl;
			return 0;
		}
	}
	cout<<0<<endl;
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;

#define ll long long int

ll mod=1000000007;

int main(){
	ll n;
	cin>>n;
	ll arr[n+1][n+1];
	for(ll i=0;i<n;i++){
		for(ll j=0;j<n;j++){
			cin>>arr[i][j];
		}
	}
	ll dp[(1<<n)+1];
	memset(dp,0,sizeof(dp));
	dp[0]=1;
	for(ll i=0;i<(1<<n);i++){
		ll k=__builtin_popcount(i);
		for(ll j=0;j<n;j++){
			if(arr[k][j] && !(i&(1<<j))){
			ll q=i|(1<<j);
			dp[q]=(dp[q]+dp[i])%mod;
			}
		}
	}
	cout<<dp[(1<<n)-1];
}

Measured memory_bytes: 16640
#include <bits/stdc++.h>
using namespace std;

int main() {
    long long s; cin >> s;
    long long n = 1e9;
    long long a = (s + n - 1) / n;
    long long b = (a * n - s) % n;
    printf("0 0 1 %ld %ld %ld\n", n, a, b);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <functional>
#include <numeric>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
using namespace std;
#define INT_MAX 2147483647
#define INT_MIN -2147483648
#define INF 100000000
#define _INF -100000000
#define INFLL (long long)1e14
#define _INFLL (long long)-1e14
#define Loop(i, n) for(int i = 0; i < (int)n; i++)
#define Loop1(i, n) for(int i = 1; i <= (int)n; i++)
#define Loopr(i, n) for(int i = (int)n - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = (int)n; i >= 1; i--)
#define bitmanip(m,val) static_cast<bitset<(int)m>>(val)
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int,int> P;

struct node {
	bool done;
	vi to, dist;
	int id, from;
	ll d;
	int depth;
	bool operator<(const node & another) const {
		return !(d != another.d ? d < another.d : id < another.id);
	}
};

class Prim {
public:
	vector<node> nodes;
	int n;
	Prim(vector<node> A) {
		n = A.size();
		nodes = A;
	}
	void mainfunc() {
		priority_queue<node> pq;
		nodes[0].d = 0;
		pq.push(nodes[0]);
		while (pq.size()) {
			node focus = pq.top(); pq.pop();
			if (nodes[focus.id].done) continue;
			Loop(i, focus.to.size()) {
				int b = focus.to[i];
				if (!nodes[b].done && focus.dist[i] < nodes[b].d) {
					nodes[b].d = focus.dist[i];
					nodes[b].from = focus.id;
					nodes[b].depth = focus.depth + 1;
					pq.push(nodes[focus.to[i]]);
				}
			}
			nodes[focus.id].done = true;
		}
		return;
	}
};

int main() {
	int v, e; cin >> v >> e;
	vector<node> nodes(v);
	Loop(i, v) nodes[i] = { false,{},{}, i, -1, INFLL, 0 };
	Loop(i, e) {
		int s, t, d; cin >> s >> t >> d;
		nodes[s].to.push_back(t);
		nodes[s].dist.push_back(d);
		nodes[t].to.push_back(s);
		nodes[t].dist.push_back(d);
	}
	Prim prim(nodes);
	prim.mainfunc();
	ll ans = 0;
	Loop(i, v) ans += prim.nodes[i].d;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 14992
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<vector>
using namespace std;
const int N=2e5+5,YL=1e9+7;
inline int MO(const int &x){return x>=YL?x-YL:x;}
inline int in(){int k;cin>>k;return k;}
int a[N],p[N],b[N],mp[N];
inline int low(int x){return x&(-x);}
int n,tot;
typedef std::pair<int,int> P;
#define mk make_pair
std::vector<P>ans;
inline void work(int n)
{
	for(int i=1;i<=n;++i)
		for(int j=i+1;j<=n;++j)
			if(i+j!=n+1)ans.push_back(mk(i,j));
}
int main()
{
	ios::sync_with_stdio(0);
	cin>>n;if(n&1)work(n-1);else work(n);
	if(n&1)for(int i=1;i<n;++i)ans.push_back(mk(i,n));
	printf("%d\n",ans.size());
	for(int i=0;i<ans.size();++i)
		printf("%d %d\n",ans[i].first,ans[i].second);
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(int)(n); i++)

using namespace std;
typedef long long LL;
typedef pair<int,int> P;

int main(){
  int N, M;
  cin >> N >> M;
  vector<LL> a(N);
  rep(i,N) cin >> a[i];
  rep(i,N) a[i]/=2;
  vector<int> ac(N);
  rep(i,N) ac[i]=a[i];
  while(1){
    int num=0;
    rep(i,N){
      if(ac[i]%2==0){
        ac[i]/=2;
        num++;
      }
    }
    if(num==0) break;
    if(num!=N){
      cout << 0 << endl;
      return 0;
    }
  }
  LL lc=1;
  rep(i,N){
    lc=lc*a[i]/__gcd(lc,a[i]);
    if(lc>M){
      cout << 0 << endl;
      return 0;
    }
  }
  int ans=0, i=1;
  LL l=lc;
  while(l<=M){
    ans++;
    i+=2;
    l=lc*i;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1408
n=int(input())
s=input()
r=s.count("R")
g=s.count("G")
b=s.count("B")
ans=r*g*b

for i in range(n):
    for d in range(n):
        j=i+d
        k=j+d
        if k>=n:
            break
        if (s[i]!=s[j]) & (s[j]!=s[k]) & (s[k]!=s[i]):
            ans-=1

print(ans)

Measured memory_bytes: 68052
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;

struct info
{
    LL a,b,id;

    bool operator <(const info x)const
    {
        if(a*x.b==b*x.a)return id<x.id;
        return a*x.b<b*x.a;
    }
};

int n,p[200009],x[200009],y[200009];

int par[200009];

int findpar(int u)
{
    if(par[u]==u)return u;
    return par[u]=findpar(par[u]);
}

set<info>s;

int main()
{
    scanf("%d",&n);
    for(int i=2;i<=n;i++)
    {
        scanf("%d",&p[i]);
    }
    int v;
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&v);
        if(v==0)x[i]=1;
        else y[i]=1;
    }
    LL ans=0;
    for(int i=1;i<=n;i++)par[i]=i;
    info tmp,tmp2;
    for(int i=1;i<=n;i++)
    {
        tmp.id=i;
        tmp.a=x[i];
        tmp.b=y[i];
        s.insert(tmp);
    }
    while(s.size()>1)
    {
        auto it=s.end();
        it--;
        tmp=*it;
        if(tmp.id==1)
        {
            it--;
            tmp=*it;
        }
        tmp2.id=findpar(p[tmp.id]);
        tmp2.a=x[tmp2.id];
        tmp2.b=y[tmp2.id];
        //cout<<tmp.id<<" "<<tmp2.id<<" "<<tmp.a<<" "<<tmp2.b<<endl;
        ans+=1LL*tmp2.b*tmp.a;
        par[tmp.id]=tmp2.id;
        s.erase(tmp);
        s.erase(tmp2);
        tmp2.a+=tmp.a;
        tmp2.b+=tmp.b;
        x[tmp2.id]=tmp2.a;
        y[tmp2.id]=tmp2.b;
        s.insert(tmp2);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 15872
#include<iostream>
#include<string>
using namespace std;

int main()
{
  string n;
  cin >> n;

  if(n[1] == n[2]){
    if(n[0] == n[1] || n[2] == n[3]){
      cout << "Yes" << endl;
      return 0;
    }
  }

  cout << "No" << endl;

  return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace  std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long

int main(){
  string s;
  cin >> s;
  s = s.erase(s.size()-1);
  while (true){
    string right_half = s.substr(0, s.size() / 2);
    string left_half = s.substr(s.size() / 2);
    if (right_half == left_half) break;
    s = s.erase(s.size()-1);
  }
  
  cout << s.size() << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string>
#include <stack>
#include <set>
#include <vector>
using namespace std;
typedef long long ll;

void printarray(int n, int a[])
{
    for (int i = 0; i < n; i++)
    {
        cout << a[i];
        if (i != n - 1)
            cout << " ";
    }
    cout << endl;
}

void printpairaraay(int n, pair<int, int> a[])
{
    int x, y;
    for (int i = 0; i < n; i++)
    {
        x = a[i].first;
        y = a[i].second;
        cout << x << " " << y << "\n";
    }
    cout << endl;
}

void swaprange(int b, int t, int e, int a[])
{
    for (int i = 0; i < e - b; i++)
    {
        swap(a[b + i], a[i + t]);
    }
}

int my_binarysearch(int n, int a[], int x)
{
    int ret = 0;
    if (distance(lower_bound(a, a + n, x), upper_bound(a, a + n, x)) != 0)
        ret = 1;
    return ret;
}

int main()
{
    int n, m, x, r;
	r = 0;
    cin >> n;
    int a[n];

    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }

    cin >> m;
    for (int i = 0; i < m; i++)
    {
        cin >> x;
        r += my_binarysearch(n, a, x);
    }
    cout << ((r == m) ? 1 : 0) << endl;

    return 0;
}

// getline(cin,s);
// a = strtok(s, ",");  ","で分解
// for (int i = 0; i < n; i++)


Measured memory_bytes: 3908
MAX_PRIME = 10**3
is_prime = [1] * MAX_PRIME
primes = []
is_prime[0] = 0
is_prime[1] = 0
for i in range(MAX_PRIME):
    if is_prime[i]:
        primes.append(i)
        for j in range(2, ((MAX_PRIME-1)//i) + 1):
            is_prime[i*j] = 0

def factorization(n):
    factor = {}
    for p in primes:
        if p ** 2 > n:
            break
        while n % p == 0:
            n //= p
            if p not in factor:
                factor[p] = 1
            else:
                factor[p] += 1
    if n > 1:
        factor[n] = 1
    return factor
def extGCD(a, b):
    if b == 0:
        return a, 1, 0
    g, y, x = extGCD(b, a%b)
    y -= a//b * x
    return g, x, y
def moddiv(a, b):
    _, inv, _ = extGCD(b, law)
    return a * inv % law

n = int(input())
a = list(map(int, input().split()))

ans = 0
l = {}
lmod = 1
law = 10 ** 9 + 7
for x in a:
    fx = factorization(x)
    for p, c in fx.items():
        if p not in l:
            ans *= p ** c
            lmod *= p ** c
            ans %= law
            lmod %= law
            l[p] = c
        elif c > l[p]:
            ans *= p ** (c - l[p])
            lmod *= p ** (c - l[p])
            ans %= law
            lmod %= law
            l[p] = c
    b = moddiv(lmod, x)
    ans += b
    ans %= law
print(ans)

Measured memory_bytes: 4596
#include<cstdio>
#include<cstring>
#include<algorithm>
char S[1001000];
int minn[1001000];
long long ans,n;
int main(){
	scanf("%s",S+1);
	n=strlen(S+1);
	minn[0]=0;
	for(int i=1;i<=n;i++)
		if(S[i]=='>')minn[i]=0;
		else minn[i]=minn[i-1]+1;
	
	int now=minn[n];
	ans=now;
	for(int i=n-1;i>=0;i--){
		if(S[i+1]=='>')now=std::max(now+1,minn[i]);
		else now=minn[i];
		ans+=now;
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 4480
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
int main(void){
    long numID,num_gate;
    long *min,*max;
    long sup=0,inf=100000;

    scanf("%ld %ld",&numID,&num_gate);
    min=(long *)malloc(sizeof(long)*num_gate);
    max=(long *)malloc(sizeof(long)*num_gate);
    long i;
    for(i=0;i<num_gate;i++){
        scanf("%ld %ld",&min[i],&max[i]);
        if(sup<min[i]){
            sup=min[i];
        }
        if(inf>max[i]){
            inf=max[i];
        }
        if(inf<sup){
            printf("0");
            free(min);
            free(max);
            return 0;
        }
    }
    printf("%ld",1+inf-sup);
    free(max);
    free(min);
    return 0;
}

Measured memory_bytes: 1664
package main

import "fmt"

func main() {
	var a, b int
	_, _ = fmt.Scanf("%d %d", &a, &b)
	fmt.Println(max3(a+b, a*b, a-b))
}

func max3(a, b, c int) int {
	if a > b && a > c {
		return a
	}
	if b > a && b > c {
		return b
	}
	return c
}


Measured memory_bytes: 512
#!/usr/bin/env python
# -*- coding: utf-8 -*-

al = [0, 5] + [0] * 49
bl = [0, 3] + [0] * 49


def solve2(ans, x, idx):
    if idx == 1:
        if x >= 5:
            return ans + 3
        if x <= 0:
            return ans
        return ans + (0, 0, 1, 2, 3, 3)[x]
    if x >= al[idx - 1] + 1:
        ans += bl[idx - 1]
        x -= al[idx - 1] + 1
        if x >= 1:
            ans += 1
            x -= 1
    else:
        x -= 1
    return solve2(ans, x, idx - 1)


def solve():
    n, x = map(int, input().split())
    for i in range(2, n + 1):
        al[i] = al[i - 1] * 2 + 3
        bl[i] = bl[i - 1] * 2 + 1
    print(solve2(0, x, n))


if __name__ == "__main__":
    solve()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    int rcount = 0, wcount = 0;
    int si = s.size();
    for (int i = 0; i < si; i++)
    {
        if (s[i] == 'R')
            rcount++;
        else
            wcount++;
    }
    int wc = 0, rc = 0;
    for (int i = 0; i < si; i++)
    {
        if (i < rcount && s[i] == 'R')
            rc++;
        else if (i >= rcount && s[i] == 'W')
            wc++;
    }
    cout << min(wcount - wc, rcount - rc) << endl;
}


Measured memory_bytes: 3676
#include<bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define repk(i,k,n) for (ll i = k; i < (ll)(n); ++i)
#define MAX 500000001000000000
#define MOD 1000000007
typedef long long  ll;

using namespace std;

int ans, cnt;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int N;
	cin >> N;

	if(N%2==0)	cout << N/2 << endl;
	else cout << N / 2 + 1 << endl;

	return 0;
}

Measured memory_bytes: 256
using System;
using System.IO;
using System.Collections.Generic;

public class Kadai
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine());
        string inp_str = Console.ReadLine();
        string[] inp_arr = inp_str.Split(' ');
        int[] input = new int[n];
        for (int i = 0; i < n; i++)
        {
            input[i] = int.Parse(inp_arr[i]);
        }

        for (int k = 0; k < n - 1; k++)
        {
            Console.Write(input[k]);
            Console.Write(' ');
        }
        Console.WriteLine(input[n - 1]);

        for (int i = 1; i < n; i++)
        {
            int v = input[i];
            int j = i - 1;
            while (j >= 0 && input[j] > v)
            {
                input[j + 1] = input[j];
                j--;
            }
            input[j + 1] = v;
            for (int k = 0; k < n - 1; k++)
            {
                Console.Write(input[k]);
                Console.Write(' ');
            }
            Console.WriteLine(input[n - 1]);
        }
    }
}


Measured memory_bytes: 15952
#include<bits/stdc++.h>
using namespace std;
int digit(int n){
  int ans=0;
  while(n!=0){
    ans+=n%10;
    n=n/10;
  }
  return ans;
}
int main(){
  int n;
  cin >> n;
  if(n % digit(n)==0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3584
#include <iostream>
#include <cmath>
using namespace std;
int main(void){
    
    long long num = pow(10, 18);
    unsigned long long sum = 1;
    
    
    int N;
    cin >> N;
    
    bool check = false;
    for(int i = 0; i < N; i++){
        long long A;
        cin >> A;
        if(A == 0){
            cout << 0 << endl;
            return 0;
        }
        
        // 10の18乗を超えるか判定
        if(sum > num / A || check == true){
            check = true;
        }
        
        sum *= A;
    }
    
    if(check == true){
        cout << -1 << endl;
    }
    else{
        cout << sum << endl;
    }
}


Measured memory_bytes: 3124
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define show(x) cout<<x<<'\n'
#define showh(x) cout<<x<<' '
#define go(i,a,n) for(ll i=a;i<n;i++)
#define gor(i,a,n) for(ll i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define mod 1000000007
bool prime[100001];
bool ispoweroftwo(ll x)
{
    return x && !(x & (x-1));
}
ll xorcal(ll n)
{
    if(n%4==0)
        return n;
    if(n%4==1)
        return 1;
    if(n%4==2)
        return n+1;
    if(n%4==3)
        return 0;
}
void sieve(ll n)
{
    memset(prime,true,sizeof(prime));
    prime[0]=false;
    prime[1]=false;
    for(ll i=2;i*i<=n;i++)
    {
        if(prime[i]==true)
        {
            for(ll j=i*i;j<=n;j+=i)
            {
                prime[j]=false;
            }
        }
    }
    show(prime[89]);
}
bool isprime(ll n)
{
    if (n<=1) return false;
    if (n<=3) return true;

    if(n%2==0 or n%3==0) return false;

    for(ll i=5;i*i<=n;i+=6)
    {
        if(n%i==0 or n%(i+2)==0) return false;
    }
    return true;
}

ll modinverse(ll a,ll m)
{
    ll m0 = m;
    ll y = 0, x = 1;

    if (m == 1)
      return 0;

    while (a > 1)
    {
        ll q = a / m;
        ll t = m;

        m = a % m; a = t;
        t = y;

        y = x - q * y;
        x = t;
    }

    if (x < 0)
       x += m0;

    return x;
}

ll gcd(ll a,ll b)
{
    if(a==0)
    {
        return b;
    }
    return(b%a,a);
}

ll power(ll A, ll B)
{
    if (A == 0)
        return 0;
    if (B == 0)
        return 1;

    ll y;
    if (B % 2 == 0) {
        y = power(A, B / 2);
        y = (y * y) % mod;
    }

    else {
        y = A % mod;
        y = (y * power(A, B - 1) % mod) % mod;
    }

    return (ll)((y + mod) % mod);
}
int main()
{
    ios_base::sync_with_stdio(false);
    ll n;
    cin>>n;
    ll a[n];
    go(i,0,n)
    {
        cin>>a[i];
    }
    ll count=0,len=INT_MIN,k=0;
    go(i,1,n)
    {
        if(a[i]<=a[i-1])
        {
            k++;
        }
        else
        {
            len=max(len,k);
            k=0;
        }
    }
    len=max(len,k);
    show(len);
    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
using namespace std;
int main(void){
    // Your code here!
    int a,b,c,d;
    scanf("%d %d %d",&a,&b,&c);

if(a>b){d=b;b=a;a=d;}
if(b>c){d=c;c=b;b=d;}
if(a>b){d=b;b=a;a=d;}
printf("%d %d %d\n",a,b,c);
}


Measured memory_bytes: 2744
h, w = gets.chomp.split.map(&:to_i)
c = Array.new(10) { gets.chomp.split.map(&:to_i) }
hs = Hash.new(0)

h.times do
  ai = gets.chomp.split.map(&:to_i)
  w.times do |j|
    hs[ai[j]] += 1
  end
end

10.times do |k|
  10.times do |i|
    10.times do |j|
      if c[i][j] > c[i][k] + c[k][j]
        c[i][j] = c[i][k] + c[k][j]
      end
    end
  end
end

res = 0
(0..9).each do |u|
  res += hs[u] * c[u][1]
end
puts res

Measured memory_bytes: 14308
#include <bits/stdc++.h>
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(v) (v).begin(),(v).end()
#define pb push_back

typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef pair<ll,ll> pll;
typedef vector<pint> vpint;


int main(){
        int n,m;
        cin>>n>>m;
        vector<pint> vec(n);
        rep(i,n){
            cin>>vec[i].first>>vec[i].second;
        }
        sort(all(vec));
        ll money=0;
        int count=m;
        rep(i,n){
            ll buy_num=min(count,vec[i].second);
            ll price=vec[i].first;
            money+=ll(price*buy_num);
            count-=buy_num;
        }
        cout<<money<<endl;

    return 0;
}

Measured memory_bytes: 1024
import java.io.*;
import java.util.*;
public class Main{
    public static void main(String[] args) throws IOException{
        MyReader r = new MyReader();     
        int N = r.i();
        ArrayList<Integer> list = new ArrayList<>(N);
        list.add(r.i());
        for(int i = 1; i < N; i++){
            int k = r.i();
            int id = binarySearch(list, k);
            if(id == -1){
                list.add(0, k);
            }
            else 
                list.set(id, k);
        }
        println(list.size());
    }
    static int binarySearch(ArrayList<Integer> list, int key){
        if(key <= list.get(0))
            return -1;
        if(list.size() == 1)
            return 0;
        int l = 0;
        int r = list.size()-1;
        int m = -1;
        while(l+1<r){            
            m = (l+r)/2;
            int a = list.get(m);
            if(key <= a){
                r = m;
            } else{
                l = m;
            }
        }
        if(m == -1){
            return list.get(1) < key ? 1 : 0; 
        }
        return list.get(r) < key ? r : l;
    }
    static void print(Object o){
        System.out.print(o.toString());
    }
    static void println(Object o){
        System.out.println(o.toString());
    }
    static int Int(String s){
        return Integer.parseInt(s);
    }
    static long Long(String s){
        return Long.parseLong(s);
    }
    static class MyReader extends BufferedReader{
        MyReader(){
            super(new InputStreamReader(System.in));
        }
        String s() throws IOException{
            return readLine();
        }
        String[] ss() throws IOException{
            return s().split(" ");
        }
        int i() throws IOException{
            return Int(s());
        }
        int[] ii() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            int[] ii = new int[size];
            for(int j = 0; j < size; j++) ii[j] = Integer.parseInt(ss[j]);
            return ii;
        }
        long l() throws IOException{
            return Long(s());
        }
        long[] ll() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            long[] ll = new long[size];
            for(int j = 0; j < size; j++) ll[j] = Long.parseLong(ss[j]);            
            return ll;
        }
    }
}

Measured memory_bytes: 32888
#include <bits/stdc++.h>
using namespace std;


int main(){
  int n;
  cin >> n;

  vector<int> h(n);
  for(int i = 0; i < n; i++){
    cin >> h.at(i);
  }

  int sea_count = 0;
  for(int i = 0; i < n; i++){
    bool sea_flag = true;

    for(int j = 0; j < i; j++){
      if(h.at(i) < h.at(j))
        sea_flag = false;
    }

    if(sea_flag)
      sea_count +=1;
  }

  cout << sea_count << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a[100001];
int main()
{
	int n,i,k,minn=INT_MAX;
	scanf("%d %d",&n,&k);
	for(i=1;i<=n;i++)
		scanf("%d",&a[i]);
	sort(a+1,a+1+n);
	for(i=1;i<=n-k+1;i++)
		minn=min(minn,a[i+k-1]-a[i]);
	printf("%d",minn);
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include<string>
#include<cmath>
#include<stack>
#include <vector>
#include<queue>
#include <random>
#include <cstdint>
#include <bitset>
#include <iomanip>
#include<utility>
using namespace std;
using ll = long long;




int main()
{
	int n, c, d[30][30], g[3][30],ans=INT32_MAX;
	fill(g[0], g[3], 0);
	cin >> n >> c;
	for (int i = 0; i < c; i++) {
		for (int j = 0; j < c; j++) {
			cin >> d[i][j];
		}
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			int a;
			cin >> a;
			g[((i + j) % 3)][a - 1]++;
		}
	}
	for (int i = 0; i < c; i++) {
		for (int j = 0; j < c; j++) {
			if (i == j)continue;
			for (int k = 0; k < c; k++) {
				if (k == i || k == j)continue;
				int sum = 0;
				for (int l = 0; l < c; l++) {
					sum += (g[0][l] * d[l][i] + g[1][l] * d[l][j] + g[2][l] * d[l][k]);
				}
				ans = min(ans, sum);
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>

//#define DEBUG

using namespace std;

template <class T>
void print_vect(std::vector<T> v){
    for(int i = 0 ; i < v .size(); i++) cout << v[i] << " ";
    cout << endl;
}


void func_to_create(){
    uint32_t S, W;
    cin >> S >> W;
    if ( W < S){
        cout << "safe" << endl;
    }else{
        cout << "unsafe" << endl;
    }
}
int main()
{
    //making data IO Fast
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);
    /****************************/

    #ifdef DEBUG
    int TEST_CASES = 3;
    while(TEST_CASES--){
    #endif // DEBBUG

    func_to_create();

    #ifdef DEBUG
    }
    #endif // DEBUG
    
    return 0;
}


Measured memory_bytes: 3636
//#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"

#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
typedef long long ll;

using namespace std;

ll modpow(ll a, ll n) {
	ll res=1;
	while (n > 0) {
		if (n & 1) res = res * a % MOD;
		a = a * a % MOD;
		n = n >> 1;
	}
	return res;
}




ll ncr(ll n, ll k) {
	if (n < k) return 0;
	if (k < 0) return 0;
	if (k > n / 2) return ncr(n, n - k);
	//cout << n << " " << k<< endl ;
	ll res=1;
	rep(i, k){
		res = res * (n - i) % MOD;
		res = res * modpow(k - i, MOD - 2)%MOD;
	}
	return res;
}

int main(void) {
	ll x, y;
	cin >> x >> y;
	if ((x + y) % 3 != 0) {
		cout << 0;
		exit(0);
	}
	ll n = (x + y) / 3;
	ll k1 = x - n;
	cout << ncr(n,k1) << endl;
}

Measured memory_bytes: 256
import sys
input=sys.stdin.readline
w,h=map(int,input().split())

L=[]

for i in range(w):
    n=int(input())
    L.append([n,0])
    
for i in range(h):
    n=int(input())
    L.append([n,1])
    
L.sort()

ans=0
for i in range(len(L)):
    if L[i][1]==0:
        ans+=L[i][0]*(h+1)
        w-=1
    else:
        ans+=L[i][0]*(w+1)
        h-=1
print(ans)

Measured memory_bytes: 69232
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

#define         pb         push_back
#define         sf(x)      scanf("%d",&x)
#define         sfl(x)     scanf("%lld",&x)
#define         pf(x)      printf("%d\n",x)
#define         pfl(x)     printf("%lld\n",x)
#define         endl       '\n'
#define         pii        pair<int,int>
#define         mapii      map<int,int>
#define         mapll      map<ll,ll>
#define         mapci      map<char,int>
#define         mapcl      map<char,ll>
#define         mapsi      map<string,int>
#define         mapsl      map<string,ll>
#define         pll        pair<ll,ll>
#define         vi         vector<int>
#define         vl         vector<ll>
#define         vd         vector<double,double>
#define         all(c)     c.begin(),c.end()
#define         F          first
#define         S          second
#define         mp         make_pair
#define        ftc(x)      cerr << #x << ": " << x << " " << endl;
#define         PI         acos(-1)
#define         lcm(a,b)   ((a*b)/__gcd(a,b))
#define        optimize    ios_base::sync_with_stdio(false);cin.tie(NULL);


int main()
{
    int tst;

   // cin >> tst;

    tst = 1;

    while(tst--)
    {
        ll i,j,k,l,m,n,a,b,c;
        string s;

      //  ll cnt = 0;
        cin >> n ;

        if(n==1)cout<<0<<endl;
        else cout << 1 << endl;
    }
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;

int main() {
    int64_t N, K;
    cin >> N >> K;
    vector<int64_t> A(N);
    for (int64_t& a : A) {
        cin >> a;
        a--;
    }

    vector<int64_t> pre_visit(N, -1);
    int64_t curr_turn = 0, curr_pos = 0;
    bool check_loop = true;
    while (curr_turn < K) {
        if (check_loop && pre_visit[curr_pos] != -1) {
            //ループした
            int64_t period = curr_turn - pre_visit[curr_pos];

            int64_t remained = K - curr_turn;
            curr_turn += remained / period * period;

            check_loop = false;
            continue;
        }

        pre_visit[curr_pos] = curr_turn++;
        curr_pos = A[curr_pos];
    }

    cout << curr_pos + 1 << endl;
}

Measured memory_bytes: 6428
#include <bits/stdc++.h>

using namespace std;

#pragma GCC optimize "-O3"

#define watch(x) cout << (#x) << " is " << (x) << endl

#define rep(i,a,b)  for(lli i=a;i<b;i++)
#define repd(i,a,b) for(lli i=a-1;i>=b;i--)
#define nl          cout<<endl;
#define test()      lli t;cin>>t;while(t--)
#define sp(n)       setprecision(n)

#define lli     long long int
#define ulli    unsigned long long int
#define ld      long double
#define uld     unsigned long double
#define S       string
#define C       char
#define elif    else if

#define pb      push_back
#define pp      pop_back
#define mp      make_pair
#define plli    pair<lli,lli>
#define vlli    vector<lli>
#define vulli   vector<ulli>
#define vld     vector<ld>
#define vs      vector<string>

#define bs      binary_search
#define ub      upper_bound
#define lb      lower_bound

#define vsort(v) sort(v.begin(),v.end())

#define max1 1000001    //10^6 + 1
#define max2 10000001   //10^7 + 1
#define max3 1000000007 //10^9 + 7
#define inf  1000000009 //10^9 + 9


int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);

    lli n,k;;
    cin>>n>>k;;
    lli h[n+1];
    rep(i,1,n+1)
    {
        cin>>h[i];

    }
    lli c[n+1]={0};
    c[1]=0;
    c[2]=abs(h[2]-h[1]);

    rep(i,3,n+1)
    {
        lli z=max3;
        rep(j,1,k+1)
        {
            if(i-j<1)
                break;
            z=min(z,c[i-j]+abs(h[i-j]-h[i]));

        }
        c[i]=z;

    }

    cout<<c[n];
    nl;;

    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,l,r) for(int (i)=(l);(i)<(r);(i)++)
#define ll long long
using namespace std;
int main(){
    ll x,y,a,b,c;
    cin>>x>>y>>a>>b>>c;
    priority_queue<ll> p,q,r;
    rep(i,0,a){
        ll d;
        cin>>d;
        p.push(d);
    }
    rep(i,0,b){
        ll d;
        cin>>d;
        q.push(d);
    }
    rep(i,0,c){
        ll d;
        cin>>d;
        r.push(d);
    }
    rep(i,0,x){
        r.push(p.top());
        p.pop();
    }
    rep(i,0,y){
        r.push(q.top());
        q.pop();
    }
    ll ans=0;
    rep(i,0,x+y){
        ans+=r.top();
        r.pop();
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 7792
#include <bits/stdc++.h>
using namespace std;

int main()
{
  string s;
  cin >> s;
  string a = s;
  reverse(a.begin(), a.end());

  string b = s.substr(0, (s.size() - 1) / 2);
  string c = b;
  reverse(c.begin(), c.end());

  string d = s.substr((s.size() + 2) / 2, s.size());
  string e = d;
  reverse(e.begin(), e.end());

  if (a == s)
  {
    if (c == b)
    {
      if (e == d)
      {
        cout << "Yes" << endl;
      }
      else
      {
        cout << "No" << endl;
      }
    }
    else
    {
      cout << "No" << endl;
    }
  }
  else
  {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
N = int(input())
list = []
cities = []
for i in range(N):
    L, R = input().split()
    list.append([L,int(R),i+1])
    cities.append(L)
li = []
for i in cities:
    if i in li:
        pass
    else:
        li.append(i)
li.sort()
cata = []
for i in li:
    cur_i = []
    for j in list:
        if j[0] == i:
            cur_i.append(j[1:3])
    cata.append(cur_i)
anslist = []
for i in cata:
    i.sort(reverse=True,key=lambda x: x[0])
    for j in i:
        anslist.append(j[1])
for i in anslist:
    print(i)

Measured memory_bytes: 3064
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#define MAXN 100000
using namespace std;
int N;
int a[MAXN+5];
int main()
{
	scanf("%d",&N);
	int sum=0;
	a[1]=0;
	a[N+2]=0;
	for(int i=2;i<=N+1;i++)
		scanf("%d",&a[i]);
	N+=2;
	for(int i=1;i<=N;i++)
		sum+=abs(a[i]-a[i-1]);
	for(int i=2;i<=N-1;i++)
		printf("%d\n",sum-abs(a[i]-a[i-1])-abs(a[i+1]-a[i])+abs(a[i+1]-a[i-1]));
	return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;
using vs = vector<string>;
using vb = vector<bool>;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
template<class T> inline void prn(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << ' ';}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printvv(vector<vector<T>>& v) {for (auto u : v) printv(u);}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

map<ll, ll> prime_factorization(ll n) {
    map<ll, ll> m;
    ll x = n;
    ll d = 2;
    while (x > 1 && d * d <= n) {
        if (x % d == 0) {
            m[d]++;
            x /= d;
        } else {
            d++;
        }
    }
    if (x != 1) m[x]++;
    return m;
}

void solve() {
    int n;
    cin >> n;
    string s;
    map<pair<int, int>, ll> m;
    REP(i, n) {
        cin >> s;
        auto p = s.find('.');
        ll l;
        if (p == string::npos) {
            l = stoll(s) * 1000000000;
        } else {
            auto t = s.substr(0, p) + s.substr(p + 1);
            l = stoll(t) * (ll)pow(10, 9 - (sz(s) - p - 1));
        }
        int two = 0;
        while (l % 2 == 0) {
            two++;
            l /= 2;
        }
        int five = 0;
        while (l % 5 == 0) {
            five++;
            l /= 5;
        }
        m[make_pair(two, five)]++;
    }

    ll ans = 0;
    for (auto e : m) {
        for (auto f : m) {
            if (e.first.first + f.first.first >= 18 and e.first.second + f.first.second >= 18) {
                if (e.first == f.first) {
                    ans += e.second * (e.second - 1);
                } else {
                    ans += e.second * f.second;
                }
            }
        }
    }
    cout << ans / 2 << endl;
}


Measured memory_bytes: 4092
#include <bits/stdc++.h>
using namespace std;

#define lli long long int
#define pb push_back

int main ()
{
    ios_base::sync_with_stdio(false) ; 
    cin.tie(NULL) ;

    int n ;
    cin >> n ;
    vector <int> v ;

    v.pb(1);
    v.pb(1);
    v.pb(1);
    v.pb(2);
    v.pb(1);
    v.pb(2);
    v.pb(1);
    v.pb(5);
    v.pb(2);
    v.pb(2);
    v.pb(1);
    v.pb(5);
    v.pb(1);
    v.pb(2);
    v.pb(1);
    v.pb(14);
    v.pb(1);
    v.pb(5);
    v.pb(1);
    v.pb(5);
    v.pb(2);
    v.pb(2);
    v.pb(1);
    v.pb(15);
    v.pb(2);
    v.pb(2);
    v.pb(5);
    v.pb(4);
    v.pb(1);
    v.pb(4);
    v.pb(1);
    v.pb(51);

    cout << v[n - 1] << endl ;
    
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


std::vector<std::vector<std::pair<int, int>>> G;

long long a[111111];


void dfs(int i)
{
  for (const auto& e : G[i]) {
    long long x = a[i] + e.second;
        
    if (a[e.first] == -INF) {
      a[e.first] = x;

      dfs(e.first);
    }
    else if (a[e.first] != x) {
      std::cout << "No" << std::endl;
        
      exit(0);
    }
  }
}


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);

  int N, M, L, R, D;

  std::cin >> N >> M;

  G.resize(N);

  for (int i = 0; i < M; i ++) {
    std::cin >> L >> R >> D;

    L --;
    R --;

    G[L].emplace_back(R,  D);
    G[R].emplace_back(L, -D);
  }

  std::fill(a, a + N, -INF);

  for (int i = 0; i < N; i ++) {
    if (a[i] != -INF)
      continue;
  
    a[i] = 0;

    dfs(i);
  }

  std::cout << "Yes" << std::endl;

  return 0;
}


Measured memory_bytes: 12416
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a=sc.nextInt();
    int b=sc.nextInt();
    int area=a*b;
    int length=2*(a+b);
    System.out.println(area+" "+length);
    sc.close();
  }
}


Measured memory_bytes: 26272
// Last Change: 01/10/2020 21:06:08.
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

int main() {
  ll K, X;
  cin >> K >> X;
  if (500 * K >= X) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
 
typedef vector<int> vi;
typedef vector<double> vd;
 
double mypow(double b ,int e){
      if(e == 0) return 1;
      if(e%2==0)
            return mypow( b*b, e/2 );
      else
            return mypow( b*b, e/2 ) * b;
}
 
int main(){
 
 
      int N,M,L; cin >> N >> M >> L ;
      if(N==1){
            cout << 1.0 << endl;
            return 0;
      }
      vector<vd> prob(N,vd(M+1,0.0));
      vector<vd> dist(N,vd(M+1,0.0));
 
      vd p(N),t(N),v(N);
      for(int i=0; i<N; i++) cin >> p[i] >> t[i] >> v[i];
 
      // PRE PROCESS
      for(int i=0; i<N; i++){
            dist[i][0] = (double)L / v[i];
            for(int j=1; j<=M; j++){
                  dist[i][j] = dist[i][j-1] + t[i];
            }
      }
      for(int i=0; i<N; i++)
            prob[i][0] = mypow((100-p[i])/100,M);
      for(int i=0; i<N; i++){
            for(int j=1; j<=M; j++){
                  if(p[i] != 100)
                        prob[i][j] = (prob[i][j-1] * (p[i]/100)) / ((100-p[i])/100);
                  else
                        prob[i][j] = 1.0;
            }
      }
      double comb = 1;
      for(int j=1; j<=M; j++){
            comb = comb * (M - j + 1) / j; 
            for(int i=0; i<N; i++){
                  prob[i][j] *= comb;
            }
      }
       
      vector<vd> sum = prob;
      for(int i=0; i<N; i++){
            for(int j=M-1; j>=0; j--){
                  sum[i][j] += sum[i][j+1];
                  if(sum[i][j] > 1) sum[i][j] = 1;
            }
      }
 
      vector<vd> ans = prob;
      for(int i=0; i<N; i++){
            for(int j=0; j<=M; j++){
                  for(int k=0; k<N; k++){
                        if(i==k) continue;
                        int id = upper_bound(dist[k].begin(),dist[k].end(), dist[i][j]) - dist[k].begin();
                        if(id > M) ans[i][j] = 0.0;
                        else       ans[i][j] *= sum[k][id];
 
                  }
            }
      }
 
      for(int i=0; i<N; i++){
            double tmp = 0.0;
            if(p[i] == 100) tmp = ans[i][M];
            else
                  for(int j=0; j<=M; j++)
                        tmp += ans[i][j];
            if(tmp > 1) tmp = 0;
            printf("%.10f\n",tmp);
      }
                         
}

Measured memory_bytes: 3348
#include<bits/stdc++.h>
#define rep(i,m) for(long long i=0; i<m; i++)
#define per(i,m) for(long long i=m-1; i>=0; i--)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define ROF(i,n,m) for(long long i=n-1; i>=m; i--)
#define SORT(v,n) do{sort(v,v+n);reverse(v,v+n);}while(0)
#define all(x) (x).begin(),(x).end()
#define EPS (1e-7)
#define INF (1e18)
#define PI (acos(-1))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
typedef pair<ll, ll> LP;

ll POW(ll x,ll n){
  if(n==0)return 1;
  if(n%2==0)return POW(x*x%MOD,n/2);
  return x*POW(x,n-1)%MOD;
}

ll gcd(ll u, ll v) {
  ll r;
  while (0 != v) {
    r = u % v; u = v; v = r;
  }
  return u;
}
 
ll KAI(ll m)
{
  if(m<0) return 0;
  if(m==0) return 1;
  return m*KAI(m-1)%MOD;
}
 
ll extGCD(ll a, ll b, ll &x, ll &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll d = extGCD(b, a%b, y, x);
    y -= a / b * x;
    return d;
}
 
inline ll mod(ll a, ll m) {
    return (a % m + m) % m;
}
 
ll modinv(ll a) {
    ll x, y;
    extGCD(a, MOD, x, y);
    return mod(x, MOD);
}
 
ll COM(ll m,ll n)
{
  if(m<n) return 0;
  if(n<0) return 0;
  if(n==0) return 1;
  if(m==n) return 1;
  return KAI(m)%MOD*modinv(KAI(n)%MOD*KAI(m-n)%MOD)%MOD;
}

ll DEC(ll x,ll m,ll n)
{
  return x%POW(m,n+1)/POW(m,n);
}

ll keta(ll x,ll n)
{
  if(x==0)return 0;
  return keta(x/n,n)+1;
}

ll DIV(ll x,ll n)
{
  if(x==0)return 0;
  return x/n+DIV(x/n,n);
}

ll ORD(ll x,ll n)
{
  if(x==0)return INF;
  if(x%n!=0)return 0;
  return 1+ORD(x/n,n);
}

int main()
{
  ll n,k,l[2300],ans;
  cin >> n >> k;
  ans=0;
  rep(i,n)cin >> l[i];
  SORT(l,n);
  rep(i,k)ans+=l[i];
  printf("%lld",ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(a) a.begin(), a.end()
#define P pair<int, int>
#define F first
#define S second
#define mod 1000000007
#define MOD 998244353
#define INF 40000000000000000
int dx8[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
int dy8[8] = {1, 1, 1, 0, -1, -1, -1, 0};
int dx4[4] = {-1, 0, 1, 0};
int dy4[4] = {0, -1, 0, 1};
signed main(void) {
    int A, B, M;
    cin >> A >> B >> M;
    vector<int> a(A), b(B);
    rep(i, A) cin >> a[i];
    rep(i, B) cin >> b[i];
    int ans = INF;
    rep(i, M) {
        int x, y, c;
        cin >> x >> y >> c;
        ans = min(ans, a[x - 1] + b[y - 1] - c);
    }
    sort(all(a)), sort(all(b));
    ans = min(ans, a[0] + b[0]);
    cout << ans << endl;
}


Measured memory_bytes: 1792