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

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <vector>
#include <numeric>

using namespace std;

void __print(int x) { cerr << x; }
void __print(long x) { cerr << x; }
void __print(long long x) { cerr << x; }
void __print(unsigned x) { cerr << x; }
void __print(unsigned long x) { cerr << x; }
void __print(unsigned long long x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }

template <typename T, typename V>
void __print(const pair<T, V> &x) {
    cerr << '{';
    __print(x.first);
    cerr << ',';
    __print(x.second);
    cerr << '}';
}
template <typename T>
void __print(const T &x) {
    int f = 0;
    cerr << '{';
    for (auto &i : x) cerr << (f++ ? "," : ""), __print(i);
    cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v) {
    __print(t);
    if (sizeof...(v)) cerr << ", ";
    _print(v...);
}
#ifdef LOCAL
#define debug(x...)               \
    cerr << "[" << #x << "] = ["; \
    _print(x)
#else
#define debug(x...)
#endif

#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)

typedef long long ll;

const string DIGITS = "0123456789";
const string ALPH = "abcdefghijklmnopqrstuvwxyz";


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll X, Y, Z;
    cin >> X >> Y >> Z;
    cout << Z << " " << X  << " " << Y << endl;


    return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;
public class Main
{
	public static void main(String[] args) 
	{
		Scanner in=new Scanner(System.in);
		int INF=1000001;
		for(;;)
		{
			int N=in.nextInt();//町の数
			int M=in.nextInt();//制限時間
			int L=in.nextInt();//冷凍施設の数
			int K=in.nextInt();//道路の数
			int A=in.nextInt();//スタート地点
			int H=in.nextInt();//ゴール^^
			if((N|M|L|K|A|H)==0)
				return;
			int war[][]=new int[N][N];
			int no[]=new int[N];
			for(int i=0;i<L;i++)
				no[in.nextInt()]=1;
			no[A]=no[H]=1;
			int ans=M;
			for(int i=0;i<N;i++)
				Arrays.fill(war[i], INF);
			for(int i=0;i<N;i++)
				war[i][i]=0;
			for(int i=0;i<K;i++)
			{
				int s=in.nextInt();
				int t=in.nextInt();
				int co=in.nextInt();
				war[s][t]=war[t][s]=co;
			}
			
			for (int i=0;i<N;i++)
				for(int j=0;j<N;j++)
					for(int k=0;k<N;k++)
					{
						//j->kへ行くのにiを経由した方が良いかどうか
						int c=war[j][i]+war[i][k];
						war[j][k]=Math.min(war[j][k],c);
					}
			for(int i=0;i<N;i++)
				for(int j=0;j<N;j++)
				{
					if(no[i]==0||no[j]==0||war[i][j]>M)
						war[i][j]=INF;
				}
			for (int i=0;i<N;i++)
				for(int j=0;j<N;j++)
					for(int k=0;k<N;k++)
					{
						//j->kへ行くのにiを経由した方が良いかどうか
						int c=war[j][i]+war[i][k];
						war[j][k]=Math.min(war[j][k],c);
					}
			if(war[A][H]==INF)
				System.out.println("Help!");
			else
			  System.out.println(war[A][H]+Math.max(0,war[A][H]-M));
		}
	}
}

Measured memory_bytes: 13000
#include <stdio.h>
#define MAX 10000
#define NIL -1


typedef struct{
  int p;
  int r;
  int l;
}info;

info tree[MAX];
int n;


void prewalk(int a){
  if(a==NIL)return;
  else{
    printf(" %d",a);
    prewalk(tree[a].l);
    prewalk(tree[a].r);
  }
}

void inowalk(int a){
  if(a==NIL)return ;

  inowalk(tree[a].l);
  printf(" %d",a);
  inowalk(tree[a].r);
  }


void postwalk(int a){
  if(a==NIL)return;

  postwalk(tree[a].l);
  postwalk(tree[a].r);
  printf(" %d",a);
}

int main(){
  int v,r,l,i,root;
  scanf("%d",&n);
  for(i=0;i<n;i++) tree[i].p = NIL;

  for(i=0;i<n;i++){
    scanf("%d %d %d",&v,&l,&r);
    tree[v].l = l;
    tree[v].r = r;

    if(l!=NIL)tree[l].p = v;
    if(r!=NIL)tree[r].p = v;
  }

  for(i=0;i<n;i++)if(tree[i].p==NIL) root = i;

  printf("Preorder\n");
  prewalk(root);
  printf("\n");
  printf("Inorder\n");
  inowalk(root);
  printf("\n");
  printf("Postorder\n");
  postwalk(root);
  printf("\n");
  return 0;
}




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

int main(){
  while(1){
    int a,b; char o;
    cin >> a >> o >> b;
    if(o == '?') break;
    if(o == '+'){
      cout << a+b << endl;
    }else if(o == '-'){
      cout << a-b << endl;
    }else if(o == '*'){
      cout << a*b << endl;
    }else{
      cout << a/b << endl;
    }
  }
  return 0;
}



Measured memory_bytes: 3080
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define pp pair<ll,ll>
#define vi vector<pair<pp,pp> >
#define pq_min priority_queue<ll,vector<ll>,greater<ll>>
#define pq_max priority_queue<ll>
#define forx(i,a,b) for(ll i=0;i<a;i++)
#define precision(x,d) cout<<fixed<<setprecision(d)<<x
#define fill(a,b) memset((a),(b),sizeof((a)))
#define ld long double
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
typedef pair<pp,pp> ppll;
const ll mod=1e9 + 7;

int main()
{
	fast;
    ll n;
    cin>>n;
    vector<string> s(n);
    ll a[n];
    for(ll i=0;i<n;i++)
    {
    	cin>>s[i];
    	cin>>a[i];
	}
	string x;
	cin>>x;
	ll f=0,sum=0;
	for(ll i=0;i<n;i++)
	{
		if(f==1)
		{
			sum+=a[i];
		}
		if(s[i]==x)
		{
			f=1;
		}
	}
	cout<<sum;	
}


Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
def main():
    s = readline().rstrip().decode()
    n = len(s)
    #print(s)
    P = int(1e9)+7
    dp = [[0, 0] for _ in range(n)]
    #dp[i][j]:=Lのi桁目まで見てLと一致する/未満である2数の組の数
    dp[0][0] = 1 #未満となる組は(0, 0)の1通り
    dp[0][1] = 2 #一致する組は(0, 1)と (1, 0)の2通り

    for i in range(1, n):
        if s[i] == '1':
            #dp[i-1][1]からの遷移は(0, 0)のみ。dp[i-1][0]からの遷移は(0, 0), (0, 1), (1, 0)
            dp[i][0] += dp[i-1][1] + dp[i-1][0] * 3 
            #i桁目が1となる組は(1, 0)と(0, 1)の2通り
            dp[i][1] += dp[i-1][1] * 2

            dp[i][0] %= P
            dp[i][1] %= P
        else:
            #(0, 0), (1, 0), (0, 1)を選ぶ
            dp[i][0] += dp[i-1][0] * 3 
            #(0, 0)を選ぶしかない
            dp[i][1] += dp[i-1][1]  

            dp[i][0] %= P
            dp[i][1] %= P

    print((dp[n-1][0]+dp[n-1][1])%P)
if __name__ == '__main__':
    main()


Measured memory_bytes: 19672
#include "bits/stdc++.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
/*----------------------------------------------------------------*/

// int MOD = 998244353;
int MOD = 1000000007;

int n;
vector<int> G[101];
int d[101];
void bfs(){
    rep(i,n)d[i] = INF;
    d[0] = 0;
    queue<int> q;
    q.push(0);

    while(q.size()){
        int p = q.front();
        q.pop();
        for(auto x:G[p]){
            if(d[x] == INF){
                d[x] = d[p]+1;
                q.push(x);
            }
        }
    }
}


/*----------------------------------------------------------------*/
signed main(){

    cin >> n;
    rep(i,n){
        int u,k;
        cin >> u >> k;
        rep(i,k){
            int v;
            cin >> v;
            G[u-1].pb(v-1);
        }
    }
    bfs();
    rep(i,n)if(d[i] == INF)d[i] = -1;
    rep(i,n)cout << i+1 << " " << d[i] << endl;


	return 0;
}
/*----------------------------------------------------------------*/

// g++ -std=c++14 code1.cpp
// sudo pip3 install --upgrade online-judge-tools
// rm -r -f test;oj dl https://code-festival-2018-quala.contest.atcoder.jp/tasks/code_festival_2018_quala_c
// rm -r -f test;oj dl https://pakencamp-2019-day3.contest.atcoder.jp/tasks/pakencamp_2019_day3_c
// rm -r -f test;oj dl https://joi2009yo.contest.atcoder.jp/tasks/joi2009yo_d


Measured memory_bytes: 3176
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
#include<map>

#define MOD 1e9+7;
#define INF 1e17+9;
#define PI acos(-1);

using namespace std;

int main() {

	int n;
	cin >> n;
	map<string,int> mp;
	for(int i=0;i<n;i++){
		string s;
		cin >> s;
		sort(s.begin(),s.end());
		mp[s]++;
	}
	
	long long sum=0;
	for(auto itr = mp.begin(); itr != mp.end(); ++itr) {
        long long temp=itr->second;
        sum+=temp*(temp-1)/2;
    }
    
	cout << sum << endl;
    
	return 0;
}


Measured memory_bytes: 11136
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <stack>
#include <queue>
#include <set>
#include <string>

using namespace std;

int main(){
 int a, b, c;
 cin >> a >> b >> c;
 cout << c << " " << a << " " << b;
}


Measured memory_bytes: 256
def main():
    from sys import stdin, setrecursionlimit
    setrecursionlimit(10**6)
    r = stdin.readline()[:-1]
    #n = int(stdin.readline()[:-1])   
    #r = [stdin.readline() for i in range(n)]
    #t = [int(stdin.readline()) for i in range(n)]

    res = 0
    a, b, c = map(int, r.split())
    if a+b < c or a > c:
        print('NO')
    else:
        print('YES')

if __name__ == '__main__':
    main()



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

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

using Graph = vector<vector<int>>;

ll calc(ll a, ll b, ll p){//aのb乗をpで割った余り
  if(b == 0) return 1;

  else if(b%2 == 0){
    ll d = calc(a,b/2,p);
    return (d*d)%p;
  }
  else if(b%2 == 1){
    return (a * calc(a,b-1,p))%p;
  }
}

typedef pair<int,int> P;

bool is_prime(int n){//nが素数であるかどうか判定 iで割り切れると素数でない
    if(n == 1) return false;//1は例外
    for(int i = 2;i*i <= n;i++){
        if(n%i == 0) return false;
    }
    
    return true;
}
int factorial(int a){
  int res = 1;
  while(a){
    res *= a;
    a--;
  }
  return res;
}

int main(){
  int A,B;
  cin >> A >> B;
  if(A == 1 && B != 1) cout << "Alice" << endl;
  else if(A != 1 && B == 1) cout << "Bob" << endl;
  else if(A == 1 && B == 1) cout << "Draw" << endl;
  else{//どちらも1を持たない時
    if(A >B) cout << "Alice" << endl;
    else if(A < B) cout << "Bob" << endl;
    else if(A == B) cout << "Draw" << endl;
  }
}

Measured memory_bytes: 256
mod = 998244353
def extgcd(a, b, c):
  x, y, u, v, k, l = 1, 0, 0, 1, a, b
  while l != 0:
    x, y, u, v = u, v, x - u * (k // l), y - (k // l)
    k, l = l, k % l
  if c == 1:
    return x
  elif c == 2:
    return y
  elif c == 3:
    return k  
def inved(x):
  return extgcd(x, mod, 1)

fact = [1 for i in range(300001)]
invf = [1 for i in range(300001)]
for i in range(300000):
  fact[i+1] = (fact[i] * (i + 1)) % mod
invf[300000] = inved(fact[300000])
for i in range(300000, 0, -1):
  invf[i-1] = (invf[i] * i) % mod

#--------------------------------------------------#

N, A, B, K = map(int, input().split())
g = extgcd(A, B, 3)
uppern = (fact[N] * fact[N]) % mod
S = 0
if K % g != 0:
  S = 0
else:
  left = max(-((B*N-K)//A), 0)
  right = min(K // A, N)
  for i in range(left, right + 1):
    if (K - A * i) % B == 0:
      l = (K - A * i) // B
      prod = (invf[i] * invf[N-i]) % mod
      prod *= (invf[l] * invf[N-l]) % mod
      prod %= mod
      prod *= uppern
      prod %= mod
      S += prod
      S %= mod
  print(S)

Measured memory_bytes: 26804
#include <bits/stdc++.h>
#define pb push_back
#define fs first
#define sc second
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef vector<double> vd;

int main() {
    int i, n;
    ll val, dshift, ushift, uv, dv;
    scanf("%d", &n);
    vll l(n), r(n);
    for(i=0; i<n; i++) scanf("%lld%lld", &l[i], &r[i]);
    priority_queue<ll, vector<ll>, less<ll>> down;
    priority_queue<ll, vector<ll>, greater<ll>> up;
    down.push(l[0]);
    up.push(l[0]);
    val=dshift=ushift=0;
    for(i=1; i<n; i++) {
        dshift-=r[i]-l[i];
        ushift+=r[i-1]-l[i-1];
        dv=down.top()+dshift;
        uv=up.top()+ushift;
        if(l[i]>=dv && l[i]<=uv) {
            down.push(l[i]-dshift);
            up.push(l[i]-ushift);
        }
        else if(l[i]<=dv) {
            val+=min(abs(l[i]-dv), abs(l[i]-uv));
            down.pop();
            up.push(dv-ushift);
            down.push(l[i]-dshift);
            down.push(l[i]-dshift);
        }
        else {
            val+=min(abs(l[i]-dv), abs(l[i]-uv));
            up.pop();
            down.push(uv-dshift);
            up.push(l[i]-ushift);
            up.push(l[i]-ushift);
        }
    }
    printf("%lld\n", val);
    return 0;
}

Measured memory_bytes: 3572
import java.util.Scanner;
 
class Main {
 
    public static String merge(String s, String t) {
        if (s.length() < 1 || s.length() > 100) {
            return null;
        }
        if (s.length() == 0 && t.length() == 0) {
            return null;
        }
        if (s.length() == 0 && t.length() != 0) {
            return t;
        }
        if (t.length() == 0 && s.length() != 0) {
            return s;
        }
        return t + s;
    }
 
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        String s1 = s.next();
        String s2 = s.next();
        System.out.println(merge(s1, s2));
    }
 
}

Measured memory_bytes: 21588
import sys

S = input().split()
A = int(S[0])
B = int(S[1])
maxval = -sys.maxsize

add = A + B
diff = A - B
mul = A * B

if add > maxval:
    maxval = add
if diff > maxval:
    maxval = diff
if mul > maxval:
    maxval = mul

print(maxval)

Measured memory_bytes: 3060
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
 
int top, S[100];
 
void push(int x){
  S[++top] = x;
}
 
int pop(){
  top--;
  return S[top+1];
}
 
int main(){
  int a, b, x, no, np;
  top = 0;
  char s[100];
  no = np = 0;
  while( scanf("%s", s) != EOF ){
    if ( s[0] == '+' ){
      a = pop();
      b = pop();
      push(a + b);
      no++;
    } else if ( s[0] == '-' ){
      b = pop();
      a = pop();
      push(a - b);
      no++;
    } else if ( s[0] == '*' ){
      a = pop();
      b = pop();
      push(a * b);
      no++;
    } else {
      x = atoi(s);
      push(x);
      np++;
    }
  }
 
  printf("%d\n", pop());
 
  return 0;
}

Measured memory_bytes: 548
c = []
for i in range(3):
    x = list(map(int,input().split()))
    c.append(x)
check = 0
for i in range(100):
    b1 = c[0][0] - i
    b2 = c[0][1] - i
    b3 = c[0][2] - i
    if (c[0][0] - b1 == c[0][1] - b2 == c[0][2] - b3 and
        c[1][0] - b1 == c[1][1] - b2 == c[1][2] - b3 and
        c[2][0] - b1 == c[2][1] - b2 == c[2][2] - b3):
        check = 1
        break
if check == 1:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include<iostream>
#include<cmath>
using namespace std;
const double pi=3.14159265;
typedef pair<double,double> P;
double t[105][2];
double s[105];
P check(P pa,P pb){
	P pc;
	if(pa.first==-1)return pb;
	if(pa.first>pb.first){
		pc=pa,pa=pb,pb=pc;
	}
	if(pa.second<pb.first){
		pb.first-=1.0,pb.second-=1.0;
		if(pa.first>pb.first){
			pc=pa,pa=pb,pb=pc;
		}
	}
	if(pa.second<pb.second)pb.second=pa.second;
	return pb;
}

int main(){
	int n;
	int i,j,k;
	double a,b,c,d;
	P pa;
	cin>>n;
	for(i=0;i<n;i++){
		cin>>t[i][0]>>t[i][1];
	}
	for(i=0;i<n;i++){
		pa=make_pair(-1,-1);
		for(j=0;j<n;j++){
			if(i==j)continue;
			a=t[i][0]-t[j][0];
			b=t[i][1]-t[j][1];
			if(a==0.0){
				if(b>0.0)c=0.5;
				else c=1.5;
			}else{
				b/=a;
				c=atan(b);
				c/=pi;
				if(c<0.0)c+=2.0;
				if(a<0.0)c+=1.0;
			}
			d=c+2.5;
			c+=1.5;
			while(c>2.0){c-=2.0,d-=2.0;}
			c/=2.0,d/=2.0;
			pa=check(pa,make_pair(c,d));
			if(pa.second<pa.first)break;
		}
		s[i]=pa.second-pa.first;
		if(s[i]<0.0)s[i]=0.0;
	}
	for(i=0;i<n;i++){
		cout<<s[i]<<endl;
	}
	return 0;
}
	
	


Measured memory_bytes: 256
#include <iostream>
#include <string.h>
using namespace std;

int main() {
  string a,b;
  cin >> a >> b;
  string c = a + b;
  int n = atoi(c.c_str());
  int max = n, i = 4; 
  while(max > i){
      if(i*i==n){
          cout << "Yes" << endl;
          return 0;
      }else{
          max = n / i;
          i++;
      }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define inf 0x3f3f3f3f
#define linf 0x3f3f3f3f3f3f3f3fll //9223372036854775807
#define pi acos(-1.0)
#define ms(a,b) memset(a,b,sizeof(a))
#define nl "\n"
#define FAST_IO ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
typedef long long ll;
const int mod = 1e9+7;
ll qpow(ll a, ll b){ll s=1;while(b>0){if(b%2==1)s=s*a;a=a*a;b=b>>1;}return s;}
//ll qpow(ll x, ll y){ll s=1;while(y){if(y&1)s=s*x%mod;x=x*x%mod;y>>=1;}return s;}
inline ll read(){ll x=0,f=1;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();return x*f;}
ll inve(ll x){return x==1?1:(mod-mod/x)*inve(mod%x)%mod;}

const int N = 1e6+5;

ll n, m;
ll ans[N];
ll a[N], b[N];

ll f[N], num[N];

int Find(int x){
    return x==f[x]?x:f[x]=Find(f[x]);
}


int main()
{
    cin>>n>>m;
    for(int i=0;i<=n;i++) f[i]=i, num[i]=1;
    for(int i=1;i<=m;i++)
        scanf("%lld%lld", &a[i],&b[i]);
    ll res = 0;
    for(int i=m;i>0;i--)
    {
        ans[i] = 1ll*n*(n-1)/2-res;
        int fx = Find(a[i]);
        int fy = Find(b[i]);
        if(fx != fy){
            res += 1ll*num[fx]*num[fy];
            f[fx] = fy;
            num[fy] += num[fx];
        }
    }
    for(int i=1;i<=m;i++)
        cout<<ans[i]<<nl;
    return 0;
}


Measured memory_bytes: 14336
#include<cmath>
#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<algorithm>
#include<cstring>
#include<map>
#include<queue>
#include<set>
#include<vector>
#include<bitset>
#define int unsigned long long
#define hh putchar('\n')
#define kg putchar(' ')
#define lowbit(x) ((x)&(-x))
using namespace std;
const int maxn=3005,mod=998244353;
int jia[maxn],cheng[maxn],a,b,n;
inline int read()
{
    int x=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9')
    {
		if(ch=='-')
			f=-1;
		ch=getchar();
    }
    while(ch>='0'&&ch<='9')
    {
		x=(x<<1)+(x<<3)+(ch^48);
		ch=getchar();
    }
    return x*f;
}
inline void write(int a)
{
    if(a<0)
    {
		putchar('-');
		putchar('1');
//		write(-a);
    }
    else
    {
		if(a>=10)
			write(a/10);
		putchar(a%10+'0');
    }
}
int quickmi(int a,int b)
{
	int kotae=1;
	while(b)
	{
		if(b&1)
			kotae=kotae*a%mod;
		a=a*a%mod;
		b>>=1;
	}
	return kotae;
}
signed main()
{
	int n=read();
	char a[maxn];
	cin>>a;
	int len=strlen(a);
	if(len<=n)
		cout<<a;
	else
	{
		for(int i=0;i<n;++i)
			cout<<a[i];
		cout<<"...";
	}
	return 0;
}





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

#define CEIL(a,b) ((a) / (b) + ((a) % (b) == 0 ? 0 : 1))

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

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'000'000'001;
constexpr ll LLINF = 4'000'000'000'000'000'001;
// constexpr int INF = 2147483647; // 2 * 1e9
// constexpr ll LLINF = 9223372036854775807; // 9 * 1e18

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    int n;
    cin >> n;
    vector<pii> a(n);
    for(int i = 0; i < n; ++i){
        cin >> a[i].first;
        a[i].second = i+1;
    }
    sort(begin(a), end(a));
    for(int i = 0; i < n; ++i){
        cout << a[i].second << " \n"[i == n-1];
    }
    return 0;
}

Measured memory_bytes: 1664
import java.lang.reflect.Array;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        Set<Character> set = new HashSet<>();
        for(char c:s.toCharArray())set.add(c);
        for(int i=0;i<26;i++){
            char c = (char)('a' + i);
            if(!set.contains(c)){
                System.out.println(c);
                return;
            }
        }
        System.out.println("None");
    }
}



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


#define li			long long int
#define rep(i,to)	for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)	for(li i=(li)(start);i<((li)(to));i++)
#define pb			push_back
#define sz(v)		((li)(v).size())
#define bgn(v)		((v).begin())
#define eend(v)		((v).end())
#define allof(v)	(v).begin(), (v).end()
#define dodp(v,n)		memset(v,(li)n,sizeof(v))
#define bit(n)		(1ll<<(li)(n))
#define mp(a,b)		make_pair(a,b)
#define rin	rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)		idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)		idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)	for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)		idp p2((x).F, (x).S)
#define dump(x,n)	idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)	idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)	idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)	idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)	rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)	rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;

int main() {
	li a,b,c;
	cin>>a>>b>>c;
	li total=a+b+c;
	bool res = (a*2==total) || (b*2==total) || (c*2==total);
	cout<<(res ? "Yes" : "No")<<endl;


	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{  
	int n,m,s,c;
	cin>>n>>m;
	
	int a[n+1];
	int b[n+1];
	for(int i=1;i<=n;i++)
	{
		a[i]=0;
		b[i]=0; 
	}
	for(int i=1;i<=m;i++)
	{
		cin>>s>>c;
		if(n>1&&s==1&&c==0)
		{
			cout<<"-1"<<endl;
			return 0;
		}
		if(b[s]==0)
		{
			a[s]=c;
			b[s]=1;
		}
		else if(c!=a[s])
		{
			cout<<"-1"<<endl;
			return 0;
		}
	}
	if(n>1&&a[1]==0)
	{
		a[1]=1;
	}
	for(int i=1;i<=n;i++)
	{
		cout<<a[i];
	}
	return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 9)

N, M = map(int, input().split())

root = [-1] * N


def r(x):
    if root[x] < 0:
        return x
    else:
        root[x] = r(root[x])
        return root[x]


def unite(x, y):
    x = r(x)
    y = r(y)
    if x == y:
        return
    
    root[x] += root[y]
    root[y] = x


def size(x):
    return -r(x)


for i in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    unite(a, b)

max_size = -min(root)
print(max_size)


Measured memory_bytes: 13268
msg=input()
pp=msg[0:1+1];p=int(pp)
qq=msg[2:3+1];q=int(qq)
if 1<=p<=12:
  if 1<=q<=12:
  	print("AMBIGUOUS")
  else:
    print("MMYY")
else:
  if 1<=q<=12:
    print("YYMM")
  else:
    print("NA")

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define REP(i,x,n) for(int i=x;i<(int)n;i++)
#define rep(i,n) REP(i,0,n)
#define sp(p) cout<<setprecision(16)<<fixed<<p<<endl;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(rall(a))
#define UNIQ(a) unique(all(a))
#define UNIQNUM(a) UNIQ(a)-a.begin()
#define UNIQIT(a) a.erase(UNIQ(a), a.end());
#define VOUT(v,i) rep(i,v.size())cout<<v[i]<<(i==v.size()-1?"\n":" ");
#define vout(v) VOUT(v,z);
#define vdbg(v,i) cout<<#v<<": ";for(int i=0;i<(int)v.size();i++){cout<<v[i]<<" ";}cout<<"\n";
#define vmin(v) *min_element(all(v))
#define vmax(v) *max_element(all(v))
#define vsum(v) accumulate(all(v), 0LL)
#define MOUT(m,r,c) rep(i,r){rep(j,c){cout<<m[i][j]<<" ";}cout<<endl;}
#define mout(m) MOUT(m,m.size(),m[0].size())
#define debg(a) cout<<#a<<": "<<a<<endl;
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
#define digit(a) to_string(a).length();
template<class T>inline int out(const T &t){ print(t); putchar('\n'); return 0; }
// template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
// template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
bool is_palindrome(string s){return s == string(s.rbegin(),s.rend());}
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef vector<ll> V;
typedef vector<vector<ll>> VV;
// const long long MOD=1000000007;
const long long INF = 1e18;
#define EPS (1e-7)
#define PI (acos(-1))
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) { a = b; return true; }
    return false;
}
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) { a = b; return true; }
    return false;
}



int main(){
    long long X;
    scanf("%lld",&X);
    //solve(X);
    ll ini=100;
    ll y=0;
    while (ini<X)
    {
        ini*=1.01;
        ini=floor(ini);
        y++;
    }
    cout << y << endl;
    
    return 0;
}


Measured memory_bytes: 3760
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int N,i,c=0;
    scanf("%d",&N);
    char s[N][20];
    map<string,int>m;
    for(i=0;i<N;i++){
        scanf("%s",&s[i]);
    }
    for(i=0;i<N;i++){
        if(m.find(s[i])==m.end()){
           c++;
           m[s[i]]=0;
        }
    }
    printf("%d\n",c);
    return 0;
}


Measured memory_bytes: 23328
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n , k ;
  cin >> n >> k ;
  vector<int> a(n);
  for(int i = 0 ; i < n ; i++){
    int t ;
    cin >> t  ;
    a.at(t-1) += 1;
  }
  int type = 0 ;
  for(int i = 0 ; i < n ; i++){
    if(a.at(i) != 0){
      type += 1;
    }
  }
  sort(a.begin(), a.end());
  int ans = 0 ;
  for(int i = 0 ; ; i++){
    if( type > k  && a.at(i) != 0){
      ans += a.at(i);
      type -= 1;
    }
    if( type <= k){
      break;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
import java.util.*;
import java.lang.*;


class Main {
    public static void main(String[] args) throws java.lang.Exception {
        Scanner in = new Scanner(System.in);

        int N = in.nextInt();
       // int[][] seats = new int[N][2];
        int seats = 0;
        for (int i = 0; i < N; i++) {
            int l1 = in.nextInt();
            int r1 = in.nextInt();
            seats += r1-l1+1;
        }
        System.out.println(seats);
    }
}

Measured memory_bytes: 25808
ans = 0
def count(use, sum, n, s):
    global ans
    if(sum > s or n < 0):
        return;
    if(n == 0 and s == sum):
        ans += 1
    else:
        for i in range(use + 1, 10):
            count(i, sum + i, n - 1, s)

while(True):
    n = map(int, raw_input().split())
    ans = 0
    if(n[0] == 0 and n[1] == 0):
        break
    count(-1, 0, n[0], n[1])
    print(ans)

Measured memory_bytes: 4224
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)

using namespace std;

typedef pair<int, double> P;

const int INF = 1e15;
const int MOD = 1e9+7;

pair<vector<double>, vector<int>> dijkstra(const vector<vector<P>>& graph, int n, int s){
    vector<double> d(n+1, INF);
    d[s] = 0;

    vector<int> p(n+1, -1);
    p[s] =  s;

    priority_queue<P, vector<pair<double, int>>, greater<pair<double, int>>> que;
    que.emplace(0.0, s);

    while(!que.empty()){
        double w = que.top().first;
        int to = que.top().second;
        que.pop();

        if(d[to] < w){
            continue;
        }

        rep(i, (int)graph[to].size()){
            int from = graph[to][i].first;
            double nw = w + graph[to][i].second;
            if(nw < d[from]){
                d[from] = nw;
                p[from] = to;
                que.emplace(nw, from);
            }
        }
    }
    return make_pair(d, p);
}

signed main(){
    double xs, ys, xt, yt;
    int n;
    cin >> xs >> ys >> xt >> yt >> n;

    vector<double> x(n), y(n), r(n);
    rep(i, n) cin >> x[i] >> y[i] >> r[i];

    vector<vector<P>> edge(n+2, vector<P>());
    double d = max(0.0, sqrt(pow(xs - xt, 2) + pow(ys - yt, 2)));
    edge[0].emplace_back(n+1, d);
    edge[n+1].emplace_back(0, d);

    rep(i, n){
        double ds = max(0.0, sqrt(pow(xs - x[i], 2) + pow(ys - y[i], 2)) - r[i]);
        edge[0].emplace_back(i+1, ds);
        edge[i+1].emplace_back(0, ds);

        double dt = max(0.0, sqrt(pow(xt - x[i], 2) + pow(yt - y[i], 2)) - r[i]);
        edge[n+1].emplace_back(i+1, dt);
        edge[i+1].emplace_back(n+1, dt);

        for(int j = i + 1; j < n; j++){
            double d = max(0.0, sqrt(pow(x[j] - x[i], 2) + pow(y[j] - y[i], 2)) - r[i] - r[j]);
            edge[i+1].emplace_back(j+1, d);
            edge[j+1].emplace_back(i+1, d);
        }
    }

    pair<vector<double>, vector<int>> ans = dijkstra(edge, n+2, 0);
    cout << fixed << setprecision(10) << ans.first[n+1] << endl;

    return 0;
}


Measured memory_bytes: 21872
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let v = read_vec::<usize>();
    let (h, w) = (v[0], v[1]);
    let mut count = 0;
    for i in 0..h {
        let s = read::<String>();
        count += s.chars().filter(|&x| x == '#').count();
    }
    if count == h + w - 1 {
        println!("Possible");
    } else {
        println!("Impossible");
    }
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 2128
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
  sc.Scan()
  return sc.Text()
}

func nextInt() int {
  sc.Scan()
  i, e := strconv.Atoi(sc.Text())
  if e != nil {
    panic(e)
  }
  return i
}

// 文字列を1行取得
func StrStdin() (stringInput string) {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	stringInput = scanner.Text()
	stringInput = strings.TrimSpace(stringInput)
	return
}

// 整数値1つ取得
func IntStdin() (int, error) {
	stringInput := StrStdin()
	return strconv.Atoi(strings.TrimSpace(stringInput))
}

// 空白や空文字だけの値を除去したSplit()
func SplitWithoutEmpty(stringTargeted string, delim string) (stringReturned []string) {
	stringSplited := strings.Split(stringTargeted, delim)

	for _, str := range stringSplited {
		if str != "" {
			stringReturned = append(stringReturned, str)
		}
	}
	return
}

// デリミタで分割して文字列スライスを取得
func SplitStrStdin(delim string) (stringReturned []string) {
	// 文字列で1行取得
	stringInput := StrStdin()

	// 空白で分割
	stringReturned = SplitWithoutEmpty(stringInput, delim)

	return
}

// デリミタで分割して整数値スライスを取得
func SplitIntStdin(delim string) (intSlices []int, err error) {
	// 文字列スライスを取得
	stringSplitted := SplitStrStdin(" ")

	// 整数スライスに保存
	for i := range stringSplitted {
		var iparam int
		iparam, err = strconv.Atoi(stringSplitted[i])
		if err != nil {
			return
		}
		intSlices = append(intSlices, iparam)
	}
	return
}


func main() {
	num, _ := SplitIntStdin(" ")

	if num[0] == num[1] {
		fmt.Println(num[2])
	} else if num[0] == num[2] {
		fmt.Println(num[1])
	} else {
		fmt.Println(num[0])
	}
}

Measured memory_bytes: 640
/********************************************************
  **░██████╗██╗░░░░░░█████╗░██╗░░░██╗██╗░█████╗░░██████╗░**
  **██╔════╝██║░░░░░██╔══██╗██║░░░██║██║██╔══██╗██╔════╝░**
  **╚█████╗░██║░░░░░███████║╚██╗░██╔╝██║██║░░╚═╝██║░░██╗░**
  **░╚═══██╗██║░░░░░██╔══██║░╚████╔╝░██║██║░░██╗██║░░╚██╗**
  **██████╔╝███████╗██║░░██║░░╚██╔╝░░██║╚█████╔╝╚██████╔╝**
  **╚═════╝░╚══════╝╚═╝░░╚═╝░░░╚═╝░░░╚═╝░╚════╝░░╚═════╝░**
  *********************************************************/

#include <bits/stdc++.h>
using namespace std;


#define ll                          long long
#define ld                          long double

#define forn(i,n)                   for(int i=0;i<n;++i)
#define all(v)                      v.begin(), v.end()
#define rall(v)                     v.rbegin(),v.rend()
#define isSubstring(s1,s2)          s1.find(s2) != std::string::npos
	
#define pb                          push_back
#define pf                          push_front
#define mp                          make_pair
#define fr                          first
#define sc                          second

#define vpi                         vector<pair<int,int>>
#define vi                          vector<int>
#define sz(a)                       (int)a.size()

#define   endl                       "\n"
#define     nl                       cout<<"\n";
#define fastio                       ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

#define  MN                           INT_MIN
#define  MX                           INT_MAX
#define int long long
bool isPrime(ll n){if(n<2)return false;for(ll x = 2;x*x <=n;x++){if(n%x == 0)return false;}return true;}
bool isPerfectSquare(long double x){long double sr=sqrt(x);return((sr-floor(sr))==0);}
int gcd(int a, int b){if(a==0)return b;if(b==0) return a;if(a==b)return a;if(a>b)return gcd(a-b,b);return gcd(a,b-a);}

int32_t main()
{
	string s;
	cin >> s;
	for(int i = 0;i<sz(s);i++)
		if(i&1&& s[i] == 'R'){
			cout << "No\n";
			return 0;
		}else if(s[i] == 'L' && i%2==0){
			cout << "No\n";
			return 0;
		}
	cout << "Yes\n";
}

Measured memory_bytes: 3712
import java.util.Scanner;

public class Main {

public static void main(String[] args) {
  Scanner in = new Scanner(System.in);
  double[] x = new double[3];
  double[] y = new double[3];
  while (in.hasNext()) {
	{
	  for (int i = 0; i < 3; i++) {
		x[i] = in.nextDouble();
		y[i] = in.nextDouble();
	  }
	  double px = in.nextDouble();
	  double py = in.nextDouble();
	  for (int i = 0; i < 3; i++) {
		x[i] -= px;
		y[i] -= py;
	  }
	}
	double[] AB = f(x, y);
	if (AB[0] >= 0 && AB[1] >= 0) {
	  System.out.println("YES");
	} else {
	  System.out.println("NO");
	}
  }
}

private static double[] f(double[] x, double[] y) {
  x[2] = -x[2];
  y[2] = -y[2];
  double D = x[0] * y[1] - x[1] * y[0];
  double xx = +y[1] * x[2] - x[1] * y[2];
  double yy = +x[0] * y[2] - y[0] * x[2];
  return new double[] { (xx / D), (yy / D) };
}
}

Measured memory_bytes: 0
#!/usr/bin/env ruby

h, w = gets.chomp.split(" ").map(&:to_i)

# . => empty
# # => bomb

map = h.times.map{
  gets.chomp.split("").map{|str| str == "." ? 0 : str}
}

index_set = (-1..1).to_a.repeated_permutation(2).to_a - [[0, 0]]

h.times do |i|
  w.times do |j|
    if "#" != map[i][j]
      next
    end

    index_set.each do |k, l|
      m = i + k
      n = j + l

      unless (0...h).include?(m) && (0...w).include?(n)
        next
      end

      if "#" == map[m][n]
        next
      else
        map[m][n] += 1
      end
    end
  end
end

map.each do |ary|
  puts ary.join
end


Measured memory_bytes: 2172
N = int(input())
A = [0]+list(map(int, input().split()))+[0]
res = 0
for i in range(1,N+2):
    res += abs(A[i]-A[i-1])
for i in range(1,N+1):
    print(res - abs(A[i+1]-A[i]) - abs(A[i]-A[i-1]) + abs(A[i+1]-A[i-1]))

Measured memory_bytes: 86808
use std::io::*;
use std::str::FromStr;

fn main() {
    let cin = stdin();
    let mut sc = Scanner::new(cin.lock());

    let s = sc.next::<String>().repeat(2);
    let t = sc.next::<String>();
    println!("{}", if s.contains(&t) { "Yes" } else { "No" });
}

/* ========== Scanner ========== */

struct Scanner<R: Read> {
    reader: R,
}

#[allow(dead_code)]
impl<R: Read> Scanner<R> {
    fn new(reader: R) -> Scanner<R> {
        Scanner { reader: reader }
    }

    fn read<T: FromStr>(&mut self) -> Option<T> {
        let token = self
            .reader
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            token.parse::<T>().ok()
        }
    }

    fn next<T: FromStr>(&mut self) -> T {
        if let Some(s) = self.read() {
            s
        } else {
            writeln!(stderr(), "Terminated with EOF").unwrap();
            std::process::exit(0);
        }
    }

    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.next()).collect()
    }

    fn chars(&mut self) -> Vec<char> {
        self.next::<String>().chars().collect()
    }

    fn char(&mut self) -> char {
        self.chars()[0]
    }
}



Measured memory_bytes: 5044
#include <bits/stdc++.h>
#include <complex>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,C,L,R;
string S,T;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

typedef vector<P> vp;
typedef vector<vp> matP;

int main() {
    cin>>N>>K;
    ll ans = 0;
    rep(i,N){
        cin>>A;
        ans += min(abs(A), abs(K-A))*2;
    }
    cout<<ans<<endl;
}

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

int main(){
    string str;
    int a;
    cin >> str;
    for(int i=0;i<str.size();i++){
        a = (int)str[i] - 3;
        if(a < (int)'A'){
            a += 26;
        }
        str[i] = (char)a;
    }
    cout << str << endl;
    return 0;
}

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

using namespace std;
using LL = long long;
using P = pair<int, int>;
using Tapris = tuple<int, int, int>;

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

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e15;
const int MOD = 1e9 + 7;

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

/*************** using variables ***************/
int a, b, n;
int x[45], y[45];
int dp[20][20];
/**********************************************/

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

    while(cin >> a >> b, a != 0 || b != 0){
        cin >> n;
        REP(i, n) cin >> x[i] >> y[i];
        
        REP(i, 20) REP(j, 20) dp[i][j] = 0;
        REP(i, n) dp[x[i]][y[i]] = -1;
        
        dp[1][1] = 1;
        FOR(i, 1, a+1){
            FOR(j, 1, b+1){
                if(i == 1 && j == 1) continue;
                if(dp[i][j] == -1) continue;

                dp[i][j] = (dp[i-1][j] != -1 ? dp[i-1][j] : 0) + (dp[i][j-1] != -1 ? dp[i][j-1] : 0);
            }
        }
        cout << dp[a][b] << endl;
    }

}



Measured memory_bytes: 3116
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        while (n-- > 0) {
            boolean[][] r = new boolean[9][9];
            int[][] l = new int[9][9];
            for (int i = 0; i < 9; i++) {
                for (int j = 0; j < 9; j++) {
                    l[i][j] = sc.nextInt();
                }
            }
            for (int i = 0; i < 9; i++) {
                int[] c1 = new int[10];
                int[] c2 = new int[10];
                int[] c3 = new int[10];
                for (int j = 0; j < 9; j++) {
                    if (++c1[l[i][j]] > 1) {
                        r[i][j] = true;
                        for (int k = j - 1; k >= 0; k--) {
                            if (l[i][j] == l[i][k]) {
                                r[i][k] = true;
                                break;
                            }
                        }
                    }
                    if (++c2[l[j][i]] > 1) {
                        r[j][i] = true;
                        for (int k = j - 1; k >= 0; k--) {
                            if (l[j][i] == l[k][i]) {
                                r[k][i] = true;
                                break;
                            }
                        }
                    }
                    int y = i / 3 * 3 + j / 3, x = i % 3 * 3 + j % 3;
                    if (++c3[l[y][x]] > 1) {
                        r[y][x] = true;
                        for (int k = j - 1; k >= 0; k--) {
                            int yk = i / 3 * 3 + k / 3, xk = i % 3 * 3 + k % 3;
                            if (l[y][x] == l[yk][xk]) {
                                r[yk][xk] = true;
                                break;
                            }
                        }
                    }
                }
            }

            for (int i = 0; i < 9; i++) {
                String s = "";
                for (int j = 0; j < 9; j++) {
                    s += (r[i][j] ? "*" : " ") + l[i][j];
                }
                System.out.println(s);
            }
            if (n > 0) {
                System.out.println();
            }
        }
    }
}



Measured memory_bytes: 30680
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define inf 1000000000
#define md 1000000007
#define pb push_back
#define li 3005
#define int long long
using namespace std;
int n,A[li],dp[li][li][3];
int dfs(int l,int r,int t){
	if(l>r){
		return 0;
	}
	if(~dp[l][r][t]) return dp[l][r][t];
	if(t==1){
		dp[l][r][t]=max(dfs(l+1,r,1-t)+A[l],dfs(l,r-1,1-t)+A[r]);
	}
	if(t==0){
		dp[l][r][t]=min(dfs(l+1,r,1-t)-A[l],dfs(l,r-1,1-t)-A[r]);
	}
	return dp[l][r][t];
}
main(){
	memset(dp,-1,sizeof(dp));
	scanf("%lld",&n);
	for(int i=1;i<=n;i++) scanf("%lld",&A[i]);
	int ty=dfs(1,n,1);
	printf("%lld\n",ty);
	return 0;
}




Measured memory_bytes: 212096
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
 #include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#include <iomanip>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << endl
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
int dx8[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy8[8] = {0, 1, 0, -1, 1, 1, -1, -1};
int dx4[4] = {1, 0, -1, 0};
int dy4[4] = {0, 1, 0, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){ fill((T*)array, (T*)(array+N), val); }
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;

//問題文が複雑な時は具体例を出して、小さい方から考えていく
//形だけが同じなら良くて、a~前の文字列で使った一番大きい文字+1が次の文字列で使える
//あとは形が同じでその中の辞書順最強をdfsで作っていく

int Q;
string s;
string rev;

int main(){
      cin >> s;
      rev = s;//最初はrevも同じ
      reverse(rev.begin(),rev.end());
      cin >> Q;

      rep(i,Q){
          int x;
          cin >> x;
          if(x == 1){
              //swap
              
              s.swap(rev);
            
          }else{
              //revには逆の操作を行う
              int y;
              string c;
              cin >> y >> c;
              if(y == 1){
                  //普通のには前に、revには後ろに,insertはO(N)なのだが、先頭をしてすれば早いのでokっぽい
                  rev+=c;
                  s.insert(0,c);//insertとの第二引数はstringなので注意
              }else{
                  s+=c;
                  rev.insert(0,c);
              }
          }
      }

      fin(s);
      
}

Measured memory_bytes: 1316
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#define getcx getchar_unlocked
#define MSV(A,a) memset(A, a, sizeof(A))
#define MP make_pair
#define PB push_back
#define INF (int(1e9))
#define INFL (LL(1e18))
#define EPS 1e-12
#define chkbit(s, b) (s & (1<<b))
#define setbit(s, b) (s |= (1<<b))
#define chk(a) cerr << endl << #a << " : " << a << endl
#define chk2(a,b) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << endl
#define chk3(a,b,c) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << endl
#define chk4(a,b,c,d) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << "\t" << #d << " : " << d << endl
#define rep(i, a, n) for(i=a;i<n;i++)
#define rev(i, a, n) for(i=a;i>=n;i--)
#define rep_itr(itr, c) for(itr = (c).begin(); itr != (c).end(); itr++)
#define MOD 1000000007
#define MAX 100005
#define in(x) scanf("%d", &x)
#define inl(x) scanf("%lld", &x)
#define in2(x, y) scanf("%d %d", &x, &y)
#define inl2(x, y) scanf("%lld %lld", &x, &y)
typedef pair<int, int> pi;
typedef pair<LL, LL> pl;
const char en = '\n';

int main() {

	double n,i, ans =0, d, s, t;

	cin>>d>>t>>s;

	double tm = d/s;

	if(tm <= t) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;

	return 0;
}

Measured memory_bytes: 3716
/*
P135
AOJ 0009 Prime Number
Difficult: 2
*/

#include <iostream>
#include <map>
#include <set>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <functional>
#include <string.h>
#include <cmath>

using namespace std;

const int MAXN = 999999;
int prime[MAXN + 1], pn;
int mindiv[MAXN + 1];

void GetPrime(int n)
{   //determin each num (that <= n) is prime or not.
    //and get primes into an array with pn elements
    //mindiv[i] == i means it is a prime
    fill(mindiv, mindiv+n+1, 0);
    pn = 0;
    for(int i=2; i<=n; ++i){
        if(mindiv[i] == 0) mindiv[i] = i, prime[pn++] = i;
        for(int p=0; p<pn && i*(long long)prime[p] <= n; ++p){
            mindiv[prime[p]*i] = prime[p];
            if(prime[p] == mindiv[i]) break;
        }
    }
}


int main()
{
    GetPrime(MAXN);
    int n;
    while(scanf("%d", &n) !=EOF){
        int x = upper_bound(prime, prime + pn, n) - prime;
        printf("%d\n", x);
    }

}

Measured memory_bytes: 7328