akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

const int DIM = 2e5 + 5;

int oki[DIM];
vector<int> edg[DIM];

void dfs( int x ) {
    oki[x] = 1;
    
    for( int y : edg[x] ) {
        if( oki[y] == 0 )
            dfs( y );
    }
    
    return;
}

int main( void ) {
    
    int n, m;
    cin >> n >> m;
    
    for( int i = 1; i <= n; i ++ ) {
        int s;
        cin >> s;
        
        for( int j = 1; j <= s; j ++ ) {
            int x;
            cin >> x;
            
            edg[i].push_back( x + n );
            edg[x + n].push_back( i );
        }
    }
    
    dfs( 1 );
    if( accumulate( oki + 1, oki + n + 1, 0 ) == n )
        cout << "YES\n";
    else
        cout << "NO\n";
    
    return 0;
}

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

const int MAXN = 2e5 + 5;
const int INF = 0x3f3f3f3f;

int H, W, N;
int mini[MAXN];

int main() {
	memset(mini, INF, sizeof mini);
	
	scanf("%d%d%d", &H, &W, &N);
	while (N--) {
		int x, y;
		scanf("%d%d", &x, &y);
		mini[x] = min(mini[x], y);
	}

	int curr = 1;	
	for (int i = 2; i <= H; i++) {
		if (mini[i] <= curr) {
			printf("%d\n", i - 1);
			return 0;
		}
		curr = min(curr + 1, mini[i] - 1);
	}
	
	printf("%d\n", H);
	
	return 0;
}

Measured memory_bytes: 1024
from decimal import Decimal

def solve():
	n = int(input())

	sum = Decimal("0")
	for i in range(n):
		amount, type = input().split()
		if type == "JPY":
			sum += Decimal(amount)
		else:
			sum += Decimal(amount)*Decimal("380000.0")
	return sum
	
	
print(solve())

Measured memory_bytes: 5332
n = int(input())
a_lst = list(map(int,input().split()))
b_lst = list(map(int,input().split()))
c_lst = list(map(int,input().split()))
good = 0

for i in range(n-1):
    a1 = a_lst[i]
    a2 = a_lst[i+1]
    b = b_lst[a1-1]
    good += b
    if a1+1==a2:
        c = c_lst[a1-1]
        good += c

a = a_lst[-1]
b = b_lst[a-1]
good += b
print(good)

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

using namespace std;

#define DUMP(x) std::cout << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++ i)
#define ALL(r) r.begin(), r.end()
#define DUP(x, y) (((x) + (y) - 1) / (y))
#define YES puts("YES")
#define NO puts("NO")
#define Yes puts("Yes")
#define No puts("No")
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end())

using ll = std::int64_t;
using vint = std::vector<int>;
using vll = std::vector<ll>;
using vstr = std::vector<std::string>;
using pint = std::pair<int, int>;

constexpr std::int32_t INF = 1001001001;

void Main() {
    string s;
    cin >> s;

    if (s == "Sunny")puts("Cloudy");
    else if (s == "Cloudy")puts("Rainy");
    else if (s == "Rainy")puts("Sunny");

}

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



Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
	string S,T;
  	cin >> S >> T;
  	bool ans = false;
  	for(int i = 0; i < S.size(); ++i){
    	if(S==T){
        	ans = true;
			break;          
        }
    	S = S.back() + S.substr(0, S.size()-1 );
    }

	if(ans){
    	cout << "Yes" << endl;
    }else{
    	cout << "No" << endl;
    }
	
	
	
}

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

int main(){
    int n,k,arr[100] = {0};
    int d,a;
    int res = 0;

    cin >> n >> k;

    for( int i = 1; i <= k; i++){
        cin >> d;
        for( int j = 0; j < d; j++ ){
            cin >> a;
            arr[a - 1] = 1;
        }
    }

    for( int i = 0; i < n; i++ ){
        if( arr[i] == 0 )res++;
    }

    cout << res << "\n";

}

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


using namespace std;
typedef struct 
{
    int finish;
    int must;
}work;
work A[300000];
bool paixu(const work& a, const work& b)
{
    if(a.must != b.must)
        return a.must < b.must;
    return a.finish < b.finish;
};
int main()
{
    int n;
    cin>>n;

    for(int i=0;i<n;i++)
    {
        cin>>A[i].finish>>A[i].must;
    }
    sort(A,A+n,paixu);
    int last;
    last = A[n-1].must - A[n-1].finish;
    for(int i=n-2;i>=0;i--)
    {
        if(last < A[i].must)
            A[i].must = last;
        else
            last = A[i].must;
        last = last - A[i].finish;
    }
    if(last >= 0)
        cout<<"Yes";
    else
    {
            cout<<"No";
    }
    
    return 0;
}

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

int main() {
  string s;
  cin >> s;
  int n=s.size();
  bool good=true;
  rep(i,n){
    if(i%2 == 0){
      if(s[i] == 'L'){
        good = false;
      }
    }else{
      if(s[i] == 'R'){
        good = false;
      }
    }
  }

  if(good){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  
  return(0);
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	int a,b,ans = 0;
	string s;
	cin >> a >> b;
	for (int i = a ;i<=b;i++){
		int flag = 1;
		s = to_string(i);
		if (s.size() % 2 == 0){
			for(int j = 0;j < s.size()/2;j++){
				if (s[j] == s[s.size() - 1 - j]){
					continue;
				}
				else{
					flag = 0;
					break;
				}
			}
		}
		else{
			for(int j = 0;j <= s.size()/2 - 1;j++){
				if (s[j] == s[s.size() - 1 - j]){
					continue;
				}
				else{
					flag = 0;
					break;
				}
			}

		}
		ans+=flag;
	}
	cout << ans <<endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath> // 変数名にy1が使えなくなるかも…。
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <limits>
#include <functional>
#include <string>

typedef __int128_t int128_t;
std::istream &operator>>(std::istream& input, int128_t& value) { // int128_tの入力。入力が64bitに収まる前提。
    long long tmp; input >> tmp; value = tmp;
    return input;
}
std::ostream &operator<<(std::ostream& output, const int128_t value) { // int128_tの出力。出力が64bitに収まる前提。
    output << (long long)value;
    return output;
}

#define rep(i, begin, end) for(int64_t i = (begin); i <= (end); i++)
#define rev(i, begin, end) for(int64_t i = (begin); (end) <= i; i--)

void printvec(const std::vector<int>& vec) {
    for (int i = 0; i < vec.size(); i++) { std::cout << vec[i] << " "; } std::cout << std::endl;
}

const int MAX_N = 1e5 + 10;
int N;
int A[MAX_N];
std::unordered_map<int, int> mp;

int main(int argc, char **argv) {
    std::cin >> N;

    rep (i, 1, N) {
        std::cin >> A[i];
        mp[A[i]]++;
    }

    int od = 0;
    int ev = 0;
    for (auto p : mp) {
        if (p.second % 2 == 0) {
            ev++;
        } else {
            od++;
        }
    }

    if (ev % 2 == 0) {
        std::cout << ev + od << std::endl;
    } else {
        std::cout << ev + od - 1 << std::endl;
    }
    
    return 0;
}

Measured memory_bytes: 4772
#include<bits/stdc++.h>
/******* MY EVERY AC WILL BE A TRIBUTE TO SSR ********/
#define vi vector
#define lli long long int
#define vli vi<lli>
#define pb push_back
#define pll pair<lli,lli>
#define mp make_pair
#define ff first
#define ss second
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).begin(),(x).end(),greater<lli>()
#define clear(x) x.clear()
#define rep(i,n) for(lli i=0;i<(lli)n;i++)
#define rep1(i,n) for(lli i=1;i<=(lli)n;i++)
#define rep2(i,n) for(lli i=1;i<(lli)n;i++)
#define refor(i,n) for(lli i=(lli)n;i>=0;i--)
#define range(i,l,r) for(lli i=(lli)l;i<=(lli)r;i++)
#define big(x,y) (x>y)?x:y
#define small(x,y) (x<y)?x:y
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define mod 1000000007
using namespace std;
lli gcd(lli a,lli b) {return b==0?a:gcd(b,a%b);}
lli lcm(lli a,lli b) {return (a*b)/gcd(a,b);}
bool isprime(lli x) {for(lli i=2;i<=sqrt(x);i++) { if(x%i == 0) return false;} return true;}
lli modpow(lli x,lli y) {x%=mod;lli res=1;while(y>0){if(y&1) res*=x%mod; y=y>>1; x=x*x%mod;} return res%mod;}
lli ncr(lli n,lli k) {lli res=1; if(k>n-k) k=n-k; rep(i,k){res*=(n-i);res/=(i + 1);} return res;}
lli bintodec(lli n) {lli decimal=0,i=0,rem;while (n!=0){rem = n%10;n/=10;decimal += rem*pow(2,i);++i;}return decimal;}

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

    char f; 
    cin>>f; 
    if(isupper(f))  
        cout<<"A"<<'\n';
    else 
        cout <<"a"<<'\n';
    return 0;
}











Measured memory_bytes: 3636
#include <cstdio>
#include <cstring>

using namespace std;

char s[200001];
int dp[200001][3][2][4];

int main() {
    int n, m = 998244353, c = 0, ans = 0, i, j, k, l, r;
    
    scanf("%s", s);
    
    n = strlen(s);
    
    for (i = 0; i < n - 1; i++) {
        if (s[i] != s[i + 1]) break;
    }
    
    if (i == n - 1) {
        ans = 1;
    } else if (n == 3) {
        if (s[0] != s[1] && s[1] != s[2] && s[2] != s[0]) {
            ans = 3;
        } else if (s[0] == s[1] || s[1] == s[2]) {
            ans = 6;
        } else {
            ans = 7;
        }
    } else {
        dp[0][0][0][3] = 1;
        
        for (i = 0; i < n; i++) {
            for (j = 0; j < 3; j++) {
                for (k = 0; k < 2; k++) {
                    for (l = 0; l < 4; l++) {
                        if (dp[i][j][k][l] == 0) continue;
                        
                        for (r = 0; r < 3; r++) {
                            int nj = (j + r) % 3, nk = k, nl = r;
                            if (l == r) nk = 1;
                            
                            dp[i + 1][nj][nk][nl] += dp[i][j][k][l];
                            if (dp[i + 1][nj][nk][nl] >= m) dp[i + 1][nj][nk][nl] -= m;
                        }
                    }
                }
            }
        }
        
        for (i = 0; i < n - 1; i++) {
            if (s[i] == s[i + 1]) break;
        }
        
        if (i == n - 1) ans++;
        
        for (i = 0; i < n; i++) c += (s[i] - 'a');
        c %= 3;
        
        for (i = 0; i < 3; i++) {
            ans += dp[n][c][1][i];
            if (ans >= m) ans -= m;
        }
    }
    
    printf("%d\n", ans);
    
    return 0;
}


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

int ctoi(char c){
  if(c>='0'&&c<='9'){
    return c-'0';
  }
  return 0;
}

int main(){
  string s;
  cin>>s;
  for(int i=1;i<s.size();i++){
    if(ctoi(s[i])!=9){
      goto skip;
    }
  }
  cout<<ctoi(s[0])+9*(s.size()-1)<<endl;
  return 0;
  skip:
  cout<<ctoi(s[0])+9*(s.size()-1)-1<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define PI 3.141592653589793238462
using namespace std;
typedef long long ll;
typedef long double db;
ll a[200005],b[200005];
int main(){
    ll n,ans=0;cin>>n;
    for(ll i=1;i<=n;i++){
        cin>>a[i]>>b[i];
    }
    for(ll j=0;j<=3;j++){
        ll mx=-2e18,mi=2e18;
        if(j==0){
            for(ll i=1;i<=n;i++){
                mx=max(a[i]+b[i],mx);
                mi=min(a[i]+b[i],mi);
            }
        }
        if(j==1){
            for(ll i=1;i<=n;i++){
                mx=max(a[i]-b[i],mx);
                mi=min(a[i]-b[i],mi);
            }
        }
        if(j==2){
            for(ll i=1;i<=n;i++){
                mx=max(-a[i]+b[i],mx);
                mi=min(-a[i]+b[i],mi);
            }
        }
        if(j==3){
            for(ll i=1;i<=n;i++){
                mx=max(-a[i]-b[i],mx);
                mi=min(-a[i]-b[i],mi);
            }
        }
        ans=max(mx-mi,ans);
    }
    cout<<ans<<endl;
} 

Measured memory_bytes: 6756
import sys
input = sys.stdin.readline

N=int(input())
A=list(map(int,input().split()))

ANS=0
B=[A[0],A[1]]
C=[]
D=A[-1]

for i in range(N-1):
    if A[i*3+2]==A[i*3+3]==A[i*3+4]:
        ANS+=1
    else:
        C.append((A[i*3+2],A[i*3+3],A[i*3+4]))

DP=[[-1]*(N+1) for i in range(N+1)]
MAXDP=[-1]*(N+1)
SCMAX=0

DP[B[0]][B[1]]=DP[B[1]][B[0]]=0
MAXDP[B[0]]=0
MAXDP[B[1]]=0

for x,y,z in C:
    #for d in DP:
    #    print(*d)
    #print()
    #print(x,y,z)
    #print()

    NLIST=[]
    SCMAX2=0

    NMAXDP=[i for i in MAXDP]

    xy=max(0,DP[x][y],DP[z][z]+1)
    yz=max(0,DP[y][z],DP[x][x]+1)
    zx=max(0,DP[z][x],DP[y][y]+1)
    
    if x==y:
        for i in range(N+1):
            if DP[i][x]!=-1:
                NLIST.append((i,z,max(DP[i][z],DP[i][x]+1)))
                #DP[i][z]=DP[z][i]=max(DP[i][z],DP[i][x]+1)
         
            NMAXDP[i]=max(NMAXDP[i],DP[i][z],DP[z][i])
            NMAXDP[z]=max(NMAXDP[z],DP[i][z],DP[z][i])

    if y==z:
        for i in range(N+1):
            if DP[i][y]!=-1:
                NLIST.append((i,x,max(DP[i][x],DP[i][y]+1)))
                #DP[i][x]=DP[x][i]=max(DP[i][x],DP[i][y]+1)
                
            NMAXDP[i]=max(NMAXDP[i],DP[i][x],DP[x][i])
            NMAXDP[x]=max(NMAXDP[x],DP[i][x],DP[x][i])

    if z==x:
        for i in range(N+1):
            if DP[i][x]!=-1:
                NLIST.append((i,y,max(DP[i][y],DP[i][x]+1)))
                #DP[i][y]=DP[y][i]=max(DP[i][y],DP[i][x]+1)
                
            NMAXDP[i]=max(NMAXDP[i],DP[i][y],DP[y][i])
            NMAXDP[y]=max(NMAXDP[y],DP[i][y],DP[y][i])

    for i,j,sc in NLIST:
        DP[i][j]=DP[j][i]=max(DP[i][j],sc)
        SCMAX2=max(SCMAX,DP[i][j])

    #for d in DP:
    #    print(*d)
    #print()

    for i in range(N+1):
        DP[i][x]=DP[x][i]=max(DP[i][x],MAXDP[i])
        DP[i][y]=DP[y][i]=max(DP[i][y],MAXDP[i])
        DP[i][z]=DP[z][i]=max(DP[i][z],MAXDP[i])
        SCMAX2=max(SCMAX2,DP[i][x],DP[i][y],DP[i][z])
                   
        NMAXDP[i]=max(NMAXDP[i],DP[i][x],DP[i][y],DP[i][z])
        NMAXDP[x]=max(NMAXDP[x],DP[i][x])
        NMAXDP[y]=max(NMAXDP[y],DP[i][y])
        NMAXDP[z]=max(NMAXDP[z],DP[i][z])

    DP[x][y]=DP[y][x]=max(SCMAX,xy)
    DP[y][z]=DP[z][y]=max(SCMAX,yz)
    DP[z][x]=DP[x][z]=max(SCMAX,zx)
    SCMAX2=max(SCMAX2,DP[x][y],DP[y][z],DP[z][x])

    MAXDP=NMAXDP
    MAXDP[x]=max(MAXDP[x],DP[x][y],DP[y][x],DP[z][x],DP[x][z])
    MAXDP[y]=max(MAXDP[y],DP[x][y],DP[y][x],DP[z][y],DP[y][z])
    MAXDP[z]=max(MAXDP[z],DP[x][z],DP[z][x],DP[z][y],DP[y][z])
    SCMAX=SCMAX2

#for d in DP:
#    print(*d)

DP[D][D]+=1

DPANS=0
for d in DP:
    DPANS=max(max(d),DPANS)

print(ANS+DPANS)

Measured memory_bytes: 115804
#include<stdio.h>

/*
次の方法で左から見ていけばよさそう：
まず、「すべてのスポーツを実施する」という前提のもと、
最も多くの人が参加しているスポーツの参加人数をチェック。
次に、その人数参加しているスポーツをすべて実施しないことにしたときに、
最も多くの人が参加しているスポーツの参加人数をチェック。
以下、これを繰り返す。
*/


int main(void){
	int N,M,A[300][300];
	int i,j;

	int held[300], num[300], rem, ans,max;

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

	for(i=0;i<M;i++){
		held[i] = 1;
	}
	
	rem = M;
	ans = N;

	while(rem>0){
		/*各スポーツの参加人数をチェック*/
		for(i=0;i<M;i++){
			num[i] = 0;
		}

		for(i=0;i<N;i++){
			for(j=0;j<M;j++){
				if(held[A[i][j]-1] == 1){
					num[A[i][j]-1]++;
					break;
				}
			}
		}

		/*参加人数の最大値をチェック*/
		max = 0;
		for(i=0; i<M; i++){
			if(max<num[i]){max = num[i];}
		}
		if(max<ans){ans = max;}

		/*参加人数が最大の競技を外す*/
		for(i=0;i<M;i++){
			if(max == num[i]){
				held[i] = 0; rem--;
			}
		}
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void _main()
{
    int x;
    cin >> x;
    cout << (x < 1200 ? "ABC" : "ARC") << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

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

  if(scanf("%d %d %d", &a, &b, &c) == 1);

  for(int i = 0; i < b; i++) {
    if((i * a) % b == c) {
      ans = 1;
      break;
    }
  }

  if(ans) {
    printf("YES");
  } else {
    printf("NO");
  }

  return 0;
}

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

int main(){
    ll n, size;
    string s;
        cin >> n >> size >> s;
    vector<int> v(n);
    int a, b;
    for(int i=0; i<s.size()-1; i++){
        v.at(i+1) = v.at(i);
        if(s.substr(i, 2)=="AC") v.at(i+1)+=1; 
    }
        
    for(int i=0; i<size; i++){
        cin >> a >> b;
        a--; b--;
        cout << v.at(b)-v.at(a) << endl;  
    }
}

Measured memory_bytes: 1408
"use strict";

function Main(input) {
    // 1行目がinput[0], 2行目がinput[1], …に入る
    input = input.split("\n");
    let alpha = input[0];

    //出力
    if (isUpperCase(alpha)) {
        console.log('A');
    } else {
        console.log('a');
    }
}

const isUpperCase = c => {
    return /^[A-Z]+$/g.test(c)
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

int main(){
    int n;
    cin >> n;
    int a[n],b[n],c[n];
    rep(i,n)cin >> a[i] >> b[i] >> c[i];
    
    int dp[n][3];
    for(int i = 0;i < n;i++){
        dp[i][0] = dp[i][1] = dp[i][2] = 0;
    }
    
    dp[0][0] = a[0];
    dp[0][1] = b[0];
    dp[0][2] = c[0];
    
    for(int i = 1;i < n;i++){
        dp[i][0] = max(dp[i-1][1],dp[i-1][2]) + a[i];
        dp[i][1] = max(dp[i-1][0],dp[i-1][2]) + b[i];
        dp[i][2] = max(dp[i-1][0],dp[i-1][1]) + c[i];
    }
    
    int alina = 0;
    rep(i,3){
        alina = max(alina,dp[n-1][i]);
    }
    cout << alina << endl;
}

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

int main() {
  int a;
  set<int> s;
  for (int i=0; i<3; i++) {
    cin >> a;
    s.insert(a);
  }
  cout << s.size() << endl;
  return 0;
}

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

signed main() {
    int X, N;
    cin >> X >> N;
    int p[110];
    rep (i, N) cin >> p[i];

    if (N == 0) {
        cout << X <<  endl;
        return 0;
    }

    R.assign(110, false);
    rep (i, N) {
        R[p[i]] = true;
    }

    int min = 111;
    int ans = 111;
    rep (i, 102) {
        if (R[i] == false) {
            int t = X - (i);
            if (t < 0) t*= -1;
            if (min > t) {
                min = t;
                ans = i;
            }
        }
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define boost_io ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define num(a) a-'0'
#define maxs(a,b) if(b>a)a=b
#define mins(a,b) if(b<a)a=b;
#define debug(x) cout<<#x<<":"<<x<<" "
#define all(a) (a).begin(), (a).end()
#define vi vector<int>
#define vl vector<long long int>
#define v vector
#define p pair
#define pb push_back
#define mk make_pair
#define f first
#define s second
#define ln "\n"	
typedef long long int ll;
typedef long double ld;
typedef double d;
using namespace std;
ll modF=1e9+7;
ll INF=1e18;

void solve(){
	ll a,b,c,x,y;
	scanf("%lld%lld%lld%lld%lld",&a,&b,&c,&x,&y);
	if(a + b > 2 * c){
		ll ans = min(x,y) * 2 * c;
		if(x > y){
			if(2 * c < a)
				ans += (x - y) * 2 * c;
			else
				ans += (x - y) * a;
		}
		else{
			if(2 * c < b)
				ans += (y - x) * 2 * c;
			else
				ans += (y - x) * b;
		}
		printf("%lld",ans);
	}
	else{
		ll ans = a * x + b * y;
		printf("%lld",ans);
	}
}

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

Measured memory_bytes: 3864
#include <iostream>
#include <map>
#include <vector>
using namespace std;
int main(void){
	int n;
	while(cin>>n,n){
		int name[1024],p[1024],q[1024],r[1024],c[1024];
		for(int i=0,it,pt,qt,rt;i<n;++i){
			cin>>it>>pt>>qt>>rt;
			name[i]=it;
			p[i]=pt;
			q[i]=qt;
			r[i]=rt;
			c[i]=pt*4+qt*9+rt*4;
		}
		int lp,lq,lr,lc;//limit
		cin>>lp>>lq>>lr>>lc;
		bool f=false;
		for(int i=0;i<n;++i){
			if(p[i]<=lp&&q[i]<=lq&&r[i]<=lr&&c[i]<=lc){
				f=true;
				cout<<name[i]<<endl;
			}
		}
		if(!f)cout<<"NA"<<endl;
	}
	return 0;
}

Measured memory_bytes: 1180
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;

int main() {
    string s;
    cin >> s;
    if (s.back() == 's') s += "es";
    else s += "s";

    cout << s << endl;
}

Measured memory_bytes: 3036
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		sc.close();
		
		if(a % 2 == 0 || b % 2 == 0) {
			System.out.println("Even");
		} else {
			System.out.println("Odd");
		}
	}

}


Measured memory_bytes: 21716
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define ll long long
#define imfor(i, n) for(int i = 0; i < n; i++)
using namespace std;
ll MOD = 1000000007;

int main() {
    int p, q, r;
    cin >> p >> q >> r;
    cout << min(p + r, min(p + q, q + r)); 
}

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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL << 30)
#define LLINF (1LL << 60)
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

int x[15], y[15];
signed main(void) {
  while (true) {
    int n, m;
    cin >> n;
    if (!n)
      break;
    VI ans;
    vector<PII> a, b, c, d;
    REP(i, n + 1) {
      int sz;
      b.clear();
      d.clear();
      cin >> m;
      REP(j, m) cin >> x[j] >> y[j];
      if (i == 0) {
        sz = m;
        a.PB({0, 0});
        FOR(j, 1, m) a.PB({x[j] - x[0], y[j] - y[0]});
        c.PB({0, 0});
        for(int j=m-2; j>=0; --j) c.PB({x[j] - x[m-1], y[j] - y[m-1]});
        /*for(PII j: a) cout << "(" << j.first << ", " << j.second << ") ";
        cout << endl;
        for(PII j: c) cout << "(" << j.first << ", " << j.second << ") ";
        cout << endl;*/
      } else {
        //cout << "c " << m << " " << sz << endl;
        if (m != sz) continue;
        //cout << "b" << endl;
        b.PB({0, 0});
        FOR(j, 1, m) b.PB({x[j] - x[0], y[j] - y[0]});
        d.PB({0, 0});
        for(int j=m-2; j>=0; --j) d.PB({x[j] - x[m-1], y[j] - y[m-1]});
        bool flag = false;
        // a??¨b????????´?????????????????????
        REP(j, 4) {
          if(j != 0) {
            //?????¢
            REP(k, m) {
              int tmp = b[k].first;
              b[k].first = -b[k].second;
              b[k].second = tmp;
            }
            REP(k, m) {
              int tmp = d[k].first;
              d[k].first = -d[k].second;
              d[k].second = tmp;
            }
          }
          /*cout << "i:" << i << endl;
          for(PII j: b) cout << "(" << j.first << ", " << j.second << ") ";
          cout << endl;
          for(PII j: d) cout << "(" << j.first << ", " << j.second << ") ";
          cout << endl;*/
          //?????´???????????????
          bool g = true;
          REP(k, m) {
            if(a[k].first != b[k].first || a[k].second != b[k].second) {
              g = false;
            }
          }
          bool h = true;
          REP(k, m) {
            if(c[k].first != d[k].first || c[k].second != d[k].second) {
              h = false;
            }
          }
          bool g1 = true;
          REP(k, m) {
            if(a[k].first != d[k].first || a[k].second != d[k].second) {
              g1 = false;
            }
          }
          bool h1 = true;
          REP(k, m) {
            if(c[k].first != b[k].first || c[k].second != b[k].second) {
              h1 = false;
            }
          }
          if(g || h || g1 || h1) flag = true;
        }
        if (flag)
          ans.PB(i);
      }
    }
    for (int i : ans) {
      cout << i << endl;
    }
    cout << "+++++" << endl;
  }

  return 0;
}

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


#define ll long long
#define pb push_back
#define mp make_pair
#define loop(i, a, b) for(int i = (a); i < (b); i++)
#define loopb(i, a, b) for(int i = (a); i > (b); --i)

typedef pair <int,int> ii;
typedef vector <int> vi;
typedef vector <ii> vii;
typedef vector <ll> vl;

const int mod = 1e9+7;
const int inf = 2e18+5;


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

  ll n,m;
  cin>>n>>m;
  ll dp[n][m+1];
  vi w(n),v(n);
  loop(i,0,n)
    {
      cin>>w[i]>>v[i];
    }

  loop(i,0,n){
    loop(j,0,m+1){
      if(i==0){

            if(j-w[i]>=0)
                dp[i][j] = v[i];
            else
                dp[i][j]=0;
      }
      else {
           	  if(j-w[i]>=0)
                  dp[i][j] = max(dp[i-1][j] , dp[i-1][j-w[i]] + v[i]);
      		    else
                  dp[i][j]=dp[i-1][j];
      }
    }
  }
  cout<<dp[n-1][m];
  return 0;
}


Measured memory_bytes: 78336
#include <cmath>
#include <iomanip>
#include <iostream>
 
using namespace std;
 
int main()
{
    double x1, y1, x2, y2, d;
 
    cin >> x1 >> y1 >> x2 >> y2;
 
    d = sqrt(pow(x2 - x1, 2) + pow(y2 - y1, 2));
 
    cout << fixed << setprecision(15) << d << endl;
 
    return 0;
}


Measured memory_bytes: 3268
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<long long>;
using pll = pair<long long, long long>;
using qll = queue<ll>;
using vb = vector<bool>;
using sll = stack<ll>;
#define rep(i,n) for(long long i(0);(i)<(n);(i)++)
#define REP(i,n) for(long long i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
#define elnd endl //* missspell check
ll INF = 1LL << 60;

int main(){
    ll N, M;
    cin >> N >> M;
    vll a(M), s(M);
    REP(i, M){
        scanf("%lld", &a[i]);
        ll len; cin >> len; ll c;
        REP(j, len){
            cin >> c;
            s[i] = s[i]|(1LL<<(c-1));
        }
    }

    vector<vll> dp(M+1, vll(1LL<<N, INF));
    REP(i, M+1)
        dp[i][0]=0;

    REP(i, M){
        for(ll S=1; S< (1LL<<N); S++){
            dp[i+1][S] = min(dp[i][S], dp[i][S & ~(s[i])]+a[i]);
        }
    }
    cout << (dp[M][(1LL<<N) -1] < INF? dp[M][(1LL<<N) -1]: -1) << endl;
    return 0;
}


Measured memory_bytes: 32384
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

X=gets.to_i
root5=(X**(1.0/5.0)).to_i**2
table=array(root5+1,0)
1.upto(root5) do|i|
    table[i]=i**5
end
ans=nil
0.upto(root5) do|x|
  0.upto(root5) do|y|
    if table[x]-table[y]==X
        ans=[x,y]
    elsif table[x]+table[y]==X
        ans=[x,-y]
    end
  end
end
puts ans.join(" ")

Measured memory_bytes: 14716
#include<bits/stdc++.h>
using namespace std;
const int maxn=2e3+10;
struct node{
    int root,l,r;
    int s,lz;
}tree[maxn<<2];
int a[maxn];
void bud(int root,int l,int r){
    tree[root].l=l;
    tree[root].r=r;
    tree[root].s=tree[root].lz=0;
    if(tree[root].l==tree[root].r)return;
    int mid=(l+r)>>1;
    bud(root<<1,l,mid);
    bud(root<<1|1,mid+1,r);
}
void push_down(int root){
    tree[root<<1].lz+=tree[root].lz;
    tree[root<<1|1].lz+=tree[root].lz;
    tree[root<<1].s+=tree[root].lz;
    tree[root<<1|1].s+=tree[root].lz;
    tree[root].lz=0;
}
void upd(int root,int l,int r){
    if(tree[root].l==l&&tree[root].r==r){
        tree[root].lz++;
        tree[root].s++;
        return;
    }
    if(tree[root].lz)push_down(root);
    int mid=(tree[root].l+tree[root].r)>>1;
    if(r<=mid)upd(root<<1,l,r);
    else if(l>mid)upd(root<<1|1,l,r);
    else{
        upd(root<<1,l,mid);
        upd(root<<1|1,mid+1,r);
    }
    tree[root].s=tree[root<<1].s+tree[root<<1|1].s;
}
int que(int root,int l,int r){
    if(tree[root].l==tree[root].r){
        return tree[root].s;
    }
    if(tree[root].lz)push_down(root);
    int mid=(tree[root].l+tree[root].r)>>1;
    if(r<=mid)return que(root<<1,l,r);
    else if(l>mid)return que(root<<1|1,l,r);
    return que(root<<1,l,mid)+que(root<<1|1,mid+1,r);
}
int main(){
    int n;
    cin>>n;
    bud(1,1,maxn);
    int ans=0;
    for(int i=1;i<=n;++i){
        cin>>a[i];
        ans+=que(1,a[i],a[i]);
        for(int j=1;j<i;++j){
            upd(1,max(a[i],a[j])-min(a[i],a[j])+1,a[i]+a[j]-1);
        }
    }
    cout<<ans<<endl;
}


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

const ll mod = 1e9+7;
const ll INF = -1*((1LL<<63)+1);
const int inf = -1*((1<<31)+1);

using namespace std;

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	vector<pair<ll,ll>> p;
	vector<ll> A(N),B(N);
	rep(i,N){
		ll a,b,c;
		cin >> a >> b;
		A[i] = a;
		B[i] = b;
		c = a + b;
		p.emplace_back(-c,i);
	}
	ll ans = 0;
	sort(ALL(p));
	rep(i,N){
		if(i%2==0)ans += A[p[i].second];
		else ans -= B[p[i].second];
	}
	cout << ans << endl;
}

Measured memory_bytes: 3956
N, K = map(int,input().split())
R, S, P = map(int,input().split())
T = list(str(input()))

can_use = []
score = 0

def get_score(forwin):
    if forwin == "r":
        score = R
    elif forwin == "s":
        score = S
    elif forwin == "p":
        score = P
    return score

def can_use_hand(forwin):
    if forwin == "r":
        hands = ["s", "p"]
    elif forwin == "s":
        hands = ["r", "p"]
    elif forwin == "p":
        hands = ["r", "s"]
    return hands

for i in range(N):
    if T[i] == "r":
        forwin = "p"
    elif T[i] == "s":
        forwin = "r"
    elif T[i] == "p":
        forwin = "s"
    
    if len(can_use) < K:
        score += get_score(forwin)
        can_use.append(can_use_hand(forwin))
    else:
        can_use_hands = can_use[-K]
        if forwin in can_use_hands:
            score += get_score(forwin)
            can_use.append(can_use_hand(forwin))
        else:
            score += 0
            can_use.append(["r","s","p"])
print(score)




Measured memory_bytes: 14032
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<cassert>
#include<cassert>
#include<unordered_map>
#include<unordered_set>
#include<functional>
#include<queue>
#include<stack>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<sstream>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<numeric>
#include<random>
#include<chrono>
#include<bitset>
using namespace std;

#define all(x) (x).begin(), (x).end()
#define pb push_back
#define xx first
#define yy second
#define sz(x) (int)(x).size()
#define gc getchar
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define mp make_pair

#ifndef ONLINE_JUDGE
#  define LOG(x) (cerr << #x << " = " << (x) << endl)
#else
#  define LOG(x) ((void)0)
#endif

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

const double PI=3.1415926535897932384626433832795;
const ll INF = 1LL<<62;
const ll MINF = -1LL<<62;

template<typename T> T getint() {
	T val=0;
	char c;
	
	bool neg=false;
	while((c=gc()) && !(c>='0' && c<='9')) {
		neg|=c=='-';
	}

	do {
		val=(val*10)+c-'0';
	} while((c=gc()) && (c>='0' && c<='9'));

	return val*(neg?-1:1);
}

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); uniform_int_distribution<int>(0, n-1)(rng)


int main() {
	IO;
	string t;
	cin>>t;
	cout<<(find(all(t),'7')==t.end()?"No":"Yes")<<"\n";
	return 0;
}


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

#define ll long long
#define pi (acos(-1))
#define rep(i, n) for (unsigned long long i = 0; i < (unsigned long long)(n); ++i)
using namespace std;
std::vector<unsigned ll> genprimevec(const unsigned ll N);

int main()
{
    int n;
    cin >> n;
    vector<pair<int, int>> vec;
    int a;
    rep(i, n)
    {
        cin >> a;
        vec.push_back(pair<int, int>(i+1, a));
    }

    sort(vec.begin(), vec.end(), [](pair<int, int> l, pair<int, int> r) { return (l.second < r.second); });
    for(auto i:vec){
	    cout<<i.first<<' ';
    }
cout<<endl;

    return 0;
}

/*author  https://qiita.com/drken/items/0c88a37eec520f82b788*/
ll extgcd(ll a, ll b, ll &x, ll &y)
{
    if (b == 0)
    {
        x = 1, y = 0;
        return a;
    }
    ll d = extgcd(b, a % b, y, x);
    y -= a / b * x;
    return d;
}


std::vector<unsigned ll> genprimevec(const unsigned ll N)
{
    std::vector<bool> is_prime(N + 1);
    for (unsigned ll i = 0; i <= N; i++) { is_prime[i] = true; }
    std::vector<unsigned ll> P;
    for (unsigned ll i = 2; i <= N; i++)
    {
        if (is_prime[i])
        {
            for (unsigned ll j = 2 * i; j <= N; j += i) { is_prime[j] = false; }
            P.emplace_back(i);
        }
    }
    return P;
}


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

int main(){
    int n;
    cin >> n;
    int p[n];
    int w = n + 1,q = 0;
    rep(i,n){
        cin >> p[i];
        if(p[i] < w){
            w = p[i];
            q++;
        }
    }
    cout << q << endl;
}

Measured memory_bytes: 1024
import java.io.*;
import java.util.*;
public class Main{
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int[] yama = new int[10];
		for(int i = 0;i <= 9;i++){
			yama[i] = Integer.parseInt(br.readLine());
		}
		int dami = 0;
		for(int i = 0;i <= 8; i++){
			int x = i;
			for(int j = i + 1;j <= 9;j++){
				if(yama[x] < yama[j]){
					x = j;
				}
			}
			if(x != i){
				dami = yama[x];
				yama[x] = yama[i];
				yama[i] = dami;
			}
		}
		for(int i = 0;i <= 2;i++){
			System.out.println(yama[i]);
		}
	}
}

Measured memory_bytes: 24352
// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")
// #pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
using namespace std;

/********************************************************************/
#define M1 1000000007
#define M3 1000000009
#define M2 998244353
#define ll long long
#define ld long double
#define pll pair<ll,ll>
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,a,b) for(ll i=b-1;i>=a;i--)
#define forr(i,n) for(ll i=0;i<n;i++)
#define F first
#define S second
#define pb push_back
#define DB pop_back
#define mp make_pair
#define MT make_tuple
#define V(a) vector<a>
#define vi vector<ll>
#define endl '\n'
#define ce(ele) cout<<ele<<' '
#define cs(ele) cout<<ele<<'\n'
#define yep cout<<"YES"<<'\n'
#define nope cout<<"NO"<<'\n'
#define CASE(te) ll te; cin>>te; while(te--)
#define sor(v) sort(v.begin(),v.end())
#define rev(v) reverse(v.begin(),v.end())

/********************************************************************/
const double pi = 3.1415926535;
//const int mx = 69;
//char grid[mx][mx];
// ll blocked[mx][mx];
// ll vis[mx][mx];
/********************************************************************/
//FAST IO//
void FAST() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}

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

ll power(ll x,ll y,ll p) 
{ 
    ll res = 1; 
    x = x % p; 
    while (y > 0) 
    {  
        if (y & 1) 
         res = (res * x) % p; 
        y = y >> 1; 
        x = (x * x) % p; 
    } 
    return res; 
} 

bool isprime(ll n) 
{ 
    if (n <= 1) 
        return false; 
    if (n <= 3) 
        return true; 
    if (n % 2 == 0 || n % 3 == 0) 
        return false; 
    for (ll i = 5; i * i <= n; i = i + 6) 
        if (n % i == 0 || n % (i + 2) == 0) 
            return false; 
    return true; 
} 
  

vector<ll> digit(ll n)
{
    ll arr[10000];
    ll i=0;
    ll j,r;
    vi v;
    while(n!=0)
    {
        r = n % 10;
        arr[i] = r;
        i++;
        n = n / 10;
    }
    for(j=i-1;j>-1;j--)
    {
        v.pb(arr[j]);
    }
    return v;
}

ll sum(ll x) {
	ll ans = 0;
	while (x > 0) {
		ans += (x % 10);
		x /= 10;
	}
	return ans;
}

bool opp(int x, int y)
{
    return ((x ^ y) < 0);
}

bool bysec(const pair<int,int> &a, const pair<int,int> &b) 
{ 
    return (a.second < b.second); 
}

int main()
{
  FAST();
  ll n;
  cin>>n;
  if(n)
  cs(0);
  else
  {
      cs(1);
  }
  
}


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

int gcd(int a, int b){

int p,q,r;

if(a<b){p=b;b=a;a=p;

}

while((r=b%a)!=0){
   q=b/a;
   b=a;
   a=r;
}
   
   return a;
}

int main(void)
{    int a, b;
    while(cin >> a >> b) {
      int lcm = a/gcd(a,b)*b;
      cout << gcd(a,b) << " " << lcm << endl;
    }
    return 0;
}



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

#define fi first
#define se second
#define be begin
#define en end
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ALL(a) (a).be() , (a).en()
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)        //repeat n times
#define REP2(i,s,n) for(int (i)=(s);(i)<(n);(i)++)   //repeat from s to n 
#define REPD(i,n) for(int (i)=(n);(i)>=0;(i)--)      //repeat from n to 0
#define REPD2(i,s,e) for(int (i)=(s);(i)>=(e);(i)--) //repeat from s to e
#define RANGE(i,v) for(auto &(i):v)                  //repeat range
#define ASIZE(a) (sizeof(a) / sizeof(a[0]))          //array size

using LL = long long;


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

    REP(i,n.size()) cout<<((n[i]=='9')?'1':'9');
    cout<<endl;

    return 0;
}

Measured memory_bytes: 256
N = int(input())
count = 0
ans = list()
r = 0
alp = ['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']
d = -1


while N > 26**count + d:
    count+=1
    d = 26**(count-1) + d

#print(count)
count = count - 1
count2 = count

while count > 0:
    #print(N)
    N = N - 26**count
    #print(N)
    count = count - 1

#print(N)
#print(N)
N = N - 1
#print(N)
A = 1
while N > 0:
    A = N // 26
    B = N % 26
    #print(ans)
    ans.append(B)
    #print(ans)
    N = A

#print(ans)
#print(len(ans))
#print(count2+1)

while len(ans) < count2 + 1:
    ans.append(0)
    #print(len(ans))

#print(N)
#print(len(ans))
#print(ans)
ans.reverse()
#print(ans)

for i in range(0, len(ans)):
    ans[i] = alp[ans[i]]

#print(ans)

print(''.join(ans))

Measured memory_bytes: 9252
a,b,c = map(int,input().split())

k = int(input())

a_new = 0
b_new = 0
c_new = 0

flag = 0
#print(k)
def solve():
    flag = 0
    for i in range(k+1):
        for j in range(k-i+1):
            #print(i,k,j)
            l = k - i - j
            a_new = a*2**i
            b_new = b*2**j
            c_new = c*2**l
            #print(a_new,b_new,c_new)
            if(c_new > b_new and b_new > a_new):
                flag = 1
                #print("hi")
                return flag
                
    
            
    return flag

flag = solve()

if(flag == 1):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9204
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define int long long
#define inf 1000000007
#define LINF 100000000000000007LL
#define ll long long
using namespace std;
signed main(){
	int n,m;
	cin>>n>>m;
	vector<int> divs;
	for(int i=1;i*i<=m;i++){
		if( m % i == 0 ){
			divs.pb(i);
			if( i*i != m ) divs.pb( m/i );
		}
	}
	sort( divs.begin(), divs.end() );
	int ans = 1;
	for(int i=0;i<divs.size();i++){
		int sho = m/divs[i];
		if( sho >= n && divs[i] > ans ) ans = divs[i];
	}
	cout<<ans<<endl;
	return 0;
}

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

int main()
{
    vector<int> v1, v2, v3;
    int n;
    cin >> n;
    while (n--)
    {
        int x;
        cin >> x;
        v1.push_back(x);
    }
    int m;
    cin >> m;
    while (m--)
    {
        int x;
        cin >> x;
        v2.push_back(x);
    }
    set_intersection(v1.begin(), v1.end(), v2.begin(), v2.end(), back_inserter(v3));
    int i;
    for (i = 0; i < v3.size(); i++)
    {
        cout << v3[i] << endl;
    }
    return 0;
}


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

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

ll h, w;
ll sx, sy, gx, gy;
vector<string> maze;

int main() {
  cin >> h >> w >> sy >> sx >> gy >> gx;
  --sx, --sy, --gx, --gy;
  maze.resize(h);
  rep(i, h) cin >> maze[i];

  deque<pair<ll, ll>> q;
  q.push_back({sy, sx});
  vector<ll> d(h * w, -1);
  d[sy * w + sx] = 0;

  while (q.size()) {
    ll y = q.front().first;
    ll x = q.front().second;
    q.pop_front();

    rep(i, 4) {
      ll ny = y + dy[i], nx = x + dx[i];
      if (ny >= 0 && ny < h && nx >= 0 && nx < w && maze[ny][nx] == '.')
        if (d[ny * w + nx] == -1 || d[ny * w + nx] > d[y * w + x])
          d[ny * w + nx] = d[y * w + x], q.push_front({ny, nx});
    }

    for (ll i = y - 2; i <= y + 2; ++i)
      for (ll j = x - 2; j <= x + 2; ++j)
        if (i >= 0 && i < h && j >= 0 && j < w && maze[i][j] == '.')
          if (d[i * w + j] == -1 || d[i * w + j] > d[y * w + x] + 1)
            d[i * w + j] = d[y * w + x] + 1, q.push_back({i, j});
  }

  cout << d[gy * w + gx] << endl;
  return 0;
}

Measured memory_bytes: 13168
main = putStrLn =<< solve <$> parse

parse :: IO [Int]
parse = getLine >> map read . words <$> getLine

solve :: [Int] -> String
solve = show . solve'

solve' :: [Int] -> Int
solve' xs = minimum $ map (rewrite xs) [minX..maxX] where
    minX = minimum xs
    maxX = maximum xs

rewrite :: [Int] -> Int -> Int
rewrite xs y = sum $ map (rewrite' y) xs

rewrite' :: Int -> Int -> Int
rewrite' x y = (x - y) * (x - y)


Measured memory_bytes: 1020
while True:
    n=int(input())
    if n==0:break
    s,vmax,vmin = 0,-1,1001
    for i in range(n):
        a = int(input())
        vmax=max(vmax,a)
        vmin=min(vmin,a)
        s+=a
    print((s-vmax-vmin)//(n-2))


Measured memory_bytes: 5596
#include <iostream>
#include <algorithm>
#include <queue>

using namespace std;

typedef long long LL;

const int N = 200010;

int n;
int a[N];

int cmp(const int &a, const int &b) {
    return a > b;
}

int main() {
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) scanf("%d", &a[i]);
    sort(a, a + n, cmp);
    priority_queue<int> pq;
    LL ans = 0;
    pq.push(a[0]);
    for (int i = 1; i < n; ++i) {
        ans += pq.top(), pq.pop();
        pq.push(a[i]);
        pq.push(a[i]);
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 4664
# 人数分布は一意
import numpy as np

N = int(input())
A = np.array([int(x) for x in input().split()])
MOD = 10 ** 9 + 7

left = np.arange(N)
right = N-1-left
cnt_1 = np.bincount(np.abs(left-right))
cnt_2 = np.bincount(A)
#print(cnt_1)
if cnt_1.shape != cnt_2.shape or (cnt_1 != cnt_2).any():
    answer = 0
else:
    answer = pow(2, N//2, MOD)
print(answer)

Measured memory_bytes: 23392
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i, n); for(ll i = 0; i < (ll)n; i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main() {
  ll n,y;
  cin >> n >> y;
  
  rep(i, n+1){
    rep(j, n-i+1){
      if(10000*i + 5000*j + 1000*(n-i-j) == y){
        cout << i << " " << j << " " << n-i-j << endl;
        return 0;
      }
    }
  }
  cout << -1 << " " << -1 << " " << -1 << endl;
}


Measured memory_bytes: 3616
#include<iostream>

using namespace std;

int main()
{
    int a,b;
    cin>>a>>b;
    if(a>b)
       cout<<"a > b"<<endl;
    else if(a<b)
       cout<<"a < b"<<endl;
    else
       cout<<"a == b"<<endl;
    return 0;
}

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

int main(){
    long long n;
    cin >> n;
    long long ans = 0;
    long long m = n;
    for(long long i = 2; i*i <= m; i++){
        if(n%i == 0){
            int cnt = 0;
            while(n%i==0){
                cnt++;
                n /= i;
            }
            for(int j=1; j<=cnt; j++){
                cnt -= j;
                if(cnt >= 0) ans++;
                else break;
            }
        }
    }
    if(n != 1) ans++;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3636
import java.io.BufferedReader;
import java.io.InputStreamReader;

/**
 * AOJ0075 BMI
 */
public class Main {
    public static void main(String... args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line = null;
        while ((line = br.readLine()) != null) {
            String[] in = line.split(",");
            int id = Integer.parseInt(in[0]);
            double w = Double.parseDouble(in[1]);
            double h = Double.parseDouble(in[2]);
            double bmi = w / (h * h);
            if (bmi >= 25.0) {
                System.out.println(id);
            }
        }
    }
}

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

using namespace std;

int main()
{
    int n, k, s;
    cin>>n>>k>>s;
    int mx = max(n, k);
    int Ans = (s/mx) + ((s%mx) ? 1 : 0);
    cout<<Ans<<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    if((100*a + 10*b + c)%4 == 0){
        printf("YES");
    }
    else{
        printf("NO");
    }
    return 0;
}

Measured memory_bytes: 128