akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;
typedef long long ll;

char dc[]={'N','E','S','W'};
int dy[]={-1,0,1,0};
int dx[]={0,1,0,-1};

int change(char ch){
  for(int i=0;i<4;i++)if(dc[i]==ch)return i;
}

int H,W,sx,sy,sdir;
ll L;
char t[100][100];
string str;

void input();
void solve();
void dfs(int,int,int,ll);

int main(){
  while(1){
    cin>>H>>W>>L;
    if(H==0&&W==0&&L==0)break;
    input();
    solve();
  }
  return 0;
}

void input(){
  for(int i=0;i<H;i++){
    cin>>str;
    for(int j=0;j<W;j++){
      if(str[j]!='#'&&str[j]!='.'){
	t[i][j]='.';
	sy=i;
	sx=j;
	sdir=change(str[j]);
      }else t[i][j]=str[j];
    }
  }  
}

ll vd[100][100][4];

void solve(){
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      for(int k=0;k<4;k++){
	vd[i][j][k]=-1;
      }
    }
  }

  dfs(sy,sx,sdir,0);
}


void dfs(int y,int x,int dir,ll cnt){
  dir%=4;

  if(cnt>=L){
    cout<<y+1<<' '<<x+1<<' '<<dc[dir]<<endl;
    return;
  }
  
  if( L-cnt>=50000LL && vd[y][x][dir]!=-1 ){
    ll ncnt;
    ncnt=(L-cnt)%(cnt-vd[y][x][dir]);
    dfs(y,x,dir,L-ncnt-(cnt-vd[y][x][dir]));
    return;
  }

  vd[y][x][dir]=cnt;
  
  int ny=y+dy[dir];
  int nx=x+dx[dir];
  if(ny<0||nx<0)dfs(y,x,dir+1,cnt);
  else if(ny>=H||nx>=W)dfs(y,x,dir+1,cnt);
  else if(t[ny][nx]=='#')dfs(y,x,dir+1,cnt);
  else dfs(ny,nx,dir,cnt+1);

}

Measured memory_bytes: 1536
#include <stdio.h>
#include <stdlib.h>

int min(int a,int b){
  if(a < b){
    return a;
  }
  return b;
}

int main(void){
  int N,A,B,C;
  scanf("%d%d%d%d",&N,&A,&B,&C);

  int l[N];
  for(int i = 0;i < N;i++){
    scanf("%d",&l[i]);
  }

  int l1,l2,l3;
  int cost,flag[3];
  int ans = 1e9;
  for(int i = 0;i < 1<<(N*3);i++){
    l1 = 0; l2 = 0; l3 = 0; cost = 0;
    flag[0] = 0; flag[1] = 0; flag[2] = 0;
    for(int j = 0;j < N;j++){
      switch((i >> 2*j)&3){
        case 0:
          l1 += l[j];
          flag[0] = 1;
          cost += 10;
          break;
        case 1:
          l2 += l[j];
          flag[1] = 1;
          cost += 10;
          break;
        case 2:
          l3 += l[j];
          flag[2] = 1;
          cost += 10;
          break;
      }
    }
    if(flag[0] && flag[1] && flag[2]){
      cost += abs(A-l1);
      cost += abs(B-l2);
      cost += abs(C-l3);
      cost -= 30;
      ans = min(ans,cost);
    }
  }

  printf("%d\n",ans);
  
  return 0;
}

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

int main(void)
{
    int N;
    cin >> N;
    vector<int> Ei(N-1);
    vector<int> Ej(N-1);
    vector<int> Ec(N-1);
    vector<vector<int>> Node(N, vector<int>(0));
    vector<int> Nend(N);
    int b, c;
    for(int i=0;i<N-1;i++){
        cin >> b >> c;
        Ei.at(i) = b-1;
        Ej.at(i) = c-1;
        Node.at(b-1).push_back(i);
        Node.at(c-1).push_back(i);
    }
    int max_d = 0;
    int max_index = 0;
    int d;
    for(int i=0;i<N;i++){
        d = Node.at(i).size();
        if(d>max_d){
            max_d = d;
            max_index = i;
        }
    }
    stack<int> s;
    int e;
    for(int i = 0;i<max_d;i++){
        e = Node.at(max_index).at(i);
        Ec.at(e) = i+1;
        s.push(Ei.at(e));
        s.push(Ej.at(e));
    }
    Nend.at(max_index) = 1;
    int n;
    while (s.size()>0){
        n = s.top();
        s.pop();
        if(Nend.at(n)==1){
            continue;
        }
        Nend.at(n)=1;
        // 入ってくるばんごう
        int in_n;
        for(int i = 0;i<Node.at(n).size();i++){
            e = Node.at(n).at(i);
            if(Ec.at(e)!=0){
                in_n = Ec.at(e);
                break;
            }
        }
        // 出ていく番号を決定する
        int edge_id = 1;
        for(int i = 0;i<Node.at(n).size();i++){
            e = Node.at(n).at(i);
            if(Ec.at(e)!=0){
                continue;
            }
            if(edge_id==in_n){
                edge_id++;
            }
            Ec.at(e) = edge_id;
            edge_id++;
            
            // if(i+1!=in_n){
            //     Ec.at(e) = i+1;
            // }else{
            //     Ec.at(e) = max_d;
            // }
            s.push(Ei.at(e));
            s.push(Ej.at(e));
        }
    }
    cout << max_d << endl;
    for(int i=0;i<N-1;i++){
        cout << Ec.at(i) << endl;
    }
    return 0;
}

Measured memory_bytes: 7552
#include <bits/stdc++.h> 
using namespace std; 
#define for_(i, s, e) for (int i = s; i < (int) e; i++)
#define for__(i, s, e) for (ll i = s; i < e; i++)
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
#define endl '\n'


int main() {
	#ifdef shiven
	freopen("test.in", "r", stdin);
	#endif
	
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	vector<ll> a(4); cin >> a[0] >> a[1] >> a[2] >> a[3];
	ll ans = LONG_LONG_MIN;
	for_(i, 0, 2) for_(j, 2, 4) ans = max(ans, a[i] * a[j]);
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3644
package main

import "fmt"

func check(s, t string) bool {
	l := len(s)
	for i := range s {
		if s[i] != t[l-1-i] {
			return false
		}
	}
	return true
}

func main() {
	var s, t string
	fmt.Scan(&s, &t)
	if check(s, t) {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;
 
////////////// Prewritten code follows. Look down for solution. ////////////////

#define fs first
#define sc second
#define pb push_back
#define len(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend
#define forn(i, n) for(int i = 0; i < (int)(n); ++i)
#define for1(i, n) for(int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for(int i = (int)(n); i >= 0; --i)
#define fore(i, a, b) for(int i = (int)(a); i <= (int)(b); ++i)

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;
typedef vector<pll> vpl;
typedef vector<vl> vvl;

template<typename T> void maxself(T &a, T &b){a = max(a, b);};
template<typename T> void minself(T &a, T &b){a = min(a, b);};

const ll LINF = 1e18;
const int INF = 1e9;
const int MOD = 1e9+7;

/// command for char arrays with spaces -> scanf(" %[^\n]", text);
 
////////////////////////// Solution starts below. //////////////////////////////

int main(){

	int n;
	scanf("%d", &n);
	printf("%d\n", (n/2)+(n%2));
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define fi first
#define se second
#define sz size()
#define bgn begin()
#define en end()
#define pb push_back
#define pp() pop_back()
#define V vector
#define P pair
#define yuko(a) setprecision(a)
#define uni(a) a.erase(unique(a.begin(),a.end()),a.end())
#define Q queue
#define pri priority_queue
#define Pri priority_queue<int,vector<int>,greater<int>>
#define PriP priority_queue<P<int,int>,vector<P<int,int>>,greater<P<int,int>>>
#define ff first.first
#define fs first.second
#define sf second.first
#define ss second.second
#define all(a)  (a).begin(),(a).end()
#define elif else if


signed main(){
  int n;
  cin>>n;
  V<int> a(n);
  fo(i,n){
    cin>>a[i];
  }
  Sort(a);
  rev(a);
  V<int> g=a;
  uni(g);
  V<P<int,int>> d(g.sz);
  int j=0;
  for(int i=0; i<n; i=i){
    int b=a[i];
    int c=0;
    d[j].fi=b;
    while(i<n){
      if(a[i]==b)
        c++;
      else
        break;
      i++;
    }
    d[j].se=c;
    j++;
  }
  int e=0,f=0;
  fo(i,g.sz){
    if(d[i].se>=2&&e==0){
      d[i].se-=2;
      e=d[i].fi;
    }
    if(d[i].se>=2&&e>0){
      f=d[i].fi;
      break;
    }
  }
  cout<<e*f<<endl;
}

Measured memory_bytes: 3328
#include <stdio.h>
#include <string.h>

int main(void)
{
	int weight[10001];
	int treasure, temp, max, mem;
	int num, limit, count;
	int i, j;
	
	count = 1;
	while (1){
		scanf("%d", &limit);
		
		if (!limit) break;
		
		scanf("%d", &num);
		memset(weight, 0, sizeof(weight));
		for (i = 0; i < num; i++){
			scanf("%d%*c%d", &treasure, &temp);
			
			for (j = limit; j >= 0; j--){
				if (weight[j] != 0 && weight[j] + treasure > weight[j + temp]) weight[j + temp] = weight[j] + treasure;
				else if (j == 0) if (weight[j] + treasure > weight[j + temp]) weight[j + temp] = weight[j] + treasure;
			}
		}
		
		max = mem = 0;
		for (j = 0; j <= limit; j++){
			if (weight[j] > max){
				max = weight[j];
				mem = j;
			}
		}
		printf("Case %d:\n%d\n%d\n", count, max, mem);
		count++;
	}
	
	return (0);
}

Measured memory_bytes: 0
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <queue>
#include <set>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <complex>

int main(){

  long long int M1, D1, M2, D2;
  scanf("%lld%lld", &M1, &D1);
  scanf("%lld%lld", &M2, &D2);

  std::cerr << "Answer: " << std::endl;
  if(M1 != M2){
    std::cout << 1 << std::endl;
  }
  else{
    std::cout << 0 << std::endl;
  }

  return 0;
}


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

int abs(int x){
  if(x<0){
    x=-x;
  }
  return x;
}

int main(){
  int a,b;
  cin>>a>>b;
  if(a>b){
    cout<<a-1<<endl;
  }else{
    cout<<a<<endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>
#include <map>
#include <unordered_map>
#include <string.h>
#include<iomanip>
#include <iterator>
#include <locale>

#define all(a) a.begin(),a.end()
#define VV(T) vector<vector< T > >
#define rep(i,N) for(int i = 0; i <N; i++)
#define repsg(i,s,g) for(int i = s; i <g; i++)
#define name(x) #x
using namespace std;


const int INF = 10000000;
const long long INFL = (1LL<<40);
const int MOD = pow(10,9)+7;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

typedef long long ll,LL;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
typedef pair<int,int> pii;
typedef pair<LL, LL> pLL;


// vector入力
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x: vec) is >> x;
    return is;
}
// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){
    for(int i=0; i<vec.size(); i++){
        os << vec[i] << ( i+1 == vec.size() ? "" : " " );
    }
    return os;
}

template< typename T >
struct edge{
    int src, to;T cost;
    edge(int to,T cost) :src(-1),to(to),cost(cost){}
    edge(int src, int to, T cost) :src(src),to(to),cost(cost){}edge
    &operator=(const int &x){
        to =x;
        return *this;
    }
    operator int() const{ return to;}
};

double dist (double a, double b,  double c, double d){
    
    return sqrt((a-c)*(a-c) + (b-d)*(b-d));
    
}

bool check(int x,int y,vector<string> a,vector<string> b ){
    for(auto i = 0; i<b.size();i++){
        for(auto j =0; j<b.size();j++){
            if(a[x+i][y+j]!= b[i][j]) return false;
        }
    }
    return true;
}

int dist(pii a, pii b){
    return abs(a.first-b.first) + abs(a.second-b.second);
}

int main() {
    int n;cin>>n;
    int a[100001]={0};rep(i,n)cin>>a[i+1];
    int light[100001] = {0};
    light[1] = 1;
    int count = 0;
    int pos = 1;
    while(1){
        if(light[2] == 1)  {cout<<count<<endl;return 0;}
        if(light[a[pos]]==1)break;
        light[a[pos]] = 1;
        pos = a[pos];
        count++;
        
    }
    cout<<-1<<endl;
    
    return 0;
}







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

#define ntest 0

using namespace std;
long long n,x, t;
void solve() {
    cin >> n >> x >> t;
    cout << ((n + x - 1) / x * t);
}
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    if(ntest){
        int t;
        cin >> t;
        while(t--) solve();
    } else {
        solve();
    }

}




Measured memory_bytes: 3632
#include <stdio.h>
int main(){
	while(1){
		int m=0,i=0,s=0,month=0;
		int p[12]={0};
		int q[12]={0};
		scanf("%d",&m);
		if(m==0)break;
			for(i=0;i<12;i++){
				scanf("%d %d",&p[i],&q[i]);
			}
			for(i=0;i<12;i++){
				s+=p[i]-q[i];
				if(s>=m){
					month=i+1;
					break;
				}
			}
		if(month)printf("%d\n",month);
		else puts("NA");
		}
return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair< int , int > P;
typedef tuple<int, int, int> T;


int main(){
int a,b,k;

cin>>k;
cin>>a>>b;
int l=k;
while(k<=b){
  if(a<=k)
  {
    cout<<"OK";
    return 0;
  }
  k+=l;
  }
  cout<<"NG";
}

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

int main()
{
    int s;
    cin >> s;
    int a, b, c;
    a = s / 100;
    c = s % 10;
    b = (s - 100 * a) / 10;
    cout << a + b + c << endl;
}

Measured memory_bytes: 256
from fractions import gcd
import math
 
A, B = map(int, input().split())
 
N = gcd(A, B)
 
def prime(n):
    factor = {}
    tmp = int(math.sqrt(n)) + 1
    for num in range(2, tmp):
        while n % num == 0:
            n //= num
            if not num in factor.keys():
                factor[num] = 1
            else:
                factor[num] += 1
    if n != 1:
        if not n in factor.keys():
            factor[n] = 1
        else:
            factor[n] += 1
    return factor

factor = prime(N)
print(len(factor) + 1)

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

#define what_is(x)    cerr<<#x<<" is "<<x<<"\n";
#define rep(i,a,n)    for(int i=a; i<=n; ++i)
#define rep1(i,a,n)   for(int i=a; i>=n; --i)
#define pb            push_back
#define mp            make_pair
#define int           long long
#define fr            first
#define sc            second
#define vc            vector
#define sz(v)         (int)v.size()
#define all(x)        (x).begin(),(x).end()
#define rall(x)       (x).rbegin(),(x).rend()
#define M             1000000007
#define MM            998244353
#define PI            3.14159265358979
#define INF           1000000000000000

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef map<int,int> mii;

int n,m,ans; string str;

int h[100005];
int dp[100005];
int solve(){
    int k; cin>>n>>k;
    rep(i,1,n) cin>>h[i];
    rep(i,1,n) dp[i]=INF;
    dp[1]=0;
    rep(i,2,n){
        rep(j,1,min(i-1,k)){
            dp[i]=min(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
        }
    }
    cout<<dp[n];
    return 0;
}

signed main() {
    ios::sync_with_stdio(0);
    std::mt19937_64 rng(std::chrono::steady_clock::now().time_since_epoch().count());
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t=1;
    //cin>>t;
    while(t--) solve();
    return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <stdlib.h>

int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}

int main(void){
	int a[3];
	scanf("%d %d %d",&a[0],&a[1],&a[2]);
	qsort(a,3,sizeof(int),compare_int);
	int ans = 0;
	ans += a[1] - a[0];
	ans += a[2] - a[1];
	printf("%d",ans);
	return 0;
}

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

int main() {
    int n,q;
    ll k;
    cin>>n>>k>>q;
    vector<int> a(q);
    map<int,int> mp{};
    rep(i,q){
        cin>>a[i];
        a[i]--;
        mp[a[i]]++;
    }
    rep(i,n){
        if(mp.count(i)==0) mp[i]=0;
    }
    for(auto x:mp){
        if(q-x.second >= k){
            cout<<"No"<< endl;
        }else{
            cout<<"Yes"<<endl;
        }
    }
    
    return 0;
}



Measured memory_bytes: 7168
n = int(input())
v = [int(i) for i in input().split()]


def gcd(x, y):
    if y > x:
        x, y = y, x
    if y == 0:
        return x
    if x % y == 0:
        return y
    return gcd(y, x % y)


l = [0 for i in range(n)]
r = l[:]

for i in range(1, n):
    l[i] = gcd(l[i - 1], v[i - 1])
    r[-i-1] = gcd(r[-i], v[-i])
m = [gcd(l[i], r[i]) for i in range(n)]
print(max(m))


Measured memory_bytes: 67436
# coding: utf-8
# Your code here!
#動的計画法
 
N = int(input())
Ni_2 = 2
Ni_1 = 1
Ni = 1
Ni_dummy = 0
 
for i in range(2, N + 1):
    Ni = Ni_1 + Ni_2
    Ni_2 = Ni_1
    Ni_1 = Ni
print(Ni)

Measured memory_bytes: 3060
#include <bits/stdc++.h> 
using namespace std;
typedef long long intl;
int main(){
	cin.tie(0);
	ios::sync_with_stdio(0);
	int n,m;
	cin>>n>>m;
	vector <vector <char> > v(n,vector <char> (m));
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			cin>>v[i][j];
		}
	}
	vector <vector <int> > dp(n,vector <int> (m,1e9));
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			if(i==0&&j==0){
				dp[i][j]=0;
			}
			else if(j==0){
				if(v[i][j]!=v[i-1][j]){
					dp[i][j]=dp[i-1][j]+1;
				}
				else{
					dp[i][j]=dp[i-1][j];
				}
			}
			else if(i==0){
				if(v[i][j]!=v[i][j-1]){
					dp[i][j]=dp[i][j-1]+1;
				}
				else{
					dp[i][j]=dp[i][j-1];
				}
			}
			else{
				if(v[i][j]!=v[i-1][j]){
					dp[i][j]=min(dp[i][j],dp[i-1][j]+1);
				}
				else{
					dp[i][j]=min(dp[i][j],dp[i-1][j]);
				}
				if(v[i][j]!=v[i][j-1]){
					dp[i][j]=min(dp[i][j],dp[i][j-1]+1);
				}
				else{
					dp[i][j]=min(dp[i][j],dp[i][j-1]);
				}
			}
		}
	}
	if(v[0][0]=='#'){
		dp[n-1][m-1]++;
	}
	if(v[n-1][m-1]=='#'){
		dp[n-1][m-1]++;
	}
	cout<<(dp[n-1][m-1]+1)/2<<endl;
}


Measured memory_bytes: 384
from sys import stdin

n = int(stdin.readline().rstrip())
li = [int(stdin.readline().rstrip()) for _ in range(n)]


mins = li[0]
maxs = -100000000000

for i in range(1,n):
    maxs = max(maxs,li[i]-mins)
    mins = min(mins,li[i])
print(maxs)


Measured memory_bytes: 13620
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<functional>
#include<queue>
#include <iomanip>
#include<map>
#include<limits>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

#define DBG cerr << '!' << endl;
#define REP(i,n) for(int (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(int (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(int (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int i = 0;i < (n);i++)cerr << v[i] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()

using namespace std;

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

int main()
{
	int n;
	ll ans = 0;
	cin >> n;
	
	vector<ll> v(n);
	REP(i,n)
	{
		cin >> v[i];
		if(v[i]%2 != 0)
		{
			ans += v[i]/2;
			v[i] = 1;
		}
		else if(v[i] > 0)
		{
			ans += v[i]/2 - 1;
			v[i] = 2;
		}
	}
	
	
	REP(i,n)
	{
		if(i < n-1 && v[i] && v[i] <= v[i+1])
		{
			ll tmp = min(v[i],v[i+1]);
			v[i]-=tmp;v[i+1]-=tmp;
			ans+=tmp;
		}
		ans += v[i]/2;
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 1152
S = input()
length = len(S)
# print(length)
S1 = S[0:int((length-1)/2)]
S2 = S[int((length+3)/2)-1:]
if S == S[::-1] and S1 == S1[::-1] and S2 == S2[::-1]:
	print("Yes")
else:
	print("No")

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

int main() {

    string s;
    int cnt = 0;

    cin >> s;

    for (int i = 0; i < s.size(); i++) {
        
        if (s[i] == 'o') cnt++;
        
    }
    
    cout << 700 + cnt * 100 << endl;

    return 0;
    
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#define REP(i, n) for(int i = 0;i < n;i++)
#define ll long long
#define INF 114514
using namespace std;




int main(){
	while (1) {
		int i = 0, sum = 0, name = 0;
		for (i = 0; i < 5; i++) {
			int a, b;
			cin >> a >> b;
			if (a == 0 && b == 0) return 0;
			if (a + b > sum) {
				sum = a + b;
				name = i + 1;
			}
		}
		if (name == 1) cout << "A " << sum << endl;
		if (name == 2) cout << "B " << sum << endl;
		if (name == 3)cout << "C " << sum << endl;
		if (name == 4) cout << "D " << sum << endl;
		if (name == 5) cout << "E " << sum << endl;
	}
	return 0;
}

Measured memory_bytes: 3076
S = int(input())

str = "NA"

if S%100 > 0 and S%100 < 13:
    str = "YYMM"

if int(S/100) > 0 and int(S/100) < 13:
    if str == "YYMM":
        str = "AMBIGUOUS"
    else:
        str ="MMYY"

print(str)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

int a,b,k;

int main(){
	cin>>a>>b>>k;
	for(int i=100;i>=0;i--) if(a%i==0&&b%i==0){
		k--;
		if(!k){
			cout<<i<<endl;
			break;
		}
	}
}

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

class D
{
	static void Main()
	{
		var k = int.Parse(Console.ReadLine());
		if (k <= 9) { Console.WriteLine(k); return; }

		var t = 9;
		var q = new Queue<long>(Enumerable.Range(1, 9).Select(i => (long)i));

		while (q.TryDequeue(out var x))
			for (long d = x % 10 - 1; d <= x % 10 + 1; d++)
			{
				if (d < 0 || d > 9) continue;
				q.Enqueue(x * 10 + d);
				if (++t == k) { Console.WriteLine(x * 10 + d); return; }
			}
	}
}


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

int main() {
    int N;
    cin >> N;
    
    if(18 <= N) {
        cout << "Yes";
    }
    else if(N % 4 == 0 || N % 7 == 0 || N == 11 || N == 15) {
        cout << "Yes";
    }
    else {
        cout << "No";
    }

    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define eb emplace_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
#define int ll
// #define ll int
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[8] ={1,0,-1,0,1,-1,1,-1};
ll dy[8] ={0,1,0,-1,1,-1,-1,1};
 
template<class T> 
inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> 
inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }



void solve(){
    ll n;
    ll a[200010];
    cin>>n;
    rep(i,n) cin>>a[i];
    sort(a,a+n);
    rep(i,n-1){
        if(a[i]==a[i+1]){
            cout<<"NO"<<endl;
            return;
        }
    }
    cout<<"YES"<<endl;

}



signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    
     

    solve(); 


    return 0;
}


Measured memory_bytes: 5164
#include <bits/stdc++.h>
#define prob "sol"
#define N 50001
#define ii pair< int, int>
#define fi first
#define se second
#define endl '\n'
#define iter set<int>::iterator
#define pb push_back
#define ll long long
#define fast ios_base::sync_with_stdio(0); cin.tie(nullptr); cout.tie(nullptr);
#define io freopen(prob".inp","r",stdin); freopen(prob".out","w",stdout);
using namespace std;
map<string,int>S;
int n;
void read()
{
    cin>>n;
    string s;
    string x;
    while(n--)
    {
        cin>>s>>x;
        if(s=="insert") S[x]++;
        else
        {
            if(!S[x]) cout<<"no\n";
            else cout<<"yes\n";
        }
    }
}
int main()
{
    fast
//    io
    read();
}



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

using namespace std;
typedef long long ll;

#define rep(i, N) for (int i = 0; i < (int)N; i++)
const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;


int main() {
  int N; cin >> N;
  ll A[N]; rep(i,N) cin >> A[i];
  sort(A,A+N);

  ll result = 0;
  if (N%2==0) {
    ll r[N] = {};
    rep(i,N/2) {
      r[i*2] = A[(N/2-1)-i];
      r[(N-1)-i*2] = A[N/2+i];
    }
    rep(i,N-1) result += abs(r[i+1]-r[i]);
  }
  else {
    ll r1[N] = {}, r2[N] = {};
    ll res1 = 0, res2 = 0;
    rep(i,N/2-1) r1[(i+1)*2] = A[i];
    r1[0] = A[N/2-1]; r1[N-1] = A[N/2];
    rep(i,N/2) r1[i*2+1] = A[N/2+1+i];
    rep(i,N-1) res1 += abs(r1[i+1]-r1[i]);

    rep(i,N/2-1) r2[(i+1)*2] = A[(N-1)-i];
    r2[0] = A[N/2+1]; r2[N-1] = A[N/2];
    rep(i,N/2) r2[i*2+1] = A[(N/2-1)-i];
    rep(i,N-1) res2 += abs(r2[i+1]-r2[i]);
    result = max(res1, res2);
    // rep(i,N) cout << r1[i] << " "; cout << endl;
    // rep(i,N) cout << r2[i] << " "; cout << endl;
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <deque>
#include <map>
#include <set>
#include <cassert>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sz(x) ((int)(x).size())
#define It iterator
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;

VI a,b;
int n;

int main() {
    //freopen("test.in","r",stdin);
    cin>>n;
    rep(i,0,2<<(n-1)) {int t; cin>>t; a.pb(t);}

    rep(i,0,n){
        rep(j,0,a.size()){
            if(j&1) continue;
            b.pb( abs(a[j]-a[j+1]));
        }
        a=b;
        b.clear();
        //rep(j,0,b.size()) cout<<b[i]<<endl;
    }
    cout<<b[0];


    return 0;
}


Measured memory_bytes: 2292
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int

int main(){
  int N,M;
  cin >> N>>M;
  vector<int> A;
  rep(i,N)
    A.push_back(2);
  rep(i,M)
    A.push_back(1);
  int count=0;
  rep(i,N+M){
    for(int j=i+1;j<M+N;j++){
      if((A[i]+A[j])%2==0){
	count++;}
    }
  }
  cout <<count<<endl;
  

  return 0;
}


Measured memory_bytes: 256
import fractions
 
N = int(input())
A = list(map(int,input().split()))
L = [0] * N
R = [0] * N

for i in range(1, N):
    L[i] = fractions.gcd(L[i-1], A[i-1])
    R[-i-1] = fractions.gcd(R[-i], A[-i])

ans = [0] * N

for i in range(0, N):
    ans[i] = fractions.gcd(L[i], R[i])

print(max(ans))

Measured memory_bytes: 16136
#include "bits/stdc++.h"
//#include<iostream>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll long long int
#define int ll
//#define slld(t) scanf("%lld",&t)
//#define sd(t) scanf("%d",&t)
//#define pd(t) printf("%d\n",t)
//#define plld(t) printf("%lld\n",t)
#define vec vector < int >
#define vecp vector < pair < int , int > >
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define debug(x)   cerr<<#x<<": "<<x<<endl
#define pii pair < int , int >
#define pll pair < ll , ll > 
#define fr(i , a , b) for(int  i = a ; i <= b ; i++)
#define all(v) v.begin() , v.end()
#define mod  1000000007
#define N 300005
#define mod1 1000000007
#define mod2 1000000009
#define bitcnt __builtin_popcount
#define PI acos(-1)
//#define endl "\n" 
#define mid  (s+e)/2
#define MAX 10000007
//const int inf = (int)1e18 + 10;;
int dp[102][100005] = {{0}};
int w[102] , val[102];
signed main(){
  fast;
  
  //freopen("input.txt" , "r" , stdin);
  //freopen("output.txt" , "w" , stdout);
  

    int n  , k;
    cin >> n  >> k;
    for(int i = 1 ; i <= n ; i++)
          cin >> w[i] >> val[i];



    for(int i = 1 ; i<=100000 ; i++)  dp[0][i] = 0;
    for(int i = 0 ; i<=n ; i++)   dp[i][0] = 1;

    for(int i = 1 ; i<= n ; i++){
          for(int j = 1 ; j<= 100000 ; j++){
               dp[i][j] = dp[i-1][j];
               if(j >= w[i] && dp[i-1][j-w[i]] > 0){
                  if( j-w[i] > 0 )
                  dp[i][j] = max(dp[i][j] , dp[i-1][j - w[i]] + val[i]);
                else
                  dp[i][j] = max(dp[i][j] , val[i]);
               }
          }
    } 
    int ans = 0;
    for(int i = 1 ; i<= k ; i++)
       ans = max(ans , dp[n][i]);


       cout << ans << endl; 

   

 }

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

int fib(int n)
{
    if(n == 1)
        return 1;
    else
        return (n + fib(n-1));
}

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

    int res = fib(n);
    cout<<res;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdint.h>
#include <iostream>
#include <fstream>
#include <cassert>
using namespace std;

#define DEBUG (1)

#ifdef DEBUG
#define DPRINT(...)  printf("D(L%d)%s: ", __LINE__, __func__); printf(__VA_ARGS__)
#else
#define DPRINT(...)
#endif

void swap(int &a, int &b);
void printAns(int ary[], int size, int numOfExchange);

int main() {
	int size;
	cin >> size; cin.ignore();
	assert(size > 0);

	int ary[size];
	for (int i=0; i < size; i++)
		cin >> ary[i];

	int numOfExchange = 0;
	bool done = 0;
#if 0
	while (!done) {
		done = 1;
		for (int i = size-1; i > 0; i--) {
			if (ary[i] < ary[i-1]) {
				swap(ary[i], ary[i-1]);
				done = 0;
				numOfExchange++;
			}
		}
	}
#endif
	int i = 0;
	while (!done) {
		done = 1;
		for (int j = size-1; j > i; j--) {
			if (ary[j] < ary[j-1]) {
				swap(ary[j], ary[j-1]);
				done = 0;
				numOfExchange++;
			}
		}
		i++;
	}
	printAns(ary, size, numOfExchange);
	return 0;
}

void swap(int &a, int &b) {
	int temp = a;
	a = b;
	b = temp;
}

void printAns(int ary[], int size, int numOfExchange) {
	for (int i = 0; i < size; i++) {
		if (i > 0) cout << " ";
		cout << ary[i];
	}
	cout << endl;
	cout << numOfExchange << endl;
}

Measured memory_bytes: 3096
#include <iostream>
#include <algorithm>

int arr[1030];
int N, K;
int answer;

int main(){
    scanf("%d %d", &N, &K);
    for (int i = 0; i < N; i++)
    {
        scanf("%d", &arr[i]);
    }
    std::sort(arr, arr + N);
    for (int i = 0; i < K; i++)
    {
        answer += arr[i];
    }
    printf("%d", answer);
}

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

int main(){
  int N, M , C;
  cin >> N >> M >> C;
  
  int b[M];
  for(int i = 0; i < M; i++){
   	cin >> b[i];
  }
  
  int count = 0;
  
  for(int i = 0; i < N; i++){
    int sum = 0;
    for(int j = 0; j < M; j++){
      int a;
      cin >> a;
      sum += b[j]*a;
    }
    if(sum + C > 0){
      count++;
    }
  }
  
  cout << count << endl;
  
}
    

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define MD 1000000007
#define INF 1ll<<60
typedef pair<ll, ll> P;
template <typename T>
std::string tostr(const T &t){std::ostringstream os;os << t;return os.str();}
int dx[4]={1, 0, -1, 0}, dy[4]={0, 1, 0, -1};

int main(){
    int n,x;
    cin>>n>>x;
    vector<int> l(n);
    for(int i=0;i<n;i++) cin>>l[i];
    int ans=1,dis=0;
    for(int i=0;i<n;i++){
        dis+=l[i];
        if(dis<=x) ans++;
        else break;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb          emplace_back
#define ll          long long
#define fi          first
#define se          second
#define mp          make_pair

using namespace std;

typedef pair<int, int> pii;
const int N = int(1e6 + 2);
const int mod = int(1e9 + 7);

void add(int& x, int y) {if((x += y) >= mod) x -= mod;}
int mul(int x, int y) {return 1ll * x * y % mod;}

unsigned int f[N], sum[N], n;

int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    #define Task        "test"
    if(fopen(Task".inp", "r")) {
        freopen(Task".inp", "r", stdin);
        freopen(Task".out", "w", stdout);
    }
    cin >> n;
    f[0] = sum[0] = 1;
    f[1] = n, sum[1] = n + 1;
    f[2] = mul(n, n);
    sum[2] = f[2] + sum[1];
    if(sum[2] >= mod) sum[2] -= mod;
    for(int i = 3; i <= n; ++i) {
        f[i] = f[i - 1] + mul(n - 1, n - 1) + sum[i - 3] + (n - i + 1);
        if(f[i] >= mod) f[i] %= mod;
        sum[i] = sum[i - 1] + f[i];
        if(sum[i] >= mod) sum[i] -= mod;
    }
    cout << f[n];
}


Measured memory_bytes: 8064
#include<iostream>
#include<algorithm>
#include<set>
using namespace std;
set<int> s;
int n,a[200010],p[200010],b,c;
int main(){
	cin>>n;s.insert(-1),s.insert(n);
	for(int i=0;i<n;i++){cin>>a[i];p[a[i]-1]=i;}
	long long r=0,h,w;
	for(int i=0;i<n;i++){
		s.insert(p[i]);
		set<int>::iterator t=s.find(p[i]);
		t++;b=*t;t--;t--;c=*t;
		h=b-p[i],w=p[i]-c;r+=h*w*(i+1);
	}cout<<r<<endl;
	return 0;
}


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

int GCD(int x, int y){
  // cout << "x:" << x << " y:" << y << endl;
  if(y == 0){
    return x;
  }
  return GCD(y, x%y);
}

int main(){
	int x, y;
  cin >> x >> y;

  int ans = GCD(x, y);

  cout << ans << endl;

}



Measured memory_bytes: 3124
#include <set>
#include <map>
#include <queue>
#include <ctime>
#include <cmath>
#include <cstdio>
#include <vector>
#include <string>
#include <cctype>
#include <bitset>
#include <cstring>
#include <cstdlib>
#include <utility>
#include <iostream>
#include <algorithm>
#define REP(i,a,b) for(int i=(a);i<=(b);i++)
#define PER(i,a,b) for(int i=(a);i>=(b);i--)
#define RVC(i,S) for(int i=0;i<(S).size();i++)
#define RAL(i,u) for(int i=fr[u];i!=-1;i=e[i].next)
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
     
template<class T> inline
void read(T& num) {
    bool start=false,neg=false;
    char c;
    num=0;
    while((c=getchar())!=EOF) {
        if(c=='-') start=neg=true;
        else if(c>='0' && c<='9') {
            start=true;
            num=num*10+c-'0';
        } else if(start) break;
    }
    if(neg) num=-num;
}
/*============ Header Template ============*/

struct edge {
    int next,to;
};

const int maxn=3005;
int a[maxn];
int fr[maxn];
edge e[maxn<<1];
int tote=0;

inline void addone(int u,int v) {
    ++tote;
    e[tote].next=fr[u];fr[u]=tote;e[tote].to=v;
}

inline void addedge(int u,int v) {
    addone(u,v);addone(v,u);
}

int dfs(int x,int f) {
    RAL(i,x) if(e[i].to!=f) {
        if(a[x]>a[e[i].to] && !dfs(e[i].to,x)) return 1;
    }
    return 0;
}

int main() {
    int n;
    read(n);
    REP(i,1,n) read(a[i]);
    memset(fr,-1,sizeof(fr));
    REP(i,1,n-1) {
        int u,v;
        read(u);read(v);
        addedge(u,v);
    }
    REP(i,1,n) if(dfs(i,0)) printf("%d ",i);putchar('\n');
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
// #include <bits/stdc++.h>

using namespace std;

#define LOG(...) fprintf(stderr,__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SQ(n) (n)*(n)

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

int main() {
  int a, b;
  int minv;

  vi l(4);
  while (cin>>a>>b,a|b) {
    minv = (int)1e9;
    int ra = sqrt(a)+1;
    int rb = sqrt(b)+1;
    FOR(i, 1, ra){
      if (a % i != 0) continue;
      FOR(j, 1, rb){
        if (b % j != 0) continue;
        l[0] = i;
        l[1] = a/i;
        l[2] = j;
        l[3] = b/j;
        SORT(l);
        int v = SQ(l[0] - l[1]) + SQ(l[1] - l[2]) + SQ(l[2] - l[3]);
        minv = min(v, minv);
      }
    }
    cout << minv << endl;
  }
}

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

void solve(std::istream &ist, std::ostream &ost)
{
    /* ------- 宣言と入力 ------- */

    int N, M;

    ist >> N >> M;

    vector<int> A;

    for (int i = 0; i < M; i++)
    {
        int tmp;
        ist >> tmp;
        A.emplace_back(tmp);
    }

    /* ------- 計算 ------- */

    for (auto a : A)
    {
        N -= a;
    }

    if (N >= 0)
    {
        ost << N << endl;
    }
    else
    {
        ost << -1 << endl;
    }
}

#ifndef WOMAIN
int main()
{
    solve(std::cin, std::cout);
    return 0;
}
#endif


Measured memory_bytes: 3696
#include <bits/stdc++.h>
//#include <atcoder/all>
#define ll long long int
#define MOD 1000000007
#define P pair<ll,ll>
#define INF 1000000000000000000

//using namespace atcoder;
using namespace std;

int main(void){
  ll n, k;
  cin >> n >> k;
  
  vector<ll> p(n);
  for (int i = 0; i < n; i++){
    cin >> p[i];
  }
  sort(p.begin(), p.end());
  
  ll ans = 0;
  for (int i = 0; i < k; i++){
    ans += p[i];
  }
  cout << ans << endl;

  return 0;
}


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

using namespace std;
using ll = long long;


int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for(int i = 0; i < n; i++)cin >> a[i];
    int ans = 0;
    for(auto i : a){
        ans += min(i, k - i) * 2;
    }
    cout << ans << endl;    
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    int r,c;
    cin >> r >> c;
    int a[r+1][c+1];
    for(int i=0;i<r+1;i++){
        for(int j=0;j<c+1;j++){
            a[i][j]=0;
        }
    }
    for(int i=0;i<r;i++){
        for(int j=0;j<c;j++){
            cin >> a[i][j];
        }
    }
    for(int i=0;i<r;i++){
        for(int j=0;j<c;j++){
            a[i][c]+=a[i][j];
        }
    }
    for(int i=0;i<c+1;i++){
        for(int j=0;j<r;j++){
            a[r][i]+=a[j][i];
        }
    }
    for(int i=0;i<r;i++){
        for(int j=0;j<c;j++){
            cout << a[i][j] << " ";
        }
        cout << a[i][c] <<endl;
    }
    for(int i=0;i<c;i++){
        cout << a[r][i] << " ";
    }
    cout << a[r][c] <<endl;
    return 0;
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define ALLG(v) v.begin(), v.end() ,greater<int>()
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
ll GCD(ll x, ll y) { return y ? GCD(y, x % y) : x; }
ll LCM(ll x, ll y) { return x * y / GCD(x, y); }
ll GetDigit(ll num) {
	ll digit = 0;
	while (num != 0) {
		num /= 10;
		digit++;
	}
	return digit;
}

using namespace std;
int main() {
	ll n,m;
	cin >> n >> m;

	ll total = 0;
	for (int i = 0; i < m; i++)
	{
		ll temp = 0;
		cin >> temp;
		total += temp;
	}

	ll ans =  n - total;

	if (ans < 0) {
		ans = -1;
	}
	


	

	cout <<  ans << endl;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (ll i=0; i<(n); ++i)
typedef long long ll;
bool debug=false;
string yes = "Yes";
string no = "No";

int main(){
  ll k,a,b; cin >> k >> a >> b;
  rep(i,1001){
    if(i*k >= a&&i*k<=b) {
      cout << "OK" << endl;
      return 0;
    }
  }
  cout << "NG" << endl;
  return 0;
}



Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
int main() {
  string str; cin >> str;
  int size = str.size();
  vector<bool> acgt(size, 0);
  for(int i = 0; i < size; i++) {
    if(str.at(i) == 'A' || str.at(i) == 'C' || str.at(i) == 'G' || str.at(i) == 'T') {
      acgt.at(i) = 1;
    }
  }
  int seen = 0, maxkari = 0, maxnum = 0;
  bool exist1 = 0;
  while(seen < size) {
    if(acgt.at(seen) == 0) {
      maxnum = max(maxnum, maxkari);
      maxkari = 0;
      exist1 = 1;
    }
    else {
      maxkari++;
    }
    seen++;
  }
  maxnum = max(maxnum, maxkari);
  cout << maxnum << endl;
}

Measured memory_bytes: 3600
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>

using namespace std;

int n;
int data[3];
vector<int> V[3];

bool common(int num){
  if(n == 2) return binary_search(V[1].begin(),V[1].end(),num);
  if(n == 3) return binary_search(V[1].begin(),V[1].end(),num)
	       && binary_search(V[2].begin(),V[2].end(),num);
}

int main(){

  cin >> n;

  for(int i = 0; i < 3; i++) cin >> data[i];

  for(int i = 0; i < n; i++){
    for(int j = 1; j*j <= data[i]; j++)
      if(data[i]%j == 0){
	V[i].push_back(j);
	if(j != data[i]/j) V[i].push_back(data[i]/j);
      }
    sort(V[i].begin(),V[i].end());
  }

  for(int i = 0; i < V[0].size(); i++)
    if(common(V[0][i])) cout << V[0][i] << endl;

  return 0;
}

Measured memory_bytes: 1224
import java.io.InputStream;
import java.io.PrintStream;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {

  public static void main(String[] args) {
    resolve(System.in, System.out);
  }

  static void resolve(InputStream is, PrintStream pw) {
    Scanner sc = new Scanner(is);
    int k = Integer.parseInt(sc.next());
    if (k % 2 == 0) {
      pw.println(-1);
      return;
    }
    Set<Integer> knownRemains = new HashSet<>();
    int remain = 7 % k;
    knownRemains.add(remain);
    int ans = 1;
    while (true) {
      if (remain == 0) {
        pw.println(ans);
        return;
      }
      remain = ((remain * 10) + 7) % k;
      if (knownRemains.contains(remain)) {
        pw.println(-1);
        return;
      }
      knownRemains.add(remain);
      ans++;
    }
  }
}


Measured memory_bytes: 102604
c = [list(map(int, input().split())) for i in range(3) ]

ans = True

X = 0
b = [c[i][0] - X for i in range(3)]
a = [c[0][i] - b[0] for i in range(3)]

for i in range(3) :
    for j in range(3) :
        if a[j] + b[i] != c[i][j] :
            ans = False

if ans :
    print('Yes')
else :
    print('No')


Measured memory_bytes: 3064
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        k: usize,
        ll: [u32;n],
    }
    let mut ll = ll;
    ll.sort();
    ll.reverse();
    let ll = &ll[0..k];
    println!("{}",
        ll.iter().sum::<u32>());
}


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

void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

typedef long long ll;

int main(){
    ll a , b;
    cin>>a>>b;

    if(b==1){
        cout<<0;
        return 0;
    }
    for(ll i=0;i<100;i++){
        ll tot = a + i*(a-1);
        if(tot>=b){
            cout<<i+1;
            return 0;
        }
    }

}


Measured memory_bytes: 764
#include "bits/stdc++.h"

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

using namespace std;
const int INF = 1 << 30;
const long long LINF = 1LL << 60;
const long long MOD = 1000000000 + 7;
const double PI = acos(-1);

int main() {
	int N; cin >> N;
	if (N % 1000 == 0)cout << 0;
	else cout << 1000 - (N % 1000);
}



Measured memory_bytes: 3620
import java.util.*;
class Stack{
    private Object stack[];
    private int stackSize;
    private int sp;
    public Stack(int n){
	stack = new Object[n];
	sp = 0;
    }

    public void clear(){ sp = 0; }
    public void push(Object x){ stack[sp++] = x; }
    public Object pop(){
	if(sp>0)
	    return stack[--sp];
	else return "*";
    }
    public boolean isEmpty(){ return sp==0; }
}

public class Main{
    static Scanner kbd = new Scanner(System.in);
    public static void main(String[] args){
	int i;

	while(kbd.hasNext()){	
	    Stack stack = new Stack(100);
	    
	    String line = kbd.nextLine();
	    int len = line.length();
	    i=0;
	    String x;
	   
	    if(! line.equals(".")){
		while(i<len){
		    String c = line.substring(i, i+1);
		    //System.out.println(c);
		    if(c.equals("(")){
			stack.push("(");
		    }
		    else if(c.equals(")")){
			x = (String)stack.pop();
			if(! x.equals("("))
			    stack.push("*");
		    }
		    else if(c.equals("[")){
			stack.push("[");
		    }
		    else if(c.equals("]")){
			x = (String)stack.pop();
			if(! x.equals("["))
			    stack.push("*");
		    }
		    i++;
		}
		//System.out.println(stack[0].isEmpty()+" "+stack[1].isEmpty());
		if(stack.isEmpty())
		    System.out.println("yes");
		else 
		    System.out.println("no");
	    }
	}
    }
}
		
		

Measured memory_bytes: 45248
#include<bits/stdc++.h>
#define int long long
#define PB push_back
#define FI first
#define SE second
using namespace std;
typedef pair<int,int> pii;
static const int inf = 1ll<<60;
static const int MAX_N = 10000;
int N;
int a[MAX_N+5];
int dp[2][MAX_N/2+5][2];
int ans=inf;

signed main(){
    cin>>N;
    for(int i=1;i<N;++i)cin>>a[i];
    for(int i=0;i<2;++i)for(int j=0;j<N/2;++j)for(int k=0;k<2;++k)dp[i][j][k]=inf;
    dp[0][0][0]=0;
    for(int i=0;i<N;++i){
        for(int j=0;j<N/2;++j){
            dp[(i+1)%2][j+1][0]=min(dp[i%2][j][0],dp[i%2][j][1]+a[i+1]);
            dp[(i+1)%2][j][1]=min(dp[i%2][j][0]+a[i+1],dp[i%2][j][1]);
        }
        for(int j=0;j<N/2;++j)dp[i%2][j][0]=dp[i%2][j][1]=inf;
    }
    cout<<min(dp[N%2][N/2][0],dp[N%2][N/2][0])<<endl;
}

Measured memory_bytes: 1388