akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define vpii vector<pair<int,int> >
#define F first
#define S second
#define ld long double
#define built __builtin_popcountll
int const M=2e5+10,M2=1e6+10,mod=1e9+7,inf=1e9+10;
ll max3(ll x,ll y,ll z) {return max(max(x,y),z);}
ll min3(ll x,ll y,ll z) {return min(min(x,y),z);}
ll pow(ll a, ll b){ll res = 1;for(int i = 1; i<=b; ++i) res *= a;return res;}
ll isPrime(ll n){for(ll i=2; i<=sqrt(n); i++){if(n%i==0) return 0;}return 1;}
ll fact(ll n){if(n==0 || n==1) return 1; else return n*fact(n-1);}
ll gcd (ll a, ll b) {return b ? gcd (b, a % b) : a;}
ll lcm(ll a, ll b){return (a/gcd(a,b))*b;}
int a[18]={2,3,5,7,11,13,13,17,19,23,29,31,37,41,43,47,53,59};
void Sieve(ll n, ll prime[]){for(int p=2; p*p<=n; p++){if(prime[p] == true){for(int i=p*2; i<=n; i += p)prime[i] = false;}}for(int p=2; p<=n; p++)if(prime[p])cout << p << " ";}


int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	string s,t;
	cin >> s;
	for(ll i=0; i<s.size(); i++){
        if(s[i]=='1'){
            t+='9';
        }
        else t+='1';
	}
	cout << t;
	return 0;
}
/* The judge is never wrong! Your code is buggy 😈
   Look for:
 * * an easier and alternate approach
 * * read the problem statement carefully
 * * if concept is correct and still WA, try with a different implementation
 * * special cases (n=1?)
 * * overflow (ll vs int?)
 * * array bounds
 * * if you have no idea just guess the appropriate well-known algorithm instead of doing nothing :/
 */


Measured memory_bytes: 256
<?php
list($a,$b,$k)=explode(" ",trim(fgets(STDIN)));
$i=0;
while($i<$k){
	if($i%2==0){
		$a=floor($a/2);
		$b+=$a;
	}else{
		$b=floor($b/2);
		$a+=$b;
	}
	++$i;
}
echo $a." ".$b;

Measured memory_bytes: 4856
import os

import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353

N = int(sys.stdin.buffer.readline())
S = [sys.stdin.buffer.readline().decode().rstrip() for _ in range(N)]


def solve():
    diffs = []
    max_downs = []
    for s in S:
        diff = 0
        mi = 0
        for c in s:
            diff += 1 if c == '(' else -1
            mi = min(diff, mi)
        diffs.append(diff)
        max_downs.append(-mi)

    if sum(diffs) != 0:
        return False

    positives = []
    zeros = []
    negatives = []
    for i, d in enumerate(diffs):
        if d > 0:
            positives.append((max_downs[i], d, i))
        elif d < 0:
            negatives.append(((-max_downs[i] - d), d, i))
        else:
            zeros.append((max_downs[i], d, i))

    positives.sort()
    zeros.sort()
    negatives.sort()
    pos = 0
    for down, diff, i in positives:
        if down > pos:
            return False
        pos += diff
    for down, diff, i in zeros:
        if down > pos:
            return False
        pos += diff
    for down, diff, i in negatives:
        pos += diff
        down = -down
        if down > pos:
            return False

    assert pos == 0
    return True


ok = solve()
if ok:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 135544
#include<bits/stdc++.h>
using namespace std;
const int N=200005;
int n,a[27],f[N],g[N],dp[N];
char s[N];
int main()
{
    scanf("%s",s+1);
    n=strlen(s+1);
    f[n+1]=n+2;
    g[n+1]=1;
    dp[n+1]=1;
    for (int i=1; i<=26; i++)
    {
        a[i]=n+1;
    }
    for (int i=n; i>=1; i--)
    {
        a[s[i]-'a'+1]=i;
        int t=1;
        for (int j=2; j<=26; j++)
        if (dp[a[j]+1]<dp[a[t]+1])t=j;
        dp[i]=dp[a[t]+1]+1;
        f[i]=a[t];
        g[i]=t;
    }
    int now=1;
    while(now<=n+1)
    {
        putchar(g[now]+'a'-1);
        now=f[now]+1;
    }
    return 0;
}


Measured memory_bytes: 2816
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll u[2005],v[2005],c[2005],dist[2005];
void solve(int n,int m)
{
    for(int i=0; i<n-1; i++)
    {
        for(int j=0; j<m; j++)
        {
            if(dist[u[j]]==inf)
                continue;
            if(dist[v[j]]>dist[u[j]]+c[j])
                dist[v[j]] = dist[u[j]] + c[j];
        }
    }
}
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    int n,m;
    cin>>n>>m;
    for(int i=1; i<=n; i++)
        dist[i]=inf;
    for(int i=0; i<m; i++)
    {
        cin>>u[i]>>v[i]>>c[i];
        c[i]*=-1;
    }
    dist[1]=0;
    solve(n,m);
    ll ans=dist[n];
    solve(n,m);
    if(ans!=dist[n])
        cout<<"inf"<<endl;
    else
        cout<<ans*-1<<endl;


    return 0;
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using vl=vector<long long>;
using pii=pair<int,int>;
using pll=pair<long long,long long>;
#define ITR(i,c) for(auto i=begin(c);i!=end(c);++i)
#define FORE(x,c) for(auto &x:c)
#define FOR(i,a,n) for(int i=a,i##_len=(int)(n);i<i##_len;++i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i=(int)(n);i>=0;--i)
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)   // c++14
#define SZ(c) ((int)c.size())
#define EXIST(c,x) (c.find(x)!=end(c))
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
#define INF (1001001001)
#define INFLL (1001001001001001001ll)
template<class T> ostream& operator << (ostream &os,const vector<T> &v) {
    ITR(i,v) os << *i << (i==end(v)-1 ? "" : " "); return os; }
template<class T> istream& operator >> (istream &is,vector<T> &v) {
    ITR(i,v) is >> * i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
        is >> p.first >> p.second; return is; }
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;}
//------------------------------------------------------------------------------
struct before_main_function {
    before_main_function() {
        #ifdef int
            #undef INF
            #define INF INFLL
            #define stoi stoll
        #endif
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
    }
} before_main_function;
//------------------------------------------------------------------------------

signed main() {
    int w,a,b;
    cin>>w>>a>>b;
    if(min(a,b)+w>=max(a,b)) cout<<0<<endl;
    else cout<<max(a,b)-(min(a,b)+w)<<endl;
    return 0;
}


Measured memory_bytes: 256
A = [[0 for i in range(3)] for j in range(3)]
t1 = list(map(int,input().split()))
t2 = list(map(int,input().split()))
t3 = list(map(int,input().split()))
A[0],A[1],A[2] = t1,t2,t3
N = int(input())
b = [int(input()) for i in range(N)]

P = [[0 for i in range(3)] for j in range(3)]

for i in range(3):
    for j in range(3):
        for s in range(N):
            if b[s] == A[i][j]:
                P[i][j] = 1
o = 0
for i in range(3):
    if (P[i][0] and P[i][1] and P[i][2]) == 1: o=1
    if (P[0][i] and P[1][i] and P[2][i]) == 1: o=1
    if (P[0][0] and P[1][1] and P[2][2]) == 1: o=1
    if (P[0][2] and P[1][1] and P[2][0]) == 1: o=1
if o==1: print('Yes')
else: print('No')


Measured memory_bytes: 3064
#include<cstdio>
#include<cstring>
#include<cctype>
#include<cmath>
#include<algorithm>
#define ll long long
using namespace std;
int read()
{
    char c;int s=0,t=1;
    while(!isdigit(c=getchar()))if(c=='-')t=-1;
    do{s=s*10+c-'0';}while(isdigit(c=getchar()));
    return s*t;
}
/*------------------------------------------------------------*/
const int inf=0x3f3f3f3f;
 
int N,M,n,m;
 
int main()
{
    scanf("%d%d%d%d",&N,&M,&n,&m);
    if(N%n==0&&M%m==0){printf("No");return 0;}
    printf("Yes\n");
    for(int i=1;i<=N;i++){
        for(int j=1;j<=M;j++)
            printf("%d ",i%n||j%m?1100:-1100*(n*m-1)-1);
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 1536
/*input
10 37
.....................................
...#...####...####..###...###...###..
..#.#..#...#.##....#...#.#...#.#...#.
..#.#..#...#.#.....#...#.#...#.#...#.
.#...#.#..##.#.....#...#.#.###.#.###.
.#####.####..#.....#...#..##....##...
.#...#.#...#.#.....#...#.#...#.#...#.
.#...#.#...#.##....#...#.#...#.#...#.
.#...#.####...####..###...###...###..
.....................................
*/
#include <bits/stdc++.h>
using namespace std;
const long long md=1e9+7;
long long dis[55][55],n,dx[]={1,-1,0,0},dy[]={0,0,1,-1};

int main(){
	#ifdef ONLINE_JUDGE
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	#endif
	long long w,q,m,k,h,ans=0,sum=0,p,x,y;
	cin>>h>>w;
	string s[55];
	for(int i=1;i<=h;++i){
		cin>>s[i];
		for(auto c:s[i]) sum+=(c=='.');
		s[i]='*'+s[i];
	}
	for(int i=0;i<55;++i)
		fill_n(dis[i],55,1e9);
	priority_queue<pair<int,pair<int,int>>,vector<pair<int,pair<int,int>>>,greater<pair<int,pair<int,int>>>> pq;
	dis[1][1]=1;
	pq.push({dis[1][1],{1,1}});
	while(!pq.empty()){
		auto u = pq.top().second;
		pq.pop();
		int x = u.first, y = u.second;
		for(int i = 0; i<4;++i){
			int tox = x+dx[i], toy = y+dy[i];
			if(tox>0 && toy>0 && tox<=h && toy<=w){
				if(s[tox][toy]!='.') continue;
				int d = dis[x][y] + 1;
				if(dis[tox][toy]>d){
					dis[tox][toy]=d;
					pq.push({dis[tox][toy],{tox,toy}});
				}
			}
		}
	}

	if(dis[h][w]>1e8) cout<<"-1";
	else cout<<sum-dis[h][w];
}

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

using namespace std;
int main (){
  int N,K;
  cin >> N >> K;
  
  int s[N];
  int max = 200000;
  vector<int> vec(max+1,0);
  
  for(int i=0;i<N;i++){
    cin >> s[i];
    vec[s[i]] += 1;}
  
  int now = 0;
  for(int i=0;i<max+1;i++){
    if(vec[i]>0) now += 1;}
  
  sort (vec.begin(),vec.end());
  
  int answer=0;
  
  
  for(int i=0;;i++){
    if (vec[i]==0) continue;
    if (now>K) {now -= 1; answer += vec[i];}
    else break;}
  
  cout << answer;
  
}

Measured memory_bytes: 1792
a, b, c, d = map(int, input().split())
if b>=0 and d>=0:  
  if a<=0 and c<=0:
    ans = max(b*d, a*c)
  else:
    ans = b*d
elif b<0 and d<0:
  ans = a*c
elif b>=0 and d<=0:
  if a <= 0:
    ans = a*c
  else:
    ans = a*d
elif b<=0 and d>=0:
  if c <= 0:
    ans = a*c
  else:
    ans =c*b
print(ans)

Measured memory_bytes: 9220
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException{
		final BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		String str;
		int a[]=new int[26];
		while((str=br.readLine())!=null){
		
		str=str.toLowerCase();
		
		for(int i=0;i<str.length();i++){
			char ch=str.charAt(i);
			if(ch<='z'&&ch>='a') a[ch-97]++;
		}
		}
		for(int i=0;i<26;i++){
			System.out.println((char)('a'+i) +" : "+a[i]);
		}
		
		
	}
}

Measured memory_bytes: 16872
#include <cstring>
#include <map>
#include <unordered_map>
#include <string>
#include <list>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <cstdio>
#include <iostream>
#include <set>
#include <unordered_set>
using namespace std;

#define MAX(a,b) (a>b?a:b)
#define MIN(a,b) (a<b?a:b)
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int, int> pii;

int gi() {
    int a;
    scanf("%d", &a);
    return a;
}

ll gli() {
    ll a;
    scanf("%lld", &a);
    return a;
}

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

    int m = gi();
    int d = gi();
    int y = 0;
    if (m == 1 || m == 3 || m == 5 || m == 7 || m == 8 || m == 10 || m == 12)
        y = (d == 31);
    else if (m == 2)
        y = (d == 28);
    else
        y = (d == 30);

    printf(y ? "1\n" : "0\n");

    return 0;
}


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

#define REP( i, n )     for( int (i) = 0; (i) < (n); (i)++ )
#define ALL( a )        (a).begin(), (a).end()

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

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( a > b ) { a = b; return 1; } return 0; }

constexpr int INF = 1e9 + 1;
constexpr ll LINF = 1e18;
constexpr int MOD = 1e9 + 7;

int main(){
    ll N, a, b; cin >> N >> a >> b;

    if( ( b - a ) % 2 == 0 ){
        cout << ( b - a ) / 2 << endl;
    }else{
        ll ans = 0;
        if( a - 1 < N - b ){
            ans += a - 1;
            ans += ( b - a ) / 2 + 1;
        }else{
            ans += N - b;
            ans += ( b - a ) / 2 + 1;
        }

        cout << ans << endl;
    }
}

/*

*/

Measured memory_bytes: 256
from math import gcd
q = int(input())
mod = 10**9+7
tan = 100
tab = [[[0]*2 for _ in range(tan)] for _ in range(tan)]

for _ in range(q):
    x, y = sorted(map(int, input().split()))

    ma = 0
    i, j = 1, 1
    while j <= x and i+j <= y:
        i, j = j, i+j
        ma += 1
    if x == 1 or y <= 2:
        print(1, x*y % mod)
    else:
        ans = 0
        if x >= i:
            ans += max(0, (y-j) // i+1)
        if y >= i:
            ans += max(0, (x-j) // i+1)
        i, j = 1, 1
        for c in range(ma-1):
            k, l = j, i+j*2
            for _ in range(ma-c-1):
                k, l = l, k+l
            if x >= k:
                ans += max(0, (y-l) // k+1)
            if y >= k:
                ans += max(0, (x-l) // k+1)
            i, j = j, i+j
        print(ma, ans % mod)


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ITR(x,c) for(__typeof(c.begin() x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin() x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define lf double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n, x; cin>>n>>x;
	vll p(n+1), w(n+1);
	p[0] = 1, w[0] = 1;
	rep(i, n){
		p[i+1] = 2*p[i]+1;
		w[i+1] = 2*w[i]+3;
	}
	ll ans=0;
	while(x>0){
		x--;

		if (x >= w[n-1]){
			x -= w[n-1];
			ans += p[n-1];
		}else{
			n--;
			continue;
		}

		if (x>0)
			x--, ans++;
		else
			break;

		if (x >= w[n-1]){
			x -= w[n-1];
			ans += p[n-1];
		}else{
			n--;
			continue;
		}
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    for(int i=0;i<7;i++){
        int a,b;
        scanf("%d %d",&a,&b);
        printf("%d\n",a-b);
    }
    return 0;
}

Measured memory_bytes: 1188
#include<stdio.h>

int main(){
    
    int m,f,r;
    
    while(1){
        scanf("%d%d%d",&m,&f,&r);
        if(m==-1&&f==-1&&r==-1)break;
        
        if(m==-1||f==-1){
            printf("F\n");
        }else if(m+f>=80){
            printf("A\n");
        }else if(m+f>=65){
            printf("B\n");
        }else if(m+f>=50){
            printf("C\n");
        }else if(m+f>=30){
            if(r>=50){
                printf("C\n");
            }else{
                printf("D\n");
            }
        }else{
            printf("F\n"); 
        }
        
    }
    return 0;
}



Measured memory_bytes: 2004
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int,int> P;
 
const int INF = 1e9;
const int mod = 1e9+7;
const double EPS = 1e-10;
const double PI = acos(-1.0);
 
int main()
{
    ll k,a,b;
    cin >> k >> a >> b;
    ll ans = 1;
    ans += min(k,a-1);
    k -= min(k,a-1);
    if(b-a > 2){
        ans += k/2*(b-a);
        ans += k%2;
    }else ans += k;
    cout << ans << endl;
    return 0;
}

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

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

Measured memory_bytes: 256
#include <stdio.h>

using namespace std;

int main(int argc, const char * argv[]) {
    int n, taro_point = 0, hanako_point = 0, j;
    char taro_card[101], hanako_card[101];
    scanf("%d", &n);
    for(int i = 0; i < n; i++){
        scanf("%s %s", taro_card, hanako_card);
        for(j = 0; taro_card[j] != '\0' && hanako_card[j] != '\0' && taro_card[j] == hanako_card[j];j++);
        if(taro_card[j] == '\0'){
            if(hanako_card[j] == '\0'){
                taro_point += 1;
                hanako_point += 1;
            }else{
                hanako_point += 3;
            }
        }else if(hanako_card[j] == '\0'){
            taro_point += 3;
        }else if(hanako_card[j] > taro_card[j]){
            hanako_point += 3;
        }else{
            taro_point += 3;
        }
    }
    printf("%d %d\n", taro_point, hanako_point);
    return 0;
}



Measured memory_bytes: 2736
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cctype>
 
#include <algorithm>
#include <random>
#include <bitset>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <vector>
#include <chrono>
#include <iostream>
#include <limits>
#include <numeric>
 
#define LOG(FMT...) fprintf(stderr, FMT)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int N = 200010;

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

int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i)
    scanf("%d", &a[i]);
  for (int i = 0; i < n; ++i)
    scanf("%d", &b[i]);
  ll ans = 0;
  priority_queue<pair<int, int>> q;
  for (int i = 0; i < n; ++i)
    q.emplace(b[i], i);
  while (!q.empty()) {
    int p, v;
    tie(v, p) = q.top(); q.pop();
    if (b[p] == a[p]) continue;
    if (b[p] < a[p]) {
      puts("-1");
      return 0;
    }
    int s = b[(p + 1) % n] + b[(p + n - 1) % n];
    if (b[p] < s) {
      puts("-1");
      return 0;
    }
    if (a[p] >= s) {
      if ((b[p] - a[p]) % s == 0) {
        ans += (b[p] - a[p]) / s;
        b[p] = a[p];
        continue;
      } else {
        puts("-1");
        return 0;
      }
    } else {
      ans += b[p] / s;
      b[p] %= s;
    }
    if (b[p] < a[p]) {
      puts("-1");
      return 0;
    }
    q.emplace(b[p], p);
  }
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 3956
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll INF = 9223372036854775807; //10^18
const int inINF = 2147483647; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int main(){
    int n, a, b;
    cin >> n >> a >> b;
    if((b-a) % 2 == 1){
        printf("Borys\n");
    }
    else{
        printf("Alice\n");
    }
}

Measured memory_bytes: 3588
use std::collections::BTreeSet;
fn solve(_n: &str) -> usize {
    let mut a = String::new();
    std::io::stdin().read_line(&mut a).unwrap();
    let u: BTreeSet<i32> = a.split_whitespace().map(|x|x.parse().unwrap()).collect();
    (u.len()+1)/2*2-1
}
fn main() {
    loop {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        let s = s.trim_right();
        if s=="" { break; }
        println!("{}",solve(&s));
    }
}

Measured memory_bytes: 2300
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        String T = sc.next();
        if(S.length() + 1 != T.length()) {
            System.out.println("No");
            return;
        }
        for(int i=0; i<S.length(); i++) {
            if(S.charAt(i) != T.charAt(i)) {
                System.out.println("No");
                return;
            }
        }
        System.out.println("Yes");
    }
}


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

int dp[4][100010];
int main() {
    cin >> n;
    vector<int> a(n, 0);
    vector<int> b(n, 0);
    vector<int> c(n, 0);
    for(int i = 0; i < n; ++i) {
        cin >> a.at(i) >> b.at(i) >> c.at(i);
    }

    dp[0][0] = a.at(0);
    dp[1][0] = b.at(0);
    dp[2][0] = c.at(0);

    for(int i = 1; i < n; ++i) {
        dp[0][i] = a.at(i) + max(dp[1][i-1], dp[2][i-1]);
        dp[1][i] = b.at(i) + max(dp[0][i-1], dp[2][i-1]);
        dp[2][i] = c.at(i) + max(dp[0][i-1], dp[1][i-1]);
    }

    cout << max({dp[0][n-1], dp[1][n-1], dp[2][n-1]}) << endl;
}

Measured memory_bytes: 2560
#include "bits/stdc++.h"
using namespace std;

#define mod 1000000007
#define INF (int) 1e9 + 5

#define add emplace
#define pb push_back
#define eb emplace_back
#define all(x) begin(x), end(x)
#define len(x) ((int)(x).size())
#define exist(a, x) (a.find(x) != end(a))
#define log(x) cout << (x) << endl;
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define rrep(i,a,b) for(int i=(int)(a);i>=(int)(b);--i)
#define loop(i,a,b) for(int i=(int)(a);i<(int)(b);++i)

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using pi = pair<int,int>;
using vpi = vector<pi>;
using vvi = vector<vi>;
using vstr = vector<string>;


int main() {
	int n; cin>>n;
	vi swim(n), catch_bugs(n), homework(n);
	rep (i, n)
		cin>>swim[i]>>catch_bugs[i]>>homework[i];

	rrep (i, n-2, 0) {
		swim[i] += max(catch_bugs[i+1], homework[i+1]);
		catch_bugs[i] += max(swim[i+1], homework[i+1]);
		homework[i] += max(catch_bugs[i+1], swim[i+1]);
	}

	cout << max(max(swim[0], catch_bugs[0]), homework[0]) << endl;
	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
string s,ss;
bool f=0;
int main()
{
	cin>>s>>ss;
	string mn=s,a=s;
	for(int i=0;i<s.size();i++){
		mn[i]='z';
	}
	if(s.size()<ss.size()) {
		cout<<"UNRESTORABLE";
		return 0;
	}
	for (int i=0;i<=s.size()-ss.size();i++)
	{
		bool fl=1;
		for (int j=0;j<ss.size();j++)
		{
			if (s[i+j]=='?') continue;
			if (s[i+j]!=ss[j])
			{
				fl=0;
				break;
			}
		}
		if (fl)
		{
		    for (int j=0;j<ss.size();j++) if (s[i+j]=='?') a[i+j]=ss[j];
		    for (int j=0;j<s.size();j++) if (a[j]=='?') a[j]='a';
		    if(mn>a) mn=a;
		    f=1;
		}
		a=s;
	}
	if(f==1) cout<<mn;
	else cout<<"UNRESTORABLE";
}

Measured memory_bytes: 3600
#pragma region // {{{ by unolight
#include <bits/stdc++.h>
#include <unistd.h>
#pragma GCC diagnostic ignored "-Wunused-result"
#pragma GCC diagnostic ignored "-Wunused-function"
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x),end(x)
#define RALL(x) rbegin(x),rend(x)
#define REP(i,n) for ( int i=0; i<int(n); i++ )
#define REP1(i,a,b) for ( int i=(a); i<=int(b); i++ )
#define MP make_pair
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef pair<int,int> PII;
typedef vector<int> VI;

namespace { namespace unolight {
// Read Input
template<class T> void _R( T &x ) { cin>>x; }
void _R( int &x ) { scanf("%d",&x); }
void _R( int64_t &x ) { scanf("%" PRId64,&x); }
void _R( double &x ) { scanf("%lf",&x); }
void _R( char &x ) { scanf(" %c",&x); }
void _R( char *x ) { scanf("%s",x); }
void R() {}
template<class T, class... U> void R( T& head, U&... tail ) { _R(head); R(tail...); }
// Write Output
template<class T> void _W( const T &x ) { cout<<x; }
void _W( const int &x ) { printf("%d",x); }
void _W( const int64_t &x ) { printf("%" PRId64,x); }
void _W( const double &x ) { printf("%.16f\n",x); }
void _W( const char &x ) { putchar(x); }
void _W( const char *x ) { printf("%s",x); }
template<class T> void _W( const vector<T> &x ) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W( const T& head, const U&... tail ) { _W(head); putchar(sizeof...(tail)?' ':'\n'); W(tail...); }

#ifdef UNOLIGHT
#include "dump.hpp"
#else
#define dump(...)
#endif

template<class T> inline bool chmax( T &a, const T &b ) { return b>a ? a=b,true : false; }
template<class T> inline bool chmin( T &a, const T &b ) { return b<a ? a=b,true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template<class T, class F=less<T>> void sort_uniq( vector<T> &v, F f=F() ) {
    sort(begin(v),end(v),f);
    v.resize(unique(begin(v),end(v))-begin(v));
}
#pragma endregion // }}}

void main() {
    int w,h;
    R(h,w);
    vector<LL> p(h), q(w);
    REP(i,h) R(p[i]);
    REP(i,w) R(q[i]);
    sort(RALL(p));
    sort(RALL(q));
    h++; w++;
    LL ans=0;
    while ( SZ(p)||SZ(q) ) {
        if ( SZ(q)==0 || (SZ(p) && p.back()<q.back()) ) {
            LL x=p.back();
            p.pop_back();
            ans+=x*w;
            h--;
        } else {
            LL x=q.back();
            q.pop_back();
            ans+=x*h;
            w--;
        }
    }
    W(ans);
}

}} // {{{ main
int main() { unolight::main(); return 0; }
// }}}

Measured memory_bytes: 4840
#include <bits/stdc++.h>
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define pll pair<ll,ll>
#define all(v) v.begin(),v.end()
#define mod 1000000007
#define mx 1000002
mt19937 myrand(time(0));

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(),cout.tie();
    ll x,y;
    cin>>x>>y;
    if(y>(4*x)){
        cout<<"No"<<endl;
        return 0;
    }
    y-=(x*2);
    if(y<0 || y&1) cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
}


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

int main() {
	int K, S;
	cin >> K >> S;
	int ans;
	ans = 0;
	for (int i = 0; i < K+1; ++i){
		for (int j = 0; j < K+1; ++j){
			int k = S - i - j;
			if (0 <= k and k <=K){
				ans++;
			}
		}
	}
	cout << ans << endl;
}

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


signed main() {
    ll A;
     cin >> A;
/*
   string B;
    cin >> B;

    B[1] = B[2];
    B[2] = B[3];
    B[3] = '\0';
    ll num = atoi(B.c_str());
*/
    double B;
    cin >> B;
    ll num = B*100 + 0.99;

    A *= num;
    A /= 100;

    cout << A << endl;
}

Measured memory_bytes: 3724
#include<iostream>
#include<string>
#include<iomanip>
using namespace std;
double a[8],b[6];
int an[8],bn[6];
int main(){
	for(int i=0;i<8;i++)
		cin>>an[i]>>a[i];
	for(int i=0;i<7;i++){
		for(int j=7;j>i;j--){
			if(a[j]<a[j-1]){
				double tmp=a[j];
				a[j]=a[j-1];
				a[j-1]=tmp;
				tmp=an[j];
				an[j]=an[j-1];
				an[j-1]=tmp;
			}
		}
	}
	cout<<an[0]<<" "<<fixed<<setprecision(2)<<a[0]<<endl;
	cout<<an[1]<<" "<<fixed<<setprecision(2)<<a[1]<<endl;
	b[0]=a[2],bn[0]=an[2],b[1]=a[3],bn[1]=an[3];
	for(int i=0;i<8;i++)
		cin>>an[i]>>a[i];
	for(int i=0;i<7;i++){
		for(int j=7;j>i;j--){
			if(a[j]<a[j-1]){
				double tmp=a[j];
				a[j]=a[j-1];
				a[j-1]=tmp;
				tmp=an[j];
				an[j]=an[j-1];
				an[j-1]=tmp;
			}
		}
	}
	cout<<an[0]<<" "<<fixed<<setprecision(2)<<a[0]<<endl;
	cout<<an[1]<<" "<<fixed<<setprecision(2)<<a[1]<<endl;
	b[2]=a[2],bn[2]=an[2],b[3]=a[3],bn[3]=an[3];
	for(int i=0;i<8;i++)
		cin>>an[i]>>a[i];
	for(int i=0;i<7;i++){
		for(int j=7;j>i;j--){
			if(a[j]<a[j-1]){
				double tmp=a[j];
				a[j]=a[j-1];
				a[j-1]=tmp;
				tmp=an[j];
				an[j]=an[j-1];
				an[j-1]=tmp;
			}
		}
	}
	cout<<an[0]<<" "<<fixed<<setprecision(2)<<a[0]<<endl;
	cout<<an[1]<<" "<<fixed<<setprecision(2)<<a[1]<<endl;
	b[4]=a[2],bn[4]=an[2],b[5]=a[3],bn[5]=an[3];
	for(int i=0;i<5;i++){
		for(int j=5;j>i;j--){
			if(b[j]<b[j-1]){
				double tmp=b[j];
				b[j]=b[j-1];
				b[j-1]=tmp;
				tmp=bn[j];
				bn[j]=bn[j-1];
				bn[j-1]=tmp;
			}
		}
	}
	cout<<bn[0]<<" "<<fixed<<setprecision(2)<<b[0]<<endl;
	cout<<bn[1]<<" "<<fixed<<setprecision(2)<<b[1]<<endl;
	return 0;
}

Measured memory_bytes: 1296
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll mod=1000000007;
int main()
{
	ll sm=0;
	int n; cin>>n;
	ll a[n];
	for(int i=0;i<n;i++)
	{
		cin>>a[i]; sm=(sm+a[i]);
	}
	ll ans=0;
	ll res=sm;
	ll act=0;
	for(int i=0;i<n-1;i++)
	{
		ll v=a[i];
		res-=a[i];
		act=res;
		act=(act%mod * v%mod ) %mod;
		ans=(ans+act)%mod;
	}
	cout<<ans;
}
	

Measured memory_bytes: 5180
from collections import deque
N = 3
m = {8: {7, 5}, 7: {8, 6, 4}, 6: {7, 3}, 5: {8, 4, 2}, 4: {7, 5, 3, 1}, 3: {6, 4, 0}, 2: {5, 1}, 1: {4, 2, 0},
     0: {3, 1}}
goal = 123456780
def g(i, j, a):
    t = a // (10 ** j) % 10
    return a - t * (10 ** j) + t * (10 ** i)
def solve():
    MAP = "".join(input().replace(" ", "") for _ in range(N))
    start = 8 - MAP.find("0")
    MAP = int(MAP)
    if MAP == goal:
        return 0
    dp = deque([(0, start, MAP)])
    LOG = {MAP}
    while dp:
        cnt, yx, M = dp.popleft()
        if M == goal:
            return cnt
        cnt += 1
        for nyx in m[yx]:
            CM = g(yx, nyx, M)
            if not CM in LOG:
                dp.append((cnt, nyx, CM))
                LOG.add(CM)
def MAIN():
    print(solve())
MAIN()



Measured memory_bytes: 25688
//C
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <vector>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define LL_MIN -9223372036854775808
#define LL_MAX 9223372036854775807
#define segment_size 65536
#define ROOP() while(true)
int main(){
    #define int long long
    int N,K;
    cin >> N >> K;
    int x[100000];
    for(int i=0; i<N; i++){
        cin >> x[i];
    }
    int ans = INT_MAX;
    for(int i=0; i+K-1<N; i++){
        if(x[i] * x[i+K-1] < 0){
            ans = min(ans, abs(x[i]) + abs(x[i+K-1]) + min(abs(x[i]), abs(x[i+K-1])) );
        }
        else{
            ans = min(ans, max(abs(x[i]), abs(x[i+K-1])) );
        }
    }
    cout << ans << endl;
    
    return 0;
}

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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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

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; }


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

    int A, B;
    cin >> A >> B;
    int ans = 0;
    vector<int> digit(5);
    int tmp = 0;
    int pow10 = 0;
    for(int i = A; i <= B; i++){
        tmp = i;
        pow10 = 10000;
        for(int j = 4; j >= 0; j--){
            digit[j] = tmp / pow10;
            tmp = tmp % pow10;
            pow10 /= 10;
        }
        if(digit[4] == digit[0] && digit[3] == digit[1]){
            ans++;
        }
    }
    
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 256
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var lines = input.split('\n');

lines.shift();
var S = lines.shift().split(' ').filter(function(val, i, arr) {
	return arr.indexOf(val) === i;
});
lines.shift();
var T = lines.shift().split(' ');

console.log(S.filter(function(i) {return T.indexOf(i) != -1;}).length);

Measured memory_bytes: 9800
import math

N, K = map(int, input().split())
R = N - K

if R == 0: #赤いボールが無い時
    print (1)
    for _ in range(1, K):
        print (0)
    exit()

if K == 1: #青いボールが1つのとき
    print (R+1)
    exit()


# K_1 = math.factorial(K-1)
# R_1 = math.factorial(R+1)
# print (K_1, R_1)
for i in range(1, K+1): #K回答えを出力
    if i > R+1:
        print (0)
        continue
    if i == 1:
        print (R + 1)
        continue
    # print (K_1, R_1, math.factorial(i))
    if i >= 2:
        position = R_1 = math.factorial(R+1)//(math.factorial(i) * math.factorial(R + 1- i))
        boal = math.factorial(K-1)//(math.factorial(i-1) * math.factorial(K - i))
    print ((position * boal)%(7 + 10 ** 9))

Measured memory_bytes: 3316
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));

    int n = Integer.parseInt(in.readLine());
    String[] str = in.readLine().split(" ");
    
    int[] h = new int[n];
    for(int i=0; i<n; i++) {
      h[i] = Integer.parseInt(str[i]);
    }
    
    in.close();
    
    int max = 0;
    boolean hantei = true;
    for(int i=0; i<n; i++) {
       max = Math.max(h[i],max);
      if(max-1 > h[i]) {
        System.out.println("No");
        return;
      }
    }
    
    System.out.println("Yes");
  }
}

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

long long n, k, a[100005] = {0}, b[100005] = {0}, t = 0;
long long memo[35] = {0};

long long solve(long long x);

int main() {
  cin >> n >> k;
  for(long long i = 0; i < n; ++i) cin >> a[i] >> b[i];
  memo[0] = 1;
  for(long long i = 1; i < 32; ++i)
    memo[i] = 2 * memo[i - 1];
  while(memo[t] <= k) ++t;
  --t;
  cout << solve(max(t, 0LL)) << endl;
  return 0;
}

// decided x ~ t
long long solve(long long x) {
  if(x < 0) return 0;
  long long ans = 0, now = 0;
  for(long long i = 0; i < n; ++i)
    if((k | a[i]) == k) now += b[i];
  for(long long i = 0; i < n; ++i) {
    if(k >= memo[x] && memo[x] > a[i])
      ans += b[i];
    else if(k >= memo[x] && a[i] >= memo[x])
      a[i] -= memo[x];
  }
  if(k >= memo[x]) k -= memo[x];
  ans = max(ans, now);
  now = solve(x - 1);
  return max(ans, now);
}

Measured memory_bytes: 1792
use std::cmp;
use std::collections::BinaryHeap;
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::VecDeque;
use std::io::Read;
use std::usize::MAX;

macro_rules! input {(source = $s:expr, $($r:tt)*) => {let mut iter = $s.split_whitespace();let mut next = || { iter.next().unwrap() };input_inner!{next, $($r)*}};($($r:tt)*) => {let stdin = std::io::stdin();let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));let mut next = move || -> String{bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect()};input_inner!{next, $($r)*}};}
macro_rules! input_inner {($next:expr) => {};($next:expr, ) => {};($next:expr, $var:ident : $t:tt $($r:tt)*) => {let $var = read_value!($next, $t);input_inner!{$next $($r)*}};}
macro_rules! read_value {($next:expr, ( $($t:tt),* )) => {( $(read_value!($next, $t)),* )};($next:expr, [ $t:tt ; $len:expr ]) => {(0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()};($next:expr, chars) => {read_value!($next, String).chars().collect::<Vec<char>>()};($next:expr, usize1) => {read_value!($next, usize) - 1};($next:expr, [ $t:tt ]) => {{let len = read_value!($next, usize);(0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()}};($next:expr, $t:ty) => {$next().parse::<$t>().expect("Parse error")};}

fn solve() {
    input! {
        a: i64,
        b: i64,
        c: i64,
        d: i64
    }

    let mut a = a;
    let mut c = c;

    let mut takahashi = true;
    while a > 0 && c > 0 {
        if takahashi {
            c -= b;
        } else {
            a -= d;
        }
        takahashi = !takahashi;
    }

    if a > 0 {
        println!("Yes");
    } else {
        println!("No");
    }
}

fn main() {
    let thd = std::thread::Builder::new().stack_size(104_857_600);
    thd.spawn(|| solve()).unwrap().join().unwrap();

    /*
    // 入力を一括で読み込む場合
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut input = buf.split_whitespace();

    // inputに対しnext()で読み込んでいく
    let q: usize = input.next().unwrap().parse().unwrap();
    */
}

const LARGE_PRIME: u64 = 1_000_000_007;

// @〜でsnippet


Measured memory_bytes: 2268
#include <algorithm>
#include <climits>
#include <cmath>
#include <iostream>
#include <map>
#include <string>
#include <vector>

using namespace std;
using ll = long long int;

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

ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

int main() {
  ll n;
  cin >> n;

  vector<ll> a(n);
  ll sum = 0;
  for (size_t i = 0; i < n; i++) {
    cin >> a[i];
    sum += a[i];
  }

  ll x = 0;
  ll y = sum;

  ll ans = INT_MAX;

  for (ll i = 0; i < n - 1; i++) {
    x += a[i];
    y -= a[i];
    ans = min(ans, abs(x - y));
  }
  cout << ans << endl;
}

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

typedef long long int ll;
typedef unsigned long long int ull;
#define rep(i,n) for(auto i=0;i<(n);i++)
#define rep1(i,n) for(auto i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()

using namespace std;


struct init{ init(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20); }; }aaaaaaa;



int main(){
  ll n;
  cin >> n;
  vector<ll> b(n+1, 1e6);
  rep(i, n-1) cin >> b[i+1];


  vector<ll> a(n);
  rep(i, n) a[i] = min(b[i], b[i+1]);


  ll sum = 0;
  rep(i, n) sum += a[i];
  

  cout << sum << endl;



  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoder
{
    class Program
    {
        private const int MODULO = 1000000007;
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        class Solver
        {
            public int[] counts = new int[1025];
            private int Count(int n)
            {
                int count = 0;
                while (n > 0)
                {
                    if ((n & 1) != 0) { ++count; }
                    n >>= 1;
                }
                return count;
            }
            public Solver()
            {
                for (int i = 1; i <= 1024; ++i) { counts[i] = Count(i); }
            }
            public int Solve(int N, int[] F, int[][] P)
            {
                int max = int.MinValue;
                for (int i = 1; i < 1024; ++i)
                {
                    int p = 0;
                    for (int j = 0; j < N; ++j)
                    {
                        p += P[j][Count(i & F[j])];
                    }
                    max = Math.Max(p, max);
                }
                return max;
            }
        }
        static void Main(string[] args)
        {
            int N = ReadInt();
            var F = new int[N];
            for (int i = 0; i < N; ++i)
            {
                int[] v = ReadInts();
                for (int j = 0; j < 10; ++j)
                {
                    F[i] <<= 1;
                    F[i] |= v[j];
                }
            }
            var P = new int[N][];
            for (int i = 0; i < N; ++i) { P[i] = ReadInts(); }
            Console.WriteLine(new Solver().Solve(N, F, P));
        }
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

int dp[100005];

int main(){
  int N, M;
  cin >> N >> M;
  string S;
  cin >> S;

  rep(i,100005) dp[i] = -1;

  for(int i=S.size()-2; i>=0; i--){
    int putted = -1;
    REP(j,1,M+1){
      if(i-j+1 < 0) break;
      if(S[i-j+1] == '1') continue;
      dp[i-j+1] = j;
      putted = i-j+1;
    }

    if(putted == -1){
      cout << -1 << endl;
      return 0;
    }
    i = putted;
  }

  vector<int> ret;
  int now = 0;
  while(now != S.size()-1){
    ret.push_back(dp[now]);
    now += dp[now];
  }
  
  rep(i,ret.size()){
    if(i > 0) cout << " ";
    cout << ret[i];
  }
  cout << endl;
  
  return 0;
}



Measured memory_bytes: 1528
import java.util.Scanner;
import java.math.BigInteger;

class Main{
	public static void main(String args[]){
		Scanner scanner = new Scanner(System.in);
		BigInteger n = scanner.nextBigInteger();
		BigInteger k = scanner.nextBigInteger();
		BigInteger reminder = n.mod(k);
		if(reminder.compareTo(k.subtract(reminder)) < 0){
			System.out.println(reminder);
		}
		else{
			System.out.println(k.subtract(reminder));
		}
	}
}

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

using namespace std;

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

const static long long int MOD = 1000000000 + 7;
const static int dy[] = {0, 1, 0, -1};
const static int dx[] = {1, 0, -1, 0};

int main (int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    cin >> n;
    vector<int> A(n), B(n);
    rep(i, n) {
        cin >> A[i];
    }
    rep(i, n) {
        cin >> B[i];
    }

    llong cnt = 0;
    rep(i, n) {
        if (A[i] > B[i]) cnt -= A[i] - B[i];
        else if (A[i] < B[i]) cnt += (B[i] - A[i]) / 2;
    }

    if (cnt < 0) cout << "No" << endl;
    else cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <math.h>
using namespace std; 
 
int main(){
  string s;
  cin>>s;
  int ans=753;
  for(int i=0;i<s.size()-2;i++){
    string ss="";
    ss+=s[i];
    ss+=s[i+1];
    ss+=s[i+2];
    int dis=stoi(ss);
    dis=abs(753-dis);
    if(ans>dis)ans=dis;
  }
  cout<<ans<<endl;
} 


Measured memory_bytes: 256
A,B,C,X,Y=map(int,input().split())
ans_2=A*X+B*Y
ans=min(X,Y)*2*C
mindelta_X=A*(max(X,Y)-min(X,Y))
mindelta_Y=B*(max(X,Y)-min(X,Y))


for i in range(1,max(X,Y)+1-min(X,Y)):
    delta=0
    if X>Y:
        delta=2*C*i+A*(max(X,Y)-min(X,Y)-i)
        if delta<mindelta_X:
            mindelta_X=delta
    if Y>X:
        delta=2*C*i+B*(max(X,Y)-min(X,Y)-i)
        if delta<mindelta_Y:
            mindelta_Y=delta

print(min([ans+mindelta_X,ans_2]) if X>Y else min([ans+mindelta_Y,ans_2]))


Measured memory_bytes: 3064
fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let s: String = sc.read();
    let ans = if s == "ABC" { "ARC" } else { "ABC" };
    println!["{}", ans];
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: ToString>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.to_string().as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}

Measured memory_bytes: 2100
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const int INF=INT_MAX,MOD=1e9+7;

int main(){
    int n; cin>>n;
    pair<int,int> a[n];
    rep(i,n){
        int x; cin>>x;
        pair<int,int> p=make_pair(x,i+1);
        a[i]=p;
    }
    sort(a,a+n);

    set<int> s; s.insert(0); s.insert(n+1);
    long long ans=0;
    for(auto i:a){
        long long num=i.second;
        auto itr=s.lower_bound(num);
        // cout<<*itr<<endl;
        ans+=i.first*(*itr-num)*(num-*(--itr));
        // cout<<*itr<<endl;
        s.insert(num);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 11136
#include <stdio.h>
int main(void) {
    int x, y;

    while (1) {
        scanf("%d %d", &x, &y);
        if (x == 0 && y == 0)
            break;
        if (x < y)
            printf("%d %d\n", x, y);
        else
            printf("%d %d\n", y, x);
    }
    return 0;
}

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

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

using namespace std;

int main(){
	int x; cin>>x;

	int ans=1;
	for(int b=2;b*b<=x;b++){
		int a=b*b;
		while(a<=x) ans=max(ans,a), a*=b;
	}
	cout<<ans<<endl;

	return 0;
}


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

int main(){
  int N, M;
  string A[51], B[51];
  bool flag = true;

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


  for(int i = 0; i < N - M + 1; i++){
    for(int j = 0; j < N - M + 1; j++){
      flag = true;
      for(int ii = 0; ii < M; ii++){
        for(int jj = 0; jj < M; jj++){
          if(A[ii + i][jj + j] != B[ii][jj]) flag = false;
        }
      }
      if(flag){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
}


Measured memory_bytes: 256
n,q = map(int,input().split())
s = input()

array = [0]*len(s)

for i in range(1,len(s)):
  if( s[i-1:i+1] == "AC" ):
    array[i] = array[i-1] + 1
  else:
    array[i] = array[i-1]
      

for i in range(q):
  l,r = map(int,input().split())
  l -= 1
  r -= 1
  ans = array[r] - array[l]
  print(ans)

 

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

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

		if (a == b && b == c) {
			cout << "1" << endl;
			return 0;
		}

		if (a != b) n++;
		if (b != c) n++;
		if (c != a) n++;

	cout << n << endl;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func main() {
	abc := strings.Split(nextLine(), " ")
	var slc []int
	for _, s := range abc {
		tmp, _ := strconv.Atoi(s)
		slc = append(slc, tmp)
	}
	//sort.Slice(slc, func(i, j int) bool { return slc[i] < slc[j] })
	sort.Sort(sort.IntSlice(slc))
	if slc[0] == 5 && slc[1] == 5 && slc[2] == 7 {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


Measured memory_bytes: 640
use std::io::Read;
use std::cmp;

fn main() {
    let mut buf = String::new();

    // 標準入力から全部bufに読み込む
    std::io::stdin().read_to_string(&mut buf);

    // 読み込んだStringを空白で分解する
    let mut iter = buf.split_whitespace();

    // nの読み込み
    let n: usize = iter.next().unwrap().parse().unwrap();
    // aの読み込み
    let a: usize = iter.next().unwrap().parse().unwrap();
    // bの読み込み
    let b: usize = iter.next().unwrap().parse().unwrap();

    if (n * a) < b {
        println!("{}", n * a);
    } else {
        println!("{}", b);
    }

    
}

Measured memory_bytes: 4352