akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cstdio>
using namespace std;
typedef long long ll;
const int N=2e3;

int main()
{
	string s;
	
	getline(cin,s);
		int op=0;
		int a=0,b=0;
		for(int i=0;i<s.length();i++)
		{
			if(s[i]==' ')
			continue;
			if(s[i]=='+')
			{
				op=1;
				continue;
			}
			if(s[i]=='-')
			{
				op=2;
				continue;
			}
			if(op==0)
			a=a*10+s[i]-'0';
			else
			b=b*10+s[i]-'0';
		}
		if(op==1)
		cout<<ll(a+b)<<endl;
		else
		cout<<a-b<<endl;
	
	return 0;	
} 

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

using namespace std;
typedef long long ll;
const ll mod=1000000007;

ll powmod(ll x,ll y){
    ll res=1;
    for(ll i=0;i<y;i++){
        res=res*x%mod;
    }
    return res;
}

int main()
{
    ll N = 0;
    cin >> N;
    ll ans = powmod(10, N) - powmod(9, N) - powmod(9, N) + powmod(8, N);
    ans %= mod;
    ans = (ans+mod)%mod;
    cout << ans << endl;
}

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

signed main(){
  int n,i,sum=0;
  map<string,int> count;
  vector<string> v;
  cin>>n;
  for(i=0;i<n;i++){
    string s;
    cin>>s;
    sort(s.begin(),s.end());
    v.push_back(s);
  }
  for(i=0;i<n;i++){
    count[v[i]]++;
  }
  map<string,int>:: iterator it;
  for(it=count.begin();it!=count.end();it++){
    int y=it->second;
    sum+=y*(y-1)/2;
  }
  cout<<sum;
}


Measured memory_bytes: 12020
data =input()
data = list(data)
deter =""
cnt2 =0
cnt =[0]*5
cnt3 =0
for t in range(len(data)):
  if data[t] =="I":
    cnt[0] +=1
  if data[t] =="K":
    cnt[1] +=1
  if data[t] =="H":
    cnt[2] +=1
  if data[t] =="B":
    cnt[3] +=1
  if data[t] =="R":
    cnt[4] +=1
  
if cnt[0] ==1 and cnt[1] ==1 and cnt[2] ==1 and cnt[3] ==1 and cnt[4] ==1:
  cnt2 +=1 

if len(data) >9 or cnt2 ==0 :
  print("NO")
  cnt3 +=1
if len(data) >=5 and len(data)<=9  and cnt2 ==1:
  if data[0] !="A":
    data.insert(0,"A")
  if data[4] !="A":
    data.insert(4,"A")
  if data[6] !="A":
    data.insert(6,"A")
  if len(data) ==8:
    data.append("A")
  else:
    if data[8] !="A":
      data.insert(8,"A")
 
  for s in range(len(data)):
    deter +=data[s]
  
  if deter =="AKIHABARA":
    print("YES")
  else:
    print("NO")

 
if len(data) <=4 and cnt3==0:
  print("NO")


Measured memory_bytes: 3064
/***************************************** 
****       Solution by SlavicG        ****
*****************************************/
 
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm> 
#include <set>
#include <utility>
#include <queue>
#include <map>
#include <assert.h>
#include <stack>
using namespace std;
#define ll long long
#define forn(i,n) for(int i=0;i<n;++i)
#define MX 10000000001
#define pow2(a) ((a)*(a))
#define pb push_back
#define pf push_front
#define all(v) v.begin(), v.end()
#define endl "\n"
#define FAST std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
 int longestIncreasingSubsequenceLenghtDP(int a[],int n){
    int dp[n],ans=0;
    for(int k = 0;k<n;k++){
        dp[k] = 1;
        for(int i = 0;i<k;i++){
            if(a[i] <= a[k]){
                dp[k] = max(dp[k],dp[i] + 1);
                ans = max(dp[k],ans);
            }
        }
    }
    return ans;
 }
int result[1000] = {0};
int factDP(int n) 
{
   if (n >= 0) {
      result[0] = 1;
      for (int i = 1; i <= n; ++i) {
         result[i] = i * result[i - 1];
      }
      return result[n];
   }
}
bool checkPrime(int n)
{
    if(n<2) return false;
    for(int x = 2;x*x <=n;x++)
    {
        if(n%x == 0)return false;
    }
    return true;
}
vector<int> primeFactors(int n){
    vector<int> f;
    for(int x = 2;x*x<=n;x++){
        while(n%x==0){
            f.push_back(x);
            n/=x;
        }
    }
    if(n>1)f.push_back(n);
    return f;
}
int binary_Search_Classic(int n, int arr[],int target){
	int l,r,mid;
	l=0;
	r=n-1;
	while(l<=r){
		mid= l+(r-l)/2;
		if(arr[mid] == target){
			return mid;
		}
		if(arr[mid] < target){
			l=mid+1;
		}else{
			r=mid-1;
		}
	}
	return -1;
	
}
int binary_Search_First_Greater(int n, int arr[],int target){
	int l,r,ans,mid;
	l = 0;
	r = n-1;
	ans=-1;
	while(l<=r){
		mid = l + (r-l)/2;
		if(arr[mid] > target){
			ans=mid;
			r=mid-1;
		}else{
			l = mid+1;
		}
	}
	return ans;
}
int countDistinctCharsString(string s) {
    unordered_map<char, int> m; 
    for (int i = 0; i < s.length(); i++) { 
        m[s[i]]++; 
    }
    return m.size(); 
} 
int main()
{
	string s;
	cin >> s;
	if(s[0] >= 'a' && s[0] <='z')
	{
		cout << "a" << endl;
	}else{
		cout << "A" << endl;
	}
	return 0;
}

Measured memory_bytes: 3588
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <string.h>

using namespace std;

// #define for(i,a,b) for (int i=(a);i<(b);++i)
typedef long long ll;
typedef pair<ll,ll> P;
#define REP(i,n) for(long long i = 0; i < (long long)(n); i++)
#define pb push_back // vectorに要素追加
#define INF (ll)1e18

ll mod = 1e9+7;
  
// 検索タグ
int main() {
	// 入力
	ll K,X;cin>>K>>X;
    
	// 解法
	bool ans = (K*500>=X);

	//出力
	if (ans) printf("Yes\n");
	else printf("No\n");
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
typedef long long ll;
typedef unsigned int uint;
using namespace std;

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

    int N, C;
    cin >> N >> C;
    int D[C][C];
    int t[3][C];
    for (int i = 0; i < C; i++) {
        for (int j = 0; j < C; j++) {
            cin >> D[i][j];
        }
    }

    fill(t[0], t[2]+C, 0);
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            int c;
            cin >> c;
            c--;
            t[(i+j)%3][c]++;
        }
    }

    int cost = 1000000007;
    for (int i = 0; i < C; i++) {
        for (int j = 0; j < C; j++) {
            if (i == j) continue;
            for (int k = 0; k < C; k++) {
                if (i == k || j == k) continue;

                int tmp = 0;
                for (int l = 0; l < C; l++) {
                    tmp += t[0][l] * D[l][i];
                }
                for (int l = 0; l < C; l++) {
                    tmp += t[1][l] * D[l][j];
                }
                for (int l = 0; l < C; l++) {
                    tmp += t[2][l] * D[l][k];
                }

                cost = min(cost, tmp);
            }
        }
     }

    cout << cost << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n;
const int N = 1e5 + 2;
int mem[N];
int arr[N];
void init() {
    mem[0] = 0;
    mem[1] = abs(arr[1] - arr[0]);
    for (int i = 2; i < N; i++) {
        mem[i] = -1;
    }
}
int findshortest() {
    for (int i = 2; i < n; i++) {
        mem[i] = min(mem[i-1] + abs(arr[i] - arr[i-1]), mem[i-2] + abs(arr[i] - arr[i-2]));
    }
    return mem[n - 1];
}
int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> arr[i];
    }
    init();
    cout << findshortest();

    

}

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

struct UnionFind{
    vector<int> r;
    
    UnionFind(int n){
        r = vector<int> (n, -1);
    }

    int root(int x){
        if(r[x] < 0){
            return x;
        }
        return r[x] = root(r[x]);
    }

    bool unite(int x, int y){
        x = root(x);
        y = root(y);

        if(x == y){
            return false;
        }

        if(x > y){
            swap(x, y);
        }
        r[x] += r[y];
        r[y] = x;
        return true;
    }

    int size(int x){
        return -r[root(x)];
    }
};


int main(){
    int N, K, L;
    cin >> N >> K >> L;

    UnionFind car(N);
    UnionFind train(N);
    for(int i=0; i<K; i++){
        int p, q;
        cin>> p >> q;
        p--;
        q--;
        car.unite(p, q);
    }

    for(int i=0; i<L; i++){
        int r, s;
        cin >> r >> s;
        r--;
        s--;
        train.unite(r, s);
    }

    map<pair<int, int>, int> dic;
    for(int i=0; i<N; i++){
        dic[{car.root(i), train.root(i)}]++;
    }

    for(int i=0; i<N; i++){
        cout<<dic[{car.root(i), train.root(i)}];
        if(i<N-1){
            cout<<" ";
        }else{
            cout<<endl;
        }
    }

    return 0;
}

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

int main() {
    int A, B, C;
    cin >> A >> B >> C;
    if(A+B+C==17 && A*B*C==5*5*7){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  #define ll long long int
  
  ll n,a,b;
  cin>>n>>a>>b;
  ll ans  = (n/(a+b))*a;
  
  if(n%(a+b)>=a)
    ans+=a;
  else
    ans+=(n%(a+b));
  cout<<ans<<endl;
}

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

int main() {
    int n;
    cin >> n;
    
    int ans;
    if(n % 1000 == 0){
        ans = 0;
    }else ans = 1000 - (n % 1000);
    
    cout << ans << endl;
    
}

Measured memory_bytes: 3612
#!/usr/bin/env python
from __future__ import division, print_function

import os
import sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip


def main():
    r = int(input())
    print(r ** 2)


# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()


if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()


Measured memory_bytes: 29548
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long int a,b,c,d,e;
  cin>>a>>b;
  c=a+b;
  d=a-b;
  e=a*b;
  if(c>=d && c>=e)
    cout<<c;
  else if(d>=c && d>=e)
    cout<<d;
  else
    cout<<e;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;

int n,k;
ll A[100010];

bool f(ll p){
	ll temp=p;
	int x=0;
	for(int i =0;i<k;i++){
		while(temp>=A[x]){
			temp-=A[x];
			x++;
		}
		temp=p;
	}
	if(x>=n) return true;
	else return false;
}

ll binary_find(ll left,ll right){
	ll mid;
	while(left+1<right){
		mid=(left+right)/2;
		if(f(mid)) right=mid;
		else left=mid;
	}
	return right;
}

int main(){
	ll p,sum;
	cin>>n>>k;
	for(int i = 0;i<n;i++){
		cin>>A[i];
		sum+=A[i];
	}
	p=binary_find(0,sum);
	cout<<p<<endl;
	return 0;
}


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

int sum(int n) {
	int s = 0;
  while(n > 0) {
  	s += n % 10;
    n /= 10;
  } 
  return s;
}

int main() {
  int n;
  cin >> n;
  int mini = 10000;
  for (int i = 1; i < n/2 + 1; i++) {
  	mini = min(mini, sum(i) + sum(n-i));
  }
  
  cout << mini << endl;
}



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

int main() {
	char s[20];
	int a,b,len;
	int flag=1;
	cin>>a>>b;
	cin>>s;
	len=strlen(s);
	if(a+b+1!=len) printf("No\n");
	else {
		if(s[a]!='-') printf("No\n");
		else {
			for(int i=0; i<a; i++) {
				if(s[i]<'0'||s[i]>'9') {
					flag=0;
					printf("No\n");
					break;
				}
			}
			if(flag!=0) {
				for(int j=a+1; j<len; j++) {
					if(s[j]<'0'||s[j]>'9') {
						flag=0;
						printf("No\n");
						break;	
					}

				}
			}
			if(flag==1) printf("Yes\n");
		}
	}
	return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

N=int(input())
C=[]
MAX=-1
for i in range(N):
    c=int1(input())
    MAX=max(MAX,c)
    if not C or (C and C[-1]!=c):
        C.append(c)
M=len(C)
dp=[0]*(M+1)
dp[0]=1
last=[-1]*(MAX+1)
for i in range(M):
    if last[C[i]]!=-1:
        dp[i+1]+=dp[i]+dp[last[C[i]]]
    else:
        dp[i+1]=dp[i]
    dp[i+1]%=MOD
    last[C[i]]=i+1
print(dp[-1])

Measured memory_bytes: 53212
#include<iostream>
#include<algorithm>
#include<climits>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define scan(arg) cin>>arg
#define prin(arg) cout<<arg<<"\n"
#define prin2(arg1,arg2) cout<<arg1<<" "<<arg2<<"\n"
using namespace std;
typedef long long ll;
int n,q;
string s;
int l[100010],r[100010];
int main(){
  cin>>n>>q;
  cin>>s;
  rep(i,q){
    cin>>l[i]>>r[i];
  }
  int S[100010];
  S[0]=S[1]=0;
  for(int i=2;i<=n;i++){
    if(s[i-1]=='C'&&s[i-2]=='A'){
      S[i]=S[i-1]+1;
    }
    else{
      S[i]=S[i-1];
    }
  }
  rep(i,q){
    prin(S[r[i]]-S[l[i]]);
  }

  

  return 0;
}


Measured memory_bytes: 2176
// This amazing code is by Eric Sunli Chen.
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
using namespace std;
template<typename T> void get_int(T &x)
{
	char t=getchar();
	bool neg=false;
	x=0;
	for(; (t>'9'||t<'0')&&t!='-'; t=getchar());
	if(t=='-')neg=true,t=getchar();
	for(; t<='9'&&t>='0'; t=getchar())x=x*10+t-'0';
	if(neg)x=-x;
}
template<typename T> void print_int(T x)
{
	if(x<0)putchar('-'),x=-x;
	short a[20]= {},sz=0;
	while(x>0)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1; i>=0; i--)putchar('0'+a[i]);
}
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define get1(a) get_int(a)
#define get2(a,b) get1(a),get1(b)
#define get3(a,b,c) get1(a),get2(b,c)
#define printendl(a) print_int(a),puts("")
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<int,int> pii;
const int inf=0x3f3f3f3f;
const LL Linf=1ll<<61;
const double pi=acos(-1.0);

char s[111];
int n,a[111];
int main()
{
	scanf("%s",s+1);n=strlen(s+1);
	for(int i=1;i<=n;i++)a[i]=1<<(s[i]-'a');
	for(int i=0;i<n;i++)
	{
		int all=(1<<26)-1;
		for(int j=1;j<=n-i;j++)all&=a[j];
		if(all)
		{
			printf("%d\n",i);
			break;
		}
		for(int j=1;j<n-i;j++)a[j]|=a[j+1];
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#include <limits>
#include <cmath> 
using namespace std;

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

    int ans=0;
    for(int i=0;i<n;i++){
        int s=1;
        while(s<=d){
            ans++;
            s+=a[i];
        }
    }
    ans+=x;
    cout<<ans<<endl;
}

Measured memory_bytes: 256
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
N = int(input())
xtoy = [-1]*(10**5+1)
uf = UnionFind(10**5+1)
xy = []
for i in range(N):
    x,y = map(int,input().split())
    if xtoy[x] == -1:
        xtoy[x] = y
    xy.append((x,y))
for x,y in xy:
    uf.union(y,xtoy[x])
ans = -N
for i in range(10**5+1):
    if xtoy[i] != -1:
        ans += uf.size(xtoy[i])
print(ans)

Measured memory_bytes: 86432
# -*- coding: utf-8 -*-

import collections
import math


class Vector2(collections.namedtuple("Vector2", ["x",  "y"])):

    def __add__(self, other):
        return Vector2(self.x + other.x, self.y + other.y)

    def __sub__(self, other):
        return Vector2(self.x - other.x, self.y - other.y)

    def __mul__(self, scalar):
        return Vector2(self.x * scalar, self.y * scalar)

    def __neg__(self):
        return Vector2(-self.x, -self.y)

    def __pos__(self):
        return Vector2(+self.x, +self.y)

    def __abs__(self):  # norm
        return math.sqrt(float(self.x * self.x + self.y * self.y))

    def dot(self, other):  # dot product
        return self.x * other.x + self.y * other.y

    def cross(self, other):  # cross product
        return self.x * other.y - self.y * other.x


def getDistanceSP(segment, point):
    p = point
    p1, p2 = segment
    if (p2 - p1).dot(p - p1) < 0:
        return abs(p - p1)
    if (p1 - p2).dot(p - p2) < 0:
        return abs(p - p2)
    return abs((p2 - p1).cross(p - p1)) / abs(p2 - p1)


def getDistance(s1, s2):
    a, b = s1
    c, d = s2
    if intersect(s1, s2):  # intersect
        return 0
    return min(getDistanceSP(s1, c), getDistanceSP(s1, d), getDistanceSP(s2, a), getDistanceSP(s2, b))


def ccw(p0, p1, p2):
    a = p1 - p0
    b = p2 - p0
    if a.cross(b) > 0:
        return 1  # COUNTER_CLOCKWISE
    elif a.cross(b) < 0:
        return -1  # CLOCKWISE
    elif a.dot(b) < 0:
        return 2  # ONLINE_BACK
    elif abs(a) < abs(b):
        return -2  # ONLINE_FRONT
    else:
        return 0  # ON_SEGMENT


def intersect(s1, s2):
    a, b = s1
    c, d = s2
    return ccw(a, b, c) * ccw(a, b, d) <= 0 and ccw(c, d, a) * ccw(c, d, b) <= 0


if __name__ == '__main__':

    n = int(input())

    for _ in range(n):
        l = list(map(int, input().split()))
        s1 = [Vector2(l[0], l[1]), Vector2(l[2], l[3])]
        s2 = [Vector2(l[4], l[5]), Vector2(l[6], l[7])]

        print(int(intersect(s1, s2)))



Measured memory_bytes: 6164
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AGC030A
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int a = int.Parse(input[0]);
            int b = int.Parse(input[1]);
            int c = int.Parse(input[2]);

            int gedoku = a + b+1;
            
            if(gedoku < c)
            {
                c = gedoku;
            }

            Console.WriteLine(b+c);

        }
    }
}


Measured memory_bytes: 11092
#include <cstdio>
#include <algorithm>
using namespace std;
long long n, s, a[300005];
int main() {
	int i;
	scanf("%d", &n);
	for(i=0; i<3*n; i++) scanf("%d", &a[i]);
	sort(a, a+3*n);
	for(i=n; i<3*n; i+=2) s += a[i];
	printf("%lld", s);
	return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <map>
#include <queue>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
using namespace std;
#pragma warning (disable: 4996)

int N, A[209][209], col[209];
vector<int> G[209];
int dst[209][209];

bool fl = false;

void dfs(int pos, int dep) {
	col[pos] = dep;
	for (int i : G[pos]) {
		if (col[i] >= 1) {
			if ((dep ^ 1) != col[i]) fl = true;
		}
		else {
			dfs(i, dep ^ 1);
		}
	}
}

int main() {
	cin >> N;
	for (int i = 1; i <= N; i++) {
		for (int j = 1; j <= N; j++) {
			char c; cin >> c;
			if (c == '1') A[i][j] = 1;
			if (A[i][j] == 1) {
				G[i].push_back(j);
				G[j].push_back(i);
			}
		}
	}
	for (int i = 1; i <= N; i++) { col[i] = -1; }
	for (int i = 1; i <= N; i++) {
		if (col[i] == -1) dfs(i, 0);
	}
	if (fl == true) {
		cout << "-1" << endl;
		return 0;
	}

	for (int i = 1; i <= N; i++) {
		for (int j = 1; j <= N; j++) {
			if (A[i][j] == 1) dst[i][j] = 1;
			else dst[i][j] = (1 << 28);
		}
		dst[i][i] = 0;
	}
	for (int k = 1; k <= N; k++) {
		for (int i = 1; i <= N; i++) {
			for (int j = 1; j <= N; j++) dst[i][j] = min(dst[i][j], dst[i][k] + dst[k][j]);
		}
	}
	int maxn = 0;
	for (int i = 1; i <= N; i++) {
		for (int j = 1; j <= N; j++) maxn = max(maxn, dst[i][j]);
	}
	cout << maxn + 1 << endl;
	return 0;
}

Measured memory_bytes: 4068
#include<bits/stdc++.h>
#define tcn cin.tie(0);
#define tct cout.tie(0);
#define pb push_back
#define ll long long
#define fr first
#define se second
#define TIME ios_base::sync_with_stdio(0);
using namespace std;

const long long N = 2e3 + 7;
const ll mod = 1e6 + 7;
ll n , m , a , b , c ,d ;
long double p = 3.141592653589793;
string s;
char ch;
vector<int>v ,v1;
int main()
{
    TIME tcn tct
    cin >> n;
    cout << n * (2 * p);
}


Measured memory_bytes: 3800
#include <bits/stdc++.h>
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 fi first
#define se second
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong

signed main(){
    int n,a,b;
    cin >> n >> a >> b;
    cout << min(n,min(a,b)) << endl;
    cout << max(llong(0), a+b -n) << endl;
}

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

int main(){
  map<string,int> mp;
  ll n;
  string s;
  cin >> n;
  rep(i,n){
    cin >> s;
    mp[s]++;
  }
  cout << mp.size() << endl;    
}

Measured memory_bytes: 19176
#include<iostream>
using namespace std;
int main(){
    int a,b,c,r;
    cin >> a >> b >> c;
    if (a > b) {r = a;a = b;b = r; }
    if (b > c) {r = b;b = c;c = r; }
    if (a > b) {r = a;a = b;b = r; }
    cout << a << " " << b << " " << c << endl;
    return 0;
}


Measured memory_bytes: 3072
using AtCoderBeginnerContest126.Questions;
using AtCoderBeginnerContest126.Extensions;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace AtCoderBeginnerContest126.Questions
{
    public class QuestionC : AtCoderQuestionBase
    {
        public override IEnumerable<object> Solve(TextReader inputStream)
        {
            var nk = inputStream.ReadIntArray();
            var n = nk[0];
            var criteria = nk[1];

            double totalProbability = 0;
            for (int dice = 1; dice <= n; dice++)
            {
                var score = dice;
                var probability = 1.0 / n;

                while (score < criteria)
                {
                    score *= 2;
                    probability /= 2;
                }
                totalProbability += probability;
            }

            yield return totalProbability;
        }
    }
}


namespace AtCoderBeginnerContest126
{
    class Program
    {
        static void Main(string[] args)
        {
            IAtCoderQuestion question = new QuestionC();    // 問題に合わせて書き換え
            var answers = question.Solve(Console.In);
            foreach (var answer in answers)
            {
                Console.WriteLine(answer);
            }
        }
    }
}

#region Base Classes

namespace AtCoderBeginnerContest126.Questions
{

    public interface IAtCoderQuestion
    {
        IEnumerable<object> Solve(string input);
        IEnumerable<object> Solve(TextReader inputStream);
    }

    public abstract class AtCoderQuestionBase : IAtCoderQuestion
    {
        public IEnumerable<object> Solve(string input)
        {
            var stream = new MemoryStream(Encoding.Unicode.GetBytes(input));
            var reader = new StreamReader(stream, Encoding.Unicode);

            return Solve(reader);
        }

        public abstract IEnumerable<object> Solve(TextReader inputStream);
    }

}

#endregion

#region Extensions

namespace AtCoderBeginnerContest126.Extensions
{
    internal static class TextReaderExtensions
    {
        internal static int ReadInt(this TextReader reader) => int.Parse(ReadString(reader));
        internal static long ReadLong(this TextReader reader) => long.Parse(ReadString(reader));
        internal static double ReadDouble(this TextReader reader) => double.Parse(ReadString(reader));
        internal static string ReadString(this TextReader reader) => reader.ReadLine();

        internal static int[] ReadIntArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(int.Parse).ToArray();
        internal static long[] ReadLongArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(long.Parse).ToArray();
        internal static double[] ReadDoubleArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(double.Parse).ToArray();
        internal static string[] ReadStringArray(this TextReader reader, char separator = ' ') => reader.ReadLine().Split(separator);
    }
}

#endregion

Measured memory_bytes: 13396
#include <stdio.h>
int n,a[100010],b[100010];
int main(void)
{
    scanf("%d",&n);
    for(int i=0;i<n+1;i++) scanf("%d",&a[i]);
    for(int i=0;i<n;i++) scanf("%d",&b[i]);
    long int c=0;
    for(int i=0;i<n;i++){
        if(b[i]<=a[i]) c+=b[i];
        else if(a[i]<b[i] && b[i]<=a[i]+a[i+1]){
            c+=b[i];
            a[i+1]-=(b[i]-a[i]);
        }
        else if(a[i]+a[i+1]<b[i]){
            c+=(a[i]+a[i+1]);
            a[i+1]=0;
        }
    }
    printf("%ld\n",c);
    return 0;
}


Measured memory_bytes: 896
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <utility>
#include <vector>
using namespace std;
typedef long long int ll;
const ll mod = 1e9 + 7;
ll nck(ll n, ll k)
{
	ll res = 1;
	for (int i = 1; i <= k; i++)
		res *= n - i + 1, res /= i;
	return res;
}
int a[200000];
void solve()
{
	ll n, k,tot=0;
	cin >> n >> k;
	while (k-1 <= n)
	{
		tot += k*(n-k+1) + 1;
		k++;
	}
	cout << tot%mod;

}
int main()
{
//	int t;
//	cin >> t;
//	while (t-- > 0)
		solve();
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
int main() {
    ios_base :: sync_with_stdio(false);
    cin.tie(nullptr);
    long long a, b, k, diff_a = 0, flag = 0;
    cin >> a >> b >> k;
    /*while (k-- != 0) {
        if (a == 0 && b == 0)
            break;
        if (a + b == k) {
            flag = 1;
            break;
        }
        else if (a >= 1)
            a--;
        else if (b >= 1)
            b--;
        cout << "k: " << k << endl;
    }*/
    diff_a = a - k;
    if (a + b <= k)
        cout << 0 << " " << 0;
    else if (diff_a <= 0)
        cout << 0 << " " << b + diff_a;
    else
        cout << diff_a << " " << b;
    /*if (flag == 1)
        cout << 0 << " " << 0;
    else
        cout << a << " " << b;*/
    return 0;
}


Measured memory_bytes: 256
n=int(input())
XL=[list(map(int,input().split())) for _ in range(n)]

XL.sort(key=lambda x:(x[0],x[1]))
now=XL[0][0]+XL[0][1]
ans=0
for i in range(1,n):
  x,l=XL[i]
  if x-l<now:
    ans+=1
    if x+l<now:
      now=x+l
  else:
    now=x+l
print(n-ans)

Measured memory_bytes: 35496
'use strict'

function main(s) {

  s = s.split('\n')[0].split(' ').map(n => Number(n));

  const a = s[0];
  const b = s[1];
  const c = s[2];

  const ans = (a + b === c || a + c === b || b + c === a) ? 'Yes' : 'No';

  console.log(ans);
}

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


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

struct CITY{
    //int id;
    int p;
    int year;
    int no;
};
CITY citys[100000];
string ids[100000];

int cmp(CITY a, CITY b)
{
    if(a.p!=b.p)
    {
        return a.p<b.p;
    }
    else
    {
        return a.year<b.year;
    }
}

string id2String(int data)
{
    string s="";
    int i,d;
    for(i=0;i<6;i++)
    {
        d = data%10;
        data = data/10;
        s = to_string(d)+s;
    }
    return s;
}


int main()
{
 int N,M;
 int i,j,number=1,p_pre=0,data2;
 char s[6],d[6],id[12];

 cin>>N>>M;
 for(i=0;i<M;i++)
 {
     citys[i].no = i;
     cin>>citys[i].p>>citys[i].year;
 }
 sort(citys, citys+M,cmp);

 for(i=0;i<M;i++)
 {
     if(p_pre == citys[i].p)
     {
        number++;
     }
     else
     {
         number=1;
         p_pre = citys[i].p;
     }
     ids[citys[i].no] = id2String(citys[i].p)+id2String(number);
 }

 for(i=0;i<M;i++)
 {
    cout<<ids[i]<<endl;
 }
 return 0;
}


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

int main(){
  int N;
  cin>>N;
  vector<int>A(N,0);
  for(int i=0;i<N;i++){
    cin>>A[i];
  }
  sort(A.begin(),A.end());

  int minans=10000000;
  if(A[0]==A[N-1]){
    cout<<0<<endl;
    return 0;
  }
  for(int j=A[0];j<A[N-1];j++){
    int tempans=0;
      for(int i=0;i<N;i++){
      //if(A[i]==i) continue;
      tempans=tempans+pow((A[i]-j),2);
      //cout<<A[i]<<" "<<j<<endl;
    }
    //cout<<tempans<<endl;
    minans=min(minans,tempans);
  }
  cout<<minans<<endl;
    return 0;
}

 

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        sc.close();

        // 主処理
        int countP = s.replaceAll("[^p]", "").length();
        int result = (s.length() - countP * 2) / 2;

        // 出力
        System.out.println(result);
    }
}


Measured memory_bytes: 46400
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N=4e5+5;
const int MD=1e9+7;
int f[N],inv[N];
int quick_pow(int x,int y) {
	int ans=1;
	while(y) {
		if(y&1) ans=1LL*ans*x%MD;
		y>>=1;
		x=1LL*x*x%MD;
	}
	return ans;
}
int C(int n,int m) {
	return 1LL*f[n]*inv[m]%MD*inv[n-m]%MD;
}
void add(int &x,int y) {
	x+=y;
	if(x>=MD) x-=MD;
}
void init() {
	f[0]=1;
	for(int i=1;i<N;i++) f[i]=1LL*f[i-1]*i%MD;
	inv[N-1]=quick_pow(f[N-1],MD-2);
	for(int i=N-2;i>=0;i--) inv[i]=1LL*inv[i+1]*(i+1)%MD;
}
int main() {
	//freopen("in.txt","r",stdin);
	init();
	int n,k,ans=0;
	scanf("%d%d",&n,&k);
	k=min(k,n-1);
	for(int i=0;i<=k;i++) {
		add(ans,1LL*C(n,i)*C(n-1,i)%MD);
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,x,y) for(int i=(int)(x);i<(int)(y);++i)
#define FORE(i,x,y) for(int i=(int)(x);i<=(int)(y);++i)
#define FORD(i,x,y) for(int i=(int)(x);i>=(int)(y);--i)
#define PB push_back
#define ST first
#define ND second
typedef long long ll;
typedef pair<int,int> pii;
const int MAXN=1e6+7;

int ans=0;
int n,m,k,q;

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);
    cin>>n;
    FOR(i,0,n){
        cin>>m;
        if(i%2==0&&m%2==1)++ans;
    }
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 3632
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<vector>
#include<cstdio>
#define MN 50
using namespace std;
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*10+ch-'0';ch=getchar();}
    return x*f;
}
bool f[MN+5];
int n,a[MN+5],b[MN+5];long long ans=(1LL<<50)-1;
bool Solve(long long S,int s,int t)
{
    memset(f,0,sizeof(f));f[s]=1;
    for(int j=s;j;--j) if(f[j]) for(int k=1;k<=j;++k) if(S&(1LL<<k-1)) f[j%k]=1;
    return f[t];
}
int main()
{
    n=read();
    for(int i=1;i<=n;++i) a[i]=read();
    for(int j=1;j<=n;++j) b[j]=read();
    for(int i=1;i<=n;++i) if(!Solve(ans,a[i],b[i])) return 0*puts("-1");
    for(int i=50;i;--i)
    {
        ans^=1LL<<i-1;int flag=1;
        for(int j=1;j<=n;++j) if(!Solve(ans,a[j],b[j])) flag=0;
        if(!flag) ans|=1LL<<i-1;
    }
    cout<<(ans<<1);
    return 0;
}

Measured memory_bytes: 256
module Main where

import           Control.Monad

main :: IO ()
main = do
    [h, _] <- (map read . words) <$> getLine
    list   <- map (map read . words) <$> (replicateM h) getLine
    let res1 = (map goRight . enumerate2d) list
    let
        result = concat
            [(concatMap fst) res1, (fst . goRight . map (last . snd)) res1]

    putStr
        $(unlines .((show . length) result :) . map ((unwords . map show) . (\((a, b), (c, d)) -> [a, b, c, d])))
        result

    return ()
goRight
    :: [((Int, Int), Int)] -> ([((Int, Int), (Int, Int))], [((Int, Int), Int)])
goRight []  = ([], [])
goRight [x] = ([], [x])
goRight (a@(aPoint, aValue) : b@(bPoint, _) : xs) = if even aValue
    then mapSnd (a :) (goRight (b : xs))
    else
        let (resMove, resMap) = goRight (mapSnd (+ 1) b : xs)
        in  ((aPoint, bPoint) : resMove, mapSnd (subtract 1) a : resMap)

enumerate :: [a] -> [(Int, a)]
enumerate = zip [1 ..]

enumerate2d :: [[a]] -> [[((Int, Int), a)]]
enumerate2d =
    (map (\(y, a) -> (map (\(x, b) -> ((y, x), b)) . enumerate) a) . enumerate)

mapTuple :: (t1 -> a) -> (t2 -> b) -> (t1, t2) -> (a, b)
mapTuple f1 f2 (a, b) = (f1 a, f2 b)

mapFst :: (t1 -> a) -> (t1, b) -> (a, b)
mapFst = flip mapTuple id

mapSnd :: (t2 -> b) -> (a, t2) -> (a, b)
mapSnd = mapTuple id


Measured memory_bytes: 63100
while True:
    a_s, op, b_s = input().split()
    a = int(a_s)
    b = int(b_s)
    ans = 0
    if op == '+':
        ans = a + b
    elif op == '-':
        ans = a - b
    elif op == '*':
        ans = a * b
    elif op == '/':
        ans = a / b
    elif op == '?':
        break
    print(int(ans))



Measured memory_bytes: 5596
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=n-1;i > m;i--)
#define pb(n) push_back(n)
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define RS(n) sort(n.begin(), n.end());reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(20) << S << endl;
#define Vecpr vector<pair<lli,lli>>
#define mod 1000000007;
int main(){
  lli N,A,B,C=0,D=0,E,M;
  cin >> N >> M;
  vector<vector<int>>PS(M);
  rep(i,0,N){
    cin >> A >> B;
    if(A>M)continue;
    PS[M-A].pb(B);
  }
  priority_queue<int>QS;
  for(int i=M-1;i>-1;i--){
    for(int K:PS[i])QS.push(K);
    if(QS.empty()!=1){
      C+=QS.top();
      QS.pop();
    }
  }
  Out(C);
}
  

Measured memory_bytes: 5632
import heapq
N,M=map(int,input().split())
AB=[]
for i in range(N):
  a,b=map(int,input().split())
  heapq.heappush(AB,[a,b])
ans=0
bought=0
while bought!=M:
  lst=heapq.heappop(AB)
  A,B=lst[0],lst[1]
  if bought+B<=M:
    ans+=A*B
    bought+=B
  else:
    ans+=A*(M-bought)
    bought=M
print(ans)

Measured memory_bytes: 19672
#!/usr/bin/env python3
import sys
import math

def eratos(n :int):
    # initialize
    isprime = [True] * (n+1)
    isprime[0] = isprime[1] = False

    for i in range(2, int(math.sqrt(n)+1)):
        if(isprime[i]):
            j = i+i
            while(j <= n):
                isprime[j] = False
                j = j+i

    return isprime

def solve(Q: int, l: "List[int]", r: "List[int]"):
    myo = eratos(100000)
    rodd = [0]*100001

    r2017 = [False]*100001
    for i in range(1,100001):
        if(i%2 == 0):
            continue
        elif(myo[i] and myo[int((i+1)/2)]):
            r2017[i] = True

    for i in range(2,100001):
        rodd[i] = rodd[i-1] +(1 if r2017[i-1] else 0)

    # for i in range(20):
    #     print(i,rodd[i])
        


    # たぶんここからがミス
    ans = [0]*Q
    for i in range(Q):
        ans[i] = rodd[r[i]+1] - rodd[l[i]]

    for i in ans:
        print(i)

    return


# Generated by 1.1.3 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    Q = int(next(tokens))  # type: int
    l = [int()] * (Q)  # type: "List[int]" 
    r = [int()] * (Q)  # type: "List[int]" 
    for i in range(Q):
        l[i] = int(next(tokens))
        r[i] = int(next(tokens))
    solve(Q, l, r)

if __name__ == '__main__':
    main()


Measured memory_bytes: 18736
using static System.Math;
using static System.Console;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var line = ReadLine().Split(' ').Select(value => int.Parse(value)).ToArray();
            var n = line[0];
            var k = line[1];
            var prices = ReadLine().Split(' ').Select(value => int.Parse(value)).ToArray();
            prices = prices.OrderBy(value => value).ToArray();

            var sum = 0;
            for(var i = 0; i < k; i++)
            {
                sum += prices[i];
            }

            WriteLine(sum);
        }
    }
}


Measured memory_bytes: 19792
n = int(input())
c = list(map(int, input().split()))
dp = [0] * n

dp[0] = 0
dp[1] = abs(c[0] - c[1])

for i in range(2, n):
    dp[i] = min(dp[i - 1] + abs(c[i] - c[i - 1]), dp[i - 2] + abs(c[i] - c[i - 2]))

print(dp[n-1])

Measured memory_bytes: 13928
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,N) for(int i = 0;i < (int)(N);i++)
int main(){
  int n;
  string s;
  cin>>n>>s;
  int ans=0;
  rep(i,n-2){
    if(s.substr(i,3)=="ABC"){
      ans++;
    }
  }
        cout<<ans<<endl;
}



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

#define ALL(a) (a).begin(), (a).end()
#define ll long long

using namespace std;

bool play(vector<set<int> > &m){
	for(auto e : m)if(e.size() != 0)return true;
	return false;
}

signed main(){
	while(true){
		int n,l; cin >> n >> l;
		if(n == 0)break;
		vector<int> d(n), p(n);
		vector<set<int> > m(l);
		for(int i = 0; i < n; i++){
			char tmp;
			cin >> tmp >> p[i];
			d[i] = tmp == 'R' ? 1 : -1;
			p[i]--;
			m[p[i]].insert(i);
		}
		int last = -1, cnt = 0;
		while(play(m)){
			for(int i = 0; i < l; i++){
//				for(auto e : m[i])cerr << e << ":";
//				cerr << "---";
			}
//			cerr << endl;
			vector<set<int> > next(l);
			for(int i = l-1; i >= 0; i--){
				for(auto e : m[i]){
					if(0 <= i+d[e] && i+d[e] < l-1){
//						cerr << i << ":" << e << "->" << (i+d[e]) << endl;
						next[i+d[e]].insert(e);
					}
					else if(i+d[e] >= l-1){
						last = e;
					}
					else{
						last = e;
					}
				}
			}
			for(int i = 0; i < l; i++){
//				for(auto e : next[i])cerr << e << ":";
//				cerr << "---";
				assert(next[i].size() <= 2);
				if(next[i].size() == 2){
					for(auto e : next[i])d[e] *= -1;
				}
			}
//			cerr << endl;
			swap(next, m);
			cnt++;
		}
		cout << cnt << " " << (last+1) << endl;
					


				
			
	}

	return 0;
}




Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
#define why(n,x) int n;while(cin >>n,n!=x)
#define iFOR(i,x,n)for(int i=x;i<n;i++)
#define fin <<'\n'
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
#define SWAP(a,b) ((a != b) && (a += b,b = a - b,a -= b))
//#define int long long
typedef long long ll;
typedef pair < int , int >  pii;
typedef vector < int > vit;
typedef map < string , int > mstit;
typedef vector < pii > vpi ;
typedef greater < pii > gpi;
typedef priority_queue < pii , vpi , gpi > dijk ;
static const signed int INF = 0x3f3f3f3f;
static const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static const signed int SMOD = 1000000007;
static const signed int NMOD = 1000000009;
static const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static const signed int dy[]={0,-1,0,1,-1,1,-1,1};

bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>T abs(T &x){return x<0 ? -x : x;}
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 qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}


inline void solve(){

    int a, x;
    cin >> x >> a;
    if(x >= a)
        cout << 10 fin;
    else
        cout << 0 fin;
    
    
    
    
}
struct xyz{ xyz(){ cin.tie(0), ios::sync_with_stdio(false); cout <<fixed<<setprecision(12);};}xyzzy;signed main(){solve();return 0;}


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

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

	string ans = "NO";
	for (int i = 1; i <= b; i++) {
		if ((a*i+c) % b == 0) {
			ans = "YES";
		}
	}
	if (a == 1) {
		ans = "YES";
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
nums = list(map(int, list(input())))

ops = []
for i in range(1 << 3):
    ops = []
    for j in range(3):
        if (i >> j & 1) == 1:
            ops.append("+")
        else:
            ops.append("-")
    ans = nums[0]
    for j in range(3):
        if ops[j] == "+":
            ans += nums[j+1]
        else:
            ans -= nums[j+1]
    if ans == 7:
        print(nums[0], end="")
        for j in range(3):
            print(ops[j] + str(nums[j+1]), end="")
        print("=7")
        exit()


    




Measured memory_bytes: 3064
N, A, B = gets.chomp.split.map(&:to_i)

output = 0

(1..N).each do |i|
  data = i / 10000 + i % 10000 / 1000 + i % 1000 / 100 + i % 100 / 10 + i % 10
  output += i if data.between?(A, B)
end

puts output


Measured memory_bytes: 1788
import os, sys, re, math, queue

A,B,C,D = list(map(int,input().split(' ')))

def gcd(a,b):
	if b == 0:
		return a
	return gcd(b, a % b)

def lcm(a,b):
	return a * b // gcd(a,b)

lc = lcm(C,D)
tmp = B // C - (A-1) // C
tmp += B // D - (A-1) // D
tmp -= (B // lc - (A-1) // lc)
print(B-A+1-tmp)


Measured memory_bytes: 3952
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<cstring>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
#include<time.h>
#include<cassert>

using namespace std;
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
#define EPS (1e-5)
#define bit(n,k) ((n>>k)&1)
const ll Mod = 1000000007;
const ll mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H& b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H& b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H& b) const { return x == b.x && y == b.y; }
	bool operator!=(const H& b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P& b) const { return cost < b.cost; }
	bool operator>(const P& b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E& b) const { return cost < b.cost; }
	bool operator>(const E& b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T& a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T& a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	ll k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j % i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
ll bitcount(ll x) {
	int sum = 0;
	for (int i = 0; i < 20; i++)
		if ((1ll << i) & x) sum++;
	return sum;
}
ll fact_[200000];
ll comb(ll x, ll y, ll mod = Mod) {
	if (!fact_[0]) {
		fact_[0] = 1;
		for (int i = 1; i < 200000; i++) {
			fact_[i] = fact_[i - 1] * i % mod;
		}
	}
	if (x < y) return 0;
	return mod_pow(fact_[x], mod, mod) *
		mod_pow(fact_[x - y], mod - 2, mod) % mod *
		mod_pow(fact_[y], mod - 2, mod) % mod;
}//xCy
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
int a, b, n;
signed main() {
	string s;
	cin >> n >>s;
	for (int i = 0; i < s.size(); i++) {
		cout << (char)(((s[i] - 'A') + n) % 26 + 'A');
	}
	cout << endl;
}

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

bool calc(bool a, bool b) {
    if (a && !b) return false;
    else return true;
}

int main() {
    int N; cin >> N;
    vector<bool> a(N);
    for (int i = 0; i < N; ++i) {
        string s; cin >> s;
        if (s == "T") a[i] = true;
        else a[i] = false;
    }
    bool res = calc(a[0], a[1]);
    for (int i = 2; i < N; ++i) {
        res = calc(res, a[i]);
    }
    if (res) cout << "T" << endl;
    else cout << "F" << endl;
}



Measured memory_bytes: 3172
h, w = gets.split.map &:to_i
a = Array.new(h); s = "#"
h.times do |i|
	a[i] = gets.chomp
end
(h+2).times do |i|
	if i == 0
		puts s*(w+2)
	elsif i == h+1
		puts s*(w+2)
	else
		puts s + a[i-1] + s
	end
end


Measured memory_bytes: 1788