akhauriyash/Code-Regression huggingface dataset:
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i=(n); i>=0; --i)
#define FOR(i, n, m) for(int i=(m), i##_len=(n); i<i##_len; ++i)
#define FOREACH(i, v) for(const auto& i : v)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define SIGN(x) (((x)>0)?1:(((x)<0)?-1:0))
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
#define vv(t) vector< t > 
#define CHC(mp, x) if(mp.end() != mp.find(x))
#define CHCV(mp, x) if(mp.end() != find(ALL(mp), x))
template<typename T>
inline T lcm(T a, T b) {return a / __gcd(a, b) * b;}
#define fi first
#define se second
#define el endl
#pragma endregion

const string YES = "YES";
const string NO = "NO";

void Main();
void solve();

int main(){
    std::cin.tie(nullptr);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}

void Main(){
    int H, W;
    cin >> H >> W;
    vv(string) S(H+1);
    REP(i, H){
        cin >> S[i];
        S[i] += " ";
    }
    vv(vv(int)) DP(H+1, vv(int)(W+1, INT_MAX));
    DP[0][0] = 0;
    if(S[0][0]=='#'){
        DP[0][0] = 1;
    }
    REP(i, H){
        REP(j, W){
            int t=0;
            if(S[i][j]=='.'){
                if(S[i+1][j]=='#'){
                    DP[i+1][j] = DP[i][j]+1;
                }else{
                    DP[i+1][j] = DP[i][j];
                }
                if(S[i][j+1]=='#'){
                    chmin(DP[i][j+1], DP[i][j]+1);
                }else{
                    chmin(DP[i][j+1], DP[i][j]);
                }
            }else{
                DP[i+1][j] = DP[i][j];
                chmin(DP[i][j+1], DP[i][j]);
            }
        }
    }
    cout << DP[H-1][W-1] << el;
}



Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
const int inf=1e9;
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
ll gcd(ll a,ll b){
	return (b==0?a:gcd(b,a%b));
}
ll lcm(ll a,ll b){
	return a/gcd(a,b)*b;
}
int main(){
	int n;
	while(cin>>n,n){
		vi a(n),b(n);
		rep(i,n)cin>>a[i]>>b[i];
		rep(i,n){
			ll t=gcd(a[i],b[i]);
			a[i]/=t;b[i]/=t;
		}
		ll g=b[0],l=a[0];
		loop(i,1,n){
			g=gcd(g,b[i]);
			l=lcm(l,a[i]);
		}
		rep(i,n)cout<<l/a[i]*(b[i]/g)<<endl;;
	}
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

#define CHMIN(a, b) a=min((a), (b))
#define CHMAX(a, b) a=max((a), (b))

const ll MOD=1000000007ll;
// const ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

bool used[5];
bool g[5][5];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int a[5], b[5];
	REP(i, 3){
		cin>>a[i]>>b[i];
		--a[i];
		--b[i];
		g[a[i]][b[i]]=g[b[i]][a[i]]=true;
	}

	REP(i, 4){
		REP(j, 4){
			used[j]=false;
		}
		used[i]=true;
		int now=i;
		REP(i, 3){
			REP(j, 4){
				if(g[now][j] && !used[j]){
					now=j;
					used[now]=true;
					break;
				}
			}
		}
		bool ok=true;
		REP(i, 4){
			if(!used[i]){
				ok=false;
				break;
			}
		}
		if(ok){
			cout<<"YES"<<'\n';
			return 0;
		}
	}
	cout<<"NO"<<'\n';
	return 0;
}


Measured memory_bytes: 256
strcmp();char s[5010],t[50000][6];i;j;k;l;main(m){for(gets(s);s[i];++i)for(j=5;j--;)memcpy(t[k++],s+i,j+1);qsort(t,k,6,strcmp);for(scanf("%d",&i);l<i;)strcmp(t[m++],t[m-1])&&l++;puts(t[m-2]);}

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

typedef struct{
    long x;
    long y;
    char c;
} wish_t;

long calc(const vector<long>& s, long M, long x, long y, long w, long h){
    return s[(x+w)+(y+h)*M] - s[(x+w)+y*M] - s[x+(y+h)*M] + s[x+y*M];
}

int main(void){
    long n, k;
    cin >> n >> k;
    vector<wish_t> w(n);
    for(long i=0; i<n; i++){
        cin >> w[i].x >> w[i].y >> w[i].c;
    }
    vector<long> b(4*k*k);
    fill(b.begin(), b.end(), 0);
    for(long i=0; i<n; i++){
        if(w[i].c=='W'){
            w[i].x += k;
            w[i].c = 'B';
        }
        w[i].y %= 2*k;
        if(w[i].y>=k){
            w[i].y-=k;
            w[i].x+=k;
        }
        w[i].x %= 2*k;
        b[w[i].x+w[i].y*2*k]++;
    }
    /*
    for(long y=0; y<2*k; y++){
        for(long x=0; x<2*k; x++){
            cout << b[x+y*2*k] << " ";
        }
        cout << endl;
    }
    cout << endl;
    */
    const long M = 2*k+1;
    vector<long> s((2*k+1)*(2*k+1));
    fill(s.begin(), s.end(), 0);
    s[1+1*M] = b[0];
    for(long i=1; i<2*k; i++){
        s[(i+1)+1*M] = s[(i-1+1)+1*M] + b[i];
    }
    for(long i=1; i<2*k; i++){
        s[1+(i+1)*M] = s[1+(i-1+1)*M] + b[2*k*i];
    }
    for(long x=1; x<2*k; x++){
        for(long y=1; y<2*k; y++){
            s[x+1+(y+1)*M] = b[x+y*2*k] + s[(x-1+1)+(y+1)*M] + s[x+1+(y-1+1)*M] - s[(x-1+1)+(y-1+1)*M];
        }
    }
    /*
    for(long y=1; y<M; y++){
        for(long x=1; x<M; x++){
            cout << s[x+y*M] << " ";
        }
        cout << endl;
    }
    cout << endl;
    */
    long max = 0;
    for(long x=0; x<k; x++){
        for(long y=0; y<k; y++){
            //long t = s[(x+k)+(y+k)*M] - s[(x+k)+y*M] - s[x+(y+k)*M] + s[x+y*M];
            long t = calc(s, M, x, y, k, k);
            t += calc(s, M, 0, 0, x, y);
            t += calc(s, M, x+k, 0, k-x, y);
            t += calc(s, M, 0, y+k, x, k-y);
            t += calc(s, M, x+k, y+k, k-x, k-y);
            t = t<n/2 ? n-t : t;
            //printf("%ld %ld %ld\n", x, y, t);
            max = t>max ? t : max;
        }
    }
    cout << max;
    return 0;
}


Measured memory_bytes: 65152
#include <bits/stdc++.h>
using namespace std;
typedef unsigned int uint;
typedef long long int lint;
typedef unsigned long long int ulint;

//#define DEBUG

#ifdef DEBUG
#	define dump(i) cout << "[*] " #i " : " << i << endl;
#	define debug(i) i
#else
#	define dump(i)
#	define debug(i)
#endif
#define rep(i, MAX) for (int i = 0; i < (MAX); ++i)

inline void solve() {
	bool a[300001];
	memset(a, -1, sizeof(a));
	a[0] = a[1] = a[2] = a[3] = a[4] = a[5] = false;
	for (int i = 6; i < 300001; ++i) {
		if (a[i]) {
			if (i % 7 == 1 || i % 7 == 6) {
				for (int j = 2; j * i < 300001; ++j) {
					a[i * j] = false;
				}
			} else {
				a[i] = false;
			}
		}
	}
	int in;
	while (true) {
		cin >> in;
		if (in == 1) break;

		cout << in << ":";
		for (int i = 6; i <= in; ++i) {
			if (a[i] && in % i == 0) {
				cout << " " << i;
			}
		}
		cout << endl;
	}
}

int main() {
	//*
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	// */
#ifdef DEBUG
	const auto start = chrono::high_resolution_clock::now();
#endif
	solve();
#ifdef DEBUG
	const auto stop = chrono::high_resolution_clock::now();
	cerr << "[*] time: " << chrono::duration_cast<chrono::milliseconds>(stop-start).count()
		<< " [ms]" << endl;
#endif
	return 0;
}



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


int main()
{
	std::ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    long test=1;
	
	while(test--)
	{
	    long long A,B,a,b,c=0,k,d=0,i,n,j,temp,p,m,tx,ty,x,y,dx,dy;
	    cin>>x>>y>>tx>>ty;
	    dx=tx-x;
	    dy=ty-y;
	    for(i=0;i<dy;i++)
	    cout<<"U";
	    for(i=0;i<dx;i++)
	    cout<<"R";
	    for(i=0;i<dy;i++)
	    cout<<"D";
	    for(i=0;i<dx;i++)
	    cout<<"L";
	    
	    cout<<"L";
	    for(i=0;i<dy+1;i++)
	    cout<<"U";
	    for(i=0;i<dx+1;i++)
	    cout<<"R";
	    cout<<"DR";
	    for(i=0;i<dy+1;i++)
	    cout<<"D";
	    for(i=0;i<dx+1;i++)
	    cout<<"L";
	    cout<<"U";
    
}
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
  int n,r,p,c;
  int i,j,k,l;
  int a[51],b[51];

  while( 1 ){
    scanf("%d %d ",&n,&r);
    if( !n && !r )
      break;

    for( i=0;i<n;i++)
      a[i]=i+1;

    for( i=0;i<r;i++){
      scanf("%d %d ",&p,&c );

      //      printf("p=%d c=%d\n",p,c);

      for( j=0;j<c;j++)
	b[j] = a[n-p-c+1+j];    
      for( j=0;j<p-1;j++)
	a[n-p-c+1+j] = a[n-p+j+1];
      for( j=n-p-c+1+j,k=0;k<c;j++,k++){
	//printf("b[%2d] = %d\n",k,b[k]);
	a[j] = b[k];
      }

      /*
      for( j=0;j<n;j++)
	printf("%d\n",a[j]);
      printf("---\n");
      */

    }
    printf("%d\n",a[n-1]);
  }
  return 0;
}

Measured memory_bytes: 0
import java.util.*;

// ARC 82-D
// https://beta.atcoder.jp/contests/arc082/tasks/arc082_b

public class Main {
	
	public static void main (String[] args) {
		Scanner in = new Scanner(System.in);
		
		int N = in.nextInt();
		ArrayList<Long> nums = new ArrayList<Long>();
		HashMap<Long, Integer> count = new HashMap<Long, Integer>();
		
		for (int i = 0; i < N; i++) {
			long n = in.nextLong();
			
			if (count.containsKey(n)) {
				int c = count.get(n);
				count.put(n, c + 1);
			} else {
				count.put(n, 1);
				nums.add(n);
			}
		}
		
		nums.sort(null);
		
		long largest = -1;
		long secondLargest = -1;
		
		int index = nums.size() - 1;
		
		while (index >= 0 && (largest == -1 || secondLargest == -1)) {
			long len = nums.get(index);
			int lenCount = count.get(len);
			
			if (lenCount >= 4) {
				if (largest == -1) {
					largest = len;
					secondLargest = len;
				} else {
					secondLargest = len;
				}
			} else if (lenCount >= 2) {
				if (largest == -1) {
					largest = len;
				} else {
					secondLargest = len;
				}
			}
			
			index--;
		}
		
		if (largest != -1 && secondLargest != -1) {
			System.out.println(largest * secondLargest);
		} else {
			System.out.println(0);
		}
	}
}


Measured memory_bytes: 67824
#include "bits/stdc++.h"
using namespace std;
int A[100];
int main() {
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++) scanf("%d",&A[i]);
	printf("%d",A[0]);
	for(int i=1;i<n;i++) printf(" %d",A[i]);
	printf("\n");
	for(int i=1;i<n;i++) {
		int j=i-1;
		int v=A[i];
		while(j>=0&&A[j]>v) {
			A[j+1]=A[j];
			j--;
		}
		A[j+1]=v;
		printf("%d",A[0]);
		for(int i=1;i<n;i++) printf(" %d",A[i]);
		printf("\n");
	}
}

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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

signed main()
{
    int AB, BC, CA;
    cin >> AB >> BC >> CA;
    printf("%lld\n", AB * BC / 2);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void)
{
    long long w,h,x,y;
    cin >> w >> h >> x >> y;

    if(w==x+x&&h==y+y){
        cout << w*h/2.0 << " " << 1;
        return 0;
    }
    else
    {
        cout << w*h/2.0 << " " << 0;
    }

    return 0;
}

Measured memory_bytes: 256
while True:
    n = int(input())
    if not n: break
    cnt = [0]*(60**3+1)
    for i in range(n):
        dep,arr = input().split()
        h,m,s = map(int,dep.split(":"))
        cnt[h*3600+m*60+s] += 1
        h,m,s = map(int,arr.split(":"))
        cnt[h*3600+m*60+s] -= 1
    for i in range(1,60**3+1): cnt[i] += cnt[i-1]
    print(max(cnt))


Measured memory_bytes: 11568
import numpy as np
N, K = map(int, input().split())
ub = K * 2
b = [[0 for j in range(ub + 1)] for i in range(ub + 1)]
ADD = {"B": 0, "W": K}


def create_bound(p, K, ub):
    if p - K + 1 >= 0:
        return [(p - K + 1, p + 1)]
    else:
        return [(0, p + 1), ((p - K + 1) % ub, ub)]


for i in range(N):
    x, y, c = input().split()
    nx = int(x) % ub
    ny = (int(y) + ADD[c]) % ub
    for add in [0, K]:
        for xlb, xub in create_bound((nx + add) % ub, K, ub):
            for ylb, yub in create_bound((ny + add) % ub, K, ub):
                b[xlb][ylb] += 1
                b[xlb][yub] -= 1
                b[xub][ylb] -= 1
                b[xub][yub] += 1

b_arr = np.array(b)
for i in range(ub):
    b_arr[i + 1, :] += b_arr[i, :]
for j in range(ub):
    b_arr[:, j + 1] += b_arr[:, j]
print(b_arr.max())


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

int main() {
  int N;
  cin >> N;
  vector<int> X(N);
  rep(i, N) cin >> X.at(i);
  int mini=1000000;
  
  for(int i=1; i<=100; i++){
    int sum=0;
    
    for(auto e:X){
     sum += (e-i)*(e-i);
      
    }
    mini = min(mini, sum);
  }
  cout << mini << endl;
  return 0;
}




Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define ld double
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> order_set;
const ll mod = 998244353;
const ll N = 1e6 + 5, M = 129;
const ld pi = acos(-1);
    
ll power(ll x, unsigned ll y, ll p)
{
        ll res = 1; 
        x = x % p;
        while (y > 0)
        {
            if (y & 1)
                res = (res*x) % p;
            y = y>>1;
            x = (x*x) % p;  
        }
    return res;
}
    
ll inv[N];
int freq[N] = {0};
    
int main() 
{ 
    FAST;
    //freopen("input.in","r",stdin);
    //freopen("output.out","w",stdout);
    for(int i=1;i<N;i++) {
        inv[i] = power(i, mod - 2, mod);
    }
    int t = 1;
    while(t--) {
        ll n;
        cin >> n;
        ll mx = 0, x, y;
        ll a[n];
        for(int i=0;i<n;i++) {
            cin >> a[i];
            mx = max(mx, a[i]);
        }
        for(int i=0;i<n;i++) {
            freq[a[i]]++;
        }
        ll dp[mx + 1] = {0};
        ll ans = 0;
        for(ll i=mx;i>=1;i--) {
            x = 0;
            y = 0;
            for(ll j=i;j<=mx;j+=i) {
                x += j*freq[j];
                y += dp[j];
            }
            x %= mod;
            y %= mod;
            dp[i] = ((x*x)%mod - y + mod)%mod;
            ans = (ans + (dp[i] * inv[i])%mod)%mod;
        }
        for(ll i=0;i<n;i++) {
            ans = (ans - a[i] + mod)%mod;
        }
        ans = (ans * inv[2])%mod;
        cout << ans << '\n';
    }
    return 0;
}

Measured memory_bytes: 21376
#include <algorithm>
#include <climits>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) FOR(i, n, 0, 1)

// functions
int ceil(int a, int b) {
    return (a + b - 1) / b;
}
int round(int a, int b) {
    return (a + b / 2) / b;
}
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
template <class T> bool amax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if (abs(a - c) <= d) {
        cout << "Yes" << endl;
    } else if (abs(a - b) <= d && abs(b - c) <= d) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int INF=1e7;
int dy[]={-1,0,1,0};
int dx[]={0,1,0,-1};
char t[20][20];
int d[20][20][1024];
int h,w;


void init(){
  for(int i=0;i<20;i++)
    for(int j=0;j<20;j++)
      for(int k=0;k<1024;k++)
        d[i][j][k]=INF;
}

int solve(int sy,int sx,int cnt){
  queue<int> qx,qy,qbit;
  qy.push(sy);
  qx.push(sx);
  qbit.push(0);
  d[sy][sx][0]=0;
  while(!qy.empty()){
    int y=qy.front();qy.pop();
    int x=qx.front();qx.pop();
    int bit=qbit.front();qbit.pop();
    
    if(bit+1 == (1<<cnt)){
      return d[y][x][bit];
    }
    
    
    for(int i=0;i<4;i++){
      int ny=y+dy[i];
      int nx=x+dx[i];
      int nbit=bit;
      if(ny<0||nx<0)continue;
      if(ny>=h||nx>=w)continue;
      if(t[ny][nx]=='x')continue;
      if(t[ny][nx]!='.'){
        int num=t[ny][nx]-'0';
        nbit=nbit|(1<<num);
      }
      int ncost=d[y][x][bit]+1;
      if(ncost < d[ny][nx][nbit]){
        d[ny][nx][nbit]=ncost;
        qy.push(ny);
        qx.push(nx);
        qbit.push(nbit);
      }
    }
  }
  return -1;
}

int main(){
  while(1){
    cin>>w>>h;
    if(w==0&&h==0)break;
    init();
    int cnt=0,si,sj;
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
        cin>>t[i][j];
        if(t[i][j]=='*'){
          t[i][j]='0'+cnt;
          cnt++;
        }
        if(t[i][j]=='o'){
          t[i][j]='.';
          si=i;
          sj=j;
        }
      }
    }
    cout<<solve(si,sj,cnt)<<endl;
  }
  return 0;
}

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

using namespace std;
typedef long long ll;

#define rep(i, n) for(int i=0; i<(n); ++i)

int main(void){
    int n, m;
    int a[101], b[101];
    int ans_a, ans_b;
    bool flag;
    while(cin >> n >> m && n) {
        rep(i, n) scanf("%d", &a[i]);
        rep(i, m) scanf("%d", &b[i]);
        int suma = 0, sumb = 0;
        rep(i, n) suma += a[i];
        rep(i, m) sumb += b[i];
        flag = false;
        int min = numeric_limits<int>::max();
        rep(i, n) {
            rep(j, m) {
                if(suma-sumb == 2*(a[i]-b[j])) {
                    if(min > a[i]+b[j]) {
                        ans_a = a[i];
                        ans_b = b[j];
                        min = a[i]+b[j];
                        flag = true;
                    }
                }
            }
        }
        if(flag) cout << ans_a << " " << ans_b << endl;
        else cout << -1 << endl;
    }
}

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

int main(){
  int N,M;
  cin >> N >> M;
  vector<int> V(M);
  for(int i=0;i<M;i++){
    cin >> V.at(i);
  }
  int P = 0;
  for(int i=0;i<M;i++){
    P += V.at(i);
  }
  if(N-P>=0)
    cout << N-P;
  else
    cout << "-1";
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define endl            "\n"
#define ll				long long int
#define all(v)          v.begin(),v.end()
#define f(n) 			for(int i=0;i<n;i++)
#define fo(n)			for(int j=0;j<n;j++)
#define p(x) 			cout<<x<<"\n"
#define ff 				first
#define ss 				second
#define pb 				push_back
#define mp 				make_pair
#define pii 			pair<int,int>
#define vi 				vector<int>
#define vp 				vector<pii>
#define mii				map<int,int>
#define test            int tt; cin>>tt; while(tt--)
#define mod 			1000000007
#define deb(x)			cout<<#x <<" "<<x<<"\n"
void fastio()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
#ifndef ONLINE_JUDGE
	freopen("ain.txt", "r", stdin);
	freopen("aout.txt", "w", stdout);
#endif
}

int main()
{
	fastio();
	int n;
	cin >> n;
	int a[n];
	f(n)cin >> a[i];
	int dp[n];
	dp[0] = 0;
	dp[1] = abs(a[1] - a[0]);
	for (int i = 2; i < n; i++)
	{
		dp[i] = min(dp[i - 1] + abs(a[i] - a[i - 1]), dp[i - 2] + abs(a[i] - a[i - 2]));

	}
	cout << dp[n - 1];
}



Measured memory_bytes: 4404
#include <bits/stdc++.h>
#define ll long long
#define ls id << 1
#define rs id << 1 | 1
#define mem(array, value, size, type) memset(array, value, ((size) + 5) * sizeof(type))
#define memarray(array, value) memset(array, value, sizeof(array))
#define pb(x) push_back(x)
#define st(x) (1LL << (x))
#define pii pair<int, int>
#define mp(a, b) make_pair((a), (b))
#define Flush fflush(stdout)
using namespace std;
const int N = 500050;
const int inf = 0x3f3f3f3f;
const ll llinf = 0x3f3f3f3f3f3f;
const ll mod = 998244353LL;
clock_t TIME_START, TIME_END;
void program_end()
{
#ifdef ONLINE
    printf("\nTime used: %.6lf(s)\n", ((double)TIME_END - TIME_START) / CLOCKS_PER_SEC);
    system("pause");
#endif
}
ll n;

void solve()
{
    cin >> n;
    cout << (1000 - (n % 1000)) % 1000;
}

int main()
{
    TIME_START = clock();
    int Test = 1;
    // cin >> Test;
    while (Test--)
        solve();
    TIME_END = clock();
    program_end();
    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
int main(){
  double W,H;
  cin >> W >> H;
  ll x,y;
  cin >> x >> y;
  double half = (W * H) / 2;
  double half_x = W / 2;
  double half_y = H / 2;
  bool flag = false;
  if(x==half_x && y==half_y)flag = true;
  cout << half << " " << flag << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;
ll N, A, B;

bool check(ll mid, const vector<ll> &h) {
    ll cnt = 0;
    rep(i, h.size()) {
        ll rest = h[i] - mid * B;
        if(rest > 0)
            cnt += rest / (A - B) + !!(rest % (A - B));
        if(cnt > mid)
            return false;
    }
    return true;
}

int main() {
    cin >> N >> A >> B;
    vector<ll> h(N);
    rep(i, N) cin >> h[i];
    ll l = 0, r = 1e9;
    while(r - l > 1) {
        ll mid = (l + r) / 2;
        if(check(mid, h)) {
            r = mid;
        } else {
            l = mid;
        }
    }
    cout << r << endl;
    return 0;
}

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

#define FOR(i, a, b)  for (int i = (a); i < (b); i++)
#define FORd(i, a, b) for (int i = (a); i >= (b); i--)
#define REP(i, n) FOR(i, 0, n)
#define TRACE(x) cout << #x << " = " << x << "\n"
#define _ << " _ " <<
#define ll long long
#define pil pair <int, ll>
#define pii pair <int, int>

using namespace std;

int arr[100010];
int num[100010];
const int MOD = 1e9 + 7;

int main() {
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  REP(i, n) {
    cin >> arr[i];
    num[arr[i]]++;
    if (num[arr[i]] > 2) {
      cout << 0 << endl;
      return 0;
    }
  }
  if (n % 2 == 1 && num[0] > 1) {
    cout << 0 << endl;
    return 0;
  }

  int out = 1;
  REP(i, n / 2) {
    out *= 2;
    out %= MOD;
  }
  cout << out << endl;

  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);



int main(){
  string s;
  cin >> s;
  REP(i,s.size()){
    if(s[i] == ',') s[i] = ' ';
  }
  cout << s << endl;
  return 0;
}


Measured memory_bytes: 3572
#include <stdio.h>
 
int main(void){
	int  n, k;
	scanf("%d %d", &n, &k);
	char s[n];
	scanf("%s", s);
	s[k-1] = s[k-1] + 32;
 
	for(int i = 0; i < n; ++i){
		printf("%c", s[i]);
	}
 	return 0;
}

Measured memory_bytes: 128
while gets
  a, b, c, d, e, f = $_.chomp.split.map(&:to_f)
  x = (c * e - b * f) / (a * e - b * d)
  y = (c - a * x) / b
  puts "%.3f %.3f" % [x.round(3).zero? ? 0 : x, y.round(3).zero? ? 0 : y]
end

Measured memory_bytes: 6184
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

bool notlike(int x, vector<int> d)
{
  int keta = 0;
  do{
    keta = x % 10;
    auto found = find(d.begin(), d.end(), keta);
    if(found != d.end())
      return true;
    x /= 10;
  }while(x > 0);
  return false;
}

int main(void)
{
  int n, k;
  cin >> n >> k;
  vector<int> d(k, 0);
  for(int i = 0; i < d.size(); i++)
    cin >> d[i];

  int res = n;
  for(res; res <= 111111; res++){
    if(!notlike(res, d))
      break;
  }

  cout << res << endl;

  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <cmath>

using namespace std;

int main()
{
	int X, e, i, j, ans=1;
	cin >> X;

	for (i = 1; i <= X; i++) {
		for (j = 2; j <= X; j++) {
			e = pow(i, j);
			if (e <= X)
				if (ans < e)
					ans = e;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
N = int(input())
hl = list(map(int, input().split()))

dp = [0]*N
for i in range(N):
    if i >= 2:
        dp[i] = min(abs(hl[i] - hl[i-1]) + dp[i-1], abs(hl[i] - hl[i-2]) + dp[i-2])
    elif i == 1:
        dp[i] = abs(hl[i] - hl[i-1])
print(dp[N-1])

Measured memory_bytes: 13928
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
using System.Text.RegularExpressions;

namespace Yuzuki
{
    class Yukari
    {
        public static void Main(string[] args)
        {
            double r = double.Parse(Console.ReadLine());
            Console.WriteLine(r * 2 * PI);
        }
    }
}

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

template<typename M>
struct segment_tree{
	typedef function<M(M, M)> F;
	int size;//2冪
	vector<M> val;//1-indexed
	F f;//結合関数
	M e;//単位元

	segment_tree(int N, vector<M> &data, F f, M e) : f(f), e(e){
		size = 1;
		while(size < N) size *= 2;
		val.assign(2 * size, e);
		for(int i = 0; i < N; i++) val[size + i] = data[i];
		for(int i = N; i < size; i++) val[size + i] = e;
		for(int i = size - 1; i > 0; i--) val[i] = f(val[2 * i], val[2 * i + 1]);
	}

	//k番目の要素をxに変更する
	void update(int k, M x){
		k += size;
		val[k] = x;
		while(k /= 2) val[k] = f(val[2 * k], val[2 * k + 1]);
	}

	//[l, r)の演算の結果を返す
	M query(int l, int r){
		M L = e, R = e;
		for(l += size, r += size; l < r; l /= 2, r /= 2){
			if(l & 1) L = f(L, val[l++]);
			if(r & 1) R = f(val[--r], R);
		}
		return f(L, R);
	}
};


//(int, my_max, -inf)
#define inf (int)(1e9)

int my_max(int x, int y){
	return max(x, y);
}


//(int, my_min, inf)

int my_min(int x, int y){
	return x < y ? x : y;
}


int main(){
	int N, K, i;
	scanf("%d%d", &N, &K);
	vector<int> P(N);
	for(i = 0; i < N; i++){
		scanf("%d", &P[i]);
	}
	segment_tree<int> s_min(N, P, my_min, inf);
	segment_tree<int> s_max(N, P, my_max, -inf);
	int ans = 1;
	int now;
	vector<int> increase(N, 1);
	for(i = 1, now = 1; i < N; i++){
		if(P[i - 1] < P[i]){
			now++;
		}
		else{
			now = 1;
		}
		increase[i] = now;
	}
/*	for(i = 0; i < N; i++){
		printf("increase[%d] = %d\n", i, increase[i]);
	}
*/	int f = 0;
	if(increase[K - 1] >= K){
		f = 1;
	}
	for(i = 1; i + K <= N; i++){
		if(s_min.query(i - 1, i - 1 + K) == P[i - 1] && s_max.query(i, i + K) == P[i + K - 1]){

		}
		else{
			if(increase[i + K - 1] >= K){
				if(f == 0){
					ans++;
					f = 1;
				}
			}
			else{
				ans++;
			}
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 5888
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<iomanip>


using namespace std;
typedef long long ll;
typedef vector<ll> v;
typedef vector<vector<ll>> vv;


#define MOD 1000000007
#define INF 1001001001
#define MIN -1001001001
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back
#define PF push_front
#define all(x) (x).begin(),(x).end()


int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


int main(){
    double A,B,H,W;
    double pi = 3.14159265358979323846;
    cin>>A>>B>>H>>W;
    double X;
    X = A*A+B*B-2*A*B*cos((H/6+W/360 -W/30)*pi);
    cout<<fixed<<setprecision(15)<<sqrt(X);
    return 0;
}

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

int main() {
    long long n, sum = 0;
    cin >> n;
    long long a[n];
    for(int i = 0; i < n; i++)
    {
        cin >> a[i];
        if(i)
        {
            if(a[i] < a[i-1])
            {
                long long diff = (a[i-1] - a[i]);
                sum += diff;
                a[i]+=diff;
            }
        }
    }
    cout << sum;
	return 0;
}

Measured memory_bytes: 5144
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
using lint = long long;

lint eval( lint A, lint B, lint N ){
    lint ans = A*N + B*to_string(N).length();
    return ans;
}

int main(){
    // input
    lint A, B, C;
    cin >> A >> B >> C;

    // Binary search
    bool ans = true;
    if( A+B+C > 21 ) ans = false;

    // output
    printf( ans ? "win" : "bust" );
} 

Measured memory_bytes: 256
#!/usr/bin/env python3

import collections


def summarize(ss):
    ctr = collections.Counter(ss)
    return ctr


def main():
    n = int(input())
    ss = [input() for _ in range(n)]
    ctr = summarize(ss)
    for status in "AC WA TLE RE".split():
        print("{} x {}".format(status, ctr[status]))


if __name__ == '__main__':
    main()

Measured memory_bytes: 16536
#!/usr/bin/env python3

N = int(input().split()[0])
a_list = list(map(int, input().split()))
x_list = []
max_a = 0
for i in range(N):
    a = a_list[i]
    if a == max_a + 1:
        max_a += 1
ans = N - max_a if max_a != 0 else -1
print(ans)


Measured memory_bytes: 24744
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
#include<numeric>
//#include <bits/stdc++.h>
#include<cstring>
#include<iostream>
#include<functional>
using namespace std;

int main() {
	int N;
	cin >> N ;
	vector<int> d(N);
	for (int i = 0; i < N; i++)
		cin >> d[i];
	sort(d.begin(), d.end());
	d.erase(unique(d.begin(), d.end()), d.end());
	cout << d.size() << endl;
	//cin >> N;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
#define FOR(i,k,n) for(int i=(k);i<(n);++i)
#define rep(i,n) for(int i=0;i<(int)(n);++i)

int main(){
    int N;ll H;cin>>N>>H;
    ll a=0LL;
    vector<ll> b(N);
    ll t;
    rep(i,N){
        cin>>t>>b[i];
        a=max(a,t);
    }
    sort(b.begin(),b.end(),greater<ll>());
    ll cnt=0LL;
    int now=0;
    while(H>0 && b[now]>a && now<N){
        H-=b[now];
        now++;
        cnt++;
    }
    while(H>0){
        H-=a;
        cnt++;
    }
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
template <class T>
void get_unique(vector<T>& x) {
    x.erase(unique(x.begin(), x.end()), x.end());
}
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (int i = 0; i < sz(v); i++) {
        os << v[i];
        if (i < sz(v) - 1) os << " ";
    }
    return os;
}
int main() {
    int n;
    cin >> n;
    vector<int> v;
    rep(i, n) {
        int a, b;
        cin >> a >> b;
        if (a == b) v.push_back(i);
    }
    if (sz(v) >= 3) {
        rep(i, sz(v) - 2) {
            if (v[i] + 1 == v[i + 1] && v[i + 1] + 1 == v[i + 2]) {
                cout << "Yes\n";
                return 0;
            }
        }
    }
    cout << "No\n";
}

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

int main() {
  ll A, B;
  cin >> A >> B;
  
  ll p = __gcd(A, B);
  ll ans = 1;
  for (int i = 2; i <= sqrt(p); i++) {
    if (p % i == 0) {
      ans++;
      while (p % i == 0) {
        p /= i;
      }
    }
  }
  if (p > 1) ans++; // 割り切れていない場合はもう1つある
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
using namespace std;

int main(void){
	int N, K;
	long result;
	cin >> N >> K;
	long cnt = N / K;
	result = cnt * cnt * cnt;
	if(K % 2 == 0){
		cnt = (N + K / 2) / K;
		result += cnt * cnt * cnt;
	}
	cout << result;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

int main()
{
    int a, b, c, cnt = 0;

    std::cin >> a >> b >> c;
    for( int x = a; x <= b; ++x )
    {
        if( c % x == 0 )
        {
            ++cnt;
        }
    }

    std::cout << cnt << std::endl;

    return 0;
}

Measured memory_bytes: 3124
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;

#define REP(i,n) for(long long i = 0; i < (n); i++)
#define FOR(i, m, n) for(long long i = (m);i < (n); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SPEED cin.tie(0);ios::sync_with_stdio(false);

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;

const ll MOD = (ll)1e9 + 7;
const ll MOD2 = 998244353;
const ll HIGHINF = (ll)1e18;
const ll LOWINF = (ll)1e15;
const long double PI = 3.1415926535897932384626433;

template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max<T>(a,b);}
template <class T> void chmin(T& a, const T b){a=min<T>(a,b);}
void YN(bool flg) {cout << ((flg) ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << ((flg) ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << ((flg) ? "yes" : "no") << endl;}

int main() {
	V<int> a(5);
	REP(i,5) cin >> a[i];
	int k; cin >> k;
	sort(ALL(a));
	corner(k < a[4]-a[0],":(");
	cout << "Yay!" << endl;


	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#define Rep(i,a,b) for(register int i=(a),i##end=(b);i<=i##end;++i)
#define Repe(i,a,b) for(register int i=(a),i##end=(b);i>=i##end;--i)
#define For(i,a,b) for(i=(a),i<=(b);++i)
#define Forward(i,a,b) for(i=(a),i>=(b);--i)
template<typename T>inline void read(T &x)
{
	T f=1;x=0;char c;
	for(c=getchar();!isdigit(c);c=getchar())if(c=='-')f=-1;
	for(;isdigit(c);c=getchar())x=x*10+(c^48);
	x*=f;
}
using namespace std;

const int MAXN=1e5+7;

static int n,a[MAXN],cnt;

inline void init()
{
	read(n);
	Rep(i,1,n)read(a[i]);
	sort(a+1,a+n+1);
}

inline int gcd(int u,int v){return v?gcd(v,u%v):u;}

int getans(int now)
{
	cnt=0;
	Rep(i,1,n)cnt+=(a[i]^1)&1;
	if(cnt&1)return now;
	else
	{
		if(cnt!=n-1||a[1]==1)return now^1;
		static int x;x=0;
		Rep(i,1,n)
		{
			if(a[i]&1)--a[i];
			x=gcd(a[i],x);
		}
		Rep(i,1,n)a[i]/=x;
		return getans(now^1);
	}
}

inline void solve()
{
	if(getans(1))return(void)puts("First");
	puts("Second");
}

int main()
{
	init();
	solve();
	return 0;
}

Measured memory_bytes: 640
using System;

class Rating{
  static void Main(){
      
      var input = int.Parse(Console.ReadLine());
      var number = Console.ReadLine().Split(' ');
      int result = 0;
      int[] houseList = new int[input];
      
      for(var i = 0; i < number.Length;i++){
          houseList[i] = int.Parse(number[i]); 
      }
      
      for(var i = 0; i <= 100;i++){
          int sum = 0;
          for(var j = 0; j < number.Length;j++){
             sum += (int)Math.Pow(Math.Abs(i - houseList[j]),2); 
          }
          if(i == 0){
              result = sum;
          }else{
              if(result > sum){
                  result = sum;
              }
          }
      }
     Console.WriteLine(result);
  }
}

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

map<int, int> f(int N) {
  map<int, int> ans;
  for (int i = 2; i <= N; i++) {
    int n = i;
    for (int p = 2; p*p <= i; p++) {
      if (n % p != 0) continue;
      int num = 0;
      while (n % p == 0) { num++; n /= p; }
      if (ans.count(p)) ans[p] += num;
      else ans[p] = num;
    }
    if (n != 1) {
      if (ans.count(n)) ans[n]++;
      else ans[n] = 1;
    }
  }
  return ans;
}
int main() {
  int N; cin >> N;
  if (N == 1) cout << 1 << endl;
  else {
    map<int, int> pf = f(N);
    long long ans = 1;
    for (pair<int, int> p : pf) ans = ans * (p.second + 1) % 1000000007;
    cout << ans << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
typedef long long ll;

using namespace std;

int main()
{
	int a,b;
	int ans=0;
	
	cin>>a>>b;
	ans = (a+b)/2+((a+b)%2);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
char ma[12][12];
int dx[] = {1,-1,0,0},dy[] = {0,0,-1,1};


void iland(int px,int py){
  ma[px][py] = '0';
  for(int i = 0 ; i < 4 ; i++){
      if(ma[px+dx[i]][py+dy[i]] == '1' &&
	 0<=px+dx[i] && px+dx[i] < 12 && 0<=py+dy[i] && py+dy[i] < 12){
	iland(px+dx[i],py+dy[i]);
    }
  }
}

int main(){

  while(cin >> ma[0][0]){

  for(int i = 0 ; i < 12 ; i++  ){
    for(int j = 0 ; j < 12 ; j++  ){
if(i == 0 && j == 0 )continue;
      cin >> ma[j][i];  
    }
  }
  int ans = 0; 
  for(int i = 0 ; i < 12 ; i++  ){
    for(int j = 0 ; j < 12 ; j++  ){
      if(ma[j][i] == '1'){
	iland(j,i);
	ans++; 
      }
    }
  }
  cout << ans << endl;
  }
}

Measured memory_bytes: 1140
private fun readStrings() = readLine()!!.split(" ")
private fun readInts() = readStrings().map { it.toInt() }

fun main(args: Array<String>) {
    val N = readInts()[0]
    val a = (1 .. N).map { readInts()[0] }

    if (a[0] != 0) println(-1)
    else {
        var counts = 0L
        var prev = a[0]
        for (num in a.drop(1)) {
            if (num > prev) {
                if (num - prev > 1) {
                    println(-1)
                    return
                } else {
                    counts++
                }
            } else {
                counts += num
            }
            prev = num
        }
        println(counts)
    }
}

Measured memory_bytes: 74396
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
int P[100], T[100], V[100];
double prob[100][51];
double comb[51][51];
int main() {
	int N, M, L;
	cin >> N >> M >> L;
	comb[0][0] = 1;
	for (int i = 1; i <= M; i++) {
		comb[i][0] = comb[i][i] = 1;
		for (int j = 1; j < i; j++) {
			comb[i][j] = comb[i - 1][j - 1] + comb[i - 1][j];
		}
	}
	for (int i = 0; i < N; i++) {
		cin >> P[i] >> T[i] >> V[i];
	}
	for (int i = 0; i < N; i++) {
		for (int j = 0; j <= M; j++) {
			prob[i][j] = comb[M][j] * pow(P[i] / 100.0, j)*pow(1 - P[i] / 100.0, M - j);
		}
	}
	for (int i = 0; i < N; i++) {
		if (V[i] == 0) {
			cout << 0 << endl;
			continue;
		}
		double ans = 0;
		for (int j = 0; j <= M; j++) {
			double t1 = (double)L / V[i] + T[i] * j;
			double p = 1;
			for (int k = 0; k < N; k++) {
				if (k == i) continue;
				if (V[k] == 0) continue;
				double sum = 0;
				for (int l = 0; l <= M; l++) {
					double t2 = (double)L / V[k] + T[k] * l;
					if (t1 < t2) sum += prob[k][l];
				}
				p *= sum;
			}
			ans += prob[i][j] * p;
		}
		printf("%.15lf\n", ans);
	}
}


Measured memory_bytes: 3540
import java.util.Scanner;

class Main {
    private static void solve() {
        final Scanner scanner = new Scanner(System.in);
        final char[][] keymap =
                { null,
                  { '\'', ',', '.', '!', '?' },
                  { 'a', 'b', 'c', 'A', 'B', 'C' },
                  { 'd', 'e', 'f', 'D', 'E', 'F' },
                  { 'g', 'h', 'i', 'G', 'H', 'I' },
                  { 'j', 'k', 'l', 'J', 'K', 'L' },
                  { 'm', 'n', 'o', 'M', 'N', 'O' },
                  { 'p', 'q', 'r', 's',  'P', 'Q', 'R', 'S' },
                  { 't', 'u', 'v', 'T', 'U', 'V' },
                  { 'w', 'x', 'y', 'z', 'W', 'X', 'Y' , 'Z' }
                 };
        while (scanner.hasNext()) {
            final char[] line = scanner.next().toCharArray();
            int index = 0;
            while (index != line.length) {
                final char digit = line[index];
                int counter = 1;
                while (++index < line.length && line[index] == digit) {
                    counter++;
                }
                if (keymap[digit - '0'] == null) {
                    for (int i = 1; i < counter; i++) {
                        System.out.print(' ');
                    }
                } else {
                    final int length = keymap[digit - '0'].length;
                    System.out.print(keymap[digit - '0'][(counter - 1) % length]);
                }
            }
            System.out.println();
        }
    }

    public static void main(String... args) {
        solve();
    }
}

Measured memory_bytes: 12000
using System;
class Program{
	static void Main(){
		int n=int.Parse(Console.ReadLine());
		int[] s=Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
		Array.Sort(s,(a,b)=>b-a);
		double c=double.MaxValue;
		int d=0;
		for(int i=1;i<n;i++){
			if(Math.Abs(s[0]/2.0-s[i])<c){
				c=Math.Abs(s[0]/2.0-s[i]);
				d=s[i];
			}
			else{break;}
		}
		Console.WriteLine("{0} {1}",s[0],d);
	}
}

Measured memory_bytes: 21472
#include <bits/stdc++.h>
using namespace std;
#define pi acos(-1)
#define IOS ios_base::sync_with_stdio(0); cin.tie(); cout.tie();
#define ff first
#define ss second
#define pb push_back
#define debug(val) cerr << "The value of " << #val << " is = " << val << '\n';
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll inf = 0x3f3f3f3f;
const ll mininf = -922337203685477;
const ll nax = 0;
unordered_map<string, int>mep;
int n;
string a;

int main(){
	IOS
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> a;
		mep[a]++;
	}
	cout << "AC x " << mep["AC"] << '\n';
	cout << "WA x " << mep["WA"] << '\n';
	cout << "TLE x " << mep["TLE"] << '\n';
	cout << "RE x " << mep["RE"] << '\n';
}


Measured memory_bytes: 3640
''' ===============================
    -- @uthor : Kaleab Asfaw
    -- Handle : kaleabasfaw2010
    -- Bio    : High-School Student
    ==============================='''

# Fast IO
import sys
import os
from io import BytesIO, IOBase
BUFSIZE = 8192
class FastIO(IOBase):
    newlines = 0
    def __init__(self, file): self._fd = file.fileno(); self.buffer = BytesIO(); self.writable = "x" in file.mode or "r" not in file.mode; self.write = self.buffer.write if self.writable else None
    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b: break
            ptr = self.buffer.tell(); self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0; return self.buffer.read()
    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE)); self.newlines = b.count(b"\n") + (not b); ptr = self.buffer.tell(); self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1; return self.buffer.readline()
    def flush(self):
        if self.writable: os.write(self._fd, self.buffer.getvalue()); self.buffer.truncate(0), self.buffer.seek(0)
class IOWrapper(IOBase):
    def __init__(self, file): self.buffer = FastIO(file); self.flush = self.buffer.flush; self.writable = self.buffer.writable; self.write = lambda s: self.buffer.write(s.encode("ascii")); self.read = lambda: self.buffer.read().decode("ascii"); self.readline = lambda: self.buffer.readline().decode("ascii")
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout); input = lambda: sys.stdin.readline().rstrip("\r\n")
# Others
# from math import floor, ceil, gcd
# from decimal import Decimal as d
mod = 10**9+7
def lcm(x, y): return (x * y) / (gcd(x, y))
def fact(x, mod=mod):
        ans = 1
        for i in range(1, x+1): ans = (ans * i) % mod
        return ans
def arr2D(n, m, default=0):
        lst = []
        for i in range(n): temp = [default] * m; lst.append(temp)
        return lst
def sortDictV(x): return {k: v for k, v in sorted(x.items(), key = lambda item : item[1])}

def solve(n, W, weight, value):
    dp = arr2D(n+1, W+1)

    for i in range(1, n+1):
        for j in range(1, W+1):
            # print(i, j)
            val = max(dp[i][j-1], dp[i-1][j])
            if j >= weight[i-1]:
                dp[i][j] = max(val, dp[i-1][j-weight[i-1]] + value[i-1])
            else: dp[i][j] = val
    return dp[n][W]

n, W = list(map(int, input().split()))
weight = []
value = []
for i in range(n):
        a, b = list(map(int, input().split()))
        weight.append(a)
        value.append(b)
print(solve(n, W, weight, value))


Measured memory_bytes: 149040