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

#define ll long long
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define ld long double
#define forn(low,high,i) for(i = low; i < high; i++)
#define forrev(high,low,i) for(i = high; i >= low; i--)
#define all(v) v.begin(),v.end()
#define decimal_digits cout << fixed << setprecision(15);

string to_string(string s) { return '"' + s + '"';}
string to_string(char s) { return string(1, s);}
string to_string(const char* s) { return to_string((string) s);}
string to_string(bool b) { return (b ? "true" : "false");}
template <typename A> string to_string(A);
template <typename A, typename B>string to_string(pair<A, B> p) {return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}
template <typename A> string to_string(A v) {bool f = 1; string r = "{"; for (const auto &x : v) {if (!f)r += ", "; f = 0; r += to_string(x);} return r + "}";}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {cerr << " " << to_string(H); debug_out(T...);}
#define pr(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

const int inf = 1e9;
const long long INF = 1e18;
const int mod = 1e9 + 7;
const int bit32 = log2(inf) + 3;
const int bit64 = log2(INF) + 3;

inline int add(long long a, long long b){a += b; if(a >= mod) a -= mod; return a;}
inline int sub(long long a, long long b){a -= b; if(a < 0) a += mod; return a;}
inline int mul(long long a, long long b){a %= mod; b %= mod; return (int)((long long) a * b % mod);}
inline int modexpo(long long a, long long b){int res = 1; while(b > 0){ if(b & 1) res = mul(res, a); a = mul(a, a); b /= 2;} return res;}
inline int divide(long long a, long long b){return mul(a, modexpo(b, mod - 2));}
inline int inv(long long a){return modexpo(a, mod - 2);}

clock_t time_p = clock();

void ktj(){
  time_p = clock() - time_p;
  cerr << "Time elapsed : " << (float)(time_p)/CLOCKS_PER_SEC << "\n";
}

void pre(){ // Reset each global variable (esp. for graphs)
  
}

void solve(){
  string s, t;
  cin >> s >> t;
  int ans = 0;
  for(int i = 0; i < s.size(); i++){
    ans += (s[i] != t[i]);
  }
  cout << ans << '\n';
}


#define GOOGLE 0
#define MULTIPLE_TC 0

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

  pre();

  int t = 1, T;
  if(MULTIPLE_TC)
    cin >> t;

  for(T = 1; T <= t; T++){
    if(GOOGLE)
      cout << "Case #" << T << ": ";
    solve();
  }

  ktj();
}

Measured memory_bytes: 3972
#include <stdio.h>

int main()
{
	int a, b;
	int sum=1;
	scanf("%d %d", &a, &b);
	int c=1;
	for(int j=0; j<a; j++)
	{
		c=c*100;
	}
	if(b<100)
	{
		for(int i=0; i<a; i++)
		{
			sum=sum*100;
		}
		sum=sum*b;
	}
	else
	{
		for(int i=0; i<a; i++)
		{
			sum=sum*100;
		}
		sum=sum*b+c;
	}
	printf("%d", sum);
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AOJ
{
	class Program
	{
		static void Main(string[] args)
		{
			var line = "";
			while ((line = Console.ReadLine()) != null)
			{
				int[] l = line.Split(',').Select(i => int.Parse(i)).ToArray<int>();
				int a = 0;
				for (int i = 0; i < 10; i++)
					a += l[i];
				double v1 = (double)l[10], v2 = (double)l[11];
				int d = 0;
				for (int i = 0; i < 10; i++)
				{
					d += l[i];
					double t = d / v1;
					if (d + t * v2 >= a)
					{
						Console.WriteLine(i + 1);
						break;
					}
				}
			}
		}
	}
}

Measured memory_bytes: 20244
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define  ff first
#define  ss second
#define sz(a) (ll)a.size()
#define lli long long int
#define pb push_back
#define pf push_front
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) ;
#define M 1000000007
#define pi 3.1415926535


 int main(){

    fast;
    
    ll n;
    cin>>n;
    
    
    ll v=n%1000;
    if(v==0)cout<<0<<"\n";
	   else  cout<<1000-v<<"\n";
     return 0;
 }





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

int  main()
{
	int a,b,k; cin >> a >> b >> k;
	set<int> st;
	for(int i = a; i <= b; i++)
	{
		if (i < a + k)
		{
			if (!st.count(i))
				cout << i << endl;
			st.insert(i);
		}
		if (i > b - k)
		{
			if (!st.count(i))
				cout << i << endl;
			st.insert(i);
		}
	}
	return (0);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <string>
using namespace std;
#include<chrono>
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define foo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define min3(a,b,c)         min(a,min(b,c))
#define max3(a,b,c)         max(a,max(b,c))
#define min4(a,b,c,d)       min(a,min(b,min(c,d)))
#define max4(a,b,c,d)       max(a,max(b,max(c,d)))
#define max5(a,b,c,d,e)     max(max3(a,b,c),max(d,e))
#define min5(a,b,c,d,e)     min(min3(a,b,c),min(d,e))
typedef pair<int, int>  pii;
typedef pair<ll, ll>  pl;
typedef vector<int>   vi;
typedef vector<ll>    vl;
typedef vector<pii>   vpii;
typedef vector<pl>    vpl;
typedef vector<vi>    vvi;
typedef vector<vl>    vvl;
int mpow(int base, int exp); 
void ipgraph(int m);
void DFS(int n);
bool isprime(ll n);
int gcd(int a,int b);
void rstgraph(int n);

const int mod = pow(10,9)+7;
const int N = 3e5, M = N;

//=======================================================================================
vi g[N];
int vis[N];
int nodes=0;
// ll ans=0;
void iluzn() {
  int n,m;
  cin>>n>>m;
  ll sum=0;
  while(m--){
    int p;
    cin>>p;
    sum+=p;
  }
  if(sum>n) cout<<-1;
  else cout<<n-sum;
}

 
int main() {
  #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
  #endif
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int t=1,i;
    // cin>>t;
     while(t--) iluzn();
    return 0;
}
int mpow(int base, int exp) {
  base %= mod;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
  }
  return result;
}
bool isprime(ll n){
    if(n<=1)
        return false;
    if(n==2)
        return true;
    if(n%2==0)
        return false;
    ll rt = sqrt(n);
    for(ll i=3;i<rt;i+=2){
        if(n%i==0)
            return false;
    }
    return true;
}
int gcd(int a, int b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b); 
} 
void ipgraph(int m){
  int u, v;
  while(m--){
    cin>>u>>v;
    g[u].pb(v);
    // g[v].pb(u);
  }
}

void DFS(int n)
{  ++nodes;
    vis[n] = 1;
    for(vector<int>::iterator i = g[n].begin(); i != g[n].end() ; i++)
    {
        if(!vis[*i])
            DFS(*i);
    }
}
void rstgraph(int n){
  int i;
  fo(i,n+1){
    g[i].clear();
    vis[i]=0;
  }
  nodes=0;
}

Measured memory_bytes: 10704
///Bismillahir Rahmanir Rahim
#include "bits/stdc++.h"

#define                           ll                          long long
#define                           int                         ll
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<ll,ll>
#define                           clr(x)                      memset(x,0,sizeof(x));
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           show(x,y)                   cout<<x<<" : ";for(auto z:y)cout<<z<<" ";cout<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

const ll inf=1e18;
const int mod=1e9+7;
const int M=100005;

 main()

{
    fast
    string s,t;
    cin>>s>>t;
    int n=s.size();
    s=s+s;
    int nxt[2*n+2][28];
    memset(nxt,-1,sizeof nxt);
    rf(i,2*n-1,0)
    {
        f(j,0,25)
        {
            nxt[i][j]=nxt[i+1][j];
        }
        nxt[i][s[i]-'a']=i;
    }
    int sz=t.size();
    int cur=0,cnt=0;
    f(i,0,sz-1)
    {
       int dan=nxt[cur][t[i]-'a'];
       if(dan==-1)
       {
           cout<<"-1"<<endl;
           return 0;
       }
       if(dan>=n)
       {
          cur=dan-n+1;
          cnt++;
       }
       else
       {
           cur=dan+1;
       }
       if(cur==n)
       {
           cur=0;
           cnt++;
       }
    }
    int ses=(cnt*n)+(cur);
    cout<<ses<<endl;
    return 0;

}





































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

set<int> s,s1;

int main(){
  int a,b,k,ans,j=0;
    cin >> a>>b>>k;
    for(int i = 1;i<=sqrt(a);i++){
        if(a%i==0){
        s1.insert(i);
        s1.insert(a/i);}
    }
    for(int i = 1;i<=sqrt(b);i++){
        if(b%i==0){
        s.insert(i);
        s.insert(b/i);}
    }
    for(auto v1 = s1.rbegin();v1!=s1.rend();v1++){

        for(auto v  = s.rbegin();v!=s.rend();v++){
            if(*v1==*v){++j;break;}
        }
        ans = *v1;
    if(j==k)break;
    }
    cout << ans << endl;



    return 0;}


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

int main(){
    int N; cin >> N;
    string S; cin >> S;
    int ans = 1;
    char c = S[0];
    rep(i, 1, N){
        if(S[i] != c){
            ans++;
            c = S[i];
        }
    }
    cout << ans << endl;

}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
long long n,x,y=1000000000,a[300005];
string s;
int main()
{
    cin>>n>>s;
    for (int i=0;i<n;i++)
    {
        a[i]=x;
        if (s[i]=='W')
            x++;
    }
    x=0;
    for (int i=n-1;i>=0;i--)
    {
        a[i]+=x;
        if (s[i]=='E')
            x++;
    }
    x=0;
    for (int i=0;i<n;i++)
    {
        y=min (a[i],y);
    }
    cout<<y;
    return 0;
}



Measured memory_bytes: 2948
#from bisect import bisect_left as bl                #c++ lowerbound bl(array,element)
#from bisect import bisect_right as br               #c++ upperbound br(array,element)
#from __future__ import print_function, division    #while using python2


def modinv(n,p):
    return pow(n,p-2,p)

def main():
    #sys.stdin = open('input.txt', 'r')
    #sys.stdout = open('output.txt', 'w')

    n = int(input())
    a = [int(x) for x in input().split()]
    a.sort(reverse=True)
    series = [a[0]]
    
    i = 1
    k = 1
    while True:
        if k == n-1:
            break
        series.append(a[i])
        k += 1
        if k == n-1:
            break
        series.append(a[i])
        k += 1
        i += 1    

    # print(series)
    print(sum(series))

#------------------ Python 2 and 3 footer by Pajenegod and c1729-----------------------------------------
py2 = round(0.5)
if py2:
    from future_builtins import ascii, filter, hex, map, oct, zip
    range = xrange

import os, sys
from io import IOBase, BytesIO

BUFSIZE = 8192
class FastIO(BytesIO):
    newlines = 0
    def __init__(self, file):
        self._file = file
        self._fd = file.fileno()
        self.writable = "x" in file.mode or "w" in file.mode
        self.write = super(FastIO, self).write if self.writable else None

    def _fill(self):
        s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
        self.seek((self.tell(), self.seek(0,2), super(FastIO, self).write(s))[0])
        return s
    def read(self):
        while self._fill(): pass
        return super(FastIO,self).read()

    def readline(self):
        while self.newlines == 0:
            s = self._fill(); self.newlines = s.count(b"\n") + (not s)
        self.newlines -= 1
        return super(FastIO, self).readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.getvalue())
            self.truncate(0), self.seek(0)

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        if py2:
            self.write = self.buffer.write
            self.read = self.buffer.read
            self.readline = self.buffer.readline
        else:
            self.write = lambda s:self.buffer.write(s.encode('ascii'))
            self.read = lambda:self.buffer.read().decode('ascii')
            self.readline = lambda:self.buffer.readline().decode('ascii')

sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip('\r\n')

if __name__ == '__main__':
   main()


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

using namespace std;
#define intMax 2147483647
#define rep(i, a, b) for (int i = a; i < b; i++)
#define repp(i, a, b) for (int i = a; i >= b; i--)
#define be(a) (a.begin(), a.end())
#define rbe(p) (p.rbegin(), p.rend())
#define pb push_back

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string a , b;
    cin >> a >> b;
    int ans = 0;
    rep(i,0,3){
        if ( a[i] == b[i] ){
            ans++;
        }
    }
    cout << ans;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
  int a, b;
  scanf("%d %d", &a, &b);
  int c;
  for ( c=1; c<=3; c++ ) {
    if ( a * b * c % 2 != 0 ) {
      puts("Yes");
      return 0;
    }
  }
  puts("No");
  return 0;
}

Measured memory_bytes: 128
#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++)

using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int dx[] = { 0, 1, -1, 0, 1, -1, 1, -1 };  // i<4:4way i<8:8way
int dy[] = { 1, 0, 0, -1, 1, -1, -1, 1 };

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

string s[1005];
ll dis[1005][1005];

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int h,w;
    int sx,sy,gx,gy;

    cin >> h >> w;
    cin >> sx >> sy;
    cin >> gx >> gy;
    rep(i,h)cin >> s[i];

    sx--;sy--;
    gx--;gy--;

    rep(i,1005)rep(j,1005)dis[i][j] = inf;

    dis[sx][sy] = 0;

    queue<pair<int,int>> q;
    queue<pair<int,int>> q2;
    q.push({sx,sy});
    while(!q.empty()){
        while(!q.empty()){
            auto now = q.front();
            q2.push(now);
            q.pop();
            // まずは現在地から歩いていける点を全て埋める
            for(int i=0;i<4;i++){
                int nx = dx[i] + now.first;
                int ny = dy[i] + now.second;
                if(nx < 0 || ny < 0 || nx >= h || ny >= w)continue;
                if(s[nx][ny] == '#')continue;
                if(dis[nx][ny] <= dis[now.first][now.second])continue;
                dis[nx][ny] = dis[now.first][now.second];
                q.push({nx,ny});
                q2.push({nx,ny});
            }
        }
        // 歩いていった点からテレポートを使う
        while(!q2.empty()){
            auto now = q2.front();
            q2.pop();
            for(int i=0;i<5;i++){
                for(int j=0;j<5;j++){
                    int nx = now.first  - 2 + i;
                    int ny = now.second - 2 + j;
                    if(nx < 0 || ny < 0 || nx >= h || ny >= w)continue;
                    if(s[nx][ny] == '#')continue;
                    if(dis[nx][ny] <= dis[now.first][now.second] + 1)continue;
                    dis[nx][ny] = dis[now.first][now.second] + 1;
                    q.push({nx,ny});
                }
            }
        }
    }
    cout << (dis[gx][gy] == inf?-1:dis[gx][gy]) << endl;
}

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

bool check_knock(std::vector<long long int> hp, long long int a, long long int b, long long int search_num) {
    long long int div = a - b;
    long long int total = 0;

    for (long long int i = 0; i < hp.size(); i++) {
        hp[i] -= search_num * b;
        if (hp[i] > 0) {
            total += (hp[i] / div); 
            if (hp[i] % div != 0) {
                total++;
            }
        }
    }
    if (total > search_num) {
        return false;
    } else {
        return true;
    }
}

int main(void) {
    long long int n;
    long long int a;
    long long int b;
    std::cin >> n >> a >> b;

    std::vector<long long int> hp(n);
    for (long long int i = 0; i < n; i++) {
        std::cin >> hp[i]; 
    }
    std::sort(hp.begin(), hp.end(), std::greater<long long int>());

    long long int left;
    long long int right;
    long long int middle;
    left = 0;
    right = 1e09;
    while (left < right) {
        middle = (left + right) / 2;
        if (check_knock(hp, a, b, middle) == false) {
            left = middle + 1;
        } else {
            right = middle;
        }
    }
    std::cout << right << std::endl;
    return 0;
}


Measured memory_bytes: 1792
from sys import setrecursionlimit
setrecursionlimit(4100000)
n, m = map(int, input().split())
P = [[] for i in range(n)]   #Pass
for i in range(m):
    a, b = map(int, input().split())
    a, b = a - 1, b - 1  
    P[a].append(b)
    P[b].append(a)
#print(P)

c = 0   #cursol
R = [0 for i in range(n)]  #Record
tm = 1  #time

def all_search_dfs(c:int, tm:int, R:list):
    if R[c] == 0:
        R[c] = 1
        if  tm < n:
            return point_calculate(c, tm, R)
        elif tm == n:
            return 1
        else:
            return 0
    else:
        return 0

def point_calculate(c:int, tm:int, R:list):
    #print('c = ', c)
    p = 0
    #print('check = ', P[c])
    for i in range(len(P[c])):
        R2 = R[:]
        #print('before = ', R2)
        tmp = all_search_dfs(P[c][i], tm + 1, R2)
        #print('after = ', R2)
        #print('tmp = ', tmp)
        p += tmp
        #print('p = ', p)
    return p

print(all_search_dfs(c, tm, R))

Measured memory_bytes: 9192
N,M,K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
a,b = [0],[0]
for i in range(N):
  a.append(a[i]+A[i])
for i in range(M):
  b.append(b[i]+B[i])
ans,j = 0,M
for i in range(N+1):
  if a[i] > K:
    break
  while b[j] > K -a[i]:
    j -= 1
  ans = max(ans, i+j)
print(ans)

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

void yes() {
    cout << "Yes" << endl;
    exit(0);
}
void no() {
    cout << "No" << endl;
    exit(0);
}
#define REP(i, n) for (long long i = 0; i < (n); i++)

vector<bool> visited(105);
vector<vector<int>> edge(105);
bool dfs(int cur, int par) {
    // if a cycle doesn't exist, return true
    visited[cur] = true;
    bool ic = false;
    if (edge[cur].size() == 0) {
        return true;
    } else {
        for (int i = 0; i < edge[cur].size(); i++) {
            if (edge[cur][i] == par) {
                continue;
            }
            if (visited[edge[cur][i]]) {
                ic = true;
                break;
            } else {
                visited[edge[cur][i]] = true;
            }
            if (!dfs(edge[cur][i], cur)) {
                ic = true;
            }
        }
        if (ic) {
            return false;
        } else {
            return true;
        }
    }
}
int ctoi(char c) {
    if (c >= '0' && c <= '9') {
        return c - '0';
    }
    return 0;
}
long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return t * t % 2019;
    } else {
        return modpow(m, n - 1) * m % 2019;
    }
}
signed main() {
    long long v, e;
    cin >> v >> e;
    vector<int> ans;
    queue<int> zeros;
    vector<vector<int>> graph(v);
    vector<vector<int>> bgraph(v);
    vector<int> degree(v);
    vector<int> dp(v);
    REP(i, e) {
        // https/chess.com
        int a, b;
        cin >> a >> b;
        graph[a - 1].push_back(b - 1);
        bgraph[b - 1].push_back(a - 1);
        degree[b - 1]++;
    }
    REP(i, v) {
        if (degree[i] == 0) {
            zeros.push(i);
        }
    }
    while (zeros.size() > 0) {
        int cur = zeros.front();
        zeros.pop();
        ans.push_back(cur);
        for (int i = 0; i < graph[cur].size(); i++) {
            degree[graph[cur][i]]--;
            if (degree[graph[cur][i]] == 0) {
                zeros.push(graph[cur][i]);
            }
        }
    }
    int anss = 0;
    REP(i, v) {
        REP(j, bgraph[ans[i]].size()) { dp[ans[i]] = max(dp[bgraph[ans[i]][j]] + 1, dp[ans[i]]); }
    }
    REP(i, v) {
        if (dp[i] > anss) {
            anss = dp[i];
        }
    }
    cout << anss << endl;
}


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

typedef long long lint;
typedef unsigned long long ulint;
const int MOD=1000000007;

int main(){
    lint A,B,C,X,Y;
    cin >> A >> B >> C >> X >> Y;
    if(2*C>=A+B){
        cout << (X*A+Y*B) << endl;
        return 0;
    }
    if(X>=Y){
        cout << (Y*C*2+min(C*2,A)*(X-Y)) << endl;
        return 0;
    }else{
        cout << (X*C*2+min(C*2,B)*(Y-X)) << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cstring>
#include <functional>
#include <cmath>
#include <complex>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep1(i,n) for(int i=1;i<=(n);++i)
#define all(c) (c).begin(),(c).end()
#define fs first
#define sc second
#define pb push_back
#define show(x) cout << #x << " " << x << endl
typedef long long ll;
int N;
ll a[4000],sum[4001];
short int inf=10000,p2[4001];
vector<short int> seg[4001];
short int pl[4001][8191];
vector<ll> vals[4001];
int query(int a,int b,int l,int r,int k,int id){
	if(b<=l||r<=a) return -inf;
	if(a<=l&&r<=b) return seg[id][k];
	return max(query(a,b,l,(l+r)/2,2*k+1,id),query(a,b,(l+r)/2,r,2*k+2,id));
}
int main(){
	cin>>N;
	rep(i,N) cin>>a[i];
	rep(i,N+1){
		p2[i]=1;
		while(p2[i]<=i) p2[i]*=2;
	}
	rep(i,N+1) seg[i].resize(p2[i]*2);
	rep(i,N) sum[i+1]=sum[i]+a[i];
	rep(l,N){
		for(int r=l+1;r<=N;r++){
			vals[r].pb(sum[r]-sum[l]);
		}
	}
	rep1(r,N){
		sort(all(vals[r]));
		vals[r].erase(unique(all(vals[r])),vals[r].end());
	}
	for(int l=0;l<N;l++){
		for(int r=l+1;r<=N;r++){
//			printf("(l,r)=%d,%d\n",l,r);
			ll s=sum[r]-sum[l];
			int id=lower_bound(all(vals[l]),s)-vals[l].begin();
			int v=query(0,id,0,p2[l],0,l);
			if(l==0) v=0;
			if(l==0||v>=1){
				int id2=lower_bound(all(vals[r]),s)-vals[r].begin();
				if(v+1>seg[r][p2[r]-1+id2]){
					seg[r][p2[r]-1+id2]=v+1;
					pl[r][p2[r]-1+id2]=l;
					//printf("seg[%d][%d]=%d\n",r,p2-1+id2,seg[r][p2-1+id2]);
					int p=(p2[r]-1+id2-1)/2;
					while(true){
						if(seg[r][p*2+1]>seg[r][p*2+2]){
							seg[r][p]=seg[r][p*2+1],pl[r][p]=pl[r][p*2+1];
						}else{
							seg[r][p]=seg[r][p*2+2],pl[r][p]=pl[r][p*2+2];
						}
						if(p==0) break;
						p=(p-1)/2;
					}
				}
			}
		}
	}
	cout<<seg[N][0]<<endl;
	vector<int> ans;
	int now=N;
	while(true){
		now=pl[now][0];
		if(now==0) break;
		ans.pb(now);
	}
	sort(all(ans));
	rep(i,ans.size()){
		if(i==ans.size()-1) cout<<ans[i]<<endl;
		else cout<<ans[i]<<" ";
	}
}

Measured memory_bytes: 185688
#include<stdio.h>
int main()
{
    int a[1000];
    int i,j,min,n,k=0;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    scanf("%d",&a[i]);
    
    
    //selection sort
    for(i=0;i<n;i++)
    {
        min=i;
        for(j=i+1;j<n;j++)
        {
            if(a[i]>a[j])
            {
                min=j;
                
            }
            
        }
        if(min!=i)
        {
        a[min]^=a[i];
         a[i]^=a[min];
            a[min]^=a[i];
            k++;
            }
        if(k>1)
        break;
    }
   
    if(k>1)
    printf("NO");
    else
    printf("YES");
    
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
typedef long long ll;
typedef pair<int, int> P;
 
int main(){
	  int n;
	    cin >> n;
			string c;
			cin >> c;
	    
			int nr=0;
			rep(i,n){
				if(c.at(i)=='R') nr++;
			}

			int RinW=0, WinR=0;
			rep(i, n){
				if(i<nr){
					if(c.at(i)!='R') WinR++;
				}
				else{
					if(c.at(i)!='W') RinW++;
				}
			}

			cout << max(RinW, WinR) << endl;
	    return 0;
}


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

const int N = (1e3) + 5;
const int OO = 1e8;
vector<int> adj[N];
vector<int> ans;
deque<int> path;
int Next[N];
bool vis[N];
int n, m;

int dfs(int u, int start, int sz) {
  int min_sz = OO;
  for (int v: adj[u]) {
    if (!vis[v]) {
      if (v == start) {
        Next[u] = v;
        return sz + 1;
      }
      vis[v] = true;
      int tmp = dfs(v, start, sz + 1);
      if (tmp < min_sz) {
        min_sz = tmp;
        Next[u] = v;
      }
    }
  }
  return min_sz;
}

void cycleRec(int start) {
  path.clear();
  path.emplace_back(start);
  int v = Next[start];
  while (v != start) {
    path.emplace_back(v);
    v = Next[v];
  }
}

int main() { // claudio van
  scanf("%d %d", &n, &m);
  for (int i = 0; i < m; ++i) {
    int u, v; scanf("%d %d", &u, &v);
    --u; --v;
    adj[u].emplace_back(v);
  }
  int start = -1, min_sz = OO;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      vis[j] = false;
      Next[j] = -1;
    }
    int sz = dfs(i, i, 0);
    if (sz < min_sz) {
      start = i;
      min_sz = sz;
    }
  }
  if (start == -1) {
    printf("-1\n");
  } else {
    for (int i = 0; i < n; ++i) {
      vis[i] = false;
      Next[i] = -1;
    }
    dfs(start, start, 0);
    cycleRec(start);
    printf("%d\n", (int) path.size());
    for (int i = 0; i < (int) path.size(); ++i) {
      printf("%d\n", path[i] + 1);
    }
  }
  return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll INF= 1e18L+5;
int mx = 0;
int idg[100005] = {0};
int visited[100005] = {0};	
void solve(int i, vector<int> v[],int dp[]){
	visited[i]++;
	for(int j=0; j<v[i].size(); j++){
		dp[v[i][j]] = max(dp[i]+1,dp[v[i][j]]);
		idg[v[i][j]]--;
		mx = max(mx,dp[v[i][j]]);
		if(idg[v[i][j]]==0)
			solve(v[i][j],v,dp);
	}

}

int main() {
	int n,m;
	cin >> n>>m;
	vector<int> v[n+1];
	int x,y;
	for(int i=0; i<m; i++){
		cin >> x>>y;
		v[x].push_back(y);
		idg[y]++;
	}
	int dp[n+1]={0};
	// for(int i=1; i<=n; i++){
	// 	for(int j=0; j<v[i].size(); j++){
	// 		dp[v[i][j]] = max(dp[i]+1,dp[v[i][j]]);
	// 		mx = max(mx,dp[v[i][j]]);
	// 	}
	// }
	for(int i=1; i<=n; i++)
		if(!visited[i]&&!idg[i])
			solve(i,v,dp);
	cout<<mx<<endl;
}

Measured memory_bytes: 11520
def solve(S, T):
    StoT = {}
    TtoS = {}
    for s, t in zip(S, T):
        if s not in StoT:
            StoT[s] = t
        if t not in TtoS:
            TtoS[t] = s
        
        if StoT[s] != t or TtoS[t] != s:
            return False

    return True
        


S = list(input())
T = list(input())

bool = solve(S, T)
if bool:
    print('Yes')
else:
    print('No')

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

using namespace std;
#define ll long long int

int main()
{
   ll t;
   t = 1;	
 //  cin t;
   while(t--){
       long double a,b;
       cin >> a >> b;
       ll C = b * 100 + 0.01;

       cout << (long long int) (a * C)/ 100 << endl;      
   }
}


Measured memory_bytes: 3732
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL MOD = 1000000007;
#define lcm(x, y) ((x) * (y) / __gcd((x), (y)))
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define debug(x) cout << #x << " : " << x << endl
#define part cout << "----------------------------------\n";
#include <iostream>

int dx[] = {1, 1, 0, -1, -1, -1, 0, 1}; // trick to explore an implicit 2D grid
int dy[] = {0, 1, 1, 1, 0, -1, -1, -1}; // S,SE,E,NE,N,NW,W,SW neighbors  //GO FOR EVEN FOR 4 moves

#define fastinput                     \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);

LL POW(LL x, LL y)
{
    LL ans = 1;
    LL base = x;
    while (y)
    {
        if (y & 1)
        {
            ans *= base;
        }
        base = base * base;
        y = y >> 1;
    }
    return ans;
}

int main()
{
    fastinput;
    LL n,i,j,k,t,temp,tc;
    cin>>n;
    LL rem=n%1000;
    LL ans=(1000-rem)%1000;
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 3648
i=->{gets.split.map &:to_i};w,h,n=i[];l=b=0;n.times{x,y,a=i[];l=a<2&&l<x ?x: l;w=a==2&&x<w ?x: w;b=a==3&&b<y ?y: b;h=a>3&&y<h ?y: h};p l<w&&b<h ?(w-l)*(h-b):0

Measured memory_bytes: 1788
#include <iostream>
#include <stdio.h>
#include <set>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>

typedef long long int lli;
#define rep(i,s,N) for(int i=s;i<N;i++)
using namespace std;

int main(void)
{
	int N, K; cin >> N >> K;
	vector<int> l(N); rep(i, 0, N)cin >> l[i];
	sort(l.begin(), l.end());
	reverse(l.begin(), l.end());
	int ans = 0;
	rep(i, 0, K)ans += l[i];
	cout << ans << endl;

	return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;

static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const ll INF = 1023456789;

#define REP(i,n)	for(int i=0;i<n;++i)
#define REPR(i,n)	for(int i=n-1;i>=0;--i)
#define FOR(i,s,n)	for(int i=s;i<n;++i)
#define FORR(i,s,n)	for(int i=n-1;i>=s;--i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define F			first
#define S			second

int main(int argc, char **argv) {
	string s;
	cin >> s;
	for (char ch = 'a'; ch <= 'z'; ++ch) if (find(ALL(s), ch) == s.end()) {
		cout << ch << endl;
		return 0;
	}
	cout << "None" << endl;
	return 0;
}


Measured memory_bytes: 512
S = input()

s = {i for i in S}
c1=0
c2=0
if len(s) !=2:
    print("No")
else:
    a = S[0]
    b = S[1]
    for i in S[2:]:
        if i==a:
            c1 += 1
        elif i == b:
            c2 += 1
    if c1 == 2 or c2 == 2:
        print("No")
    else:
        print("Yes")


Measured memory_bytes: 2940
#include <stdio.h>

int main(void)
{       
  int a,b,c;
  scanf("%d %d",&a,&b);
   if(a<=b){
  	c=(a+b-1)/a; 
  }
   else if(b<=a){
  	c=1; 
  }
  printf("%d\n",c);
	return 0;
}


Measured memory_bytes: 2104
#include <iostream>
#include <vector>
#include <utility>
#include <string>
#include <cctype>
#include <climits>
#include <algorithm>

using namespace std;
typedef pair<int,int> Point;

inline int dist(const Point &p1, const Point &p2) {
    return abs(p1.first-p2.first) + abs(p1.second-p2.second);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    while(true) {
        int X, Y;
        cin >> X >> Y;
        if(!X && !Y) break;

        Point start, goal;
        vector<Point> creatures[5];
        for(int i = 0; i < Y; ++i) {
            string line;
            cin >> line;
            for(int j = 0; j < X; ++j) {
                if(line[j] == 'S') {
                    start = make_pair(i, j);
                } else if(line[j] == 'G') {
                    goal = make_pair(i, j);
                } else if(isdigit(line[j])) {
                    creatures[line[j]-'0'-1].push_back(make_pair(i, j));
                }
            }
        }
        int best_init = -1;
        int ans = INT_MAX;
        for(int init = 0; init < 5; ++init) {
            vector<int> prev, cur;
            {
                int target = (init+1) % 5;
                // 最初は init から始めて, init+1 を捕まえたところから始める．
                prev.resize(creatures[target].size());
                for(int i = 0; i < (int)creatures[target].size(); ++i) {
                    prev[i] = dist(start, creatures[target][i]);
                }
            }
            for(int step = 2; step < 5; ++step) {
                const int target = (init+step) % 5;
                const int prev_target = (target+4) % 5;
                const vector<Point> &tv = creatures[target];
                const vector<Point> &pv = creatures[prev_target];
                cur.resize(tv.size());
                fill(cur.begin(), cur.end(), INT_MAX/5);
                for(int i = 0; i < (int)tv.size(); ++i) { // Target(position move to)
                    for(int j = 0; j < (int)pv.size(); ++j) { // Previous(position move from)
                        cur[i] = min(cur[i], prev[j] + dist(pv[j], tv[i]));
                    }
                }
                prev = cur;
            }
            // 最後はゴールへ移動
            {
                const int prev_target = (init+4) % 5;
                for(int i = 0; i < (int)prev.size(); ++i) {
                    const int d = prev[i] + dist(creatures[prev_target][i], goal);
                    if(d < ans) {
                        ans = d;
                        best_init = init;
                    }
                }
            }
        }
        if(best_init == -1) cout << "NA" << endl;
        else cout << best_init+1 << ' ' << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 1300
from collections import *
import sys

cnt1 = Counter()
cnt2 = Counter()
for s in sys.stdin:
    if s == "\n": break
    cnt1[map(int,s.split(","))[0]] += 1
for s in sys.stdin:
    if s == "\n": break
    cnt2[map(int,s.split(","))[0]] += 1
for e in cnt1:
    if cnt2[e]: print e,cnt1[e]+cnt2[e]

Measured memory_bytes: 4604
#pragma GCC optimize("Ofast")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <random>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;

typedef
tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> orderedSet;

#define pb push_back
#define F first
#define S second
#define all(a) (a).begin(), (a).end()

#define for1(i0, l0, r0) for (int i0 = l0; i0 < r0; ++i0)
#define for2(i0, l0, r0) for (int i0 = l0; i0 <= r0; ++i0)
#define forn(i0, n0) for (int i0 = 0; i0 < n0; ++i0)
#define forn1(i0, n0) for (int i0 = 1; i0 < n0; ++i0)
#define forr(i0, n0) for (int i0 = n0; i0 >= 0; --i0)
#define forr1(i0, r0, l0) for (int i0 = r0; i0 > l0; --i0)
#define forr2(i0, r0, l0) for (int i0 = r0; i0 >= l0; --i0)

#define Sort(a) sort(all(a))
#define Reverse(a) reverse(all(a))
#define relaxMax(a, b) a = max(a, b)
#define relaxMin(a, b) a = min(a, b)

typedef long double ld;
#define ui unsigned int
#define ull unsigned long long

typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef pair<string, string> pss;

typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<ld> vld;
typedef vector<bool> vb;
typedef vector<string> vs;

typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<pdd> vpdd;

typedef vector<vi> vvi;
typedef vector<vd> vvd;
typedef vector<vll> vvll;
typedef vector<vb> vvb;

#define vpss vector<pss>
#define vvs vector<vs>
#define vvpii vector<vpii>
#define vvpll vector<vpll>
#define vpt vector<pt>
#define vvvi vector<vvi>
#define vsi vector<set<int>>
#define ss second
#define ff first

#define printvi(arr) for (int x0 : arr) cout << x0 << ' '; cout << '\n';
#define printvll(arr) for (ll x0 : arr) cout << x0 << ' '; cout << '\n';
#define printpair(pair0) cout << pair0.F << ' ' << pair0.S << '\n';
#define printvp(arr) for (auto pair0 : arr) printpair(pair0);
#define initArray(arr, N0, X0) memset(arr, X0, N0 * sizeof(int))
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void init() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //cout.precision(16);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
}

void solve() {
    ll a, b, c;
    cin >> a >> b >> c;
    if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0){
        cout << "0\n";
        return;
    }
    cout << min(a * b, min(a * c, b * c)) << '\n';
}

bool multitest = false;

int main() {
    init();
    int t = 1;
    if (multitest) cin >> t;
    forn(i, t) solve();
}

Measured memory_bytes: 3616
def lcs(x, y):
    m = len(x)
    n = len(y)

    c = [[0 for _ in range(n + 1)] for _ in range(m + 1)]
    for i in range(1, m + 1):
        for j in range(1, n + 1):
            if x[i - 1] == y[j - 1]:
                c[i][j] = c[i - 1][j - 1] + 1
            else:
                c[i][j] = max(c[i - 1][j], c[i][j - 1])

    lcs_str = ''
    i, j = m, n
    while i > 0 and j > 0:
        if x[i-1] == y[j-1]:
            lcs_str += x[i-1]
            i -= 1
            j -= 1
        else:
            if c[i][j] == c[i-1][j]:
                i -= 1
            else:
                j -= 1

    return lcs_str[::-1]


s = input()
t = input()
print(lcs(s, t))


Measured memory_bytes: 119900
n, k = map(int, input().split())

ans = 0

def select(l, r):
    return (l+r)*(r-l+1) // 2

for i in range(k, n+2):
    l = select(0, i-1)
    r = select(n-i+1, n)
    ans += (r-l+1) 
    ans %= (pow(10, 9) + 7)

print(ans)

Measured memory_bytes: 9108
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG 
#define rep(i, n) for (int i = 0; i < n; i++)
#define reps(i, s, n) for (int i = s; i < n; i++)
#define all(v) v.begin(), v.end() // sort(all(array))
#define INF 1000000000
#define mod 1000000007
#define EPS 0.001
using namespace std;
using ll = long long;
using vi = vector<int>; //vi array(要素数, 初期値)
using pll = pair<ll, ll>;
using pii = pair<int, int>;
using vc = vector<char>;
using vs = vector<string>;
using vb = vector<bool>;
using vvi = vector<vi>; //vvi table(行数, vi(列数, 初期値))
using vvc = vector<vc>;
using vvs = vector<vs>;
using vvb = vector<vb>;

//解法1 long double型の利用
int main() {
    long double a, b; cin >> a >> b;
    /*long longへのキャストで1.00-->0.9999...となるかもしれない
    ==> +0.001(EPS)をする*/
    cout << (ll)(a * b + EPS) << endl;
}

/*解法2 文字列の利用
int main() {
    ll a; cin >> a;
    string b; cin >> b;
    ll b100 = (b[0] - '0') * 100 + (b[2] - '0') * 10 + (b[3] - '0');
    cout << a * b100 / 100 << endl;
}
*/



Measured memory_bytes: 3656
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define endl "\n"
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define vll vector<ll>
#define all(x)	x.begin(),x.end()
#define fileopen freopen("input.txt", "rt", stdin);
#define fileclose freopen("output.txt", "wt", stdout);
#define Fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define hash visited.max_load_factor(0.25);visited.reserve(512)

using namespace std;

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

   if(n%1000==0)
   {
       cout<<0;
   }
   else
   {
       cout<<1000-n%1000;
   }
   
   
}



    
   
   



    
   
   
    
  


    


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

#define INF 1e9
using namespace std;
typedef long long ll;

ll weight[110], value[110];

ll dp[110][100100];

int main() {

    ll n, w; cin >> n >> w;

    for (ll i = 0; i < n; ++i) {
        cin >> weight[i] >> value[i];
    }

    for (ll i = 0; i < 110; ++i) {
        for (int j = 0; j < 100100; ++j) {
            dp[i][j] = 1LL<<60;
        }
    }

    dp[0][0] = 0;

    for (ll i = 0; i < n; ++i) {
        for (ll j = 0; j < 100100; ++j) {
            //選ぶ
            if (j - value[i] >= 0) {
                dp[i+1][j] = min(dp[i+1][j], dp[i][j-value[i]] + weight[i]);
            }

            //選ばない
            dp[i+1][j] = min(dp[i+1][j], dp[i][j]);
        }
    }

    ll ans;

    for (ll i = 0; i < 100100; ++i) {
        if (dp[n][i] <= w) {
            ans = i;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 86272
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")

def main():
    #h,w=list(map(int,input().split()))
    n=int(input())
    ans=[]
    for x in range(1,n+1):
        if x%3==0 or str(x).count("3")>0:
            ans.append(x)
    print("",*ans)
main()



Measured memory_bytes: 6108
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main(){
  int a, b, c;
  int i;

  cin >> a >> b >> c;

  int flag = 0;

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

  if(flag == 1){
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long                                    // long long省略
#define pb push_back                                    // push_back省略
#define mp make_pair                                    // make_pair省略
#define fi first                                        // first省略
#define se second                                       // second省略
#define itn int                                         // int誤字保険
#define count cout                                      // cout誤字保険
#define vecotr vector                                   // vector誤字保険
#define ednl endl                                       // endl誤字保険
#define opt() cin.tie(0); ios::sync_with_stdio(false)   // 入出力速度改善

#define rep(i,l,r) for(ll i=(l);i<(r);i++)               // 範囲[l, r)で刻み1のfor文(順方向)
#define repp(i,l,r,k) for(ll i=(l);i<(r);i+=(k))         // 範囲[l, r)で刻みkのfor文(順方向)
#define rrep(i,l,r) for(ll i=(r-1);i>=(l);i--)           // 範囲[l, r)で刻み1のfor文(逆方向)
#define rrepp(i,l,r,k) for(ll i=(r-1);i>=(l);i-=(k))     // 範囲[l, r)で刻みkのfor文(逆方向)
#define all(x) (x).begin(), (x).end()                   // vectorのポインタ位置指定用
#define max(p,q)((p)>(q)?(p):(q))                       // max拡張
#define min(p,q)((p)<(q)?(p):(q))                       // min拡張
#define bit(n,m)(((n)>>(m))&1)                          // 変数nのm番目のbitを取り出す

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

int dy[]={0, 1, 0, -1};                                 // 4方向近傍
int dx[]={1, 0, -1, 0};                                 // 4方向近傍

int main(){
    ll n,a,b;cin>>n>>a>>b;
    cout << "Christmas";
  	rep(i,0,25-n) cout << " Eve";
  	cout << ednl;
}


Measured memory_bytes: 256
#include <stdio.h>
#define N 200000
typedef struct process{
	char name[11];
	int time;
}process;

process P[N];
int head = 0;
int bottom = 0;

void push(process x){
	P[head%N]= x;
	head++;
}
process pop(void){
	int d;
	d = bottom%N;
	bottom++;
	return P[d];
}

int main(int argc, char argv[]){
	int n;
	int q;
	int t=0;
	scanf("%d %d",&n,&q);
	process ins;

	int i;
	for(i=0;i<n;i++){
		scanf("%s %d",ins.name,&ins.time);
		push(ins);
	}

	while(head!=bottom){
		ins = pop();
		if(ins.time-q>0){
			ins.time -= q;
			push(ins);
			t += q;
		}else{
			t += ins.time;
			printf("%s %d\n",ins.name,t);
		}
	}

	return 0;
}

Measured memory_bytes: 4648
#include <stdio.h>

int main(void){
  int a, b, digit, sum;

  while(scanf("%d%d", &a, &b) != EOF){
    sum = a + b;
    digit = 0;
    while(sum != 0){
      digit++;
      sum /= 10;
    }
    printf("%d\n", digit);
  }
  return 0;
}

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

using namespace std;

#define topper top //XDDDDDDD

#define mp make_pair
#define pb push_back
#define db(x) cerr << #x << " == " <<  x << endl;
#define _ << " " <<

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;

const long double EPS = 1e-9;
const int N=1e5+5;
const int MOD=1e9+7;
const int INF=0x3f3f3f3f;
const ll LINF=0x3f3f3f3f3f3f3f3f;

int n, m;
ll cc, mi[N], best[N], vis[N], cst[N], ord[N];
set<int> thebest;
vi adj[N];

void dfs(int u) {
  vis[u] = cc;
  if(cst[u] < mi[cc]) {
    best[cc] = u;
    mi[cc] = cst[u];
  }
  for(int v : adj[u]) if(vis[v] != cc) dfs(v);
}

int main(){
  scanf("%d %d", &n, &m);

  for(int i=0; i<n; i++) scanf("%lld", &cst[i]), mi[i] = LINF, ord[i] = i;

  memset(vis, -1, sizeof vis);

  for(int i=0; i<m; i++) {
    int u, v;
    scanf("%d %d", &u, &v);
    adj[u].pb(v), adj[v].pb(u);
  }

  for(int i=0; i<n; i++) if(vis[i] == -1) {
    dfs(i);
    cc++;
  }

  for(int i=0; i<cc; i++) thebest.insert(best[i]);

  if(2*(cc-1) > n) return printf("Impossible\n"), 0;

  sort(mi, mi+cc);
  sort(ord, ord+n, [](int i, int j) { return cst[i] < cst[j]; });

  ll ans = 0;
  ll need = 2*(cc-1);
  for(int i=0; i<cc; i++) if(need) ans += mi[i], need--;
  for(int i=0; i<n; i++) if(need > 0 and !thebest.count(ord[i])){
    need--;
    ans += cst[ord[i]];
  }

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

  return 0;
}



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

namespace DPL2_B
{
    class Program
    {
        const int INF = 1 << 30;
        const int MAX = 15;
        //???????????°
        static int n;
        //??¨??????????????????
        static int[,] d = new int[MAX,MAX];
        //??????????¬???°
        static int[] deg = new int[MAX];
        //?±?????????????
        static int ans;
        //?\??????????????????????
        static List<int> odds = new List<int>();

        static void floyd()
        {
            var a = scan;
            n = a[0];
            int e = a[1];
            for (int i = 0; i < n; i++)
            {
                for (int j = 0; j < n; j++)
                {
                    d[i, j] = i == j ? 0 : INF;
                }
            }
            for (int i = 0; i < e; i++)
            {
                var f = scan;
                ans += f[2];
                deg[f[0]]++;
                deg[f[1]]++;
                d[f[0], f[1]] = Math.Min(f[2],d[f[0],f[1]]);
                d[f[1], f[0]] = Math.Min(f[2],d[f[1],f[0]]);
            }
            for (int k = 0; k < n; k++)
            {
                for (int i = 0; i < n; i++)
                {
                    if (d[i, k] == INF) continue;
                    for (int j = 0; j < n; j++)
                    {
                        if (d[k, j] == INF) continue;
                        d[i, j] = Math.Min(d[i, j], d[i, k] + d[k, j]);
                    }
                }
            }
            for (int i = 0; i < n; i++)
            {
                if (deg[i] % 2 ==1)
                {
                    odds.Add(i);
                }
            }
        }
        static void Main(string[] args)
        {
            floyd();
            int cnt = odds.Count;
            int N = 1 << cnt;
            var dp = Enumerable.Repeat(INF, N).ToArray();
            dp[0] = 0;

            //???????????????S???1????????????
            for (int S = 0; S < N; S++)
            {
                for (int i = 0; i < cnt; i++)
                {
                    if ((S & 1 << i) != 0) continue;
                    for (int j = i+1; j < cnt; j++)
                    {
                        if ((S & 1 << j) != 0) continue;
                        dp[S | (1 << i) | (1 << j)] = Math.Min(dp[S | (1 << i) | (1 << j)], dp[S] + d[odds[i], odds[j]]);                     
                    }
                }
            }
            Console.WriteLine(ans+dp[N-1]);
        }

        static int[] scan
        {
            get { return Console.ReadLine().Split().Select(int.Parse).ToArray(); }
        }
    }
}

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

int main()
{
  int n = 0;
  cin >> n;
  int counter = 0;

  for(int i = 1;i <= n;i++){
    string s = to_string(i);
    if(s.size() % 2 == 1){
      counter ++;
    }
  }
  cout << counter << endl;
  return 0;
}

Measured memory_bytes: 256