akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(int i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(int i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll x, y;
    cin >> x >> y;
    
    if (x % y == 0) {
        cout << -1 << endl;
        return 0;
    }
    
    cout << x << endl;
    return 0;
}

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

typedef long long ll;
typedef pair<int,int> P;

#define p_ary(ary,a,b,i) do { cout << "["; for (int (i) = (a);(i) < (b);++(i)) cout << ary[(i)] << ((b)-1 == (i) ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

struct zabuton {
    int h,p;
    bool operator<(const zabuton& a) const {
        return h+p < a.h+a.p;
    }
};

int main() {
    int n;
    cin >> n;
    vector<zabuton> a(n);
    vector<vector<ll>> dp(n+1,vector<ll>(n+1,1LL<<60));
    for (int i = 0;i < n;++i) cin >> a[i].h >> a[i].p;
    sort(a.begin(),a.end());
    dp[0][0] = 0;
    for (int i = 0;i < n;++i) {
        dp[i+1] = dp[i];
        for (int j = 0;j < n;++j) {
            if (dp[i][j] <= a[i].h) dp[i+1][j+1] = min(dp[i+1][j+1],dp[i][j]+a[i].p);
        }
    }
    for (int i = n;i >= 0;--i) if (dp[n][i] < (1LL<<60)) {
        cout << i << endl;
        break;
    }
    return 0;
}

Measured memory_bytes: 195968
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define Blue ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define rep(i,a,n) for(int i=a;i<n;++i)
typedef vector<int> vi;
typedef long long ll;
const int mod=1e9+7;
 
const int dx[]={1,-1,0,0},dy[]={0,0,1,-1};

void solve(){
	int n;
	string s,t;
	cin>>n>>s>>t;
	rep(i,0,n){
		cout<<s[i]<<t[i];
	}
 
}
 
 
int main(){
	Blue;
	int test=1;
	//cin>>test;
	while(test--)
		solve();
	return 0;
}

Measured memory_bytes: 3624
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG //FOR THE DEBUG! COMMENT OUT THIS WHEN SUBMITTING!
#endif
/* I REALLY HOPE MY WISH REACH YOU , ATCODER'S ONLINE JUDGE */
#define WOULD
#define YOU
#define PLEASE
#define ACCEPT
#define MY
#define SUBMISSION
/* I REALLY HOPE MY WISH REACH YOU , ATCODER'S ONLINE JUDGE */
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

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; }
const long long INF = 100100100100;
const long long MOD = 1000000007;
typedef pair<int,int> P;
//NのM乗を求める(繰り返し二乗法)
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}
long long nCr(long long n, long long r) {
    long long A = 1, B = 1;
    //Aが分子Bが1/r!
    for (long long i = n - r + 1; i <= n; i++) {
        A = A * i % MOD;
    }
    for (long long i = 1; i <= r; i++) {
        B = B * i % MOD;
    }
    B = mod_pow(B, MOD - 2);
    B %= MOD;
    //Bは割るのではなく掛ける
    return (A * B) % MOD;
}

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

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

//long long A,B;
bool ok(long long key,long long index){
    if(index > key) return true;
    else if(index <= key) return false;
}
long long binary_search(long long key,long long size){
    //left,right,midはいずれもindex
    long long left = -1,right = size;
    while(right - left > 1){
        long long mid = left + (right-left)/2;
        long long hantei = ok(key,mid);
        if(hantei) right = mid;
        else left = mid;
    }
    if(left == -1)return 0;
    return left;
}

int main() {
    string S;cin >> S;
    int N;cin >> N;
    for(int i = 0;i<S.size();i++){
        if(i == S.size()-1){
            N %= 26;
            for(int j = 0;j<N;j++){
                S.at(i)++;
                if(S.at(i) > 'z') S.at(i) = 'a';
            }
            break;
        }
        char C = S.at(i);
        int toA = 122-C + 1;
        if(C == 'a') continue;
        if(toA <= N){
            N -= toA;
            S.at(i) = 'a';
        }
    }

    cout << S << endl;

}


Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
#include <string>
#include <cctype>
#include <cmath>
using namespace std;

int main()
{
    int H,W;
    cin>>H>>W;
    string Picture[H];
    for(int i=0;i<H;i++){
        cin>>Picture[i];
    }
    for(int i=0;i<H;i++){
        cout<<Picture[i]<<endl;
        cout<<Picture[i]<<endl;
    }

}




Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <utility>
#include <algorithm>
#include <bitset>
#include <numeric>
#include <math.h>
#include <tuple>
#include <queue>
#include <set>

using namespace std;

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

    int A, B, C;
    cin >> A >> B >> C;

    if(A < B){
        if(A < C && C < B){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }else{
        if(A > C && C > B){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }

    }    
    return 0;
}


Measured memory_bytes: 256
# Author: cr4zjh0bp
# Created: Sat Mar 28 15:38:17 UTC 2020
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

x, y, a, b, c = na()
p = na()
q = na()
r = na()
p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)

ans = []
ans.extend(p[:x])
ans.extend(q[:y])
ans.extend(r)

ans.sort(reverse=True)
print(sum(ans[:x + y]))

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

int main(){
    int n;

    while(cin >> n, n != 0){
        int matrix[n+1][n+1];
        int rowsum, colsum;
        int allsum = 0;

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

        for(int i=0; i<n; i++){
            rowsum = 0;
            for(int j=0; j<n; j++){
                printf("%5d", matrix[i][j]);
                rowsum += matrix[i][j];
            }
            printf("%5d\n", rowsum);
        }

        for(int i=0; i<n; i++){
            colsum = 0;
            for(int j=0; j<n; j++){
                colsum += matrix[j][i];
            }
            allsum += colsum;
            printf("%5d", colsum);
        }
        printf("%5d\n", allsum);
    }

    return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<string>

int main(){
	long long a;
	std::string b;
	std::cin >> a >> b;
	long long b100 = (b[0]-'0')*100 + (b[2]-'0')*10 + (b[3]-'0');
	std::cout << a * b100 / 100 << std::endl;
	return 0;
}

Measured memory_bytes: 3596
a[6],x;main(i,j){for(;~j;++i)i<6?x|=1<<(j=a[i]=atoi(gets(a))-1):i>10?x=i=0:printf("%d\n",x-(x&-x)&&x-7?j=a[i-5],x&2?x&1?j+1:j:j?1:2:3);}

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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define pb push_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define BiSearchRangeNum(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y)turn idx;
#define deg_to_rad(deg) ((((double)deg)/((double)360)*2*M_PI))
#define rad_to_deg(rad) ((((double)rad)/(double)2/M_PI)*(double)360)

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

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

int main() {
  int N;
  cin >> N;
  double mom = 0.0;
  double a;

  rep(i, 0, N) {
    cin >> a;
    mom += 1.0 / a;
  }

  cout << 1.0 / mom << endl;
};


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

int main(){
  int i;
  long long A,B,N;
  cin >> A >> B >> N;
  if(N>=B-1) cout << (A*(B-1))/B - A*((B-1)/B);
  else cout << (A*N)/B - A*(N/B);
  return 0;
}

Measured memory_bytes: 3592
import sys
while True:
    a,b = map(int, raw_input().split())
    if a ==0 and b == 0:
        break
    for i in range(a):
        for j in range(b):
            if (i % 2 == 0 and j % 2 == 0) or ( i % 2 == 1 and j % 2 == 1):
                sys.stdout.write("#")
            else:
                sys.stdout.write(".")
        print 
    print

Measured memory_bytes: 6444
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,-1,sizeof(x))
const int INF = 1e9 + 1;
const ll MOD = 1e9 + 7;
const double PI = 3.141592653589793;
const int MAX_N = 2e5;

int main(){
  int d;
  cin >> d;
  int c[26];
  rep(i, 26) cin >> c[i];
  int s[365][26];
  rep(i, d){
    rep(j, 26){
      cin >> s[i][j];
    }
  }
  int t[365];
  rep(i, d){
    int k;
    cin >> k;
    k--;
    t[i] = k;
  }
  
  ll point = 0;
  int last[26];
  fill(last, last+26, 0);
  rep(i, d){
    point += s[i][t[i]];
    rep(i, 26) last[i]++;
    last[t[i]] = 0;
    rep(j, 26){
      point -= c[j]*last[j];
    }
    cout << point << endl;
  }
}

Measured memory_bytes: 3656
#include <iostream>
#include <string>
#include <stdio.h>

using namespace std;

int main() {

    long int sum = 0;
    int num, min = 1000000, max = -1000000;

    cin >> num;
    int* a = new int[num];

    for (int i = 1; i <= num; i++) {
        cin >> a[i];
        if (min > a[i])
            min = a[i];
        if (max < a[i])
            max = a[i];
        sum += a[i];
    }
    cout << min << " " << max << " " << sum << endl;
    return 0;
}

Measured memory_bytes: 3104
import math
import numpy as np


#横並び
#a, b, c, x = map(int, [input() for i in range(4)])
#z = list(map(int, input().split()))
#n, a, b = map(int, input().split())

#print(len(z))
#for i in z:
#    print(i)

#a = sorted(a,reverse = True)
#print(sum(a[::2]) - sum(a[1::2]))
#z = map(int, [input() for i in range(int(n))])
#data_list = [ list(map(int,input().split(" "))) for i in range(3)]


n = int(input())
a = list(map(int,input().split()))
a.sort()

v = a[0]

for i in a:
    v = (v + i)/2

print(v)


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

int main(){
    
    int a,b,c;
    int t;
    cin>> a >> b >> c;
    if(a > b){t = a; a = b; b = t;}
    if(b > c){t = b; b = c; c = t;}
    if(a > b){t = a; a = b; b = t;}
    cout << a << " " << b << " " << c << endl;
        return 0;
}

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


int main (){
    int N;
    cin>>N;
    int Count=0;
    for(int i=1; i<N+1; i++){
        int Yaku=0;
        for(int j=1; j<i+1; j++){
            if(i%j==0){
                Yaku ++;
            }
        }
        if(Yaku ==8&&i%2==1){
            Count ++;
          //cout<<i<<endl;
        }
    }
    cout<<Count<<endl;
}

Measured memory_bytes: 256
ll = list(input())

count = {}

for i in range(13):
    count[i] = 0

count[0] = 1

for i in ll:

    new_count = {}
    
    for j in range(13):
        new_position = (j * 10) % 13
        new_count[new_position] = count[j]

    count = new_count.copy()

    new_count = {}
    
    if i.isdigit():
        i_int = int(i)
        for j in range(13):
            new_position = (i_int + j) % 13
            new_count[new_position] = count[j]
            
    else:
        for j in range(13):
            new_count[j] = 0
            
        for k in range(10):
            for j in range(13):
                new_position = (k + j) % 13
                new_count[new_position] += count[j]            
    
    count = new_count.copy()
    
    for i in range(13):
        count[i] = count[i] % (10 ** 9 + 7)
    
print(count[5])

Measured memory_bytes: 49776
import numpy as np
(H, W, K) = map(int, input().split())
M = 1000000007
F = np.zeros((H+1,W+2),dtype=np.int64)

def hor_cmb(x):
    if x<=0:
        return 1
    elif x==1:
        return 2
    else:
        return (hor_cmb(x-1) + hor_cmb(x-2))

F[0,1] = 1
for h in range(1,H+1):
    for w in range(1,W+1):
        c = hor_cmb(w-3)*hor_cmb(W-w-1)
        d = hor_cmb(w-2)*hor_cmb(W-w-1)
        e = hor_cmb(w-2)*hor_cmb(W-w-2)
        F[h,w] = (c*F[h-1,w-1] + d*F[h-1,w] + e*F[h-1,w+1]) % M
print(F[H,K])

Measured memory_bytes: 12504
import sys
import numpy as np
N,M= (int(i) for i in input().split(" "))  

LR= np.array([[int(i) for i in input().split()] for i in range(M)]) 

L=np.max(LR[:,0])
R=np.min(LR[:,1])


el=np.sum(np.logical_and(LR>L,R>LR))

if L>R:
    print(0)
else:
    
    print(int((R-L)+1))

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

ll n;
string s;
string ans;

void calc_ans(string fs) {
	ans = fs;
	for (ll i = 1; i < n - 1; ++i) {
		if ((s[i] == 'o') ^ (ans[i] == 'W') ^ (ans[i - 1] == 'S')) {
			ans.push_back('W');
		}
		else {
			ans.push_back('S');
		}
	}
}

bool check_ans() {
	if ((s[n - 1] == 'o') ^ (ans[n - 1] == 'W') ^ (ans[n - 2] == ans[0]))return false;
	if ((s[0] == 'o') ^ (ans[0] == 'W') ^ (ans[n - 1] == ans[1]))return false;
	return true;
}

int main() {
	cin >> n >> s;
	for (string fs : {"SS", "SW", "WS", "WW"}) {
		calc_ans(fs);
		if (check_ans()) {
			cout << ans << endl;
			return 0;
		}
	}
	cout << -1 << endl;
}


Measured memory_bytes: 3736
#include <iostream>
#include <utility>
#include <cmath>
#include <iomanip>
using namespace std;

typedef long long lint;
typedef pair<double,double> pt;
#define mp(a,b) make_pair(a,b)

long double dist2(pt a,pt b){
    return (a.first-b.first)*(a.first-b.first)+(a.second-b.second)*(a.second-b.second);
}
long double dist2(double x1, double y1, double x2, double y2){
    return (x1-x2)*(x1-x2)+(y1-y2)*(y1-y2);
}
long double dot(pt a,pt b){
    return a.first*b.first+a.second*b.second;
}
pt operator-(pt a,pt b){
    return mp(a.first-b.first,a.second-b.second);
}

int main(){
    long double x1,x2,x3,y1,y2,y3;
    cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;

    pt a,b,c;
    if(dist2(x1,y1,x2,y2)>dist2(x2,y2,x3,y3)){
        if(dist2(x1,y1,x2,y2)>dist2(x1,y1,x3,y3)){
            a=mp(x1,y1);
            b=mp(x2,y2);
            c=mp(x3,y3);
        }else{
            a=mp(x1,y1);
            b=mp(x3,y3);
            c=mp(x2,y2);
        }
    }else{
        if(dist2(x2,y2,x3,y3)>dist2(x1,y1,x3,y3)){
            a=mp(x2,y2);
            b=mp(x3,y3);
            c=mp(x1,y1);
        }else{
            a=mp(x1,y1);
            b=mp(x3,y3);
            c=mp(x2,y2);
        }        
    }

    long double cos2p,cos2q,cotp,cotq;
    cos2p=dot(c-a,b-a)*dot(c-a,b-a)/(dist2(c,a)*dist2(b,a));
    cos2q=dot(c-b,a-b)*dot(c-b,a-b)/(dist2(c,b)*dist2(a,b));
    cotp=(1+sqrt(cos2p))/sqrt(1-cos2p);
    cotq=(1+sqrt(cos2q))/sqrt(1-cos2q);
    cout << fixed << setprecision(18) << sqrt(dist2(a,b))/(2.0+cotp+cotq) << 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)
#define all(x) (x).begin(),(x).end()

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

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



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

    int k;
    cin >> k;

    if(k < 10){
        cout << k << "\n";
        return 0;
    }

    queue<ll> q;
    for (int i = 1; i < 10; ++i) {
        q.push(i);
    }

    ll ans = 0;
    for (int i = 0; i < k; ++i) {
        ll x = q.front(); q.pop();
        ans = x;
        if(x % 10 != 0){
            q.push((10*x) + (x%10-1));
        }
        q.push(10*x + (x%10));
        if(x % 10 != 9){
            q.push((10*x) + (x%10+1));
        }
    }


    cout << ans << "\n";

    return 0;
}


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


int main() {
	string s;

	cin >> s;

	if (s == "A") {
		cout << "T" << endl;
	}
	else if (s == "T") {
		cout << "A" << endl;
	}
	else if (s == "C") {
		cout << "G" << endl;
	}
	else {
		cout << "C" << endl;
	}
}


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


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

struct point {
    int x;
    int y;
    int id;
};

struct edge {
    int node;
    int cost;
    bool operator<(const edge& r) const {
        return cost > r.cost;
    }
};

bool cmpx(const point& l, const point& r) {
    return l.x < r.x;
}
bool cmpy(const point& l, const point& r) {
    return l.y < r.y;
}

vector<edge> edges[100010];
bool visited[100010];

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

    vector<point> v;
    for (int i=0; i<N; i++) {
        int x,y;
        cin >> x >> y;
        v.push_back( point{x,y,i} );
    }

    // x軸で移動するとき
    sort(v.begin(), v.end(), cmpx);
    for (int i=1; i<v.size(); i++) {
        int c = abs(v[i].x - v[i-1].x);
        edges[v[i].id].push_back( edge{v[i-1].id, c} );
        edges[v[i-1].id].push_back( edge{v[i].id, c} );
    }

    // y軸で移動するとき
    sort(v.begin(), v.end(), cmpy);
    for (int i=1; i<v.size(); i++) {
        int c = abs(v[i].y - v[i-1].y);
        edges[v[i].id].push_back( edge{v[i-1].id, c });
        edges[v[i-1].id].push_back( edge{v[i].id, c} );
    }

    int ans = 0;
    priority_queue<edge> q;
    q.push( edge{0, 0} ); // 初期ノード
    while (!q.empty()) {
        edge curr = q.top();
        q.pop();
        if (visited[curr.node]) continue;
        visited[curr.node] = true;
        ans += curr.cost;

        for (int i=0; i<edges[curr.node].size(); i++) {
            edge e = edges[curr.node][i];
            if (visited[e.node]) continue;
            q.push( e );
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 11252
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;
int main() {
	int A, B;
	cin >> A >> B;

	vector<string> grid(100);
	string w(100, '.');
	string b(100, '#');
	A--; B--;
	for (int i = 0; i < 50; i++)
	{
		string g = w;
		if (i % 2 == 1)
		{
			for (int j = 0; j < 100; j++)
			{
				if (j % 2 == 0&&B!=0)
				{
					g[j] = '#';
					B--;
				}
			}
		}
		grid[i] = g;
	}
	for (int i = 50; i < 100; i++)
	{
		string g = b;
		if (i % 2 == 1)
		{
			for (int j = 0; j < 100; j++)
			{
				if (j % 2 == 0 && A != 0)
				{
					g[j] = '.';
					A--;
				}
			}
		}
		grid[i] = g;
	}

	cout << 100 << " " << 100 << endl;

	for (int i = 0; i < 100; ++i) {
		cout << grid[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 256
n = int(input())
a = [int(input()) for _ in range(n)]

min_v = a[0]
max_p = a[1] - a[0]

for i in range(1,n):
    max_p = max(max_p, a[i] - min_v)
    min_v = min(min_v, a[i])

print(max_p)


Measured memory_bytes: 13596
N = int(input())
S = input()
ans = 1
if len(S) == 1:
    print(1)
else:
    if len(S) == 2:
        if S[0] == S[1]:
            print(1)
        else:
            print(2)
    else:
        for x in range(len(S)-1):
            curr = S[x]
            if curr == S[x+1]:
                pass
            else:
                ans += 1
        print(ans)

Measured memory_bytes: 3316
n = int(input())
a_n = list(map(int, input().split()))
a_n.sort()
a_n.reverse()
def check(idx):
    global a_n
    base = a_n[idx]
    count = 0
    dif = 0
    while dif <= 2:
        idx += 1
        count += 1
        if(idx == n):
            return count
        dif = base - a_n[idx]
    return count

ans = 1
i = 0
c = check(i)
tmp = a_n[0]
while(i != n):
    if(tmp != a_n[i]):
        tmp = a_n[i]
        c = check(i)
    if(ans < c):
        ans = c
    i += 1
print(ans)


Measured memory_bytes: 13964
def s0():return input()
def s1():return input().split()
def s2(n):return [input() for x in range(n)]
def s3(n):return [[input().split()] for _ in range(n)]
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]
def t3(n):return [tuple(int(x) for x in input().split()) for _ in range(n)]
def p0(b,yes,no): print(yes) if b else print(no)
# from collections import Counter,deque,defaultdict
# import itertools
# import math
# import networkx
# from bisect import bisect_left,bisect_right
n=n0()
s=s0()
print(s.count("ABC"))

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

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

    vector<int> as(3);
    for (int i = 0; i < 3; i++) cin >> as[i];
    sort(as.begin(), as.end());
    cout << as[0] + as[1] << endl;
}

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

int w, h, c, n;
int a[50][50];
queue<int> q;

void bfs() {
	int x, y;
	while (1) {
		x = q.front() % w;
		y = q.front() / w;
		
		if ( x > 0 && y > 0 && a[y - 1][x - 1] == 1 ) {
			a[y - 1][x - 1] = 0;
			q.push( ( y - 1 ) * w + x - 1 );
		}
		if ( x < w - 1 && y > 0 && a[y - 1][x + 1] == 1 ) {
			a[y - 1][x + 1] = 0;
			q.push( ( y - 1 ) * w + x + 1 );
		}
		if ( x > 0 && y < h - 1 && a[y + 1][x - 1] == 1 ) {
			a[y + 1][x - 1] = 0;
			q.push( ( y + 1 ) * w + x - 1 );
		}
		if ( x < w - 1 && y < h - 1 && a[y + 1][x + 1] == 1 ) {
			a[y + 1][x + 1] = 0;
			q.push( ( y + 1 ) * w + x + 1 );
		}
		if ( x > 0 && a[y][x - 1] == 1 ) {
			a[y][x - 1] = 0;
			q.push( y * w + x - 1 );
		}
		if ( y > 0 && a[y - 1][x] == 1 ) {
			a[y - 1][x] = 0;
			q.push( ( y - 1 ) * w + x );
		}
		if ( x < w - 1 && a[y][x + 1] == 1 ) {
			a[y][x + 1] = 0;
				q.push( y * w + x + 1 );
		}
		if ( y < h - 1 && a[y + 1][x] == 1 ) {
			a[y + 1][x] = 0;
			q.push( ( y + 1 ) * w + x );
		}
		q.pop();
		if ( q.empty() ) break;	
	}
	n++;
}

int main() {

	while (1) {
		n = 0;
		for ( int j = 0; j < 50; j++ )
			for ( int i = 0; i < 50; i++ )
				a[j][i] = 0;
		cin >> w >> h;
		if ( w == 0 ) break;
		for ( int j = 0; j < h; j++ ) {
			for ( int i = 0; i < w; i++ ) {
				cin >> c;
				a[j][i] = c;
			}
		}
		for ( int j = 0; j < h; j++ ) {
			for ( int i = 0; i < w; i++ ) {
				if ( a[j][i] == 1 ) {
					a[j][i] = 0;
					q.push( j * w + i );
					bfs();
				}
			}
		}
		cout << n << endl;
	}
}

Measured memory_bytes: 1224
n = int(input())
h = list(map(int, input().split())) + [0]*2
dp = [0] + [float("inf")] * (n+1)

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

print(dp[n-1])

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

int main()
{
        int i;
        int n;

        i = 1;
        while(1){
                cin >> n;
                if( n == 0 ){ break; }
                cout << "Case " << i << ": " << n << endl;
                i++;
        }
        return 0;
}

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

int main() {
    int H, A;
    cin >> H >> A;
    int ans = H / A;
    if (H % A != 0)
    {
        ans++;
    }
    cout << ans << 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++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)

ll mod = 1e09;

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

  ll n, m;
  cin >> n;
  ll t[n];
  REP(i, n) cin >> t[i];
  cin >> m;
  ll p[m], x[m];
  REP(i, m) cin >> p[i] >> x[i];

  ll sum = 0;
  REP(i, n) sum += t[i];

  ll ans;
  REP(i, m){
    ans = sum - (t[p[i] - 1] - x[i]);
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")
#define rep(i, n) for(int i=0;i<(int)(n);++i)
#ifdef LOCAL
#include "../../../DBG/dbg.h"
#endif
template <typename T> ll gcd(T a, T b) {return b?gcd(b, a%b):a;}
template <typename T> ll lcm(T a, T b) {return a * b / gcd(a, b);};
template <typename T> inline void chmin(T &a, const T& b){if(a>b)a=b;}
template <typename T> inline void chmax(T &a, const T& b){if(a<b)a=b;}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, r;
  cin >> n >> r;
  if (n >= 10) {
    cout << r << '\n';
  } else {
    cout << r + 100 * (10 - n) << '\n';
  }
}


Measured memory_bytes: 256
# https://atcoder.jp/contests/abc086/tasks/arc089_a
t0 = 0
x0 = 0
y0 = 0
n = int(input())
result = "Yes"

for i in range(n):
    t1, x1, y1 = list(map(int, input().split()))
    dt = t1 - t0
    dx = x1 - x0
    dy = y1 - y0
    if ((dx + dy)%2 == dt % 2) and (dx + dy) <= dt:
        t0 = t1
        x0 = x1
        y0 = y1
    else:
        result = "No"

print(result)


Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<stdio.h>

#define S 100
#define MW 300
#define INF 10000000000

int N;
long W, w[S], w2[S], v[S], w0;

long memo[S][S][MW];

int input(){
	std::cin >> N >> W;
	for( int i = 0; i < S; i++ ){
		for( int j = 0; j < S; j++ ){
			for( int k = 0; k < MW; k++ ){
				memo[i][j][k] = -1;
			}
		}
	}
	for( int i = 0; i < N; i++ ){
		std::cin >> w[i] >> v[i];
	}
	for( int i = 0; i < N; i++ ){
		w2[i] = w[i] - w[0];
	}
	return 0;
}

long search(int i, int c, long u){
	//printf("%d,%d,%ld\n", i, c, u);
	if( i == N ){ return 0; }
	if( memo[i][c][u] >= 0 ){ return memo[i][c][u]; }
	//std::cout << c*(w[0]+3)-u << std::endl;
	long v1 = v[i] + search(i+1, c+1, u-w2[i]);
	if( (c+1)*w[0] + (3*N - u + w2[i]) > W ){ v1 = -INF; }
	long v2 = search(i+1, c, u);
	//printf("%d,%d,%ld, %ld,%ld\n", i, c, u, v1, v2);
	memo[i][c][u] = (v1>v2?v1:v2);
	return memo[i][c][u];
}




int run(){
	long re = search(0, 0, 3*N);
	std::cout << re << std::endl;
	return 0;
}

int main(){
	input();
	run();
	return 0;
}


Measured memory_bytes: 23680
#include<stdio.h>
 
int main(){
	int x,y,z;
	int a[2];
	for(int k=0;k<3;k++){
		for(int i=0;i<2;i++){
			scanf("%d %d %d",&x,&y,&z);
			a[i]=x*3600+y*60+z;
	    }
        int ans=a[1]-a[0];
		printf("%d %d %d\n",ans/3600,(ans%3600)/60,ans%60);
	}
    return 0;
}

Measured memory_bytes: 1028
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

int main() {
  string s;
  cin >> s;
  if(s=="RRR") cout << 3 << endl;
  else if(s=="RRS"||s=="SRR") cout << 2 << endl;
  else if(s=="SSS") cout << 0 << endl;
  else cout << 1 << endl;
}

Measured memory_bytes: 3584
using System;
using System.Linq;
public class Program {
  public static void Main() {
    int N = 3;
    int[][] maps = new int[N][];
    for (int i = 0; i < N; i++) {
      maps[i] = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
    }

    int[] a = new int[N];
    int[] b = new int[N];
    for (int i = 0; i < N; i++) {
      int[] temp = new int[3];
      for (int j = 0; j < N; j++) {
        temp[j] = maps[i][j];
      }
      a[i] = temp.Min();
      for (int j = 0; j < N; j++) {
        b[j] = temp[j] - a[i];
      }
    }

    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        if (maps[i][j] != a[i] + b[j]) {
          Console.WriteLine("No");
          return;
        }
      }
    }
    Console.WriteLine("Yes");
  }
}


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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> pii;

#define pb push_back
#define ff first
#define ss second
#define SIZE 100010
#define INF 2e9 + 9
#define acmpIN "input.txt"
#define acmpOUT "output.txt"

//#pragma GCC optimize("Ofast")

int n, m;



void solve()
{
    cin >> n >> m;
    int ans = 0;
    ans += (n * (n - 1)) / 2;
    ans += (m * (m - 1)) / 2;
    cout << ans;
}


int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
//    freopen(acmpIN, "r", stdin);
//    freopen(acmpOUT, "w", stdout);

    solve();

    return 0;
}


Measured memory_bytes: 256
import sys
from bisect import bisect_right, insort

def I(): return int(sys.stdin.readline())

def main():
  n = I()
  a = [I() for i in range(n)]
  b = []

  for i in range(n-1, -1, -1):
    t = bisect_right(b, a[i])
    if len(b)-1<t or b[t]==a[i]:
      insort(b, a[i])
    else:
      b[t] = a[i]
  print(len(b))

if __name__ == '__main__':
  main()

Measured memory_bytes: 49628
import java.util.Scanner;
import java.util.StringJoiner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int w = sc.nextInt();
        String[][] a = new String[h][w];
        boolean[] row = new boolean[h];
        boolean[] column = new boolean[w];
        for (int i = 0; i < h; i++) {
            a[i] = sc.next().split("");
            row[i] = false;
        }
        for (int i = 0; i < w; i++) {
            column[i] = false;
        }

        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                if ("#".equals(a[i][j])) {
                    row[i] = true;
                    column[j] = true;
                }
            }
        }
        for (int i = 0; i < h; i++) {
            if (!row[i]) {
                continue;
            }
            StringJoiner sj = new StringJoiner("");
            for (int j = 0; j < w; j++) {
                if (!column[j]) {
                    continue;
                }
                sj.add(a[i][j]);
            }
            System.out.println(sj.toString());
        }
    }

}


Measured memory_bytes: 24616
#include <stdio.h>

int main(){
	int h, m, s;
	scanf("%d", &s);
		m = s / 60;
	h = m / 60;
	printf("%d:", h);
	h = m % 60;
	printf("%d:", h);
	m = s % 60;
	s = m % 60;
	printf("%d\n", s);
	return 0;
}

Measured memory_bytes: 1020
import java.io.*

fun main() {
    val d = readInt()
    val c = readInts()
    val s = mutableListOf<List<Int>>()
    repeat(d) {
        s.add(readInts())
    }

    val last = MutableList(c.size) { 0 }

    fun calcDissatisfaction(currDay: Int): Int {
        return c.mapIndexed { index, num -> num * (currDay - last[index]) }.sum()
    }

    val contests = c.mapIndexed { index, cost -> Contest(index + 1, s[0][index], cost) }

    fun updateContests(day: Int) {
        contests.forEachIndexed { index, contest -> contest.update(day + 1, s[day - 1][index], last[index]) }
    }

    var satisfaction = 0
    var dissatisfaction: Int
    val t = mutableListOf<Int>()
    repeat(d) { day ->
        updateContests(day + 1)
        dissatisfaction = contests.map { it.dissatisfaction }.sum()
        val contestToHold = contests.maxBy { it.contribution(dissatisfaction) }!!
        last[contestToHold.id - 1] = day + 1
//        println("Dissatisfaction on day $day : ${calcDissatisfaction(day + 1)}")
        satisfaction += (s[day][contestToHold.id - 1] - calcDissatisfaction(day + 1))
        t.add(contestToHold.id)
    }

//    println("Satisfaction: $satisfaction")
//    println("Score: ${1000_000 + satisfaction}")

//    writeToFile("output.txt", t.joinToString("\n"))

    // For submission
    println(t.joinToString("\n"))
}

data class Contest(val id: Int, var satisfaction: Int, val cost: Int) {
    var dissatisfaction = cost

    fun update(nextDay: Int, newSatisfaction: Int, lastDayHeld: Int) {
        satisfaction = newSatisfaction

        dissatisfaction = cost * (nextDay - lastDayHeld)
    }

    fun contribution(totalDissatisfaction: Int): Double {
        return satisfaction - 5.0*(totalDissatisfaction - dissatisfaction)
    }
}
// 3 -> 1621750   4 -> 1678645   5 -> 1715594
//// Write to file
//fun writeToFile(filename: String, content: String) {
//    val outputWriter = OutputStreamWriter(FileOutputStream(File(filename)))
//    outputWriter.append(content)
//    outputWriter.close()
//}
//
//// Read from file
//private val inputReader = InputStreamReader(FileInputStream(File("input.txt")))
//private val lines = inputReader.readLines()
//private var currLine = -1
//private fun readLn(): String {
//    currLine++
//    return lines[currLine]
//}

// Current score: 62484479
// 1414762


// Input Reader
private fun readLn() = readLine()!!

private fun readStrings() = readLn().trim().split(" ")
private fun readInt() = readLn().toInt()
private fun readInts() = readStrings().map { it.toInt() }


Measured memory_bytes: 40456
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
ll dp[100005][4];

int main(void){
    string s;

    cin >> s;

    dp[0][0] = 1;

    rep(i, 0, s.length()){
        rep(j, 0, 4){
            if(s[i] == '?'){
                dp[i+1][j] += dp[i][j] * 3;
                dp[i+1][j] %= 1000000007;
            }else{
                dp[i+1][j] += dp[i][j];
                dp[i+1][j] %= 1000000007;
            }
            if((s[i] == 'A' || s[i] == '?') && j == 0){
                dp[i+1][j+1] += dp[i][j];
                dp[i+1][j+1] %= 1000000007;
            }else if((s[i] == 'B' || s[i] == '?') && j == 1){
                dp[i+1][j+1] += dp[i][j];
                dp[i+1][j+1] %= 1000000007;
            }else if((s[i] == 'C' || s[i] == '?') && j == 2){
                dp[i+1][j+1] += dp[i][j];
                dp[i+1][j+1] %= 1000000007;
            }
        }
    }



    cout << dp[s.length()][3] % 1000000007 << endl;
    return 0;
}


Measured memory_bytes: 3584
N = int(input())
A_list = list(map(int, input().split()))

num_sum = 0
xor_sum = 0
idx = 0
r = 0
count = 0
for l in range(0, N):
    while r < N and num_sum + A_list[r] == xor_sum ^ A_list[r]:
        num_sum += A_list[r]
        xor_sum ^= A_list[r]
        r += 1
    num_sum -= A_list[l]
    xor_sum ^= A_list[l]
    count += (r - l)
print(count)


Measured memory_bytes: 23560
#include<iostream>
#include<vector>
#include<unordered_map>
#include<queue>
#include<algorithm>

using namespace std;

struct S{
  char v[10];
  int size;
  int c,d,e;
  long long b;
  S(const vector<int> &pv,int pc):c(pc){
    size=pv.size();
    copy(begin(pv),end(pv),begin(v));
    eval();
  }
  void eval(){
    b=0;
    for(int i=0;i<size;i++){
      b=(b<<4)+v[i];
    }
    d=(v[0]!=1)+(v[size-1]!=size);
    for(int i=0;i+1<size;i++){
      d+=abs(v[i]-v[i+1])>1;
    }
    e=c+(d+1)/2;
  }    
  void reverse(int a,int b){
    c++;
    std::reverse(begin(v)+a,begin(v)+b+1);
    eval();
  }
  bool operator<(const S &s)const{
    return e>s.e;
  }
};

int main(){
  int N;
  cin>>N;
  vector<int> v(N);
  for(auto &e:v){
    cin>>e;
  }
  S is(v,0);
  priority_queue<S> que;
  que.push(is);
  unordered_map<long long,int> m;
  m[is.b]=0;
  for(;;){
    S c=que.top();
    if(c.d==0)break;
    que.pop();
    for(int i=0;i<N;i++){
      for(int j=i+1;j<N;j++){
	S n=c;
	n.reverse(i,j);
	if(m.count(n.b)&&m[n.b]<=n.c)continue;
	m[n.b]=n.c;
	que.push(n);
      }
    }
  }
  cout<<que.top().c<<endl;
}

Measured memory_bytes: 139844
#include<stdio.h>
#include<limits.h>

int main(){
  int a,n,j,k,l,i,p[101],m[101][101];
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%d%d",&p[i-1],&p[i]);
  }
  for(i=1;i<=n;i++)m[i][i]=0;
  for(l=2;l<=n;l++){
    for(i=1;i<=n-l+1;i++){
      j=i+l-1;
      m[i][j]=INT_MAX;
      for(k=i;k<=j-1;k++){
	if(m[i][j]>m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j]) m[i][j]=m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j];
      }
    }
  }
  printf("%d\n",m[1][n]);
  return 0;
}



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


int main(){
	int n, x, d,a[100],ans;
	cin >> n >> d >> x;
	ans = x;

	for (int i = 0; i < n; i++) {
		cin >> a[i];
		ans += 1;
		for (int j = 1; (j*a[i])+1 <= d; j++) {
			ans += 1;
		}
	}

	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main(void)
{
  int i,y=700;
  char s[4],r[4];
  strcpy(r,"ooo");
  scanf("%s",s);
   
  for(i=0;i<3;i++)
  {
    if(s[i]==r[i])
      y=y+100;
  }
  
  printf("%d",y);
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <time.h>

using namespace std;
typedef long long ll;
#define pl pair<ll,ll>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define foreach(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); itr++)
#define dbg(x) cout << #x"="<< (x) << endl
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back(a) 
#define in(x) cin >> x;
#define all(x) (x).begin(), (x).end()
#define INF 2147483600
#define fi first
#define se second

int main(){
	//全ての値を加えていく.
	//同時に10の倍数でない最小の値を見つける.
	ll n;cin>>n;
	vector<ll> s(n);
	ll m=101,total=0;
	rep(i,n){
		cin>>s[i];
		total+=s[i];
		if(s[i]%10!=0){
			m=min(s[i],m);
		}
	}
	if(m==101){
		cout<<0<<endl;
		return 0;
	}else{
		if(total%10==0){
			cout<<total-m<<endl;
		}else{
			cout<<total<<endl;
		}
	}
    return 0;
}

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

int main()
{
    int K;
    int count = 0;
    cin >> K;

    for (int i = 1; i <= K; i++){
        for (int j = i + 1; j <= K; j += 2){
            count++;
        }
    }
    cout << count << endl;
    return 0;
}

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

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

string S[2];

int main()
{
    ll N;
    cin >> N;
    REP(i, 2)
    {
        cin >> S[i];
    }

    ll ans = 1;
    REP(i, N)
    {
        if (S[0][i] == S[1][i])
        {
            if (i == 0)
                ans = 3;
            else if (S[0][i - 1] == S[1][i - 1])
                ans *= 2;
        }
        else
        {
            if (i == 0)
                ans = 6;
            else
            {
                if (S[0][i - 1] == S[1][i - 1])
                    ans *= 2;
                else
                    ans *= 3;
            }
            ++i;
        }
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
  int hi, hy, ki, ky;
  int a, b, c, d;
  cin >> hi >> hy >> ki >> ky;
  cin >> a >> b >> c >> d;
  int h_point = 0, k_point = 0;
  h_point += hi * a + (hi / 10) * c;
  h_point += hy * b + (hy / 20) * d;
  k_point += ki * a + (ki / 10) * c;
  k_point += ky * b + (ky / 20) * d;
  cout << (h_point == k_point ? "even" : (h_point > k_point ? "hiroshi" : "kenjiro")) << endl;
  return 0;
}



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

int main() {
    int A, B, C, D;
    cin >> A >> B >> C >> D;

    int left, right;
    if (A < C) {  // 大きい数を左端
        left = C;
    } else {
        left = A;
    }
    if (B < D) {  // 小さい数を右端
        right = B;
    } else {
        right = D;
    }

    int ans = 0;
    if (right - left > 0) {
        ans = right - left;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int K = sc.nextInt();
    
    int ans = K;
    for (int i = 2; i <= N; i++) {
      ans *= K-1;
    }
    
    System.out.println(ans);
  }
}

Measured memory_bytes: 19924
#include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<unordered_map>
#include<cstring>
#include<sstream>
#include<complex>
#include<iomanip>
#include<numeric>
#include<cassert>
#define X first
#define Y second
#define pb push_back
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define repe(X,Y) for ((X) = 0;(X) < (Y);++(X))
#define peat(X,Y) for (;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T> using vv=vector<vector<T>>;
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"<<endl; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
const ll MOD=1e9+7;

int main(){
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(0);
  int n;
  cin>>n;
  vector<int> a(n);
  rep(i,n) cin>>a[i];
  sort(rall(a));
  a.pb(0);
  //cout<<a;
  int d;
  rep(i,n){
    if(a[i]==i+1){
      //cout<<"yoko"<<endl;
      for(d=0;a[i]==a[i+1];++i) ++d;
      break;
    }else if(a[i]!=a[i+1]){
      if(a[i+1]==i+1){
	int f1=0,f2=0;
	if((a[i]-a[i+1])%2){
	  //cout<<"bokoA"<<endl;
	  f1=1;
	}
	  //cout<<"bokoB"<<i<<endl;
	  for(++i;a[i]==a[i+1];++i) ++f2;
	  f2=1-f2%2;
	//d=1;
	  assert(!f1 || i);
	  d=f1||f2;
	break;
      }else if(a[i+1]<i+1){
	//cout<<"tate"<<endl;
	d=a[i]-(i+1);
	break;
      }
    }
  }
  //cout<<d<<endl;
  cout<<(d%2?"First":"Second")<<endl;
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <stdint.h>
#include <queue>
#include <bitset>
#include <iomanip>
#include <set>
#include <map>

using namespace std;

#define PI (3.14159265358979323846)
#define INF (2147483647)
#define INF_LL (9223372036854775807)
#define DIV_NUM (1000000007)
typedef long long ll;

// 配列初期化テンプレ
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T& val) {
	std::fill((T*)array, (T*)(array + N), val);
}


int main() {

	int H, W, K;
	cin >> H >> W >> K;

	vector<vector<char>> matrix(H, vector<char>(W));
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cin >> matrix[i][j];
		}
	}

	// 1bitずつ立てながら、それぞれ処理を行ってゆくコード
	int ans_count = 0;
	int i = 0;
	int search_bit_num = H+W;
	for (i = 0; i < (1 << search_bit_num); i++) { // 000-111の様にループを回す

		vector<vector<char>> temp;
		temp = matrix;
		for (int j = 0; j < search_bit_num; j++) { // 下から一桁づつ処理
			if (i & (1 << j)) { // j番目のビットが1なら
				if (j < H) for (int k = 0; k < W; k++) temp[j][k] = 'r';
				else for (int k = 0; k < H; k++) temp[k][j - H] = 'r';
				// j番目のビットが1の時の処理
			}
			else {
				// j番目のビットが0の時の処理
			}
		}
		// ビット状態にかかわらず、共通して実施する処理

		int count = 0;
		for (int n = 0; n < H; n++) {
			for (int m = 0; m < W; m++) {
				if (temp[n][m] == '#') count++;
			}
		}
		if (count == K) ans_count++;
	}

	cout << ans_count << endl;

	return 0;
}


Measured memory_bytes: 3632
s = input()
s = "".join([ i for i in reversed(s)]) + "0"

INF = 10 ** 32
n = len(s)
dp = [ [INF]*2 for _ in range(n)]

dp[0][0] = 0

for i in range(n-1):
    x = int(s[i])
    dp[i+1][0] = min( dp[i][0]+x, dp[i][1]+x )
    # i番目で繰り上がっていたら、(10-1)-x
    dp[i+1][1] = min( dp[i][0]+1+(10-x), dp[i][1]+(9-x) )

print(min(dp[n-1][0], dp[n-1][1]))

Measured memory_bytes: 176536
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		long h = sc.nextLong();
		long count = 0;
		long ans = 1;

		while(h >= 1) {
			h = h / 2;
			count += ans;
			ans *= 2;
		}

		System.out.println(count);

	}

}


Measured memory_bytes: 35632
#include <bits/stdc++.h>
#define INF 1000000000
#define LINF 1000000000000000000
#define MOD 1000000007
#define mod 1000007
#define INF63 1061109567
#define INF127 9187201950435737471
#define UINF 18446744073709551615
#define F first
#define S second
#define ll long long
using namespace std;
int main(){
	string s;
	cin>>s;
	if(s[0]=='A'&&s[1]=='A'&&s[2]=='A')
	{
		cout<<"No"<<endl;
	}
	else if(s[0]=='B'&&s[1]=='B'&&s[2]=='B')
	{
		cout<<"No"<<endl;
	}
	else
	{
		cout<<"Yes"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
import sys
n,k = map(int,input().split())
w = list(map(int,sys.stdin.readlines()))

def binarysearch(start,end):
    left = start
    right = end
    middle = 0
    while left < right:
        middle = (left + right)//2
        if simulate(middle,w,k):
            right = middle
        else:
            left = middle + 1
    return left

def simulate(prb,wei,dai):
    count = 1
    tmp = 0
    for j in wei:
        tmp += j
        if tmp > prb:
            tmp = j
            count += 1
            if count > dai:
                return False
    return True

print(binarysearch(max(w), sum(w)))

Measured memory_bytes: 17796
#include<iostream>
using namespace std;
int main () {
  char a[4];
  cin >> a[0] >> a[1] >> a[2] >> a[3];
  int p = 0;
  int q = 0;
  int r = 0;
  int s = 0;
  for (int i = 0; i < 4; i ++) {
    switch(a[i]) {
      case '1': p ++; break;
      case '9': q ++; break;
      case '7': r ++; break;
      case '4': s ++; break;
    }
  }
  if (p == 1 && q == 1 && r == 1 && s == 1) cout << "YES" << endl;
  else cout << "NO" << endl;
}
  


Measured memory_bytes: 384