akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int a,b;
int f(int m)
{
    if (m == 0)
        return 0;
    else
        return m*(m-1)/2;
}

int main()
{
    scanf("%d %d",&a,&b);
    printf("%d",f(a)+f(b));
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string.h>
#include <algorithm>
#include <vector>
#include <queue>

using namespace std;
typedef long long ll;
const int INF=1000000;
int n,k;
int s[2][2001][2001]={};
int main() {
	int b1=0;
	int w0=0;
	cin>>n>>k;
	int x1,y1;
	char c1;
	for(int i=0;i<n;++i){
		cin>>x1>>y1>>c1;
		if(c1=='W'){
			s[0][x1%(k*2)+1][y1%(k*2)+1]++;
			w0++;
		}
		if(c1=='B'){
			s[1][x1%(k*2)+1][y1%(k*2)+1]++;
			b1++;
		}
	}
	int ans=0;
	for(int i=1;i<=k*2;++i){
		for(int j=1;j<=2*k;++j){
			s[0][i][j]+=s[0][i-1][j]+s[0][i][j-1]-s[0][i-1][j-1];
			s[1][i][j]+=s[1][i-1][j]+s[1][i][j-1]-s[1][i-1][j-1];
		}
	}
	for(int i=0;i<k+1;++i){
		for(int j=0;j<k+1;++j){
			int b2=0,w1=0;

			w1=s[0][i][j];
			b2=s[1][i][j];

			w1+=s[0][i+k][j+k]-s[0][i][j+k]-s[0][i+k][j]+s[0][i][j];
			b2+=s[1][i+k][j+k]-s[1][i][j+k]-s[1][i+k][j]+s[1][i][j];

			w1+=s[0][2*k][2*k]-s[0][2*k][j+k]-s[0][i+k][2*k]+s[0][i+k][j+k];
			b2+=s[1][2*k][2*k]-s[1][2*k][j+k]-s[1][i+k][2*k]+s[1][i+k][j+k];

			w1+=s[0][2*k][j]-s[0][i+k][j];
			b2+=s[1][2*k][j]-s[1][i+k][j];

			w1+=s[0][i][2*k]-s[0][i][j+k];
			b2+=s[1][i][2*k]-s[1][i][j+k];
			ans=max(ans,w1+b1-b2);
			ans=max(ans,w0-w1+b2);
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 31488
#include<bits/stdc++.h>
using namespace std;
int main(){
  int64_t a,b;
  cin >> a >> b;
  int64_t x = abs(a);
  int64_t y = abs(b);
  int ans = 0;
  if(a < b){
    if(a*b >= 0){
      ans = b-a;
    }
    else if(x >= y){
      ans = x-y+1;
    }
    else{
      ans = b-x+1;
    }
  }
  else if(a > b){
    if(a*b > 0){
      ans = abs(a-b)+2;
    }
    else if(x >= y){
      ans = x-y+1;
    }
    else{
      ans = y-x+1;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
from collections import Counter

def ABC137C_GreenBin():
    N = int(input().strip())
    S = [input().strip() for i in range(N)]

    ans = 0
    di = Counter()
    for s in S:
        s = ''.join(sorted(list(s)))
        
        if s in di:
            ans += di[s]

        di[s] += 1
    
    print(ans)


def main():
    ABC137C_GreenBin()

if __name__ == "__main__":
    main()


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

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;

typedef int Weight;
struct Edge {
  int src, dst;
  Weight weight;
  double gas;
  Edge(int src, int dst, Weight weight) :
    src(src), dst(dst), weight(weight) { }
  Edge(int src, int dst, Weight weight, double gas) :
    src(src), dst(dst), weight(weight), gas(gas) { }

};

bool operator < (const Edge &e, const Edge &f) {
  return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
    e.src != f.src ? e.src < f.src : e.dst < f.dst;
}

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

int main() {
  int n, m, cap;
  while(cin>>n>>m>>cap,n||m||cap) {
    map<string, int> id;
    int idnum = 0;
    string src,dst;
    cin >> src >> dst;
    id[src] = idnum++;
    id[dst] = idnum++;
    string a[n], b[n];
    int c[n];
    REP(i, n) {
      cin>>a[i]>>b[i]>>c[i];
      if (id.count(a[i])==0) id[a[i]] = idnum++;
      if (id.count(b[i])==0) id[b[i]] = idnum++;
    }
    Graph g(idnum);
    REP(i, n) {
      g[id[a[i]]].push_back(Edge(id[a[i]], id[b[i]], c[i]));
      g[id[b[i]]].push_back(Edge(id[b[i]], id[a[i]], c[i]));
    }
    set<int> station;
    REP(i, m) {
      string tmp;
      cin >> tmp;
      station.insert(id[tmp]);
    }

    cap *= 10;
    vector<vector<Weight> > dist(g.size(), vector<Weight>(cap+1, INF));
    dist[id[src]][cap] = 0;
    priority_queue<Edge> Q; // "e < f" <=> "e.weight > f.weight"
    for (Q.push(Edge(-2, id[src], 0, cap)); !Q.empty(); ) {
      Edge e = Q.top(); Q.pop();
      if (dist[e.dst][e.gas] < e.weight) continue;
      //cout << e.dst << endl;
      FOR(f,g[e.dst]) {
        int nextgas = e.gas - f->weight;
        //cout << "dst : " << f->dst << " " << nextgas << endl;
        if (nextgas < 0) continue;
        if (station.count(f->dst)) nextgas = cap;
        //cout << nextgas << endl;
        if (dist[f->dst][nextgas] > e.weight+f->weight) {
          dist[f->dst][nextgas] = e.weight+f->weight;
          Q.push(Edge(f->src, f->dst, e.weight+f->weight, nextgas));
          //cout << ": " << f->dst << endl;
        }
      }
    }
    int ans = *min_element(ALL(dist[id[dst]]));
    if (ans == INF)
      cout << -1 << endl;
    else
      cout << ans << endl;
    
  }
}

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

using namespace std;
using ll = long long;

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << #x << ": " << x << endl;
#define popcnt __builtin_popcount


int main() {
    int a, b;
    cin>>a>>b;
    if(b%a==0)cout<<a+b<<endl;
    else cout<<b-a<<endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int dp[101][100010];
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int N, W;
    cin >> N >> W;
    vector<int> w(N), v(N);
    for (int i = 0; i < N; ++i) {
        cin >> w[i] >> v[i];
    }
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j <= 100000; ++j) {
            dp[i+1][j] = dp[i][j];
            if (j > v[i] && dp[i][j-v[i]] != 0 && dp[i][j-v[i]] + w[i] <= W) {
                if (dp[i+1][j] == 0) {
                    dp[i+1][j] = dp[i][j-v[i]] + w[i];
                } else {
                    dp[i+1][j] = min(dp[i+1][j], dp[i][j-v[i]] + w[i]);
                }
            } else if (j == v[i]) {
                if (dp[i + 1][j] == 0) {
                    dp[i + 1][j] = w[i];
                } else {
                    dp[i + 1][j] = min(dp[i + 1][j], w[i]);
                }
            }
        }
    }
    int ans = 0;
    for (int j = 0; j <= 100000; ++j) {
        if (dp[N][j] != 0) {
            ans = max(ans, j);
        }
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 39296
<?php
$n = (int)trim(fgets(STDIN));

$max = (int)ceil(sqrt($n));
$sum = 0;
for ($i=1; $i <= $max; $i++) { 
	if ($n % $i === 0) {
		$m = (int)($n/$i)-1;
		// echo $i . ': ' . $m . PHP_EOL;
		if ($m > 0 && (int)($n/$m) === $n%$m) {
			$sum += $m;
		}
	}
}
echo $sum;

Measured memory_bytes: 4856
let counting_sort a b k =
  let c = Array.make (k + 1) 0 in
  Array.iter (fun e -> c.(e) <- c.(e) + 1) a;
  Array.iteri (fun i _ -> if i <> 0 then c.(i) <- c.(i) + c.(i-1)) c;
  for i = Array.length a - 1 downto 0 do
    b.(c.( a.(i) ) - 1) <- a.(i);
    c.( a.(i) ) <- c.( a.(i) ) - 1;
  done

let () =
  let n = read_int () in
  let a = Array.init n (fun _ -> Scanf.scanf "%d " (fun e -> e)) in
  let b = Array.make n 0 in
  counting_sort a b 10000;
  print_int b.(0);
  for i = 1 to n - 1 do
    print_string " ";
    print_int b.(i);
  done;
  print_newline ()

Measured memory_bytes: 36196
#include <bits/stdc++.h>
const char nl = '\n';
using namespace std;
typedef long long ll;
typedef long double ld;
typedef complex<ld> pt;
const int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const int N = 3010;

int n;
int a[N];
ll dp[N][N];

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int sz = 0; sz < n; sz++) {
    for (int l = 0; l+sz < n; l++) {
      int r = l + sz;
      dp[l][r] = max(-dp[l+1][r] + a[l], -dp[l][r-1] + a[r]);
    }
  }
  cout << dp[0][n-1] << nl;
  return 0;
}


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

int main() {
	int A, B;
	cin >> A >> B;
	if (0 < A && A < 10) {
		if (0 < B && B < 10) {
			cout << A * B << endl;
		}
		else {
			cout << -1 << endl;
		}
	}
	else {
		cout << -1 << endl;
	}
}

Measured memory_bytes: 256
while True:
    record=input()
    if record=="0":
        break
    a=record.count('A')
    b=record.count('B')
    if record[0]=='A':
        a-=1
    elif record[0]=='B':
        b-=1
    if a>b:
        a+=1
    else:
        b+=1
    print(f'{a} {b}')


Measured memory_bytes: 5564
#include "iostream"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
#define lp(n) for (int i = 0; i < n; i++)
#define lop(n,i) for (int i = 0; i < n; i++)
#define INT_MAX 2147483647
#define LLINT_MAX 9223372036854775807
#define mod 1000000007
#define ll long long int
using namespace std;

int main() {
	string s;
	cin >> s;
	bool a[4];
	lp(4)
		a[i] = false;
	lp(s.size())
		if (s[i] == 'N')a[0] = true;
		else if (s[i] == 'S')a[1] = true;
		else if (s[i] == 'E')a[2] = true;
		else a[3] = true;
		if (a[0] == a[1] && a[2] == a[3])cout << "Yes" << endl;
		else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
typedef struct{
double x;
double y;
}xy;

void kock(int n,xy p1,xy p2){
  xy s,u,t;
  double theta=M_PI*60/180;
  if(n==0)return;
  s.x=(2*p1.x+p2.x)/3;
  s.y=(2*p1.y+p2.y)/3;
  t.x=(p1.x+2*p2.x)/3;
  t.y=(p1.y+2*p2.y)/3;
  u.x=(t.x-s.x)*cos(theta)-(t.y-s.y)*sin(theta)+s.x;
  u.y=(t.x-s.x)*sin(theta)+(t.y-s.y)*cos(theta)+s.y;

  kock(n-1,p1,s);
  printf("%f %f\n",s.x,s.y);
  kock(n-1,s,u);
  printf("%f %f\n",u.x,u.y);
  kock(n-1,u,t);
  printf("%f %f\n",t.x,t.y);
  kock(n-1,t,p2);
}

int main(){
  int n;
  xy a,b;
  a.x=0;
  a.y=0;
  b.x=100;
  b.y=0;
  scanf("%d",&n);
  printf("%f %f\n",a.x,a.y);
  kock(n,a,b);
  printf("%f %f\n",b.x,b.y);
  return 0;
}



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

int X;

int main() {
    cin >> X;
    if (X >= 400 && X <= 599) cout << 8 << endl;
    else if (X >= 600 && X <= 799) cout << 7 << endl;
    else if (X >= 800 && X <= 999) cout << 6 << endl;
    else if (X >= 1000 && X <= 1199) cout << 5 << endl;
    else if (X >= 1200 && X <= 1399) cout << 4 << endl;
    else if (X >= 1400 && X <= 1599) cout << 3 << endl;
    else if (X >= 1600 && X <= 1799) cout << 2 << endl;
    else cout << 1 << endl;
    return 0;
}


Measured memory_bytes: 3632
s = list(map(int, input().split())) 
result = []
month = s[0]

m = list(range(4,month + 1))

day= s[1]
count = 0

for i in range(2,day + 1):
    d1 = i % 10
    d2 = i//10
    if (d1 >= 2) and (d2 >=2):
        if d1 * d2 in m:
            count +=1
print(count)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int>list(N);
  for(int i=0; i<N; i++){
    cin >> list[i];   
  }
  vector<int>ans(N);
  
  for(int i=0; i<N; i++){
    ans[list[i]-1]=i+1;
  }
  
  for(int i=0; i<N; i++){
    cout << ans[i] << ' ';
  }
  cout << endl;

}

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

const double PI=acos(-1.0);

int main() {
    int n;
    cin >> n;
    int a[2][n];
    rep(i, 2) rep(j, n) cin >> a[i][j];

    int ans = 0;
    rep(i, n) {
        int tmp = 0;
        bool under = false;
        rep(j, n + 1) {
            if(j <= i && !under) {
                tmp += a[0][j];
            }
            else if(!under) {
                tmp += a[1][j - 1];
                under = true;
            } else {
                tmp += a[1][j - 1];
            }
        }
        ans = max(ans, tmp);
    }

    cout << ans << 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;
using ll = long long;
using P = pair<int,int>;

const int MX = 100001;

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

  int ans = 0;

  rep(i,a+1){
    if(i*500>x) break;

    rep(j,b+1){
      if(i*500+j*100>x) break;

      rep(k,c+1){
        if(i*500+j*100+k*50==x) ans++;
      }

    }

  }

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

Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll in()
{
	ll re=0,f=1;char x=getchar();
	while(x<'0'||x>'9'){if(x=='-')f=-1;x=getchar();}
	while(x>='0'&&x<='9')re=re*10+x-48,x=getchar();
	return re*f;
}
void out(ll x)
{
	if(x<0)putchar('-'),x=-x;
	if(!x){putchar('0');return;}
	char z[21],ct=0;
	while(x){z[++ct]=x%10+48,x/=10;}
	while(ct){putchar(z[ct]);--ct;}
}
ll n,q,a[100010],b[100010],p;
ll s[100010],tag[100010];
int _find(ll x)
{
	int l=1,r=p,mid,pos=0;
	while(l<=r)
	{
		mid=l+r>>1;
		if(b[mid]<x)pos=mid,l=mid+1;
		else r=mid-1;
	}
	return pos;
}
void solve(ll len,ll t)
{
	int k=_find(len);
	if(k==0)
	{
		s[1]+=t;s[len+1]-=t;
		return;
	}
	ll ti=len/b[k],lft=len%b[k];
	tag[k]+=t*ti;
	solve(lft,t);
}
int main()
{
	a[0]=n=in();q=in();
	for(int i=1;i<=q;++i)a[i]=in();
	ll cur=2e18;for(int i=q;~i;--i)if(a[i]<cur)cur=a[i],b[++p]=a[i];
	reverse(b+1,b+p+1);tag[p]=1;
	for(int i=p;i;--i)solve(b[i],tag[i]);
	for(int i=1;i<=n;++i)s[i]+=s[i-1],out(s[i]),putchar(10);
}

Measured memory_bytes: 4864
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	n, _ := strconv.Atoi(sc.Text())
	return n
}

func main() {
	sc.Split(bufio.ScanWords)
	a := make([]int, 5)
	for i := range a {
		a[i] = getInt()
	}

	k := getInt()

	ans := 0
	for i := 1; i < 5; i++ {
		for j := 0; j < i; j++ {
			if a[i]-a[j] > k {
				ans++
				fmt.Println(":(")
				break
			}
		}
		if ans != 0 {
			break
		}
	}

	if ans == 0 {
		fmt.Println("Yay!")
	}
}


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


char s[500011];

int nxt[26][500011];
int nxt0[500011];
int nxt2[21][500011];


int n;
int q;


int main()
{
    int i,j,k;
    int l,r;
    
    scanf("%s",s);
    n=strlen(s);
    scanf("%d",&q);
    
    memset(nxt,-1,sizeof(nxt));
    memset(nxt0,-1,sizeof(nxt0));
    
    
    for(i=n-1;i>=0;i--)
    {
        int now=s[i]-'a';
        
        nxt[now][i]=i+1;
        
        for(j=now+1;j<26;j++)
        {
            if(nxt[j-1][i]!=-1)
            {
                nxt[j][i]=nxt[j-1][nxt[j-1][i]];
            }
        }
        
        if(nxt[25][i]!=-1)
        {
            nxt0[i]=nxt[25][nxt[25][i]];
        }
        
        if(nxt0[i]!=-1)
        {
            for(j=0;j<now;j++)
            {
                nxt[j][i]=nxt[j][nxt0[i]];
            }
        }
    }
    memset(nxt2,-1,sizeof(nxt2));
    for(i=0;i<n;i++)
    {
         nxt2[0][i]=nxt0[i];
    }
    
    
    for(i=1;i<=20;i++)
    {
        for(j=0;j<n;j++)
        {
            if(nxt2[i-1][j]==-1)
            {
                nxt2[i][j]=-1;
            }
            else
            {
                nxt2[i][j]=nxt2[i-1][nxt2[i-1][j]];
            }
        }
    }
    
    
    /*
    for(i=0;i<n;i++)
    {
        for(j=0;j<10;j++)
        {
            cout<<nxt2[j][i]<<' ';
        }
        cout<<endl;
    }
    */
    /*
    for(i=0;i<n;i++)
    {
        cout<<nxt0[i]<<' ';
    }
    cout<<"!!!"<<endl;
    */
    
    for(i=1;i<=q;i++)
    {
        scanf("%d %d",&l,&r);
        l--;
        //cout<<l<<endl;
        int now=l;
        for(j=20;j>=0;j--)
        {
            if(nxt2[j][now]!=-1 && nxt2[j][now]<=r)
            {
                now=nxt2[j][now];
            }
            //cout<<now<<endl;
        }
        
        if(now==r)
        {
            printf("Yes\n");
        }
        else
        {
            printf("No\n");
        }
    }
    
    
    return 0;
} 


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

int main()
{
    int a;
    int debt=100000;
    cin >> a;
    for (int i=0; i<a; i++)
    {
	debt+=debt/20;
	debt=(debt+999)/1000*1000;
    }
    cout << debt << endl;
    return 0;
}

Measured memory_bytes: 0
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

using namespace std;

typedef long long ll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vec) {
    os << "[ ";
    REP(i, vec.size()) {
        os << vec[i] << " ";
    }
    os << "]";

    return os;
}

ll pow_mod(ll a, ll p) {
    ll res = 1;
    while(p) {
        if (p & 1) res = (res * a) % MOD;
        a = (a * a) % MOD;
        p >>= 1;
    }

    return res;
}


ll mod_inv(ll a, ll m) {
    ll b = m, u = 0, v = 1;
    while(a) {
        ll t = b / a;
        swap(b -= t * a, a);
        swap(u -= t * v, v);
    }

    return (u % m + m) % m;
}

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


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

    int M = 55555 + 1;
    int S[M];
    REP(i, M) S[i] = i;
    S[0] = -1; S[1] = -1;
    REP(i, M) {
        if (S[i] != i) continue;

        for (int j=i+i; j < M; j+=i){
            S[j] = i;
        }
    }

    vector<int> C[5];

    REP(i, M) {
        if (S[i] != i) continue;

        int mod = S[i] % 5;
        C[mod].pb(S[i]);
    }

    REP(i, N) {
        cout << C[1][i] << " ";
    }
    cout << endl;

}


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

using namespace std;

#define ALL(x) x.begin(), x.end()
#define RALL(x) x.rbegin(), x.rend()
#define MP make_pair
#define PB push_back
#define X first
#define Y second

typedef long long int lld;
typedef pair<int, int> pii;
typedef pair<lld, lld> pll;

bool isPrime(lld k) {
    if (k == 1)
        return false;

    for (lld i = 2; i * i <= k; i++) {
        if (k % i == 0)
            return false;
    }
    return true;
}

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

    if (n == 1) {
        cout << 0 << '\n';
        return 0;
    }

    int ans = 0;

    vector<lld> v;

    map<lld, int> mp;

    v.push_back(1);
    for (int i = 2; i <= 100; i++) {
        v.push_back(v.back() + i);
    }

    for (lld i = 2; i * i <= n; i++) {
        while (n % i == 0) {
            mp[i]++;
            if (isPrime(n / i) && i != n / i) {
                mp[n / i]++;
            }
            n /= i;
        }
    }

    for (auto &p : mp) {
        ans += upper_bound(ALL(v), p.second) - v.begin();
    }

    cout << max(1, ans) << '\n';

    return 0;
}

// g++ sol.cpp -o sol.out -Wall -Wextra -Wshadow -fsanitize=undefined -std=c++17

Measured memory_bytes: 3660
#include <stdio.h>
#include <stdint.h>
#include <math.h>
#define MIN(x, y) ((x)<(y)?(x):(y))
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define rep(i,n) FOR(i,0,n)

int main() {
    int n;
    scanf("%d", &n);
    
    int minus = 0, zero = 0;
    int64_t tot = 0, mini = (1LL << 62);
    rep(i, n) {
        int64_t a;
        scanf("%ld", &a); 
        minus += a < 0;
        tot += abs(a);
        zero |= a == 0;
        mini = MIN(mini, abs(a));
    }
    
    if (minus % 2 == 0 || zero)
        printf("%ld", tot);
    else
        printf("%ld", tot - 2 * mini);
}

Measured memory_bytes: 256
#include <stdio.h>

int cube(int,int);

int main(){
   int x,a;
   scanf("%d",&x);
   a = cube(x,3);
   printf("%d\n",a);
   return 0;
}

int cube(int x,int y){
   int i;
   int result =1;
   for(i = 1;i <= y;i++){
      result = result*x;
   }
   return result;
}


Measured memory_bytes: 2032
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<math.h>
#include<map>
#include<functional>
#include<queue>
#include<stack>
#include<string.h>
#define ll long long int
#define MOD 1000000007LL
using namespace std;
int main(){
    int h,w,n;
    cin>>h>>w>>n;
    int a[10001]={};
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    int c[114][114]={};
    int ir=1;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            c[i][j]=ir;
            a[ir-1]--;
            if(a[ir-1]==0){
                ir++;
            }
        }
    }
    for(int i=0;i<h;i++){
        if(i%2==0){
            for(int j=0;j<w;j++){
                cout<<c[i][j];
                if(j==w-1){
                    cout<<endl;
                }else{
                    cout<<" ";
                }
            }
        }else{
            for(int j=w-1;j>=0;j--){
                cout<<c[i][j];
                if(j==0){
                    cout<<endl;
                }else{
                    cout<<" ";
                }
            }
        }
    }
}   





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

using ll=long long;
const ll MOD=1000000007;

int main() {
  int n;
  cin >> n;
  vector<string> p(n);
  for(int i=0;i<n;i++){
    cin >> p[i];
  }
  sort(p.begin(),p.end());
  vector<int> vec(n,0);
  int m=0;
  for(int i=0;i<n-1;i++){
    if(p[i]==p[i+1])
      vec[m]++;
    else
      m=i+1;
  }
  int MAX=0;
  for(int i=0;i<n;i++){
    MAX=max(MAX,vec[i]);
  }
  for(int i=0;i<n;i++){
    if(vec[i]==MAX){
      cout << p[i] << endl;
    }
  }
}

Measured memory_bytes: 16384
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
    ll n;
    cin>>n;
    vector<ll>a,b;
    for(ll i=0;i<n;i++){
        ll t1,t2;
        cin>>t1>>t2;
        a.push_back(t1);
        b.push_back(t2);
    }
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());


    ll x,y,ans;
    if(n%2!=0){
        x = a[n/2];
        y=b[n/2];
       // cout<<x<<y<<endl;
        ans = abs(x-y)+1;
    }
    else{
        x = a[n/2]+a[(n/2)-1];
        y = b[n/2]+b[(n/2)-1];
        ans = abs(x-y)+1;

         //cout<<x<<y<<endl;

    }

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


Measured memory_bytes: 6580
import scala.util.control.Breaks

object Main extends App {
  val n = scala.io.StdIn.readInt()
  var xyVectorVector = Vector.empty[Vector[Vector[Int]]]
  (1 to n).foreach {_ =>
    val a = scala.io.StdIn.readInt()
    var xyVector = Vector.empty[Vector[Int]]
    (1 to a).foreach {_ =>
      val xyInput = scala.io.StdIn.readLine()
      val xy = xyInput.split(" ").map(_.toInt).toVector
      xyVector :+= xy
    }
    xyVectorVector :+= xyVector
  }

  def check(userList: Vector[Int]): Boolean = {
    var result = true
    val b = new Breaks
    b.breakable {
      userList.zipWithIndex.foreach { u =>
        if (u._1 == 1) {
          val xyVector = xyVectorVector(u._2)
          xyVector.foreach { xy =>
            if (userList(xy(0) - 1) != xy(1)) {
              result = false
              b.break()
            }
          }
        }
      }
    }
    result
  }
  val b1 = new Breaks
  var result = Vector.empty[Int]
  b1.breakable {
    (0 to n).foreach { fuseizitsuNum =>
      var userList = Vector.empty[Int]
      (0 to n - 1).foreach { _ =>
        if (userList.filter(_ == 0).size < fuseizitsuNum) {
          userList :+= 0
        } else {
          userList :+= 1
        }
      }
      val b2 = new Breaks

      b2.breakable {
        userList.permutations.foreach { u =>
          if (check(u)) {
            result = u
            b2.break()
          }
        }
      }
      if(result.nonEmpty) {
        b1.break()
      }
    }
  }
  println(result.filter(_ == 1).size)

}

Measured memory_bytes: 43596
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define fori(a) for(auto i : a )
#define all(a) begin(a), end(a)
#define set(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
#define pi 3.14159
#define ll long long
#define ull unsigned long long
#define pb push_back
#define PF push_front //deque
#define mp make_pair
#define pq priority_queue
#define mod 1000000007
#define f first
#define s second
#define pii pair< int, int >
#define vi vector<int>
#define vpii vector<pii>
#define debug(v) for(auto i:v) cout<<i<<" ";
#define tc int t; cin >> t; while(t--)

using namespace std;
string repeat(string s, int n) {
    string s1 = "";
    for (int i=0; i<n;i++)
        s1+=s;
    return s1;
}
string getString(char x) {
    string s(1, x);
    return s;
}

void optimizeIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
int gcd(int a, int b){
    if (a == 0)  return b;
    return gcd(b % a, a);
}
void  solve(){
  int a,b;
  cin>>a>>b;
  if(a%2 && b%2) cout<<"Yes\n";
  else cout<<"No\n";
}
int main(){
    optimizeIO();
    // tc
    { solve();
    }
}


Measured memory_bytes: 3656
#include <stdio.h>
#include <string.h>

int main(void){
	char s[100];
	int len;
	int len_1,len_2,len_3;
	int flag = 0;
	int k;

	scanf("%s", s);
	len = strlen(s);
	//-- 1
	len_1 = len/2;
	for (k = 0; k < len_1; k++) {
		if (s[k] != s[len-1-k]) { flag = 1;  break;}
	}
	//-- 2
	len_2 = (len-1)/2;
	for (k = 0; k < (len_2/2); k++) {
		if (s[k] != s[len_2-1-k]) { flag = 1;  break;}
	}
	//-- 3
	len_3 = (len+3)/2;
	for (k = len_3-1; k < len_3-1+(len/2); k++) {
		if (s[k] != s[len-1-k]) { flag = 1;  break;}
	}

	//-- output
	if (flag == 0) { puts("Yes"); } else { puts("No"); }

	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k,x,y;
    cin>>n>>k>>x>>y;
    if(k>=n)
        cout<<(n*x)<<endl;
    else
    {
        cout<<(k*x + (n-k)*y)<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline

MAXN = 1005
MAXV = MAXN*(MAXN-1)//2
to = [[] for _ in range(MAXV)] # 頂点間の辺の情報
id = [[[] for _ in range(MAXN)] for _ in range(MAXN)] # 試合のid=DAGの頂点番号
def toId(i,j): # 選手idから試合idを返す関数
    if i > j: # i,jが逆になっても試合idは同じ
        i,j = j,i
    return id[i][j]

visited = [False]*MAXV
calculated = [False]*MAXV
dp = [1]*MAXV # Vからスタートしたときの最長経路。頂点の個数ベースで経路の長さを数えるので、初期値は1

def dfs(v):
    if visited[v]:
        if not calculated[v]:
            return -1 # 計算が終わっていない頂点を2度訪れるのはループがあるということ
        return dp[v]
    visited[v] = True
    for u in to[v]: # 全ての辺をなめる
        res = dfs(u)
        if res == -1: return -1 # ループがあれば-1を返す
        dp[v] = max(dp[v], res+1)
    calculated[v] = True
    return dp[v]

def main():
    n = int(input())
    a = [[int(i) for i in readline().split()] for _ in range(n)]
    for i in range(n):
        for j in range(n-1):
            a[i][j] -= 1 # 選手idを0始まりに変換
    V = 0
    for i in range(n):
        for j in range(n):
            if i < j:
                id[i][j] = V
                V += 1 # 0から順に各試合にidを割り振る
    for i in range(n):
        for j in range(n-1):
            a[i][j] = toId(i,a[i][j]) # 選手idを試合id(頂点番号)に置き換える
        for j in range(n-2): # 頂点間の依存関係はn-2個
            to[a[i][j+1]].append(a[i][j])
    ans = 0
    for i in range(V):
        res = dfs(i)
        if res == -1:
            print('-1') # ループがあれば-1を返す（問題文の指示）
            return
        ans = max(ans, res)
    print(ans)
    return

if __name__ == '__main__':
    main()

Measured memory_bytes: 208368
// clang-format off
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(ll i=1, i##_len=(n); i<=i##_len; ++i)
#define rrep(i,n) for(ll i=n-1; i>=0; --i)
#define rrep1(i,n) for(ll i=n; i>0; --i)
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort(all(x))
#define SORT_DESC(x) sort(all(x), greater<>())
#define pb push_back
#define mp make_pair
#define coutl cout<<fixed<<setprecision(10)
#define ANS(ans) cout<<ans<<endl;
#define INF 1e9;
#define LINF 1e18;
template<class T>bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a, const T &b){if (b<a){a=b;return 1;}return 0;}
// clang-format on

void solve(long long N, std::vector<long long> a) {
  ll m = a[distance(a.begin(), max_element(all(a)))];
  vector<ll> nums(m + 2);
  set<ll> keys;
  ll ans = 0;
  for (ll i : a) {
    keys.insert(i);
    nums[i]++;
  }
  for (ll i : keys) {
    ll n = nums[i] + nums[i + 1];
    if (i >= 1)
      n += nums[i - 1];
    ans = max(n, ans);
  }
  ANS(ans);
}

// clang-format off
int main() {
  long long N;
  scanf("%lld",&N);
  std::vector<long long> a(N);
  for(int i = 0 ; i < N ; i++){
    scanf("%lld",&a[i]);
  }
  solve(N, std::move(a));
  return 0;
}


Measured memory_bytes: 4736
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
#include <cmath>
#include <stack>

using namespace std;
using ll = long long int;

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}

void solve(long long N, std::vector<long long> a, std::vector<long long> b, std::vector<long long> c, std::vector<long long> d){
  vector<pair<ll, ll>> rd;
  vector<pair<ll, ll>> bl;
  ll ans = 0;
  set<pair<ll,ll>> s;
  for(ll i=0; i<N; i++) {
    rd.push_back(make_pair(a[i], b[i]));
    bl.push_back(make_pair(c[i], d[i]));
  }
  sort(rd.begin(), rd.end());
  sort(bl.begin(), bl.end());
  for(ll i=0; i<N; i++) {
    auto bp = bl[i];
    ll m = -1;
    pair<ll,ll> p;
    for(ll j=0; j<N; j++) {
      auto rp = rd[j];
      if(bp.first <= rp.first) break;
      if(bp.second <= rp.second) continue;
      if(s.find(rp)!=s.end()) continue;
      if(rp.second > m) {
	p = rp;	
	m = rp.second;
      }
    }
    if(m!=-1) {
      s.insert(p);
      ans++;
    }
  }
  std::cout << ans << std::endl;
}

int main(){
  long long N;
  scanf("%lld",&N);
  std::vector<long long> a(N);
  std::vector<long long> b(N);
  for(int i = 0 ; i < N ; i++){
    scanf("%lld",&a[i]);
    scanf("%lld",&b[i]);
  }
  std::vector<long long> c(N);
  std::vector<long long> d(N);
  for(int i = 0 ; i < N ; i++){
    scanf("%lld",&c[i]);
    scanf("%lld",&d[i]);
  }
  solve(N, std::move(a), std::move(b), std::move(c), std::move(d));
  return 0;
}



Measured memory_bytes: 256
def recursion(queue, data, res)
  if data.size == 0
    res << queue.inject(0, :+)
  else
    d = data.slice(1..data.size)
    res = recursion(queue, d, res)
    res = recursion(queue + [data[0]], d, res)
  end
end

# main
n = gets.to_i
ary = gets.split(' ').map(&:to_i)
q = gets.to_i
targets = gets.split(' ').map(&:to_i)
res = recursion([], ary, [])
targets.each{ |t|
  if res.include?(t)
    puts 'yes'
  else
    puts 'no'
  end
}

Measured memory_bytes: 17188
import java.util.Scanner;
public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		long n = sc.nextLong();
		long m = sc.nextLong();
		
		long ans = 0;
		
		if(n * 2 < m) {
			ans += n;
			m = m - 2 * n;
			ans += m / 4;
		}
		else {
			ans += m/2;
		}
		System.out.println(ans);
	}

}


Measured memory_bytes: 21972
#include <iostream>
#include <cstdio>

using namespace std;

int read()
{
	int x;
	scanf("%d", &x);
	return x;
}

string s;

int main()
{
	cin >> s;
	int x = 0, y = 0;
	for(int i = 0; i <= s.size() - 1; i ++)
	{
		if(i % 2 == 0)
		{
			if(s[i] != '0')
			{
				x ++;
			}
		}
		else if(i % 2 != 0)
		{
			if(s[i] != '1')
			{
				x ++;
			}		
		}
	}
	for(int i = 0; i <= s.size() - 1; i ++)
	{
		if(i % 2 == 0)
		{
			if(s[i] != '1')
			{
				y ++;
			}
		}
		else
		{
			if(s[i] != '0')
			{
				y ++;
			}		
		}
	}
	if(x > y)cout << y << endl;
	else cout << x << endl;
	return 0;
}
	

Measured memory_bytes: 512
#include <iostream>
#define P_SIZE 10
using namespace std;

int main() {
  int ink1[5][2] = {{0,0},{1,0},{0,1},{-1,0},{0,-1}};
  int ink2[9][2] = {{0,0},{1,0},{0,1},{-1,0},{0,-1},
		    {1,1},{-1,1},{-1,-1},{1,-1}};
  int ink3[13][2] =  {{0,0},{1,0},{0,1},{-1,0},{0,-1},
		      {1,1},{-1,1},{-1,-1},{1,-1},
		      {2,0},{0,2},{-2,0},{0,-2}};

  static int ink_num[3] = {5, 9, 13};
  
  int map[P_SIZE][P_SIZE];
  for(int i = 0; i < P_SIZE; i++) {
    for(int j = 0; j < P_SIZE; j++) {
      map[i][j] = 0;
    }
  }

  int x, y, size;
  while(scanf("%d,%d,%d", &x, &y, &size) != EOF) {
    for(int i = 0; i < ink_num[size-1]; i++) {
      int nx, ny;
      switch(size) {
      case 1:
	nx = x + ink1[i][0];
	ny = y + ink1[i][1];
	break;
      case 2:
	nx = x + ink2[i][0];
	ny = y + ink2[i][1];
	break;
      case 3:
	nx = x + ink3[i][0];
	ny = y + ink3[i][1];
	break;
      }
      if(nx < 0 || nx >= P_SIZE || ny < 0 || ny >= P_SIZE) continue;

      map[ny][nx] += 1;
    }
  }

    int inkMax = 0;
    int space = 0;
    for(int i = 0; i < P_SIZE; i++) {
      for(int j = 0; j < P_SIZE; j++) {
	if(map[i][j] == 0) space++;
	if(map[i][j] > inkMax) inkMax = map[i][j];
      }
    }
    cout << space << endl;
    cout << inkMax << endl;
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define N 101
using namespace std;
int A[N];

int mem[N][N],used[N][N];
int dfs(int l,int r){
  if(l == r) return 0;
  if(r - l == 1) return A[l]*A[r]*A[r+1];
  if(used[l][r]++) return mem[l][r];

  int res = 1e9;  
  for(int i=l;i<r;i++){
    int a = dfs(l,i);
    int b = dfs(i+1,r);
    int c = A[l] * A[i+1] * A[r+1];
    res = min(res,a + b + c);
  }
  return mem[l][r] = res;
}

int main(){
  
  int n;
  cin>>n;
  for(int i=0,cnt=0;i<n;i++){
    int a,b;
    cin>>a>>b;
    if(i == 0) A[cnt++] = a;
    A[cnt++] = b;
  }

  cout<<dfs(0,n-1)<<endl;


  return 0;
}

Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define ll         long long
#define fl(i,n)    for(i=0;i<n;i++)
#define fld(i,a,b) for(i=a;i>b;i--)
#define fli(i,a,n) for(i=a;i<n;i++)
#define pb         push_back
#define mp         make_pair
#define F          first 
#define S          second
#define mod        998244353
#define all(x)     x.begin(),x.end()    
#define speedup    ios_base::sync_with_stdio(false),cin.tie(0)
using namespace std;
void comp() {
	ll i,j,k,n,m;
	cin>>k>>n;
	vector<ll>v1;
	map<ll,ll>m1;
	fl(i,n) {
		cin>>j;
		m1[j]=1;
	}
	fli(i,0,1000) {
		if(m1[k-i]==0) {
			cout<<k-i<<"\n";
			return;
		}
		if(m1[k+i]==0) {
			cout<<k+i<<"\n";
			return;
		}
	}
}

int main() {
    speedup;
    ll i=0,t;
    t=1;
    //cin>>t;
    while(t--) {
        comp();
    }
    return 0;
}

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

int main(){
    int N;
    cin >> N;
    vector<tuple<string, int , int>> table(N);
    for(int i =0; i < N; i++){
        string name;
        int score;
        cin >> name >> score;
        get<0>(table.at(i)) = name;
        get<1>(table.at(i)) = - score;
        get<2>(table.at(i)) = i + 1;
    }  
    sort(table.begin(), table.end());
    for(int i =0; i < N; i++){
        cout << get<2>(table.at(i)) << endl;
    }      
}

Measured memory_bytes: 256
def main():
  nm = list(map(int,input().split()))
  h = list(map(int,input().split()))
  hairetu = [0]*(nm[0]+1)
  #print(hairetu)
  for m in range(0,nm[1],1):
    ab = list(map(int,input().split()))
    if(h[ab[0]-1]>h[ab[1]-1]):
      #print(ab[1])
      hairetu[ab[1]] = -1
    elif(h[ab[0]-1]==h[ab[1]-1]): 
      hairetu[ab[1]] = -1
      hairetu[ab[0]] = -1
    else:hairetu[ab[0]] = -1
  sum = 0
  for x in range(1,nm[0]+1,1):
    if(hairetu[x]==0):sum = sum + 1
  
  #print(hairetu)
  print(sum)
  
main()

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


int main() {
  ll A, B, C, D, E;
  cin >> A >> B >> C >> D >> E;

  int ans = 0;
  if (A == 0) ans = 1;
  else if (B == 0) ans = 2;
  else if (C == 0) ans = 3;
  else if (D == 0) ans = 4;
  else if (E == 0) ans = 5;
  
  cout << ans << endl;
  return 0;
}


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

#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define LL long long
#define pii pair <int,int>
#define fi first
#define se second
#define pb push_back
#define mpr make_pair

using namespace std;

const LL MOD=1e9+7;

LL k,fac[3000010],pw[3000010],pw2[3000010],ans;
string s;

LL fastpow(LL x,LL a)
{
	LL res=x,ret=1;
	while(a>0)
	{
		if((a&1)==1) ret=ret*res%MOD;
		a>>=1;
		res=res*res%MOD;
	}
	return ret;
}

LL C(LL n,LL m)
{
	return fac[n]*fastpow(fac[m],MOD-2)%MOD*fastpow(fac[n-m],MOD-2)%MOD;
}

int main()
{
	fac[0]=pw[0]=pw2[0]=1;
	repn(i,3000005) fac[i]=fac[i-1]*i%MOD,pw[i]=pw[i-1]*26%MOD,pw2[i]=pw2[i-1]*25%MOD;
	cin>>k>>s;
	rep(i,k+1)
	{
		LL tmp=C(i+s.size()-1,s.size()-1);
		//cout<<tmp<<' '<<pw[k-i]<<endl;
		ans=(ans+tmp*pw[k-i]%MOD*pw2[i])%MOD;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 75596
a,b,c= input().split('/')
x,y,z=(int(a),int(b),int(c))
ans_list = [2019, 4, 30]
if ans_list[0] > x:
    print('Heisei')
elif ans_list[0] == 2019:
    if y >= 5:
        print('TBD')
    else:
        print('Heisei')

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n, k, c;
  string s;
  cin >> n >> k >> c >> s;
  
  vector<int> x(n), y(n);
  int now = 0, count = 1;
  while (true) {
    if (count > k) break;
    if (s.at(now) == 'o') {
      x.at(now) = count;
      count++;
      now += c + 1;
    }
    else {
      now++;
    }
  }
  
  now = n - 1;
  count = k;
  while (true) {
    if (count <= 0) break;
    if (s.at(now) == 'o') {
      y.at(now) = count;
      count--;
      now -= c + 1;
    }
    else {
      now--;
    }
  }
  
  bool flag = false;
  for (int i = 0; i < n; i++) {
    if (x.at(i) == y.at(i) && x.at(i) != 0) {
      cout << i + 1 << '\n';
      flag = true;
    }
  }
  
  if (!flag) cout << '\n';
}

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

int main() {
  string s;
  cin >> s;
  for(int i = 0; i < 4; i++){
    cout << s[i];
  }
  cout << " ";
  for(int i = 4; i < s.size(); i++){
    cout << s[i];
  }
  cout << endl;
  return 0;
}

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

using namespace std;

//FILE *fi=freopen("1.txt","r",stdin);

int n;
long long d[21][11],sum[21];

void init()
{
    for (int i=0;i<=9;++i)
        d[1][i]=1;
    sum[1]=9;
    for (int i=2;i<=11;++i)
    {
        for (int j=0;j<=9;++j)
        {
            for (int k=max(0,j-1);k<=min(9,j+1);++k)
                d[i][j]+=d[i-1][k];
            if (j) sum[i]+=d[i][j];
        }
    }
}

void solve(int k,int l,int st,bool ty)
{
    if (!l) return;
    if (ty)
    {
        for (int i=1;i<=9;++i)
        {
            if (k>d[l][i])
                k-=d[l][i];
            else
            {
                cout<<i;
                solve(k,l-1,i,0);
                return;
            }
        }
    }
    else
    {
        for (int i=max(0,st-1);i<=min(9,st+1);++i)
        {
            if (k>d[l][i])
                k-=d[l][i];
            else
            {
                cout<<i;
                solve(k,l-1,i,0);
                return;
            }
        }
    }
}

void process()
{
    int l=1;
    while (n>sum[l])
    {
        n-=sum[l];
        l++;
    }
    solve(n,l,1,1);
}

int main()
{
    scanf("%d",&n);
    init();
    process();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <ext/numeric>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#define oo 0x3f3f3f3f
#define OO 0x3f3f3f3f3f3f3f3f
#define popcount(n) __builtin_popcount(n)
#define popcountll(n) __builtin_popcountll(n)

using namespace std;
//using namespace __gnu_cxx;
using namespace __gnu_pbds;
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const double PI = acos(-1.0), EPS = 1e-6;
const long long inf = 2e12 + 12;
const int MAXN = 100005, MAXM = 1003, Mod = 1000000007 , MAXLog = 20;



int main() {
#ifndef ONLINE_JUDGE
//    freopen("input.txt", "rt", stdin);
//    freopen("output.txt", "w", stdout);
#endif
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0), cout.precision(9), cout << fixed;

    string s;
    cin >> s;
    bool f =false;
    for (int i = 1; i < s.size(); ++i) {
        if (s[i] == s[i - 1]) {
            f = true;
        }
    }

    if (f) {
        cout << "Bad\n";
    } else {
        cout << "Good\n";
    }


    return 0;
}

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

using namespace std;

#define NMAX 2<<15

int main(){

    int n;
    vector<int> prime;
    int hurui[NMAX+1];
    int cnt;

    for(int i=2;i<=NMAX;i++){
        hurui[i]=1;
    }
    hurui[0]=0,hurui[1]=0;

    for(int i=0;i<=NMAX;i++){
        if(hurui[i]==1){
            prime.push_back(i);
            for(int j=i*2;j<=NMAX;j+=i){
                hurui[j]=0;
            }
        }
    }

    while(1){

        cin>>n;
        if(n==0) break;

        cnt=0;
        for(int i=0;i<prime.size()&&prime[i]*2<=n;i++){
            for(int j=i;j<prime.size()&&prime[i]+prime[j]<=n;j++){
                if(prime[i]+prime[j]==n) cnt++;
            }
        }

        cout<<cnt<<endl;
    }
}

Measured memory_bytes: 1540
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define reps(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; --i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define repc2(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define inf 2e9
#define linf 9000000000000000000ll
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

class DisjointSet {
   private:
    vector<int> rank, parent;

   public:
    DisjointSet() {}
    DisjointSet(int size) {
        rank.resize(size, 0);
        parent.resize(size, 0);
        rep(i, size) { makeSet(i); }
    }

    void makeSet(int x) {
        parent[x] = x;
        rank[x] = 0;
    }

    bool same(int x, int y) { return findSet(x) == findSet(y); }

    void unite(int x, int y) { link(findSet(x), findSet(y)); }

    void link(int x, int y) {
        if (x == y) {
            return;
        }
        if (rank[x] > rank[y]) {
            parent[y] = x;
        } else {
            parent[x] = y;
            if (rank[x] == rank[y]) {
                rank[y]++;
            }
        }
    }
    int findSet(int x) {
        if (x != parent[x]) {
            parent[x] = findSet(parent[x]);
        }
        return parent[x];
    }
};
int n, q;

int main() {
    scanf("%d%d", &n, &q);
    DisjointSet ds(n);
    rep(i, q) {
        int t, u, v;
        scanf("%d%d%d", &t, &u, &v);
        if (t == 0) {
            ds.unite(u, v);
        } else {
            printf("%d\n", ds.same(u, v));
        }
    }
    return 0;
}

Measured memory_bytes: 4708
void main()
{
    long x, y, a, b, c;
    rdVals(x, y, a, b, c);
    long[] p = rdRow;
    long[] q = rdRow;
    long[] r = rdRow;

    p.sort!"a > b";
    q.sort!"a > b";
    r.sort!"a > b";

    long result = p[0..x].sum + q[0..y].sum;
    long pidx = x - 1, qidx = y - 1, ridx;
    while (true)
    {
        if (pidx >= 0 && qidx >= 0 && ridx < c)
        {
            if (p[pidx] <= q[qidx])
            {
                if (r[ridx] < p[pidx]) break;
                result += r[ridx] - p[pidx];
                ++ridx, --pidx;
            }
            else
            {
                if (r[ridx] < q[qidx]) break;
                result += r[ridx] - q[qidx];
                ++ridx, --qidx;
            }
        }
        else if (pidx >= 0 && ridx < c)
        {
            if (r[ridx] < p[pidx]) break;
            result += r[ridx] - p[pidx];
            ++ridx, --pidx;
        }
        else if (qidx >= 0 && ridx < c)
        {
            if (r[ridx] < q[qidx]) break;
            result += r[ridx] - q[qidx];
            ++ridx, --qidx;
        }
        else break;
    }

    result.writeln;
}

enum long mod = 10^^9 + 7;
enum long inf = 1L << 60;

T rdElem(T = long)()
if (!is(T == struct))
{
    return readln.chomp.to!T;
}

alias rdStr = rdElem!string;
alias rdDchar = rdElem!(dchar[]);

T rdElem(T)()
if (is(T == struct))
{
    T result;
    string[] input = rdRow!string;
    assert(T.tupleof.length == input.length);
    foreach (i, ref x; result.tupleof)
    {
        x = input[i].to!(typeof(x));
    }
    return result;
}

T[] rdRow(T = long)()
{
    return readln.split.to!(T[]);
}

T[] rdCol(T = long)(long col)
{
    return iota(col).map!(x => rdElem!T).array;
}

T[][] rdMat(T = long)(long col)
{
    return iota(col).map!(x => rdRow!T).array;
}

void rdVals(T...)(ref T data)
{
    string[] input = rdRow!string;
    assert(data.length == input.length);
    foreach (i, ref x; data)
    {
        x = input[i].to!(typeof(x));
    }
}

void wrMat(T = long)(T[][] mat)
{
    foreach (row; mat)
    {
        foreach (j, compo; row)
        {
            compo.write;
            if (j == row.length - 1) writeln;
            else " ".write;
        }
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.mathspecial;
import std.traits;
import std.container;
import std.functional;
import std.typecons;
import std.ascii;
import std.uni;
import core.bitop;

Measured memory_bytes: 12744
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n, m, d[20], dp[50001];
  fill_n( dp, 50001, 1 << 30);
  cin >> n >> m;
  for(int i = 0; i < m; i++){
    cin >> d[i];
  }
  sort( d, d + m);
 
  dp[0] = 0;
  for(int i = 0; i < n; i++){
    for(int j = 0; j < m; j++){
      if(i + d[j] > n) break;
      dp[i + d[j]] = min( dp[i + d[j]], dp[i] + 1);
    }
  }
  cout << dp[n] << endl;
}


Measured memory_bytes: 3348
a = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K = int(input())
print(a[K - 1])

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


int main() {

    string s, t;
    cin >> s >> t;
    sort(s.begin(), s.end());
    sort(t.rbegin(), t.rend());
    if (s < t) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int r, c, i, j, d, sum, s_sum;
    int sheet[100][100];
    scanf("%d%d", &r, &c);
    
    for(i = 0; i < r; i++){
        sum = 0;
        for(j = 0; j < c; j++){
            scanf("%d",&d);
            sheet[i][j] = d;
            sum += d;
            printf("%d ", d);
        }
        printf("%d\n",sum);
    }
    
    s_sum = 0;
    for(j = 0;j < c; j++){
        sum = 0;
        for(i = 0;i < r;i++){
            sum += sheet[i][j];
        }
        printf("%d ", sum);
        s_sum += sum;
    }
    printf("%d\n",s_sum);
    return 0;
}

Measured memory_bytes: 636