akhauriyash/Code-Regression huggingface dataset:
#include <cmath>
#include <cstdio>
#include <algorithm>

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

using namespace std;

const double PI=acos(-1);

// whether (hx, hy) is covered by the sector (tx,ty,w,a)
bool check(int hx,int hy,int tx,int ty,double d,double w,int a){
	int x=hx-tx,y=hy-ty;
	if(sqrt(x*x+y*y)>a) return false;

	double phi=atan2(y,x);
	if(w>PI) w-=2*PI; // -PI < w <= PI
	return min(min(abs(phi-w),abs(phi-w+2*PI)),abs(phi-w-2*PI))<d/2;
}

int main(){
	for(int h,r;scanf("%d%d",&h,&r),h;){
		int hx[100],hy[100];
		rep(i,h) scanf("%d%d",hx+i,hy+i);

		int nu,nm,ns;
		double du,dm,ds;
		scanf("%d%d%d",&nu,&nm,&ns);
		scanf("%lf%lf%lf",&du,&dm,&ds);
		du*=PI/180;
		dm*=PI/180;
		ds*=PI/180;

		int ux[10],uy[10],mx[10],my[10],sx[10],sy[10];
		rep(i,nu) scanf("%d%d",ux+i,uy+i);
		rep(i,nm) scanf("%d%d",mx+i,my+i);
		rep(i,ns) scanf("%d%d",sx+i,sy+i);

		double w[100];
		int a[100];
		rep(i,r){
			scanf("%lf%d",w+i,a+i);
			w[i]*=PI/180;
		}

		int cnt[100]={};
		rep(i,h) rep(j,r) {
			bool ok=check(hx[i],hy[i],0,0,du,w[j],a[j]);
			rep(k,nu) if(check(hx[i],hy[i],ux[k],uy[k],du,w[j],a[j])) ok=false;
			rep(k,nm) if(check(hx[i],hy[i],mx[k],my[k],dm,w[j],a[j])) ok=false;
			rep(k,ns) if(check(hx[i],hy[i],sx[k],sy[k],ds,w[j],a[j])) ok=false;
			if(ok) cnt[i]++;
		}

		int maxi=*max_element(cnt,cnt+h);
		if(maxi==0){ puts("NA"); continue; }

		int num=0;
		rep(i,h) if(cnt[i]==maxi) {
			printf("%s%d",num>0?" ":"",i+1);
			num++;
		}
		puts("");
	}

	return 0;
}

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

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
//using namespace __gnu_pbds;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair <int,int> pii;
typedef pair <ll,ll> pll;

#define si(a)           scanf("%d",&a)
#define sii(a,b)        scanf("%d %d",&a,&b)
#define siii(a,b,c)     scanf("%d %d %d",&a,&b,&c)

#define sl(a)           scanf("%lld",&a)
#define sll(a,b)        scanf("%lld %lld",&a,&b)
#define slll(a,b,c)     scanf("%lld %lld %lld",&a,&b,&c)

#define un(x)           x.erase(unique(all(x)), x.end())
#define xx              first
#define yy              second
#define pb              push_back
#define mp              make_pair
#define all(v)          v.begin(),v.end()
#define D(x)            cerr << #x " = " << x << '\n'
#define DBG             cerr << "Hi!" << '\n'

#define CLR(a)          memset(a,0,sizeof(a))
#define SET(a)          memset(a,-1,sizeof(a))

#define PI              acos(-1.0)

//inline int setBit(int n,int pos) { return n = n | (1 << pos); }
//inline int resetBit(int n,int pos) { return n = n & ~(1 << pos); }
//inline bool checkBit(int n,int pos) { return (bool)(n & (1 << pos)); }
//inline int countBit(ll n) { return __builtin_popcountll(n); }


//int fx[] = {+0, +0, +1, -1, -1, +1, -1, +1};
//int fy[] = {-1, +1, +0, +0, +1, +1, -1, -1}; //Four & Eight Direction

/******************************************************************************************/

const int MAX = 100010;
const int INF = 0x3f3f3f3f;
//const double inf = 1.0/0.0;
const int MOD = 1000000007;

vector <int> ed[MAX];
vector <int> G[MAX];

void dfs(int s,int p) {
    for(auto x : ed[s]) {
        if(x == p) continue;
        G[s].pb(x);
        dfs(x,s);
    }
}

int dp[MAX][2];

int call(int s,int p) {

    if(dp[s][p]!=-1) return dp[s][p];

    ll ans0 = 1;
    ll ans1 = 1;

    for(auto x : G[s]) {
        ans0 *= call(x,0);
        ans0 %= MOD;
        ans1 *= call(x,1);
        ans1 %= MOD;
    }

    if(p==0) dp[s][p] = (ans0 + ans1) % MOD;
    else dp[s][p] = ans0;

    return dp[s][p];
}



int main() {
//    freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);

    int n,u,v;
    si(n);

    for(int i=1;i<n;i++) {
        sii(u,v);
        ed[u].pb(v);
        ed[v].pb(u);
    }

    dfs(1,-1);

    SET(dp);

    cout << call(1,0) << endl;

    return 0;
}



Measured memory_bytes: 18944
#include <stdio.h>
#include<string.h>
char word[1500];
int main() {
scanf("%[^\n]s",word);
int len = strlen(word);
for(int i=0;i<len;i++){
    if(word[i]>=65 && word[i]<=90){
        word[i] += 32;
    }
   else if(word[i]>=97 && word[i]<=122){
        word[i] -= 32;
    }
}
printf("%s\n",word);
    return 0;
}


Measured memory_bytes: 2064
import java.util.*;
import java.io.*;

public class Main {

    private static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

    public static void main(final String[] args) throws IOException {
        FastReader in = new FastReader();
        PrintWriter out = new PrintWriter(System.out, true);
        int n = in.nextInt();

        int num = n % 1000;
        int carry = n / 1000;
        out.printf("AB%s%n", carry == 0 ? 'C' : 'D');
    }

}


Measured memory_bytes: 22996
#include <stdio.h>

int main()
{
	int a = 0, b = 0;
	char flg = 0, naflg = 0;
	
	while ( scanf( "%d %d\n", &a, &b ) ) {
		if ( a == 0 && b == 0 ) {
			break;
		}
		if ( flg == 1 ) { printf( "\n" ); }

		naflg = 1;
		flg = 1;
		for ( int i = a ; i <= b ; i++ ) {
			if ( i % 4 == 0 && i % 100 != 0 || i % 400 == 0 ) {
				printf( "%d\n", i );
				naflg = 0;
			}
		}

		if ( naflg == 1 ){
			printf( "NA\n" );
		}
		a = b = 0;
	}
	
	return 0;
}



Measured memory_bytes: 1980
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
#define pb push_back
#define rsz resize
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
using pi = pair<int,int>;
#define ff first
#define ss second

void setIO(string name = "") { // name is nonempty for USACO file I/O
    ios_base::sync_with_stdio(0); cin.tie(0); // see Fast Input & Output
    freopen((name+".in").c_str(), "r", stdin); // see Input & Output
    freopen((name+".out").c_str(), "w", stdout);
}
// the code that we provide requires everything above this line to compile

int main() {
	int n, k;cin>>n>>k;
	int arr[n];
	for(int i = 0; i < n; ++i) cin>>arr[i];
	for(int i = k; i < n; ++i){
		if(arr[i] > arr[i-k]){
			cout<<"Yes\n";
			continue;
		}
		cout<<"No\n";
	}
    return 0;
}

Measured memory_bytes: 4380
N = int( input())
A = list( map( int, input().split()))
ans = 10**15
for i in [1, -1]:
    ansi, sums = 0, 0
    for a in A:
        sums += a
        if sums*i <= 0:
            ansi += abs(sums-i)
            sums = i
        i *= -1
    ans = min( ans, ansi)
print(ans)

Measured memory_bytes: 14332
#include<iostream>
#include<string>
#include<map>
#include<cctype>
using namespace std;

string s;
map<string,int> m;

int parse(int l, int r){
  int res = 0;

  for(int i=l;i<r;i++){
    if(s[i]=='('){
      int b = i+1;
      int k=0;
      while(s[++i]!=')' || k){
	if(s[i]=='(')k++;
	if(s[i]==')')k--;
      }

      int cal = parse(b,i);
      if(cal<0)return -1;

      int num = 0;
      while(isdigit(s[++i]))num = num*10 + (int)(s[i]-'0');
      if(!num)num=1;
      i--;
      res += cal * num;
    }else{
      string tmp; tmp += s[i];
      if(islower(s[i+1]))tmp += s[++i];

      int num = 0;
      while(isdigit(s[++i]))num = num*10 + (int)(s[i]-'0');
      if(!num)num=1;
      i--;

      if(m.find(tmp)!=m.end()){
	res += m[tmp] * num;
      }else{
	return -1;
      }
    }
  }
  return res;
}

int main(){
  string a;
  int w;

  while(cin >> a,a!="END_OF_FIRST_PART"){
    cin >> w;
    m[a] = w;
  }
  
  while(cin >> s,s!="0"){
    int ans = parse(0,s.size());
    if(ans<0)cout << "UNKNOWN\n";
    else cout << ans << endl;
  }
}

Measured memory_bytes: 1236
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author NikuKyabe
 */

#include <iostream>
#include <fstream>

#include "bits/stdc++.h"

using namespace std;
#define int long long
#define FOR(i, a, b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i, n)  FOR(i,0,(n))


class CColoringColorfully {
public:
    void solve(std::istream &in, std::ostream &out) {
      string s;
      in >> s;
      vector<string> ss(2, "");
      REP(i, s.length()) {
        ss[i % 2] += "0";
        ss[(i + 1) % 2] += "1";
      }
      int t0 = 0, t1 = 0;
      REP(i, s.length()) {
        if (s[i] != ss[0][i]) {
          t0++;
        } else if (s[i] != ss[1][i]) {
          t1++;
        }
      }
      out << min(t0, t1) << endl;
    }
};


signed main() {
  ios::sync_with_stdio(false);
  cout.tie(0);
  cout << fixed;
  CColoringColorfully solver;
  std::istream &in(std::cin);
  std::ostream &out(std::cout);
  solver.solve(in, out);
  return 0;
}


Measured memory_bytes: 720
#include <bits/stdc++.h>
#define FOR(I,X,Y) for(int I=X;I<Y;I++)
#define REP(I,X,Y) for(int I=Y-1;I>=X;I--)
#define INF 1000000007
#define LINF 1000000000000000007
typedef long long ll;
using namespace std;

ll S[100010];

int main(){
  ll N,K,a,b;
  cin >> N >> K;
  FOR(i,0,N){
    cin >> a >> b;
    S[a] += b;
  }
  FOR(i,1,100010)S[i] += S[i-1];
  FOR(i,1,100010){
    if(S[i-1] < K && K <= S[i]){
      cout << i << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;

int main() {
	long long N, K, A[100], MOD = 1000000007;
	static long long DP[110][100010] = {};
	DP[0][0] = 1;
	cin >> N >> K;
	for (int i = 0; i < N; i++) cin >> A[i];
	for (int i = 0; i < N; i++) {
		static long long SUM[100010] = {};
		for (int j = 0; j <= K; j++) {
			SUM[j + 1] = (SUM[j] + DP[i][j]) % MOD;
		}
		for (int j = 0; j <= K; j++) {
			DP[i + 1][j] = (SUM[j + 1] - SUM[max(0LL, j - A[i])] + MOD) % MOD;
		}
	}
	cout << DP[N][K] << endl;
}

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

int main(){
  int P,Q,R;
  cin >> P >> Q >> R;
  if(P>=Q && P>=R){
   cout << Q+R << endl;
  }
  else if(Q>=P && Q>=R){
   cout << P+R << endl;
  }
  else{
  cout << Q+P << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
using namespace std;

#define REP(i,n) for (int i = 0; i < (int)(n); ++i)
#define FOR(i,p,k) for (int i = p; i < (int)(k); ++i)
#define FOREACH(it,x) for (__typeof((x).begin()) it = (x).begin(); it != (x).end(); ++it)
#define ALL(x) x.begin(), x.end()
#define DEBUG(x) cerr<<#x":"<<(x)<<" "
template<class T> void DUMP(const T& v) { FOREACH(it,v) cerr<<*it<<' '; cerr<<endl; }

const int INF = 12345678;
vector<int> nums;

int memo[1000005][2];

int solve(int rest, int odd) {
  if (rest < 0) return INF;
  if (rest == 0) {
    return 0;
  }
  int& minv = memo[rest][odd];
  if (minv >= 0) return minv;
  minv = rest;
  for (int i = nums.size()-1; i >= 2; --i) {
    int v = nums[i];
    if (odd && v % 2 == 0) continue;
    if (rest < v) continue;
    if (minv <= rest / v) continue;
    minv = min(minv, solve(rest - v, odd) + 1);
  }
  return minv;
}

int main() {
  int n;
  for (int i = 0; ; i++) {
    int v = i * (i+1) * (i+2) / 6;
    if (v > 1000000) break;
    nums.push_back(v);
  }
  memset(memo, -1, sizeof(memo));
  while (cin >> n, n) {
    cout << solve(n, 0) << " " << solve(n, 1) << endl;
  }
  return 0;
}

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

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

int main() {

    int n;
    char s[333];
    deque<char> ans;
    Scd(n);
    Scs(s);

    int r = 0;
    Rep(i,n)
        ans.push_back(s[i]);

    Rep(i,n){
        if( s[i] == ')' ){
            if(r) r--;
            else
                ans.push_front('(');
        }
        if( s[i] == '(' ){
            r++;
        }
    }
    Rep(i,r){
        ans.push_back(')');
    }

    n = ans.size();
    Rep(i,n){
        printf ("%c", ans.front());
        ans.pop_front();
    }
    printf ("\n");


    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1LL << 60;
ll MOD = 1e9 + 7;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    int num = 1, cnt = 0;

    for (int i = 0; i < n; i++) {
        if (a[i] == num) {
            num++;
        } else {
            cnt++;
        }
    }
    if (num == 1) cnt = -1;
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 4000
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Kein Yukiyoshi
 */

#include "bits/stdc++.h"
#define int long long
#define rep(i, n)           for (int i = 0; i < (int)(n); i++)
#define REP(i, a, b)        for (int i = (int)(a); i < (int)(b); i++)
#define FOR(i, a)           for (auto &i : a)
#define ALL(obj)            begin(obj), end(obj)
#define MAX(x)              *max_element(ALL(x))
#define MIN(x)              *min_element(ALL(x))
#define LOWER_BOUND(A, key) distance(A.begin(), lower_bound(ALL(A), key))
#define UPPER_BOUND(A, key) distance(A.begin(), upper_bound(ALL(A), key))
#define Endl                endl

using namespace std;
const int MOD   = (int)(1e9 + 7);
const int INF   = (int)(1e13 + 7);
const double PI = acos(-1);

int CEIL(int a, int b) { return (a >= 0 ? (a + (b - 1)) / b : (a - (b - 1)) / b); } //ceil() for int
int mod(int a, int b) { return a >= 0 ? a % b : a - (b * CEIL(a, b)); }             //always return positive num
int pow(int x, int y) {                                                             //return x^y in order(log(y))
  if (x == 0) return 0;
  if (y == 0) return 1;
  int ans   = 1;
  int digit = (int)((log((double)y) / log((double)2) / 1 + 1));
  x %= MOD;
  for (int i = 0; i < digit; i++) {
    if (((y >> i) & 1u) == 1) ans = ans * x % MOD;
    x = x * x % MOD;
  }
  return ans;
}
template <class T>
void cumulative_sum(T &container) {
  for (int i = 0; i < container.size() - 1; i++) container[i + 1] += container[i];
}

class DColoringEdgesOnTree {
public:
  static void solve(istream &cin, ostream &cout) {
    int N;
    cin >> N;
    vector<int> color(N, 0);
    vector<pair<int, int>> edge(N - 1);
    vector<vector<pair<int, int>>> edge2(N);
    map<int, int> ans;
    rep(i, N - 1) {
      int a, b;
      cin >> a >> b;
      color[a - 1]++;
      color[b - 1]++;
      edge[i] = {a - 1, b - 1};
      edge2[a - 1].emplace_back(b - 1, i);
      edge2[b - 1].emplace_back(a - 1, i);
    }
    cout << MAX(color) << endl;
    deque<pair<int, int>> pos = {{0, 0}};
    vector<int> check(N, 0);
    check[0] = 1;
    while (pos.size()) {
      int now  = pos[0].first;
      int used = pos[0].second;
      pos.pop_front();
      int i = 0;
      rep(j, edge2[now].size()) {
        if (check[edge2[now][j].first]) continue;
        i++;
        if (i == used) i++;
        check[edge2[now][j].first] = 1;
        ans[edge2[now][j].second]  = i;
        pos.emplace_back(edge2[now][j].first, i);
      }
    }
    rep(i, N - 1) {
      cout << ans[i] << endl;
    }
  }
};


signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  DColoringEdgesOnTree solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}


Measured memory_bytes: 17408
#include <stack>
#include <queue>
#include <cstdio>
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <string>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n0,n) for(int i=n0;i<n;i++)
#define Com(i,j,n) for(int i=0;i<n-1;i++)for(int j=i+1;j<n;j++)
const int INF =100100100;
const int MOD = (int)1e9+7;
const double EPS = 1e-9;
typedef long long ll;
typedef long li;
#define pb push_back 
#define mp make_pair



signed main (){	
	int NN,max,hh,count=0;
	cin >> NN ;
	rep(i,NN) {
		cin >> hh ;
		if(i==0){
			count += 1;
			max = hh;
		} else {
			if(hh >= max) {
				count += 1;
				max = hh;
			}
		}
	}
	cout << count << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define itn int
#define mod 1000000007
#define INFi 2147483647
#define INFl 9223372036854775807LL
#define fi first
#define se second
#define be begin()
#define en end()
int abs(int a,int b){
    return max(a,b)-min(a,b);
}
signed main(){
// __builtin_ctz(N); Nを２で何回割り切れるかを返す
//(n+1)*n/2; １からNまでの総和を求める式
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b=0,e;
    pair<string,int> c[1000];
    string d,f;
    cin>>a;
    for(int i=0;i<a;i++){
	cin>>d>>e;
	c[i]=make_pair(d,e);
    }
    cin>>f;
    for(int i=0;i<a;i++){
	if(f==c[i].fi){
	    e=i;
	}
    }
    for(int i=e+1;i<a;i++){
	b+=c[i].se;
    }
    cout<<b<<"\n";
}


Measured memory_bytes: 256
// Problem : B - Simplified mahjong
// Contest : AtCoder - AtCoder Grand Contest 003
// URL : https://atcoder.jp/contests/agc003/tasks/agc003_b
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
using namespace std; 
#define ll long long int
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define INF LLONG_MAX
#define PI acos(-1)
const ll MOD = 1e9 + 7;
#define fir first
#define sec second
#define all(x) x.begin(),x.end()
#define mem(a,b) memset(a,b,sizeof(a))
#define rep(c,a,b) for(ll c=a;c<b;c++)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define min_heap priority_queue<pll,vector<pll>,greater<pll> >
ll dx4[]={-1,1,0,0};
ll dy4[]={0,0,-1,1};
ll dx8[]={-1,-1,-1,0,1,1,1,0};
ll dy8[]={-1,0,1,1,1,0,-1,-1};
bool isvalid(ll x,ll y,ll n,ll m)
{
    return (x>=0 and y>=0 and x<n and y<m);
}
ll isprime[1000];
vector<ll> prime;
void sievetoprime(ll n)
{
    mem(isprime,true);
    for(ll p=2;p*p<=n;p++)
    {
        if(isprime[p]==true)
        {
            for(ll i=p*p;i<=n;i+=p)
                isprime[i]=false;
        }
    }
}
ll lcm(ll a,ll b)
{
    return (a/__gcd(a,b))*b;
}
void solve()
{
    ll n;
    cin>>n;
    ll a[n];
    ll cnt=0,sum=0;
    rep(i,0,n)
    {
    	cin>>a[i];
    	if(a[i]!=0)
    	{
    		sum=sum+a[i];
    	}
    	else
    	{
    		cnt=cnt+sum/2;
    		sum=0;
    	}
    }
    cnt=cnt+sum/2;
    cout<<cnt;
}
int main()
{
    ll inpoup = 0;
    if(inpoup==1)
    {
        #ifndef ONLINE_JUDGE
            freopen("input.txt","r",stdin);
            freopen("output.txt","w",stdout);
        #endif
    }
    IOS
    ll t;
    t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
#define int long long
#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(obj) begin(obj), end(obj)
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define LOWER_BOUND(A, key) distance(A.begin(), lower_bound(ALL(A), key))
#define UPPER_BOUND(A, key) distance(A.begin(), upper_bound(ALL(A), key))

using namespace std;
using ll      = long long;
const int MOD = (int)(1e9 + 7);
const int INF = (int)(1e13 + 7);

int bpm(int x, unsigned int y) {
  if (x == 0) return 0;
  if (y == 0) return 1;
  int ans   = 1;
  int digit = (int)((log((double)y) / log((double)2) / 1 + 1));
  x %= MOD;
  for (unsigned int i = 0; i < digit; i++) {
    if (((y >> i) & 1u) == 1) ans = ans * x % MOD;
    x = x * x % MOD;
  }
  return ans;
}

const int MAX_ = 5000 + 10;
int Z[MAX_];
void Z_algorithm(string &S) { //length of size must be length of string
  fill(begin(Z), end(Z), 0);
  int c = 0;
  for (int i = 1; i < S.size(); i++) {
    if (i + Z[i - c] < c + Z[c]) {
      Z[i] = Z[i - c];
    } else {
      int j = max(0LL, c + Z[c] - i);
      while (i + j < S.size() and S[j] == S[i + j]) ++j;
      Z[i] = j;
      c    = i;
    }
  }
  Z[0] = S.size();
}

signed main() {
  int N;
  string S;
  cin >> N >> S;
  string temp{};
  int ans = 0;
  rep(i, N) {
    temp = string(1, S[i]) + temp;
    Z_algorithm(temp);
    rep(j, temp.size()) if (Z[j] <= j) ans = max(ans, Z[j]);
  }
  cout << ans << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20);} } fast;


int main() {
    string s;
    getline(cin, s);
    
    for (int i = 0; i < s.size(); i++){
        char c = s[i];
        if ('a' <= c && c <= 'z'){
            cout << char(c - 'a' + 'A');
        }else if ('A' <= c && c <= 'Z'){
            cout << char(c - 'A' + 'a');
        }else{
            cout << c;
        }
    }
    cout << endl;
}


Measured memory_bytes: 3236
#include<bits/stdc++.h>
#define ll long long
#define pii_ pair<int,int>
#define mp_ make_pair
#define pb push_back
#define fi first
#define se second
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define show1(a) cout<<#a<<" = "<<a<<endl
#define show2(a,b) cout<<#a<<" = "<<a<<"; "<<#b<<" = "<<b<<endl
using namespace std;
const ll INF = 1LL<<60;
const int inf = 1<<30;
const int maxn = 2e5+5;
inline void fastio() {ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);}
char s[maxn];
bool check()
{
    int n = strlen(s+1);
    if(s[1]!='1' || s[n]!='0') return false;
    rep(i,1,n-1){
        if(s[i]!=s[n-i]) return false;
    }
    return true;
}

int main()
{
    fastio();
    cin>>s+1;
    int n=strlen(s+1);
    if(!check()) {cout<<-1<<endl;return 0;}
    int cnt = 0;
    rep(i,1,n) if(s[i]=='1') cnt++;
    rep(i,1,cnt) cout<<i<<" "<<i+1<<endl;
    int last = 1,now=cnt+2,c=1;
    rep(i,2,n){
        if(s[i]=='1'){
            c++;
            int t = i-last-1;
            rep(j,1,t) cout<<c<<" "<<now++<<endl;
            last = i;
        }
    }
    return 0;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG true
#define LL long long
// sort(a.begin(), a.end(), std::greater<int>());
using namespace std;

int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> start;
    vector<int> end;
    rep(i, m)
    {
        int a, b;
        cin >> a >> b;
        if (a == 1)
        {
            start.push_back(b);
        }
        if (b == n)
        {
            end.push_back(a);
        }
    }
    SORT(start);
    SORT(end);
    rep(i,start.size()){
       if( binary_search(end.begin(), end.end(), start[i])==true){
           cout<<"POSSIBLE"<<endl;
           return 0;
       }
    }
    cout<<"IMPOSSIBLE"<<endl;
    return 0;
}


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

using namespace std;

using ll = long long;
using ld = long double;

void solve() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (auto &e : a) cin >> e;

    vector<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];
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int t = 1;
    // cin >> t;
    while (t--) solve();

    return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<iostream>
#include<functional>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<assert.h>
#include<stdlib.h>
#include<stack>
using namespace std;
/*********************Contest Template***********************/
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
typedef pair<int,int> Cord;
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(0);
struct S{
    int a,b; S(){}S(int _a,int _b){
        a=_a;
        b=_b;
    }
    const bool operator<(const S &o) const{
        return a<o.a;
    }
};
priority_queue<int,vector<int>,greater<int>> mpq;
#define SPACE 0
#define NL 1
inline void showAll(vector<int> &v,int NL_or_space){ 
    //0 is space, 1 is NL
    for(int &here:v){
        printf("%d",here);
        printf("%c",(NL_or_space)?'\n':' ');
    }
}
/*********************Contest Template***********************/
int main(){
    int arr[6];

    for(int i=1 ; i<=5 ; i++)
        scanf("%d",&arr[i]);
    int k;  scanf("%d",&k);

    for(int i=1 ; i<=5 ; i++){
        for(int j=i+1 ; j<=5 ; j++){
            if(abs(arr[i]-arr[j])>k){
                printf(":(\n");
                return 0;
            }
        }
    }
    printf("Yay!\n");

    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;


 
int main(){
    ll n,m; cin >> n >> m;
    char a[n][n];
    char b[m][m];
    /*rep(i,n){
        rep(j,n) cin >> a[i][j];
    }
    rep(i,m){
        rep(j,m) cin >> b[i][j];
    }*/
    rep(i,n) cin >> a[i];
    rep(i,m) cin >> b[i];
    bool flag;
    rep(i,n-m+1){
        rep(j,n-m+1){
            flag = true;
            rep(k,m){
                rep(l,m){
                    if(a[i+k][j+l] != b[k][l]){
                        flag = false;
                        break;
                    }
                }
                if(!flag) break;
            }
            if(flag){
                puts("Yes");
                return 0;
            }
        }
    }
    puts("No");
}


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

const int mod = 1e9+7;
const int maxn = 1e6+5;
void tlfclwx(){ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);}
int k[maxn];
int main()
{
    tlfclwx();
    int n, q;
    cin >> n >> q;
    for(int i = 1; i <= n; i++) cin >> k[i];
    sort(k+1, k+n+1);
    int a = n-q;
    if(a > 0) {
        ll sum = 0;
        for(int i = 1; i <= a; i++) {
            sum += k[i];
        }
    cout << sum << endl;
    }
    else cout << 0 << endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define rgi register int
#define ll long long
// using namespace std;
 
ll a,b,c,d;
inline ll solve()
{
	--a,--b,--c,--d;
	ll res=std::abs(a-c)+std::abs(b-d),t=1LL;
	for(rgi i=1;i<=33;++i) t*=3LL;
	for(rgi i=33;i>=0;--i)
	{
		for(rgi j=0;j<2;++j)
		{
			if(a/t==c/t&&(a/t)%3LL==1LL&&std::abs(b/t-d/t)!=1LL&&std::abs(b-d)>=t)
			{
				ll mn=std::min(a,c),mx=std::max(a,c);
				return res+std::min(mn-mn/t*t+1LL,(mx/t+1LL)*t-mx)*2LL;
			}
			std::swap(a,b),std::swap(c,d);
		}
		t/=3LL;
	}
	return res;
}
 
signed main()
{
	rgi q;
	std::cin>>q;
	while(q--)
	{
		std::cin>>a>>b>>c>>d;
		std::cout<<solve()<<std::endl;
	}
	return 0;
}
// ----------------------------
// by imzzy


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m; i<n; i++)
#define co(n) cout << n << endl
using namespace std;
int main(){
  int n, a, b;
  cin >> a >> b;
  co(a+b/2);
  
  return 0;
}


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

using ll = long long;

ll gcd(ll a, ll b, int& cnt) {
    if(b == 0) {
        return a;
    }
    return gcd(b, a % b, ++cnt);
}

//ll lcm(ll a, ll b) {
//    int g = gcd(a, b);
//    a /= g;
//    b /= g;
//    return a * b * g;
//}

int main() {
    int a, b;
    while(cin >> a >> b, a) {
        int cnt = 0;
        if(a < b) {
            swap(a, b);
        }
        int res = gcd(a, b, cnt);
        cout << res << ' ' << cnt << endl;
    }
}


Measured memory_bytes: 3088
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cassert>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define rep(i,n) FOR(i,0,n)
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define vint vector<int>
#define vdouble vector<double>
#define vstring vector<string>
using namespace std;

#include<map>
#include<set>
#include<queue>

typedef long long ll;
typedef unsigned long long ull;

const int MAX_N = 1000000;
const int INFTY = (1 << 21); // 2097152
// const ll INFTY = (1 << 60);

class Edge{
public:
	int from, to, cost;
	Edge(int from = 0, int to = 0, int cost = 0) :
			from(from), to(to), cost(cost){}

	bool operator < (const Edge &e) const{
		return cost < e.cost;
	}
	bool operator >(const Edge &e) const{
		return cost > e.cost;
	}

};

class Node{
public:
	vector<Edge> edges;
	int dist;

	Node(){
		dist = INFTY;
	}
};

class Graph{
public:
	vector<Node> nodes;
	Graph(int n) {
		rep(i, n) { Node n;  nodes.push_back(n); }
	}
	Node& operator[](int i){
		return nodes[i];
	}
};

class Data{

public:
	int dist;
	Edge *edge;
	Data(int dist, Edge *edge) {
		this->dist = dist;
		this->edge = edge;
	}

	bool operator < (const Data &d) const{
		return dist < d.dist;
	}
	bool operator >(const Data &d) const{
		return dist > d.dist;
	}
};

Graph G(0);
int N;

int prim(){

    priority_queue<Edge, vector<Edge>, greater<Edge>> pq;
    Edge e0 = Edge(-1, 0, 0);
    pq.push(e0);

    while(!pq.empty()){
        Edge e = pq.top(); pq.pop();
        Node &n = G[e.to];
        if(n.dist != INFTY) continue;
        n.dist = e.cost;
        // cerr << n.dist << endl;

        for(auto &ee: n.edges){
            pq.push(ee);
        }
    }

    int ret = 0;
    rep(i, N) ret += G[i].dist;
    return ret;
}

int main() {
	cin >> N;
	G = Graph(N);

    rep(i, N){
        rep(j, N) {
            int cost;
            cin >> cost;
            if(cost != -1){
                int from = i; int to=j;
                G[from].edges.push_back(Edge(from, to, cost));
            }
        }
    }

	cout << prim() << endl;
}

Measured memory_bytes: 3204
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  string N;
  cin >> N;
  if(N[0]==N[1]&&N[1]==N[2])
  {
    cout << "Yes" << endl;
    return 0;
  }
  else if(N[1]==N[2]&&N[2]==N[3])
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
  
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <limits.h>

#define DEF_ELEM_MAX 200000

typedef long long llong;

int S[DEF_ELEM_MAX];
int L[DEF_ELEM_MAX/2+2];
int R[DEF_ELEM_MAX/2+2];
	int N;
/////////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////////
llong merge(int *A, int left, int mid, int right)
{
	llong cnt = 0;
	int i;
	int j;
	int k;
	int n1 = mid - left;
	int n2 = right - mid;

//  L[0...n1], R[0...n2] ?????????

	for ( i = 0 ; i < n1 ; i++ ) {
		L[i] = A[left + i];
	}

	for ( i = 0 ; i < n2 ; i++ ) {
		R[i] = A[mid + i];
	}

	L[n1] = INT_MAX;
	R[n2] = INT_MAX;
	i = 0;
	j = 0;
	for ( k = left ; k < right ; k++ ) {
		if ( L[i] <= R[j] ) {
			A[k] = L[i++];
		} else {
			A[k] = R[j++];
			cnt += n1 - i; // = mid + j - k -1
		}
	}
	return cnt;
}

/////////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////////
llong mergeSort(int *A, int left, int right)
{
	llong v1;
	llong v2;
	llong v3;
	int mid;
	if (left+1 < right) {
		mid = (left + right)/2;
		v1 = mergeSort(A, left, mid);
		v2 = mergeSort(A, mid, right);
		v3 = merge(A, left, mid, right);
		return v1+v2+v3;
	} else {
		return 0;
	}
}
/////////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////////
int main(void)
{
	llong ans;
	int i;
//
	scanf("%d", &N);
	for ( i = 0 ; i < N ; i++ ) {
		scanf("%d", &S[i] );
	}

	ans = mergeSort(S, 0, N);

	printf("%ld\n", ans);

	return 0;
}

Measured memory_bytes: 2156
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e18 + 3)
template<class T> bool chmax(T &a,  T b) {if(a<b){a=b; return 1;} return 0;}
template<class T> bool chmin(T &a,  T b) {if(a>b){a=b; return 1;} return 0;}
bool Add(int &a,int b){a = (a + b) % MOD;}
void myprint(int* A,int A_num){
   REP(i,A_num) cout << A[i] << " ";
   cout << endl;
}

signed main(){
    int n;
    cin >> n;
    int A[n];
    int sum = 0;
    REP(i,n){
        cin >> A[i];
        sum += A[i];
    }
    if(A[0] * 2 >= sum){
        cout << 2 * A[0] - sum << endl;
        return 0; 
    }
    if(A[n-1] * 2 >= sum){
        cout << 2 * A[n-1] - sum << endl;
        return 0;
    }
    int tmp = 0;
    int ans = 0;
    REP(i,n){
        if(2 * (tmp +A[i]) > sum){
            ans = min(2 *(tmp + A[i]) -sum, sum - 2 * tmp);
            break;
        }
        tmp += A[i];
    }
    cout << ans << endl;


}

Measured memory_bytes: 1792
"use strict";
function main(input) {
  let kari = input[0].trim().split(" ");
  let n = parseInt(kari[0]);
  let r = parseInt(kari[1]);

  console.log((n>=10)?r:(r + 100*(10-n)));
}
main(require('fs').readFileSync('/dev/stdin', 'utf8').trim().split("\n"));

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

// Shrotening
#define fst first
#define snd second
#define pb push_back
#define mp make_pair

// Loop
#define FOR(i,a,b) for(auto i=(a);i<(b);++i)
#define RFOR(i,a,b) for(auto i=(a);i>=(b);--i)

#define REP(i,a) for(long i=0;i<(a);++i)
#define RREP(i,a) for(long i=(a);i>=0;--i)

#define EACH(i,a) for(auto (i)=(a).begin(),_END=(a).end();i!=_END;++i)
#define REACH(i,a) for(auto (i)=(a).rbegin(),_END=(a).rend();i!=_END;++i)

//Algorithm
#define ALL(a) (a).begin(), a.end()
#define RALL(a) (a).rbegin(), a.rend()
#define EXIST(a,x) ((a).find(x)!=(a).end())
#define SORT(a) std::sort((a).begin(), (a).end())
#define UNIQUE(a) std::sort((a).begin(), a.end()), a.erase(std::unique((a).begin(), a.end()), a.end());
#define SUM(a) std::accumulate((a).begin(), (a).end(), 0);

//Setting
#define OPT std::cin.tie(0);std::ios::sync_with_stdio(false);

//debug message
bool debug = true;
#define MSG(s)   if(debug){std::cout << s << std::endl;}
#define DEBUG(x) if(debug){std::cout << "debug(" << #x << "): " << x << std::endl;}

//alias
typedef long long LL;
typedef std::vector<char> VC;
typedef std::vector<int>  VI;
typedef std::vector<long> VL;
typedef std::vector<long long> VLL;

typedef std::vector< VC > VC2;
typedef std::vector< VI > VI2;
typedef std::vector< VL > VL2;
typedef std::vector< VLL > VLL2;

typedef std::pair<int,int> PII;


int n;
VI w(301);
VI2 memo(301, VI(301));

int dp(int l, int r) {
    if(l == r) return 0;
    if(r-l == 1) return (std::abs(w[l]-w[r]) <= 1) ? 2 : 0;
    if(memo[l][r] != -1) return memo[l][r];

    int ans = 0;
    if(std::abs(w[l]-w[r]) <= 1) {
        int res = dp(l+1, r-1);
        if(res == r-l-1) {
            ans = 2 + res;
        }
    }
    for(int i=l; i<r; ++i) {
        ans = std::max(ans, dp(l, i) + dp(i+1, r));
    }
    return memo[l][r] = ans;
}

int main() {
    while(std::cin >> n, n != 0) {
        REP(i, n) {
            std::cin >> w[i];
        }
        memo.assign(301, VI(301, -1));
        std::cout << dp(0, n-1) << std::endl;
    }
}


Measured memory_bytes: 3244
#include <bits/stdc++.h>
using namespace std;
string s[] = {
    "", "Man", "Oku", "Cho", "Kei", "Gai", "Jo",
    "Jou", "Ko", "Kan", "Sei", "Sai", "Gok", "Ggs",
    "Asg", "Nyt", "Fks", "Mts"
};
int main(){
  int n,m;
  while(cin>>m>>n,m){
    int a[18]={};
    a[0]=1;
    for(int i=0;i<n;i++)
      for(int j=17;j>=0;j--){
        a[j]*=m;
        a[j+1]+=a[j]/10000;
        a[j]=a[j]%10000;
      }
    for(int i=17;i>=0;i--)if(a[i])cout<<a[i]<<s[i];
    cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 3216
while True:
    try:
        n=input()
        a=0
        b=0
        
        for i in range(len(n)-2):
            if n[i:i+3]=="JOI":
                a+=1
            elif n[i:i+3]=="IOI":
                b+=1
        print(a)
        print(b)
    except:
        break


Measured memory_bytes: 5568
N = gets.to_i
as = []
bs = []
N.times{
	pair = gets.split(/ /).collect{|num| num.to_i}
	as << pair[0]
	bs << pair[1]
}
i = N - 1
plus = 0
while i >= 0
	b = bs[i]
	a = as[i] + plus
	if a == 0
	elsif b > a
		plus += b - a
	elsif (rem = a % b) != 0
		plus += b - rem
	end
	
	i -= 1
end
puts plus


Measured memory_bytes: 4216
#include<cstdio>
#include<vector>
#include<algorithm>

using namespace std;
int main(void) {
	long long n, m;
	long long x, y, z;
	vector<pair<long long, long long> >a;
	scanf("%lld %lld", &n, &m);
	for (long long i = 0; i < n; i++) {
		scanf("%lld %lld", &x, &y);
		a.push_back(make_pair(x, y));
	}
	sort(a.begin(), a.end());
	z = 0;
	for (long long i = 0; i < n; i++) {
				z += min(m, a[i].second)*a[i].first;
				m -= min(m, a[i].second);
}
	printf("%lld\n", z);

	return 0;
}

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

int main(){
 int n;
 cin>>n;
 int tarous=0,hanakos=0;
 for(int i=0;i<n;i++){
 string tarou,hanako;
 cin>>tarou>>hanako;
 if(tarou>hanako){
 tarous+=3;
 }else if(tarou<hanako){
 hanakos+=3;
 }else{
 tarous++;
 hanakos++;
 }
}
 cout<<tarous<<" "<<hanakos<<endl;
 
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
#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 pb push_back
#define mp make_pair
#define fst first
#define snd second
#define Size(x) ((int)x.size())
using namespace std;
typedef long long ll;
const int N = 400010;
int n, m, a[N], b[N], value[N], id[N], fa[N];
vector<int> e[N];
ll f[N], g[N]; bool vis[N];

template<typename T> void gi(T &x) {
	x = 0; register char c = getchar();
	for(; c < '0' || c > '9'; c = getchar());
	for(; c >= '0' && c <= '9'; c = getchar()) x = x * 10 + (c ^ 48);
}
inline bool cmp(const int &x, const int &y) { return value[x] < value[y]; }
int find(int x) { return x == fa[x] ? x : fa[x] = find(fa[x]); }
int main() {
	gi(n), gi(m);
	rep(i, 1, n) gi(a[i]), gi(b[i]), value[i] = max(0, a[i] - b[i]), id[i] = fa[i] = i;
	sort(id + 1, id + n + 1, cmp);
	rep(i, 1, m) { int x, y; gi(x), gi(y), e[x].pb(y), e[y].pb(x); }
	rep(i, 1, n) {
		vector<int> edge; int u = id[i]; vis[u] = 1, g[u] = b[u];
		for(auto v : e[u]) if(vis[v] && find(u) != find(v))
			edge.pb(v), edge.pb(find(v)), g[u] += g[find(v)], fa[find(v)] = u;
		f[u] = g[u] + value[u];
		for(auto v : edge) f[u] = min(f[u], g[u] - g[v] + max(1ll * value[u], f[v]));
	}
	printf("%lld\n", f[id[n]]);
	return 0;
}

Measured memory_bytes: 25720
n = int(input())
a = list(map(int,input().split()))

sum_a = sum(a)
ans = [0]*n
ans[0] = sum_a - 2*(sum(a[1:n-1:2]))
for i in range(1,n):
    ans[i] = 2*a[i-1] - ans[i-1]
print(*ans)

Measured memory_bytes: 20552
#include "bits/stdc++.h"
using namespace std;
int main()
{
    int n, maxv = -2000000000, minv, a;
    scanf("%d", &n);
    scanf("%d", &minv);
    for (int i = 1; i < n; i++)
    {
        scanf("%d", &a);
        maxv = max(a - minv, maxv);
        minv = min(a, minv);
    }
    printf("%d\n", maxv);
}


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

int main(){
  int a,b;
  cin>>a>>b;
  a--;
  b--;
  if(!a)a=13;
  if(!b)b=13;

  if(a>b){
    cout<<"Alice"<<endl;
  }else if(a==b){
    cout<<"Draw"<<endl;
  }else{
    cout<<"Bob"<<endl;
  }
}


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

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

using namespace std;

// data
int n, q;
vector<int> A;

bool solve(int i, int M);
int main(){
    // input 
    cin >> n;
    rep(i, n){
        int Ai; cin >> Ai;
        A.push_back(Ai);
    }

    cin >> q;
    rep(i, q){
        int M; cin >> M;

        cout << (solve(0, M) ? "yes": "no") << endl;
    }
}

bool solve(int i, int M){
    // pre end
    if(M == 0 || M == A[i]) return true;
    if(M < 0) return false;
    // end
    if(i == n-1) return false; // recursive to A_n-1 but need to make M !=

    // recursive
    return solve(i+1, M) || solve(i+1, M-A[i]);
}


Measured memory_bytes: 3140
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            string sN = System.Console.ReadLine().Trim();
            int iN = int.Parse(sN);
            List<ClsDes> lstDes = new List<ClsDes>();
            for (int i = 0; i < iN; i++)
            {
                string[] sS = System.Console.ReadLine().Trim().Split(' ');
                ClsDes oneUsr = new ClsDes();
                oneUsr.iA = long.Parse(sS[0]);
                oneUsr.iB = long.Parse(sS[1]);
                oneUsr.iC = oneUsr.iA + oneUsr.iB;
                lstDes.Add(oneUsr);
            }

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            //lstDes.Sort(delegate (ClsDes mca1, ClsDes mca2) { return (int)(mca2.iA - mca1.iA == 0 ? mca2.iB - mca1.iB : mca2.iA - mca1.iA); });      // Aの降順のBの降順
            lstDes.Sort(delegate (ClsDes mca1, ClsDes mca2) { return (int)(mca2.iC - mca1.iC); });      // Cの降順
            long iASm = 0L;
            long iBSm = 0L;
            for (int i = 0; i < lstDes.Count; i++)
            {
                if (i % 2 == 0) { iASm += lstDes[i].iA; }
                else { iBSm += lstDes[i].iB; }
            }
            long iOut = iASm - iBSm;

            // 出力
            System.Console.WriteLine("{0}", iOut.ToString().Trim());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }

        private class ClsDes
        {
            public long iA { get; set; } = 0L;
            public long iB { get; set; } = 0L;
            public long iC { get; set; } = 0L;
        }

}


Measured memory_bytes: 22844
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <set>
#include <map>
using namespace std;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))
#define rep(i,a,b) for(int (i)=int(a);(i)<int(b);(i)++)
#define rrep(i,a,b) for(int (i)=int(a);(i)>=int(b);(i)--)

#define put(a) cout << (a) << endl
#define puts(a) cout << (a) << " "

#define llint long long int

#define INF (long long)1e9+1
#define MOD (long long)1e9+7
#define INF64 (long long)1e18+1

#define F first
#define S second

#define Pii  pair<int,int>
#define Pll  pair<long long,long long>
#define Piii pair<int,pair<int,int>>
#define Plll pair<long long,pair<long long,long long>>

#define Vll(a,b,c)    vector<vector<long long>> (a)((b),vector<long long>((c))
#define Vlll(a,b,c,d) vector<vector<vector<long long>>> (a)((b),vector<vector<long long>>((c),vector<long long>((d)))

#define MAX_N 1000000

int main (void)
{
  //INPUT
  llint A,B;
  cin >> A >> B;

  //SOLVE
  llint ans;
  ans = max(A+B,A-B);
  ans = max(ans,A*B);

  //OUTPUT
  cout << ans << endl;

  return 0;
}


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

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

    vector<int> dp(n + 1);
    dp[0] = 1; dp[1] = 1;
    for (auto i = 2; i <= n; i++) dp[i] = dp[i - 1] + dp[i - 2];

    cout << dp[n] << endl;
    return 0;
}


Measured memory_bytes: 3104
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::{stderr, stdin, stdout, BufRead, BufWriter, Read, StdoutLock, Write};
#[allow(unused_imports)]
use std::iter::FromIterator;
#[allow(unused_imports)]
use std::{i64, u64, usize};
#[allow(unused_macros)]
/// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules !input {(source =$s :expr ,$($r :tt ) *) =>{let mut iter =$s .split_whitespace () ;input_inner !{iter ,$($r ) *} } ;($($r :tt ) *) =>{let mut 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 ) *} } ;}
#[allow(unused_macros)]
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 ) *} } ;}
#[allow(unused_macros)]
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" ) } ;}
#[allow(unused_macros)]
macro_rules !dbg {($($a :expr ) ,*) =>{writeln !(&mut stderr () ,concat !($(stringify !($a ) ," = {:?}, " ) ,*) ,$($a ) ,*) .unwrap () ;} }
#[allow(non_snake_case)]
#[allow(dead_code)]
fn main() {
    input! {
        x: u64
    }
    let div100 = x / 100;
    if x % 100 <= div100 * 5 {
        println!("1");
    } else {
        println!("0");
    }
}

Measured memory_bytes: 4352