akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#define MAXN 100000
using namespace std;
int N,a[2*MAXN+5];
bool seq[2*MAXN+5];
int Check(int x)
{

    for(int i=1;i<=2*N-1;i++)
        if(a[i]<=x)
            seq[i]=0;
        else
            seq[i]=1;
 //   for(int i=1 ;i<=2*N-1;i++)
   // cout<<seq[i]<<"  ";
 //   cout<<endl;
    if(seq[N]==seq[N-1]||seq[N]==seq[N+1])
    
        return seq[N];//?????????????
    int l=-1,r=-1;
    int ld,rd;
    for(int i=2;i<=N;i++)
        if(seq[i]==seq[i-1])
            l=seq[i],ld=N-i+1;//?????????????
    for(int i=N;i<2*N-1;i++)
        if(seq[i]==seq[i+1])
        {
            r=seq[i];//?????????????
            rd=i-N+1;
            break;
        }
    
    if((l==0&&r==-1)||(l==-1&&r==0)||(l==0&&r==0))//??2?3
        return 0;
    if((l==1&&r==0&&ld>rd)||(l==0&&r==1&&ld<rd))//??4
        return 0;
    if(l==-1&&r==-1&&seq[1]==0)//??5
        return 0;
    return 1;
}
int main()
{
    scanf("%d",&N);
    for(int i=1;i<=2*N-1;i++)
        scanf("%d",&a[i]);
    int L=0,R=2*N;

    while(L<R)
    {
 //       cout<<endl<<endl<<L<<"   LLL  RRR   "<<R<<endl<<endl;        
	    int mid=(L+R)/2;
//	    cout<<L<<"   two   "<<R<<" mid  "<<mid<<endl<<endl<<endl; 
        if(Check(mid)==0)//O(n)??
         {
         	R=mid;
 //           cout<<"r   "<<R<<endl;	
		 }   
        else
            {
                L=mid+1;
	//			cout<<"   L"<<L<<endl;	
			}
    }
    printf("%d\n",R);
    return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rrep(i,n) for (int i = (int)(n)-1; i>=0; --i)
#define For(i,a,b) for(auto i=(a);i<=(b);++i)
#define rFor(i,a,b) for(auto i=(b);i>=(a);--i)
#define call(var) cerr<<#var<<"="<<var<<"\n";
#define dup(x,y) (((x)+(y)-1)/(y))
#define all(x) (x).begin(),(x).end()
using ll=long long;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;
const double pi = acos(-1);
template<class t,class u> inline bool chmax(t&a,u b){if(a<b){a=b;return true;}return false;}
template<class t,class u> inline bool chmin(t&a,u b){if(b<a){a=b;return true;}return false;}
template<class T> istream& operator>>(istream& is, vector<T>& a){rep(i,a.size()) is >> a[i]; return is;}
template<class T> ostream& operator<<(ostream& os, vector<T>& a){rep(i,a.size()) os << a[i] << " "; return os;}
template<class T, class U> istream& operator>>(istream& is, pair<T,U>& p){is >> p.first >> p.second; return is;}
template<class T, class U> ostream& operator<<(ostream& os, const pair<T,U>& p){os << "("<< p.first << "," << p.second << ")"; return os;}
template<class T, class U> ostream& operator<<(ostream& os, const map<T,U>& mp){for(auto& t : mp) os << t.first << " " << t.second << "\n"; return os;}

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

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

    map<ll,ll> mp;
    rep(i,n){
        mp[a[i]]++;
    }

    int Q;cin >> Q;
    while(Q--){
        ll b,c;cin >> b >> c;
        sum += (ll)(c-b) * mp[b];
        //cerr << "ans is ";
        cout << sum << "\n";
        mp[c] += mp[b];
        mp[b] = 0;
        //cout << mp << "\n";
    }
}

Measured memory_bytes: 9936
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int o = 0;
    string a, b;
    cin >> a;
    cin >> b;
    
    for(int i = 0;i < a.size();i++){
    if(a[i] != b[i]){ 
        o += 1;
    }
    }
    cout << o << endl;
}

Measured memory_bytes: 3824
#include<iostream>
#include<string>
#include<algorithm>
#include<functional>
#include<vector>
#include<set>
#include<queue>
#include<list>
#include<stdio.h>
#include<stdlib.h>
#include<map>
#include<cstdio>
#include <iomanip>

#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

typedef long long ll;

using namespace std;

int main() {
	string s;

	cin >> s;

	if (s.length() == 2 ) {

		if (s[0] == s[1]) {
			cout << "1 2" << endl;
		}
		else {
			cout << "-1 -1" << endl;
		}
		
		return 0;
	}

	if (s.length() == 3) {
		if (s[0] == s[1]) {
			cout << "1 2" << endl;
			return 0;
		}

		if (s[1] == s[2]) {
			cout << "2 3" << endl;
			return 0;
		}

		if (s[0] == s[2]) {
			cout << "1 3" << endl;
			return 0;
		}

		cout << "-1 -1" << endl;
		return 0;
	}

	for (int i = 0; i < s.length()-2; i++) {
		if (s[i] == s[i + 1]) {
			cout << i+1 << " " << i + 2 << endl;
			return 0;
		}

		if (s[i] == s[i + 2]) {
			cout << i+1 << " " << i + 3 << endl;
			return 0;
		}

	}

	cout << "-1 -1" << endl;

	return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long int ll;
using namespace std;
int main()
{
	IOS;
	ll n,x,t;
	cin>>n>>x>>t;
	if(n<x) cout<<t<<endl;
	else if(n%x==0) cout<<n*t/x<<endl;
	else{
		cout<<(n/x)*t+t<<endl;
	}
	
}


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

using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr int inf = 1<<30;
constexpr int mod = 1e9+7;
constexpr ll infl = 1ll<<60;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    ll n,k;
    cin>>n>>k;
    vector<pair<int,int>> v(n);
    for(int i=0;i<n;++i){
        int a,b;
        cin>>a>>b;
        v[i] = {a,b};
    }
    sort(v.begin(),v.end());
    ll count =0ll;
    for(int i=0;i<n;++i){
        count += v[i].second;
        if(count >= k){
            cout << v[i].first << endl;
            break;
        }
        
    }
    return 0;
}

Measured memory_bytes: 3960
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  int p;
  p = 700;
  cin >> s;
  for(int i=0;i<3;i++){
    if(s.at(i) == 'o'){
      p += 100;
    }
  }
  cout << p << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
  int n[2];
  cin >> n[0] >> n[1] >> n[2];
  sort(n, n + 3);
  cout << n[0] << ' ' << n[1] << ' ' << n[2] << endl;
  return 0;
}

Measured memory_bytes: 3156
# -*- coding: utf-8 -*-
# case.rb

loop{ # 無限ループをするメソッド
  
  a, op, b = STDIN.gets.split(' ')
  a = a.to_i
  b = b.to_i  
 
 case op
  when "+"  
    puts a+b
  when "-"
    puts a-b
  when "*"
    puts a*b
  when "/"
    puts a/b
  else 
    break
  end
}

Measured memory_bytes: 8676
///=======================///
/// coder: Andy - Tohrumi ///
///=======================///

#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define fastio ios_base::sync_with_stdio(); cin.tie(0); cout.tie(0);
#define pb push_back
#define mp make_pair
#define all(x) x.begin(), x.end()
#define rep(i, a, b) for(__typeof(b) i = a; i < b; i++)
#define Rep(i, a, b) for(__typeof(a) i = a; i > b; i--)

using namespace std;

typedef pair<ll, ll> pll;	typedef pair<int, int> ii;
typedef vector<pll> vll;	typedef vector<string> vs;		typedef vector<ii> vii;
typedef vector<int> vi; 	typedef vector<ll> vl;

///======code start here======///

signed main() {
	fastio;
	int N, W; cin >> N >> W;
	int w[N], v[N];
	rep(i, 0, N) {
		cin >> w[i] >> v[i];
	}
	ll dp[N + 1][W + 1];
	rep(i, 0, N + 1) {
		rep(j, 0, W + 1) {
			dp[i][j] = 0;
		}
	}
	rep(i, 1, N + 1) {
		rep(j, 1, W + 1) {
			if(j >= w[i - 1]) dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - w[i - 1]] + v[i - 1]);
			else dp[i][j] = dp[i - 1][j];
		}
	}
	cout << dp[N][W] << endl;
	return 0;
}



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

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

    if (s == "SUN")
        cout << 7;
    else if (s == "MON")
        cout << 6;
    else if (s == "TUE")
        cout << 5;
    else if (s == "WED")
        cout << 4;
    else if (s == "THU")
        cout << 3;
    else if (s == "FRI")
        cout << 2;
    else
        cout << 1;
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
import math
n = int(input())
p_ls = list(map(int, input().split()))
q_ls = list(map(int, input().split()))

def dict_num(ls):
    m = len(ls)
    ans = 0
    already = []
    for i in range(m):
        top = ls[i]
        for j in range(1,top):
            if j not in already:
                ans += math.factorial(m-i-1)
        already.append(top)
    return ans+1
print(abs(dict_num(q_ls)-dict_num(p_ls)))

Measured memory_bytes: 9056
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int[] xA = new int[n];
        int[] yA = new int[n];
        int[] hA = new int[n];

        for (int i = 0; i < n; i++) {
            xA[i] = sc.nextInt();
            yA[i] = sc.nextInt();
            hA[i] = sc.nextInt();
        }

        for (int x = 0; x <= 100; x++) {
            for (int y = 0; y <= 100; y++) {
                int h = -1;
                for (int i = 0; i < n; i++) {
                    if (hA[i] == 0) continue;
                    int tmp = hA[i] + Math.abs(xA[i] - x) + Math.abs(yA[i] - y);
                    if (h == -1) {
                        h = tmp;
                    } else if (h != tmp) {
                        h = -1;
                        break;
                    }
                }

                for (int i = 0; i < n; i++) {
                    if (hA[i] != 0) continue;
                    int dist = Math.abs(xA[i] - x) + Math.abs(yA[i] - y);
                    if (h > dist) {
                        h = -1;
                        break;
                    }
                }

                if (h > 0) {
                    System.out.println(x + " " + y + " " + h);
                    System.exit(0);
                }
            }
        }
    }
}

Measured memory_bytes: 24020
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = (a); i <= (b); i++)
#define per(i, a, b) for(int i = (a); i >= (b); i--)
using namespace std;
int n, m, a, b;

int main() {
	cin >> n >> m >> a >> b;
	rep(i, 1, n) {
		rep(j, 1, m) {
			if(i <= b && j <= a) printf("1");
			else if(i > b && j > a) printf("1");
			else printf("0");
		}
		puts("");
	}
	return 0;
}

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

int main(){
    int a, b;
    cin >> a >> b;
    int ans = max(2*a-1,max(2*b-1,a+b));
    cout << ans << endl;
}

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

ll solve(ll val[], ll w[], ll capacity, ll n, vector<vector<ll>>& dp){
	if(capacity==0 || n==0)
		return 0;
	
	if(dp[n][capacity]!=-1)
		return dp[n][capacity];
		
	ll ans=0;
	if(capacity >= w[n-1]) {
		ans = max ( solve(val, w, capacity, n-1, dp), val[n-1] + solve(val, w, capacity-w[n-1], n-1, dp) );
	} else {
		ans = solve(val, w, capacity, n-1, dp);
	}
	return dp[n][capacity] = ans;
}

void bottomup(){
	ll n, capacity;
	cin >> n >> capacity;
	ll val[n];
	ll w[n];
	
	ll vmax=0;
	
	for(ll i=0; i<n; i++) {
		cin >> w[i];
		cin >> val[i];
		vmax += val[i];
	}
	
	vector<vector<ll>> dp(n+1, vector<ll>(vmax+1, 1e9+5));

	for(ll i=0;i<=n;i++)
		dp[i][0]=0;
		
	for(ll i=1; i<=n; i++) {
		for(ll j=1; j<=vmax; j++) {
			if(val[i-1] > j) {
				dp[i][j]=dp[i-1][j];
			} else {
				dp[i][j]=min(dp[i-1][j], w[i-1]+dp[i-1][j-val[i-1]]);
			}
		}
	}
	
	ll res=0;
	
	for(ll i=0; i<=vmax; i++) {
		if(dp[n][i] <= capacity)
			res=i;
	}
	
	cout << res << "\n";

}

void solve(){
	ll n, capacity;
	cin >> n >> capacity;
	ll val[n];
	ll w[n];
	
	vector<vector<ll>> dp(n+1, vector<ll>(capacity+1, -1));
	
	for(ll i=0; i<n; i++) {
		cin >> w[i];
		cin >> val[i];
	}
	
	cout << solve(val, w, capacity, n, dp) << "\n";
}

int main(){
	bottomup();
}


Measured memory_bytes: 80256
#include <bits/stdc++.h>
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end() 
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 1000000000
using namespace std;
typedef long long ll;

int main() {
    ll N, K;
    cin >> N >> K;

    vector<ll> ans;
    ll i = 0, res = N%K, pos = N/K;
    while (pos != 0){
        ans.push_back(res);
        res = pos%K;
        pos = pos/K;
    }
    ans.push_back(res);

    cout << SIZE(ans) << endl;
}

Measured memory_bytes: 3604
import sys,bisect

sys.setrecursionlimit(10000000)
N = int(input())
C = [int(input()) for _ in range(N)] #color
v = 10**9+7
from collections import defaultdict
d = defaultdict(list)
for i,c in enumerate(C):
    d[c].append(i)


def guchoku(l):
    assert isinstance(l,list)
    if len(l) <=2:
        return 1
    top_coor = l[0]
    if top_coor in l[1:] and l[0] != l[1]:
        _index= l[1:].index(top_coor)
        return guchoku(l[_index+1:])+ guchoku(l[1:])
    return guchoku(l[1:])

cache = dict()
cache[N] = 1
cache[N-1] = 1
cache[N-2] = 1

def check(i):
    index = bisect.bisect_left(d[C[i]],i+1)

    if index==len(d[C[i]]):
        return -1
    # print(i, d[C[i]] ,d[C[i]][index])
    return d[C[i]][index]

def guchoku_i(i):
    # print("hoge",i,d[C[i]])
    if i<0:
        raise
    if i in cache:
        return cache[i]
    c = check(i)
    if C[i] != C[i+1] and c !=-1 :
        cache[i]= guchoku_i(i+1) + guchoku_i(c) %v
        return cache[i]
    cache[i]=  guchoku_i(i+1) %v
    return cache[i]

# print(guchoku(C))
print(guchoku_i(0)%v )

Measured memory_bytes: 248468
#include<iostream>
#include<stdio.h>
#include<string>
#include<algorithm>
#include<math.h>
#include<vector>
using namespace std;
#define INF 999999999
#define lint long long
#define rep(i, n) for(int i = 1; i <= (int)(n); i++)
#define rep0(i, n) for(int i = 0; i < (int)(n); i++)
int gcd(int a,int b){return b?gcd(b,a%b):a;}


int main(){
    int dp[100001], h[100001], N;
    cin >> N;
    rep(i, N){
        cin >> h[i];
        if(i==1){ dp[i] = 0; continue;}
        if(i==2){ dp[i] = abs(h[1]-h[2]); continue; }
        dp[i] = min(dp[i-1]+abs(h[i-1]-h[i]), dp[i-2]+abs(h[i-2]-h[i]));
    }
    cout << dp[N];
    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>

int main(void){


int ai,n,i,min,max;


long sum;


scanf("%d",&n);


for(i=0;i<n;i++){


scanf("%d",&ai);


if(i==0){


min=ai;


max=ai;


sum=ai;


}


else{


sum=sum+ai;


if(min>ai){


min=ai;


}


if(max<ai){


max=ai;


}


}


}


printf("%d %d %ld\n",min,max,sum);


return 0;


}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ll long long
#define hii cout << "hii" << endl
#define int long long
#define endl '\n'
#define all(s) s.begin(), s.end()
 
template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.first << ' ' << v.second; return os; }
template <class T, class S> ostream& operator << (ostream &os, const unordered_map<T, S> &v) { for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' '; return os; }
 
 
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <class Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << endl; }
    template <class Arg1, class... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args) {
        const char* sep = strchr(names + 1, ',');
        cerr.write(names, sep - names) << " : " << arg1 << "  ";
        __f(sep + 1, args...);
    }
#else
#define trace(...) 0
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#endif // ifndef ONLINE_JUDGE

const int N = 5e5 + 5;
const int MAX = 250000 + 5;
const int M = 5e6 + 5;
const int mod = 998244353;
const int MOD = 998244353;
const int INF = 1e15;
const int LG = 21;

vector<int> v[N];
int DP[N];

void solve()
{
	int n;
	cin >> n;
	string input;
	cin >> input;
	int s = 0;
	int e = n - 1;
	int ret = 0;
	while(s < e)
	{
		if(input[s] == 'W' and input[e] == 'R')
		{
			s++;
			e--;
			ret++;
		}
		else if(input[s] == 'R') s++;
		else if(input[e] == 'W') e--;
	}
	cout << ret << endl;
}
 
int32_t main() 
{	
	ios_base:: sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	    int t = 1;
	    // cin >> t;
	while(t--)solve();
	return 0;
}

Measured memory_bytes: 15456
#include<bits/stdc++.h>
#define f(i,a,b) for(register int i=(a),i##end=(b);i<=i##end;i=-(~i))
namespace IO
{
	const unsigned int bufsize=1<<15,outsize=1<<24;
	static char ch[bufsize],*S=ch,*T=ch;
	inline char getc()
	{return ((S==T)&&(T=(S=ch)+fread(ch,1,bufsize,stdin),S==T)?0:*S++);}
	static char Out[outsize],*nowp=Out;
	inline void flush(){fwrite(Out,1,nowp-Out,stdout);nowp=Out;}
	template<typename T>
		inline void read(T &x)
		{
			char c=getc();x=0;
			for(;!isdigit(c);c=getc());
			for(;isdigit(c);x=(x<<1)+(x<<3)+(c^'0'),c=getc());
		}
	template<typename T>
		inline void write(T x,char c='\n')
		{
			if(!x)*nowp++='0';
			static unsigned int stk[50],tp=0;
			for(;x;x/=10)stk[++tp]=x%10;
			for(;tp;*nowp++=stk[tp--]^'0');*nowp++=c;
		}
	void readstr(char *str)
	{
		char c=getc();
		for(;!isalpha(c);c=getc());
		int len=0;
		for(;isalpha(c);c=getc())str[++len]=c;
	}
	void writstr(char *str)
	{
		int len=strlen(str)-1;
		f(i,0,len)*nowp++=str[i];*nowp++='\n';
	}
}
const int leko=100,neko=200010;
typedef long long ll;
ll l,r,ans[30],len[leko],cnt[leko][30];
namespace String
{
	char s[neko];
	int fail[neko],n;
	void get_alpha(int x,ll *p)
	{f(i,1,x)++p[s[i]-'a'];}
	void get_border()
	{
		fail[0]=-1;
		for(register int i=1,j=-1;i<=n;fail[i++]=++j)
			for(;j>=0&&s[j+1]^s[i];j=fail[j]);
		len[0]=n-fail[n],len[1]=n;
		get_alpha(len[0],cnt[0]),get_alpha(len[1],cnt[1]);
	}
	void get_ans(ll x)
	{
		if(x<=n)return get_alpha(x,ans);
		int i;
		for(i=0;len[i+1]<=x;++i);
		f(j,0,25)ans[j]+=cnt[i][j];
		get_ans(x-len[i]);
	}
	void get_string(ll x)
	{
		get_border();
		for(register int i=2;len[i-1]<=x;++i)
		{
			len[i]=len[i-1]+len[i-2];	
			f(j,0,25)cnt[i][j]=cnt[i-1][j]+cnt[i-2][j];
		}
	}

}
int main()
{
	using namespace IO;
	using namespace String;
	readstr(s),n=strlen(s+1)>>1;
	read(l),read(r);
	get_string(r),get_ans(l-1);
	f(i,0,25)ans[i]=-ans[i];
	get_ans(r);
	f(i,0,25)write(ans[i],i^iend?' ':'\n');
	return flush(),0;
}

Measured memory_bytes: 896
let split_on_char sep s =
  let open String in
  let r = ref [] in
  let j = ref (length s) in
  for i = length s - 1 downto 0 do
    if get s i = sep then begin
      r := sub s (i + 1) (!j - i - 1) :: !r;
      j := i
    end
  done;
  sub s 0 !j :: !r

let () =
  let n = read_int () in
  let (tbl : (string, unit) Hashtbl.t) = Hashtbl.create n in
  for _ = 0 to n - 1 do
    match split_on_char ' ' (read_line ()) with
    | ["insert"; s] -> Hashtbl.add tbl s ()
    | ["find"; s] -> print_endline (if Hashtbl.mem tbl s then "yes" else "no")
    | _ -> ()
  done

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

int main() {
	int n;
	cin >> n;
	string s;
	cin >> s;
	bool b = false;
	if (n % 2 == 0) {
		bool bOk = true;
		for (int i = 0; i < n / 2; ++i) {
			if (s[i] != s[i + n / 2]) {
				bOk = false;
			}
		}
		if (bOk == true) {
			b = true;
		}
	}
	cout << (b ? "Yes" : "No") << '\n';
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define sar(a,n) cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl
#define svec(v) cout<<#v<<":";rep(pachico,v.size())cout<<" "<<v[pachico];cout<<endl
#define svecp(v) cout<<#v<<":";each(pachico,v)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl
#define sset(s) cout<<#s<<":";each(pachico,s)cout<<" "<<pachico;cout<<endl
#define smap(m) cout<<#m<<":";each(pachico,m)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 100005;
const int N = 15;

struct edge
{
    int to, cost;
};

vector<edge> G[MAX_N];
int dp[1 << N];
int ans;

inline int trans(int val)
{
    return (val == 0)?(0):(1 << (val-1));
}

int dfs(int u, int p)
{
    vi vec;
    int res = 0;
    each(e,G[u]){
        if(e.to != p){
            int num = dfs(e.to,u);
            int val = 0;
            rep(i,N){
                if((num >> i) & 1){
                    val ^= i+1;
                }
            }
            if(num & trans(e.cost^val)){
                ans++;
            }
            vec.pb(num^trans(e.cost^val));
        }
    }
    rep(i,N){
        int cnt = 0;
        rep(j,len(vec)){
            if((vec[j] >> i) & 1){
                cnt++;
            }
        }
        ans += cnt/2;
        res += ((cnt%2) << i);
    }
    return res;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    rep(i,n-1){
        int x,y,a;
        cin >> x >> y >> a;
        G[x].pb((edge){y,a}), G[y].pb((edge){x,a});
    }
    srep(i,1,(1 << N)){
        int val = 0;
        rep(j,N){
            if((i >> j) & 1){
                val ^= (j+1);
            }
        }
        if(val){
            dp[i] = __builtin_popcount(i);
        }else{
            dp[i] = __builtin_popcount(i)-1;
        }
        for(int j=i;j>0;j=(j-1)&i){
            cmn(dp[i],dp[j]+dp[i^j]);
        }
    }
    int res = dfs(0, -1);
    cout << ans + dp[res] << "\n";
    return 0;
}


Measured memory_bytes: 14848
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;

int N, M;
vector<vector<int>> adj;
vector<int> visit;

void Solve(int p) {
  visit[p] = 1;
  for (int q : adj[p]) {
    if (visit[q] > 0) continue;
    Solve(q);
  }
}

int main() {
  while (cin >> N >> M) {
    adj.clear();
    adj.resize(N);
    visit.clear();
    visit.resize(N);
    for (int i = 0; i < M; ++i) {
      int u, v, w;
      cin >> u >> v >> w;
      --u; --v;
      adj[u].push_back(v);
      adj[v].push_back(u);
    }
    int cnt = 0;
    for (int i = 0; i < N; ++i) {
      if (visit[i] > 0) continue;
      Solve(i);
      ++cnt;
    }
    cout << cnt << endl;
  }
}


Measured memory_bytes: 9216
#include <bits/stdc++.h>
using namespace std;
vector<vector<int>> g;
vector<int> dt, da;

void dfs(int x, int par, vector<int> &dist) {
  dist[x] = dist[par] + !(x == par);
  for (auto to : g[x]) {
    if (to == par)  continue;
    dfs(to, x, dist);
  }
}

int main() {

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

  int n, t, a;
  cin >> n >> t >> a;

  g.resize(n + 5);
  dt.assign(n + 5, 0);
  da.assign(n + 5, 0);

  for (int i = 1; i < n; ++i) {
    int u, v;
    cin >> u >> v;

    g[u].push_back(v);
    g[v].push_back(u);
  }

  dfs(t, t, dt);
  dfs(a, a, da);

  int ans = 0;
  for (int i = 1; i <= n; ++i) {
    if (dt[i] < da[i])
      ans = max(ans, da[i] - 1); 
  }

  cout << ans << '\n';
}

Measured memory_bytes: 10368
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
def sieve(n):
    p = [True for i in range(n + 1)]
    p[0] = p[1] = False
    end = int(n ** .5)
    for i in range(2, end + 1):
        if p[i]:
            for j in range(i * i, n + 1, i):
                p[j] = False
 
    return p
 
def primes_below(n):
    if n < 2: return 0
    c = 1
    for i in range(3, n + 1, 2):
        if p[i]: c += 1
 
    return c
 
p = sieve(1000000)
while 1:
    try:
        n = int(input())
    except EOFError:
        break
    else:
        print(primes_below(n))

Measured memory_bytes: 14584
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

template <class T = int>T in(){
    T x;
    cin >> x;
    return (x);
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    char b = in<char>();
    if(b == 'A')cout << 'T' << "\n";
    if(b == 'G')cout << 'C' << "\n";
    if(b == 'C')cout << 'G' << "\n";
    if(b == 'T')cout << 'A' << "\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll mod=1000000007;
const int MAX_N = 1000;         // n の最大値
 
// nCk を取得
double nCk(int n, int k) {
double res=1.0;
for(int i=0; i<n; i++){
res*=0.5;}
for(int i=0; i<k; i++){
res*=(double)(n-i);
res/=(double)(k-i);
}
return res;}
 
int main() {
ll n;
cin>>n;
ll ca=0;
ll d[n]={};
ll f=0;
cin>>ca;
if(ca!=0){
cout << 0 << endl;}
else{
d[0]++;
for(ll i=1; i<n; i++){
cin>>ca;
d[ca]++;}
ca=1;
ll q=0;
if(d[0]!=1) cout << 0 << endl;
else{
for(ll i=0; i<=n-1; i++){
if(d[i]>0){
q=i;}}
for(ll i=1; i<=q; i++){

for(ll k=0; k<d[i]; k++){
ca=ca*d[i-1];
ca%=998244353;}
}
cout << ca << endl;}}}



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

int main()
{
	int N, M;
	cin >> N >> M;
	priority_queue<int> p;
	
	int A;
	for (int i = 0; i < N; ++i)
	{
		cin >> A;
		p.push(A);
	}
	
	for (int i = 0; i < M; ++i)
	{
		int top = p.top();
		p.pop();
		p.push(top / 2);
	}
	
	long long ans = 0;
	for (int i = 0; i < N; ++i)
	{
		ans += p.top();
		p.pop();
	}
	
	cout << ans << '\n';
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long int A,B,C;cin>>A>>B>>C;
  if(A%2*B%2*C%2==0)cout<<"0"<<endl;
  else if(max({A,B,C})==A)cout<<B*C<<endl;
  else if(max({A,B,C})==B)cout<<A*C<<endl;
  else cout<<A*B<<endl;
}

Measured memory_bytes: 256
use proconio::{fastout, input};
use proconio::marker::Chars;

#[fastout]
fn main() {
    input! {
        s: String,
    }

    let mut count = 0;
    let mut was_sunny = false;
    let mut was_rainy = false;

    if s.contains("RRR") { println!("{}", 3); return; }
    if s.contains("RR") { println!("{}", 2); return; }
    if s.contains("R") { println!("{}", 1); return;}    

    println!("{}", 0);

   /*  for w in s {
        if !was_sunny && w == 'R' {
            count += 1;
        } else {
            if count == 0 || count == 1 {
                was_sunny = true;
            }
        }
    } */
}


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

typedef long long ll;
int H,W;
int sh,sw;
int N;
string S, T;
int main(){
    cin >> H >> W >> N >> sh >> sw >> S >> T;
    int l1=0,r1=0,u1=0,d1=0,l2=0,r2=0,u2=0,d2=0;
    for (int i = 0; i < N; ++i) {
        {
            char c = S[i];
            if(c == 'L')l1 ++;
            else if(c == 'R')r1 ++;
            else if(c == 'U')u1 ++;
            else d1++;
            c = T[i];
            if(l1 - r2 >= sw || r1 - l2 >= W - sw + 1 || u1 - d2 >= sh || d1 - u2 >= H - sh +1){
                cout << "NO\n";return 0;
            }
            if(c == 'L')l2 ++;
            else if(c == 'R')r2 ++;
            else if(c == 'U')u2 ++;
            else d2++;
            l2 = min(l2, sw -  1 + r1);
            r2 = min(r2, W - sw + l1);
            u2 = min(u2, sh -1 + d1);
            d2 = min(d2, H - sh + u1);

        }
    }
    cout << "YES\n";
}

Measured memory_bytes: 776
n, m, q = map(int,input().split())
query = []
for i in range(q):
    query.append(list(map(int, input().split())))

#print(query)

import itertools
cnbr = []  #組み合わせ
for i in range(m+1):
    for j in itertools.combinations_with_replacement(range(m), n):
        cnbr.append(j)

#print(cnbr)
points = [0] * len(cnbr)

for _ in range(len(cnbr)):
    for a,b,c,d in query:
        if cnbr[_][b - 1] - cnbr[_][a - 1] == c:
            points[_] += d

print(max(points))

Measured memory_bytes: 234276
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define mt make_tuple
#define show(x) cout<<x<<'\n'
#define showh(x) cout<<x<<' '
#define go(i,a,n) for(ll i=a;i<n;i++)
#define gor(i,a,n) for(ll i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define mod 1000000007
bool prime[100001];
bool ispoweroftwo(ll x)
{
    return x && !(x & (x-1));
}
ll xorcal(ll n)
{
    if(n%4==0)
        return n;
    if(n%4==1)
        return 1;
    if(n%4==2)
        return n+1;
    if(n%4==3)
        return 0;
}
void sieve(ll n)
{
    memset(prime,true,sizeof(prime));
    prime[0]=false;
    prime[1]=false;
    for(ll i=2;i*i<=n;i++)
    {
        if(prime[i]==true)
        {
            for(ll j=i*i;j<=n;j+=i)
            {
                prime[j]=false;
            }
        }
    }
    show(prime[89]);
}
bool isprime(ll n)
{
    if (n<=1) return false;
    if (n<=3) return true;

    if(n%2==0 or n%3==0) return false;

    for(ll i=5;i*i<=n;i+=6)
    {
        if(n%i==0 or n%(i+2)==0) return false;
    }
    return true;
}

ll modinverse(ll a,ll m)
{
    ll m0 = m;
    ll y = 0, x = 1;

    if (m == 1)
      return 0;

    while (a > 1)
    {
        ll q = a / m;
        ll t = m;

        m = a % m; a = t;
        t = y;

        y = x - q * y;
        x = t;
    }

    if (x < 0)
       x += m0;

    return x;
}

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

ll power(ll A, ll B)
{
    if (A == 0)
        return 0;
    if (B == 0)
        return 1;

    ll y;
    if (B % 2 == 0) {
        y = power(A, B / 2);
        y = (y * y) % mod;
    }

    else {
        y = A % mod;
        y = (y * power(A, B - 1) % mod) % mod;
    }

    return (ll)((y + mod) % mod);
}

int main()
{
    ios_base::sync_with_stdio(false);
    ll n;
    cin>>n;
    ll a[n];
    go(i,0,n)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    show(a[(n/2)]-a[(n/2)-1]);
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;

long long a, b, c;

int main() {
    scanf("%lld %lld.%lld", &a, &b, &c);
    b = b * 100 + c;
    c = a * b / 100;
    printf("%lld\n", c);
    return 0;
}

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

#define INF 1e9
using namespace std;

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

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

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

typedef long long ll;


int main() {
    char c;
    cin >> c;
    char at[] = {'A', 'T'};
    char cg[] = {'C','G'};
    // in at?
    REP(i,2) {
        if (c==at[i]) {
            bool ib = i != 0;
            cout << at[!ib] << endl;
        }
    }
    // in cg
    REP(i,2) {
        if (c==cg[i]) {
            bool ib = i != 0;
            cout << cg[!ib] << endl;
        }
    }

    return 0;
}


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

using namespace std;
const int MAXN=1e5+1e4;
int n,dist[2][MAXN],d[MAXN],vis[MAXN];
vector<int> G[MAXN];
void bfs(int beg)
{
    queue<int> q;
    memset(vis,0,sizeof(vis));
    while(!q.empty()) q.pop();
    q.push(beg);
    vis[beg]=1;
    d[beg]=0;
    while(!q.empty())
    {
        int u=q.front();
        q.pop();
        for (int i=0;i<G[u].size();i++)
        {
            if (!vis[G[u][i]])
            {
                vis[G[u][i]]=1;
                q.push(G[u][i]);
                d[G[u][i]]=d[u]+1;
            }
        }
    }
}
int main()
{
    cin >> n;
    for (int i=0;i<n-1;i++)
    {
        int x,y;
        cin >> x >> y;
        --x,--y;
        G[x].push_back(y);
        G[y].push_back(x);
    }
    bfs(0);
    memcpy(dist[0],d,sizeof(d));
    bfs(n-1);
    memcpy(dist[1],d,sizeof(d));
    int sumF=0,sumS=0;
    for (int i=0;i<n;i++)
    {
        if (dist[0][i]<=dist[1][i]) ++sumF;
        else                        ++sumS;
    }
    if (sumF>sumS)
    {
        cout << "Fennec" << endl;
    }else
    {
        cout << "Snuke" << endl;
    }
    return 0;
}


Measured memory_bytes: 7808
MAX = 10 ** 5
def sieve(n):
    f = [False] * (n + 1)
    res = []
    for i in range(2, n+1):
        if f[i]:
            continue
        res.append(i)
        for j in range(2 * i, n+1, i):
            f[j] = True
    return res

pn = sieve(MAX)
acc = [0] * (MAX + 1)
for p in pn:
    if p % 2 == 1 and (p + 1) // 2 in pn:
        acc[p] = 1
for i in range(2, MAX+1):
    acc[i] += acc[i-1]
Q = int(input())
for _ in range(Q):
    l, r = map(int, input().split())
    print(acc[r] - acc[l-1])


Measured memory_bytes: 77192
N = int(input())
pf = {}
for i in range(2, int(N**0.5) + 1):
    while N % i == 0:
        pf[i] = pf.get(i, 0) + 1
        N //= i
if N > 1:
    pf[N] = pf.get(N, 0) + 1

ans = 0
for i in pf.values():
    if i < 3:
        ans += 1
    elif i < 6:
        ans += 2
    elif i < 10:
        ans += 3
    elif i < 15:
        ans += 4
    elif i < 21:
        ans += 5
    elif i < 28:
        ans += 6
    elif i < 36:
        ans += 7
    elif i < 45:
        ans += 8
    elif i < 55:
        ans += 9
print(ans)

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)

int main() {
    int n;
    cin >> n;
    int ans =0;
    int pre;
    vector<int> a(n+1),b(n+1),c(n);
    for(int i = 1;i<n+1;i++) {
        cin >> a[i];
    }
    for(int i = 1;i<n+1;i++) {
        cin >> b[i];
    }
    for(int i = 1;i<n;i++) {
        cin >> c[i];
    }
    pre=a[1];
    for(int i = 1;i<n+1;i++) {
        ans+= b[a[i]];
        if(pre+ 1 == a[i]) ans+=c[pre];
        pre = a[i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int main (void)
{
int a,b,i,j;
while(1){
scanf("%d %d",&i,&j);
if(i == 0 && j == 0){
	break;
}
for(a = 1;a <=i;a++){
	for(b=1;b<=j;b++){
		if(a%2!=0 && b%2!=0){
			printf("#");
		}
		if(a%2!=0 && b%2==0){
			printf(".");
		}
		if(a%2==0 && b%2==0){
			printf("#");
		}
		if(a%2==0 && b%2!=0){
			printf(".");
		}
	}
	printf("\n");
}
printf("\n");
}
return 0;
}

Measured memory_bytes: 572
n,x,y = map(int,input().split()) 

dist = [0]*n

for i in range(0,n-1):
    for j in range(i,n):
        
        #xy使わない距離
        dist1 = j-i
        
        #xy使う距離
        dist2 = abs((x-1) - i) + 1 + abs((y-1) - j)
        
        
        # print(i,j,dist1,dist2)
        
        #最短距離
        dist_min = min(dist1,dist2)
        
        dist[dist_min] += 1
        
for k in range(1,n):
    print(dist[k])
        

Measured memory_bytes: 69224
#include <cstdio>
using namespace std;

int main(){
	int n;
	int x;
	int S;
	
	while((scanf("%d", &n)) != EOF){
		x = n;
		S = 0;
		while(x < 600){
			S += n * (x * x);
			x += n;
		}
		printf("%d\n", S);
	}
	
	return 0;
}

Measured memory_bytes: 1024
#include <cstdio>

int main(){
    int A, B;
    scanf("%d %d", &A, &B);
    int A5 = A / 10000;
    int B5 = B / 10000;
    int count = 0;
    if(B5 - A5 > 1){
        count += 100 * (B5 - A5 - 1);
    }
    if(A5 == B5){
        for(int i = A; i <= B; i++){
            if(i % 10 == A5 && (i - A5*10000) / 1000 == (i % 100 - A5) / 10){
                count += 1;
            }
        }
    }else{
        for(int i = A; i < (A5+1)*10000; i++){
            if(i % 10 == A5 && (i - A5*10000) / 1000 == (i % 100 - A5) / 10){
                count += 1;
            }
        }
        for(int i = B; i >= B5*10000; i--){
            if(i % 10 == B5 && (i - B5*10000) / 1000 == (i % 100 - B5) / 10){
                count += 1;
            }
        }
    }
    printf("%d", count);
}

Measured memory_bytes: 128
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

var (
	readString func() string
	readBytes  func() []byte
)

func init() {
	readString, readBytes = newReadString(os.Stdin)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func minInt64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func maxInt64(a, b int64) int64 {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a > 0 {
		return a
	}
	return -a
}

// sort ------------------------------------------------------------

type int64Array []int64

func (s int64Array) Len() int           { return len(s) }
func (s int64Array) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s int64Array) Less(i, j int) bool { return s[i] < s[j] }

type xxx struct {
	x int
}

type sortArray []xxx

func (s sortArray) Len() int           { return len(s) }
func (s sortArray) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s sortArray) Less(i, j int) bool { return s[i].x < s[j].x }

// -----------------------------------------------------------------

func main() {
	a := readInt()
	b := readInt()

	if a < 6 {
		fmt.Println(0)
	} else if a < 13 {
		fmt.Println(b / 2)
	} else {
		fmt.Println(b)
	}
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main(){ 
 string S;
 int F,L;
 cin >> S;
  if(S.at(0)=='0'){
    if(S.at(1)=='0'){
      F=0;
    }
    else{
      F=1;
    }
  }
  else if(S.at(0)=='1'){
    if(S.at(1)=='1'||S.at(1)=='2'){
      F=1;
    }
    else{
      F=0;
    }
  }
  else{
    F=0;
  }
  
  if(S.at(2)=='0'){
    if(S.at(3)=='0'){
      L=0;
    }
    else{
      L=1;
    }
  }
  else if(S.at(2)=='1'){
    if(S.at(3)=='1'||S.at(3)=='2'){
      L=1;
    }
    else{
      L=0;
    }
  }
  else{
    L=0;
  }
  if(F==1&&L==1){
    cout << "AMBIGUOUS" <<endl;
  }
       if(F==0&&L==1){
    cout << "YYMM" <<endl;
  } 
      if(F==1&&L==0){
    cout << "MMYY" <<endl;
  }
       if(F==0&&L==0){
    cout << "NA" <<endl;
  }
}

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

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

using namespace std;
using ll=long long;

const int INF = 100000;

int main() {
    string S;
    int Q;
    cin >> S >> Q;
    int T[200000] = {}, F[200000] = {};
    string C[200000] = {};
    rep(i, Q) {
        cin >> T[i];
        if (T[i] == 2) {
            cin >> F[i] >> C[i];
        }
    }

    bool pos = true;
    rep(i, Q) {
        if (T[i] == 1) {
            pos = !pos;
        } else {
            if (F[i] == 1) {
                if (pos) {
                    S.insert(0, C[i]);
                } else {
                    S += C[i];
                }
            } else {
                if (pos) {
                    S += C[i];
                } else {
                    S.insert(0, C[i]);
                }
            }
        }
    }

    if (pos) {
        cout << S;
    } else {
        reverse(S.begin(), S.end());
        cout << S;
    }
    return 0;
}


Measured memory_bytes: 13440
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int map[12][10];
int main(void) {
	int n;
	cin >> n;
	int a, b, c, d;
	for (int i = 0; i < n; i++) {
		cin >> a >> b >> c >> d;
		int k = (a - 1) * 3 + b - 1;
		map[k][c - 1] +=d;
	}
	for (int i = 0; i < 12; i++) {
		for (int j = 0; j < 10; j++) {
			cout <<" "<<map[i][j];
		}
		if ( i==2 || i==5 || i==8 ) {
			cout << endl<<"####################";
		}
		cout << endl;
	}
}


Measured memory_bytes: 3096
#include <cmath>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <algorithm>

using namespace std;
typedef pair<double,double> pp;
vector<pp> a;

#define sqr(x) ((x)*(x))
double Plus (double x){
	return x<0?-x:x;
}
double dist (pp x, pp y){
	return sqr(x.first-y.first) + sqr(x.second-y.second);
}

double go (int l, int r)
{
	if (r-l==1)
		return dist(a[l],a[r]);
	if (r-l==2)
		return min(dist(a[l],a[l+1]), min(dist(a[l],a[l+2]), dist(a[l+1],a[l+2])));

	int m=(l+r)/2;
	double d=min(go(l,m),go(m+1,r));

	vector<pp> v;
	for (auto i=l;i<=r;i++)
		if (sqr(a[i].first-a[m].first)<d)
			v.emplace_back (a[i].second,a[i].first);
	sort (v.begin(),v.end());
	for (auto i=v.begin();i!=v.end();i++)
		for (auto j=i+1;j!=v.end();j++)
		{
if (sqr(j->first - i->first) > d) break;
			d=min(d,dist(*i,*j));
		}
	return d;
}

int main ()
{
	int i,n;
	double x,y;
	scanf ("%d",&n);
	for (i=0;i<n;i++)
		scanf ("%lf%lf",&x,&y), a.emplace_back(x,y);
	sort (a.begin(),a.end());
	printf ("%lf ",sqrt(go(0,n-1)));
}

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

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr), cout.tie(nullptr);
  cout << fixed << setprecision(6);
  double l; cin >> l;
  double len = l / 3.0;
  l -= len;
  double b = l / 2.0;
  double ht = l - b;
  cout << len * ht * b << endl;
}


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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1)
    printEoln();
  if (suc == 2)
    printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

template <class T, class U> void chmax(T &a, U b) {
  if (a < b)
    a = b;
}

template <class T, class U> void chmin(T &a, U b) {
  if (b < a)
    a = b;
}

template <class T> T Sq(const T &t) { return t * t; }

const int mod = 1e9 + 7;

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


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

class Cube {
public:
	int f[6];
	Cube() {}
	void roll_z() { roll(1, 2, 4, 3); }
	void roll_y() { roll(0, 2, 5, 3); }
	void roll_x() { roll(0, 1, 5, 4); }
	void roll(int i, int j, int k, int l) {
		int t = f[i]; f[i] = f[j], f[j] = f[k]; f[k] = f[l]; f[l] = t;
	}
};

bool eq(Cube c1, Cube c2) {
	for (int i = 0; i < 6; i++)
		if (c1.f[i] != c2.f[i])return false;
	return true;
}

bool equal(Cube c1, Cube c2) {
	for (int i = 0; i < 6; i++) {
		for (int j = 0; j < 4; j++) {
			if (eq(c1, c2))return true;
			c1.roll_z();
		}
		if (i % 2 == 0)c1.roll_y();
		else c1.roll_x();
	}
	return false;
}

int main() {
	Cube c1, c2;

	for (int i = 0; i < 6; i++)cin >> c1.f[i];
	for (int i = 0; i < 6; i++)cin >> c2.f[i];

	if (equal(c1, c2))cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;

}

Measured memory_bytes: 3068
using System.Text;
public partial class IntroductionToProgramming{
	public static void Main(){
		System.Console.ReadLine();
		string[] line = System.Console.ReadLine().Split(' ');

		StringBuilder sb = new StringBuilder();

		for (int i = line.Length - 1; i >= 0; i--)
		{
			sb.Append(line[i] + " ");
		}

		System.Console.WriteLine(sb.ToString().Trim());
	}
}

Measured memory_bytes: 5268
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cctype>
#include <numeric>
using namespace std;

#define rep(i,n) for(int (i)=0; (i)<(int)(n); ++(i))
#define foreach(c,i) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)

int C, D, W, X, E[20][40], F[20][40], dp[32][52][8];

void main2() {
  memset(dp, 0, sizeof dp);
  for (int i = 0; i < D; ++i) { // ツ禿コツ付
    for (int j = 0; j <= W; ++j) { // ツ氾ヲツ労ツ度
      for (int k = 0; k <= X; ++k) { // 2ツ嘉アツ暗按湘」ツづ個δ可イツブツづーツ行ツつ、ツ禿コ
        for (int l = 0; l < C; ++l) { // ツ地ツ暗ヲ
          int dW = F[l][i], dE = E[l][i];
          if (dE > 0 && dW + j <= W) {
            dp[i+1][j+dW][k] = max(dp[i+1][j+dW][k],
                                   max(dp[i][j+dW][k], dp[i][j][k] + dE));
            if (k < X) {
              // ツ湘」ツつェツづゥ
              for (int ll = l-1; ll >= 0; --ll) {
                dW += F[ll][i]; dE += E[ll][i];
                if (dW + j > W || E[ll][i] == 0) break;
                dp[i+1][j+dW][k+1] =
                    max(dp[i+1][j+dW][k+1],
                        max(dp[i][j+dW][k+1], dp[i][j][k] + dE));
              }
              // ツ可コツつェツづゥ
              dW = F[l][i], dE = E[l][i]; // ツ渉可甘コツ可サ
              for (int ll = l+1; ll < C; ++ll) {
                dW += F[ll][i]; dE += E[ll][i];
                if (dW + j > W || E[ll][i] == 0) break;
                dp[i+1][j+dW][k+1] =
                    max(dp[i+1][j+dW][k+1],
                        max(dp[i][j+dW][k+1], dp[i][j][k] + dE));
              }
            }
          } else {
            dp[i+1][j+dW][k] = max(dp[i+1][j+dW][k], dp[i][j+dW][k]);
          }
        }
      }
    }
  }
  int ans = -1;
  for (int j = 0; j <= W; ++j) {
    for (int k = 0; k <= X; ++k) {
      // printf("%d,%d => %d\n", j,k,dp[D][j][k]);
      ans = max(ans, dp[D][j][k]);
    }
  }

  printf("%d\n", ans);
}

int main() {
  while (-1 != scanf("%d%d%d%d", &C, &D, &W, &X)) {
    if (!(C)) break;
    rep(i,C) rep(j,D) scanf("%d", E[i]+j);
    rep(i,C) rep(j,D) scanf("%d", F[i]+j);
    main2();
  }
  return 0;
}

Measured memory_bytes: 944