akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define endl "\n"
#define sz(x) ((ll)(x).size())
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define prt(x) cout << (x)
#define prtl(x) cout << (x) << endl
#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 mp(a, b) make_pair(a, b)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define debug(v) cout << #v<< ": " << v <<endl;
#define fst first
#define snd second
using namespace std;
using vi = vector<int>;
using vll = vector<long long int>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vc = vector<char>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long int>>;
using vvc = vector<vector<char>>;
using ll = long long int;
using P = pair<long long int, long long int>;
using Map = map<long long int, long long int>;
ll INF = 1LL<<60;
ll M = 1000000007;

int main(){
    ll m, n; cin >> m >> n;
    ll c = 0;
    rep(i, 1, m+1){
        rep(j, 1, n+1){
            ll f = j%10;
            ll k = j - f;
            k /= 10;
            if(f > 1&&k > 1&&f*k == i){
                c++;
            }
        }
    }
    prtl(c);
}


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

int main(){
  int n,a=1;
  cin >> n;
  r(i,n){
    a*=2;
    if(n<a)a/=2;
  }
  cout << a << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int x;
    cin>>x;
    long long int fizz=0;
    for(int i=0;i<=x;++i){
        if(i%3==0 || i%5==0 ||i%15==0)
        continue;
        fizz+=i;
    }
    cout<<fizz;
}

Measured memory_bytes: 3192
function Main(input) {
    input = input.trim()
  input = input.split("");
  var a=0;
  for(var i=0;i<input.length;i++){
    if(i%2==0){
      if(input[i]==0){
        a++;
      }
    }else{
      if(input[i]==1){
        a++;
      }
    }
  }
  if(input.length-a<a){
    console.log(input.length-a);
  }else{
    console.log(a);
  }
}Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

import fileinput
import math

def main():
    while True:
        line = input().strip()
        x, y = map(int, line.split())

        if (x == 0 and y == 0):
            break
        else:
            if (x > y):
                print('%d %d' % (y, x))
            else:
                print('%d %d' % (x, y))

if __name__ == '__main__':
    main()

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

using namespace std;
using ll = long long;

ll INF = 1000000000;

int main()
{
    int n, W;
    cin >> n >> W;
    vector<int> v(n), w(n);
    for(int i = 0; i < n; i++)cin >> v[i] >> w[i];
    vector<int> dp(W + 1, -INF);
    dp[0] = 0; //重さ0は価値0

    for(int i = 0; i <= W; i++){
        for(int j = 0; j < n; j++){
            if(i + w[j] > W)continue;
            dp[i + w[j]] = max(dp[i] + v[j], dp[i + w[j]]);
        }
    }
    cout << *max_element(dp.begin(), dp.end()) << endl;
}


Measured memory_bytes: 3144
import java.io.*;
import java.util.*;

class Main{
    public static void main(String[] args){
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	ArrayList<Integer> array = new ArrayList<Integer>();
	ArrayList<Integer> arrayOut = new ArrayList<Integer>();

	try {
	    while(true){
		int i = Integer.valueOf(br.readLine());
		if(i==0)
		    break;
		array.add(i);
	    }
	} catch(Exception e){
	    System.out.println("Error");
	}
	
	for(int i=0; i<array.size(); i++){
	    int k = 0;
	    int ix = 1000-array.get(i);	    
	    while(ix>=500){
		ix-=500;
		k++;
	    }
	    while(ix>=100){
		ix-=100;
		k++;
	    }
	    while(ix>=50){
		ix-=50;
		k++;
	    }
	    while(ix>=10){
		ix-=10;
		k++;
	    }
	    while(ix>=5){
		ix-=5;
		k++;
	    }
	    while(ix>=1){
		ix-=1;
		k++;
	    }
	    
	    arrayOut.add(k);
	}
	
	for(int i=0; i<array.size(); i++)
	    System.out.println(arrayOut.get(i));
	
    }
}

Measured memory_bytes: 8900
#include <cstdio>
#include <cstdint>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <unordered_map>
#include <unordered_set>

int main()
{
    int N;
    std::cin >> N;
    int a[N+1] = {0};
    int b[N+1] = {0};
    int c[N+1] = {0};

    for (int i = 1; i <= N; ++i) {
        std::cin >> a[i] >> b[i] >> c[i];
    }

    int h[N+1][3] = {0};

    for (int i = 1; i <= N; ++i) {
        if (i == 1) {
            h[i][0] = a[i];
            h[i][1] = b[i];
            h[i][2] = c[i];
        } else {
            h[i][0] = std::max(h[i-1][1] + a[i], h[i-1][2] + a[i]);
            h[i][1] = std::max(h[i-1][0] + b[i], h[i-1][2] + b[i]);
            h[i][2] = std::max(h[i-1][0] + c[i], h[i-1][1] + c[i]);
        }
    }

    std::cout << std::max({h[N][0], h[N][1], h[N][2]}) << std::endl;

    return 0;
}

Measured memory_bytes: 2560
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<climits>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<iomanip>
using namespace std;

#define rep(i,j,n) for(int i=(j);i<(n);++i)
#define erep(i,j,n) for(int i=(j);i<=(n);++i)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define INF 1e9
const int mod = 1e9 + 7;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<int, int> pi;
typedef long long i64;

int main() {
	int n, m;
	cin >> n >> m;
	vector<pi> x;
	rep(i, 0, m) {
		int a, b;
		cin >> a >> b;
		x.push_back({ a, b });
	}
	sort(all(x));
	int r = 1;
	int ans = 0;
	for (int i = 0; i < m; i = r) {
		int a = x[i].first;
		int b = x[i].second;
		if (i == r) r++;
		while (r < m) {
			if (b <= x[r].first) break;
			a = max(a, x[r].first);
			b = min(b, x[r].second);
			r++;
		}
		ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 1400
#include<iostream>
#include<queue>
#define fi first
#define se second

using namespace std;
typedef pair<int, int> pii;
const int inf=1e9;
const pii d[]={{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
int H, W, dis[1000][1000];
char N, fld[1000][1000];
pii start;

int bfs(char num){
    queue<pii> qu;
    qu.push(start);

    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            dis[i][j]=inf;
        }
    }

    dis[start.fi][start.se]=0;
    while(!qu.empty()){
        pii now=qu.front(); qu.pop();
        int h=now.fi, w=now.se;
        if(fld[h][w]==num){
            start=make_pair(h, w);
            return dis[h][w];
        }

        for(int k=0; k<4; k++){
            pii nx=make_pair(h+d[k].fi, w+d[k].se);
            if(!(0<=nx.fi&&nx.fi<H&&0<=nx.se&&nx.se<W)) continue;//is_field?
            if(fld[nx.fi][nx.se]=='X') continue;
            if(dis[nx.fi][nx.se]!=inf) continue;
            dis[nx.fi][nx.se]=dis[h][w]+1;
            qu.push(nx);
        }
    }

}

void solve(){

    int ans=0;
    for(char c='1'; c<=N; c++){
        ans+=bfs(c);
    }

    cout<< ans<< endl;
    return;
}
int main(){

    cin>> H>> W>> N;
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            cin>> fld[i][j];
            if(fld[i][j]=='S'){
                start=make_pair(i, j);
            }
        }
    }

    solve();

    return 0;
}

Measured memory_bytes: 7972
import math

#n
n= int(input())

#x
x = list(map(int, input().split()))

sum = 0

for i in range(len(x)):
    sum += x[i]

#よくわからんが中央値の前後でやってみる
sum1 = math.ceil(sum/n)
sum2 = math.floor(sum/n)

ans1 = 0
ans2 = 0

for i in range(len(x)):
    ans1 += abs(x[i]-sum1)**2
    ans2 += abs(x[i]-sum2)**2

if ans1 <= ans2:
    print(ans1)
else:
    print(ans2)


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

using namespace std;

int main(){
    int n;
    scanf("%d", &n);
    if(n==2){
        int num[2];
        scanf("%d %d",num,num+1);
        sort(num,num+2);
        for(int i=1;i<=num[0];i++){
            if(num[0]%i==0 && num[1]%i==0){
                printf("%d\n",i);
            }
        }
    }else if(n==3){
        int num[3];
        scanf("%d %d %d",num,num+1,num+2);
        sort(num,num+3);
        for(int i=1;i<=num[0];i++){
            if(num[0]%i==0 && num[1]%i==0 && num[2]%i==0){
                printf("%d\n",i);
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3288
import sys
sys.setrecursionlimit(1000000)

ma_map = [ -1, 2, 5, 5, 4, 5, 6, 3, 7, 6 ]
N, M = (int(i) for i in input().split())
ma = list(int(i) for i in input().split())
memo = [-1] * 100000

def dfs(num):
	if memo[num] != -1: return memo[num]
	if num == 0: return 0

	ret = -1
	for p in ma:
		if 0 <= num - ma_map[p]:
			ret = max(dfs(num - ma_map[p]) * 10 + p, ret)

	memo[num] = ret
	return ret

ma.sort()
print(dfs(N))

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

int main() {
long x=0;
int K;
  cin>>K;
  int J;
  J=K+10;
  vector<long> L(J+3);
  
  for(int i=1;i<10;i++){
    L.at(i-1)=i;
    x++;
  }

    for(int j=0;j<999999999999;j++){
      int s=L.at(j)%10;
      	if(x>K-1){
          break;
        }
        if(s!=0){
          L.at(x)=L.at(j)*10+s-1;
          x++;
        }
        L.at(x)=L.at(j)*10+s;
          x++;
        if(s!=9){
          L.at(x)=L.at(j)*10+s+1;
          x++;
        }
    }
    
  cout<<L.at(K-1)<<endl;  
  
}

Measured memory_bytes: 1024
N=int(input())
D=[0]*(10**4)
for i in range(1,101):
  for j in range(1,101):
    for k in range(1,101):
      d=(i+j+k)**2-i*j-i*k-j*k
      if d<=10**4:
        D[d-1]+=1
for i in D[:N]:
  print(i)

Measured memory_bytes: 9316
package main

import (
    "fmt"
    "sort"
)

func main() {
    var n, k int
    fmt.Scan(&n, &k)
    var h = make([]int, n);
    for i := 0; i < n; i++ {
        fmt.Scan(&h[i])
    }
    sort.Ints(h)
    var ans int64
    for i := n-1-k; i >= 0; i-- {
        ans += int64(h[i]);
    }
    fmt.Println(ans);
}

Measured memory_bytes: 7040
# L 以下の数のうち最大の2のべき数をtとする。t = 2 ** k とする。
# k は len(L)-1だね。

# a+bがt未満： 3 ** k 通り
# a+bがt以上L以下： いろいろ複雑！

L = input()
lenL = len(L) 
ans = 3 ** (lenL - 1)
mod = 10 ** 9 + 7

pow_2 = [1] * (lenL+1)
pow_3 = [1] * (lenL+1)

for i in range(1, lenL+1):
	pow_2[i] = pow_2[i-1] * 2 % mod
	pow_3[i] = pow_3[i-1] * 3 % mod

num_one_leftside = 1
for i in range(1, lenL):
	if L[i] == '1':
		ans += pow_2[num_one_leftside] * pow_3[lenL - i - 1]
		ans %= mod

#		print (num_one_leftside ,  (lenL - i - 1))
		num_one_leftside += 1

ans += pow_2[num_one_leftside]
ans %= mod

print(ans)

Measured memory_bytes: 11124
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

int ans = 0;
vector<int> dp;

vector<int> Tsort(vector<vector<int>> & G){
    vector<int> To; //トポロジカルソート後のグラフ
    // To.size() == V であればトポロジカルソートができた、そうでなければできなかったと判定できる
    int V = G.size();
    stack<int> st; //入次数が 0 の頂点の集合
    int indeg[V] = {}; //頂点の入次数を管理する配列
    for(int i = 0; i < V; i++){
        for(int j = 0; j < G[i].size(); j++){
            indeg[G[i][j]]++;
        }
    }
    for(int i = 0; i < V; i++){
        if(indeg[i] == 0){
            st.push(i);
        }
    }
    dp.assign(V, 0);
    while(!st.empty()){
        int u = st.top();
        st.pop();
        To.push_back(u);
        for(int i = 0; i < G[u].size(); i++){
            indeg[G[u][i]]--; //隣接する頂点の入次数を1減らす
            dp[G[u][i]] = max(dp[G[u][i]], dp[u] + 1);
            ans = max(ans, dp[G[u][i]]);
            if(indeg[G[u][i]] == 0){
                st.push(G[u][i]); //入次数が 0 になればstに追加
            }
        }
    }
    return To;
}

signed main(){
    int n,m;
    cin >> n >> m;
    vector<vector<int>> G(n);
    int x,y;
    REP(i,m){
        cin >> x >> y;
        x--;
        y--;
        G[x].push_back(y);
    }
    Tsort(G);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 7164
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define eb          emplace_back
#define c(P)        cout<<P<<"\n"
#define pii         pair<ll,ll>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define F           first
#define S           second
#define mp(x,y)     make_pair(x,y) 
#define mem(a,val)  memset(a,val,sizeof(a))
#define fr(i,a,n)   for(ll i=a;i<n;i++)
#define frr(i,a,n)  for(ll i=n-1;i>=a;i--)


const ll N   =  500005;
const ll mod = 1e15 + 7;

using namespace std;


void solve()
{
// string s;
  ll n,m,k,x=0,y=0,c=0,q,ans=0;
  cin>>n>>m>>q;
 std::vector<ll> a,b;
a.pb(-mod);
b.pb(-mod);

  for (ll i = 0; i < n; ++i)
  {
  cin>>x;
  a.pb(x);
  }
  for (int i = 0; i < m; ++i)
  {
    /* code */
    cin>>x;
    b.pb(x);
  }
a.pb(mod);
b.pb(mod);
  for (int i = 0; i < q; ++i)
  {
    ans = 1e18;
    cin>>k;
    x = lower_bound(a.begin(), a.end(),k) - a.begin();
    y = lower_bound(b.begin(), b.end(),k) - b.begin();
    ll la = k - a[x-1];
    ll lb = k - b[y-1];
    ll ra = a[x] - k;
    ll rb = b[y] - k;
    ans = min(ans,max(ra,rb));
    ans = min(ans,max(la,lb));
    ans = min(ans,la+ rb + min(la,rb));
    ans = min(ans,lb +ra + min(lb,ra));
    c(ans);

  }

}

signed main(){

      ios_base::sync_with_stdio(false);   
      cin.tie(NULL);
      ll T=1;
      //cin>>T;
      while(T--)
      {
      solve();
      }
      return 0;
    }


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


def solve(N: int, S: str):
    C = {'E': 0, 'W': 0}
    D = {'E': 0, 'W': 0}
    for c in S:
        C[c] += 1
    a = 1e20
    for c in S:
        C[c] -= 1
        a = min(a, C['E'] + D['W'])
        D[c] += 1
    return a


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))
    S = next(tokens)
    print(solve(N, S))

if __name__ == '__main__':
    main()


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

int main()
{
	std::string weather[3]{"Sunny", "Cloudy", "Rainy"};
	std::string S;
	std::cin >> S;
	for (int i{}; i < 3; i++)
		if (S == weather[i])
			std::cout << weather[(i + 1) % 3] << std::endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<vector>
using namespace std;
#define rep(i, n)        for(int i=0; i<(int)(n); ++i)
int main() {
  char a,b,c,d;
  cin>>a>>b>>c>>d;
  map<char, int> map;
  map[a]=1;
  map[b]+=1;
  map[c]+=1;
  map[d]+=1;
  if(map[a]==2&&map[b]==2&&map[c]==2)cout<<"Yes";
  else cout<<"No";
}


Measured memory_bytes: 256
#include<algorithm>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;
 
typedef long long ll;

const ll MOD = 1000000007;
const ll INF = 1LL<<50;
#define PB push_back
#define MP make_pair
#define F first
#define S second

template<typename T,typename U>
bool chmax(T& max, const U& x){
	if(max<x){
		max = x;
		return true;
	}
	return false;
}

template<typename T,typename U>
bool chmin(T& min, const U& x){
	if(min>x){
		min = x;
		return true;
	}
	return false;
}


int main(){
  	ll n,m;
  	cin >> n >> m;
  	ll dp[1100][5000];
  	fill(dp[0],dp[0]+1100*5000,INF);
  	
  	vector<ll> a(m),b(m),c(m,0);
  	for(ll i=0;i<m;i++){
    	cin >> a[i] >> b[i];
      	for(ll j=0;j<b[i];j++){
        	ll t;
          	cin >> t;
          	c[i] += (1<<(t-1));
        }
    }
  	dp[0][0]=0;
  	for(ll i=0;i<m;i++){
      	for(ll j=0;j<pow(2,n);j++){
          	chmin(dp[i+1][j],dp[i][j]);
          	chmin(dp[i+1][j|c[i]],dp[i][j]+a[i]);
        	
        }
    }
  		if(dp[m-1][(ll)pow(2,n)-1]==INF){
        	cout << -1 <<endl;
        }else{
        	cout << dp[m-1][(ll)pow(2,n)-1]<< endl;
        }
}

Measured memory_bytes: 43264
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

i64 m;
vector<i64> d, c;
int main() {
  cin >> m;
  d.resize(m);
  c.resize(m);
  for (int i = 0; i < m; ++i) cin >> d[i] >> c[i];
  
  i64 ans = 0;

  vector<i64> d_new;
  for (int i = 0; i < m; ++i) {
    while (c[i] > 0) {
      ans += c[i] / 2 * (2 * d[i] >= 10 ? 2 : 1);
      if (c[i] % 2 == 1) {
        d_new.push_back(d[i]);
      }
      d[i] = 2 * d[i] % 10 + 2 * d[i] / 10;
      c[i] /= 2;
    }
  }

  for (int i = 1, x = d_new[0]; i < d_new.size(); ++i) {
    x += d_new[i];
    ans += x >= 10 ? 2 : 1;
    x = x % 10 + x / 10;
  }

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

Measured memory_bytes: 37732
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int N; cin>>N;
	set<string> st;
	for (int i=0; i<N; i++) {
		string S; cin>>S; st.insert(S);
	}
	cout<<st.size()<<"\n";
	return 0;
}

Measured memory_bytes: 19220
#include<bits/stdc++.h>
using namespace std; 
const int INF = (1<<30);

int main()
{
  int data[50][50];
  int dp[50][50];
  int h, w;
  
  cin >> h >> w;
  for(int i=0; i<h; i++) {
    string s;
    cin >> s;
    for(int j=0; j<w; j++) {
      data[i][j] = s[j]-'0';
      dp[i][j] = INF;
    }
  }
  dp[0][0] = 0;

  for(int i=0; i<h; i++) {
    for(int j=0; j<w; j++) {
      if( i ) dp[i][j] = min(dp[i][j], dp[i-1][j] + data[i][j]);
      if( j ) dp[i][j] = min(dp[i][j], dp[i][j-1] + data[i][j]);
    }
  }

  cout << dp[h-1][w-1] << endl;
}

Measured memory_bytes: 1224
#include <cstdio>
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
using namespace std;

int main()
{
	int h, w;
	for (int i = 0; i < 100000000; i++) {
		cin >> h >> w;
		if (h == 0 && w == 0) break;
		for (int j = 0; j < h; j++) {
			for (int t = 0; t < w; t++) {
				if (j == 0 || j == (h - 1) || t == 0 || t == (w - 1)) {
					cout << "#";
				}
				else {
					cout << ".";
				}
			}
			cout << endl;
		}
		cout << endl;
	}
}


Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
#define PIGRECO 3.141592653589793

#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 {
	~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 << "]";
}
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
///////////////////////////////////////////////////////////////////////////
//////////////////// DO NOT TOUCH BEFORE THIS LINE ////////////////////////
///////////////////////////////////////////////////////////////////////////
#define int long long
const int MOD = 1e9 + 7;

int32_t main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif


	int n, k;
	cin >> n >> k;

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

	vector<vector<int>>dp(n + 1, vector<int>(k + 1));

	vector<vector<int>>pref(n + 1, vector<int>(k + 1));

	for (int i = 0; i <= n; i++)dp[i][0] = pref[i][0] = 1;

	for (int j = 0; j <= k; j++)pref[0][j] = 1;



	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= k; j++) {


			if (j - a[i] - 1 >= 0) {
				dp[i][j] = ((((dp[i][j] + pref[i - 1][j]) % MOD) - pref[i - 1][j - a[i] - 1])) % MOD;
				if (dp[i][j] < 0)dp[i][j] += MOD;
			}
			else {
				dp[i][j] = (dp[i][j] + pref[i - 1][j]) % MOD;
			}

			pref[i][j] = ((pref[i][j] + dp[i][j]) % MOD + pref[i][j - 1]) % MOD;
			if (pref[i][j] < 0)pref[i][j] += MOD;


		}


	}


	cout << dp[n][k] << endl;

}

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

int main() {
	string S;
	cin >> S;
	
	//文字列の中にa, b, cが一個ずつあるかたしかめればいい
	if(S.find('a')==string::npos || S.find('b') == string::npos || S.find('c')==string::npos) cout << "No";
	else cout << "Yes";
	
	//条件部分が冗長
	
	cout << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define max3(a,b,c) ((a>b)?(a>c)?a:c:(b>c)?b:c)
#define min3(a,b,c) ((a<b)?(a<c)?a:c:(b<c)?b:c)
#define testcase int t;cin>>t;while(t--)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(), x.end()
#define pii pair<int, int>
#define pll pair<long long int,long long int>
typedef long long int ll;
typedef unsigned long long int ull;
#define M 1000000007
using namespace std;
int main()
{
    fast
    int a,b,res,dis1,dis2;
        cin>>a>>b;bool flag=0;
for(int x=13;x<=1000;x++)
{
    dis1=8*x/100;
    dis2=10*x/100;
    if(dis1==a&&dis2==b)
    {
        flag=1;res=x;break;
    }
}  if(flag==1)
    cout<<res<<endl;
    else
    cout<<"-1"<<endl;
return 0;
}







Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        while(true){
            int H = scan.nextInt();
            int W = scan.nextInt();
            if(H == 0 && W == 0){
                break;
            }
            for(int h = 0; h < H; h++){
                for(int w = 0; w < W; w++){
                    
                    if((h + w)%2 == 0){
                        System.out.print("#");
                    }else{
                        System.out.print(".");
                    }

                }
                System.out.print("\n");
            }

            System.out.print("\n");
        }
    }
}



Measured memory_bytes: 37180
n = int(input())

p = list(map(int,input().split()))

count=0

for i in range(n-2):
  if max(p[i],p[i+1],p[i+2])!=p[i+1]:
    if min(p[i],p[i+1],p[i+2])!=p[i+1]:
      count=count+1

print(count)
    

Measured memory_bytes: 3060
import java.io.*;
import java.util.*;
class Main{
	public static long numOfOperations(int[] candies, int maxCount){
		int excessCandies;
		long opCost = 0;
		for (int i = 0; i < candies.length - 1; i ++){
			excessCandies = candies[i] + candies[i + 1] - maxCount;
			if (excessCandies <= 0)
				continue;
			else{
				opCost += excessCandies;
				if (excessCandies < candies[i + 1]){
					candies[i + 1] -= excessCandies;
				}
				else{
					candies[i] -= excessCandies - candies[i + 1];	
					candies[i + 1] = 0;
				}
			}
		}
		return opCost;
	}
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int numOfBoxes = sc.nextInt();
		int maxCount = sc.nextInt();
		sc.nextLine();
		String[] arr = sc.nextLine().split(" ");
		int[] candies = new int[arr.length];
		for (int i = 0; i < arr.length; i ++){
			candies[i] = Integer.parseInt(arr[i]);
		}
		System.out.println(numOfOperations(candies, maxCount));
	}
}


Measured memory_bytes: 46840
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef list<int> liint;
typedef pair<int, int> pint;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }



int main() {
    ll N, K;
    cin >> N >> K;
    vint A(N);
    rep(i, N) cin >> A[i];

    ll ans = 0;
    ll p = 1000000007;
    rep(i, N) {
        REP(j, i + 1, N) {
            if (A[i] > A[j]) {
                ans++;
                ans %= p;
            }
        }
    }
    ans *= ll(K);
    ans %= p;
    ll s = ((K - 1) * K) / 2;
    sort(A.begin(), A.end());

    int num = 1;
    REP(i, 1, N) {
        if (A[i] > A[i - 1])
            num = i + 1;
        ans += (ll(num - 1) * (((ll(K) * ll(K - 1)) - s) % p) ) % p;
        ans %= p;
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if (min(b,d)>max(a,c)) cout<<min(b,d)-max(a,c)<<endl;
    else cout<<0<<endl;
}



Measured memory_bytes: 256
from collections import Counter
S = list(input())
S = Counter(S)
ans = "No"
if len(S) == 4:
    ans = "Yes"
elif len(S) == 2:
    if "N" in S and "S" in S:
        ans = "Yes"
    if "W" in S and "E" in S:
        ans = "Yes"
print(ans)



Measured memory_bytes: 9248
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n=int(input())
data=[0]*100
for ni in range(1,n+1):
    a=str(ni)[0]; b=str(ni)[-1]
    a=int(a); b=int(b)
    data[a*10+b]+=1
for i in range(1,10):
    for j in range(1,10):
        ans+=data[i*10+j]*data[j*10+i]
# print(data)
print(ans)
    


Measured memory_bytes: 3316
#include <cstdio>
#include <iostream>
#include <cmath>
#include <ctype.h>
#include <string> 
#include <sstream>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <iomanip>
  
using namespace std;

#define pi 3.141592653589793

int main()
{
	int n, m;
	while(1){
		cin >> n;
		if(n == 0) break;
		int h, r;
		int mato[1001][1001] = {};
		for(int i = 0; i < n; i++){
			cin >> h >> r;
			mato[h][r] = 1;
		}
		cin >> m;
		for(int i = 0; i < m; i++){
			cin >> h >> r;
			mato[h][r] = 1;
		}
		int result[1001][1001] = {};
		int ans = 0;
		for(int i = 1; i < 1001; i++){
			for(int j = 1; j < 1001; j++){
				result[i][j] = max(result[i - 1][j - 1] + mato[i][j], max(result[i - 1][j], result[i][j - 1]));
				ans = max(ans, result[i][j]);
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 8992
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;

//using Graph = vector<vector<edge>>;
using dou =long double;
string yes="yes";
string Yes="Yes";
string YES="YES";
string no="no";
string No="No";
string NO="NO";

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; }
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(ll i = m; i < (ll)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define query int qq;std::cin >> qq;rep(qqq,qq)
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum(a) accumulate(all(a),0ll)
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
#define case std::cout <<"Case #" <<qqq+1<<": "
#define RES(a,i,j) a.resize(i);rep(ii,i)a[ii].resize(j); 
#define as assign
#define ffor for(;;)
#define ppri(a,b) std::cout << a<<" "<<b << std::endl
#define pppri(a,b,c) std::cout<<a<<" "<<b<<" "<<c<<std::endl
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define ssum(a) accumulate(a,0ll) 
#define gre(n) greater<n>()

typedef long long ll;
//
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
//typedef long long T;
const int INF = 1000000000;
const double dINF = 1000000000;
const ll INF64 = 922337203685477580ll;
const ll MOD = 1000000007ll;
//const ll MOD = 67280421310721ll;
const dou pi=3.141592653589793;
//メモ
//二次元配列のresizeのしかた
//vv.resize(n);
//for(size_t i=0; i<n; i++){
// vv[i].resize(n);
//}

//メモ
//負の辺を持つ最短経路問題では到達不可経路でも初期化値より小さくなりうるので注意しよう！
int main(){
    ll ans=0;
    ll n;
    std::cin >> n;
    rrep(i,1,n+1){
        if(i%3!=0&&i%5!=0)ans+=i;
    }
    std::cout << ans << std::endl;
}

Measured memory_bytes: 3640
// A modular inverse based solution to 
// compute nCr % p 
#include<bits/stdc++.h> 
using namespace std; 
#define ll long long 
	ll fac[200000]; 
/* Iterative Function to calculate (x^y)%p 
in O(log y) */
ll fact(int n)
{
    
	fac[0] = 1; 
	for (ll i=1 ; i<=n; i++) 
		fac[i] = fac[i-1]*i%1000000007; 
		return fac[n];
		
}
ll power(ll x, ll y, ll p) 
{ 
	ll res = 1;	 // Initialize result 

	x = x % p; // Update x if it is more than or 
				// equal to p 

	while (y > 0) 
	{ 
		// If y is odd, multiply x with result 
		if (y & 1) 
			res = (res*x) % p; 

		// y must be even now 
		y = y>>1; // y = y/2 
		x = (x*x) % p; 
	} 
	return res; 
} 

// Returns n^(-1) mod p 
ll modInverse(ll n, ll p) 
{ 
	return power(n, p-2, p); 
} 

// Returns nCr % p using Fermat's little 
// theorem. 
ll nCrModPFermat(ll n, ll r, ll p) 
{ 
// Base case 
if (r==0) 
	return 1; 

	// Fill factorial array so that we 
	// can find all factorial of r, n 
	// and n-r 


	return (fact(n)* modInverse(fac[r], p) % p * 
			modInverse(fac[n-r], p) % p) % p; 
} 

// Driver program 
int main() 
{    ll a,b;
cin>>a>>b;
for(int i=1;i<=b;i++)
if(a-b+1>=i)
		cout<< (nCrModPFermat(a-b+1, i, 1000000007)*nCrModPFermat(b-1,i-1,1000000007))%1000000007<<endl; 
		else
		cout<<0<<endl;
	return 0; 
} 


Measured memory_bytes: 256
def main():
    N = int(input())
    F = [0] * (N + 1)
    for x in range(1, N):
        if x * x > N - 5:
            continue
        for y in range(1, N):
            Y = x * x + y * y + x * y
            if Y > N - 3:
                continue
            for z in range(1, N):
                Z = Y + z * z + y * z + z * x
                if Z > N:
                    continue
                F[Z] += 1

    print('\n'.join(map(str, F[1:])))

main()


Measured memory_bytes: 70572
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i=0; i<(ll)n; i++)
#define REPR(i, n) for(ll i=(ll)n-1; i>=0; i--)
#define FOR(i, m, n) for(ll i=(ll)m; i<(ll)n; i++)
#define FORR(i, m, n) for(ll i=(ll)m-1; i>=(ll)n; i--)
#define ALL(x) (x).begin(), (x).end()
#define ASC(v) sort(ALL(v));
#define DESC(v) sort(ALL(v), greater<int>());
#define UNIQ(a) sort(ALL(a));(a).resize(unique(ALL(a)) - a.begin());
#define PRINTD(x, d) cout << fixed << setprecision(d) << x << "\n";
#define DEBUG(x) cout<<#x<<": "<<x<<"\n"
const double PI = acos(-1);
ll lcm(ll a, ll b) { return a / __gcd(a, b) * b; }
bool isprime(int x){ int i; if(x<2)return 0; else if(x==2) return 1; if(x%2==0) return 0; for(i=3; i*i<=x; i+=2) if(x%i==0) return 0; return 1; }
int digsum(int n) { int r=0; while(n>0) { r+=n%10; n/=10; } return r; }
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; }
struct nya{ nya(){ cin.tie(0); ios::sync_with_stdio(false); } }nyan;


int main(){
    ll N;
    cin >> N;
    map<ll, ll> A;
    REP(i, N-1) {
        ll a;
        cin >> a;
        if (A.count(a-1) == 0) A[a-1] = 1;
        else A[a-1]++;
    }
    REP(i, N) {
        if (A.count(i) == 0) cout << "0\n";
        else cout << A[i] << "\n";
    }

}


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

typedef long long ll;
typedef pair<ll,ll> pi;
typedef vector <ll> vi;
typedef vector <pi> vpi;
#define f first
#define s second
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
#define aFOR(i,x) for (auto i: x)
#define mem(x,i) memset(x,i,sizeof x)
#define fast ios_base::sync_with_stdio(false),cin.tie(0)
#define maxn 51
#define INF (ll)1e18
#define int ll
int N;
string S[maxn][2];
int C[maxn];
map <string, int> dp[2];

bool ispalin(string str){
	string str2 = str; reverse(all(str2));
	return (str == str2);
}
int dpf(string str,int j){
	if (ispalin(str)) return 0;
	
	if (dp[j].find(str) != dp[j].end()) return dp[j][str];
	dp[j][str] = INF;

	
	FOR(i,1,N){
		bool ok = 1;
		int f = (j+1) % 2;
		FOR(k,0,min(S[i][f].size(), str.size()) - 1) if (S[i][f][k] != str[k]) ok = 0;
		if (!ok) continue;
		if (S[i][f].size() < str.size()){
			string nxt = "";
			FOR(k,S[i][f].size(), str.size() - 1) nxt += str[k];
			dp[j][str] = min(dp[j][str], dpf(nxt, j) + C[i]);
		}else{
			string nxt = "";
			FOR(k,str.size(), S[i][f].size() - 1) nxt += S[i][f][k];
			dp[j][str] = min(dp[j][str], dpf(nxt, f) + C[i]);
		}
	}
		
	return dp[j][str];
}
int32_t main(){
	fast;
	
	cin>>N;
	FOR(i,1,N){
		cin>>S[i][0]>>C[i];
		S[i][1] = S[i][0];
		reverse(all(S[i][1]));
	}
	int ans = INF;
	FOR(i,1,N){
		ans = min(ans, dpf(S[i][0],0) + C[i]);
	}
	
	cout<<(ans == INF ? -1 : ans);
}



Measured memory_bytes: 3736
n = int(input())
s = input()

rs = s.count('R')
gs = s.count('G')
bs = s.count('B')

t = rs * gs * bs

for i in range(n-2):
    for j in range(i, n-1):
        k = 2 * j - i
        if k < n:
            if s[i] != s[j] and s[j] != s[k] and s[k] != s[i]:
                t -= 1

print(t)


Measured memory_bytes: 9188
#include<bits/stdc++.h>
#define ford(i,a,b) for(int i=(a);i>=b;i--)
#define rep(i,a,b) for(int i=(a);(i)<=(b);(i)++)
#define ll long long
#define re return
#define mp map<int,int>
using namespace std;
int main() {
	string s;
	cin>>s;
	int x=(s[0]-'0')*10+(s[1]-'0');
	int y=(s[2]-'0')*10+(s[3]-'0');
	if(x<=12&&x>=1&&(y>=13||y==0))cout<<"MMYY";
	else if(y<=12&&y>=1&&(x>=13||x==0))cout<<"YYMM";
	else if(x<=12&&x>=1&&y<=12&&y>=1)cout<<"AMBIGUOUS";
	else cout<<"NA";
	re 0;
}


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

using namespace std;
static vector<int64_t> cost;

int32_t main()
{
  int64_t N, T;
  cin >> N >> T;

  int64_t min_val = INT64_MAX;
  for (int64_t i = 0; i < N; i++) {
    int64_t A;
    cin >> A;
    min_val = min(min_val, A);
    cost.push_back(A - min_val);
  }

  sort(cost.begin(), cost.end(), greater<int64_t>());

  uint32_t i = 0;
  uint64_t count = 0;
  while (cost[0] == cost[i] && i < cost.size()) {
    count++;
    i++;
  }

  cout << count << endl;

  return 0;
}


Measured memory_bytes: 1400
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
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;}
//自作関数
template<class T> ll llpow(T x,T n){ll ans=1;while(n--){ans*=x;}return ans;}

#define rep(i,n) for(ll i=0;i<(ll)n;i++)
#define rep2(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)

long long INF = 1LL<<60;
int n;
int main(){
    cin>>n;
    vector<int> p(n);
    rep(i,n)cin>>p[i];
    int smallest=p[0];
    int ans=0;
    rep(i,n){
        if(smallest>=p[i]){
            ans++;
            smallest=p[i];
        }
    }
    cout<<ans<<endl;
    return 0;
}




Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define INF 99999999
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
 
int main()
{
    int N;
    cin >> N;
    vector<ll> A(N);
    rep(i,N)
    {
        cin >> A[i];
    }
    sort(all(A));
    ll i = 1;
    for(i; pow(2,i) < A[0]+1; i ++)
    {
        rep(j,N)
        {
            if(A[j]%(int)pow(2,i) != 0)
            {
                cout << i - 1 << endl;
                return 0;
            }
        }
    }
    cout << i - 1 << endl;
}


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

const int MAX=2000005;
const int MOD=1000000007; 

long long fac[MAX],finv[MAX], inv[MAX];

void combit() {
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2; i<MAX; i++){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}

long long com(int nn, int kk){
    if(nn<kk) return 0;
    if(nn<0 || kk<0) return 0;
    return fac[nn]*(finv[kk]*finv[nn-kk]%MOD)%MOD;
}

int main() {
    long long x,y;
    cin >> x >> y;
    combit();
    if((x+y)%3!=0) cout << 0;
    else cout << com((x+y)/3, min(x,y)-(x+y)/3);
}

Measured memory_bytes: 47104
#include <iostream>
#include <algorithm>
#include <functional>
#include<vector>
#include<math.h>
#include<bitset>
#include<string>
#include<queue>


using namespace std;

int main() {
	string S;
	cin >> S;
	long long int Y = 0;
	long int R = 0;

	int B[10];
	for (int i = 0; i < S.size(); i++) {
		if (S[i] == '1')B[i] = 1;
		if (S[i] == '2')B[i] = 2;
		if (S[i] == '3')B[i] = 3;
		if (S[i] == '4')B[i] = 4;
		if (S[i] == '5')B[i] = 5;
		if (S[i] == '6')B[i] = 6;
		if (S[i] == '7')B[i] = 7;
		if (S[i] == '8')B[i] = 8;
		if (S[i] == '9')B[i] = 9;
		if (S[i] == '0')B[i] = 0;
	}


	for (long long int i = 0; i < pow(2,(S.size()-1)); i++) {
		bitset<10> bit(i);

		for (int k =S.size()-1;k>=0 ; k--) {
			

			

			Y += B[k] * pow(10, R);
			if (bit[S.size()-k-1] == 0) {
				R = 0;
			}
			else {
				R++;
			}
		}


	}
	cout << Y << endl;

	return 0;
}

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

using ll = long long;

int main(){
    int n;
    std::cin >> n;
    ll cnt = 0;
    for(int i = 0; i < n; i++){
        ll a;
        std::cin >> a;
        while(a % 2 == 0){
            cnt++;
            a /= 2;
        }
    }

    std::cout << cnt << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <algorithm>

using namespace std;

int main(){

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


    return 0;
}



Measured memory_bytes: 3112
/* ***********************************************
Author        :taciturnity
Created Time  :2020/2/21 8:23:51
File Name     :TEST.cpp
************************************************ */

#include <iostream>
#include <vector>
#include <queue>
#include <cstdio>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#define ll long long
#define INF 0x3f3f3f3f
#define bug puts("--------------")
const int N = 1e6 + 10;
const int M = 2e6 + 10;
const ll mod = 1e9 + 7;
using namespace std;
ll read()
{
    ll x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int n;
int a[105];
int main(){
    int sum = 0;
    cin >> n;
    for(int i = 1;i <= n;++i) cin >> a[i],sum += a[i];
    int d1 = sum/n;
    int d2 = d1 + 1;
    int s1 = 0,s2 = 0;
    for(int i = 1;i <= n;++i){
        s1 += (d1 - a[i])*(d1 - a[i]);
        s2 += (d2 - a[i]) * (d2 - a[i]);
    }
    cout << min(s1,s2);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<vector>
using namespace std;
#define ll long long
const long long M = 10e9+7;
int main()
{
	int k,x;cin>>k>>x;
	if(k*500>=x) cout<<"Yes\n";
	else cout<<"No\n";
	return 0;
}

Measured memory_bytes: 256
import math
# 最大公約数gcd, 
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

# 最小公倍数lcm
def lcm(a, b):
    return (a*b) // gcd(a,b)

a, b, c, d = (int(i) for i in input().split())

cd = lcm(c,d)
r = b-a+1

min_c = a//c + (1 if a%c!=0 else 0)
max_c = b//c
min_d = a//d + (1 if a%d!=0 else 0)
max_d = b//d
min_cd = a//cd + (1 if a%cd!=0 else 0)
max_cd = b//cd

c_num = max_c-min_c+1
d_num = max_d-min_d+1
cd_num = max_cd-min_cd+1

print(r-c_num-d_num+cd_num)


Measured memory_bytes: 38384
#include <iostream>
#include <string>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

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

Measured memory_bytes: 3588
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Xml.Schema;

namespace Contest
{
    class Scanner
    {
        private string[] line = new string[0];
        private int index = 0;
        public string Next()
        {
            if (line.Length <= index)
            {
                line = Console.ReadLine().Split(' ');
                index = 0;
            }
            var res = line[index];
            index++;
            return res;
        }
        public int NextInt()
        {
            return int.Parse(Next());
        }
        public long NextLong()
        {
            return long.Parse(Next());
        }
        public ulong NextUlong()
        {
            return ulong.Parse(Next());
        }
        public string[] Array()
        {
            line = Console.ReadLine().Split(' ');
            index = line.Length;
            return line;
        }
        public int[] IntArray()
        {
            var array = Array();
            var result = new int[array.Length];
            for (int i = 0; i < array.Length; i++)
            {
                result[i] = int.Parse(array[i]);
            }

            return result;
        }
        public long[] LongArray()
        {
            var array = Array();
            var result = new long[array.Length];
            for (int i = 0; i < array.Length; i++)
            {
                result[i] = long.Parse(array[i]);
            }

            return result;
        }
    }

    struct S
    {
        public int X, Y, H;
    }

    class Program
    {
        private int N;
        private S[] S;
        private int NonZero = -1;
        private void Scan()
        {
            var sc = new Scanner();
            N = sc.NextInt();
            S = new S[N];
            for (int i = 0; i < N; i++)
            {
                S[i] = new S()
                {
                    X = sc.NextInt(),
                    Y = sc.NextInt(),
                    H = sc.NextInt()
                };
                if (S[i].H != 0)
                {
                    NonZero = i;
                }
            }
        }

        public void Solve()
        {
            Scan();

            for (int i = 0; i <= 100; i++)
            {
                for (int j = 0; j <= 100; j++)
                {
                    int h;
                    if (Check(i, j, out h))
                    {
                        Console.WriteLine($"{i} {j} {h}");
                        return;
                    }
                }
            }

        }

        private bool Check(int x, int y, out int h)
        {
            h = S[NonZero].H + Math.Abs(S[NonZero].X - x) + Math.Abs(S[NonZero].Y - y);
            foreach (S s in S)
            {
                if (s.H != Math.Max(0, h - Math.Abs(s.X - x) - Math.Abs(s.Y - y)))
                {
                    return false;
                }
            }
            return true;
        }

        static void Main() => new Program().Solve();
    }
}

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

int main() {

    int n;
    cin >> n;
    vector<int> vec(n);
    rep(i, n){
        cin >> vec.at(i);
    }
    sort(vec.begin(), vec.end());

    cout << vec.at(n - 1) - vec.at(0) << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <functional>

#define ll long long

using namespace std;

bool solve(vector<string>& A, int N, vector<string>& B, int M, int i, int j) {
    for (int k = 0; k < M; k++) {
        for (int g = 0; g < M; g++) {
            if (i + k >= N || j + g >= N) {
                return false;
            }
            if (A[i + k][j + g] == B[k][g]) {
                continue;
            }
            else {
                return false;
            }
        }
    }
    return true;
}

int main()
{
    int N, M; cin >> N >> M;
    vector<string> A(N);
    for (auto& a : A) {
        cin >> a;
    }
    vector<string> B(M);
    for (auto& b : B) {
        cin >> b;
    }
    bool ans = false;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            if (A[i][j] == B[0][0]) {
                ans = solve(A, N, B, M, i, j);
                if (ans) break;
            }
        }
        if (ans) break;
    }

    cout << (ans ? "Yes" : "No") << endl;
}



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

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

typedef long long ll;
typedef pair<ll,ll> Path;
int main(int argc, char const *argv[])
{
    cin.tie(0);
   	ios::sync_with_stdio(false);
    ll N, M; cin >> N >> M;
    vector<vector<ll>> vv(N+1);
    REP(i, M) {
        Path p;
        cin >> p.first >> p.second;
        vv[p.first].push_back(p.second);
        vv[p.second].push_back(p.first);
    }
    queue<Path> que; // src, dst
    vector<ll> res(N+1,0);
    que.push(make_pair(0,1));
    while(!que.empty()) {
        Path cur_p = que.front(); que.pop();
        if (res[cur_p.second] <= 0) {// 初訪問
            res[cur_p.second] = cur_p.first;
        }
        for(auto x: vv[cur_p.second]) { // 今いるところから行けるところ // N*M になっているっぽい
            if (res[x] == 0) { //未訪問の時のみ
                que.push(make_pair(cur_p.second, x));
                res[x] = -1; // queueに入ったことを表しておくと重複が減るはず
            }
        }
    }
    cout << "Yes" << endl;
    REP(i, N+1){
        if (i>1) cout << res[i] << endl;
    }
    return 0;
}


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

using ll = long long;
using pp = pair<ll,ll>;
const ll amari = 1e9+7;
const char BC = 'A' - 'a';
#define ben(a) a.begin(),a.end() //昇順
#define enb(a) a.rbegin(),a.rend() //降順
#define pb(a,b) a.push_back(b)
//fixed << setprecision(20)

int main(){
	int a,b;
	cin >> a >> b;
	if(a > 9 || b > 9)cout << -1 << endl;
	else cout << a * b << endl;
	return 0;
}


Measured memory_bytes: 256