akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 
using namespace std;
 
#define ll long long int
 
#define REP(i, n) for(int i = 0; i < (n); i++)
#define SREP(i, s) for(int i = 0; i < (s.size()); i++)
#define SORT(v, n) sort(v, v+n);
#define GSORT(v, n) sort(v, v+n, greater<int>());
#define VSORT(v) sort(v.begin(),v.end());
#define VGSORT(v) sort(v.begin(),v.end(),greater<int>());
#define REV(a) reverse(begin(a),end(a));
#define FIND(v,i) find(v.begin(),v.end(),i);

int main(){
	ios::sync_with_stdio(false);cin.tie(0);
////////////////////////////////////////////
	int h,w;
    cin >> h >> w;
    string s[h];
    REP(i,h) cin >> s[i];
    REP(i,h*2) cout << s[i/2] << endl;
/////////////////////////////////////////////
}

Measured memory_bytes: 256
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

int** tate_ruisekiwa;
int** yoko_ruisekiwa;
int** dp;
int W,H;

int recursive(int row,int col,int turn){

	if(row == H || col == W)return 0;

	if(dp[row][col] != -BIG_NUM)return dp[row][col];

	if(turn == 0){

		dp[row][col] = max(recursive(row+1,col,1-turn)+(yoko_ruisekiwa[row+1][W]-yoko_ruisekiwa[row+1][col]),recursive(row,col+1,1-turn)-(tate_ruisekiwa[H][col+1]-tate_ruisekiwa[row][col+1]));

	}else{

		dp[row][col] = min(recursive(row+1,col,1-turn)+(yoko_ruisekiwa[row+1][W]-yoko_ruisekiwa[row+1][col]),recursive(row,col+1,1-turn)-(tate_ruisekiwa[H][col+1]-tate_ruisekiwa[row][col+1]));

	}

	return dp[row][col];
}


int main(){

	scanf("%d %d",&W,&H);

	tate_ruisekiwa = new int*[H+1];
	yoko_ruisekiwa = new int*[H+1];
	dp = new int*[H+1];

	for(int row = 0; row <= H; row++){
		tate_ruisekiwa[row] = new int[W+1];
		yoko_ruisekiwa[row] = new int[W+1];
		dp[row] = new int[W+1];
		for(int col = 0; col <= W; col++){
			tate_ruisekiwa[row][col] = 0;
			yoko_ruisekiwa[row][col] = 0;
			dp[row][col] = -BIG_NUM;
		}
	}

	for(int row = 1; row <= H; row++){
		for(int col = 1; col <= W; col++){
			scanf("%d",&tate_ruisekiwa[row][col]);
			yoko_ruisekiwa[row][col] = tate_ruisekiwa[row][col];
		}
	}

	for(int col = 1; col <= W; col++){
		for(int row = 1; row <= H; row++){
			tate_ruisekiwa[row][col] += tate_ruisekiwa[row-1][col];
		}
	}

	for(int row = 1; row <= H; row++){
		for(int col = 1; col <= W; col++){
			yoko_ruisekiwa[row][col] += yoko_ruisekiwa[row][col-1];
		}
	}

	printf("%d\n",abs(recursive(0,0,0)));

	return 0;
}

Measured memory_bytes: 15128
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
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 pb push_back
#define mp make_pair
#define F .first
#define S .second 
using ll=long long;
using ld=long double;
const ll INF = 1LL<<60;
const ll mod=1e9+7;
using namespace std;
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }


long long modpow(ll a, ll b) {
    ll res=1;
    while (b) {
        if (b&1)res=res*a%mod;
        a=a*a%mod;
        b>>=1;
    }
    return res;
}

map<tuple<ll,ll,ll>,ll> p;
int main(){
    
    ll n,m=0,pm,x,y,ans=1;
    cin>>n;
    rep(i,0,n){
        pm=0;
        cin>>x>>y;
        if((y<0&&x>=0)||(y>=0&&x<0)){y=labs(y);x=labs(x);pm=1;}

        if(x==0&&y==0)m++;
        else if(y==0)p[{1,0,0}]++;
        else if(x==0)p[{0,1,0}]++;
        else  {
            p[{x/gcd(x,y),y/gcd(x,y),pm}]++;
        }
    }
    
    for(map<tuple<ll,ll,ll>,ll>::iterator it=p.begin();it!=p.end();it++){
        tuple<ll,ll,ll> f=it->first;
        ll g=it->second;
        ll s1=get<0>(f),s2=get<1>(f),s3=get<2>(f);
        ll pm2=0;
        if(s1&&s2){
            if(s3==0)pm2=1;
            else pm2=0;
        }

        ll g2=p[{s2,s1,pm2}];
        
        ll tmp=(modpow(2,g)+modpow(2,g2)-1)%mod;
        ans=(ans*tmp)%mod;
        p[f]=0,p[{s2,s1,pm2}]=0;
        
    }
    cout<<(ans-1+m+mod)%mod<<endl;
}

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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, x);
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;

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

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

int main(void)
{
    int a, b;
    cin >> a >> b;
    ((a + b >= 10) ? (cout << "error" << endl) : (cout << a + b << endl));
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
    int a,b; //a=月、b=日
    int x=0,ans;

    for(;;){
    scanf("%d%d",&a,&b);
    if(a == 0 && b == 0)return 0;

    if(a == 1)x=0;
    else if(a == 2)x=3;
    else if(a == 3)x=4;
    else if(a == 4)x=0;
    else if(a == 5)x=2;
    else if(a == 6)x=5;
    else if(a == 7)x=0;
    else if(a == 8)x=3;
    else if(a == 9)x=6;
    else if(a == 10)x=1;
    else if(a == 11)x=4;
    else if(a == 12)x=6;

    ans=(b+x+11)%7;

    if(ans == 1)printf("Sunday\n");
    else if(ans == 2)printf("Monday\n");
    else if(ans == 3)printf("Tuesday\n");
    else if(ans == 4)printf("Wednesday\n");
    else if(ans == 5)printf("Thursday\n");
    else if(ans == 6)printf("Friday\n");
    else if(ans == 0)printf("Saturday\n");
    }
}

Measured memory_bytes: 584
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> P1;
typedef pair<P, P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i, x) for (long long i = 0; i < x; i++)
#define repn(i, x) for (long long i = 1; i <= x; i++)
#define SORT(x) sort(x.begin(), x.end())
#define ERASE(x) x.erase(unique(x.begin(), x.end()), x.end())
#define POSL(x, v) (lower_bound(x.begin(), x.end(), v) - x.begin())
#define POSU(x, v) (upper_bound(x.begin(), x.end(), v) - x.begin())
vector<pair<string, P> > vec;
// vector<vector<int>> data(3, vector<int>(4));

void solve(long long N, vector<long long> A) {
    vector<ll> res(N);
    rep(i, N - 1) res[A[i]]++;
    rep(i, N) cout << res[i] << endl;
}

int main() {
    long long N;
    scanf("%lld", &N);
    vector<long long> A(N - 2 + 1);
    for (int i = 0; i <= N - 2; i++) {
        scanf("%lld", &A[i]);
        A[i]--;
    }
    solve(N, A);
    return 0;
}


Measured memory_bytes: 8012
#include <bits/stdc++.h>
using namespace std;
struct edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    edge(int t, int w) : to(t), weight(w) { }
};
using Graph = vector<vector<int>>;
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 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 resize
#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)
 
typedef long long ll;
typedef pair<int,int> P;
//typedef long long T;
const int INF = 2000000000;
const ll INF64 = 922337203685477580ll;
const ll MOD = 1000000007ll;
int w,h;
void dfs(std::vector<std::vector<int> > &a,int y,int x){
    a[y][x]=0;
    rrep(i,max(0,y-1),min(y+2,h)){
        rrep(j,max(0,x-1),min(x+2,w)){
            if(y==i&&x==j)continue;
            if(a[i][j]==0)continue;
            dfs(a,i,j);
        }
    }
}
int main(){
    for(;;){
        
        std::cin >> w>>h;
        if(w==0)exit(0);
        vvector(a,int,h,w,0);
        reprep(i,j,h,w)std::cin >> a[i][j];
        int ans=0;
        reprep(i,j,h,w){
            if(a[i][j]){
                ans++;
                dfs(a,i,j);
            }
        }
        std::cout << ans << std::endl;
    }
    
    
}


Measured memory_bytes: 3428
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



int N;
vector<vector<int>> V;

void recursive(vector<int> vec,int pre,int tmp_sum){

	for(int i = min(pre,N-tmp_sum); i >= 1; i--){

		vector<int> next = vec;
		next.push_back(i);

		int next_tmp_sum = tmp_sum+i;

		if(next_tmp_sum == N){
			V.emplace_back(next); //★注意★
			continue;
		}
		recursive(next,i,next_tmp_sum);
	}
}

void func(){

	V.clear();

	vector<int> first;

	recursive(first,BIG_NUM,0);

	for(int i = 0; i < V.size(); i++){
		printf("%d",V[i][0]);
		for(int k = 1; k < V[i].size(); k++){
			printf(" %d",V[i][k]);
		}
		printf("\n");
	}
}

int main(){

	while(true){

		scanf("%d",&N);
		if(N == 0)break;

		func();
	}

	return 0;
}



Measured memory_bytes: 3580
#include<stdio.h>
int a=0;
int N,a;
char hoge[1000000]={0};
char box[1000000];

int  main(void){
	scanf("%d ",&N);
    scanf("%s",hoge);
	
 


for(int i=0;i<N-1;i++){
	if(hoge[i]==hoge[i+1]){
		a++;
		}else{
			;
			}	
	}
printf("%d",N-a);
}
		

Measured memory_bytes: 256
use std::str::FromStr;
use std::collections::{HashMap,HashSet,VecDeque,BinaryHeap};
use std::cmp::{max,min,Ordering};
use std::io::Read;

fn main() {

    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut buf_it = buf.split_whitespace();

    let x = buf_it.next().unwrap().parse::<usize>().unwrap();
    let y = buf_it.next().unwrap().parse::<usize>().unwrap();

    println!("{}",gcd(x,y));

}

fn gcd(x:usize,y:usize)->usize{
    if y==0 {return x}
    gcd(y,x%y)
}


Measured memory_bytes: 5032
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<string>
using namespace std;
int main(){
	long long n,a;
	while(~scanf("%lld",&n)){
		for(int i=1;i<=sqrt(n);i++){
			if(i*i<=n&&(i+1)*(i+1)>n) a=i*i;
		}
		printf("%lld\n",a);
	}
}

Measured memory_bytes: 256
while True:
    a, op, b =input().split()
    a=int(a)
    b=int(b)
    if op=="+":
        print(a+b)
    elif op=="-":
        print(a-b)
    elif op=="*":
        print(a*b)
    elif op=="/":
        print(a//b)
    elif op=="?":
        break


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

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

const int INT_INF = 2147483646;
const ll LL_INF = 9223372036854775807;
const double PI=3.1415926535897932;

bool SecondCompare(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second<b.second;
}
 
bool SecondCompareDes(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second>b.second;
}

ll minll(ll a, ll b){
    if(a >= b)  return b;
    else    return a;
}

ll maxll(ll a, ll b){
    if(a >= b)  return a;
    else    return b;
}

ll x,a,b,ans;

int main(){
    cin >> x >> a >> b;
    ans = x;
    ans -= a;
    ans = ans - ans/b*b;
    cout << ans << endl;
}

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

#include <vector>

using namespace std;
using ll = long long;

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

    string S;
    cin >> S;

    vector<vector<int>> dp(N, vector<int>(27, 0));
    dp[0][S[0] - 'a'] = 1;
    for (int i = 1; i < N; i++) {
        for (char c = 'a'; c <= 'z'; c++) {
            if (S[i] == c)
                dp[i][c - 'a'] = dp[i - 1][c - 'a'] + 1;
            else
                dp[i][c - 'a'] = dp[i - 1][c - 'a'];
        }
    }
    // for (int i = 0; i < N; i++) {
    // for (int j = 0; j < 27; j++) {
    // cout << dp[i][j];
    // }
    // cout << endl;
    // }

    int output = 0;
    for (int i = 0; i < N; i++) {
        int tmp = 0;
        for (int j = 0; j <= 26; j++) {
            if (dp[i][j] > 0 && dp[N - 1][j] - dp[i][j] > 0) {
                tmp++;
            }
        }
        if (output < tmp) output = tmp;
    }

    cout << output << endl;

    return 0;
}


Measured memory_bytes: 3620
#include<cstdio>

int extgcd(int a, int b, int& x, int& y){
	int d = a;
	if(b != 0){
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}else{
		x = 1; y = 0;
	}
	return d;
}

int main(){
	int a, b, x, y;
	scanf("%d %d", &a, &b);
	int d = extgcd(a, b, x, y);
	printf("%d %d\n", x, y);
	return 0;
}

Measured memory_bytes: 2748
#include <iostream>
using namespace std;
int main(){

    int n;
    cin>>n;
    int k;
    cin>>k;
    
    int kk=k-1;
    int ans=1;
    while(k<n){
        k+=kk;
        ans++;
    }
    
    cout<<ans<<endl;




return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define showmap(is, js, x) {rep(i, is){rep(j, js){cout << x[i][j] << " ";}cout << endl;}}
#define show(x) {for(auto i: x){cout << i << " ";} cout<<endl;}
#define showm(m) {for(auto i: m){cout << m.x << " ";} cout<<endl;}
typedef long long ll;
typedef pair<int, int> P;
ll gcd(int x, int y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}

const int mmax = 52;

int amap[mmax][mmax] = {0};
int bmap[mmax][mmax] = {0};
int n, m;

bool shift_matching(int is, int js){
    bool ans = true;
    for (int i = 0; i < m; i++)
    {
        for (int j = 0; j < m; j++)
        {
            if(bmap[i][j] != amap[i+is][j+js]){
                ans = false;
            }   
        }
    }    
    return ans;
}

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

    rep(i, n){
        string tmp; cin >> tmp;
        rep(j, n){
            amap[i][j] = (tmp[j]=='#') ? 2 : 1;
        }
    }

    rep(i, m){
        string tmp; cin >> tmp;
        rep(j, m){
            bmap[i][j] = (tmp[j]=='#') ? 2 : 1;
        }
    }
//   showmap(n, n, amap);
//    showmap(m, m, bmap);

    bool isok = false;
    rep(ishift, n-m+1){
        rep(jshift, n-m+1){
            if(shift_matching(ishift, jshift)){
                isok = true;
            }
        }
    }

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



Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define REP(i, b, n) for (Int i = b; i < Int(n); i++)
#define rep(i, n) REP(i, 0, n)
using namespace std;
using Int = long long;
Int inf = 1000000000000000001LL;
using vi = vector<Int>;
using vvi = vector<vi>;
using pii = pair<Int,Int>;
using mapis = unordered_map<Int,string>;
using mapii = unordered_map<Int,Int>;

Int GCD(Int a, Int b){
    if(b==0) return a;
    if(a < b) return GCD(b, a);
    unsigned r;
    while ((r=a%b)) {
        a = b;
        b = r;
    }
    return b;
}

Int LCM(Int a, Int b){
    return a*b/GCD(a,b);
}


int main() {
    Int A, P;
    cin >> A >> P;
    Int allP = A*3 + P;
    Int ans = allP/2;

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

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

using namespace std;

#define rep(i, n) for(long long i = 0; i < (long long)(n); i++)
#define all(x) (x).begin(),(x).end()

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

	int left = s / 100;
	int right = s % 100;

	string ans = "NA";
	auto is_m = [](int v) { return 1 <= v && v <= 12; };
	if(is_m(left) && is_m(right))
	{
		ans = "AMBIGUOUS";
	}
	else if (is_m(left))
	{
		ans = "MMYY";
	}
	else if (is_m(right))
	{
		ans = "YYMM";
	}
	else
	{
		ans = "NA";
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
a, b, n = map(int,input().split())
for i in range(a, a + n + 1):
    if i > b - n:
        break
    if i <= a + n - 1:
        print(i)
    
for j in range(b - n, b + 1):
    if i > b:
        break
    if j >= b - n + 1 and a <= j:
        print(j)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define F first
#define S second
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b?gcd(b, a%b):a;}
ll lcm(ll a, ll b) { return a*b/gcd(a,b);}
ll MOD=1000000007;

int main(){
  int n,l;cin>>n>>l;
  vi v(n);
  bool fl=false;
  int ans=0;
  rep(i,n){
    v.at(i)=l+i;
    if(l+i==0) fl=true;
  }
  sort(all(v));
  if(!fl){
    if(v.at(0)>0){
      for(int i=1;i<n;i++){
        ans+=v.at(i);
      }
    }else{
      for(int i=0;i<n-1;i++){
        ans+=v.at(i);
      }
    }
  }else{
    rep(i,n){
      ans+=v.at(i);
    }
  }
  cout<<ans<<endl;
}

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

int main(){
	int N, M, C, cnt = 0;
	vector<int> B;
	vector< vector<int> >A;

	cin >> N >> M >> C;
	for(int i = 0; i < M; ++i){
		int Bi; cin >> Bi;
		B.push_back(Bi);
	}

	A.resize(N);
	for(int i = 0; i < N; ++i){
		for(int j = 0; j < M; ++j){
			int Aij; cin >> Aij;
			A[i].push_back(Aij);
		}
	}

	for(int i = 0; i < N; ++i){
		int sum = 0;
		for(int j = 0; j < M; ++j){
			sum += A[i][j]*B[j];
		}
		sum += C;
		if(sum > 0) cnt++;
	}

	cout << cnt << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define FOR(i,l,r) for(i=l;i<r;i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define P pair<ll,ll>
#define F first
#define S second
signed main(){
  ll i;
  REP(i,365)cout<<i%26+1<<endl;
  return 0;
}

Measured memory_bytes: 3620
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		int[] f_w = new int[2];
		Scanner sc = new Scanner(System.in);

		do {
			for (int i = 0; i < 2; i++) {
				f_w[i] = sc.nextInt();
			}

			if (f_w[0] == 0 && f_w[1] == 0) {
				break;
			} else {
				 System.out.println(findWays(f_w[0], f_w[1]));
			}
		}while(true);
		sc.close();


	}

	private static int findWays(int n, int x) {
		int cnt = 0;

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

					if (i != j && j != k && k != i && i + j + k == x) {
							cnt++;
					}

				}
			}
		}

		return cnt;

	}

}



Measured memory_bytes: 26632
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include <unordered_map>
//#include"testlib.h"
#define endl "\n"
#define all(v) v.begin(),v.end()
#define allr(s) s.rbegin(),s.rend()
#define RT(s) return cout<<s,0
#define watch(x) cout << (#x)<<" = "<<x<<endl
#define sz(s)    (int)(s.size())
#define PI acos(-1)
#define EPS 1e-8
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
int dy[] = { 1, -1, 0, 0, -1, 1, 1, -1 };
int dx[] = { 0, 0, 1, -1, 1, -1, 1, -1 };
void file() {
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
#else
	//freopen("street.in", "r", stdin);
	//freopen("out.txt", "w", stdout);
#endif
}
void fast() {
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL);
}
int num = 0, n, k;
vi str;
void solve(int idx, int prev) {
	if (idx == n) {
		num++;
		if (num == k) {
			for (auto& it : str)
				cout << it;
			cout << endl;
			exit(0);
		}
		return;
	}
	if (!idx) {
		for (int i = 1; i <= 9; i++) {
			str.push_back(i);
			solve(idx + 1, i);
			str.pop_back();
		}
		return;
	}
	if (prev - 1 >= 0) {
		str.push_back(prev - 1);
		solve(idx + 1, prev - 1);
		str.pop_back();
	}

	str.push_back(prev);
	solve(idx + 1, prev);
	str.pop_back();

	if (prev + 1 <= 9) {
		str.push_back(prev + 1);
		solve(idx + 1, prev + 1);
		str.pop_back();
	}
}
int main() {
//	file();
	fast();
	cin >> k;
	for (int i = 1; true; i++) {
		n = i;
		solve(0, 0);
	}
	return 0;
}



Measured memory_bytes: 256
#include"bits/stdc++.h"
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/adaptors.hpp>
//#include <vector>
//#include <iostream>

typedef long long ll;
typedef unsigned long long ull;
#define MOD 1000000007
int X, Y;


long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; std::swap(a, b);
        u -= t * v; std::swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

std::vector<std::vector<ll>> comb(int n, int r) {
  std::vector<std::vector<long long>> v(n + 1,std::vector<long long>(n + 1, 0));
  for (int i = 0; i < v.size(); i++) {
    v[i][0] = 1;
    v[i][i] = 1;
  }
  for (int j = 1; j < v.size(); j++) {
    for (int k = 1; k < j; k++) {
      v[j][k] = (v[j - 1][k - 1] + v[j - 1][k]);
    }
  }
  return v;
}

void Main()
{
	std::cin >> X >> Y;
	if ((X + Y) % 3 != 0) {
		std::cout << 0 << std::endl;
		return;
	}
	int m = (2*X - Y) / 3;
	int n = (2*Y - X) / 3;
	if (n < 0 || m < 0) {
		std::cout << 0 << std::endl;
		return;
	}
	//std::vector<std::vector<ll>> combination = comb(n+m, n);
	ll ans = 1;
	for (int i = 0; i < n; i++) {
		ans *= (n+m-i);
		ans %= MOD;
	}
	ll fact = 1;
	for (int i = n; i > 0; i--) {
		fact *= i;
		fact %= MOD;
	}
	//std::cout << (ans/fact)%MOD <<std::endl;
	std::cout << ans * modinv(fact, MOD) % MOD <<std::endl;

	return;


}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define pb push_back
const int N = 5e5+5;
int bit[33][N];
void add(int id,int idx,int val){
    for(int i=idx;i<N;i+=(i&-i)){
        bit[id][i]+=val;
    }
}
int sm(int id,int idx){
    int ret = 0;
    for(int i=idx;i>0;i-=(i&-i)){
        ret+=bit[id][i];
    }
    return ret;
}
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n;
    cin>>n;
    string s;
    cin>>s;
    for(int i=0;i<n;i++){
        add(s[i]-'a',i+1,1);
    }
    int m;
    cin>>m;
    while(m--){
        int t;
        cin>>t;
        if(t==1){
            int x;
            cin>>x;
            char c;
            cin>>c;
            if(s[x-1]==c)continue;
            add(s[x-1]-'a',x,-1);
            add(c-'a',x,1);
            s[x-1] = c;
        }
        else{
            int l,r;
            cin>>l>>r;
            int ans = 0;
            for(int i=0;i<33;i++){
                if(sm(i,r)-sm(i,l-1)>0)ans++;
            }
            cout<<ans<<endl;
        }

    }
    return 0;
}


Measured memory_bytes: 52124
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>
#include<queue>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

bool isPrime(Int n) {
	if (n == 2 || n == 3) return true;
	else if (n % 2 == 0 || n % 3 == 0) return false;
	else if (n % 6 != 1 && n % 6 != 5) return false;
	for (Int i = 5; i * i <= n; i += 6) {
		if (n % i == 0) return false;
		if (n % (i + 2) == 0) return false;
	}
	return true;
}

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	Int N;
	cin >> N;

	map<Int, Int> cnt;

	Int temp;
	for (Int i = 2; i <= N; i++) {
		if (isPrime(i)) {
			temp = i;
			while (temp <= N) {
				cnt[i] += N / temp;
				temp *= i;
			}
		}
	}

	Int ans=0;

	Int c2 = 0;
	Int c4 = 0;
	Int c14 = 0;
	Int c24 = 0;
	Int c74 = 0;

	for (auto itr = cnt.begin(); itr != cnt.end(); ++itr) {
		if (itr->second >= 2)c2++;
		if (itr->second >= 4)c4++;
		if (itr->second >= 14)c14++;
		if (itr->second >= 24)c24++;
		if (itr->second >= 74)c74++;
	}

	
	if(c74)ans += c74;
	if (c4) {
		if (c2 >= 2) {
			ans +=c4*(c4-1)/2*(c2-2) ;
		}
	}
	if (c4)ans += c14 * (c4 - 1);
	if (c2)ans += c24 * (c2 - 1);

	cout << ans << "\n";
}


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

using namespace std;

const int N = 300004;
int cnth[N], cntw[N], x[N], y[N];
map <int, bool> mp[N];

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int h, w, m;
    cin >> h >> w >> m;
    for (int i = 0; i < m; i++) {
        cin >> x[i] >> y[i];
        mp[x[i]][y[i]] = true;
        cnth[x[i]]++, cntw[y[i]]++;
    }
    int mxh = 0, mxw = 0;
    for (int i = 0; i < N; i++) {
        mxh = max(mxh, cnth[i]);
        mxw = max(mxw, cntw[i]);
    }
    vector <int> hall, wall;
    for (int i = 0; i < N; i++) {
        if (cnth[i] == mxh) {
            hall.push_back(i);
        }
        if (cntw[i] == mxw) {
            wall.push_back(i);
        }
    }
    int cnt = 0, mx = 0;
    for (int i = 0; i < hall.size(); i++) {
        for (int j = 0; j < wall.size(); j++) {
            cnt++;
            if (cnt > N * 2)
                break;
            mx = max(mx, mxh + mxw - mp[hall[i]][wall[j]]);
        }
        if (cnt > N * 2)
            break;
    }
    cout << mx;
}

Measured memory_bytes: 66572
#include <iostream>
#include <stdio.h>
#include <queue>
#include <string.h>
#include <vector>
#include <map>
#include <string>
#include <set>
#define ll long long
using namespace std;
const ll maxn = 1000050;
const ll mod = 1e12+7;
const ll p = 4903;
ll C[100050];
ll ha[maxn] = {0};
//vector<int> G[maxn];
int SG[maxn] = {0};
int fa[maxn] = {0};
map<ll,ll> T;
ll n;
int vis[maxn]={0};
void bfs(){
	int i;
	queue<int> q;
	for(i=1;i<=n;++i){
		ha[i] = 1;
		if(SG[i]==0) {
			q.push(i);vis[i] = 1;
		}
	}
	while(!q.empty()){
		int t = q.front();
		q.pop();
		if(t==1) continue;
		if(SG[t]!=0){//儿子没跟完 
			q.push(t);continue;
		}
		ha[fa[t]] = (ha[fa[t]]+ha[t]*p)%mod;
		SG[fa[t]]--;//少一个儿子 
		
		if(!vis[fa[t]]){//队列里还没有过 
			vis[fa[t]] = 1;q.push(fa[t]);
		}
	}
	for(i=1;i<=n;++i){
		if(T.find(ha[i])!=T.end()) T[ha[i]]++;
		else T[ha[i]] = 1;
	}
}
int main(){
	int i,a,b;
	cin>>n;
//	for(i=1;i<=n;++i) G[a].clear();
	for(i = 1;i < n; ++i){
		scanf("%d%d",&a,&b);
		//G[a].push_back(b);
		SG[a]++;
		fa[b] = a;
	}
	T.clear();
	bfs();
	map<ll,ll>::iterator it;
	ll ans = 0;
	for(it = T.begin();it!=T.end();++it){
	//	cout<<it->second<<endl;
		ans+=it->second*(it->second-1)/2;
	}
	printf("%lld\n",ans);
	return 0;
}


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

const int MOD = 1000000007;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define copy(from, to) copy(from.begin(), from.end(), back_inserter(to))
#define sort(a) sort(a.begin(), a.end())
#define reverse(s) reverse(s.begin(), s.end())
#define p(s) cout << (s) << endl

typedef long long ll;
using namespace std;

template<class T>
void load(vector<T> &v, int n) {
  for (int i = 0; i < n; ++i) {
    T t;
    cin >> t;
    v.push_back(t);
  }
}

template<class T>
T max(vector<T> &v) {
  return *max_element(v.begin(), v.end());
}

template<class T>
T min(vector<T> &v) {
  return *min_element(v.begin(), v.end());
}

void py(bool isUpper = false) {
  if (isUpper) {
    p("YES");
  } else {
    p("Yes");
  }
}

void pn(bool isUpper = false) {
  if (isUpper) {
    p("NO");
  } else {
    p("No");
  }
}

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

  int sum = 0;
  for (int i = 1; ; ++i) {
    sum += i;
    if (sum >= x) {
      p(i);
      return 0;
    }
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    long long A[N+1];
    for(int i=0; i<N+1; i++){
        cin >> A[i];
    }
    long long B;
    long long ans=0;
    for(int i=0; i<N; i++){
        cin >> B;
        if(B>=A[i]){
            B-=A[i];
            ans+=A[i];
        }else{
            ans+=B;
            B=0;
        }
        if(B>=A[i+1]){
            ans+=A[i+1];
            A[i+1]=0;
        }else{
            ans+=B;
            A[i+1]-=B;
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 1024
if __name__ == "__main__":

    length = int(input())
    dataset = [int(x) for x in input().split()]
    last = dataset[-1] 

    pop_list = []
    i=0
    breaks=0
    for x in dataset:
        if x == i+1:
            i += 1
        else:
            breaks +=1
    
    if breaks>0 and i==0:
        print(-1)
    else:
        print(breaks)


Measured memory_bytes: 26012
# N本のそれぞれについてA, B, Cのどれかの材料にする或いはどこにも採用しないという4通りをとるとして全探索
# そうしてできた各長さと実際のA,B,Cとの差を取ることで,インクリメント/デクリメントした際のMPはわかる寸法
# 合成したときに10使うところの計算をちゃんとやる
# (↑解説のやつは最初から足しちゃって最後にまとめて引いている)

N, A, B, C = gets.chomp.split.map(&:to_i)
@kadomatsuz = N.times.map{gets.chomp.to_i}

def rec(i, a, b, c)
  if i == N
    return [a, b, c].min > 0 ? (A-a).abs + (B-b).abs + (C-c).abs : 10**10
  end
  x = rec(i+1, a, b, c)
  y = rec(i+1, a+@kadomatsuz[i], b, c) + (a.zero? ? 0 : 10)
  z = rec(i+1, a, b+@kadomatsuz[i], c) + (b.zero? ? 0 : 10)
  w = rec(i+1, a, b, c+@kadomatsuz[i]) + (c.zero? ? 0 : 10)
  return [x, y, z, w].min
end

puts rec(0, 0, 0, 0)

Measured memory_bytes: 1788
N = int(input())
X = []
Y = []
hh = []
vec = list()
G = (-1,-1,-1)

for _ in range(N):
    x, y, h = map(int, input().split())
    X.append(x)
    Y.append(y)
    hh.append(h)
    # 高さが1以上の三組を一つ取る(この場合, hi = H - |Xi - Cx| - |Yi - Cy|が成立する)
    if h >= 1:
        G = (x, y, h)

for i in range(0,101):
    for j in range(0,101):
        # 最初にHを固定する
        H = G[2] + abs(G[0] - i) + abs(G[1] - j)
        H = max(H, 0)
        flag = True
        for k in range(N):
            key = H - abs(X[k] - i) - abs(Y[k] - j)
            key = max(key, 0)
            if key != hh[k]:
                flag = False
        # 全てのkについてHが成立するとき, append
        if flag:
            vec.append((i,j,H))

if len(vec) == 1:
    print(vec[0][0], vec[0][1], vec[0][2])

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  string n;
  cin >> n;
  if (n.at(0) == n.at(2)) {
  	cout << "Yes\n";
  }else {
  	cout << "No\n";
  }
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
    int q[6];
    for(int i=0;i<6;i++)
        scanf("%d",&q[i]);
    for(int i=0;i<4;i++){
        for(int j=i+1;j<5;j++){
            if(q[j]-q[i]>q[5]){
                printf(":(");
                return 0;
            }
        }
    }
    printf("Yay!");
}

Measured memory_bytes: 128
//#define DEB1 //input from input.txt
//#define NDEBUG
#include <iostream>
#include <algorithm>
#include <string>
#include <fstream>
#include <vector>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <thread>
#include <mutex>
#include <iomanip>
#include <cassert>

#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))
#define INF(a) memset(a, 0x3f, sizeof(a))
#define ALL(t) (t).begin(),(t).end()
#define FILL(a,c) fill(a, a+ sizeof(a)/sizeof(*a),c)
#define FILL2D(A,c) fill(A[0], A[0] +sizeof(A)/sizeof(**A),c)
#define FILL3D(A,c) fill(A[0][0], A[0][0] +sizeof(A)/sizeof(***A),c)
#define REP(i,m) for(int i=0;i<(m);++i)
// closed interval, inverse repeat
#define CIREP(i,start,fin) for(int i=(start);i>=(fin);i--)
#define CREP(i,start,fin) for(int i=(start);i<=(fin);i++)
#define RNG(i,start,fin) for(int i=(start);i<(fin);i++)
#define IN(a, x, b) (a<=x && x<b)
#define PB push_back
#define SZ(x) (int)(x).size()

using namespace std;

using LL = long long;
using PAIR = pair<int, int>;
using PAIRLL = pair<LL,LL>;
using VI = vector<int>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VVI = vector<VI>;
const LL LINF = 1001002003004005006ll;
/* 
template<typename T>inline istream& operator>>(istream&i,vector<T>&v)
{REP(j,SZ(v))i>>v[j];return i;}

template<typename T>string join(const vector<T>&v)
{stringstream s;REP(i,SZ(v))s<<' '<<v[i];return s.str().substr(1);}

template<typename T>inline ostream& operator<<(ostream&o,const vector<T>&v)
{if(SZ(v))o<<join(v);return o;}
*/

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




/*
constant values
*/

//const int dx[] = {1,0,-1,0};
//const int dy[] = {0,1,0,-1};
//const int MX = 31001;

//const ll INF= 1LL<<60 ;//INF = 1001001001001; //1e9


// Main program
void solve(){
    int N;
    cin >> N;
    string S;
    cin >> S;
    int sum = 0;
    REP(i,N-2){
        if(S[i]=='A' && S[i+1]=='B' && S[i+2]=='C'){
            ++sum;
        }
    }
    

    cout << sum << endl;
    return;
}



// ----------------------------------------------
int main(){

#ifdef DEB1
    cout << "DEBUG MODE"  << endl;
    ifstream in("input.txt"); //for debug
    cin.rdbuf(in.rdbuf()); //for debug
#endif

    int T=1; 

    for (int i = 0; i < T; ++i) {
        solve();
    }

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x1 = sc.nextInt();
        int y1 = sc.nextInt();
        int x2 = sc.nextInt();
        int y2 = sc.nextInt();
        int xdiff = x1 - x2;
        int ydiff = y1 - y2;
        int x3 = 0;
        int y3 = 0;
        int x4 = 0;
        int y4 = 0;
        if (xdiff > 0 && ydiff > 0) {
            x3 = x2 + ydiff;
            y3 = y2 - xdiff;
            x4 = x1 + ydiff;
            y4 = y1 - xdiff;
        } else if (xdiff <= 0 && ydiff > 0) {
            x3 = x2 + ydiff;
            y3 = y2 - xdiff;
            x4 = x1 + ydiff;
            y4 = y1 - xdiff;
        } else if (xdiff > 0 && ydiff <= 0) {
            x3 = x2 + ydiff;
            y3 = y2 - xdiff;
            x4 = x1 + ydiff;
            y4 = y1 - xdiff;
        } else {
            x3 = x2 + ydiff;
            y3 = y2 - xdiff;
            x4 = x1 + ydiff;
            y4 = y1 - xdiff;
        }

        System.out.print(x3);
        System.out.print(" ");
        System.out.print(y3);
        System.out.print(" ");
        System.out.print(x4);
        System.out.print(" ");
        System.out.print(y4);



    }

}

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

using namespace std;
int main() {
  int N, M, C;
  cin >> N >> M >> C;
  vector<int> A(N*M), B(M);
  for (int i = 0; i < M; i++) {
    cin >> B[i];
  }
  for (int i = 0; i < N*M; i++) {
    cin >> A[i];
  }
  int correct = 0;
  for (int i = 0; i < N; i++) {
    int result = C;
    for (int j = 0; j < M; j++) {
      result += A[i*M + j] * B[j];
    }
    if (result > 0) { correct++; }
  }
  cout << correct << endl;
}

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

using namespace std;
using i64 = int64_t;
using i32 = int32_t;


int main() {
    i64 n;
    cin >> n;
    if (n == 2) {
        cout << 1 << endl;
        return 0;
    }
    set<i64> st;
    i64 ans = 2;
    for (i64 x = 2; x * x <= n - 1; ++x) {
        if ((n - 1) % x == 0) {
            // cerr << x << endl;
            st.insert(x);
            ++ans;
            if (x * x != (n - 1)) ++ans;
        }
    } 
    for (i64 x = 2; x * x <= n; ++x) {
        i64 y = n;
        while (y % x == 0) {
            y /= x;
        }
        // if (y % x == 1) cerr << x << endl;
        ans += (y % x) == 1 && st.count(x) == 0;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
n = int(input())
lst = [0] * 10**6
for x in range(1, 101):
  for y in range(1, 101):
    for z in range(1, 101):
      t = (x**2 + y**2 + z**2 + (x+y+z)**2) // 2
      lst[t] += 1
for i in range(1, n+1):
  print(lst[i])

Measured memory_bytes: 16808
#include <stdio.h>
int main(){
 int a,b;
 scanf("%d%d", &a, &b);
 if(a < b){
  printf("a < b\n");
 }else if(a > b){
  printf("a > b\n");
 }else if(a == b){
  printf("a == b\n");
 }
 return 0;
}

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

int main(){
  int n;
  cin >> n;
  vector<int> p(n);
  rep(i, n) cin >> p[i];
  int ans = 0;
  rep(i, n-2){
    if (p[i] < p[i+1] && p[i+1] < p[i+2] ||
        p[i] > p[i+1] && p[i+1] > p[i+2])
      ans++;
  }
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 3600
using System;
using System.Linq;

class abc124_A
{
    static void Main(string[] args)
    {
        var r = Console.ReadLine().Split(' ');
        var QA = int.Parse(r[0]);
        var QB = int.Parse(r[1]);

        if(QA>QB) {
            Console.WriteLine(QA*2-1);
        } else if(QA<QB) {
            Console.WriteLine(QB*2-1);
        } else {
            Console.WriteLine(QA*2);
        }
    }
}

Measured memory_bytes: 13140
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define ll long long
#define imfor(i, n) for(int i = 0; i < n; i++)
using namespace std;
ll MOD = 1000000007;

int main() {
    int n;
    string s;
    cin >> n;
    cin >> s;
    int l[300010];
    int r[300010];
    int tmp = 0;
    for (int i = 0; i < s.size(); i++) {
        l[i] = tmp;
        if (s[i] == 'W') {
            tmp++;
        }
    }
    tmp = 0;
    for (int i = s.size(); i >= 0; i--) {
        r[i] = tmp;
        if (s[i] == 'E') {
            tmp++;
        }
    }
    int ans = 999999;
    for (int i = 0; i < s.size(); i++) {
        ans = min(ans, l[i] + r[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3076
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define puts(i) cout << i << endl
#define INF INT_MAX
#define INFL LLONG_MAX
typedef long long ll;
using namespace std;


int main(){

  string t,s;
  cin >> s >> t;


int sts=s.size()-t.size();
int ts=t.size();
  std::vector<int> v(sts,0);

if(sts==0){
  if(t==s){
    cout << 0 << endl;
  }
  else{
    int sum=0;
    for(int i=0;i<ts;i++){
      if(t.at(i)!=s.at(i)){
        sum++;
      }
    }
    cout << sum << endl;
  }
  return 0;
}

  for(int i=0;i<sts;i++){
    for(int j=0;j<ts;j++){
      if(t.at(j)!=s.at(i+j)){
        v.at(i)++;
      }
    }
  }
  sort(all(v));

  cout << v.at(0) << endl;


  }


Measured memory_bytes: 3604
n = gets.to_i
sum = 0
a = STDIN.map(&:to_i)
(n - 1).times{|i|
    if a[i] % 2 == 1 && a[i + 1] > 0
        a[i] -= 1
        a[i + 1] -= 1
        sum += 1
    end
    }
p sum + a.map{|x|x / 2}.inject(:+)

Measured memory_bytes: 3452
#include<bits/stdc++.h>
using namespace std;
int a,b,c;
int main(){
  cin>>a>>b;
  if((a==1&&b==2)||(a==2&&b==1))c=3;
  if((a==2&&b==3)||(a==3&&b==2))c=1;
  if((a==3&&b==1)||(a==1&&b==3))c=2;
  cout<<c<<endl;
  
}

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

using namespace std;

const int N = 205;

int n;
char mp[N][N];
int f[N][N];

vector<int> bl[N];
int vis[N],tot;
bool dfs(int u){
	bl[tot].push_back(u);
	for(int v=1;v<=n;v++)
		if(mp[u][v]=='1'){
			if(vis[v]) {
				if(vis[v]==vis[u]) return false;
				continue;
			}
			vis[v]=3-vis[u];
			if(!dfs(v)) return false;
		}
	return true;
}

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%s",mp[i]+1);
	
	tot=0;
	for(int i=1;i<=n;i++)
		if(!vis[i]){
			++tot; vis[i]=1;
			if(!dfs(i)) { printf("-1\n"); return 0; }
		}
	
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++) f[i][j]=(mp[i][j]=='1'?1:n*n+1);
	for(int i=1;i<=n;i++) f[i][i]=0;
	for(int k=1;k<=n;k++)
		for(int i=1;i<=n;i++)
			for(int j=1;j<=n;j++)
				if(mp[i][j]=='1') f[i][j]=min(f[i][j],f[i][k]+f[k][j]);
	
	for(int k=1;k<=n;k++)
		for(int i=1;i<=n;i++)
			for(int j=1;j<=n;j++)
				f[i][j]=min(f[i][j],f[i][k]+f[k][j]);
	
	int mx=0,ans=0;
	for(int t=1;t<=tot;t++){
		mx=0; int s=bl[t].size();
		for(int i=0;i<s;i++)
			for(int j=i+1;j<s;j++) mx=max(mx,f[bl[t][i]][bl[t][j]]);
		ans+=mx+1;
	}
	printf("%d\n",ans);
	
	return 0;
}

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

#ifndef M_PI
#define M_PI 3.14159265358979
#endif
#define deg_to_rad(deg) (((deg) / 360) * 2 * M_PI)
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)

using namespace std;

typedef long long ll;
typedef vector<long long> vll;
typedef pair<long long, long long> pll;
typedef long double ld;

const ll INF = 1e15;
const ll MOD = 1e9 + 7;

int main() {
    ll i, j, k;
    ll A, B, K;
    cin >> A >> B >> K;
    ll cnt = 0;
    for(i = min(A, B); i > 0; i--) {
        if(A % i == 0 && B % i == 0) {
            cnt++;
        }
        if(cnt == K) {
            cout << i << endl;
            return 0;
        }
    }
}


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

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

	vector<string> inside(h);
	for (int i = 0; i < h; i++)
	{
		cin >> inside.at(i);
	}

	vector<vector<char>> outside(h + 2, vector<char>(w + 2, '#'));
	for (int i = 0; i < h; i++)
	{
		for (int j = 0; j < w; j++)
		{
			outside.at(i + 1).at(j + 1) = inside.at(i)[j];
		}
	}

	for (int i = 0; i < h + 2; i++)
	{
		for (int j = 0; j < w + 2; j++)
		{
			cout << outside.at(i).at(j);
		}
		cout << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const ll INF = 1LL << 60;

int main(){
    string s;
    cin >> s;
    bool run=true;
    if(s[0] == s[1] && s[1] == s[2]){
        run = false;
    }
    if(run){
        cout << "Yes" << endl;
    }
    else cout << "No" << endl;
}

Measured memory_bytes: 3588
// -*- coding:utf-8-unix -*-

use num::Float;
use proconio::input;
use std::collections::{BTreeMap, BTreeSet, BinaryHeap};

// ABC086C - Traveling
// https://atcoder.jp/contests/abs/fasks/arc089_a

fn switch<T>(flag: bool, t: T, f: T) -> T {
    if flag {
        t
    } else {
        f
    }
}

fn main() {
    input! {
        s:String
    }

    let w: String = s
        .chars()
        .map(|x| match x {
            '?' => 'D',
            y => y,
        })
        .collect();

    println!("{}", w);
}


Measured memory_bytes: 2676
/*
    Ujjawal Pabreja [cuber_coder]
*/
#include <bits/stdc++.h> 
#include <functional> 
using namespace std;
#define speed_cubing    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll              long long
#define ld              long double
#define rep(i,a)        for(ll i = 0 ; i < a ; i++)
#define repe(i,a,b)     for(ll i = a ; i < b ; i++)
#define bac(i,a)        for(ll i = a ; i >= 0 ; i--)
#define bace(i,a,b)     for(ll i = a ; i >= b ; i--)
#define pb              push_back
#define in              insert
#define ff              first
#define ss              second
#define setbit(x)       __builtin_popcountll(x)
#define init(c,a)       memset(c,a,sizeof(c))
#define all(c)          c.begin(),c.end()
#define sz(c)           (ll)c.size()
#define lb              lower_bound
#define ub              upper_bound
#define maxe            *max_element
#define mine            *min_element
#define rev             reverse
#define Y				"YES"
#define N 				"NO"
#define endl            "\n"
#define debug(x)        cout << #x << " : " << x << endl;
const ll inf = 1e18;  
const ll mod = 1e9 + 7;
const ll MOD = 998244353;
const ll MAX = 2e5 + 1;

inline ll add(ll a,ll b) {return ((a % mod) + (b % mod)) % mod;}
inline ll sub(ll a,ll b) {return ((a % mod) - (b % mod) + mod) % mod;}
inline ll mul(ll a,ll b) {return ((a % mod) * (b % mod)) % mod;}
ll pwr(ll x,ll n){
    if(n == 0){
        return 1;
    }
    if(n&1){
        return mul(x, pwr(mul(x, x), (n - 1) / 2));
    } else {
        return pwr(mul(x, x), n / 2);
    }
}
ll modInv(ll n){ 
    return pwr(n, mod - 2); 
}
ll gcd(ll a,ll b) {
    if(b == 0) {
        return a;
    }
    return gcd(b, a % b);
}
// ====== Useful functions end ======
 
// ====== Global Variables begin ======

// ====== Global Variables end ======
bool possible(ll a[], ll n, ll k, ll mx){
    ll cuts = 0;
    rep(i,n){
        if(a[i] <= mx){
            continue;
        }
        cuts += (a[i] / mx - (a[i] % mx == 0));
    }
    return cuts <= k;
}
void speed_solve(){
    ll n, k;
    cin >> n >> k;
    ll a[n];
    rep(i,n){
        cin >> a[i];
    }
    ll lo = 1, hi = maxe(a,a + n);
    ll ans;
    while(lo <= hi){
        ll mid = lo + (hi - lo) / 2;
        if(possible(a, n, k, mid)){
            hi = mid - 1;
            ans = mid;
        } else {
            lo = mid + 1;
        }
    }
    cout << ans;
}

int main(){
    // #ifndef ONLINE_JUDGE
    //     freopen("input.txt", "r", stdin);
    //     freopen("output.txt", "w", stdout);
    // #endif
    speed_cubing;
    ll test_cases = 1;
    // cin >> test_cases;
    rep(i,test_cases){
        // cout << "Case #" << i + 1 << ": ";
        speed_solve();
    }
    return 0;
}

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

int main(){
    int i,len;
    char a[10];
    
    scanf("%s",a);
    
  //  len = strlen(a);
    
    
        if(a[2]==a[3] && a[4]==a[5]){
            printf("Yes\n");
        }
        else{
            printf("No\n");
        }
    
    
    return 0;
}

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

#define ll long long
#define ar array

int main() {
	int n, m, a[10000];
	cin >> n >> m;
	int sum=0;
	for(int i=0;i<m;i++) {
		cin >> a[i];
		sum+=a[i];
	}
	if(sum<=n) {
		cout << n-sum;
	}else {
		cout << -1;
	}

}


Measured memory_bytes: 3644
#include<stdio.h>
 
int main(void){
 
	int w,h,x,y,r,f;
 
	scanf("%d %d %d %d %d",&w,&h,&x,&y,&r);
 
	f=0;
	if(x+r>w)f=1;
	if(y+r>h)f=1;
	if(r>x)f=1;
	if(r>y)f=1;
 
	if(f == 0){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
 
return 0;
}

Measured memory_bytes: 584
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n;
	cin>>n;
	vector<double>vi;
	for(int i = 0; i< n; i++){
		double x;cin>>x;
		vi.push_back(x);
	}
	sort(vi.begin() , vi.end());
	for(int i = 1 ; i< n; i++){
		vi[0] = (vi[0] + vi[i])/2;
	}
	cout<<vi[0];
	return 0;
}


Measured memory_bytes: 256