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

using namespace std;

int main(){
    int a,b,k;
    cin>>a>>b>>k;
    if((abs(a-b)+1)/2>=k){
        for(int i=a;i<a+k;i++) cout<<i<<endl;
        for(int i=b-k+1;i<=b;i++) cout<<i<<endl;
    }else{
        for(int i=a;i<=b;i++) cout<<i<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
N = int(input())
A = map(int, input().split())

x = [0 for i in range(N+10)]
x[0] = 3

mod = 1000000007

ans = 1

for a in A:
    ans *= x[a]
    ans %= mod
    if ans == 0:
        break
    x[a] = x[a] - 1
    x[a+1] = x[a+1] + 1


print(ans)



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


int main(){
    int n,k;
    cin>>n>>k;
    int a[200005];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    double res=0,z=0;
    for(int i=0;i<k;i++){
        z+=a[i];
    }
    res=z;
    for(int i=k;i<n;i++){
        z-=a[i-k];
        z+=a[i];
        if(z>res){
            res=z;
        }
    }
    res+=k;
    res/=2;
    printf("%.12lf",res);
}


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

int main() {
	ll n,a,l,r;
	cin>>n>>a;
	l=a-n+1;
	r=a+n-1;
	for(int i=l;i<=r;i++)cout<<i<<' ';
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define fi first
#define se second
long long mo = 1000000007;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
typedef pair<ll,Pll> PlP;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

int main(){
    ll N, K;
    cin >> N >> K;
    vector<ll> P(N), C(N);
    rep(i,N){
        cin >> P[i];
        P[i]--;
    }
    rep(i,N){
        cin >> C[i];
    }
    ll ans = -1e18;
    /*rep(i,N){
        ll cur = i;
        ll sum = 0;
        vector<ll> s;
        while(1){
            cur = P[cur];
            s.push_back(C[cur]);
            sum += C[cur];
            if(cur == i) break;
        }
        ll l = s.size();
        ll t = 0;
        rep(j,l){
            t += s[j];
            if(j+1 > K) break;
            ll now = t;
            if(sum > 0){
                ll e = (K-(j+1))/l;
                now += sum*e;
            }
            cmax(ans, now);
        }
    }
    cout << ans << endl;*/
    
    rep(i,N){
        ll cur = P[i]; 
        ll cnt = 0;
        ll sum = 0;
        //ll sum = C[P[cur]];
        //cnt++;
        vector<ll> memo(N);
        vector<ll> S(N+10);
        //memo[P[cur]] = cnt;
        //S[cnt] = sum;
        //cmax(ans,sum);
        //cur = P[cur];
        while(1){
            if(memo[cur] > 0){
                break;
            }
            memo[cur] = 1;
            sum += C[cur];
            //memo[P[cur]] = cnt;
            cur = P[cur];
            cnt++;
        }
        //cmax(ans, sum);
        //if(K <= N) continue;
        //cnt = memo[cur] - memo[P[cur]] + 1;
        //sum = S[memo[cur]];
        /*ll t = 0;
        cur = P[i];
        rep(j,cnt){
            t += C[cur];
            if(j+1 > K)break;
            ll now = t;
            if(sum > 0){
                ll e = (K-(j+1))/cnt;
                now += sum*e;
            }
            cur = P[cur];
            cmax(ans,now);
        }*/
        /*
        if(sum <= 0) continue;
        */
        ll q = ll(K/cnt) - 1;
        ll r = K%cnt;
        if(q < 0){
            cnt = 0;
            sum = 0;
            cur = i;
        }else{
            if(sum > 0){
                sum = sum*q;
            }else{
                sum = 0;
            }
            cur = i;
        }
        rep(j, cnt+r){
            sum += C[P[cur]];
            cur = P[cur];
            cmax(ans, sum);
        }        
        cmax(ans, sum);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3764
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();
		int z = sc.nextInt();
		
		int ans = x / (y + z);
		int tmp = x % (y + z);
		if (tmp < z) {
			ans--;
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 22608
!ここに民を導く先導者となるべきものを決める儀式を執り行う
integer N
!民の総数である
integer,allocatable,dimension(:)::LookingWEST,LookingEAST
!日沈む方向及び、日出る方向を見る民の総数である
character(3*10**5) S
!民の眼差しの向く方向、一体何が見えているのだろうか。それは民のみぞ知る。
integer ans
!我々の解答である、これによって先導者を決めることとなる、一切の誤謬も許されない。
!さあ儀式の始まりである。
!民は集え、その手を上げよ。
read*,N
!そして目指す方向を述べよ
read*,S
!民の心を受け止めるのに相応しいだけの器を用意する
allocate(LookingWEST(0:N-1),LookingEAST(2:N+1))
!西端には誰もいない、茫漠と荒野が広がっている。
LookingWEST(0)=0
Do i=1,N-1
  !さあ一人一人訊いていこうではないか
  !爾いずれの方向を見るものぞ
  !若し西を見るものであれば我々はそれを記憶する
  !さあ答えよ
  LookingWEST(i)=LookingWEST(i-1)+merge(1,0,S(i:i)=="W")
  !ここに爾のことは記録された
End DO
!東端にも誰もいない、と大洋が広がっている。
LookingEAST(N+1)=0
Do i=N,2,-1
  !さあ今度は東から一人一人訊いていこうではないか
  !爾いずれの方向を見るものぞ
  !若し東を見るものであれば我々はそれを記憶する
  !さあ答えよ
  LookingEAST(i)=LookingEAST(i+1)+merge(1,0,S(i:i)=="E")
  !ここに爾のことは記録された
End DO

!リーダーとはより民に慕われているもの
!すなわちより民の顔が向けられていることが先導者として必要なことである。
!民が目指す先に先導者はいなくてはならない。
!民が後ろを向くことは許されない
!後ろを向くな
!先(まえ)へ
ans=huge(ans)
do i=1,N
  !スコシデモオオクノタミヲマエニムカワセナクテハ
  ans=min(ans,LookingWEST(i-1)+LookingEAST(i+1))
end do
!答えは出た
!これから我々の答えを発表する
!ココロシテキクヨウニ
print"(i0)",ans
!ギシキハ終わりを迎える、我々の役目はここまで、
!また
!先導者の資格がしりたくなったら逢おう
!また答えは変わるやもしれぬ
!Δεν υπάρχει μόνιμη ευτυχία, υπάρχουν μόνο στιγμές ευτυχίας.
end

Measured memory_bytes: 3340
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int maxN = 1e4+7;
const int maxV = 90010;
//const int INF = 1e9+9;
//const ll INF = (1ll)<<60;
const int INF = 2e9+9;
const int MOD = 1e9+7;

int n;
vector<int> v[maxN];
int c[maxN];
int ans[maxN];
int fa[maxN];
int tot = 0;
void dfs(int x)
{
	ans[x] = c[++tot];
	for(auto y:v[x])
	{
		if(fa[x] == y) continue;
		fa[y] = x;
		dfs(y);
	}
}
int main()
{
	scanf("%d",&n);
	
	for(int i=1;i<n;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		v[x].push_back(y);
		v[y].push_back(x);
	}
	int sum = 0;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&c[i]);
		sum += c[i];
	}
	sort(c+1,c+1+n);
	sum -= c[n];
	reverse(c+1,c+1+n);
	dfs(1);
	cout<<sum<<endl;
	for(int i=1;i<n;i++)
	{
		printf("%d ",ans[i]);
	}
	printf("%d\n",ans[n]);
	return 0;
}

Measured memory_bytes: 1408
import java.io.*;
import java.util.NoSuchElementException;
import java.util.Scanner;

public class Main {


    public static void main(String[] args) {
	
	Scanner sc=new Scanner(System.in);
	
	String str=sc.next();
	
	String f=str.substring(0,4);
	String l=str.substring(4);
	System.out.println(f.toUpperCase()+" "+l.toUpperCase());
	
    }


 
    
    
}


Measured memory_bytes: 9676
#include<bits/stdc++.h>
#define ford(i,a,b) for(int i=(a);i>=b;i--)
#define rep1(i,a,b) for(int i=(a);(i)<=(b);(i)++)
#define rep0(i,a,b) for(int i=(a);(i)<(b);(i)++)
#define ll long long
#define re return
#define mp map<string,int>
#define N 200005
#define pql priority_queue<ll>
#define all(v) (v).begin(),(v).end()
#define str stringstream
using namespace std;
int n,ans; mp s;
string ch[N];
int main() {
	cin>>n;
	rep0(i,0,n){
		cin>>ch[i]; s[ch[i]]++;
		ans=max(ans,s[ch[i]]);
	}
	sort(ch,ch+n);
	rep0(i,0,n) 
		if(ans==s[ch[i]]) {
			s[ch[i]]=0;
			cout<<ch[i]<<"\n";
		}
	re 0;
}


Measured memory_bytes: 26752
#include <stdio.h>
#include <algorithm>
using namespace std;

int main(){
  int e,minInt;
  while (true){
    scanf("%d",&e);
    if (e==0) return 0;
    minInt=10000000;
    for (int z=100;z>=0;z--)
      for (int y=1000;y>=0;y--)
        if ((e-(y*y+z*z*z))>=0)
          minInt=min(minInt,y+z+e-(y*y+z*z*z));
    printf("%d\n",minInt);
  }
}

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

int main(){
 	int A,B,C,X;
  	cin >> A>> B >> C >> X;
  	int res = 0;
  	for(int a = 0 ; a <= A ; ++a){
    	for(int b = 0 ; b <= B ; ++b){
        	for(int c = 0 ; c <= C ; ++c){
            	int total = 500*a + 100*b +c*50;
              	if(total == X ) ++res;
            }
        }
    }
  cout << res << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <queue>
#include <stack>
#include <list>
#include <deque>
#include <set>
using namespace std;
using ll = long long;
using ld = long double;

const ll MOD = 1000000000 + 7;
const ll INF = 1e+9;
const ld PI = acos((ld)(-1));

#define FAST ios::sync_with_stdio(false); cin.tie(nullptr)
#define Fixed(n) std::fixed << std::setprecision(n)
#define rep(i, n) for(int (i) = (0); (i) < (n); (++i))
#define print(x) cout << x << endl;
#define next '\n'
#define sp " "
#define FOR(i, start, end) for(int (i) = (start); (i) < (end); (++i))
#define foreach(elem, _list) for(auto& (elem) : (_list))
#define view(_list) foreach(e, _list){ cout << e << sp; } cout << endl
#define SIZE(s) (s).size()
#define ALL(vec) (vec).begin(), (vec).end()
#define pb(e) push_back(e)
#define eb(e) emplace_back(e)

int main() {
    FAST;

    int n;
    string s;
    cin >> n >> s;
    if(SIZE(s) <= n){
        cout << s << endl;
    }else{
        rep(i, n){
            cout << s[i];
        }
        cout << "..." << endl;
    }
}



Measured memory_bytes: 3652
#include<cstdio>
#include<cstring>
char a[20000];
int main()
{
	while(~scanf("%s",a))
	{
		int l=strlen(a);
		bool flag=1;
		for(int i=1;i<l;i++)
		{
			if(a[i]==a[i-1])
			{
				flag=0;
				break;
			}
		}
		if(flag)
			printf("Good\n");
		else
			printf("Bad\n"); 
	}
} 

Measured memory_bytes: 1608
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main(){
    int a;
    string s;
    cin>>a>>s;
    if(a<3200) cout<<"red"<<endl;
    else cout<<s<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int N,T,A,f,i;
    cin>>N;
    int height[N];
    double At[N],d[N],e,index;
    cin>>T>>A;
    for(i=0;i<N;i++)
        cin>>height[i];
    for(i=0;i<N;i++){
        At[i]=T-height[i]*0.006;
        d[i]=At[i]-A;
        if(d[i]<0)
            d[i]=-d[i];
    }
    e=d[0];
    f=0;
    for(i=1;i<N;i++){
        if(d[i]<e){
            e=d[i];
            f=i;
        }
    }
    cout<<f+1;
    return 0;
}


Measured memory_bytes: 256
package main

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

func main() {
  sc := bufio.NewScanner(os.Stdin)
  sc.Split(bufio.ScanWords)

  sc.Scan()
  a, _ := strconv.Atoi(sc.Text())

  sc.Scan()
  b, _ := strconv.Atoi(sc.Text())

  fmt.Println((a + b + 1) / 2)
}


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

const ll INF = 1e18;

int N;
ll h[100001];
ll dp[100010][3];

int main(){
    cin >> N;
    vector<vector<int>> abc(N, vector<int>(3));
    for (int i=0; i<N; i++) {
        for (int j=0; j<3; j++) {
            cin >> abc[i][j];
        }
    }
    for (int i=0; i<N; i++) {
        for (int j=0; j<3; j++) {
            dp[i][j] = -INF;
        }
    }
    for (int j=0; j<3; j++) dp[0][j] = 0;
    for (int i=0; i<N; i++) {
        for (int j=0; j<3; j++) {
            for (int k=0; k<3; k++) {
                if (j != k) dp[i+1][k] = max(dp[i+1][k], dp[i][j] + abc[i][k]);
            }
        }
    }
    cout << max(dp[N][0], max(dp[N][1], dp[N][2])) << endl;
}

Measured memory_bytes: 11136
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define mod 1000000007
#define mod1 998244353
#define timepass 1073741824
#define MAXN 200000 + 5
#define LOGN 20
#define over ((1ll << 32))
using namespace std;
#define N 2005
 
/*#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
/*template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
 
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define int ll 
#define all(arr) arr.begin() , arr.end()
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define rep(i , a , n) for(int i = a ; i < n ; i++)
#define rrep(i , n , a) for (int i = n - 1 ; i >= a ; i--)
#define ms(arr , val) memset(arr , val , sizeof(arr))
#define sp(a , x) cout << fixed << setprecision(a) << x << endl; 
#define siz(temp) (ll)temp.size()
#define len(temp) (ll)temp.length()
#define s(arr) sort(all(arr))
#define r(arr) reverse(all(arr))
#define rs(arr) s(arr) ; r(arr)
#define pi acos(-1)
#define con continue
#define endl "\n"
#define w(q) while(q--)
 
//debug
#define trace1(x)                cout<<#x<<": "<<x<<endl
#define trace2(x, y)             cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define trace7(a, b, c, d, e, f , g) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<< f << " | "<< #g <<": "<<g<<endl
#define trace8(a, b, c, d, e, f , g , h) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<< f << " | " << #g <<": "<< g <<" | "<<#h<< ": " << h << endl
 
typedef pair<int , int> pii;
typedef pair<int , pii> piii;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef vector<piii> vpiii;
 
signed main()
{
    FAST;
    int n;
    cin >> n;
    int ans = n - 1;
    ans = ans * n;
    ans /= 2;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<cstring>
#include<cctype>
#include<cstdio>
#include<map>
#define rep(i,x,y) for(int i=x; i<=y; ++i)

using namespace std;
typedef long long LL;
const int N=100005;
int n,p[N],siz[N],fa[N];
LL d[N],d_[N];
map <LL,int> s;

bool cmp(int x,int y)
{
	return d[x]>d[y];
}

int main()
{
	scanf("%d",&n);
	rep(i,1,n) scanf("%lld",&d[i]),p[i]=i,s[d[i]]=i;
	sort(p+1,p+1+n,cmp);
	rep(i,1,n-1)
	{
		++siz[p[i]];
		LL D=d[p[i]]-n+2*siz[p[i]];
		if(D>=d[p[i]] || !s.count(D)) {puts("-1"); return 0;}
		fa[p[i]]=s[D],siz[fa[p[i]]]+=siz[p[i]];
		d_[fa[p[i]]]+=d_[p[i]]+siz[p[i]];
	}
	if(d_[p[n]]!=d[p[n]]) puts("-1");
	else rep(i,1,n-1) printf("%d %d\n",p[i],fa[p[i]]);
	return 0;
}

Measured memory_bytes: 12304
/*
Author: Sagar Gupta
E mail: sagar.june97p@gmail.com
*/

#pragma comment(linker, "/STACK:268435456")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define endl ("\n")
#define deb(n) cerr << #n << " = " << (n) << '\n'
#define PI (3.141592653589)
#define ordered_set tree<int, null_type, std::less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define MOD 1000000007
using ll = long long;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed;
    cout.precision(15);
    // Those who forgive themselves, and are able to accept their true nature...THEY ARE THE STRONG ONES

    double a, b, h, m;
    cin >> a >> b >> h >> m;
    double minute = PI / 30 * m;
    double hour = PI / 6 * h + PI / 6 * m / 60;

    double x1, y1, x2, y2;
    x1 = a * cos(PI - hour);
    y1 = a * sin(PI - hour);
    x2 = b * cos(PI - minute);
    y2 = b * sin(PI - minute);

    cout << sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));

    return 0;
}

Measured memory_bytes: 4116
from collections import deque
n=int(input())
num=[[] for _ in range(n)]
for i in range(n-1):
    a,b,c=map(int,input().split())
    num[a-1].append([b,c])
    num[b-1].append([a,c])
q,k=map(int,input().split())
seen=[False]*n
queue=deque()
queue.append(k)
ans=[0]*n
seen[k-1]=True
for i in range(n):
    if len(queue)==0:
        break
    num1=queue.popleft()
    for j in range(len(num[num1-1])):
        num2=num[num1-1][j][0]
        if seen[num2-1]==False:
            queue.append(num2)
            seen[num2-1]=True
            ans[num2-1]=ans[num1-1]+num[num1-1][j][1]
for i in range(q):
    x,y=map(int,input().split())
    print(ans[x-1]+ans[y-1])


Measured memory_bytes: 51456
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = n;i >= m;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 999999999
#define MINF -999999999
#define ALL(n) n.begin(),n.end()
ll n, s, a[210000],b,cs, c = 0;

int main() {
	cin >> n >> s;
	REP(i, n) {
		cin >> b >> cs;
		a[b] += cs;
	}
	REP(i, 100010) {
		c += a[i];
		if (c >= s) {
			cout << i << endl;
			break;
		}

	}
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;

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

int n;
int a[100010];

bool is_inRange(int l, int r) {
    return (1<=l and r<=n);
}

int calc(int p) {
    int ret = 0;
    int l = p, r = p;
    while(is_inRange(l,r)) {
        if(a[l] != a[r]) return ret;
        int cnt = 0 , t = a[l];
        if(l == r) cnt = -1;

        while(1 <= l and a[l] == t) l--, cnt++;
        while(r <= n and a[r] == t) r++, cnt++;
        if(cnt >= 4) ret += cnt;
    }

    return ret;
}

int main() {
    while(cin>>n && n) {
        ZERO(a);
        FOR(i,1,n+1) scanf("%d",&a[i]); // 1-indexed

        int cnt = -1;
        FOR(pos, 1, n+1) {
            int tmp = a[pos];
            FOR(color, 1, 4) {
                if(color == tmp) continue;
                a[pos] = color;
                cnt = max(cnt, calc(pos));
            }
            a[pos] = tmp;
        }

        printf("%d\n", n - cnt);
    }

    return 0;
}

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

int N;
int A;
int B;
int C;
int L[8];
long long cost = 1000000000;

int calc(int num){

    int sumA = 0;
    int sumB = 0;
    int sumC = 0;
    bool afirst = false;
    bool bfirst = false;
    bool cfirst = false;

    string s = to_string(num);
    long long costSum = 0;
    for(int i = 0; i < N; i++){
        if(s[i] ==  '1'){
            if(afirst) costSum += 10;
            sumA += L[i];
            afirst = true;
        }
        if(s[i] ==  '2'){
            if(bfirst) costSum += 10;
            sumB += L[i];
            bfirst = true;
        }
        if(s[i] ==  '3'){
            if(cfirst) costSum += 10;
            sumC += L[i];
            cfirst = true;
        }
    }
    costSum = costSum + abs(sumA - A) + abs(sumB - B) + abs(sumC - C);
    if(costSum < cost && afirst && bfirst && cfirst){
        cost = costSum;
        //cout << s << endl;
    }


}

int search(int num, int depth){

    if(depth == N){
        calc(num);
        return 0;
    }

    search(10 * num + 1, depth + 1);
    search(10 * num + 2, depth + 1);
    search(10 * num + 3, depth + 1);
    search(10 * num + 4, depth + 1);

}



int main(){

    cin >> N;
    cin >> A;
    cin >> B;
    cin >> C;
    
    for(int i = 0; i < N; i++){
        cin >> L[i];
    }

    search(0, 0);
    cout << cost << endl;


}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[]args){
		Scanner sc=new Scanner(System.in);
		int k=1;
		while(k==1){
			int H=sc.nextInt();
			int W=sc.nextInt();
			if(H==0&&W==0)
				break;
			for ( int i = 0; i < H; i++ ){
			    for ( int j = 0; j < W; j++ ){
			        if(i==0||i==H-1||j==0||j==W-1)
			            System.out.print("#");
			        else
			            System.out.print(".");
			    }
			    System.out.println();
			}
			System.out.println();
		}
	}

}


Measured memory_bytes: 33848
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
/////////
#define R(i,n) for(int i=0;i<(n);++i)
/////////
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;

////定数
const int INF = (int)1e9 + 10;
const LL MOD = (LL)1e9 + 7;
const LL LINF = (LL)4e18 + 20;
const LD PI = acos(-1.0);
const double EPS = 1e-9; 
/////////
using namespace::std;
template<typename T>
void chmax(T& a, T b) {
	a = max(a, b);
}

template<typename T>
void chmin(T& a, T b) {
	a = min(a, b);
}

template<typename T>
void IN(vector<T> &A,int N=-1) {
	if (N == -1) {
		N = A.size();
	}
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
	}
}

template<typename T>
void SO(vector<T> &A,bool F=false) {
	sort(A.begin(), A.end());
	if (F) {
		reverse(A.begin(), A.end());
	}
}
//////////////

void solve() {
	int N, M, Q;
	cin >> N >> M >> Q;
	vector<vector<int>> A(N+1, vector<int>(N+1, 0));
	for (int i = 0; i < M; ++i) {
		int L, R;
		cin >> L >> R;
		A[L][R]++;
		/*
		A[L - 1][L - 1]--;
		A[L - 1][R]++;
		A[L - 1][R]--;
		A[R][R]++;*/
	}
	for (int h = 1; h <= N; ++h) {
		for (int w = 1; w <= N; ++w) {
			A[h][w] += A[h][w - 1];
		}
	}
	for (int w = 1; w <= N; ++w) {
		for (int h = 1; h <= N; ++h) {
			A[h][w] += A[h-1][w];
		}
	}
	while (Q--) {
		int p, q;
		cin >> p >> q;
		int res = A[q][q]-A[q][p-1]-A[p-1][q]+A[p-1][p-1];
		cout << res << endl;
	}
}

signed main(void) {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}

Measured memory_bytes: 1920
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<int, P> E;
#define gt first
#define gc second.first
#define gr second.second
#define MOD (1000000007ll)
#define l_ength size
#define PI 3.14159265358979

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	b += MOD;
	a += b;
	a %= MOD;
}

int main(void){
	int cnt[26],i,j,k;
	string s;
	bool flag = false;
	fill(cnt,cnt+26,0);
	cin >> s;
	for(i=(s.l_ength()-1); i>=0; --i){
		++cnt[s[i]-'a'];
	}
	if(s.l_ength() < 26){
		for(i=0; i<26; ++i){
			if(!cnt[i]){
				cout << s << ((char)('a'+i)) << endl;
				flag = true;
				break;
			}
		}
	}else{
		for(i=(s.l_ength()-1); i>=0; --i){
			for(j=((s[i]-'a')+1); j<26; ++j){
				if(!cnt[j]){
					for(k=0; k<i; ++k){
						cout << s[k];
					}
					cout << ((char)('a'+j)) << endl;
					flag = true;
					break;
				}
			}
			if(flag){
				break;
			}else{
				--cnt[s[i]-'a'];
			}
		}
	}
	if(!flag){
		cout << "-1" << endl;
	}
	return 0;
}


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

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> h(N);
    rep(i, N) cin >> h[i];

    vector<int> dp(N, 2000000001);
    dp[0] = 0;
    rep(i, N) for(int j=1; j<=K; j++) {
        if(i+j < N) dp[i+j] = min(dp[i+j], dp[i]+abs(h[i]-h[i+j]));
    }

    cout << dp[N-1] << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
#include <set>
#define MAXN 100005
#define INF 0x3f3f3f3f
#define p 1000000007
#define rint register int
#define LL long long
#define LD long double
using namespace std;

int n, cnt, head[MAXN], f[MAXN][2];

struct Edge {int next, to;} edge[MAXN*2];

void addedge(int from, int to)
{
	edge[++cnt].next=head[from];
	edge[cnt].to=to;
	head[from]=cnt;
}

void dfs(int x, int fa)
{
	f[x][0]=f[x][1]=1;
	for(rint i=head[x]; i; i=edge[i].next)
	{
		int to=edge[i].to;
		if(to==fa) continue;
		dfs(to, x);
		f[x][0]=1LL*f[x][0]*f[to][1]%p;
		f[x][1]=1LL*f[x][1]*(f[to][1]+f[to][0])%p;
	}
}

int main()
{
	scanf("%d", &n);
	for(rint i=1, x, y; i<n; ++i)
	{
		scanf("%d%d", &x, &y);
		addedge(x, y);
		addedge(y, x);
	}
	dfs(1, 0);
	printf("%d\n", (f[1][0]+f[1][1])%p);
	return 0;
}

Measured memory_bytes: 8448
#include<iostream>
#include<set>
using namespace std;
int main(){
 int n,k;
 cin >> k >> n;
 int a[n];
  int sum = 0;
  cin >> a[0];
  int maxlen = 0;
  for(int i=1;i<n;i++){
    cin >> a[i];
    if(a[i]-a[i-1]>maxlen) maxlen = a[i]-a[i-1];
    sum += a[i]-a[i-1];
  }
  if(k-a[n-1]+a[0]>maxlen) maxlen = k-a[n-1]+a[0];
  sum += k-a[n-1]+a[0];
  cout << sum - maxlen;
  
  
  
}

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

int main() {
  int a,b;
  cin >> a >> b;
  
  int X = a * b;
  int Y = X % 2;
    
  if (Y == 0){
    cout << "Even" << endl;
  }
  else{
    cout << "Odd" << endl;
  }
  
}


Measured memory_bytes: 256
#include <iostream> // cin, cout, cerr
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota
#include <cstdio> // printf, scanf
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <iomanip> // cout<<setprecision(n)
#include <functional> // function<void(int)>
#include <cmath>
#include <cassert>
#include <bitset>

#ifdef DEBUG
#include "debug.hpp"
#else
#define debug(...)
#endif

#define int long long // at least int64 > 9*10^18
#define EL '\n'
#define rep(i,n) for(int i = 0; i < (n); i++)
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
/* libraries */

// ceil of a/b
inline int ceil(int a, int b) { return (a+b-1)/b; }

signed main() {
	int n,a,b;
	std::cin >> n >> a >> b;
	if(n-b+1<a || a<ceil(n,b)) {
		print(-1);
		return 0;
	}
	if(n==a) {
		for(int i=1;i<=n;i++) std::cout << i << ' ';
		std::cout << EL;
	} else {
		int x=(n-a)/(b-1);
		int y=a-ceil(n-a,b-1);
		int i=1;
		rep(j,y) std::cout << i++ << ' ';
		rep(j,x) {
			i+=b;
			rep(k,b) std::cout << i-k-1 << ' ';
		}
		int j=n;
		while(j>=i) std::cout << j-- << ' ';
		std::cout << EL;
	}
	return 0;
}


Measured memory_bytes: 2176
#include<stdio.h>
#include<string.h>
 
#define M 1046527
#define L 14
 
char H[M][L]; /* Hash Table */
 
int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
}
 
/* convert a string into an integer value */
long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}
 
int h1(int key){ return key%M; }
int h2(int key){ return 1+(key%(M-1)); }
 
int find(char str[]){
  long long key,i,h;
  key=getKey(str);
  for(i=0;;i++){
    h=(h1(key)+i*h2(key))%M;
    if(strcmp(H[h],str)==0)return 1;
    else if(strlen(H[h])==0)return 0;
  }
  return 0;
}
    
 
int insert(char str[]){
  long long key,i,h;
  key=getKey(str);
  for(i=0;;i++){
    h=(h1(key)+i*h2(key))%M;
    if(strcmp(H[h],str)==0)return 1;
    else if(strlen(H[h])==0){
      strcpy(H[h],str);
      return 0;
    }
  }
  return 0;
 
}
 
int main(){
    int i, n, h;
    char str[L], com[9];
    for ( i = 0; i < M; i++ ) H[i][0] = '\0';
     
    scanf("%d", &n);
     
    for ( i = 0; i < n; i++ ){
    scanf("%s %s", com, str);
     
    if ( com[0] == 'i' ){
        insert(str);
    } else {
        if (find(str)){
        printf("yes\n");
        } else {
        printf("no\n");
        }
    }
    }
 
    return 0;
}

Measured memory_bytes: 16040
# A - Five Antennas
import itertools
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
k=int(input())

for v in itertools.combinations([a,b,c,d,e],2):
    if (abs(v[1]-v[0])>k):
        print(":(")
        exit()

print("Yay!")



Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int l, r, d;
  cin >> l >> r >> d;
  int ans = 0;
  rep2(i, l, r+1){
    if(i % d == 0) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3632
function Main (input) {
  let x = input.split(" ")[0], y = input.split(" ")[1];
  
  let bool = false;
  for (let crane = 0; crane <= x; crane++) {
    if (crane * 2 + (x - crane) * 4 == y) {
      bool = true;
      console.log("Yes");
      break;
    }
  }
  
  if (!bool) console.log("No");
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 29624
read a b h m
d=$((m*12-h*60-m))
pi=`echo "scale=13;a(1)*4" | bc -l`
v="scale=13;sqrt(${a}*${a}+${b}*${b}-2*${a}*${b}*c(${d}/2/180*${pi}))"
echo $v | bc -l


Measured memory_bytes: 3780
//Built by Sabuj Jana(greenindia) from Jadavpur University,Kolkata,India 
// God is Great------------/////\\\\\\\--------------------------------
 #include <bits/stdc++.h>
 using namespace std;
 #define crap ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
 #define endl "\n"
 #define INF LLONG_MAX
 #define pb push_back
 #define mp make_pair
 #define F(i,a,b) for (ll i=a;i<=b;i++)
 
 typedef long long ll;
 typedef vector<ll> vi;
 	 
 int main() {
 	 
    crap;
                  
     ll n; cin>>n;
     ll arr[n+7];
     //~ arr[0]=0;
		for(ll i=1; i<=n; i++){
			
			cin>>arr[i];
		}
     arr[0]=arr[1];
     ll dp[n+7];
     dp[0]=0;dp[1]=0;
     for(ll i=2; i<=n; i++){
		 
		 dp[i]= min( dp[i-1]+ abs(arr[i]-arr[i-1]), dp[i-2]+ abs(arr[i]-arr[i-2]) );
		 
	 }
      
      cout<<dp[n]<<endl;
      
    return 0;
 }



Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>; // グラフ型
typedef long long ll;
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i = 0; i < (n); ++i)

int main() {
  ll X;
  cin>>X;
  
  for(ll A=-3000;A<=3000;A++){
      for(ll B=-3000;B<=3000;B++){
          if(A*A*A*A*A-B*B*B*B*B==X){
              cout<<A<<" "<<B<<endl;
              return 0;
          }
      }
  }
}


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

int main() {
    int x, y, z;
    cin >> x >> y >> z;
    cout << z << " " << x << " " << y << endl;
    return 0;
}

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

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);

    int N, Q;
    string S;
    cin >> N >> Q >> S;
    int countac[N];
    countac[0] = 0;
    int count = 0;
    for(int i=1; i<N; i++){
        if(S[i-1] == 'A' && S[i] == 'C'){
            count ++;
        
        }
        countac[i] = count;
    }

    int begin, end;

    for(int i=0; i<Q; i++){
        cin >> begin >> end;
        if(begin == 1){
            cout << countac[end-1] << '\n';
        }else{
            if(S[begin-2] == 'A' && S[begin-1] == 'C'){
                cout << countac[end-1] - countac[begin-2] - 1 << '\n';
            }else{
                cout << countac[end-1] - countac[begin-2] << '\n';
            }
        }
    }

    
    return 0;
}

Measured memory_bytes: 1488
use std::io::stdin;

fn read_line() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim().to_string()
}

fn main() {
    let mut input: Vec<i32> = read_line()
        .split_whitespace()
        .map(|n| n.parse::<i32>().unwrap())
        .collect();
    let k: i32 = read_line()
        .parse::<i32>().unwrap();
    let pos: usize = input.iter().position(|n| n == input.iter().max().unwrap()).unwrap();

    for _ in 0 .. k {
        input[pos] = input.iter().max().unwrap() * 2;
    }

    let sum: i32 = input.iter().sum();
    println!("{}", sum);
}


Measured memory_bytes: 4352
#include <iostream>
#include <stdio.h>
using namespace std;

int main()
{
  int a,b,d,r;
  double f;

  cin >> a >> b;
  d = a / b;
  r = a % b;
  f = (double)a / (double)b;

  printf("%d %d %lf\n",d,r,f);

  return 0;
}

Measured memory_bytes: 3200
n,k=map(int,input().split())
d=[]
al=[]
a=[0]*k
for i in range(k):
  d.append(int(input()))
  a[i]=input().split()
  for j in range(d[i]):
    al.append(a[i][j])
  
al=set(al)
print(str(n-len(al)))

Measured memory_bytes: 9724
import java.util.HashMap;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long N = sc.nextLong();

        HashMap<Long, Long> numCount = new HashMap<>();
        long sum = 0;
        for (var i=0; i<N; i++) {
            long a = sc.nextLong();
            sum+= a;
            if (numCount.containsKey(a))
                numCount.put(a, numCount.get(a) + 1);
            else
                numCount.put(a, (long) 1);
        }
        long Q = sc.nextLong();
        for (var i=0; i<Q; i++) {
            long b = sc.nextLong();
            long c = sc.nextLong();
            long bCount = numCount.getOrDefault(b, (long) 0);
            long cCount = numCount.getOrDefault(c, (long) 0);

            sum += (c - b) * bCount;
            numCount.put(b, (long)0);
            numCount.put(c, bCount + cCount);
            System.out.println(sum);
        }
    }
}

Measured memory_bytes: 66256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
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; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll N,M;
    cin >>N>>M;
    ll l,r;
    l=0;r=N+M;
    ll now;
    map<ll,bool>m;
    while(1){
        ll flag=0;
        now=(l+r)/2;
        if(now*2>M){
            flag=1;
        }else if((M-now*2)/2+N<now){
            flag=1;
        }

        if(flag==1){
            r=now-1;
            if(m[now]==1){
                r--;
            }
        }else{
            l=now+1;
            if(m[now]==1){
                cout<<now<<endl;
                return 0;
            }
        }
        m[now]=1;

    }
    
  


    return 0;
    

}

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

int main(void){
	long long int N,a[100];
	cin >> N;
		a[0]=2;
		a[1]=1;
	for(int i=2;i<=N;i++){
		a[i]=a[i-1]+a[i-2];
	}
	cout << a[N] << endl;
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env ruby
K=gets.to_i
A,B=gets.split(/ /).map{|s| s.to_i}

# exists nK \in [A,B]?

base = A / K

if K * base == A
  puts "OK"
elsif K * (base+1) <= B
  puts "OK"
else 
  puts "NG"
end


Measured memory_bytes: 14336
#include<bits/stdc++.h>
using namespace std;
const int MOD = 1e9+7;

class solution{
public:
    long long pairProduct(vector<int>& A, int n){
        unsigned long long sum=0;
        for(int i=0; i<n; ++i) sum+=A[i];
        long long ans=0;
        for(int i=0; i<n; ++i){
            sum-=A[i];
            ans = (ans + ((sum%MOD)*(A[i]%MOD))%MOD)%MOD;
        }
        return ans;
    }
};

int main(){
    int n;
    cin>>n;
    vector<int> A(n);
    for(int i=0; i<n; ++i) cin>>A[i];
    solution solve = solution();
    long long ans = solve.pairProduct(A, n);
    cout<<ans<<"\n";
}

Measured memory_bytes: 4032
#include <numeric>
#include<iostream>
#include<set>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include<algorithm>
#include <sstream>
#include<string>
#include <cmath>
#include <iomanip>
#include <string>
#include<list>
#include<string.h>
#include<memory.h>
using namespace std;
#define inf 1000000007
#define int long long
#define rep(i,j,n) for(int i=j;i<n;i++)
typedef pair<int,int>  P;
double pi = 3.141592653589793;
//ここから下

signed main(){
char c[3][3];
rep(i,0,3){
    rep(j,0,3){
        cin>>c[i][j];
    }
}
    cout<<c[0][0]<<c[1][1]<<c[2][2]<<endl;
    return 0;
    
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int A, B, K;
    cin >> A >> B >> K;

    if (2 * K > B - A + 1) {
        for (int i = A; i <= B; ++i) {
            cout << i << endl;
        }
    } else {
        for (int i = A; i <= A + K - 1; ++i) {
            cout << i << endl;
        }

        for (int j = B - K + 1; j <= B; ++j) {
            cout << j << endl;
        }
    }

}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>
#include <chrono>
#include <ctime>
#include <bitset>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define P pair<int, int>
#define debug(x) cerr << #x << ": " << x << ", "
#define debugln(x) cerr << #x << ": " << x << '\n'

using namespace std;
using ll = long long;
const ll mod = 1e9+7;

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

  int a, b; cin >> a >> b;
  if (a+b >= 10) {
    cout << "error" << endl;
  } else {
    cout << a+b << endl;
  }
}

Measured memory_bytes: 256
n = int(input())
l = list(map(int, str(n)))[::-1]

def rec(s, keta):
    global ans
    if keta == -1:
        ans = max(ans, s)
        return

    rec(s+l[keta], keta-1)
    if l[keta]:
        tmp = s + l[keta]-1 + 9*keta
        ans = max(ans, tmp)

ans = 0
rec(0, len(l)-1)
print(ans)

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

void f(int n){
  int ans=10000000;
  for(int i=0;i*i*i<=n;i++){
    for(int j=0;i*i*i+j*j<=n;j++){
      int k=n-i*i*i-j*j;
      if(k<0) continue;
      ans=min(ans,i+j+k);
    }
  }

  cout<<ans<<endl;
}

main(){
  int n;
  while(true){
    cin>>n;
    if(n==0) break;
    f(n);
  }
}



Measured memory_bytes: 3080
/***************************************************
 * Problem Name : C - Vacation.cpp
 * Problem Link :
 * OJ           :
 * Verdict      : Trying
 * Date         : 2019-01-26
 * Problem Type :
 * Author Name  : Saikat Sharma
 * University   : CSE, MBSTU
 ***************************************************/
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<climits>
#include<cstring>
#include<string>
#include<sstream>
#include<cmath>
#include<vector>
#include<queue>
#include<cstdlib>
#include<deque>
#include<stack>
#include<map>
#include<set>
#define __FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define FileRead freopen ("/home/saikat/Desktop/logN/input.txt", "r", stdin);
#define FileWrite freopen ("/home/saikat/Desktop/logN/output.txt", "w", stdout);
#define SET(a,v) memset(a,v,sizeof(a))
#define pii pair<int,int>
#define pll pair <ll, ll>
#define debug cout <<"#########\n";
#define nl cout << "\n";
#define sp cout << " ";
#define sl(n) scanf("%lld", &n)
#define sf(n) scanf("%lf", &n)
#define si(n) scanf("%d", &n)
#define ss(n) scanf("%s", n)
#define pf(n) scanf("%d", n)
#define pfl(n) scanf("%lld", n)
#define all(v) v.begin(), v.end()
#define Pow2(x) ((x)*(x))
#define Mod(x, m) ((((x) % (m)) + (m)) % (m))
#define Max3(a, b, c) max(a, max(b, c))
#define Min3(a, b, c) min(a, min(b, c))
#define pb push_back
#define mk make_pair
#define MAX 1000005
#define INF 1000000000
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

template <typename T>
std::string NumberToString ( T Number ) {
    std::ostringstream ss;
    ss << Number;
    return ss.str();
}
ll lcm (ll a, ll b) {
    return a * b / __gcd (a, b);
}
/************************************ Code Start Here ******************************************************/
int ar[MAX][5];
int dp[MAX][5];
int n;
int fun (int i, int t) {
    //~ debug;
    if (i == n - 1) {
        return ar[i][t];
    }

    if (dp[i][t] != -1) return dp[i][t];

    int ret1 = 0, ret2 = 0;

    if (t == 0) {
        ret1 = ar[i][t] + fun (i + 1, 1);
        ret2 = ar[i][t] + fun (i + 1, 2);

    } else if (t == 1) {
        ret1 = ar[i][t] + fun (i + 1, 0);
        ret2 = ar[i][t] + fun (i + 1, 2);

    } else {
        ret1 = ar[i][t] + fun (i + 1, 0);
        ret2 = ar[i][t] + fun (i + 1, 1);
    }

    return dp[i][t] = max (ret1, ret2);
}
int main () {
    //~ __FastIO;
    //~ int n;
    cin >> n;

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 3; j++) {
            cin >> ar[i][j];
        }
    }

    //~ debug;
    SET (dp, -1);
    int a = fun (0, 0);
    //~ debug;
    int b = fun (0, 1);
    int c = fun (0, 2);
    cout << Max3 (a, b, c) << "\n";
    return 0;
}


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

int main() {
    int a, b;
    scanf("%d%d", &a, &b);
    int t = b;
    int tmp = 1;
    while(t) t/=10, tmp*=10;
    t = a*tmp+b;
    int c = sqrt(t);
    if(c*c == t) puts("Yes");
    else puts("No");
}


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

int main() {
	int a, b, c, x, cnt = 0;
	cin >> a >> b >> c >> x;
	a++, b++, c++;
	rep(i, a) {
		rep(j, b) {
			rep(k, c) {
				if (500 * i + 100 * j + 50 * k == x) cnt++;
			}
		}
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
n=int(input())
ss=list(input())
mod=10**9+7
import collections

"""
ss=[s[0]]

for i in range(1,n):
    if s[i]!=s[i-1]:
        ss.append(s[i])
"""
#print(ss)

c = collections.Counter(ss)

result=1
for k in c.keys():
    result=result*(c[k]+1)%mod

print((result-1)%mod)




Measured memory_bytes: 49520
#include <iostream>
#include <string>
using namespace std;
int main() {
    string s,t;
    int ans = 0;
    cin >> s >> t;
    for(int i = 0; i < s.length(); i ++){
        if(s[i] != t[i]) ans ++;
    }
    cout << ans;
    return 0;
}

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

using namespace std;

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

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()
#define sortAl(v) sort(all(v))
#define sortAlr(v)          \
  sort(v.begin(), v.end()); \
  reverse(v.begin(), v.end())

#define cout(n) cout << fixed << setprecision(n)

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T &a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T &a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
#define INF LLONG_MAX

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

  string s;
  cin >> s;

  rep(i, s.length()) {
    cout << 'x';
  }

  cout << endl;

  return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

const int MOD = 1000000007;

long long solve(const vector<int>& a)
{
    int n = a.size();
    vector<int> b(n);
    b[0] = a[0];
    for(int i=1; i<n; ++i)
        b[i] = a[i] ^ b[i-1];

    long long ans = 1;
    if(b.back() == 0){
        for(int i=0; i<n-1; ++i){
            if(b[i] == 0){
                ans *= 2;
                ans %= MOD;
            }
        }
    }

    int cnt = 0;
    map<long long, long long> dp1, dp2, prev;
    for(int i=0; i<n; ++i){
        if(b[i] == 0){
            ++ cnt;
        }
        else{
            dp1[b[i]] += dp2[b[i]] * (cnt - prev[b[i]]);
            dp1[b[i]] %= MOD;
            prev[b[i]] = cnt;
            dp2[b[i]] += dp1[b[i]] + 1;
            dp2[b[i]] %= MOD;
        }
    }
    if(b.back() == 0){
        for(const auto& p : dp2){
            ans += p.second;
            ans %= MOD;
        }
    }
    else{
        ans += dp1[b.back()];
        ans %= MOD;
    }
    return ans;
}

long long solve2(const vector<int>& a)
{
    int n = a.size();
    int ans = 0;
    for(int i=0; i<(1<<(n-1)); ++i){
        bitset<32> bs(i);
        set<int> s;
        int x = 0;
        for(int j=0; j<n; ++j){
            x ^= a[j];
            if(!bs[j]){
                s.insert(x);
                x = 0;
            }
        }
        if(s.size() == 1)
            ++ ans;
    }

    return ans;
}

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i=0; i<n; ++i)
        cin >> a[i];

    cout << solve(a) << endl;

    return 0;
}


Measured memory_bytes: 57984
#include <iostream>

using namespace std;

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

int main() {
  int n;
  cin >> n;
  string s, t;
  cin >> s >> t;
  rep(i,n) cout << s[i] << t[i];
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
 
  int a = A + B;
  int b = C + D;
  
  if( a > b ){
    cout << "Left" << endl;
  } else if (a < b) {
    cout << "Right" << endl;
  } else {
    cout << "Balanced" << endl;
  }
}

Measured memory_bytes: 256
h,w=map(int,input().split())
C=[list(map(int,input().split())) for _ in range(h)]
DP=[[0 for _ in range(w)] for _ in range(h)]

for i in range(w):
    if C[0][i]==0:DP[0][i]=1
    else:DP[0][i]=0

for i in range(1,h):
    for j in range(w):
        if C[i][j]==0:DP[i][j]=DP[i-1][j]+1
        else:DP[i][j]=0

cost=0
for i in range(h):
    stack=[]
    for j in range(w):
        if len(stack)==0:
            stack.append((DP[i][j],j))
        elif DP[i][j]>stack[-1][0]:
            stack.append((DP[i][j],j))
        elif DP[i][j]<stack[-1][0]:
            add=0
            while DP[i][j]<stack[-1][0]:
                rect,pos=stack.pop()
                cost=max(cost,(j-pos)*rect)
                add=pos
                if len(stack)==0:break
            stack.append((DP[i][j],add))

    if len(stack)!=0:
        while len(stack)!=0:
            rect,pos=stack.pop()
            cost=max(cost,(w-pos)*rect)

print(cost)


Measured memory_bytes: 63864