akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ctime>
#include <sstream>
#define weewoo ios::sync_with_stdio(false);cin.tie(0)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ld long double
#define ll long long
#define se second
#define fi first
#define ctoi(x) (x-'0')
#define pi (acos(-1))
#define llputin(a,n) for(int i=0;i<n;i++){ll x;cin >> x;a.push_back(x);}
#define iputin(a,n) for(int i=0;i<n;i++){int x;cin >> x;a.push_back(x);}

#define MOD ((ll) 1e9 + (ll) 7)
using namespace std;

ll pw(ll x,ll a){
    if(a==0)
        return 1;
    ll t = pw(x,a/2);
    if(a%2==0)
        return (t*t);
    else
        return (t*t*x);
}

bool prime(int x)
{
    if(x < 2) return false;
        for(int i=2; i<= sqrt(x); i++) {
            if ((x%i) == 0) return false;
        }
    return true;
}

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


ll lcm(ll a,ll b){
    return ( a*b/__gcd(a,b));
}

vector<int>a;

int main()
{
    weewoo;
    ll n;
    cin >> n;
    iputin(a,n);
    ll ans = 1e9;
    for(int i=0;i<=100;i++){
        ll cur=0;
        for(int j=0;j<a.size();j++){
            ll u1 = a[j]-i;
            u1*=u1;
            cur+=u1;
        }
        ans = min(cur,ans);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin>>N;
  int64_t count=0;
  for(int i=1;i<N+1;i++){
    if(i%3==0||i%5==0)
      continue;
    count+=i;
  }
  cout<<count<<endl;
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for (int i = a; i < (int)b; ++i)
#define rrep(i, n) for (int i = ((int)n - 1); i >= 0; --i)

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

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
    ll a, b, v, w, t;
    cin >> a >> v >> b >> w >> t;
    if (v == w) {
        if (a == b) cout << "YES" << endl;
        else cout << "NO" << endl;
    } else if (v < w) {
        cout << "NO" << endl;
    } else {
        if (t * (v - w) >= abs(a - b)) cout << "YES" << endl;
        else cout << "NO" << endl;
    }
    
    return 0;
}



Measured memory_bytes: 3636
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#include<iomanip>
#include<cstring>
#define initdp(a,b) for(int i=0;i<=a;i++)for(int j=0;j<=b;j++)dp[i][j]=-1;
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define ll long long
#define pll pair<ll,ll>
#define rep(i,n) for(int i=0;i<n;i++)
#define repd(i,n) for(int i=n-1;i>=0;i--)
#define waste ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define inf 1e9+1
#define inf1 1e18+1
#define mod 1000000007
#define pie 3.14159265358979323846
#define N 1000005
#define mid(l,r) l+(r-l)/2
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int ddx[8]={1,1,0,-1,-1,-1,0,1},ddy[8]={0,1,1,1,0,-1,-1,-1};
void mad(ll &a,ll b){a=(a+b)%mod;if(a<0)a+=mod;}
ll gcd(ll a,ll b){ if(a>b)swap(a,b);if(!a)return b;return gcd(b%a,a);}

void solve(){
	int x,a;
	cin>>x>>a;
	if(x<a)cout<<0;
	else cout<<10;
}
int main()
{
	waste;
	int t;
	//cin>>t;
	t=1;
	while(t--){
		solve();
	}
}

Measured memory_bytes: 256
use itertools::Itertools;
use proconio::input;
use proconio::marker::*;
use std::cmp;
use std::cmp::Ordering;
use std::cmp::Reverse;
use std::collections::BinaryHeap;

const MAX_V: usize = 50;
const MAX_S: i64 = MAX_V as i64 * 50 + 5;
const INF: i64 = 1e18 as i64;

#[derive(Clone, Copy)]
struct Edge {
    to: usize,
    fee: i64,
    time: i64,
}

#[derive(Eq)]
struct Data {
    v: usize,
    s: i64,
    time: i64,
}

impl Ord for Data {
    fn cmp(&self, other: &Self) -> Ordering {
        self.time.cmp(&other.time)
    }
}

impl PartialOrd for Data {
    fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
        Some(self.cmp(other))
    }
}

impl PartialEq for Data {
    fn eq(&self, other: &Self) -> bool {
        self.time == other.time
    }
}

fn main() {
    input! {
        n: usize,
        m: usize,
        s: i64,
        rails: [(Usize1, Usize1, i64, i64); m],
        exchanges: [(i64, i64); n],
    }

    let mut g = vec![vec![]; MAX_V];
    for (from, to, fee, time) in rails {
        g[from].push(Edge { to, fee, time });
        g[to].push(Edge {
            to: from,
            fee,
            time,
        });
    }

    let mut dp = vec![vec![INF; MAX_S as usize + 5]; MAX_V];

    let mut solve = Solve {
        dp,
        n,
        m,
        g,
        s,
        exchanges,
    };
    solve.solve();
}

struct Solve {
    n: usize,
    m: usize,
    s: i64,
    g: Vec<Vec<Edge>>,
    dp: Vec<Vec<i64>>,
    exchanges: Vec<(i64, i64)>,
}

impl Solve {
    fn solve(&mut self) {
        let s = cmp::min(self.s, MAX_S);
        let g = self.g.clone();

        let mut q = BinaryHeap::new();
        self.push(&mut q, 0, s, 0);

        while let Some(Reverse(data)) = q.pop() {
            let Data { v, s, time } = data;
            if self.dp[v][s as usize] != time {
                continue;
            }

            let (c, d) = self.exchanges[v];
            let ns = cmp::min(s + c, MAX_S);
            self.push(&mut q, v, ns, time + d);

            for e in g[v].iter().copied() {
                self.push(&mut q, e.to, s - e.fee, time + e.time);
            }
        }

        for i in 1..self.n {
            let mut ans = INF;
            for j in 0..(MAX_S + 5) {
                ans = cmp::min(ans, self.dp[i][j as usize]);
            }
            println!("{}", ans);
        }
    }

    fn push(&mut self, q: &mut BinaryHeap<Reverse<Data>>, v: usize, s: i64, time: i64) {
        let data = Data { v, s, time };
        if s < 0 {
            return;
        }
        if self.dp[v][s as usize] <= time {
            return;
        }
        self.dp[v][s as usize] = time;
        q.push(Reverse(data));
    }
}


Measured memory_bytes: 4752
// https://atcoder.jp/contests/abc156/tasks/abc156_d
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define CEIL(a, b) ((a - 1) / b + 1)

const int MOD = 1e9 + 7;

// mod条件下の高速pow
int modpow(int a, int p) {
    if (p == 0)
        return 1;
    if (p % 2 == 0) {
        int root = modpow(a, p / 2);
        return root * root % MOD;
    } else
        return a * modpow(a, p - 1) % MOD;
}

int fermatComb(int a, int b) {
    if (b > a - b)
        return fermatComb(a, a - b);
    int mul = 1; //分子
    int div = 1; //分母
    for (int i = 0; i < b; i++) {
        mul *= (a - i);
        mul %= MOD;
        div *= (i + 1);
        div %= MOD;
    }
    //フェルマーの小定理を利用して掛け算で計算
    return mul * modpow(div, MOD - 2) % MOD;
}

void solve() {
    int N, A, B;
    cin >> N >> A >> B;
    int t = modpow(2, N) - fermatComb(N, A) - fermatComb(N, B) - 1;
    while (t < 0)
        t += MOD;
    cout << t << endl;
}

signed main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    solve();
}


Measured memory_bytes: 3632
#include<iostream>
#include<string>
#include<cstring>
#include<cstdio>
using namespace std;
int main(void){

	string s;
	int n;
	cin >> s;
	cin >> n;

	int count=0;
	int flag[101]={0};
	string b[111];
	for(int i=0;i<n;i++){
        cin >> b[i];
        b[i]+=b[i];
        }
    for(int i=0;i<n;i++){
        if(b[i].find(s)!=string::npos)count++;
    }


    cout<<count<<endl;




	return 0;
}

Measured memory_bytes: 1220
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvvl vector<vvl>
#define vvl vector<vector<ll>>
#define VV(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define VVV(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

typedef pair<ll, string> p;
p get_depth(string s){
  ll cnt = 0;
  for(int i=0;i<s.size();i++) {
    if(s[i]=='.') cnt++;
    else break;
  }
  return make_pair(cnt, s);
}

bool solve(){
  ll n;std::cin >> n;
  if(n==0) return false;
  vvl G = VV(n+1, 0, 0, ll);
  vector<p> v(n);
  for(int i=0;i<n;i++){
    string s;std::cin >> s;
    v[i] = get_depth(s);
  }
  //get par
  for(int i=1;i<n;i++){
    for(int j=i-1;j>=0;j--){
      if(v[j].first<v[i].first){
        G[j].push_back(i);
        break;
      }
    }
  }

  for(int i=0;i<n;i++){
    ll d = v[i].first;
    //直近の子について、[l:r]に|を貼る命令を作る
    ll ml = 10000000, mr = -1;
    for(auto to:G[i]){
      ml = min(ml, to);
      mr = max(mr, to);
    }
    if(mr==-1) continue;
    for(int j=ml;j<=mr;j++){
      if(v[j].first==d+1){
        v[j].second[d] = '+';
      }else{
        v[j].second[d] = '|';
      }
    }
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<v[i].second.size();j++){
      if(v[i].second[j]=='.') v[i].second[j] = ' ';
    }
  }
  for(int i=0;i<n;i++) std::cout << v[i].second << '\n';
  return true;
}
int main(int argc, char const *argv[]) {
  while(true) if(!solve()) break;
  return 0;
}



Measured memory_bytes: 3400
//#pragma comment(linker, "/STACK:102400000,102400000") 手动扩栈
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <math.h>
#include <queue>
#include<string>
#include <set> //插入时相同的不插，边插边排序，里面还有multiset可以重复
#include <algorithm>
#define foc(i,x,y) for(int i = x ; i <= y ; i ++)
#define rea(i,x,y) for(int i = x ; i >= y ; i --)
#define scf(a) scanf("%d",&a)
#define sca(a,b) scanf("%d%d",&a,&b)
#define pri(a) printf("%d\n",a)
#define pri_(a) printf("%d ",a)
#define prn printf("\n")
#define mem(a) memset(a,0,sizeof(a))
#define LL long long
using namespace std;
const double eps = 1e-9;
const int maxn = 1e6 + 10;
const int INF = 0x3f3f3f3f;
const int mod = 1e9 + 7;
int main()
{
    string s;
    cin >> s;
    if(s.length()==2)
    {
        cout << s << endl;
    }
    else
    {
        cout << s[2] << s[1] << s[0] << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>

using namespace std;

int main() {
    int N;
    cin >> N;
    
    int x[N], y[N];
    long long int h[N];
    for(int i=0; i<N; i++) {
        cin >> x[i] >> y[i] >> h[i];
    }
    
    int Cx=0, Cy=0, H=0, flag;
    bool secflag;
    for(int cx=0; cx<101; cx++) {
        for(int cy=0; cy<101; cy++) {
            long long int _H=0;
            flag=0;
            secflag=false;
            for(int i=0; i<N; i++) {
                if(h[i]!=0) {
                    if(_H==0) {
                        _H = h[i] + abs(cx-x[i]) + abs(cy-y[i]);
                        secflag=true;
                    } else {
                        if(h[i]+abs(cx-x[i])+abs(cy-y[i])==_H) {
                            secflag=true;
                            flag++;
                        } else {
                            secflag=false;
                            break;
                        }
                    }
                }
            }
            if(secflag) {
                for(int i=0; i<N; i++) {
                    if(h[i]==0) {
                        if(h[i]+abs(cx-x[i])+abs(cy-y[i])>=_H) {
                            flag++;
                        } else {
                            break;
                        }
                    }
                }
            }
            if(flag==N-1) {
                Cx=cx;
                Cy=cy;
                H=_H;
                break;
            }
        }
    }
    
    cout << Cx << " " << Cy << " " << H << endl;

    return 0;

}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>

using namespace std;

int main() {
	int l = 0;
	int r = 0;
	int n;
	scanf("%d", &n);
	while (getchar() != '\n');
	vector<char> str;
	str.resize(n);
	for (int i = 0; i < n; i++) {
		scanf("%c", &str[i], 2);
		if (str[i] == '(') {
			r++;
		} else {
			if (r >= 1) {
				r--;
			} else {
				l++;
			}
		}
	}


	for (int i = 0; i < r; i++) {
		str.push_back(')');
	}
	for (int i = 0; i < l; i++) {
		str.insert(str.begin(), '(');
	}
	for (int i = 0; i < str.size(); i++) {
		printf("%c", str[i]);
	}
	printf("\n");	
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
X = [-1]*N

total = sum(A)/2
total2 = sum(A[1::2])
for i in range(N//2):
    X[i*2] = int(total - total2)
    X[i*2+1] = int(A[i*2]-X[i*2])
    total -= A[i*2]
    total2 -= A[i*2+1]
X[-1] = int(A[-1] - X[0])

ans = ''
for i in range(N):
    ans += str(X[i]*2) + ' '

print(ans[:-1])

Measured memory_bytes: 15696
import collections

def primes(n): #試し割り法で各素因数とその指数を求める
 cnt=collections.defaultdict(int)
 for i in range(2,int(n**0.5)+1):
   if n%i==0:
     while n%i==0:
       cnt[i]+=1
       n//=i
 if n!=1:
   cnt[n]+=1
 return cnt

n=int(input())
cnt=primes(n)
ans=0
for key in cnt.keys():
 val=cnt[key]
 for i in range(100): #各素因数の指数について、k(k+1)//2<=(指数)を満たす最大のkを求める
   if (i*(i+1))//2>val:
     ans+=i-1
     break
print(ans)

Measured memory_bytes: 9712
#![allow(unused_imports)]
use num::integer::gcd;
use proconio::*;
use std::cmp::*;
use std::collections::VecDeque;
use std::ops::*;

fn main() {
   input! {
      a: usize,
      b: usize,
      c: usize,
      d: usize,
   }

   let ta = (c-1)/b + 1;
   let ao = (a-1)/d + 1;
   if ta <= ao {
      println!("Yes");

   } else {
      println!("No");
   }
}


Measured memory_bytes: 2176
#pragma GCC optimize("Ofast,inline,unroll-loops,fast-math")
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <string>
using namespace std;

int main(void)
{
    string a;

    cin >> a;
    if(a == "SUN")
        cout << 7 << endl;
    else if(a == "MON")
        cout << 6 << endl;
    else if(a == "TUE")
        cout << 5 << endl;
    else if(a == "WED")
        cout << 4 << endl;
    else if(a == "THU")
        cout << 3 << endl;
    else if(a == "FRI")
        cout << 2 << endl;
    else
        cout << 1 << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>//Carefully Crafted by hetp111
using namespace std;
#define int long long
#define double long double
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vii vector<pii>
#define MOD (1000000007)
#define MOD2 (998244353)
#define MOD3 (1000000009)
#define PI acos(-1)
#define eps (1e-8)
#define INF (1e18)
#define FASTER ios_base::sync_with_stdio(0);cin.tie(0)
template<class A,class B>ostream&operator<<(ostream&out,const pair<A,B>&a){return out<<"("<<a.first<<","<<a.second<<")";}
template<class A>ostream&operator<<(ostream&out,const vector<A>&a){for(const A &it:a)out<<it<<" ";return out;}
template<class A,class B>istream&operator>>(istream&in,pair<A,B>&a){return in>>a.first>>a.second;}
template<class A>istream&operator>>(istream&in,vector<A>&a){for(A &i:a)in>>i;return in;}
ifstream cinn("in.txt");ofstream coutt("out.txt");
int poww(const int &a,int b,const int &m=MOD){if(b==0)return 1;int x=poww(a,b/2,m);x=x*x%m;if(b&1)x=x*a%m;return x;}
int ceil(const int &a,const int &b){return (a+b-1)/b;}
////Read:
//Use __builtin_popcountll for ll;
//Check corner cases, n==1;
//
////Some function:
//__builtin_popcountll(), 

signed main(){
    FASTER;
    int x,y;cin>>x>>y;
    for(int a=0;a<=1000;a++){
        for(int b=0;b<=1000;b++){
            if(a*2+4*b==y && a+b==x){
                cout<<"Yes\n";
                return 0;
            }
        }
    }
    cout<<"No\n";
}



Measured memory_bytes: 3656
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

#define rep(i, x, n) for(int i = x; i < n; i++)
using namespace std;
const long long INF = 1LL << 60;

long long GCD(long long a, long long b) {
    if(b == 0)
        return a;
    else
        return GCD(b, a % b);
}
long long LCM(long long a, long long b) {
    long long g = GCD(a, b);
    return a / g * b;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
int main() {
    int A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;
    long long mcost = INF;
    int n = max(X, Y);
    rep(i, 0, 2 * n + 1) {
        long long cost = 0;
        cost += i * C;
        int nokoriA = X - i / 2;
        int nokoriB = Y - i / 2;
        if(nokoriA > 0) {
            cost += nokoriA * A;
        }
        if(nokoriB > 0) {
            cost += nokoriB * B;
        }
        if(mcost > cost) {
            mcost = cost;
        }
    }
    cout << mcost << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
	int a,b;
	scanf("%d %d", &a, &b);
	while (a && b && a != b)
		if (a > b)
			a = a % b;
		else if (b > a)
			b = b % a;
	cout << max(a, b) << endl;
}

Measured memory_bytes: 1204
#include<iostream>
#include<fstream>
#include<cstdio>
#include<vector>
#include<string>
#include<cstring>
#include<queue>
#include<map>
#include<set>
#include<algorithm>
#include<iomanip>
#include<bitset>
using namespace std;

const int N = 2010;

int n, m, x[N][N], l[N][N], cj[N][N], cs[N][N], st[N], top;
char a[N][N];

int main() {
    int i, j, k, r, rez = 0;
    //freopen("ttt", "r", stdin);

    cin >> n >> m;

    for(i = 1; i <= n; ++i)
        cin >> (a[i] + 1);

    for(i = 2; i <= n; ++i) {
        for(j = 1; j <= m; ++j)
            x[i][j] = (a[i][j] == a[i - 1][j] ? 0 : 1);
    }

    for(i = 1; i <= n; ++i)
        for(j = 1; j <= m; ++j) {
            if(j == 1) {
                l[i][j] = 1;
                continue;
            }

            l[i][j] = 1;

            if(x[i][j] == x[i][j - 1])
                l[i][j] = l[i][j - 1] + 1;
        }

    for(i = 1; i <= m; ++i) {
        top = 0;
        st[0] = 0;

        for(j = 1; j <= n; ++j) {
            int le = l[j][i];

            while(top && l[st[top]][i] >= le) {
                --top;
            }

            cj[j][i] = st[top];

            st[++top] = j;
        }

        top = 0;
        st[0] = n + 1;

        for(j = n; j; --j) {

            int le = l[j][i];

            while(top && l[st[top]][i] >= le) {
                --top;
            }

            cs[j][i] = st[top];

            st[++top] = j;
        }
    }

    for(i = 1; i <= n; ++i)
        for(j = 1; j <= m; ++j) {
            int left = l[i][j];

            k = cs[i][j] - 1;
            r = max(1, cj[i][j]);

            rez = max(rez, left * (k - r + 1));
        }

    cout << rez;

    return 0;
}


Measured memory_bytes: 67200
main(a,b,m,i,M){
  for(;;){
    M=0;
    for(i=0;i<5;i++){
      scanf("%d%d",&a,&b);
      if(a+b==0)return 0;
      if(a+b>M)M=a+b,m=i;
    }
    printf("%c %d\n",m+65,M);
  }
}

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

using namespace std;

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

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

int gcd(int a, int b) {
    if (b == 0) {
        return a;
    } else {
        return gcd(b, a % b);
    }
}

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

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;  cin >> s;
    if ((s[0] == s[1] && s[1] == s[2]) || (s[1] == s[2] && s[2] == s[3])) {
      cout << "Yes" << '\n';
    } else {
      cout << "No" << '\n';
    }

    return 0;
}


Measured memory_bytes: 256
#include <cstddef>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <array>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <limits>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <bitset>
#include <valarray>
#include <utility>
#include <tuple>
#include <cmath>
#include <memory>
#include <random>
#include <fstream>
#include <locale>

using ll = long long;
using ull = unsigned long long;

//vector
template <class T>
using vec = std::vector<T>;

template <class T>
using vvec = vec<vec<T>>;

constexpr std::size_t operator""_sz(ull n) { return std::size_t(n); }

int main()
{
    using namespace std;

    string s;
    cin >> s;

    int ans{};
    for (auto c : s)
    {
        if (c == '2')
            ++ans;
    }

    cout << ans << endl;

    return 0;
}


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

int main()
{
	int H, W;
	while (cin >> H >> W, H || W) {
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				cout << '#';
			}
			cout << endl;
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3084
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<string>
#include<cmath>
#include<queue>
#include<vector>
#include<sstream>
#include<algorithm>
#include<stack>
#include<bitset>
#include<map>
#include<set>
#define rep(i,n) for(int i=0;(i)<(n);i++)
#define rep1(i,n) for(int i=1;(i)<=(n);i++)
#define mst(a,b) memset(a,b,sizeof(a))
#define scd(a) scanf("%d",&a)
#define scdd(a,b) scanf("%d%d",&a,&b)
#define scddd(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define dbg(a) cout<<"* "<< #a <<" : "<<a<<endl
#define fr first
#define se second
#define ls x<<1
#define rs x<<1|1
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define lowbit(x) x&(-x)
#define ac cout<<ans<<endl
//#define DEBUG 0
using namespace std;
const double pi=acos(-1.0);
const double eps=1e-6;
const ull hashp=1e7+19;
const ll INF=0x3f3f3f3f3f3f3f3fll;
const int inf=0x3f3f3f3f;
const int mod=1e9+7;
const int maxn=2e5+100;

void solve(){
	char ch;
	scanf("%c",&ch);
	printf("%c",ch+1);
}
int main(){
    //IOS;
    //freopen("D://data.txt","r",stdin);
    solve();
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cstdlib>
#include<cmath>
#include<map>
#include<set>
#include<iomanip>
#include<iterator>
#include<sstream>
using namespace std;
int main()
{
    long long n,d1,d2,s=0,t=0;
    cin>>n;
    while(n--)
    {
        cin>>d1>>d2;
        if(d1==d2)
        {
            s++;
        }
        else
        {
            if(s>=3)
            {
                t++;
            }
            s=0;
        }
    }
    if(s>=3)
    {
        t++;
    }
    if(t==0)
    {
        cout<<"No"<<endl;
    }
    else
    {
        cout<<"Yes"<<endl;
    }
    return 0;
}

Measured memory_bytes: 3620
#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++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
int N,M,L;
double B[11],H[11],h[10];
int F[9];
double X[9];
void pour(int x,double& v,int l,int r){
	if(r-l>=2){
		int mx=l+1;
		for(int i=l+1;i<r;i++) if(H[i]>H[mx]) mx=i;
		if(x<mx){
			pour(x,v,l,mx);
			pour(x,v,mx,r);
		}else{
			pour(x,v,mx,r);
			pour(x,v,l,mx);
		}
	}
	double w=B[r]-B[l],u=min(H[l],H[r]);
	double dh=v/w;
	if(h[l]+dh<u){
		v=0;
		for(int i=l;i<r;i++) h[i]+=dh;
	}else{
		v-=(u-h[l])*w;
		for(int i=l;i<r;i++) h[i]=u;
	}
}
int main(){
	int Q;
	cin>>Q;
	rep(tt,Q){
		cin>>N;
		rep1(i,N) cin>>B[i]>>H[i];
		N++;
		B[0]=0,B[N]=100;
		H[0]=H[N]=50;
		cin>>M;
		rep(i,M){
			cin>>F[i]>>X[i];
			X[i]/=30;
			F[i]=lower_bound(B,B+N,F[i])-B-1;
		}
		cin>>L;
		rep(i,L){
			rep(j,N) h[j]=0;
			int p,t;
			cin>>p>>t;
			rep(j,M){
				double v=X[j]*t;
				pour(F[j],v,0,N);
			}
			p=lower_bound(B,B+N,p)-B-1;
			printf("%.8f\n",h[p]);
		}
	}
}

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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    string s;
    cin >> n >> s;
    int res = 0;

    for(int p = 0; p < 1000; ++p){
        char one = p / 100 + '0';
        char two = (p / 10) % 10 + '0';
        char three = p % 10 + '0';
        
        bool one_f = false;
        bool two_f = false;
        bool three_f = false;

        int ptr = 0;

        for (int i = 0; i < n-2; ++i){
            if(s[i] == one){
                one_f = true;
                ptr = i;
                break;
            }
        }

        for (int i = ptr+1; i < n-1; ++i){
            if(s[i] == two){
                two_f = true;
                ptr = i;
                break;
            }
        }

        for (int i = ptr+1; i < n; ++i){
            if(s[i] == three){
                three_f = true;
                ptr = i;
                break;
            }
        }

        if(one_f && two_f && three_f) res++;
    }
    cout << res << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int,int> P;
 
const int INF = 1e9;
const int mod = 1e9+7;
const double EPS = 1e-10;
const double PI = acos(-1.0);

int main()
{
    int n,m,Q;
    cin >> n >> m >> Q;
    vector<int> right[n+10];
    for(int i = 0; i < m; i++){
        int l,r;
        cin >> l >> r;
        right[r].emplace_back(l);
    }
    for(int i = 1; i <= n; i++) sort(right[i].begin(),right[i].end());
    for(int i = 0; i < Q; i++){
        int p,q,res = 0;
        cin >> p >> q;
        for(int j = p; j <= q; j++){
            if(right[j].size() == 0) continue;
            res -= lower_bound(right[j].begin(),right[j].end(),p)-right[j].end();
        }
        cout << res << endl;
    }

    return 0;
}

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

int main (){

    string c[3];
    for(int i = 0; i < 3; i++) {
        cin >> c[i];
    }

    cout << c[0][0] << c[1][1] << c[2][2] << endl;
    

    return 0;
}


Measured memory_bytes: 256
//FA専用
#include <bits/stdc++.h>
using namespace std;
#define int long long
const long long LINF=1e18;
using ld=long double;
template<typename T>
void chmax(T &a,T b){
  if(a<b)a=b;
}
template<typename T>
void chmin(T &a,T b){
  if(a>b)a=b;
}
template<typename T>
void fin(T a){
  cout<<a<<endl;
  exit(0);
}

signed main(){
  int n;cin>>n;
  cout<<(n/500)*1000+((n%500)/5)*5<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
#include<string>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#include <iomanip>
#pragma region Macros
#define int long long
#define double long double
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define LAST(x) x[x.size()-1]
#define ALL(x) (x).begin(),(x).end()
#define swap(a,b) (a += b,b = a - b,a -= b)
#define CEIL(a,b) ((a+b-1)/b)
int FACT(int a) {
	if (a == 0)
		return 1;
	else
		return a * FACT(a - 1);
}
int nPr(int n, int r) {
	int s = n - r + 1;
	int sum = 1;
	for (int i = s; i <= n; i++)
		sum *= i;
	return sum;
}
//int nCr(int n, int r)
int nCr2(int n, int r) {
	return FACT(n) / (FACT(r) * FACT(n - r));
}
int GCD(int a, int b) // assuming a,b >= 1
{
	if (a < b)
		swap(a, b);
	if (b == 0)
		return a;
	if (a % b == 0)
		return b;
	return GCD(b, a % b);
}
int LCM(int a, int b) // assuming a,b >= 1
{
	return  a * b / GCD(a, b);
}
double LOG(int a, int b) {
	return log(b) / log(a);
}
inline bool BETWEEN(int x, int min, int max) {
	if (min <= x && x <= max)
		return true;
	else
		return false;
}
inline bool PRIMEOR (int x) {
	if (x ==1)
		return false;
	if (x == 2)
		return true;
	if (x%2==0)
		return false;
	double sqrtx = sqrt(x);
	for (int i = 3; i <= sqrtx; i += 2) {
		if (x % i == 0)
			return false;
	}
	return true;
}

using namespace std;
#pragma endregion
signed main() {
	string A, ans = "Yes";
	cin >> A;
	if (A.size() % 2 == 0) {
		for (int i = 0; i < A.size(); i += 2) {
			if (A[i] != 'h' || A[i + 1] != 'i')
				ans = "No";
		}
	}
	else
		ans = "No";
	cout << ans ;
}

Measured memory_bytes: 256
Q, H, S, D = map(int, input().split())
N = int(input())

if H > Q*2:
  H = Q*2
if S > H*2:
  S = H*2
if D > S*2:
  D = S*2

if N % 2 == 0:
  print((N//2)*D)
else:
  print((N//2)*D+S)

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

//#pragma GCC optimize("Ofast")

#define fi first
#define se second
#define ll long long
#define dl double long

using namespace std;

const int NN = 1e9 + 7;
const int N = 2e5 + 7;
const int M = 26;
const ll mod = 998244353;
const ll inf = 1e18 + 7;
const dl rf = 1e-14;
const int B = sqrt(N);
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void solve1()
{
    int k;
    cin >> k;
    int res = 0;
    vector < int > used(361 , 0);
    int x = k;
    while( !used[x] ){
        res += 1;
        used[x] = 1;
        x += k;
        x %= 360;
    }
    cout << res;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    //freopen( "input.txt" , "r" , stdin );
    //freopen( "output.txt" , "w" , stdout );

    int cghf = 1;//cin >> cghf;
    while( cghf-- ){
        solve1();
    }
}


Measured memory_bytes: 3652
#include <iostream> //üoÍ
#include <vector>   //®Izñ
#include <cstdio>
#include <cmath>

using namespace std;

int main(){
	double n;
	while(cin >> n){
		vector<double> vec;
		vec.push_back(n);
		for(int i=0;i<5;i++){
			cin >> n;
			vec.push_back(n);
		}
		double x = ((vec[2]*vec[4])-(vec[1]*vec[5]))/((vec[0]*vec[4])-(vec[1]*vec[3]));
		double y = (vec[2]-(vec[0]*x))/vec[1];

		x = floor((x*1000)+0.5)/1000;
		y = floor((y*1000)+0.5)/1000;
		printf("%.3f %.3f\n", x, y);
		
	}
	
		return 0;
}

Measured memory_bytes: 0
import java.util.*;

public class Main {

    Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        new Main().run();
    }

    void run() {

        int n = sc.nextInt();

        int[] arr = new int[n];
        for (int i=0; i<n; i++) arr[i] = sc.nextInt();


        int cnt = 0;

        for (int i=0; i<n-2; i++) {
            for (int j=i+1; j<n-1; j++) {
                for (int k=j+1; k<n; k++) {
                    if (arr[i]==arr[j] || arr[j]==arr[k] || arr[k]==arr[i]) continue;
                    int[] tmp = new int[3];
                    tmp[0] = arr[i];
                    tmp[1] = arr[j];
                    tmp[2] = arr[k];
                    Arrays.sort(tmp);
                    if (tmp[0]+tmp[1]>tmp[2]) cnt++;
                }
            }
        }

        System.out.println(cnt);

    }


}



Measured memory_bytes: 41568
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n+1;i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end())
typedef long long ll;
typedef vector<int> vec;
typedef vector<vector<int>> vv;

int main(){
  char x,y;
  cin >> x >> y;
  char ans;
  if(x<y) ans = '<';
  if(x==y) ans = '=';
  if(x>y) ans = '>';
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <cstring>
#include <deque>
#include <cstdio>
#include <cmath>
#include <complex>
#include <iostream>
#include <iterator>

using namespace std;

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

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

typedef vector<double> vd;
typedef vector<vd> vvd;

int main()
{
	int n;
	while(scanf("%d", &n), n){
		char str[256];
		vector<string> table(n);
		rep(i, n){
			scanf("%s", str);
			table[i] = str;
		}
		
		int ans = 0;
		rep(i, n) rep(j, n){
			const int dy[] = {-1, -1, 0, 1};
			const int dx[] = {0, 1, 1, 1};
			rep(k, 4){
				int y = i, x = j;
				int cnt = 0;
				while(table[y][x] == '1'){
					++cnt;
					int py = y + dy[k], px = x + dx[k];
					if(py<0 || n<=py || px<0 || n<=px)
						break;
					y = py;
					x = px;
				}
				ans = max(ans, cnt);
			}
		}
		
		printf("%d\n", ans);
	}
	
	return 0;
}

Measured memory_bytes: 1008
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

#define rep(i, x, n) for(int i = x; i < n; i++)
using namespace std;
const long long INF = 1LL << 60;

long long GCD(long long a, long long b) {
    if(b == 0)
        return a;
    else
        return GCD(b, a % b);
}
long long LCM(long long a, long long b) {
    long long g = GCD(a, b);
    return a / g * b;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
int N, M, Q;
vector<int> a;
vector<int> b;
vector<int> c;
vector<int> d;
long long max(vector<int> v, int k, int m) {
    if(k == N) {
        long long ten = 0;
        // rep(i, 0, v.size()) { cout << v[i] << " "; }
        rep(i, 0, Q) {
            if(v[b[i] - 1] - v[a[i] - 1] == c[i]) {
                ten += d[i];
            }
        }
        // cout << ten << endl;
        return ten;
    } else {
        long long maxten = 0;
        rep(i, m, M + 1) {
            vector<int> v2;
            v2 = v;
            v2.push_back(i);
            long long ten = max(v2, k + 1, i);
            if(maxten < ten) {
                maxten = ten;
            }
        }
        return maxten;
    }
}
int main() {
    cin >> N >> M >> Q;
    a.assign(Q, 0);
    b.assign(Q, 0);
    c.assign(Q, 0);
    d.assign(Q, 0);
    rep(i, 0, Q) { cin >> a[i] >> b[i] >> c[i] >> d[i]; }
    vector<int> v;
    cout << max(v, 0, 1) << endl;
}


Measured memory_bytes: 3636
N = int(input())
s = [input() for _ in range(N)]
M = int(input())
t = [input() for _ in range(M)]

X = 0
for i in range(N):
    temp = 0
    temp = s.count(s[i])
    for j in range(M):
        if s[i] == t[j]:
            temp -= 1
    X = max(X, temp)
print(X)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(){
	string S;
	int Q;
	cin >> S;
	cin >> Q;
	int revflg = 0;
	string face = "", tail = "";
	for(int i = 0; i < Q; i++){
		int q1;
		cin >> q1;
		if(q1 == 1){
			revflg++;
			continue;
		}
		int q2;
		cin >> q2;
		char c;
		cin >> c;
		bool flg = (q2 == 1);
		if(revflg%2==1)
			flg = !flg;
		if(flg)
			face += c;
		else
			tail += c;
	}
	if(revflg%2 == 0){
		reverse(face.begin(), face.end());
		S = face+S+tail;
	}else{
		reverse(S.begin(), S.end());
		reverse(tail.begin(), tail.end());
		S = tail+S+face;
	}
	cout << S << endl;

	return 0;
}

Measured memory_bytes: 1348
#include <cstdio>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;

#define X real()
#define Y imag()

typedef complex<double> Point;

namespace std {
  bool operator < (Point a, Point b) {
    if (a.X != b.X) return a.X < b.X;
    return a.Y < b.Y;
  }
}

double dot(Point a, Point b) {
  return (conj(a)*b).X;
}

double cross(Point a, Point b) {
  return (conj(a)*b).Y;
}

bool ccw(Point a, Point b, Point c) {
  return cross(c-b, a-b) > 0.0;
}

vector<Point> ps;

vector<Point> Graham(vector<Point> &ps) {
  vector<Point> qs;

  qs.resize(ps.size()*2);
  sort(ps.begin(), ps.end());

  int k = 0;
  for (int i=0; i<ps.size(); i++) {
    while (k > 1 && !ccw(qs[k-2], qs[k-1], ps[i])) --k;
    qs[k++] = ps[i];
  }

  int _k = k;
  for (int i=ps.size()-1; i>=0; i--) {
    while (k > _k && !ccw(qs[k-2], qs[k-1], ps[i])) --k;
    qs[k++] = ps[i];
  }

  qs.resize(k-1);
  return qs;
}

int main() {
  while (1) {
    int n;
    scanf("%d", &n);
    if (n == 0) return 0;

    ps.resize(n);
    for (int i=0; i<n; i++) {
      double x, y;
      scanf("%lf,%lf", &x, &y);
      ps[i] = Point(x, y);
    }

    vector<Point> convs = Graham(ps);
    printf("%d\n", n-(int)convs.size());
  }
}

Measured memory_bytes: 2596
#include <bits/stdc++.h>
using namespace std;
#define DEBUG 0
#define nl          '\n'
#if     DEBUG
#define trace(var)  {cerr << "Line " << __LINE__ << ": " << #var << "=" << var << nl;}
#else
#define trace(var)	{}
#endif
#define fori(n)			for(int i = 0; i < n; ++i) 
#define forj(n)			for(int j = 0; j < n; ++j)
#define fork(n)			for(int k = 0; k < n; ++k)
#define forl(n)			for(int l = 0; l < n; ++l)

typedef long long ll;typedef pair<int,int> pii;typedef vector<bool> vbool;typedef vector<int> vint;typedef vector<ll> vll;typedef long double ld;typedef vector<vector<int>> vvi;

const ll N = 10010;
const ll INF = 0x3f3f3f3f;
const ll MOD = 1e9 + 7;

int n,m;

void dfs(vvi &adj, vint &dist, vbool &seen, int u) {
	seen[u] = true;
	for(auto v : adj[u]) {
		if (!seen[v])
			dfs(adj, dist, seen, v);
		dist[u] = max(dist[u], 1 + dist[v]);
	}
}
	
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> m; int x,y;
	vvi adj(n+1);
	fori(m) {
		cin >> x  >> y;
		adj[x].push_back(y);
	}
	vbool seen(n+1, false);
	vint dist(n+1,0);
	fori(n) 
		if (!seen[i+1]) 
			dfs(adj, dist, seen, i+1);
	
	int ans = 0;
	fori(n) 
		ans = max(ans,dist[i+1]);

	cout << ans << nl;
	#if DEBUG
	cerr << "Time: " << (ld)clock() / CLOCKS_PER_SEC << " s" << nl;
	#endif
	return 0;
}


Measured memory_bytes: 9600
import sys
import copy
from collections import deque

sys.setrecursionlimit(10**6)
input = sys.stdin.readline
#read = sys.stdin.buffer.read

def main():
    global field
    R, C, K = map(int, input().split())
    field = []
    for _ in range(R):
        tmp = [0] * C
        field.append(tmp)
    DP1 = copy.deepcopy(field)
    DP2 = copy.deepcopy(field)
    DP3 = copy.deepcopy(field)

    for _ in range(K):
        r, c, k = map(int, input().split())
        field[r-1][c-1] = k
    
    i = 0
    DP1[0][0] = field[0][0]
    for j in range(1, C):
        DP3[i][j] = max(DP2[i][j-1] + field[i][j], DP3[i][j-1])
        DP2[i][j] = max(DP1[i][j-1] + field[i][j], DP2[i][j-1])
        DP1[i][j] = max(field[i][j], DP1[i][j-1])

    for i in range(1, R):
        for j in range(C):
            DP3[i][j] = max(DP2[i][j-1] + field[i][j], DP3[i][j-1])
            DP2[i][j] = max(DP1[i][j-1] + field[i][j], DP2[i][j-1])
            DP1[i][j] = max(field[i][j], DP1[i][j-1], max(DP1[i-1][j], DP2[i-1][j], DP3[i-1][j]) + field[i][j])

    ans = max(DP3[R-1][C-1], DP2[R-1][C-1], DP1[R-1][C-1])
    print(ans)


if __name__ == "__main__":
    main()


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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'

// n回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) // 1-indexed昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  // 0-indexed降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   // 1-indexed降順
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii;  // 2次元配列
typedef vector<ll> vll;
typedef vector<double> vd;
typedef pair<int, int> PII;

template<typename T>
using vec = vector<T>;
template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

const ld Pi = std::acos(-1.0L);
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    int _StartTime_ = clock();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    // cout << fixed << setprecision(15);

    int n,m; cin >> n >> m;
    vi c(m); rep(i,m) cin >> c[i];

    // MinimumNumberOfCoins
    vi dp(n+1, inf);
    dp[0] = 0;

    for(int v = 0; v <= n; ++v) {
        for(int i = 0; i < m; ++i) {
            if(v+c[i] <= n) chmin(dp[v + c[i]], dp[v] + 1);
        }
    }

    cout << dp[n] << '\n';

    // printf("ExcutionTime: %d /ms\n",1000*(int)((clock()-_StartTime_)/CLOCKS_PER_SEC));
}


Measured memory_bytes: 3300
#include<cstdio>
#include<iostream>
using namespace std;
int main(){
  int n, y, a;
  char x,xx;
  int cards[4][14];
  for(int b = 0; b < 4; b++){
    for(int c = 0; c < 14; c++){
      cards[b][c] = 0;
    }
  }

  scanf("%d", &n);
  for(int i = 0; i < n; i++){
    cin>>x>>y;
    if(x == 'S'){
      a = 0;
    }    
    if(x == 'H'){
      a = 1;
    }
    if(x == 'C'){
      a = 2;
    }
    if(x == 'D'){
      a = 3;
    }
    cards[a][y] = 1;
  }
  for(int j = 0; j < 4; j++){
    for(int l = 1; l < 14; l++){
      if(cards[j][l] == 1){
      }
      else{
	if(j == 0){
	  x = 'S';
	}    
	if(j == 1){
	  x = 'H';
	}
	if(j == 2){
	  x = 'C';
	}
	if(j == 3){
	  x = 'D';
	}
	printf("%c %d\n", x, l);
      }
    }
  }
}

Measured memory_bytes: 1228
import math
N = int(input())

#(方針) (k-1)k/2 <= N <k(k+1)/2 をみたすk　がイイ感じ
#→ (-1+sqrt(1+8N))//2 < k <= (1+sqrt(1+8N))//2 らへん
#k整数/区間の幅 1より k = int((-1+sqrt(1+8N))//2) or int((-1+sqrt(1+8N))//2) + 1
#丸め誤差あるかもしれないので,少し多めに


about_k = int((-1+math.sqrt(1+8*N))//2)
k = about_k
#print(k)
for i in range(about_k-10,(about_k+10)+1):
 if((i-1)*i < 2*N <= i*(i+1)): 
  #print('a; ',(i-1)*i,2*N)
  k = i
  break

ans = []
sum_p = N
for i in range(k):
  tmp = k-i #tmp = k,k-1,...,1
  if(sum_p-tmp >= 0):
   sum_p -= tmp
   ans.append(tmp)
  if(sum_p == 0): break
    
for i in range(len(ans)):
  print(ans[i])
#print('...',sum(ans))

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

int main(int argc, char* argv[]){
    string S;
    vector<string> a = {"", "A"};
    vector<string> v;
    cin >> S;
    rep(i, 2){
        rep(j, 2){
            rep(k, 2){
                rep(l, 2){
                    v.push_back(a[i] + "KIH" + a[j] + "B" + a[k] + "R" + a[l]);
                }
            }
        }
    }

    rep(i, 16){
        if(S == v[i]){
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    int k,q;
    scanf("%d%d",&k,&q);
    int d[k];
    for (int i = 0; i < k; i++){
        scanf("%d",&d[i]);
    }
    while (q--){
        int n,x,m;
        scanf("%d%d%d",&n,&x,&m);
        ll ans = 0;
        n--;
        ll total = x%m;
        for (int i = 0; i < k; i++){
            int T = (n/k) + (n%k > i);
            total += (ll)T*(d[i]%m);
            if (d[i]%m) ans+=T;
        }
        ans -= total/m;
        printf("%d\n",ans);
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long llo;
#define mp make_pair
#define pb push_back
#define a first 
#define b second
#define endl '\n' 

llo n,k;
llo q;
llo it[200001];
pair<llo,llo> ss[200001][20];
pair<llo,llo> tt[200001][20];
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin>>n>>k;
	for(llo i=0;i<n;i++){
		cin>>it[i];
	}
	for(llo i=n-1;i>=0;i--){
		if(it[n-1]<it[i]+k){
			ss[i][0]={-1,0};
		}
		else{
			llo xx=ss[i+1][0].a;
			if(xx==-1){
				xx=n-1;
			}
			for(llo j=xx;j>=i;j--){
				if(it[j]<it[i]+k){
					break;
				}
				ss[i][0]={j,j};
			}
		}
	}
	for(llo i=0;i<n;i++){
		if(it[0]>it[i]-k){
			tt[i][0]={-1,0};
		}
		else{
			llo xx=tt[i-1][0].a;
			if(xx==-1){
				xx=0;
			}
			for(llo j=xx;j<=i;j++){
				if(it[j]>it[i]-k){
					break;
				}
				tt[i][0]={j,j};
			}
		}
	}
	for(llo j=1;j<20;j++){
		for(llo i=0;i<n;i++){
			if(ss[i][j-1].a==-1){
				ss[i][j]={-1,0};
				continue;
			}
			ss[i][j]={ss[ss[i][j-1].a][j-1].a,-1};
			if(ss[i][j].a==-1){
				continue;
			}
			ss[i][j].b=ss[i][j-1].b+ss[ss[i][j-1].a][j-1].b;
		}
	}
	for(llo j=1;j<20;j++){
		for(llo i=0;i<n;i++){
			if(tt[i][j-1].a==-1){
				tt[i][j]={-1,0};
				continue;
			}
			tt[i][j]={tt[tt[i][j-1].a][j-1].a,-1};
			if(tt[i][j].a==-1){
				continue;
			}
			tt[i][j].b=tt[i][j-1].b+tt[tt[i][j-1].a][j-1].b;
		}
	}
	/*for(llo i=0;i<n;i++){
		cout<<ss[i][0].a<<":";
	}
	cout<<endl;
	for(llo i=0;i<n;i++){
		cout<<tt[i][0].a<<":";
	}
	cout<<endl;
*/

	cin>>q;
	while(q--){
		llo aa,bb;
		cin>>aa>>bb;
		aa--;
		bb--;
		llo x=1;
		llo su=aa;
		llo cur=aa;
		for(llo j=19;j>=0;j--){
			if(ss[cur][j].a==-1){
				continue;
			}
			if(ss[cur][j].a<=bb){
				x+=(1<<j);
				//cout<<j<<":";
				su+=ss[cur][j].b;
				cur=ss[cur][j].a;
			}
		}
		//cout<<endl;
		llo su2=bb;
		cur=bb;
		for(llo j=19;j>=0;j--){
			if(tt[cur][j].a==-1){
				continue;
			}
			if(tt[cur][j].a>=aa){
				su2+=tt[cur][j].b;
				cur=tt[cur][j].a;
			}
		}
		cout<<(su2-su+x)<<endl;
		


	}



	return 0;
}

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

#define all(container) container.begin(), container.end()
#define sortall(container) (sort(container.begin(), container.end()))
#define yn(cond) ((cond) ? (cout << "Yes" << endl) : (cout << "No" << endl))
#define YN(cond) ((cond) ? (cout << "YES" << endl) : (cout << "NO" << endl))

typedef long long       ll;

typedef vector<int>     vi;
typedef vector<ll>      vll;
typedef vector<double>  vd;
typedef vector<bool>    vb;
typedef vector<char>    vc;
typedef vector<string>  vs;
typedef pair<int, int>  pii;
typedef pair<ll, ll>    pll;
typedef vector<vi>		vvi;
typedef vector<vll>		vvll;
typedef vector<vd>		vvd;
typedef vector<vb>		vvb;
typedef vector<vc>		vvc;
typedef vector<vs>		vvs;
typedef vector<pii>     vpii;
typedef vector<pll>     vpll;

typedef struct edge_ {
	ll to;
	ll cost;
} edge;

typedef struct point_ {
	ll x, y;
	point_(ll x = 0, ll y = 0) : x(x), y(y) {}
} point;

template <typename T>
using mat2d = vector<vector<T>>;

constexpr double	PI = 3.14159265358979323846;
constexpr ll		INF = 1 << 15;
constexpr ll		MOD = (ll)1e9 + 7;
constexpr double	EPS = 1e-7;
constexpr int		dy4[4] = { 0, 1, 0, -1 };
constexpr int		dx4[4] = { 1, 0, -1, 0 };
constexpr int		dy8[8] = { 0, 1, 1, 1, 0, -1, -1, -1 };
constexpr int		dx8[8] = { 1, 1, 0, -1, -1, -1, 0, 1 };

template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
	for (T& x : vec) is >> x;
	return is;
}

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vec) {
	for (const T& x : vec) os << x << " ";
	return os;
}

template<typename S, typename T>
istream& operator >> (istream& is, pair<S, T>& p) {
	is >> p.first >> p.second;
	return is;
}

istream& operator >> (istream& is, point& p) {
	is >> p.x >> p.y;
	return is;
}

template<typename S, typename T>
ostream& operator << (ostream& os, const pair<S, T>& p) {
	os << "{" << p.first << " : " << p.second << "}";
	return os;
}

template<typename T>
ostream& operator << (ostream& os, const set<T>& s) {
	for (const T& x : s) os << x << " ";
	return os;
}

ostream& operator << (ostream& os, const edge e) {
	os << "{to: " << e.to << ", cost: " << e.cost << "}";
	return os;
}

ostream& operator << (ostream& os, const point& p) {
	os << "(" << p.x << " " << p.y << ")";
	return os;
}

/******************************************************************************/
/**********************         Don't make WA !!         **********************/
/******************************************************************************/


int main()
{
	int N, L;
	cin >> N >> L;
	vs S(N);
	cin >> S;

	sortall(S);

	for (auto s : S)
		cout << s;
	cout << endl;

	return 0;
}

Measured memory_bytes: 256