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

using namespace std;
typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);	
    
    string s;
    int n=0, max=0;
    cin >> s;
    for(int i=0; i<3; ++i)
		if(s[i] == 'R') {
			n++;
			max = n;
		} else {	
			n = 0;
		}
	if(n>max)
		cout << n;
	else 
		cout << max;
    return 0;
} 
 


Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long int n;
   cin>>n;
 long long  int p=100,countt=0;
   while(p<n)
   {
       p+=p/100;
       countt++;
   }
   cout<<countt<<endl;
return 0;
}


Measured memory_bytes: 3532
#include <stdio.h>

void print(int s) {
    printf("%02d:%02d:%02d\n", s/60/60, s/60%60, s%60);
}

int main() {
    for (;;) {
        int h, m, s;
        scanf("%d%d%d", &h, &m, &s);
        if (h == -1 && m == -1 && s == -1) return 0;
        const int r = 120*60 - h*60*60 - m*60 - s;
        print(r);
        print(r*3);
    }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using intpair=pair<int,int>;
using llpair=pair<ll,ll>;
using llvec=vector<ll>;
using llmat=vector<vector<ll>>;
#define llmattp(name,a,b,num) name(a,vector<ll>(b,num))
#define INTINF 1<<30
#define LLINF 1LL<<60
#define ABS(x) ( (x)>0 ? (x) : -(x) )

template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}

template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

ll gcd(ll a, ll b) { //最大公約数
	if(a==0||b==0) return 0;
	if(a<b) swap(a,b);
	ll tmp = a%b;
	while(tmp!=0) {
		a = b;
		b = tmp;
		tmp = a%b;
	}
	return b;
}

ll factorial(ll x) { //階乗
	ll f=1;
	for(ll i=2; i<x; i++) {
		f*=i;
	}
	return f;
}

ll nPr(ll n, ll r) {
	ll result=1;
	for(ll i=r+1; i<=n; i++) result*=i;
	return result;
}

ll nCr(ll n, ll r) {
	if (n == r) { return 1; }
	if (r > n) { return 0; }

	if (r > n / 2) { r = n - r; }

	if (n == 0) { return 0; }
	if (r == 0) { return 1; }
	if (r == 1) { return n; }

	double result = 1;
	for (double i = 1; i <= r; i++) {
		result *= (n - i + 1) / i;
	}

	return (ll)result;
}

bool IsPrime(ll num) { //素数判定
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

	double sqrtNum = sqrt(num);
	for (ll i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			// 素数ではない
			return false;
		}
	}

	// 素数である
	return true;
}

ll GreaterBinarySearch(ll *array, ll key, ll max, ll min) {
	if(array[max]<array[min]) {
		return NULL;
	} else {
		ll mid = max + (min-max)/2;
		if(array[mid]<key) {
			return GreaterBinarySearch(array,key,max,mid-1);
		} if(array[mid]>key) {
			return GreaterBinarySearch(array,key,mid+1,min);
		} else {
			return mid;
		}
	}
}

int DigitNum(ll n) { //桁数
	int digit=0;
	ll wari=1LL;
	while(n/wari) {
		digit++;
		wari*=10;
	}
	return digit;
}

void PrimeFact(ll x) { // 素因数分解 出力部を適切に書き換え
	int i=2;
	while(x%2&&i*i<=x) {
		cout<<2<<endl;
		x/=2;
	}
	i++;
	while(i*i<=x) {
		if(x%i) {
			i+=2;
			continue;
		}
		cout<<i<<endl;
		x/=i;
	}
}

bool Palind(string s) { //回文判定
	return s == string(s.rbegin(), s.rend());
}

int main() {
	string S,T; cin>>S>>T;
	int Slen=S.length(), Tlen=T.length();
	priority_queue<string,vector<string>,greater<string>> str;

	for(int i=Slen-Tlen; i>=0; i--) {
		bool eql=true;
		for(int j=0; j<Tlen; j++) {
			if(S.at(i+j)!=T.at(j)&&S.at(i+j)!='?') {
				eql=false;
				break;
			}
		}
		if(eql) {
			string tmps=S;
			tmps.replace(i,Tlen,T);
			for(int i=0; i<Slen; i++) {
				if(tmps.at(i)=='?') tmps.replace(i,1,"a");
			}
			str.push(tmps);
		}
	}
	if(str.empty())
		cout<<"UNRESTORABLE"<<endl;
	else
		cout<<str.top()<<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>;

const ll MOD = 1e9 + 7;

int main(void){
    int s;
    cin >> s;
    vector<int> dp(s + 1);
    fill(dp.begin(), dp.end(), 0);
    dp[0] = 1;
    for(int i = 3; i <= s; ++i)
        dp[i] = (dp[i - 1] + dp[i - 3]) % MOD;
    cout << dp[s] << endl;
    return 0;
}

Measured memory_bytes: 3604
#include <iostream>

using namespace std;

char s[51][51];

int vx[] = { 0,  1, 1, 1, 0, -1, -1, -1};
int vy[] = {-1, -1, 0, 1, 1,  1,  0, -1};

int checkMine(int h, int w, int x, int y) {
    int cnt = 0;

    for (int i = 0; i < 8; i++) {
        if ((x + vx[i] < w && x + vx[i] >= 0) || (y + vy[i] < h && y + vy[i] >= 0)) {
            if (s[x + vx[i]][y + vy[i]] == '#') {
                cnt++;
            } 
        }
    }
    // cout << "(" << x << ", " << y << ") = " << cnt << endl;

    return cnt;

}
int main()
{
    int h, w; cin >> h >> w;

    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cin >> s[i][j];
            // cout << "s[" << i << ", " << j << "] = " << s[i][j] << endl;
        }
    }

    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (s[i][j] == '.') {
                s [i][j] += 2 + checkMine(h, w, i, j);
            }
        }
    }

    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (j != w - 1) {
                cout << s[i][j];
            } else {
                cout << s[i][j] << endl;
            }
        }
    }

    return 0;
}


Measured memory_bytes: 256
/* ex3_4
	kanon */

#include <stdio.h>

int main(void)
{

    //与えられる値を入れる変数を宣言
    int N;

    //変数に値を入力する
    scanf("%d", &N);

    //九九に含まれる値全てについてNと一致しないか調べる
    //一致すればflagを１にする、flagを使って答えの出力の場合分けをする
    int flag=0;
    for(int i=1;i<=9;i++){
        for(int j=1;j<=9;j++){
            if(i*j==N){
                flag=1;
                break;
            }
        }

        if(flag){
            break;
        }
    }

    //答えの出力
    if(flag){
        printf("Yes");
    }else{
        printf("No");
    }

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define fastIO (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define precise(i) fixed << setprecision(i)
using namespace std;

int main() {
    fastIO;
    int n;
    cin >> n;
    set<string> used;
    string cur = "(x_x)", prev = ":^)";

    rep(_, n) {
        cin >> cur;

        if (used.find(cur) != used.end()) {
            cout << "No";
            return 0;
        }
        used.insert(cur);

        if (prev != ":^)" && prev.back() != cur.front()) {
            cout << "No";
            return 0;
        }
        prev = cur;
    }

    cout << "Yes";
    return 0;
}

Measured memory_bytes: 3616
"""
# 標準入力取得
## 文字列
 = sys.stdin.readline().rstrip()
 = list(sys.stdin.readline().rstrip())

## 数値
 = int(sys.stdin.readline())
 = map(int, sys.stdin.readline().split())
 = list(map(int, sys.stdin.readline().split()))
 = [list(map(int,list(sys.stdin.readline().split()))) for i in range(h)]  # 二次元配列入力　二次元マップみたいな入力のとき

# 0埋め, 小数点出力桁指定時のときの出力
a = 100
b = 0.987654321
print("{0:06d}-{1:6f}".format(a,b))
000100-0.987654

# 文字列をリストに格納
char_list = list("abcd") # ["a","b","c","d"]
"""

import math
import sys
import itertools
import queue
from fractions import gcd

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

mod = 1000000007

if __name__ == "__main__":
    A,B = map(int, sys.stdin.readline().split())
    if B%A==0:
        print(A+B)
    else:
        print(B-A)

Measured memory_bytes: 5096
#include<bits/stdc++.h>
#define N 17
using namespace std;
typedef long long ll;
const int mod=1e9+7;
int n,m,a[N];
ll jie[1<<N],ni[1<<N],dp[N][1<<N];
int cnt[1<<N];
inline ll rd(){
    ll x=0;char c=getchar();bool f=0;
    while(!isdigit(c)){if(c=='-')f=1;c=getchar();}
    while(isdigit(c)){x=(x<<1)+(x<<3)+(c^48);c=getchar();}
    return f?-x:x;
}
inline void MOD(ll &x){x=x>=mod?x-mod:x;}
inline ll power(ll x,ll y){
    ll ans=1;
    while(y){if(y&1)ans=ans*x%mod;x=x*x%mod;y>>=1;}
    return ans;
}
inline ll C(int n,int m){return jie[n]*ni[m]%mod*ni[n-m]%mod;}
inline bool cmp(int a,int b){return a>b;}
int main(){
    n=rd();m=rd();
    for(int i=1;i<=m;++i)a[i]=rd();
    sort(a+1,a+m+1,cmp);
    int maxn=(1<<n);
    for(int i=1;i<=maxn;++i)cnt[i]=cnt[i-(i&-i)]+1;
    jie[0]=1;
    for(int i=1;i<=maxn;++i)jie[i]=jie[i-1]*i%mod;
    ni[maxn]=power(jie[maxn],mod-2);
    for(int i=maxn-1;i>=0;--i)ni[i]=ni[i+1]*(i+1)%mod;
    dp[0][0]=1;
    for(int i=1;i<=m;++i)
        for(int s=0;s<(1<<n);++s)if(dp[i-1][s]){
            MOD(dp[i][s]+=dp[i-1][s]);
            for(int j=0;j<n;++j)if(!(s&(1<<j))){
                MOD(dp[i][s|(1<<j)]+=dp[i-1][s]*jie[1<<j]%mod*C(maxn-a[i]-s,(1<<j)-1)%mod);
            }
        }
    ll ans=0;
    for(int s=0;s<(1<<n);++s){
        if(cnt[s]&1)MOD(ans=ans-dp[m][s]*jie[maxn-1-s]%mod+mod);
        else MOD(ans=ans+dp[m][s]*jie[maxn-1-s]%mod);
    }
    printf("%lld\n",ans*maxn%mod);
    return 0;
}

Measured memory_bytes: 17408
#include<stdio.h>
#include<vector>
#include<math.h>
#include<string>

typedef long long ll;
typedef unsigned short int unsi;
typedef unsigned int uni;
typedef unsigned long int unli;

using namespace std;

unsi gojoho(unsi A, unsi B) {
	unsi R = 1;
	if (A > B) {
		while (R!=0) {
			R = A % B;
			A = B;
			B = R;
		}
		return A;
	} else {
		while (R != 0) {
			R = B % A;
			B = A;
			A = R;
		}
		return B;
	}
}

uni gojoho(uni A, uni B) {
	uni R = 1;
	if (A > B) {
		while (R != 0) {
			R = A % B;
			A = B;
			B = R;
		}
		return A;
	} else {
		while (R != 0) {
			R = B % A;
			B = A;
			A = R;
		}
		return B;
	}
}

unli gojoho(unli A, unli B) {
	unli R = 1;
	if (A > B) {
		while (R != 0) {
			R = A % B;
			A = B;
			B = R;
		}
		return A;
	} else {
		while (R != 0) {
			R = B % A;
			B = A;
			A = R;
		}
		return B;
	}
}

int gojoho(int A, int B) {
	int R = 1;
	if (A > B) {
		while (R != 0) {
			R = A % B;
			A = B;
			B = R;
		}
		return A;
	} else {
		while (R != 0) {
			R = B % A;
			B = A;
			A = R;
		}
		return B;
	}
}



int main(){
	int K, N,ans;
	scanf("%d%d",&N,&K);
	ans = N - K + 1;
	printf("%d", ans);
	return(0);
}





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

int main() {
    int n;
    ll h, count = 0;
    cin >> n >> h;
    ll max_a = 0;
    vector<ll> B(n);
    for(int i=0; i<n; i++){
        ll a, b;
        cin >> a >> b;
        max_a = max(max_a, a);
        B[i] = b; 
    }

    sort(B.begin(), B.end());
    int index = 0;
    bool flag = true;
    for(int i=0; i<n; i++){
        if(B[i]>max_a){
            index = i;
            flag = false;
            break;
        }
    }
    if(flag){
        index = n-1;
    }

    ll sum = 0;
    for(int i=n-1; i>=index; i--){
        sum += B[i];
        if(sum >= h){
            cout << n-i << endl;
            return 0;
        }
    };
    count += n-index;
    // 切り上げ
    count += ceil((double)(h-sum)/max_a);
    cout << count << endl;

    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define brep(index,num) for(int index=num-1;index>=0;index--)
#define brep1(index,num) for(int index=num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
pair<vll,vll > prime_factor_decomp(ll n) {
    vll p, e;
    ll m = n;
    for (ll i = 2; i * i <= n; i++) {
        if (m % i != 0) continue;
        int c = 0;
        while (m % i == 0) c++, m /= i;
        p.push_back(i);
        e.push_back(c);
    }
    if (m > 1) {
        p.push_back(m);
        e.push_back(1);
    }
    return mp(p, e);
}
ll gcd(ll x,ll y){
	if(y==0) return x;
	return gcd(y,x%y);
}
int main(){
	ll A,B;
	scan(A>>B);
	ll G=gcd(A,B);
	if(G==1) prin(1);
	else{
		int s=prime_factor_decomp(G).first.size();
		prin(s+1);
	}

	return 0;
}


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

int main(){
  int a,b;
  cin >> a >> b;
  if(a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0) {
    cout << "Possible" << endl;
  }
  else cout << "Impossible" << endl;
}


Measured memory_bytes: 256
// AOJ 1373: Placing Medals on a Binary Tree
// 2018.1.7 bal4u@uu

#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>

#define N 500000
int bit[500003];

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0;
	int c = getchar_unlocked();
	do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

void add(int i, int v)
{
    while (i <= N) bit[i] += v, i |= i+1;
}
 
int sum(int i)
{
    int s = 0;
    while (i) s += bit[i-1], i &= i-1;
    return s;
}

int sub(int a, int b) { return sum(a) - sum(b); }

int main()
{
	int n, i, x, k, ans;

	k = 0;
	n = in(); while (n--) {
		x = in();
		ans = 1;
		if (sub(1, 0) == 1) ans = 0;
		else if (x >= N) k++;
		else if (sub(x+1, 0) < x) {
			for (i = x; sub(i+1, i); i--) add(i, -1); add(i, 1);
		} else if (sub(x+1, 0) == x) {
			if (k || sub(N, x+1)) ans = 0;
			else { for (i = 1; i <= x; i++) add(i, -1); add(0, 1); }
		}
		puts(ans? "Yes": "No");
	}
	return 0;
}



Measured memory_bytes: 3612
#include "bits/stdc++.h"
using namespace std;
int a, b;
string s;
void solve(){
    cin >> a >> b, cin >> s;
    bool check = true;
    for(int i = 0; i < s.size(); i++){
        if(i != a){
            if(s.at(i) == '-')
            check = false;
        }
        else if(s.at(i) != '-')
        check = false;
    }
    if(check)
    cout << "Yes" << endl;
    else 
    cout << "No" << endl;
}
int main(){
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;

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

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

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

using namespace std;

#define ll long long
#define ld long double
#define ff first
#define ss second
#define rsz resize
#define ins insert 
#define mp make_pair
#define pf push_front 
#define pb push_back
#define eb emplace_back 
#define ft front() 
#define bk back()
#define sz(x) (int)(x).size()
#define all(x) begin(x), end(x)
#define deb(x) cout<<#x<<" "<<x<<'\n';
#define rep(i,a,b) for (int i = (a); i < (b); ++i)

const ll mod = 1e9+7; // 998244353;
const ll inf = 1e18; 
const ld pie = acos((ld)-1);

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



int main(){
    
	double d,t,s;
	cin>>d>>t>>s;
	if(d/t > s){
		puts("No");
	}else{
		puts("Yes");
	}

	return 0;

	/*STUFF TO LOOK:	
		1. Check the constraints
		2. Corner cases(n==0||n==1)
		3. Variables in loops
		4. Make sure two ints aren’t multiplied to get a long long
		5. Don't use scanf or printf while using ios_base
		6. using the local variable of the same name when global variable was required to be used
	*/
}


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

char num[20];

int main()
{
	scanf("%s", num);
	int ans = 0, len = strlen(num);
	for (int i = 0; i < len; i++) ans += num[i] - '0';
	int ano = 0;
	if (num[0] != '0') ano += num[0] - '0' - 1;
	for (int i = 1; i < len; i++) ano += 9;
	ans = max(ans, ano);
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) a.begin(),a.end()
#define print(A,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i];}cout<<endl;
#define pprint(A,m,n) rep(j,0,m){print(A[j],n);}
const long mod=1e9+7;
const int size=2e5;
const int INF=1e9;
int main(){
	int N,K;cin>>N>>K;
	int H[N];int count=0;
	rep(i,0,N){
		cin>>H[i];
		if(H[i]>=K) count++;
	}cout<<count<<endl;
}

Measured memory_bytes: 640
import math
def main():
    A, B = map(int, input().split())

    for i in range(1001):
        a = int(0.08*i)
        b = int(0.1*i)
        #print(a, b)
        if (a == A) and (b == B):
            print(i)
            return 0
    print(-1)
    return 0
if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
 
ll gcd(ll a, ll b){
    if(a % b == 0){
        return b;
    }
    return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a * (b / gcd(a, b));
}
 
int main(){
    ll n, m;  cin >> n >> m;
    vector<ll> lis(n); 
    cin >> lis[0];
    ll a = lis[0] / 2, b;
    for(int i = 1; i < n; i++){
        cin >> lis[i];
        a = lcm(a, lis[i] / 2);
    }
    for(int i = 0; i < n; i++){
        if(a % lis[i] == 0){
            cout << 0 << endl;
            return 0;
        }
    }
    cout << (m/a + 1) / 2 << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <stack>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstdbool>
#include <cstring>
#include <map> 
#include<set>
#include<queue>
#include <iomanip>

typedef long long ll;

#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const long long INF = 1000000000000000;
const ll inf = -1e18;
typedef pair<ll, ll> P;
ll ma = 1000000000 + 7;
ll mx = 1000003;
ll h,n, w,m,t; string s;
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };
ll gcd(ll x, ll y) {
	if (x % y == 0) return y;
	return gcd(y, x % y);
}
ll lcm(ll a,ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
void comb(vector<vector <ll> >& v) {
	for (ll i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (ll k = 1; k < v.size(); k++) {
		for (int j = 1; j < k; j++) {
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j])%ma;
		}
	}
}

ll GetDigit(ll num) {
	return log10(num) + 1;
}
ll Combination(int n, int r)
{
	if (n - r < r) r = n - r;
	if (r == 0) return 1;
	if (r == 1) return n;

	vector<ll> numerator(r);
	vector<ll> denominator(r);

	for (int k = 0; k < r; k++)
	{
		numerator[k] = n - r + k + 1;
		denominator[k] = k + 1;
	}

	for (int p = 2; p <= r; p++)
	{
		int pivot = denominator[p - 1];
		if (pivot > 1)
		{
			int offset = (n - r) % p;
			for (int k = p - 1; k < r; k += p)
			{
				numerator[k - offset] /= pivot;
				denominator[k] /= pivot;
			}
		}
	}

	ll result = 1;
	for (int k = 0; k < r; k++)
	{
		if (numerator[k] > 1) result *= numerator[k];
		result %= ma;
	}

	return result;
}
int main() {
	string S, T;
	cin >> n;
	cin >> S >> T;
	string res = "";
	rep(i, n) {
		res += S[i];
		res += T[i];
	}
	cout << res << endl;
}


Measured memory_bytes: 256
def solve(n):
    n = list(map(int, n))
    a, b = 0, 9
    for d in n:
        a, b = min(d+a, d+b), min(11-d+a, 9-d+b)
    return min(a, b)

assert solve("36") == 8
assert solve("91") == 3
assert solve("314159265358979323846264338327950288419716939937551058209749445923078164062862089986280348253421170") == 243

n = input()
print(solve(n))

Measured memory_bytes: 13508
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#pragma warning(disable:4786)
#pragma warning(disable:4996)
#include <ctime>
#include<list>
#include <numeric>
#include<bitset>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<functional>
#include<string>
#include<cstring>
#include<cstdlib>
#include<queue>
#include<utility>
#include<fstream>
#include<sstream>
#include<cmath>
#include<stack>
#include<assert.h>
#include<unordered_map>
#include<unordered_set>
using namespace std;

#define MEM(a, b) memset(a, (b), sizeof(a))
#define CLR(a) memset(a, 0, sizeof(a))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define ABS(X) ( (X) > 0 ? (X) : ( -(X) ) )
#define S(X) ( (X) * (X) )
#define SZ(V) (int )V.size()
#define FORN(i, n) for(int i = 0; i < n; i++)
#define FORAB(i, a, b) for(int i = a; i <= b; i++)
#define ALL(V) V.begin(), V.end()
#define IN(A, B, C)  ((B) <= (A) && (A) <= (C))
#define AIN(A, B, C) assert(IN(A, B, C))

//typedef int LL;
typedef long long int LL;
//typedef __int128 LLL;
typedef long long LLL;

typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef pair<double, double> PDD;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII > VP;
typedef vector<PLL > VPL;
typedef vector<double> VD;
typedef long double ld;


void solve(int ks) {
	char S[1000];
	int n;
	scanf("%d", &n);
	scanf("%s", S);
	int r = 0;
	for (int i = 0; i < n; i++) {
		r += S[i] == 'R';
	}
	int b = n - r;
	printf("%s\n", (r > b) ? "Yes" : "No");
}

int main()
{
#ifdef LOCAL
	double start_time = clock();
	freopen("C:\\Home\\ContestCodes\\sample.in", "r", stdin);
	//	freopen("out.out", "w", stdout);
#endif


	if (0) {
		int T = 1000;
		scanf("%d", &T);
		for (int ks = 1; ks <= T; ks++) solve(ks);
	}
	else {
		solve(0);
	}

#ifdef LOCAL
	double end_time = clock();
	fprintf(stderr, "Time = %lf\n", (end_time - start_time) / CLOCKS_PER_SEC);
#endif

	return 0;
}


Measured memory_bytes: 256
import sys
n, a, b, c = map(int, input().split())
s = []
for _ in range(n):
    s.append(input())
    
ans =[]
for i in range(n):
    if s[i] == "AB":
        if a == b == 1 and i < n-1:
            if s[i+1] == "AC":
                a += 1
                b -= 1
                ans.append("A")
            else:
                a -= 1
                b+= 1
                ans.append("B")
        else:
            if min(a, b) == a:
                a += 1
                b -= 1
                ans.append("A")
            else:
                a -= 1
                b+= 1
                ans.append("B")
    elif s[i] == "BC":
        if c == b == 1 and i < n-1:
            if s[i+1] == "AB":
                b += 1
                c -= 1
                ans.append("B")
            else:
                b -= 1
                c+= 1
                ans.append("C")
        else:
            if min(c, b) ==b:
                b += 1
                c -= 1
                ans.append("B")
            else:
                b -= 1
                c+= 1
                ans.append("C")
    else:
        if c == a == 1 and i < n-1:
            if s[i+1] == "BC":
                c += 1
                a -= 1
                ans.append("C")
            else:
                a += 1
                c-= 1
                ans.append("A")
        else:
            if min(c, a) == c:
                c += 1
                a -= 1
                ans.append("C")
            else:
                c -= 1
                a += 1
                ans.append("A")
    if min(a, b, c) < 0:
        print("No")
        sys.exit()

print("Yes")
print("\n".join(ans))

Measured memory_bytes: 17400
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#include <bits/stdc++.h>
using namespace std;
 
//priority_queue<long long, vector<long long>, greater<long long>> pq;

const double TL = 1.5 * CLOCKS_PER_SEC;
mt19937 rng((unsigned int) chrono::steady_clock::now().time_since_epoch().count());
#define clr(x, y) memset(x, y, sizeof(x))
#define forn(i, n) for (int i = 0; i < n; i++)
#define LL long long
const double pi = acos(-1.0);

int n;
LL a[200005];

int main() {
  //auto start_clock = clock();
#ifdef LOCAL
  freopen("in", "r", stdin);
#endif

  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }

  LL ans = 0;
  map<LL, LL> mp;
  for (int i = 0; i < n; i++) {
    ans += mp[-a[i] + i];
    mp[a[i] + i] += 1;
  }
  cout << ans << endl;


  return 0;
}

Measured memory_bytes: 28004
#include <bits/stdc++.h>
using namespace std;
#define what_is(x) cerr << #x << " is " << x << endl;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define st first
#define nd second
#define endl '\n'

typedef long long ll;
typedef pair<int,int> pii;
const int N = 1e5+5;
const int INF = 1e9;
const int MOD = 1e9+7;

int n;
int a[N], b[N];

int main()
{
	IOS
	// freopen("input.txt", "r", stdin);
	cin >> n;
	for(int i=0; i<=n; i++) cin >> a[i];
	for(int i=0; i<n; i++) cin >> b[i];
	ll ans = 0;
	for(int i=0; i<n; i++){
		int left = min(a[i], b[i]);
		b[i] -= left;
		int right = min(b[i], a[i+1]);
		a[i+1] -= right;
		ans += left + right;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1024
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int D = sc.nextInt();
        int T = sc.nextInt();
        int S = sc.nextInt();
        
        int time =T*S;
        if(D<=time){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
        
    }
}


Measured memory_bytes: 35604
#include <iostream>
#include <vector>

auto main() -> int {
  using std::cin;
  using std::cout;

  int a, b, count;
  cin >> a >> b;
  
  if(a%b != 0) {
  auto i = (a-(a%b))/b+1;
    cout << i << "\n";
  } else {
    auto i = (a-(a%b))/b;
    cout << i << "\n";
  }

  return 0;
}

Measured memory_bytes: 256
/*   _/                _/                 _/_/_/   _/
  _/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
   _/     _/    _/   _/     _/    _/  _/_/_/     _/
  _/     _/    _/   _/     _/    _/  _/    _/   _/
   _/_/   _/_/       _/_/   _/_/      _/_/     _/ */
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
using ll=long long;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=2e9;
const ll INF=1e18;
using P=pair<int,int>;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  int h,w,x[105]={},y[105]={},cnt,f;
  string s[105]={};
  cin >> h >> w;
  for(int i=0; i<h; i++) {
    cin >> s[i];
  }
  for(int i=0; i<h; i++) {
    cnt=0;
    for(int j=0; j<w; j++) {
      if(s[i][j]=='.') {
        cnt++;
      }
    }
    if(cnt==w) {
      x[i]=1;
    }
  }
  for(int i=0; i<w; i++) {
    cnt=0;
    for(int j=0; j<h; j++) {
      if(s[j][i]=='.') {
        cnt++;
      }
    }
    if(cnt==h) {
      y[i]=1;
    }
  }
  for(int i=0; i<h; i++) {
    f=0;
    for(int j=0; j<w; j++) {
      if(!x[i]&&!y[j]) {
        cout << s[i][j];
        f=1;
      }
    }
    if(f) {
      cout << "\n";
    }
  }
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for (int i = a; i < (int)b; ++i)
#define rrep(i, n) for (int i = ((int)n - 1); i >= 0; --i)

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

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
    int n, m;
    cin >> n >> m;
    vector<ll> h(n);
    vector<bool> ok(n, true);
    rep (i, n) cin >> h[i];
    rep (i, m) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        if (h[a] > h[b]) {
            ok[b] = false; 
        } else if (h[a] < h[b]) {
            ok[a] = false;
        } else {
            ok[a] = ok[b] = false;
        }
    }
    int res = 0;
    rep (i, n) {
        if (ok[i]) res++;
    }
    cout << res << endl;
    
    return 0;
}



Measured memory_bytes: 3992
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
const int mod =1e+9+7;

ll RepeatSquaring(ll a, ll n, ll p){
    if(n==0) return 1;
    if(n%2==0){
        ll t = RepeatSquaring(a, n/2, p);
        return t*t % p;
    }
    return (a*RepeatSquaring(a, n-1, p))%p;
}

ll nCr(ll n, ll r, ll mod){
    ll mul = 1, div = 1;
    for(ll i = 0; i < r; i++){
        mul *= n - i;
        div *= i + 1;
        mul %= mod;
        div %= mod;
    }   
    return mul * RepeatSquaring(div, mod - 2, mod) % mod;
}
int main(){
    ll x,y; cin>>x>>y;
    if(2*x-y<0||2*y-x<0||(2*x-y)%3!=0||(2*y-x)%3!=0){
        cout<<0<<endl;
        return 0;
    }
    ll a=(2*x-y)/3,b=(2*y-x)/3;
    ll ans=nCr(a+b,a,mod);
    cout<<ans<<endl;

}









































Measured memory_bytes: 3608
#include "iostream"
#include "fstream"
#include "algorithm"
#include "iomanip"
#include "stack"
#include "queue"
#include "string"
#include "vector"
#include "map"
#include "set"
#include "unordered_set"
#include "unordered_map"
#include "iterator"
#include <ctime>
#include "bitset"
#include "cmath"
#include "list"
#include "complex"
#include <cassert>
#include "deque"
#include "numeric"
#include <cstdio>

using namespace std;

//#define f(i,n) for(int i=0; i<n;i++) 
//#define rf(i, n) for(int i=n-1;i>=0;i--)
//#define forn(i, j, n) for(int i=j; i<n; i++)
//#define ff(i, j, n) f(i, n)f(j, n)
#define pb push_back
#define mp make_pair
#define maxi(a,b) a = max(a, b);
#define mini(a,b) a = min(a, b);
#define endl '\n'
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x))
#define SZ(a) ((int)(a.size()))
#define watch(x) cout << (#x) << " = " << x << endl;
//typedef long long ll;
typedef long double ld;
#define int long long
#define double ld
typedef map<int, int> mii;
typedef pair<int, int> pii;
typedef pair<string, int> psi;
typedef pair<int, string> pis;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<pii> vpii;
typedef vector<char> vc;

template<class T>
void show(const vector<T> &a)
{
	for (T x : a)
		cout << x << " ";
	cout << endl;
}

const int sze = 1e5 + 50, oo = 1e18 + 500, mod = 1e9 + 7;
const double eps = 1e-9, PI = 2 * acos(0.0);
vi vertices[sze];
vc visit(sze, false);
vi arr(sze, 0);
int n, m, k;
int A, B;
int cnt = 0;
//int s, t;
//
//struct edge {
//	int from, to, flow, cap;
//};
//
//vector<edge> e;
//
//void add_edge(int u, int v, int w)
//{
//	edge e1 = { u, v, 0, w };
//	edge e2 = { v, u, 0, 0 };
//
//	vertices[u].pb(e.size());
//	e.pb(e1);
//	vertices[v].pb(e.size());
//	e.pb(e2);
//}
//
//int d[sze], ptr[sze];
//
//bool bfs()
//{
//	queue<int> q;
//	q.push(s);
//
//	fill(d, d + n + 10, -1);
//	d[s] = 0;
//
//	while (!q.empty() && d[t] == -1)
//	{
//		int v = q.front();
//		q.pop();
//
//		for (auto id : vertices[v])
//		{
//			int to = e[id].to;
//
//			if (d[to] == -1 && e[id].cap > e[id].flow)
//			{
//				q.push(to);
//				d[to] = d[v] + 1;
//			}
//		}
//	}
//
//	return d[t] != -1;
//}
//
//int dfs(int v, int flow)
//{
//	if (!flow)
//		return 0;
//
//	if (v == t && flow != oo)
//		return flow;
//
//	for (; ptr[v] < vertices[v].size(); ptr[v] ++)
//	{
//		int id = vertices[v][ptr[v]];
//		int to = e[id].to;
//
//		if (d[to] != d[v] + 1) continue;
//
//		int pushed = dfs(to, min(flow, e[id].cap - e[id].flow));
//
//		if (pushed)
//		{
//			e[id].flow += pushed;
//			e[id ^ 1].flow -= pushed;
//			return pushed;
//		}
//	}
//
//	return 0;
//}
//
//
//int dinic()
//{
//	int flow = 0;
//
//	while (bfs())
//	{
//		fill(ptr, ptr + n + 10, 0);
//		while (int pushed = dfs(s, oo))
//		{
//			flow += pushed;
//		}
//	}
//
//	return flow;
//}
//
//bool from[sze], to[sze];


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

	int a, b;
	cin >> k >> a >> b;

	if (b <= a + 2)
	{
		cout << k + 1;
	}
	else
	{
		int ans = 1 + min(k, a - 1);
		k -= min(k, a - 1);
		cnt = k / 2;
		ans += cnt*(b - a);
		ans += k - cnt * 2;
		cout << ans;
	}

	return 0;
}



Measured memory_bytes: 3456
#!/usr/bin/env python3
import sys
from collections import deque, Counter
from heapq import heappop, heappush
from bisect import bisect_right
from itertools import accumulate

sys.setrecursionlimit(10**6)
INF = 10**12
m = 10**9 + 7

def main():
    N = input()
    res = 0
    for i in range(len(N)):
        res += int(N[i])
    print('Yes') if res % 9 == 0 else print('No')

if __name__ == "__main__":
    main()


Measured memory_bytes: 68572
#include <bits/stdc++.h>
using namespace std;
int N,ans;
map<int,int>mp;
int main() {
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    cin>>N;
    for(int i=0;i<N;i++){
        int x;
        cin>>x;
        mp[x-1]++;
        mp[x]++;
        mp[x+1]++;
    }
    for(int i=-10;i<100010;i++){
        ans=max(ans,mp[i]);
    }
    cout<<ans;
}


Measured memory_bytes: 4992
from math import floor
# 約数全列挙(ソート済み)
# n = 24 -> [1,2,3,4,6,8,12,24]
def divisor(n):
    left = [1]
    right = [n]
    sup = floor(pow(n,1/2))
    for p in range(2,sup+1):
        if n % p == 0:
            if p == n//p:
                left.append(p)
                continue
            left.append(p)
            right.append(n//p)
    res = left + right[::-1]
    return res

ans_list = []

def main():
    while True:
        ans = solve()
        if ans == "end":
            break
        ans_list.append(ans)
    
    for ans in ans_list:
        print(ans)

def solve():
    n = int(input())
    if n == 1:
        return "end"
    cand = [c for c in divisor(n) if c % 7 in (1,6)]
    ans = "{}:".format(n)
    for c in cand:
        flag = True
        for p in [p for p in divisor(c) if p % 7 in (1,6)]:
            if p not in (1,c):
                flag = False
                break
        if c > 1 and flag is True:
            ans += " {}".format(c)
    return ans

main()


Measured memory_bytes: 5912
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <climits>
#include <utility>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int INF=1<<29;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int N,sum=0;
	cin>>N;
	vector<int> P(N);
	for(int i=0;i<N;i++) cin>>P[i];
	for(int i=0;i<N;i++){
		if(P[i]!=i+1) sum++;
	}
	if(sum==2 || sum==0) cout<<"YES\n";
	else cout<<"NO\n";
	return 0;
}

Measured memory_bytes: 256
/*
  KUNAL ANAND
  MNNIT ALLAHABAD
*/  
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define debug1(x) cout << # x << " " << x << endl;
#define debug2(x,y) cout << #x << " " << x << " " << #y << " " << y << endl;
#define debug3(x,y,z) cout << #x << " " << x << " " << #y << " " << y << " " << #z << " " << z << endl;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
typedef long long int ll;
const ll INF=1e14;
const ll mod=1e9+7;
ll dp[100005][3],ans=LLONG_MIN,var=0;
vector<ll>graph[100005];
ll nod_val[100005];
ll power(ll x,ll y)
{
    if(y==0)
        return 1;
    ll a=power(x,y/2);
    a=(a*a);
    if(y%2)
        a=(a*x);
    return a;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll t,x;
    ll i,j,k,a,b,n,m,q,y,flag=0,c,d,sum=0,cr=0,maxi=0,cl=0,temp,curr,l,r,sum1,sum2,sum3,low,high,mid;
    cin >> n;
    ll A[n],B[n],C[n];
    for(i=0;i<n-1;i++)
        cin >> B[i];
    A[0]=A[1]=B[0];
    for(i=1;i<n-1;i++)
    {
        if(B[i]<A[i])
        {
            A[i]=B[i];
            A[i+1]=B[i];
        }
        else
            A[i+1]=B[i];
    }
    ll ans=0;
    for(i=0;i<n;i++)
        ans+=A[i];
    cout << ans << endl;
    return 0;
}    

Measured memory_bytes: 3584
#![allow(unused_imports)]
use proconio::{
   fastout, input,
   marker::{Bytes, Isize1, Usize1},
};

#[fastout]
fn main() {
   input! {
      n: usize,
      m: usize,
      xyz: [(i64, i64, i64); n]
   }

   let mut ans = 0;
   for i in [1, -1].iter() {
      for j in [1, -1].iter() {
         for k in [1, -1].iter() {
            let mut s: Vec<_> = xyz.iter().map(|&(x, y, z)| i * x + j * y + k * z).collect();
            s.sort();
            let mut x = 0;
            for i in 0..m {
               x += s[n - 1 - i];
            }
            ans = std::cmp::max(ans, x);
         }
      }
   }
   println!("{}", ans);
}


Measured memory_bytes: 2248
/*
　　こんにちは。あたしはｶｳｶﾞｰﾙ。
　　redcoderになるためAtCoderを巡る旅をしてます。

　　　 　 ＿_
　　　 ヽ|＿_|ノ　　　　ﾓｫ
　　　　||‘‐‘||ﾚ　　_)_, ―‐ 、
　　　　/(Ｙ (ヽ＿ /・ ヽ　　 ￣ヽ
　　　　∠ ＿ ゝ　 ｀^ヽ ﾉ.::::_(ノヽ
　　　　 _/ヽ　 　　  /ヽ￣￣/ヽ
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl

#define rep(i, n) REP(i, 0, n)                  // 0, 1, ..., n-1
#define REP(i, x, n) for(int i = x; i < n; i++) // x, x + 1, ..., n-1
#define FOREACH(x, a) for(auto &(x) : (a))

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()

#define COUT(x) cout << (x) << endl

template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}

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

    int n;
    cin >> n;
    bool check = false;
    REP(i, 1, 10) {
        REP(j, 1, 10) {
            if(i * j == n) check = true;
        }
    }
    Yes(check);
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;

public class Main{

    /**
     * @param args
     */
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int[] ps = getPrimes();
        while(true){
            long m = sc.nextInt();
            int a = sc.nextInt();
            int b = sc.nextInt();
            if(m+a+b==0)break;
            double e = 1e-9;
            long ansp=0,ansq=0;
            long max  =-(1<<29);
            for (int i = 0; i < ps.length; i++) {
                for (int j = i; j < ps.length; j++) {
                    long p = ps[i];
                    long q = ps[j];
                    long pq  =p*q;
                    if(pq>m)break;
                    if((double)a/b <= (double)p/q+e && (double)p/q <= 1+e){
                        if(max < pq){
                            max= pq;
                            ansp=p;
                            ansq=q;
                        }
                    }
                }
            }
            System.out.println(ansp+" "+ansq);
        }
    }
    static int[] getPrimes(){
        List<Integer>list = new LinkedList<Integer>();
        boolean[] p = new boolean[100000/2 + 10];
        Arrays.fill(p, true);
        p[0]=p[1]=false;
        for (int i = 2; i*i <= p.length; i++) {
            if(p[i]){
                for (int j = i+i; j < p.length; j+=i) {
                    p[j]=false;
                }
            }
        }
        for (int i = 0; i < p.length; i++) {
            if(p[i])list.add(i);
        }
        
        Integer[] res =list.toArray(new Integer[list.size()]);
        int[] res2 = new int[res.length];
        for (int i = 0; i < res2.length; i++) {
            res2[i]=res[i];
        }
        return res2;
    }
}

Measured memory_bytes: 29564
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] S = new int[n];
        for (int i = 0; i < n; i++) {
            S[i] = scanner.nextInt();
        }
        int q = scanner.nextInt();
        int cnt = 0;
        for (int i = 0; i < q; i++) {
            if (binarySearch(S, scanner.nextInt()) != -1) {
                cnt++;
            }
        }
        System.out.println(cnt);
    }

    private static int binarySearch(int[] a, int key) {
        int lo = 0;
        int hi = a.length - 1;
        while (lo <= hi) {
            int mid = (lo + hi) / 2;
            if (a[mid] > key) {
                hi = mid - 1;
            } else if (a[mid] < key) {
                lo = mid + 1;
            } else {
                return mid;
            }
        }
        return -1;
    }
}

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

int main()
{
	int a, b, c, d;
	bool can = false;

	cin >> a >> b >> c >> d;

	if (abs(a-c) <= d)
	{
		can = true;
	} else if (abs(a-b) <= d)
	{
		if (abs(b-c) <= d)
		{
			can = true;
		}
	}

	if (can)
	{
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}

	return 0;
}

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

using namespace std;

int get(char a,char b,char c)
{
	if (a==b&&b==c) return 0;
	if (a!=b&&a!=c&&b!=c) return 2;
	if (a==b||b==c||a==c) return 1;
}

int main() {
	int n;
	string a,b,c;
	cin>>n;
	cin>>a>>b>>c;
	int ans=0;
	for (int i=0;i<n;i++)
		ans+=get(a[i],b[i],c[i]);
	cout<<ans<<endl;
	return 0;
}

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

#define INF 100100100
#define MOD 1000000007

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

using namespace std;
using ll = long long;
using ull = unsigned long long ;

struct edge{ll to,cost;};

int main(int argc, char const* argv[]){
   ios::sync_with_stdio(false);
   cin.tie(0);
   int N;
   cin >> N;
   vector<int> T(N),A(N);
   FOR(i,N)cin >> T[i] >> A[i];
   ull t=T[0],a=A[0];
   ull right,left,mid;
   for(int i=1;i<N;i++){
      left = 0;
      right = 480000000000000000;
      while(right-left > 1){
         mid = (left+right)/2;
         if(T[i]*mid>=t&&A[i]*mid>=a) right = mid;
         else left = mid;
      }
      a = right*A[i];
      t = right*T[i];
   }
   cout << a+t << endl;
   return 0;
}


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


int main(){
  int r, g, b; cin >>r >> g >> b;
  int K;cin >> K;
  int flag = 0;
  while(K--){
    if(g <= r) {
      g *= 2;
      continue;
    }
    if(b <= g){
      b *= 2;
    }
    if(b > g && g > r) {
      flag=1;
      break;
    }
  }
  if(flag) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}


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

ll h,w;
char a[100][100];

void search(ll x,ll y){

    a[x][y]='.';
    if(a[x+1][y]=='#'){
        search(x+1,y);
    }else if(a[x][y+1]=='#'){
        search(x,y+1);
    }
    return;
}

void solve(){
    bool flag=true;
    string ans="Possible";

    cin>>h>>w;
    for(ll i=0;i<h;++i){
        for(ll j=0;j<w;++j){
            cin>>a[i][j];
        }
    }

    if(a[0][0]=='#'){
        search(0,0);
    }else{
        cout<<ans<<endl;
    }

    for(ll i=0;i<h;++i){
        for(ll j=0;j<w;++j){
            if(a[i][j]=='.'){
                continue;
            }else{
                flag=false;
                break;
            }
        }
    }
    if(flag){
        cout<<"Possible"<<endl;
        return;
    }else{
        cout<<"Impossible"<<endl;
        return;
    }
}

int main(){
    solve();
}


Measured memory_bytes: 384
t1,t2=map(int,input().split())
a1,a2=map(int,input().split())
b1,b2=map(int,input().split())
n1=(b1-a1)*t1
n2=(b2-a2)*t2
if n1*n2>0 or abs(n1)>abs(n2):
  print(0)
elif abs(n1)==abs(n2):
  print('infinity')
else:
  c=abs(n1)//abs(n1+n2)
  while (c+1)*abs(n1+n2)<=abs(n1):
    c+=1
  ans=2*c
  if abs(n1)%(abs(n1+n2))!=0:
    ans+=1
  print(ans)

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

int main(void)
{
    IOS
    const int N = 1e6;
    int n; cin >> n;
    vector<int> v(N+10);
    REP(i,n) {
        int x; cin >> x;
        v[x]++;
    }

    int ans = 0;
    REP(i,N-2) {
        ans = max(ans,v[i] + v[i+1] + v[i+2]);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4224
# require "set"

s = gets.to_s.chomp.bytes
x, y = gets.to_s.split.map{|t| t.to_i }

# p "FT".bytes # => [70, 84]
state = 0
yoko = []
tate = []
tmp = 0
s.each do |c|
  
  if c == 70
    tmp += 1
  else
    if state == 0
      yoko << tmp
    else
      tate << tmp
    end
    tmp = 0
    state = 1 - state
  end
end

if state == 0
  yoko << tmp
else
  tate << tmp
end

sx = sy = 0
if s[0] == 70
  sx = yoko.shift
end

# yoko.sort!
# tate.sort!

hx = { sx => true }
yoko.each do |d|
  t = {}
  hx.each do |k, v|
    t[k+d] = true
    t[k-d] = true
  end
  hx = t
end

hy = { sy => true }
tate.each do |d|
  t = {}
  hy.each do |k, v|
    t[k+d] = true
    t[k-d] = true
  end
  hy = t
end

puts ( hx[x] && hy[y] ) ? "Yes" : "No"


Measured memory_bytes: 87676
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_E main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LLONG_MAX/2)
const int MGN = 10;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
using psi = pair<string, int>;
// functions

#endif

vvi es;
vvi games;

vb vis;
vb done;
vi dp;
int M;
int dfs(int n) {
    if (n >= M) return -1;
    // Found a cycle
    if (vis[n] && !done[n]) return -1;

    if (dp[n] >= 1) return dp[n];    

    vis[n] = true; // visitting
    dp[n] = 1; // day 1

    for (int i : es[n]) {
        int res = dfs(i);
        if (res == -1) return -1;

        dp[n] = max(dp[n], res + 1);
    }

    done[n] = true; // visited

    return dp[n];
}


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

    int N; cin >> N;
    vvi A(N, vi(N-1));
    REP(i,N) {
        REP(j,N-1) {
            cin >> A[i][j];
            A[i][j]--;
        }
    }

    games = vvi(N, vi(N));
    int gm_id = 0;
    REP(i,N) {
        REP(j,N) {
            if (i < j) {
                games[i][j] = gm_id;
                games[j][i] = gm_id;
                gm_id++;
            }
        }
    }

    M = gm_id;
    vvi prog(N, vi(N));
    set<pii> st;
    es = vvi(M);
    REP(i,N) {
        REP(j,N-2) {
            int g1 = games[i][A[i][j]];
            int g2 = games[i][A[i][j+1]];

            if (st.count(pii(g1, g2)) == 0) st.insert(pii(g1, g2));
            else continue;

            es[g1].push_back(g2);
        }
    }

    int ans = 0;
    vis = vb(M, false);
    done = vb(M,false);
    dp = vi(M, -1);
    // dp[i] := Max path length from i

    REP(i, M) {
        int res = dfs(i);

        if (res == -1) {
            ans = -1;
            break;
        }

        ans = max(ans, res);
    }

    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 88320
#include <bits/stdc++.h>
#define lsb(x) (x & (-x))
#define ll long long
#define ull unsigned long long
#define uint unsigned int


using namespace std;

const int MAXN = 100;

char mat[MAXN + 1][MAXN + 1];

int main() {
#ifdef HOME
    ifstream cin("A.in");
    ofstream cout("A.out");
#endif
    int i, j, n, m;
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    cin >> n >> m;
    for(i = 1; i <= n; i++) {
    	cin >> (mat[i] + 1);
    }
   	vector<vector<int>> dp(n + 1, vector<int>(m + 1, 1e9));
   	dp[1][1] = (mat[1][1] == '#');
   	for(i = 1; i <= n; i++) {
   		for(j = 1; j <= m; j++) {
   			dp[i][j] = min(dp[i][j], dp[i - 1][j] + (mat[i][j] == '#' && mat[i - 1][j] == '.'));
   			dp[i][j] = min(dp[i][j], dp[i][j - 1] + (mat[i][j] == '#' && mat[i][j - 1] == '.'));
   		}
   	}
   	cout << dp[n][m];

    return 0;
}


Measured memory_bytes: 256