akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("O3")
#pragma GCC target("avx")
#pragma GCC optimize("unroll-loops")
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>
#define LL long long
#define DB double
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MAX(x,y) ((x)<(y)?(y):(x))
#define FOR(i,a,n) for(i=a;i<n;i++)
#define rep(i,n) FOR(i,0,n)
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810364364
#define PI 3.14159265358979
#define ERR 0.00000001
#define NUM 200010

void swap(LL* a,LL* b){LL tmp=*a;*a=*b;*b=tmp;}
void Yn(LL a){if(a)printf("Yes\n");else printf("No\n");}
void YN(LL a){if(a)printf("YES\n");else printf("NO\n");}
LL pwmn(LL a,LL n){LL ans=1;while(ans<a)ans*=n;return ans;}
LL GCD(LL a,LL b){LL c=1,tmp=MAX(a,b);b=MIN(a,b);a=tmp;while(c!=0){c=a%b;a=b;b=c;}return a;}
LL LCM(LL a,LL b){return a*b/GCD(a,b);}
int lcmp(const void* a,const void* b){if(*(LL*)a>*(LL*)b)return 1;if(*(LL*)a<*(LL*)b)return -1;return 0;}
int lcmpr(const void* a,const void* b){if(*(LL*)a>*(LL*)b)return -1;if(*(LL*)a<*(LL*)b)return 1;return 0;}
int ccmp(const void* a,const void* b){return *(char*)a-*(char*)b;}
int ccmpr(const void* a,const void* b){return *(char*)b-*(char*)a;}
int scmp(const void* a,const void* b){return strcmp((char*)a,(char*)b);}
int scmpr(const void* a,const void* b){return strcmp((char*)b,(char*)a);}
LL mod(LL a,LL m){if(a<0)return a%m+m;else return a%m;}
LL DIV(LL a,LL d){LL m=MOD,x=1,y=0,k;while(m){k=d/m;d-=k*m;swap(&m,&d);x-=k*y;swap(&x,&y);}return mod(a*mod(x,MOD),MOD);}
LL POW(LL a,LL n){LL ans=1;while(n>0){if(n&1)ans=ans*a%MOD;a=a*a%MOD;n>>=1;}return ans;}
LL fact[NUM],finv[NUM],inv[NUM];
void comi(){LL i;fact[0]=fact[1]=1;finv[0]=finv[1]=1;inv[1]=1;FOR(i,2,NUM){fact[i]=fact[i-1]*i%MOD;inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;finv[i]=finv[i-1]*inv[i]%MOD;}}
LL com(LL n,LL k){if(n<k||n<0||k<0)return 0;return fact[n]*(finv[k]*finv[n-k]%MOD)%MOD;}

DB dist(DB x1,DB y1,DB x2,DB y2){return sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));}
void eqd(DB* vx1,DB* vy1,DB* vx2,DB* vy2,DB x1,DB y1,DB r1,DB x2,DB y2,DB r2){
  DB d=dist(x1,y1,x2,y2);
  if(d<ERR)*vx1=x1,*vy1=y1,*vx2=x2,*vy2=y2;
  else if(d-r1-r2>ERR)*vx1=-1,*vy1=-1,*vx2=-1,*vy2=-1;
  else if(r1+r2-d>ERR){
    DB c=(r1*r1+d*d-r2*r2)/(2*r1*d),d1=r1*c,x=x1+(x2-x1)*d1/d,y=y1+(y2-y1)*d1/d,h=sqrt(r1*r1-d1*d1);
    *vx1=x-(y2-y1)*h/d,*vy1=y+(x2-x1)*h/d,*vx2=x+(y2-y1)*h/d,*vy2=y-(x2-x1)*h/d;
  }
  else *vx1=x1+(x2-x1)*r1/(r1+r2),*vy1=y1+(y2-y1)*r1/(r1+r2),*vx2=*vx1,*vy2=*vy1;
}

int main(){
  LL N,i,j,k,l,flag;
  DB min=0-ERR,max=720.0,mid;
  scanf("%lld",&N);
  LL x[N],y[N];
  FOR(i,0,N)scanf("%lld%lld",&x[i],&y[i]);
  while(max-min>ERR){
    mid=(max+min)/2;
      FOR(i,0,N){
        FOR(j,i+1,N){
          DB nx[2],ny[2];
          eqd(&nx[0],&ny[0],&nx[1],&ny[1],x[i],y[i],mid,x[j],y[j],mid);
          FOR(l,0,2){
          flag=0;
          FOR(k,0,N)if(dist(x[k],y[k],nx[l],ny[l])>mid+ERR){
            flag=1;break;
          }
          if(flag==0)break;
        }
        if(flag==0)break;
      }if(flag==0)break;
    }
    if(flag==0)max=mid;
    else min=mid;
  }

  printf("%.10f\n",max);
	return 0;
}


Measured memory_bytes: 128
N=int(input())
K=input()
dic = {}
ts = 'RGB'
for t in ts:
    p=[]
    for ir, r in enumerate(K):
        if r == t:
            p.append(ir)
    dic[t] = p
ans1 = len(dic['R']) * len(dic['G']) * len(dic['B'])

ans2 = 0

for i in range(N):
    for j in range(i, N):
        if (i + 2*(j-i) < N):
            if  K[i] != K[j] and K[i] != K[i + 2*(j-i)] and K[i+2*(j-i)] != K[j]:
                ans2 +=1

print(ans1 - ans2)


Measured memory_bytes: 68340
#include<bits/stdc++.h>
using namespace std;
#define INF 1<<29
int d[101];
int V;
void dijkstra(int s,vector<vector<int> > &G){
  bool used[101];
  fill(d,d+101,INF);
  memset(used,false,sizeof(used));
  d[s]=0;
  while(1){
    int id=-1;
    for(int i=0;i<=V;++i){
      if(!used[i] && (id==-1||d[id]>d[i]))
        id=i;
    }
    if(id==-1) break;
    used[id]=true;
    for(int i=0;i<=V;++i){
      d[i]=min(d[i],d[id]+G[id][i]);
    }
  }
}
int main(){
  int k;
  while(cin>>V>>k,V){
    vector<vector<int> > G(V+1,vector<int>(V+1,INF));;    
    for(int i=0;i<k;++i){
      int x; cin>>x;
      if(x){
        int a,b,c; cin>>a>>b>>c;
        G[a][b]=G[b][a] = min(G[a][b], c);
      }else{
        int a,b; cin>>a>>b;
        dijkstra(a,G);
        cout<<(d[b]==INF?-1:d[b])<<endl;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 3096
import sys
def f0070(A,n,s):
  if n==1:return s in A
  c=0
  A=sorted(A)
  A1=A[:n][::-1]
  A2=A[-n:]
  N=range(n)
  def f(A):
    return sum([(i+1)*A[i] for i in N])
  if f(A1)<=s<=f(A2):
    for i in range(len(A)):
      b=s-A[i]*n
      c+=f0070(A[:i]+A[i+1:],n-1,b)
  return c
for a in sys.stdin:
  n,s=map(int,a.split())
  print f0070(range(10),n,s)

Measured memory_bytes: 4240
from statistics import mean, median,variance,stdev
import numpy as np
import sys
import math
import fractions
import itertools
import copy
from operator import itemgetter
#以下てんぷら
def j(q):
    if q==1: print("Yes")
    else:print("No")
    exit(0)


def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")

def ip():
    return int(input())

rem = pow(10,9)+7

#n = ip()                                     #入力整数1つ
#x,y,z= (int(i) for i in input().split())       #入力整数横2つ以上
#a = [int(i) for i in input().split()]        #入力整数配列
#a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列
#n = ip()                      #入力セット(整数改行あり)(1/2)
#a=[input() for i in range(x)]    #入力セット(整数改行あり)(2/2)

#jの変数はしようできないので注意
#全足しにsum変数使用はsum関数使用できないので注意
#こっから本文
a = input()
b = input()
c = input()
sa = [a[i] for i in range(len(a))]
sb = [b[i] for i in range(len(b))]
sc = [c[i] for i in range(len(c))]
next = a[0]
while True:
    if next == 'a':
        if len(sa) == 0:
            print("A")
            exit(0)
        next = sa[0]
        sa.pop(0)
    if next == 'b':
        if len(sb) == 0:
            print("B")
            exit(0)
        next = sb[0]
        sb.pop(0)
    if next == 'c':
        if len(sc) == 0:
            print("C")
            exit(0)
        next = sc[0]
        sc.pop(0)



Measured memory_bytes: 13708
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,n,s) for(int i = s; i < (n); ++i)
#define rsrep(i,n,s) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;

vint to[1005], rto[1005];
vbool from_1(1005, false), to_n(1005, false);

struct edge {
    int to;
    int from;
    ll cost;
};
 
void dfs(int v) {
    if (from_1[v]) return;
    from_1[v] = true;
    for (int u : to[v]) dfs(u);
}
 
void rdfs(int v) {
    if (to_n[v]) return;
    to_n[v] = true;
    for (int u : rto[v]) rdfs(u);
}
 
int main() {
    int n, m;
    cin >> n >> m;
    vector<edge> e(m);
    rep(i, m) {
        cin >> e[i].from >> e[i].to >> e[i].cost;
        e[i].from--;
        e[i].to--;
        e[i].cost *= -1;
        to[e[i].from].push_back(e[i].to);
        rto[e[i].to].push_back(e[i].from);
    }
 
    dfs(0);
    rdfs(n-1);
    vbool ok(n);
    rep(i, n) {
        ok[i] = from_1[i] & to_n[i];
    }
 
    vll v(n, LINF);
    v[0] = 0;
    rep(i, n) {
        bool update = false;
        rep(j, m) {
            if (ok[e[j].from] == false || ok[e[j].to] == false) continue;
            if (v[e[j].to] > v[e[j].from] + e[j].cost) {
                v[e[j].to] = v[e[j].from] + e[j].cost;
                update = true;
            }
        }
        if (i == n-1 && update) {
            puts("inf");
            return 0;
        }
    }
    ll ans = v[n-1] * -1;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
n, m = gets.chomp.split.map(&:to_i)

is_clear = Array.new(n+1, false)
clear = 0
pena = 0
p = [0]
s = [0]
1.upto(m) do |i|
  pp, ss = gets.chomp.split
  p[i] = pp.to_i
  s[i] = ss
end

1.upto(m) do |i|
  pp, ss = p[i], s[i]
  if ss == 'AC'
    unless is_clear[pp]
      clear += 1
      is_clear[pp] = i
    end
  end
end

1.upto(m) do |i|
  pp, ss = p[i], s[i]
  if ss == 'WA'
    if is_clear[pp] && is_clear[pp] > i
      pena += 1
    end
  end
end

puts "#{clear} #{pena}"


Measured memory_bytes: 11152
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

const int M = 1e9+7;

using namespace std;

main()
{
    fast;
    ll x,y;
    cin>>x;
    y=x%11;
    ll ans=x/11*2;
    if (y==0)
        cout<<ans<<endl;
    else if (y<=6)
        cout<<ans+1<<endl;
    else
        cout<<ans+2<<endl;
}


Measured memory_bytes: 256
#pragma GCC optimize(2)
#pragma G++ optimize(2)
#include<bits/stdc++.h>
#define si(a) scanf("%d",&a)
#define sl(a) scanf("%lld",&a)
#define sd(a) scanf("%lf",&a)
#define ss(a) scanf("%s",a)
#define ms(a) memset(a,0,sizeof(a))
#define repi(i,a,b) for(register int i=a;i<=b;++i)
#define repd(i,a,b) for(register int i=a;i>=b;--i)
#define reps(s) for(int i=head[s],v=e[i].to;i;i=e[i].nxt,v=e[i].to)
#define ce(i,r) i==r?'\n':' '
#define pb push_back 
#define all(x) x.begin(),x.end()
#define fi first
#define se second
//#define pr(x) cout<<#x<<": "<<x<<endl
using namespace std;
typedef long long ll;
const int MAX_N=1e5+5;
const ll inf=1e18;
inline int qi(){
    int f=0,fu=1; char c=getchar();
    while(c<'0'||c>'9'){ if(c=='-')fu=-1; c=getchar(); }
    while(c>='0'&&c<='9'){ f=(f<<3)+(f<<1)+c-48; c=getchar(); }
    return f*fu;
}
inline ll ql(){
	ll f=0;int fu=1; char c=getchar();
    while(c<'0'||c>'9'){ if(c=='-')fu=-1; c=getchar(); }
    while(c>='0'&&c<='9'){ f=(f<<3)+(f<<1)+c-48; c=getchar(); }
    return f*fu;
}
ll c[MAX_N],p[MAX_N];
bool vis[MAX_N];
ll b[MAX_N],sum[MAX_N];
ll cal(vector<ll> a,ll k)
{

	b[0]=sum[0]=0;
	for(auto x:a) b[++b[0]]=c[x];
	
	repi(i,1,b[0]) b[b[0]+i]=b[2*b[0]+i]=b[i];
	repi(i,1,3*b[0]) sum[i]=sum[i-1]+b[i];
	ll res=0,tk=k,tmp=-inf;
	if(sum[b[0]]>0){
		if((tk/b[0])>2) res+=sum[b[0]]*((tk/b[0])-1),tk-=b[0]*((tk/b[0])-1);
		repi(i,1,tk)repi(j,1,b[0]) tmp=max(tmp,sum[j+i-1]-sum[j-1]);	
	} 
	else{
		tk=min(tk,b[0]-1);
		repi(i,1,tk)repi(j,1,b[0]) tmp=max(tmp,sum[j+i-1]-sum[j-1]);
	}
	return res+tmp;
}
int main()
{
	ll n=ql(),k=ql();
	repi(i,1,n) p[i]=ql();
	repi(i,1,n) c[i]=ql();
	ll ans=-inf;
	repi(i,1,n)if(!vis[i]){
		ll now=i;
        vector<ll> tmp;
        while(p[now]!=i) tmp.pb(now),vis[now]=true,now=p[now]; vis[now]=true,tmp.pb(now);
    	ans=max(ans,cal(tmp,k));
	}
	printf("%lld\n",ans);
}

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

using namespace std;

using ll = long long;

struct Trie {
  bool leaf;
  Trie* node[2];
  Trie(){
    leaf = false;
    for(int i=0; i<2; i++){
      node[i] = (Trie*)0;
    }
  }
  void insert(const string &str){
    Trie *r = this;
    for(int i=0; i<str.length(); i++){
      char c = str[i];
      if(!r->node[c - '0']) r->node[c - '0'] = new Trie;
      r = r->node[c - '0'];
    }
    r->leaf = true;
  }
  bool find(const string &str) const {
    const Trie *r = this;
    for(int i=0; i<str.length(); i++){
      char c = str[i];
      if(!r->node[c - '0']) return false;
      r = r->node[c - '0'];
    }
    return r->leaf;
  }    
};

unordered_map<string, int> memo;
ll L;

void solve(int cur, Trie* r, vector<ll>& hoge) {
    if (!r->node[0] ^ !r->node[1]) hoge.push_back(L - cur);
    if (r->node[0]) solve(cur + 1, r->node[0], hoge);
    if (r->node[1]) solve(cur + 1, r->node[1], hoge);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n >> L;
    vector<string> sv(n);
    for (int i = 0; i < n; i++) {
        cin >> sv[i];
    }
    
    Trie t;
    for (int i = 0; i < n; i++) {
        t.insert(sv[i]);
    }

    vector<ll> hoge;
    solve(0, &t, hoge);
    ll foo = 0;
    for (ll x : hoge) {
        int cnt = 0;
        while (x > 0) {
            if (x & 1) break;
            cnt++;
            x >>= 1;
        }
        foo ^= (1LL << cnt);
    }
    cout << (foo != 0 ? "Alice" : "Bob") << endl;
    return 0;
}

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

int a, b, c;
int ans = ~(1<<31);

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string>
#include<cmath>

using namespace std;

#define ll long long int
#define ld long double
#define loop(i, n) for (int i = 0; i < n; i++)
#define loops(i, s, n) for (int i = s; i < n; i++)
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define sz(x) ((int)(x).size())
#define fi first
#define se second
#define deb(x) cout<< #x << '=' << x <<endl
#define MOD 1000000007

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

    int a;
    cin>>a;
    cout<<a + (a*a) + (a*a*a);
}

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

// iterator
#define REP(i,init, n) for(lli i=init;i<n;i++)
#define REPE(i,init, n) for(lli i=init;i<=n;i++)
#define REPIT(it,container) for(auto it = container.begin(); it != container.end(); it++)
#define REPIT_R(it,container) for(auto it = container.rbegin(); it != container.rend(); it++)

// input
#define cin1(x)             cin >> x
#define cin2(x, y)          cin >> x >> y
#define cin3(x, y, z)       cin >> x >> y >> z
#define ncin1(n, x)         REP(i, 0, n) {cin1(x[i]);}
#define ncin2(n, x, y)      REP(i, 0, n) {cin2(x[i], y[i]);}
#define ncin3(n, x, y, z)   REP(i, 0, n) {cin3(x[i], y[i], z[i]);}

#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

typedef long long int lli;
typedef pair<lli, lli> P;

int main() {
    lli n;
    cin1(n);
    lli a[n];
    ncin1(n, a);
    map<lli, lli> m;
    REP(i, 0, n) {
        m[a[i]]++;
    }
    if (m.size() > 3) {
        cout << "No" << endl;
        return 0;
    }
    else if (m.size() == 3) {
        lli num = m[a[0]];
        REPIT(it, m) {
            if (it->second != num) {
                cout << "No" << endl;
                return 0;
            }
        }
        lli x[3];
        lli ind = 0;
        REPIT(it, m) {
            //printf("key: %d, value: %d\n", it->first, it->second);
            x[ind] = it->first;
            //cout << x[ind] << endl;
            ind++;
        }

        if (((x[0] ^ x[1]) == x[2]) &&
                ((x[1] ^ x[2]) == x[0])&&
                ((x[2] ^ x[0]) == x[1])) {
            cout << "Yes" << endl;
            return 0;
        }
        cout << "No" << endl;

    }
    else if (m.size() == 2) {
        lli x_f[2];
        lli x_s[2];
        lli ind = 0;
        REPIT(it, m) {
            x_f[ind] = it->first;
            x_s[ind] = it->second;
            ind++;
        }
        if (x_f[0] != 0) {
            cout << "No" << endl;
            return 0;
        }
        if (x_s[0] * 2 != x_s[1]) {
            cout << "No" << endl;
            return 0;
        }
        cout << "Yes" << endl;
        return 0;
    }
    else if (m.size() == 1) {
        REPIT(it, m) {
            if (it->first != 0) {
                cout << "No" << endl;
                return 0;
            }
        }
        cout << "Yes" << endl;
        return 0;
    }

}


Measured memory_bytes: 5632
/*
@author James Fisher
@date
@version
*/

import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;


class Graph2 {
    private int totalVertex;
    private LinkedList<LinkedList<Integer>> adjList;
    private int[] completion;
    private boolean[] seen;
    private int[] indegree;

    // adjacency list of edges
    Graph2() {
        totalVertex = 0;
    }

    void loadAdjList() {
        Scanner in = new Scanner(System.in);
        totalVertex = in.nextInt();
        completion = new int[totalVertex];
        seen = new boolean[totalVertex];
        indegree = new int[totalVertex];

        int totalEdges = in.nextInt();
        adjList = new LinkedList<LinkedList<Integer>>();

        for(int i = 0; i < totalVertex ; i++) {
            LinkedList<Integer> tmp = new LinkedList<Integer>();
            adjList.add(tmp);
        }

        for (int i = 0; i < totalEdges; i++) {
            int vert = in.nextInt();
            int out = in.nextInt();
            adjList.get(vert).add(out);
            indegree[out]++;
        }

        in.close();
    }


    void isEligible() {
        Queue<Integer> eligible = new LinkedList<Integer>();
        for(int i = 0; i < totalVertex; i++) {
            if(indegree[i] == 0) {
                eligible.add(i);
            }
        }

        while(!eligible.isEmpty()) {
            int cur = eligible.poll();
            System.out.println(cur);
            for(Integer n : adjList.get(cur)) {
                indegree[n]--;
                if(indegree[n] == 0) {
                    eligible.add(n);
                }
            }
        }
    }
}
public class Main{
    public static void main(String argv[]) {
        Graph2 g = new Graph2();
        g.loadAdjList();
        g.isEligible();
    }
}



Measured memory_bytes: 74320
import java.util.Scanner;

public class Main {

    public static void main (String [] args){
        Scanner sc = new Scanner(System.in);
        int N =sc.nextInt();
        int D = sc.nextInt();
        int X =sc.nextInt();
        int ans =0;
        int A[] = new int[N];
        for (int i =0;i<N;i++){
            A[i] =sc.nextInt();
        }
        for (int i=0; i<N ;i++){
            int cnt=0;
            while(cnt*A[i]+1 <= D) {
                cnt++;
                ans += 1;
            }
        }
        ans += X;
        System.out.println(ans);
    }
}

Measured memory_bytes: 21844
import Foundation

class Scanner {
    static func readInt() -> Int {
        return Int(readLine()!)!
    }
    
    static func readIntArr() -> [Int] {
        return readLine()!.split(separator: " ").map { Int($0)! }
    }
    
    static func readM(_ n: Int) -> [[Int]] {
        var res = [[Int]]()
        for _ in 0..<n {
            res.append(readIntArr())
        }
        return res
    }
    
    static func readUknownIntMat() -> [[Int]] {
        var res = [[Int]]()
        while let line = readLine() {
            res.append(line.split(separator: " ").map { Int($0)! })
        }
        return res
    }
    
    static func readString() -> String {
        return readLine()!
    }
}

class Printer {
    static func printIntArray(_ arr: [Int]) {
        print(arr.map { String($0) }.joined(separator: " "))
    }
}


class Solution {
    func canFormPolygon(_ arr: [Int]) -> Bool {
        let total = arr.reduce(0) {$0 + $1}
        for side in arr {
            guard 0 < total-(2*side) else {
                return false
            }
        }
        return true
    }
}

let n = Scanner.readInt()
let arr = Scanner.readIntArr()
print(Solution().canFormPolygon(arr) ? "Yes" : "No")

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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int n;
vector<vi> g;
vi match;
vector<bool> used;
bool dfs(int v) {
    used[v] = true;
    for (int i=0; i<sz(g[v]); ++i) {
        int u = g[v][i], w = match[u];
        if (w==-1 || (!used[w] && dfs(w))) {
            match[v] = u;
            match[u] = v;
            return true;
        }
    }
    return false;
}

int main(){
    cin >> n;
    g = vector<vi>(n*2);
    match = vi(n*2, -1);
    vpii ab(n), cd(n);
    rep(i, n) cin >> ab[i].first >> ab[i].second;
    rep(i, n) cin >> cd[i].first >> cd[i].second;
    rep(i, n) rep(j, n) {
        if (ab[i].first >= cd[j].first) continue;
        if (ab[i].second >= cd[j].second) continue;
        g[i].pb(n+j);
        g[n+j].pb(i);
    }
    int ans = 0;
    rep(i, n) {
        if (match[n+i]==-1) {
            used = vector<bool>(n*2, false);
            if (dfs(n+i)) {
                ++ans;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


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

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

    int count=0;
    int a=S.size();

    for(int i=0;i<a/2;i++){
        if(S.at(i)!=S.at(a-i-1)){
            count++;
        }
    }
  
    cout << count << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
#include<map>
#include<iomanip>
#include<queue>

const long long INFL = 1e17+7;
const long long INFI = 1e9+7;
const long long MOD = 1e9+7;
const double EPS = 1e-8;
const double PI=acos(-1);

using namespace std;


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	long long a,b,c;
    cin >> a >> b >> c;
    int k;
    cin >> k;
  
    for(int i=0;i<k;i++){
      c*=2;
      if(c>b && b>a){
        cout << "Yes" << endl;
        return 0;
      }
    }
  
    for(int i=0;i<k;i++){
        c/=2;
        b*=2;
        if(c>b && b>a){
          cout << "Yes" << endl;
          return 0;
        }
    }
  
    cout << "No" << endl;
  
	return 0;
}


Measured memory_bytes: 3612
import java.util.Scanner;
import java.util.Stack;

public class Main {
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		while (true) {
			String line = s.nextLine();
			if (line.equals("."))
				break;
			System.out.println(CheckParenthesis(line) ? "yes" : "no");
		}
		s.close();
	}

	private static boolean CheckParenthesis(String line) {
		Stack<Character> stack = new Stack<Character>();
		for (int i = 0; i < line.length(); i++) {
			char ch = line.charAt(i);
			switch (ch) {
			case '[':
				stack.push(']');
				break;
			case '(':
				stack.push(')');
				break;
			case ']':
			case ')':
				if (stack.empty() || stack.pop() != ch)
					return false;
			}
		}
		return stack.empty();
	}
}

Measured memory_bytes: 32196
#include<bits/stdc++.h>
#include <iterator>
#include <iostream>
#include <numeric>
#include <math.h>
#define ll long long
#define ull long
#define mpa make_pair
#define pb push_back
#define ff first
#define pii pair<ll,ll>
#define dd long long
#define trace(x) cerr << #x << " : " << x << endl
#define ss second
#define boost ios_base::sync_with_stdio(0)
#define forp(i,a,b) for(ll i=a;i<=b;i++)
#define rep(i,n)    for(ll i=0;i<n;++i)
#define ren(i,n)    for(ll i=n-1;i>=0;i--)
#define forn(i,a,b) for(ll i=a;i>=b;i--)
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c).begin()) i = (c).begin(); i != (c).end();
#define sc(x) scanf("%lld",&x)
#define clr(x,val) memset(x,val,sizeof(x))
#define pr(x) printf("%lld\n",x) 
#define gc getchar
#define pdd pair<dd,dd>
#define prec(x) cout<<fixed<<setprecision(x)
#define fre freopen("input.txt","r",stdin),freopen("output.txt","w",stdout)
#define ar array 
using namespace std;

ll a[1000005];
ll mod=1e9+7;
int main(){
  ll t;
  string s;
  cin>>s;
  ll n=s.size();
 
  if(s[n-1]=='s')s+="es";
  else s+="s";
  cout<<s<<endl;
    
    
    
    
    
    
	
   
}
  

Measured memory_bytes: 3624
#include <iostream>
using namespace std;
int main() {
  int N; cin >> N;
  char color[N];
  for(int i = 0; i < N; i++)
    cin >> color[i];
  int yellow = 0;
  for(int i = 0; i < N; i++) {
    if(color[i] == 'Y') {
      yellow = 1;
      break;
    }
  }
  cout << ((yellow == 0) ? "Three" : "Four") << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main () {
	int l, r, d, tot = 0;
	scanf("%d %d %d", &l, &r, &d, &tot);
	while (l <= r ) {
		if (l % d == 0) {
			tot = tot + 1;
		}
		l++;
	}
	printf("%d\n", tot);
	return 0;	
}

Measured memory_bytes: 1736
fn main() {
    proconio::input! {
        a: i64,
        b: i64,
        c: i64,
        k: i64,
    }
    let ans = if a >= k {
        k
    } else if a + b >= k {
        a
    } else {
        a - (k - a - b)
    };
    println!("{}", ans);
}


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

#define ll long long
#define mm(a, b) memset(a, b, sizeof(a))
#define inf 999999999

#define For(i, a, b) for(ll i = (a);i <= (b); ++i)
#define rep(i, a, b) for(ll i = (a);i >= (b); --i)

#define gnn cerr << "GNN睡着了" << endl;

using namespace std;

ll read(){
	ll sum = 0, fg = 1;
	char c = getchar();

	while(c < '0' || c > '9'){if(c == '-')fg = -1;c = getchar();}
	while(c >='0' && c <='9')sum = (sum << 1) + (sum << 3) + c-'0', c = getchar();

	return sum * fg;
}

const ll maxn = 1000010;

ll n, m, cnt, Max;

struct node{
	ll x, y, t;
}a[maxn];

bool cmp(node c, node d){
	return c.t < d.t;
}

void Get(){
	n = read();
	For(i, 1, n) a[i].t = read(), a[i].x = read(), a[i].y = read();
	For(i, 1, n) Max = max(Max, a[i].t);
	sort(a + 1, a + n + 1, cmp);
}

char s[maxn];

bool flagg = 0;

void solve_bf(){
	ll x = 0, y = 0, t = 0;
	For(i, 1, n){
		ll mhd = abs(a[i].x - x) + abs(a[i].y - y);
		if(mhd % 2 != (a[i].t - t) % 2 || (a[i].t - t) < mhd){
			printf("No\n");
			flagg = 1;
			return;
		}

		ll mhdx = abs(a[i].x - x), mhdy = abs(a[i].y - y);
		For(j, 1, mhdx) if(a[i].x - x < 0) s[cnt++] = 'L'; else s[cnt++] = 'R';
		For(j, 1, mhdy) if(a[i].y - y < 0) s[cnt++] = 'D'; else s[cnt++] = 'U';
		For(j, mhd + 1, a[i].t - t) if(j & 1) s[cnt++] = 'U'; else s[cnt++] = 'D';

		x = a[i].x, y = a[i].y, t = a[i].t;
	}

	printf("Yes\n");
}

ll d[4][2] = {{0, 1}, {-1, 0}, {0, -1}, {1, 0}}, ls[maxn], flag, nowx[maxn], nowy[maxn];

char ss[] = "ULDR";

void check(){
	ll x = 0, y = 0;
	For(i, 1, m){
		x = x + d[ls[i]][0], y = y + d[ls[i]][1];
		nowx[i] = x, nowy[i] = y;
	}

	For(i, 1, n){
		ll nowtime = a[i].t / m;
		ll nowposx = nowx[m] * nowtime + nowx[a[i].t % m];
		ll nowposy = nowy[m] * nowtime + nowy[a[i].t % m];
		if(nowposx != a[i].x || nowposy != a[i].y) return;
	}

	flag = 1;
	For(i, 1, m){
		printf("%c", ss[ls[i]]);
	}printf("\n");
}

void dfs(ll h){
	if(flag) return;
	if(h == m+1){
		check();
		return;
	}
	For(i, 0, 3){
		ls[h] = i;
		dfs(h+1);
	}
}

void solve_other_bf(){
	dfs(1);
	if(!flag) printf("NO\n");
}

int main(){

	//freopen("Thunder.in", "r", stdin);
	//freopen("Thunder.out", "w", stdout);

	Get();
	solve_bf();
	
	return 0;
}


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

int pos;
string s[1010];

vector<int> tree[1010];
string name[1010];
int n;

int dfs(int depth){
	int cur = pos++;
	
	name[cur] = s[cur].substr(s[cur].find_first_not_of("."));
	vector<int> ch;
	while( pos < n &&  s[pos].find_first_not_of(".") == depth+1 ){
		ch.push_back(pos);
		dfs(depth+1);
	}
	tree[cur] = ch;
}

string dummy;
int get(int x,int depth=0){
	dummy = dummy + "|";
	for(int i = 0 ; i < tree[x].size() ; i++){	
		dummy[dummy.size()-1] = '+';
		cout << dummy << name[tree[x][i]] << endl;
		if( i + 1 == tree[x].size() ){
			dummy[dummy.size()-1] = ' ';
		}else{
			dummy[dummy.size()-1] = '|';
		}
		get(tree[x][i],depth+1);
	}
	dummy = dummy.substr(0,dummy.size()-1);
}

int main(){
	while( cin >> n && n ){
		pos = 0;
		for(int i = 0 ; i < 1010 ; i++) tree[i].clear();
		for(int i = 0 ; i < n ; i++) cin >> s[i];
		dfs(0);
		cout << name[0] << endl;
		get(0);
	}
}

Measured memory_bytes: 2328
#include <stdio.h>

int main(void) {
	int S[100000], T[50000], n, q, i, count;
	count = 0;

	scanf("%d",&n);
	for (i = 0;i < n;i++)
		scanf("%d", &S[i]);

	scanf("%d",&q);
	for (i = 0;i < q;i++) {
		scanf("%d", &T[i]);
		if (binarySearch(S, T[i], n) == 1) {
			count++;
		}
	}

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

}

int binarySearch(int s[], int key, int n) {
	int left = 0;
	int right = n;
	int mid;
	s[n] = key;

	while (left < right) {
		mid = (left + right) / 2;
		if (s[mid] == key)
			return 1;
		else if (key < s[mid])
			right = mid;
		else
			left = mid + 1;
	}
	return 0;
}


Measured memory_bytes: 2316
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
#define pb push_back
#define pii pair < int, int >
#define F first
#define S second
#define int  long long int
#define sync ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
const int N=2e5+100,M=63;
ll x[N];
ll par[N][M];
ll a[N];
pii t[N];
ll val[N];
ll getpar(ll v,ll h){
    for(int i=0;i<M;i++){
        if (h & ((ll)1 << i)) v = par[v][i];
    }
    return v;
}
int32_t main(){
    sync;
    ll n;
    cin >> n;
    for (int i=1;i<=n;i++){
        cin >> x[i];
    }
    ll m,k;
    cin >> m >> k;
    for (int i=1;i<=m;i++){
        cin >> a[i];
    }
    for (int i=2;i<=n;i++){
        t[i-1]={x[i]-x[i-1],i-1};
        val[i-1]=x[i]-x[i-1];
    }
    for (int i=1;i<=m;i++){
        swap(t[a[i]-1],t[a[i]]);
    }
    for (int i=1;i<=n-1;i++){
        par[i][0]=t[i].S;
    }
    for (int i=1;i<M;i++){
        for (int j=1;j<=n-1;j++){
            par[j][i]=par[par[j][i-1]][i-1];
        }
    }
    ll ans=x[1];
    for (int i=1;i<=n;i++){
        cout << ans << endl;
        ll z=getpar(i,k);
        //cout << i << " " << k << " " << z << " " << val[z] << endl;
        ans+=val[z];
    }

}


Measured memory_bytes: 58624
# include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
typedef long long ll;
int n,arr[100005];
int cnt;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>n;
    // 0=turun 1=naik
    int tren=2;
    for(int i=1;i<=n;i++){
        cin>>arr[i];
        if(i==1) continue;
        if(arr[i]>arr[i-1] && tren==0){
            tren=2;
            cnt++;
        }
        else if(arr[i]<arr[i-1] && tren==1){
            tren=2;
            cnt++;
        }
        else if(tren==2){
            if(arr[i]>arr[i-1]) tren =1;
            else if(arr[i]<arr[i-1]) tren =0;
        }
    }
    
    cout<<cnt+1<<endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
char a[100][100];
char b[100][100];
int main() {
 int N,M;
 cin>>N>>M;
 for(int i=0;i<N;i++){
     for(int j=0;j<N;j++){
     cin>>a[i][j];
 }
 }
 for(int i=0;i<M;i++){
     for(int j=0;j<M;j++){
     cin>>b[i][j];
 }
 }
 bool match=false;
 for(int i=0;i<N;i++){
     for(int j=0;j<N;j++){
      if(i+M-1>=N||j+M-1>=N){continue;}
      bool ok=true;
      for(int k=0;k<M;k++){
          for(int t=0;t<M;t++){
           if(a[i+k][j+t]!=b[k][t]){ok=false;}
          }
      }
      if(ok){match=true;}
     }
 }
 if(match){cout<<"Yes"<<endl;}
 else{cout<<"No"<<endl;}
 return 0;}

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

using namespace std;

// Header files, namespaces,
// macros as defined above
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>


#define f first
#define s second
#define db long double
#define pb push_back
#define sz(c) (c).size()
#define all(c) (c).begin(),(c).end()

typedef long long ll;
typedef pair <int , int> ii;
typedef pair <ii , ll> iii;
typedef vector <int> vi;
typedef vector <ii> vii;
typedef vector <iii> viii;
typedef vector <vi> vvi;
typedef vector <vii> vvii;

const ll mod = 1e9+7;
const int MAX = (1<<17);
const db eps = 1e-13;
const ll oo = 1e18;
ll dp[MAX] , cost[MAX];

ll A[17][17];

int main()
{

	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
    cout<<setprecision(0)<<fixed;

    int n;cin>>n;
    for( int i = 1; i <= n ; i++ )
        for( int j = 1; j <= n ; j++ )
            cin>>A[i][j];

    fill( dp , dp+(int)(1<<n), -oo );

    for( int mask = 1; mask < (1<<n) ; mask++ )
        for( int i = 0 ; i < n ; i++ )
            for( int j = i+1 ; j < n ; j++ )
                if( ( (1<<j)&mask ) && ( (1<<i)&mask ) )
                    cost[mask] += A[i+1][j+1];
//    cout<<dp[3]<<"\n";
//    cout<<cost[5]<<"\n";
    dp[0] = 0;
    for( int mask = 1; mask < (1<<n) ; mask++ )
        for( int s = mask ; s ; s = (s-1)&mask )
            dp[mask] = max( dp[mask] , dp[mask^s] + cost[s] );

    cout<<dp[(1<<n)-1]<<"\n";

}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
#define sz(x) ((int) (x).size())
#define forn(i,n) for (int i = 0; i < int(n); ++i)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long long i64;
typedef long double ld;
const int inf = int(1e9) + int(1e5);
const ll infl = ll(2e18) + ll(1e10);

const int maxn = 100100;
map<ll, ll> bad;
map<ll, int> cnt;

ll root(ll x) {
    ll y = roundl(sqrtl(x));
    while (y * y < x)
        ++y;
    while (y * y > x)
        --y;
    if (y * y != x)
        return -1;
    return y;
}

void add(ll x) {
    ll y = 1, z = 1;
    for (ll i = 2; i * i * i <= x; ++i) {
        if (x % i)
            continue;
        int deg = 0;
        while (x % i == 0)
            x /= i, ++deg;
        deg %= 3;
        if (deg == 0)
            continue;
        forn (j, deg)
            y *= i;
        forn (j, 3 - deg)
            z *= i;
    }
    ll rt = root(x);
    if (rt == -1) {
        y *= x;
        if (ld(x) * ld(x) * z > 1e12)
            z = infl;
        else
            z *= x * x;
    } else {
        y *= x;
        z *= rt;
    }
    bad[y] = z;
    cnt[y]++;
}

int main() {
    #ifdef LOCAL
    assert(freopen("d.in", "r", stdin));
    #else
    #endif
    int n;
    cin >> n;
    forn (i, n) {
        ll x;
        cin >> x;
        add(x);
    }
    int res = 0;
    for (auto p: cnt) {
        ll y = p.first, c = p.second;
        ll z = bad[y];
        if (y == 1) {
            ++res;
            continue;
        }
        int cz = cnt[z];
        if (cz > c || (cz == c && z > y))
            continue;
        res += c;
    }
    cout << res << '\n';
}


Measured memory_bytes: 20864
n, k = map(int, input().split())
li = list(map(int, input().split()))
 
check = [0] * (n+10)
res = []
next = 0
 
for i in range(k):
    if check[next] == 0:
        check[next] = 1
        next = li[next]-1
    elif check[next] == 1:
        check[next] += 1
        res.append(next+1)
        next = li[next]-1
    else:
        cnt = len(res)
        k -= check.count(1)
        amari = k%cnt
        print(res[amari])
        break
else:
    print(next+1)

Measured memory_bytes: 32372
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	static void Main(){
		Sc sc=new Sc();
		var s=sc.Ia;
		var a=sc.Ia;
		var dp=Enumerable.Repeat((int)1e9,s[0]+1).ToArray();
		dp[0]=0;
		for(int i = 0;i<s[1];i++) {
			for(int j = a[i];j<=s[0];j++) {dp[j]=Min(dp[j],dp[j-a[i]]+1);}
		}
		Console.WriteLine("{0}",dp[s[0]]);
	}
}

public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),long.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}


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

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

    for (int i = 0; i < n.size(); i++)
    {
        if (n[i] == '9')
            n[i] = '1';
        else
            n[i] = '9';
    }
    cout << n << endl;

    return (0);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define double long double
#define rep(i, a, n) for(int i = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int i = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int i = (int)(a);(x);++(i))
#define repr(i, a, n) for(int i = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int i = (int)(a);(i) >= (int)(n);--(i))
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x), end(x)
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), end(x))
#define gcd(x, y) __gcd(x, y)
#define lcm(x, y) ((x)/gcd(x,y)*(y))
#define isin(x, l, r) ((l) <= (x) and (x) < (r))
#define fcout(n) cout << fixed << setprecision(n)
#define rcout(n) cout << right << setw(n)
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define PI (acosl(-1))
#define EPS (1e-10)
#define INF LLONG_MAX
#define INF32 INT32_MAX
#define MOD 1000000007LL
using namespace std;
using VI = vector<int>;
using PII = pair<int, int>;
using TIII = tuple<int, int, int>;
using VPII = vector<PII>;
using VTIII = vector<TIII>;
using Complex = complex<double>;
template<typename T, template<typename> typename C = less> using PQ = priority_queue<T, vector<T>, C<T>>;
template<typename T> bool chmax(T& a, const T& b, bool t = false){ if(a<b or (t and a == b)){ a=b; return true; } return false; }
template<typename T> bool chmin(T& a, const T& b, bool t = false){ if(a>b or (t and a == b)){ a=b; return true; } return false; }


int N, M;
int h[1510];
int w[1510];
int ch[1500*1000+10];
int cw[1500*1000+10];


signed main(){
    while(cin >> N >> M, N+M){
        rep(i, 0, N) cin >> h[i];
        rep(i, 0, M) cin >> w[i];
        rep(i, 0, N){
            int s = 0;
            rep(j, i, N) s += h[j], ch[s]++;
        }
        rep(i, 0, M){
            int s = 0;
            rep(j, i, M) s += w[j], cw[s]++;
        }
        int ans = 0;
        repe(i, 1, 1500*1000) ans += ch[i]*cw[i], ch[i] = cw[i] = 0;
        cout << ans << endl;
    }

    return 0;
}


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

#define int long long
typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

int N, C, K;
int T[100000];

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N >> C >> K;
  rep(i, N) cin >> T[i];
  sort(T, T+N);
  int c = 0, h = 0, l = 0;
  while (true) {
    l = h;
    int mx = T[l] + K, v = C;
    while (v > 0 && h < N && T[h] <= mx) h++, v--;
    c++;
    if (h == N) break;
  }
  cout << c << "\n";
  return 0;
}


Measured memory_bytes: 1024
'''
問題：
    文字列 A, B, Cが与えられます。
    これがしりとりになっているか判定してください。

    つまり、
        A の最後の文字と B の最初の文字が同じ
        B の最後の文字と C の最初の文字が同じ
    この 2つが正しいか判定してください。
    両方とも正しいならば YES、そうでないならば NO を出力してください。
'''

'''
制約：
    A, B, C は全て英小文字(a ~ z)からなる。
    1 ≦ |A|, |B|, |C| ≦ 10
    なお、
    |A|, |B|, |C| は文字列A, B, Cの長さを表します。
'''

# 標準入力から A, B, C を取得する
a, b, c = map(str, input().split())

result = 'ret'

if ( a[-1] == b[0] ) and (b[-1] == c[0]) :
    result = 'YES'
else:
    result = 'NO'

print(result)


Measured memory_bytes: 9092
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main()
{
    string s,t;
    cin>>s>>t;
    sort(s.begin(),s.end());
    sort(t.begin(),t.end(),greater<char>());
    if(s<t)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef complex<double> P;
typedef vector<P> vec;

namespace std{
  bool operator < (const P &a,const P &b){
    return (a.imag()==b.imag()?
            a.real()<b.real():
            a.imag()<b.imag());
  }
};

double eps=1e-8;
double PI=acos(-1);

bool eq(double a,double b){return (b-a<eps&&a-b<eps);}
double dot(P a,P b){return real(b*conj(a));}
double cross(P a,P b){return imag(b*conj(a));}
P project(P a,P b,P c){b-=a;c-=a;return a+b*real(c/b);}
P reflect(P a,P b,P c){b-=a;c-=a;return a+conj(c/b)*b;}
int ccw(P a,P b,P c){
  b-=a,c-=a,a=c*conj(b);
  if(a.imag()>eps)return 1;//ccw
  if(a.imag()<-eps)return -1;//cw
  if(a.real()<-eps)return 2;//ob
  if(abs(b)+eps<abs(c))return -2;//of
  return 0;//os
}

//segment ab , point c
double dist(P a,P b,P c){
  if(dot(b-a,c-a)<0)return abs(c-a);
  if(dot(a-b,c-b)<0)return abs(c-b);
  return abs(cross(b-a,c-a))/abs(b-a);
}

bool isintersect(P a,P b,P c,P d){
  return ((ccw(a,b,c)*ccw(a,b,d)<=0)&&(ccw(c,d,a)*ccw(c,d,b)<=0));
}

//segment ab , segment cd
P intersect(P a,P b,P c,P d){
  a-=d;b-=d;c-=d;
  return d+a+(b-a)*imag(a/c)/imag(a/c-b/c);
}

double dist(P a,P b,P c,P d){
  if(isintersect(a,b,c,d))return 0;
  double ab=min(dist(a,b,c),dist(a,b,d));
  double cd=min(dist(c,d,a),dist(c,d,b));
  return min(ab,cd);
}

double calcArea(vec &t){
  double res=0;
  int n=t.size();
  for(int i=0;i<n;i++)res+=cross(t[i],t[(i+1==n?0:i+1)]);
  return abs(res/2.0);
}

double Arg(P a,P b,P c){
  b-=a,c-=a;
  return arg(c*conj(b));
}

int inPolygon(vec &t,P p){
  int n=t.size();
  double sum=0;  
  for(int i=0;i<n;i++){
    P a=t[i],b=t[(i+1==n?0:i+1)];
    if( ccw(a,b,p) == 0 )return 1;// on
    sum+= Arg(p,a,b);
  }
  if( abs(sum) < eps )return 0;//out
  else  return 2;//in
}

typedef pair<double,P> Pair;

vec andrewScan(vec &t){
  int N=t.size(),C=0;
  vec R;
  for(int i=0;i<N;i++){
    while(2<=C&&ccw(R[C-2],R[C-1],t[i])==-1)R.pop_back(),C--;
    R.push_back(t[i]),C++;
  }
  return R;
}
vec ConvexHull2(vec &t){
  sort(t.begin(),t.end());
  vec u=andrewScan(t);
  reverse(t.begin(),t.end());
  vec l=andrewScan(t);
  for(int i=1;i+1<(int)l.size();i++)u.push_back(l[i]);
  return u;
}

vec ConvexHull(vec &t){
  vector<Pair> u;
  vec R;
  int N=t.size(),K=0,C=0;
  for(int i=1;i<N;i++)if(t[i]<t[K])K=i;
  for(int i=0;i<N;i++)u.push_back(Pair(arg(t[i]-t[K]),t[i]));
  R.push_back(t[K]),C++;
  sort(u.begin(),u.end());
  for(int i=0;i<N;i++){
    P p=u[i].second;
    if(2<=C&&ccw(R[C-2],R[C-1],p)==0)continue;
    if(2<=C&&ccw(R[C-2],R[C-1],p)==2)continue;
    while(2<=C&&ccw(R[C-2],R[C-1],p)!=1)R.pop_back(),C--;
    R.push_back(p),C++;    
  }
  return R;
}

int main(){
  int n;
  cin>>n;
  vec t;
  double x,y;
  for(int i=0;i<n;i++){
    cin>>x>>y;
    t.push_back(P(x,y));
  }
  vec ans=ConvexHull2(t);
  cout<<ans.size()<<endl;
  for(int i=0;i<(int)ans.size();i++){
    cout<<(int)ans[i].real()<<' '<<(int)ans[i].imag()<<endl;
  }
  return 0;
}

Measured memory_bytes: 6288
#include <iostream>
#include <string>
#include <stdio.h>
using namespace std;

int main() {
  string name1,name2;
  long flag=0,i;
  cin >> name1;
  cin >> name2;
  for (i=0;i<name1.size();i++){
    if (name1[i]!=name2[i]){
      flag++;
    }
  }
  cout << flag;
  return 0;
}

Measured memory_bytes: 3804