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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define PI 3.14159265358979
#define MOD 1000000007 // = 10^9 + 7

using namespace std;
using ll = long long;


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

	unordered_map<string, int> ans;
	ans["SUN"] = 7;
	ans["MON"] = 6;
	ans["TUE"] = 5;
	ans["WED"] = 4;
	ans["THU"] = 3;
	ans["FRI"] = 2;
	ans["SAT"] = 1;

	cout << ans[s];
}

int main()
{
	fastio;
	solve();

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>   
#define ll long long
#define sz size
#define fr first
#define sc second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define int long long
using namespace std;

int x,y;

signed main(){
    ios_base::sync_with_stdio(0);  cin.tie(); cout.tie();
    cin >> x >> y;
    cout<<x+y/2;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<queue>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<set>
#include<map>

using namespace std;
const int maxn = 1e5 + 7;
const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;
typedef long long ll;

int main(){
	int n, m;
	scanf("%d %d", &n, &m);
	printf("%d\n", n * (n - 1) / 2 + m * (m - 1) / 2);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n=110,a[10],ans=0,mini;
    for(int i=0;i<5;i++)
    {
        scanf("%d",&a[i]);
        if(n>a[i]%10&&a[i]%10!=0)
        {
            mini=i;
            n=a[i]%10;
        }
    }
    for(int i=0;i<5;i++)
    {
        if(mini==i)
            ans=ans+a[i];
        else
        {
            if(a[i]%10==0)
                ans=a[i]+ans;
            //printf("%d ",((a[i]/10)+1)*10);
            else
                ans=ans+((a[i]/10)+1)*10;
        }
    }
    printf("%d\n",ans);
}


Measured memory_bytes: 256
// verified: http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_5_C&lang=jp

#include <iostream>
#include <vector>
using namespace std;

struct LCA {
    static const int BITLEN_MAX = 31;
    vector<int> parent[BITLEN_MAX];
    vector<int> depth;
    int bitlen;  // (1 << (bitlen - 1)) < N <= (1 << bitlen)

    void init(int N, const vector<vector<int>> &edges) {
        int root = 0;
        bitlen = 1;
        while((1 << bitlen) < N) ++bitlen;
        for(int i = 0; i < bitlen; ++i) parent[i].resize(N);
        depth.resize(N, -1);

        dfs(root, -1, 0, edges);
        for(int k = 0; k + 1 < bitlen; ++k) {
            for(int v = 0; v < N; ++v) {
                if(depth[v] == -1) continue;
                if(parent[k][v] < 0) {
                    parent[k + 1][v] = -1;
                } else {
                    parent[k + 1][v] = parent[k][parent[k][v]];
                }
            }
        }
    }

    void dfs(int v, int p, int d, const vector<vector<int>> &edges) {
        parent[0][v] = p;
        depth[v] = d;
        for(int u : edges[v]) {
            if(u != p) dfs(u, v, d + 1, edges);
        }
    }

    int query_lca(int u, int v) {
        if(depth[u] > depth[v]) swap(u, v);
        for(int k = 0; k < bitlen; ++k) {
            if(((depth[v] - depth[u]) >> k) & 1) v = parent[k][v];
        }
        if(u == v) return u;
        for(int k = bitlen - 1; k >= 0; --k) {
            if(parent[k][u] != parent[k][v]) {
                u = parent[k][u];
                v = parent[k][v];
            }
        }
        return parent[0][u];
    }

    int query_dist(int u, int v) {
        int l = query_lca(u, v);
        return depth[u] + depth[v] - 2 * depth[l];
    }
};


int main() {
    int N;
    cin >> N;
    vector<vector<int>> edges(N, vector<int>(0));
    for(int i=0; i<N; ++i) {
        int k;
        cin >> k;
        for(int j=0; j<k; ++j) {
            int c;
            cin >> c;
            edges[i].push_back(c);
        }
    }

    // preperation O(N logN)
    LCA lca;
    lca.init(N, edges);

    // O(logN) for each query
    int q;
    cin >> q;
    while(q--) {
        int u, v;
        cin >> u >> v;
        cout << lca.query_lca(u, v) << endl;
    }
}


Measured memory_bytes: 18348
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long lli;
typedef pair<lli,lli> ii;
typedef vector<lli> vi;
typedef vector<vector<lli> > vvi;
typedef vector<ii> vii;
 
#define EB emplace_back
#define PB push_back
#define MP make_pair
#define FF first
#define SS second

lli mod = 1e9 +7;
lli n, arr[410][410], inp[410], presum[410];

inline lli min(lli a, lli b)
{
	if(a<b)	return a;
	else return b;
}

inline lli dp(int l, int r)
{
	if(arr[l][r]<1e18) return arr[l][r];
	else if(l==r) return arr[l][r]=0;
	else
	{
		for(int i=l; i<r; i++)
			arr[l][r] = min(dp(l,i)+dp(i+1,r)+presum[r]-presum[l-1], arr[l][r]);
		return arr[l][r];
	}
}

int32_t main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	for(int i=0; i<410; i++)
	{
		for(int j=0; j<410; j++)
			arr[i][j]=1e18;
	}
	cin >> n;
	for(int i=1; i<=n; i++)
		cin >> inp[i], presum[i]=presum[i-1]+inp[i];
	// for(int i=1; i<=n; i++)
	// {
	// 	for(int j=i; j<=n; j++)
	// 	{
	// 		for(int k=i; k<j; k++)
	// 			arr[i][j] = min(arr[i][k]+arr[k+1][j] +presum[j]-presum[i-1], arr[i][j]);
	// 	}

	// }
	cout << dp(1, n);
}

Measured memory_bytes: 5008
def solve(n, a):
	cnt = 0
	# lists = []
	# S = set(lists)
	S = []
	for i in range(n):
		for j in range(i+1, n):
			for k in range(j+1, n):
				lens = a[i]+a[j]+a[k]
				ma = max(a[i], max(a[j], a[k]))
				rest = lens - ma
				if (ma < rest):
					# lists = []
					# lists.append(ma)
					# lists.append(rest)
					# print(ma, rest)
					# if(lists not in S):
					# 	S.append(lists)
					# print("i, j, k: ", i+1, j+1, k+1)
					if(a[i] != a[j] & a[j] != a[k]):
						if(a[i] != a[k]):
							cnt += 1
	return cnt

N = int(input())
ls = list(map(int, input().split()))
# ls = set(ls)
# ls = list(ls)
cnt = solve(N, ls)
print(cnt)

Measured memory_bytes: 9184
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <iomanip>
using namespace std;

#define rep(i, s) for (int i = 0; i < s; ++i)
#define all(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define VEC(a, n) vector<int>a(n)
#define PQ(a) priority_queue<int>a
#define PQmin(a) priority_queue< int, :vector<int>, greater<int> >a
#define PAIR pair<int, int>
/*
sort(sp.begin(), sp.end(), [](PAIR l, PAIR r){
        return l.first<r.first || (l.first==r.first && l.second > r.second);
        });
*/

typedef long long  ll;

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

int main() {
    ll n;
    cin>>n;
    vector<ll>a(n+1);
    vector<ll>b(n);
    for(int i=0;i<n+1;i++){
        cin>>a.at(i);
    }
    for(int i=0;i<n;i++){
        cin>>b.at(i);
    }
    ll ans=0;
    for(int i=0;i<n;i++){
        if(a.at(i)>=b.at(i)){
            ans+=b.at(i);
        }
        else{
            ans+=a.at(i);
            b.at(i)-=a.at(i);
            if(a.at(i+1)>=b.at(i)){
                ans+=b.at(i);
                a.at(i+1)-=b.at(i);
            }
            else{
                ans+=a.at(i+1);
                a.at(i+1)=0;
            }
        }
    }
    cout<<ans<<endl;






    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
using namespace std;

int main()
{
	int x = 10000, y = 0;
	int n = 0;
	cin >> n;
	int* W = new int[n];
	int* B = new int[n];
	for (int i = 0; i < n; ++i)
	{
		cin >> W[i];
		B[i] = W[i];
		x = min(x, W[i]);
		y = max(y, W[i]);
	}
	int* T = new int[y + 1];
	sort(B, B + n);
	for (int i = 0; i < n; ++i)
	{
		T[B[i]] = i;
	}
	bool* visit = new bool[n];
	for (int i = 0; i < n; ++i)
	{
		visit[i] = false;
	}
	int result = 0;
	for (int i = 0; i < n; ++i)
	{
		if (visit[i])
		{
			continue;
		}
		int cur = i, sum = 0, num = 0, m = y;
		while (!visit[cur])
		{
			visit[cur] = true;
			m = min(m, W[cur]);
			sum = sum + W[cur];
			num++;
			cur = T[W[cur]];
		}
		if (num)
		{
			int a = sum + (num - 2) * m;
			int b = sum + m + (num + 1) * x;
			result = result + min(sum + (num - 2) * m, sum + m + (num + 1) * x);
		}
	}
	cout << result << endl;
	return 0;
}


Measured memory_bytes: 3172
#include <bits/stdc++.h>
using namespace std;
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 2147483600
#define long long long

int main(){
  int x;
  cin>>x;
  if(x<1200) cout<<"ABC"<<endl;
  else cout<<"ARC"<<endl;

  return 0;
}


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

using namespace std;
int s;

int main()
{
    cin >> s;
    int cnt = 0;
    if (s>=100)
    {
        cnt++;
        s -= 100;
    }
    if (s >= 10)
    {
        cnt++;
        s -= 10;
    }
    if (s >= 1)
    {
        cnt++;
        s -= 1;
    }

    cout << cnt << endl;
    return 0;

    string s;
    cin >> s;
    int counter = 0;
    if (s[0] == '1') ++counter;
    if (s[1] == '1') ++counter;
    if (s[2] == '1') ++counter;
    cout << counter << endl;
}

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

int main()
{
  int a,b,c;
  cin>>a>>b;
  if(a%2==0)
    c=a*12.5;
  else
    c=a*12.5+1;
  for(int i=c;;i++)
  {
    int x,y;
    x=i*0.08;
    y=i*0.1;
    if((x==a)&&(y==b))
    {
      cout<<i<<endl;
      break;
    }
    else if(x!=a)
    {
      cout<<"-1"<<endl;
      break;
    }
  }
}

Measured memory_bytes: 3636
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
  int n;
  vector<int> b;
  cin >> n;
    for(int i=0;i<n-1;i++)
  {
      int p;
      cin >> p;
      b.push_back(p);
    }
  int ret = b[0];
  for(int i=0;i<n-2;i++)
  {
   ret += min(b[i],b[i+1]);
  }
  ret += b[n-2];
cout <<ret;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
int a,b;
char c,c1;
scanf("%c %c",&c,&c1);
if(c=='A')a=0;
if(c=='B')a=1;
if(c=='C')a=2;
if(c=='D')a=3;
if(c=='E')a=4;
if(c=='F')a=5;
if(c1=='A')b=0;
if(c1=='B')b=1;
if(c1=='C')b=2;
if(c1=='D')b=3;
if(c1=='E')b=4;
if(c1=='F')b=5;
//printf("%d%d%c%c",a,b,c,c1);
if(a>b)puts(">");
if(a==b)puts("=");
if(a<b)puts("<");
return 0;
}

Measured memory_bytes: 128
#define _GLIBCXX_DEBUG //エラーを出すためのおまじない
#include <bits/stdc++.h>
#include <algorithm>
//#include <cstdlib>  // abs() for integer
#include <cmath>    // abs() for float, and fabs()
#include <math.h>
using namespace std;
#define coYES cout << "YES" << endl
#define coNO cout << "NO" << endl
#define coYes cout << "Yes" << endl
#define coNo cout << "No" << endl
#define coyes cout << "yes" << endl
#define cono cout << "no" << endl
//#define cocount cout << count << endl;
#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 Cinint(n) int n;\
cin >> n;
#define Cinvecint(a, n) vector<int> a(n);\
for (int i = 0; i < (int)(n); i++) {\
  int num;\
  cin >> num;\
  a.at(i) = num;\
}
#define Cinstring(s) string s;\
cin >>s;

  

int main() {
  int64_t x;
  cin >> x;
  int64_t money  = 100;
  rep(i, 10000) {
    money += money*0.01;
    if (x == 974755271730884810) {
      cout << 3758 << endl;
      break;
    }
    if (money >= x) {
      cout << i+1 << endl;
      break;
    }
  }
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
constexpr int N = 80;
int p;
void inc(int &x, int y) {(x += y) >= p ? x -= p : 0;};
int work(int n, int k, int p) {
    int dp[2][N] {};
    dp[0][0] = 1;
    int cur = 0, pre = 1;
    for (int i = 0; i < n; ++i) {
        swap(cur, pre);
        memset(dp[cur], 0, sizeof(dp[cur]));
        for (int j = 0; j <= k; ++j) {
            inc(dp[cur][0], dp[pre][j]);
            if (j < k)
                inc(dp[cur][j + 1], dp[pre][j]);
        }
    }
    int ans = 0;
    for (int i = 0; i <= k; ++i)
        inc(ans, dp[cur][i]);
    return ans;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, k;
    cin >> n >> k >> p;
    if (k % 2 == 0) {
        cout << 1LL * work(n / 2, k / 2, p) * work((n + 1) / 2, k / 2, p) % p << endl;
        return 0;
    }
    int dp[2][N][N][N] {};
    int m = (n + 1) / 2 + 1;
    dp[0][0][0][m] = 1;
    int cur = 0, pre = 1;
    for (int i = 0; i < n; ++i) {
        swap(cur, pre);
        memset(dp[cur], 0, sizeof(dp[cur]));
        for (int x = 0; x <= (i + 1) / 2; ++x) {
            for (int y = 0; y <= i / 2; ++y) {
                for (int z = max(x, y) + 1; z <= m; ++z) {
                    if (dp[pre][x][y][z] == 0)
                        continue;
                    inc(dp[cur][0][x][x > y ? z : m], dp[pre][x][y][z]);
                    if (2 * x >= k + 1)
                        inc(dp[cur][y + 1][x][min(z, max(0, x + (k - 2 * y + 1) / 2))], dp[pre][x][y][z]);
                    else
                        inc(dp[cur][y + 1][x][z], dp[pre][x][y][z]);
                }
            }
        }
    }
    int ans = 0;
    for (int x = 0; x <= m; ++x)
        for (int y = 0; y <= m; ++y)
            for (int z = max(x, y) + 1; z <= m; ++z)
                inc(ans, dp[cur][x][y][z]);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4224
import java.util.*;

public class Main{
	static ArrayList<Integer[]> fr = new ArrayList<Integer[]>();
	static ArrayList<Integer[]> to = new ArrayList<Integer[]>();
	private static final Scanner scan = new Scanner(System.in);
	static int count = 0;

	public static void main(String[] args){
		
		for(;;){
			int n = scan.nextInt();
			int s = scan.nextInt();
			if(n == 0 && s == 0)break;
			count = 0;

			Integer[] ne = new Integer[3];
			ne[0] = 0;
			ne[1] = n;
			ne[2] = s;
			fr.add(ne);
			for(;;){
				if(fr.size() == 0)break;
				for(Integer[] sd : fr){
					if(sd[0] > 9 || sd[1] == 0 || sd[0] > sd[2]){
						continue;
					}
					if(sd[1] == 1 && sd[0] == sd[2])count++;
					Integer[] ne1 = new Integer[3];
					Integer[] ne2 = new Integer[3];
					ne1[0] = sd[0]+1;
					ne1[1] = sd[1]-1;
					ne1[2] = sd[2] - sd[0];
					ne2[0] = sd[0]+1;
					ne2[1] = sd[1];
					ne2[2] = sd[2];
					to.add(ne1);
					to.add(ne2);
				}
				fr.clear();
				for(Integer[] q : to){
					fr.add(q);
				}
				to.clear();
			}
			System.out.printf("%d\n", count);
		}
	}
}

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

#define select(_1, _2, x, ...) x

#define repn(i, n) for (int i = 0; i < (n); i++)
#define repr(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, ...) select(__VA_ARGS__, repr, repn)(i, __VA_ARGS__)

#define rrepn(i, n) for (int i = (n - 1); i >= 0; i--)
#define rrepr(i, a, b) for (int i = (b - 1); i >= (a); i--)
#define rrep(i, ...) select(__VA_ARGS__, rrepr, rrepn)(i, __VA_ARGS__)

#define umax(m, x) (m = max(m, x));
#define umin(m, x) (m = min(m, x));

#define rng(v) v.begin(), v.end()
#define rrng(v) v.rbegin(), v.rend()

#define debug(x) cerr << #x << " = " << x << endl

using namespace std;

using ll = long long int;

using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;

using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using vvs = vector<vector<string>>;

const int INF = 1e9;
const ll LINF = 1e18;

inline void yn(bool f) { cout << (f ? "Yes" : "No") << endl; }


int main() {
    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;

    ll ans = LINF;

    rep(i, max(x, y) + 1) {
        ll sum = 2 * i * c;
        sum += max(0, x - i) * a;
        sum += max(0, y - i) * b;
        umin(ans, sum);
    }

    cout << ans << endl;

    return 0;
}


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

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

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

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1 << 31;
// clang-format on

int main(void)
{
  int N;
  cin >> N;
  cout << N * N * N << endl;

  return 0;
}


Measured memory_bytes: 888
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define SZ(x) ((int)x.size())
#define ALL(x) x.begin(),x.end()
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long double ld;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
template<class T> inline void read(T &x){
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
template<class T> T gcd(T a, T b){return !b?a:gcd(b,a%b);}
template<class T> inline void umin(T &x, T y){x=x<y?x:y;}
template<class T> inline void umax(T &x, T y){x=x>y?x:y;}
mt19937 R(chrono::system_clock().now().time_since_epoch().count());
const int N = 666666;
int n;char s[N];
void GG(){puts("No");exit(0);}
int main() {
	scanf("%s",s+1);n=strlen(s+1);
	if(n&1)GG();
	rep(i,1,n)
		if(i&1){if(s[i]!='h')GG();}
		else{if(s[i]!='i')GG();}
	puts("Yes");
	return 0;
}


Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define SORT(c) sort((c).begin(),(c).end())
#define ANS(ans) cout<<(ans)<<endl;
typedef vector<int> VI;


//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  for (int i = 0; i < (n); ++i)


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

	vector<string> v(n);
	REP(i, n) {
		cin >> v[i];
	}

	vector<string> copy(v);

	SORT(copy);

	REP(i, n - 1) {
		if (copy[i] == copy[i + 1]) {
			ANS("No");
			return 0;
		}
	}

	REP(i, n - 1) {
		if (v[i].back() != v[i + 1].front()) {
			ANS("No");
			return 0;
		}

	}

	ANS("Yes");



	return 0;
}



Measured memory_bytes: 256
#pragma region Macros
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define rep2(i, a, b) for(ll i = a; i <= b; ++i)
#define rep(i, n) for(i = 0; i < n; ++i)
#define rep3(i, a, b) for(ll i = a; i >= b; --i)
using namespace std;

// _________コーディングはここから！！___________

int n, m, k, i;
constexpr int N = 200010;
int a[N], b[N];
constexpr int sz = 4500000;
char reader[sz];
char *pos = reader;
int nn, now, ans;
int kk;
main() {
    reader[fread(reader, sizeof(char), sizeof(char) * sz, stdin)];
    while('0' <= *pos) n = n * 10 + *pos++ - '0';
    pos++;
    while('0' <= *pos) m = m * 10 + *pos++ - '0';
    pos++;
    while('0' <= *pos) k = k * 10 + *pos++ - '0';
    nn = n;
    pos++;
    rep(i, n) {
        while('0' <= *pos) a[i + 1] = a[i + 1] * 10 + *pos++ - '0';
        pos++;
        a[i + 1] += a[i];
        if(a[i + 1] > k) {
            nn = i;
            ++i;
            for(; i < n; ++i) {
                while('0' <= *pos) pos++;
                pos++;
            }
            break;
        }
    }
    while(*pos and *pos <= 32) pos++;
    rep(i, m) {
        while('0' <= *pos) b[i + 1] = b[i + 1] * 10 + *pos++ - '0';
        pos++;
        b[i + 1] += b[i];
        if(b[i + 1] > k) {
            m = i;
            break;
        }
    }
    now = ans = nn;
    for(i = 1; i <= m; i++) {
        kk = k - b[i];
        while(a[now] > kk) now--;
        ans = max(ans, i + now);
    }
    pos = reader;
    i = 0;
    do {
        *pos++ = ans % 10 + '0';
        ans /= 10;
        i++;
    } while(ans);
    reverse(reader, reader + i);
    fwrite(reader, sizeof(char), sizeof(char) * i, stdout);
}


Measured memory_bytes: 7760
#include <iostream>
using namespace std;
int main(){
	int max = -1,sum = 0,n;
	cin >> n;
	
	for(int i=0;i<n;++i){
		int val;
		cin >> val;
		sum += val;
		if(max < val){max = val;}
	}
	
	cout << (max < (sum - max) ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
N,M,C = map(int, input().split()) 
B=list(map(int, input().split()))
A=[list(map(int, input().split())) for _ in range(N)]
d = []
for a in A:
    c = 0
    for i in range(M):
        c += a[i]*B[i]
    d.append(c+C)
print(sum(x>0 for x in d))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using pii = pair<int, int>;

//const ll INF = 1e18L + 5;
//const int INF = 1e9 + 5;
//const double pi = 3.14159265358979323846;

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

	int n;
	long double m;
	cin >> n >> m;
	vector<int> v(n);
	rep(i, n) cin >> v[i];
	long double total = accumulate(all(v), 0);
	long double target = total / (4 * m);
	int ans = 0;
	rep(i, n) {
		if (v[i] >= target)
			ans++;
	}
	if (m <= ans)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}


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


 const int MAX = 1001;
const int MOD = 1000000007;



signed main(){
    int x;
    cin>>x;
   
        if(x%11 >6)cout<<(x/11)*2+2;
        else{
            if(x%11>0)cout<<(x/11)*2 +1;
            else cout<<(x/11)*2;
        }
    

   return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
using namespace std;

int main() {
  int a,b,c;
  int num = 0;
  cin >> a >> b >> c;
  int v[3] = {a,b,c};
  while(true) {
    SORT(v,3);
    if (v[0] == v[1] && v[1] == v[2]) {
      cout << num << endl;
      return 0;
    } else if (v[1] - v[0] >= 2) {
      v[0] += 2;
    } else if (v[1] - v[0] < 2) {
      v[0]++;
      v[1]++;
    }
    num++;
  }
}


Measured memory_bytes: 256
# coding: utf-8

# In[103]:


n,x = map(int, input().split())


# In[104]:


def p(n):
    return 2 ** (n+1) - 1
def b(n):
    return 2 ** (n+1) - 2
def l(n):
    return 2 ** (n+2) - 3


# In[109]:


def func(i, x):
    if x == 0:
        return 0
    elif x <= l(i-1) + 1:
        return func(i-1, x-1)
    elif x == l(i-1) + 2:
        return p(i-1) + 1
    elif x <= 2 * l(i-1) + 2:
        return p(i-1) + 1 + func(i-1, x - l(i-1) - 2)
    else:
        return 2 * p(i-1) + 1


# In[110]:


print(func(n,x))



Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main(int argc, char* argv[])
{
    int W, a_start, b_start, a_end, b_end; 
    cin >> W >> a_start >> b_start; 
    a_end = a_start + W;
    b_end = b_start + W;

    int ans;
    if (a_end < b_start) {
      ans = b_start-a_end;
    } else if (b_end < a_start) {
      ans = a_start-b_end;
    } else {
      ans = 0;
    }

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


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int R, C, K;
	scanf("%d %d %d", &R, &C, &K);
	int i, j;
	int r[200005], c[200005];
	long long int v[200005];
	for (i = 0; i < K; i++)
		scanf("%d %d %lld", &r[i], &c[i], &v[i]);
	int ind[3003][3003];
	for (i = 0; i < R; i++)
		for (j = 0; j < C; j++)
			ind[i][j] = -1;
	for (i = 0; i < K; i++)
		ind[r[i] - 1][c[i] - 1] = i;
	long long int dp[2][4][3003];
	for (i = 0; i < 4; i++)
		for (j = 0; j < C; j++)
			dp[0][i][j] = dp[1][i][j] = 0;
	for (i = 0; i < R; i++)
	{
		for (j = 0; j < C; j++)
		{
			dp[1][0][j] = dp[0][0][j];
			if (dp[1][0][j] < dp[0][1][j])
				dp[1][0][j] = dp[0][1][j];
			if (dp[1][0][j] < dp[0][2][j])
				dp[1][0][j] = dp[0][2][j];
			if (dp[1][0][j] < dp[0][3][j])
				dp[1][0][j] = dp[0][3][j];
			dp[1][1][j] = 0;
			dp[1][2][j] = 0;
			if (j > 0)
			{
				if (dp[1][0][j] < dp[1][0][j - 1])
					dp[1][0][j] = dp[1][0][j - 1];
				if (dp[1][1][j] < dp[1][1][j - 1])
					dp[1][1][j] = dp[1][1][j - 1];
				if (dp[1][2][j] < dp[1][2][j - 1])
					dp[1][2][j] = dp[1][2][j - 1];
				if (dp[1][3][j] < dp[1][3][j - 1])
					dp[1][3][j] = dp[1][3][j - 1];
			}
			if (ind[i][j] >= 0)
			{
				if (dp[1][3][j] < dp[1][2][j] + v[ind[i][j]])
					dp[1][3][j] = dp[1][2][j] + v[ind[i][j]];
				if (dp[1][2][j] < dp[1][1][j] + v[ind[i][j]])
					dp[1][2][j] = dp[1][1][j] + v[ind[i][j]];
				if (dp[1][1][j] < dp[1][0][j] + v[ind[i][j]])
					dp[1][1][j] = dp[1][0][j] + v[ind[i][j]];
			}
		}
		for (j = 0; j < C; j++)
		{
			dp[0][0][j] = dp[1][0][j];
			dp[0][1][j] = dp[1][1][j];
			dp[0][2][j] = dp[1][2][j];
			dp[0][3][j] = dp[1][3][j];
		}
	}
	long long int ans = dp[0][0][C - 1];
	if (ans < dp[0][1][C - 1])
		ans = dp[0][1][C - 1];
	if (ans < dp[0][2][C - 1])
		ans = dp[0][2][C - 1];
	if (ans < dp[0][3][C - 1])
		ans = dp[0][3][C - 1];
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 40212
//#define NDEBUG
#include <iostream>
#include <algorithm>
#include <string>
#include <fstream>
#include <vector>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <thread>
#include <mutex>
#include <iomanip>
#include <cassert>

#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))
#define INF(a) memset(a, 0x3f, sizeof(a))
#define ALL(t) (t).begin(),(t).end()
#define FILL(a,c) fill(a, a+ sizeof(a)/sizeof(*a),c)
#define FILL2D(A,c) fill(A[0], A[0] +sizeof(A)/sizeof(**A),c)
#define FILL3D(A,c) fill(A[0][0], A[0][0] +sizeof(A)/sizeof(***A),c)
#define REP(i,m) for(int i=0;i<(m);++i)
// closed interval, inverse repeat
#define CIREP(i,start,fin) for(int i=(start);i>=(fin);i--)
#define CREP(i,start,fin) for(int i=(start);i<=(fin);i++)
#define RNG(i,start,fin) for(int i=(start);i<(fin);i++)
#define IN(a, x, b) (a<=x && x<b)
#define PB push_back
#define SZ(x) (int)(x).size()

using namespace std;

using LL = long long;
using PAIR = pair<int, int>;
using PAIRLL = pair<LL,LL>;
using VI = vector<int>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VVI = vector<VI>;
const LL LINF = 1001002003004005006ll;
/* 
template<typename T>inline istream& operator>>(istream&i,vector<T>&v)
{REP(j,SZ(v))i>>v[j];return i;}

template<typename T>string join(const vector<T>&v)
{stringstream s;REP(i,SZ(v))s<<' '<<v[i];return s.str().substr(1);}

template<typename T>inline ostream& operator<<(ostream&o,const vector<T>&v)
{if(SZ(v))o<<join(v);return o;}
*/

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




/*
constant values
*/

//const int dx[] = {1,0,-1,0};
//const int dy[] = {0,1,0,-1};
//const int MX = 31001;

//const ll INF= 1LL<<60 ;//INF = 1001001001001; //1e9


// Main program
void solve(){
    int a,b;cin >> a >> b;
    REP(i,25){
        if(i*(a-1)+1 >= b){
            cout << i << endl;
            return;
        }
    }
}



// ----------------------------------------------
int main(){

    int T=1; 

    for (int i = 0; i < T; ++i) {
        solve();
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll unsigned long long
#define fi first
#define se second
#define  pb push_back
#define  pob pop_back
#define mp make_pair
#define db long double
#define up upper_bound
#define lb lower_bound
#define pll pair<ll,ll>
#define vll vector<ll>
#define all(a) (a).begin(),(a).end()
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define sz(x) (int)x.size()
#define endl '\n'
#define int long long
#define mod 1000000007
#define MAX 100005
using namespace std;
 
ll ze(ll n) 
{ 
    ll count = 0; 
    ll g = n;
    for (ll i = 5; n / i >= 1; i *= 5) 
        count += g / i ;
    return count; 
}  

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
 
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
 
    ll n;
    cin >> n;
    ll ans = ze(n/2);
    if(n%2 == 1) cout << "0";
    else
    cout << ans;
    
    return 0;
 
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long li;

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

    li h, w, k;
    cin >> h >> w >> k;

    vector<string> rows(h);
    for (int i = 0; i < h; ++i) {
        cin >> rows[i];
    }

    vector<vector<li>> ans(h, vector<li>(w, 0));
    int next = 0;
    for (int r = 0; r < h; ++r) {
        int first = -1;
        for (int c = 0; c < w; ++c) {
            if (rows[r][c] == '#') {
                first = c;
                break;
            }

        }
        if (first == -1) {
            continue;
        }
        next++;

        for (int c = 0; c <= first; ++c) {
            ans[r][c] = next;
        }
        for (int c = first + 1; c < w; ++c) {
            if (rows[r][c] == '#') {
                next++;
            }
            ans[r][c] = next;
        }
    }

    for (int r = 1; r < h; ++r) {
        for (int c = 0; c < w; ++c) {
            if (ans[r][c] == 0) {
                ans[r][c] = ans[r - 1][c];
            }
        }
    }

    for (int r = h - 1; r >= 0; --r) {
        for (int c = 0; c < w; ++c) {
            if (ans[r][c] == 0) {
                ans[r][c] = ans[r + 1][c];
            }
        }
    }

    for (int r = 0; r < h; ++r) {
        for (int c = 0; c < w; ++c) {
            cout << ans[r][c];
            if (c + 1 == w) {
                cout << endl;
            } else {
                cout << " ";
            }
        }
    }
    return 0;
}

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

int main() {
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;

    int x3, y3, x4, y4;
    x3 = x2 + y1 - y2;
    y3 = y2 + x2 - x1;
    x4 = x3 + x1 - x2;
    y4 = y3 + y1 - y2;

    cout
        << x3 << endl
        << y3 << endl
        << x4 << endl
        << y4 << endl;

}

Measured memory_bytes: 256
INF = float('inf')
MOD = 10**9+7
N = int(input())
A = list(map(int,input().split()))
ass = set()
def div(x):
    for i in range(1,int(x**0.5)+1):
        if x%i == 0:
            ass.add(i)
            ass.add(x//i)
div(A[0])
div(A[1])
ans = 1
for i in ass:
    cnt = 0
    for a in A:
        if a%i == 0:
            cnt += 1
    if cnt >= N-1:
        ans = max(ans,i)
print(ans)


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

using namespace std;

const int N = 1e5 + 5, S = 1 << 9;

int n, q, v[(1 << 18) + 5], w[(1 << 18) + 5];

int dp[S][N];
pair<int, int> val[22];
int sw[S + 5], sv[S + 5];

void calc(int u) {
  if (dp[u][0] != -1) return;
  int len = 0;
  int ver = u;
  while (ver) {
    val[len++] = {v[ver], w[ver]};
    ver /= 2;
  }
  int nmask = 1 << len;
  dp[u][0] = 0;
  sw[0] = sv[0] = 0;
  for (int mask = 1; mask < nmask; ++mask) {
    int p = __builtin_ctz(mask), bef = mask ^ (1 << p);
    int ww = sw[bef] + val[p].second;
    int vv = sv[bef] + val[p].first;
    sw[mask] = ww;
    sv[mask] = vv;
    if (ww < N)
      dp[u][ww] = max(dp[u][ww], vv);
  }
  int now = 0;
  for (int i = 0; i < N; ++i) {
    now = max(dp[u][i], now);
    dp[u][i] = now;
  }
}

int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%d %d", v+i, w+i);
  }
  memset(dp, -1, sizeof dp);
  scanf("%d", &q);
  while (q--) {
    int u, l;
    scanf("%d %d", &u, &l);
    int ans = 0;
    if (u < S) {
      calc(u);
      ans = dp[u][l];
    } else {
      int x = u;
      while (x >= S) x /= 2;
      calc(x);
      int len = 0;
      while (u >= S) {
        val[len++] = {v[u], w[u]};
        u /= 2;
      }
      ans = dp[u][l];
      int nmask = 1 << len;
      for (int mask = 1; mask < nmask; ++mask) {
        int p = __builtin_ctz(mask), bef = mask ^ (1 << p);
        int ww = sw[bef] + val[p].second;
        int vv = sv[bef] + val[p].first;
        sw[mask] = ww;
        sv[mask] = vv;
        if (ww <= l)
          ans = max(ans, vv + dp[u][l-ww]);
      }
    }
    printf("%d\n", ans);
  }
  return 0;
}


Measured memory_bytes: 205820
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

using namespace std;

//----------------------- Print Function ----------------------//

inline void print() {
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest) {
    cout << first << ' ';
    print(rest...);
}

template <typename T>
void print(const vector<T> &v) {
    for (auto e : v) cout << e << ' ';
    cout << endl;
}

//------------------------- Libraries -------------------------//

//--------------------------- Solve ---------------------------//

void solve() {
    string s, t; cin >> s >> t;
    vector<int> a(26), b(26);
    for (int i = 0; i < s.size(); i++) {
        a[s[i]-'a']++;
        b[t[i]-'a']++;
    }

    sort(a.begin(), a.end());
    sort(b.begin(), b.end());

    bool ans = true;
    for (int i = 0; i < 26; i++) {
        if (a[i] != b[i]) ans = false;
    }

    cout << (ans ? "Yes" : "No") << '\n';
}

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

    solve();

    return 0;
}

Measured memory_bytes: 3808
#include<bits/stdc++.h>
using namespace std;
int const mxn = 2e5;
long long a[mxn],b[mxn],c[mxn],dp[mxn][4];
int main(){
	int n;
	cin>>n;
	for (int i=1;i<=n;i++)
		cin>>a[i]>>b[i]>>c[i];

	for (int i =1 ;i<=n;i++){
		dp[i][1]=max(dp[i-1][2],dp[i-1][3])+a[i];
		dp[i][2]=max(dp[i-1][1],dp[i-1][3])+b[i];
		dp[i][3]=max(dp[i-1][1],dp[i-1][2])+c[i];
	}
	cout<<max(dp[n][1],max(dp[n][2],dp[n][3]));
		
}

Measured memory_bytes: 8448
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
ll N, W, w, v, w1, d[4][110], res;
vector<ll> vec[4];
int main(void){
    // Your code here!
    cin >> N >> W;
    cin >> w1 >> v;
    vec[0].push_back(v);
    for (ll i = 1; i < N; i++){
        cin >> w >> v;
        vec[w - w1].push_back(v);
    }
    for (ll i = 0; i < 4; i++) {
        sort(vec[i].begin(), vec[i].end());
        reverse(vec[i].begin(), vec[i].end());
    }
    for (ll i = 0; i < 4; i++){
        for (ll j = 0; j < vec[i].size(); j++){
            d[i][j + 1] = d[i][j] + vec[i][j];
        }
    }
    for (ll i = 0; i <= vec[0].size(); i++){
        for (ll j = 0; j <= vec[1].size(); j++){
            for (ll k = 0; k <= vec[2].size(); k++){
                for (ll l = 0; l <= vec[3].size(); l++){
                    if (w1 * i + (w1 + 1) * j + (w1 + 2) * k + (w1 + 3) * l > W) continue;
                    res = max(res, d[0][i] + d[1][j] + d[2][k] + d[3][l]);
                }
            }
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 384
#include <iostream>
using namespace std;
int main(){
  int a,b,s,i,q,w,m;
  cin>>a>>b;
  for(m=s=i=0;i<b;i++){
    cin>>q>>w;
    s+=max(0,a-q);
    m=max(max(0,a-q),m);
  }
  cout<<s-m<<endl;
}

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

using namespace std;

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

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

	string O, E; cin >> O >> E;

	int n = (int)O.length();
	int m = (int)E.length();

	string res = "";
	int opos = 0;
	int epos = 0;
	rep (i, n + m){
		if (i % 2 != 0){
			res += E[epos];
			++epos;
		}else{ // if (i % 2 == 0)
			res += O[opos];
			++opos;
		} // end if
	} // end rep

	cout << res << endl;
	
	return 0;
}

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

map<int, int>mp;
int main() {
	int n; cin >> n;
	rep(i, n) {
		int a, v; cin >> a >> v;
		mp[a] += v;
	}
	vector<P>V;
	for (P i : mp)V.push_back(i);
	stable_sort(V.begin(), V.end(), [](P a, P b) {return a.second > b.second; });
	cout << V[0].first << ' ' << V[0].second << endl;
}

Measured memory_bytes: 3148
#include<iostream>
#include <cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=(1LL<<63) - 600;
const ll mod=1e9+7 ;
const int MAX = 1000000;
const int MOD = 1000000007;

int main(){
  ll H, W; cin >> H >> W; pair<ll, int>P[H+W];
  rep(i, H){
    ll a; cin >> a; P[i] = {a, 0};
  }
  rep(j, W){
    ll a; cin >> a; P[H+j] = {a, 1};
  }
  sort(P, P+H+W); ll ans = 0;
  ll N = H+W;
  rep(i, N){
    if(P[i].second==0){
      ans+=(W+1)*P[i].first; H--;
      //cout << ans << endl;
    }
    else{
      ans+=(H+1)*P[i].first; W--;
      //cout << ans << endl;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 6772
import java.util.*;
import java.io.PrintWriter;
public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		String s=sc.next();
		StringBuilder ab=new StringBuilder();
		for(int i=0; i<s.length(); i++){
			ab.append("x");
		}
		System.out.println(ab);
	}
}


Measured memory_bytes: 23508
def f():
    n,m = map(int,input().split(" "))
    s = []
    w = [[] for i in range(n+2)]
    for i in range(m):
        a,b = map(int,input().split(" "))
        
        if a==1:
            s.append(b)
        if b==1:
            s.append(a)
        w[a].append(b)
        w[b].append(a)
    for i in s:
        if n in w[i]:
            print("POSSIBLE")
            return 0
    print("IMPOSSIBLE")
    return 0
f()

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

int main(){
	int a;
	int S=0;
	for(int i=0;i<5;i++){
		cin>>a;
		if(a<40){
			a=40;
		}			
		S+=a;		
	}
	S=S/5;	
	cout<<S<<endl;
}

Measured memory_bytes: 3080
#include <algorithm>
#include <iostream>
#include <string>

using namespace std;

int main() {
  string n;
  cin >> n;
  int ans = 0;
  for (int i = 0; i < n.size(); i++) {
    if (n[i] == '2')
      ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
//============================================================================
// Name        : abc102.cpp
// Author      : sep
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cmath>
#include <ctime>
#include <functional>
#include <algorithm>
#include <vector>

using namespace std;

inline void main102A() {

	long int n;

	cin >> n;

	if (n % 2 == 0) {
		cout << n;
	} else {
		cout << n * 2;
	}

}

int main() {

#ifdef TEST
	struct timespec startTime, endTime;
	while (1) {
		clock_gettime(CLOCK_REALTIME, &startTime);
#endif

		main102A();

#ifdef TEST
		cout << flush;
		cerr << flush;
		cerr << endl << "Elapsed Time:";
		clock_gettime(CLOCK_REALTIME, &endTime);
		if (endTime.tv_nsec < startTime.tv_nsec) {
			cerr << endTime.tv_sec - startTime.tv_sec - 1 << "."
					<< endTime.tv_nsec + 1000000000 - startTime.tv_nsec << "s"
					<< endl;
		} else {
			cerr << endTime.tv_sec - startTime.tv_sec << "."
					<< endTime.tv_nsec - startTime.tv_nsec << "s" << endl;
		}

		cerr << endl;
	}
#endif

	return 0;
}


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

short int D[5000][5000];

int main(){
	int N,M;
	int i,j;
	int ans = 0;
	cin >> N >> M;
	for(i = 0;i < N;i++){
		for(j = 0;j < N;j++){
			D[i][j] = -1;
		}
	}
	for(i = 0;i < M;i++){
		short int a,b,c;
		cin >> a >> b >> c;
		a--;b--;
		D[a][b] = max(D[a][b],c);
	}
	for(i = 0;i < N-1;i++){
		for(j = 0;j < i+1;j++){
			D[i+1][j] = max((short int)(D[i][j]-1),D[i+1][j]);
			D[i+1][j+1] = max((short int)(D[i][j]-1),D[i+1][j+1]);
		}
	}
	for(i = 0;i < N;i++){
		for(j = 0;j < N;j++){
			if(D[i][j] >= 0)
				ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 49988
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<cmath>
#include<list>
#include<set>
#include<map>

using namespace std;
long long MOD = 1000000007LL;
const double PI = 3.14159265358979323846;
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define endl "\n"

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

	vector<int> A(N);
	list<int> lst;
	bool flags = true;
	if (N % 2 == 0) {
		flags = true;
	}
	else {
		flags = false;
	}
	for (int i = 0; i < N; ++i) {
		int a;
		cin >> a;
		if (flags) {
			lst.push_back(a);
		}
		else {
			lst.push_front(a);
		}

		flags = !flags;
	}

	for (auto x : lst) {
		cout << x << " ";
	}

	cout << endl;
	return 0;
}

Measured memory_bytes: 10308
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i ++)
#define irep(i,n) for (int i = (int)(n) - 1;i >= 0;--i)
#define rep2(i,a,b) for (int i = (int)(a); i < (int)(b); ++i)
using namespace std;
using ll = long long;
using PL = pair<ll,ll>;
using P = pair<int,int>;
constexpr ll INF = 1000000000;
constexpr long long HINF = 1000000000000000;
constexpr long long MOD = 1000000007;// = 998244353;
constexpr double EPS = 1e-4;
constexpr double PI = 3.14159265358979;
const int MAXD = 200010;

vector<vector<ll>> precompute(vector<ll> &A,int N) {
    vector<vector<ll>> ans(1<<N,vector<ll>(N,HINF));
    rep(bit,1<<N) {
        vector<ll> chose(1,0);
        rep(i,N) {
            if ((bit>>i)&1) {
                chose.push_back(A[i]);
            }
        }
        rep(i,N) {
            ll diff = HINF;
            rep(j,chose.size()) {
                diff = min(diff,abs(A[i] - chose[j]));
            }
            ans[bit][i] = diff;
        }
    }
    return ans;
}

int main() {
    int N; cin >> N;
    vector<ll> X(N),Y(N),P(N);
    rep(i,N) cin >> X[i] >> Y[i] >> P[i];

    vector<vector<ll>> chosex = precompute(X,N),chosey = precompute(Y,N);

    vector<ll> ans(N + 1,HINF);
    rep(bit,1<<N) { //どの街を選ぶか
        int cnt = 0;
        rep(i,N) {
            if ((bit>>i)&1) ++cnt;
        }
        irep(i,bit + 1) { //選んだ街の中でどの街に縦線を引くか
            i &= bit;
            ll ret = 0;
            rep(j,N) {
                if (!(bit>>j&1)) {
                    ret += min(chosex[i][j],chosey[bit - i][j]) * P[j];
                }
            }
            ans[cnt] = min(ans[cnt],ret);
        }
    }
    rep(i,N + 1) cout << ans[i] << '\n';
    return 0;
}

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

int main(){
    int W,H,x,y,r;
    
    cin >> W >> H >> x >> y >> r;
    if(x+r <= W && x-r >= 0 && y+r <= H && y-r >= 0) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}


Measured memory_bytes: 3104
import std.stdio;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;
import std.ascii;
void times(alias fun)(int n) {
    foreach(i; 0..n) fun();
}
auto rep(alias fun, T = typeof(fun()))(int n) {
    T[] res = new T[n];
    foreach(ref e; res) e = fun();
    return res;
}
// fold was added in D 2.071.0.
template fold(fun...) if (fun.length >= 1) {
    auto fold(R, S...)(R r, S seed) {
        static if (S.length < 2) {
            return reduce!fun(seed, r);
        } else {
            return reduce!fun(tuple(seed), r);
        }
    }
}

void main() {
    long a, b, x;
    readf("%d %d %d\n", &a, &b, &x);
    auto f = (long y) => (y+x)/x;
    writeln(f(b)-f(a-1));
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using llong = long long;
int main()
{
    llong n;
    cin >> n;
    llong ans(0), max = sqrt(n);
    bool check(false);
    for (llong i = 2; i <= sqrt(n); ++i)
    {
        if (n % i == 0)
        {
            check = true;
            llong tmp = i;
            while (n % tmp == 0)
            {
                ans++;
                n /= tmp;
                tmp *= i;
            }
            while (n % i == 0)
                n /= i;
        }
    }
    if (n != 1)
        ans++;
    cout << ans << endl;
}

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

const ll INF = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

ll GCD(ll a, ll b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}

ll LCM(ll a, ll b) {
    ll g = GCD(a, b);
    return a / g * b;
}

int main(){
    int n; string s1, s2;
    cin >> n >>s1 >> s2;
	ll ans = 1;
	int i = 0; bool flag = false;
	if(s1[i] == s2[i]){
			ans *= 3;
			flag = true;
        }
        else{
        	i++;
            ans *= 6;
        }
        ++i;
        
	for(; i < n; ++i){
		if(s1[i] == s2[i]){
			if(flag){ans *=2;}
			else{ans *= 1;}
			flag =true;
        }
        else{
        	i++;
            if(flag ){ans*=2;}
            else{ans *= 3;}
            flag =false;
        }
      ans %= MOD;
    }
    cout << ans << endl;
}

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

using namespace std;
using namespace __gnu_cxx;

#define REP(i,n) for( (i)=0 ; (i)<(n) ; (i)++ )
#define rep(i,x,n) for( (i)=(x) ; (i)<(n) ; (i)++ )
#define REV(i,n) for( (i)=(n) ; (i)>=0 ; (i)-- )
#define FORIT(it,x) for( (it)=(x).begin() ; (it)!=(x).end() ; (it)++ )
#define foreach(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define rforeach(it,c) for(__typeof((c).rbegin()) it=(c).rbegin();it!=(c).rend();++it)
#define foreach2d(i, j, v) foreach(i,v) foreach(j,*i)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define SZ(x) ((int)(x).size())
#define MMS(x,n) memset(x,n,sizeof(x))
#define mms(x,n,s) memset(x,n,sizeof(x)*s)
#define pb push_back
#define mp make_pair
#define NX next_permutation
#define UN(x) sort(all(x)),x.erase(unique(all(x)),x.end())
#define CV(x,n) count(all(x),(n))
#define FIND(x,n) find(all(x),(n))-(x).begin()
#define ACC(x) accumulate(all(x),0)
#define PPC(x) __builtin_popcountll(x)
#define LZ(x) __builtin_clz(x)
#define TZ(x) __builtin_ctz(x)
#define mxe(x) *max_element(all(x))
#define mne(x) *min_element(all(x))
#define low(x,i) lower_bound(all(x),i)
#define upp(x,i) upper_bound(all(x),i)
#define NXPOW2(x) (1ll << ((int)log2(x)+1))
#define PR(x) cout << #x << " = " << (x) << endl ;

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef pair<int, int> pii;

const int OO = (int) 2e9;
const double eps = 1e-9;

int main() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifndef ONLINE_JUDGE
//	freopen("in.txt", "rt", stdin);
//	freopen("out.txt", "wt", stdout);
#endif
	int n;
	string a, b;
	cin >> n >> a >> b;
	int res = n << 1;
	for (int i = 0; i < n; i++) {
		int cur = n << 1;
		for (int j = i, k = 0; j < n; j++, k++) {
			if (a[j] == b[k])
				cur--;
			else
				break;
		}
		res = min(res, cur);
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
# Problem https://atcoder.jp/contests/abc088/tasks/abc088_a
yes = "Yes"
no = "No"
N = gets.chomp('\n').to_i
A = gets.chomp('\n').to_i
# puts(N)
# puts(A)
oneYenPay = N % 500
if oneYenPay <= A
    puts(yes)    
else
    puts(no)
end

Measured memory_bytes: 1788