akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))

using namespace std;
typedef pair<llint, llint> P;

llint w, h, k;

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

llint calc(llint w, llint h)
{
	llint ret = 0;
	for(llint x = 1; x < w; x++){
		for(llint y = 1; y < h; y++){
			if((w-x)*y > k + 3*max(w, h)) break;
			llint K = k + gcd(x, y) - (w-x)*y;
			if(K > 0) ret += min(h-1, K / x);
			for(llint z = max(1LL, K/x+1); z < h; z++){
				if(x*z > K + (w-x) + w) break;
				if(x*z - gcd(w-x, z) - gcd(w, abs(y-z)) <= K) ret++;
			}
		}
	}
	return ret;
}

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> w >> h >> k;
	k = 2*k - 2;
	
	llint ans = 2 * calc(w, h) + 2 * calc(h, w);
	cout << ans << endl;
	
	return 0;
}

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

typedef long long ll;

const int mx=1e6+5, mod=1e9+7;

int phi(int n) {
	int result=n;
	for (int i=2; i*i<=n; i++) {
		if(n%i==0) result-=result/i;
		while(n%i==0) n/=i;
	}
	if(n>1) result-=result/n;
	return result;
}

// (a^b)%m
ll exp(ll a, ll b, ll m) {
	ll r=1;
	while(b) {
		if(b%2) r=(r*a)%m;
		a=(a*a)%m;
		b/=2;
	}
	return r;
}

// a^-1 %m, any m
ll inv(ll a, ll m) {
	return exp(a, phi(m)-1, m);
}

// a^-1 %m, prime m
ll invp(ll a, ll m) {
	return exp(a, m-2, m);
}

ll fact[mx];

ll combi(int n, int x, ll m) {
	ll p=fact[n], q=fact[x], r=fact[n-x];
	ll ret=p;
	ret=(ret*invp(q,m))%m;
	ret=(ret*invp(r,m))%m;
	return ret;
}

int main() {
	fact[0]=1;
	for (int i=1; i<mx; i++)
		fact[i]=(fact[i-1]*i)%mod;
	int x,y; cin>>x>>y;
	int sum=x+y;
	if(sum%3) {
		cout<<0<<"\n";
		return 0;
	}
	int k=sum/3,a=x-k, b=k-a;
	if(a<0||a>k||b<0||b>k) {
		cout<<0<<"\n";
		return 0;
	}
	cout<<combi(k,a,mod)<<"\n";
	return 0;
}

Measured memory_bytes: 8064
import heapq

def sol():
    N = int(input())
    A = list(map(int, input().split()))

    hq = []
    for a in A:
        heapq.heappush(hq, a)

    while len(hq) > 1:
        x = heapq.heappop(hq)
        y = heapq.heappop(hq)
        new = (x + y) / 2
        heapq.heappush(hq, new)

    ans = heapq.heappop(hq)
    print(ans)


sol()

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

#ifdef LOCAL
#define DEBUG(...) debug(#__VA_ARGS__, __VA_ARGS__);
#else
#define DEBUG(...) 6;
#endif

template<typename T, typename S> ostream& operator << (ostream &os, const pair<T, S> &p) {return os << "(" << p.first << ", " << p.second << ")";}
template<typename C, typename T = decay<decltype(*begin(declval<C>()))>, typename enable_if<!is_same<C, string>::value>::type* = nullptr>
ostream& operator << (ostream &os, const C &c) {bool f = true; os << "["; for (const auto &x : c) {if (!f) os << ", "; f = false; os << x;} return os << "]";}
template<typename T> void debug(string s, T x) {cerr << s << " = " << x << "\n";}
template<typename T, typename... Args> void debug(string s, T x, Args... args) {cerr << s.substr(0, s.find(',')) << " = " << x << " | "; debug(s.substr(s.find(',') + 2), args...);}

int a[505];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int n, k;
    cin >> n >> k;
    int sum = 0;
    for (int i=0; i<n; i++) {
        cin >> a[i];
        sum += a[i];
    }

    int ret = 0;
    for (int i=1; i*i<=sum; i++)
        if (sum % i == 0)
            for (int d : {i, sum / i}) {
                vector<int> rem;
                for (int j=0; j<n; j++)
                    if (a[j] % d)
                        rem.push_back(a[j] % d);
                sort(rem.begin(), rem.end());
                long long lsum = 0, rsum = 0;
                for (int x : rem)
                    rsum += d - x;
                if (rsum % d == 0 && rsum <= k) {
                    ret = max(ret, d);
                    continue;
                }
                bool ok = false;
                for (int x : rem) {
                    lsum += x;
                    rsum -= d - x;
                    if (abs(lsum - rsum) % d == 0 && max(lsum, rsum) <= k) {
                        ok = true;
                        break;
                    }
                }
                if (ok)
                    ret = max(ret, d);
            }
    cout << ret << "\n";

    return 0;
}


Measured memory_bytes: 3632
n = int(input())
a  = list(map(int,input().split()))
d = []
l = 0
for i in range(n-1):
    if a[i+1] == a[i]:
        r =  i+1
        d.append(r-l)
        l = r
d.append(n-l)
ans = 0

for i in range(len(d)-2):
    ans = max(ans,d[i]+d[i+1]+d[i+2])
if len(d) == 2:
    ans = max(d[0]+d[1],ans)
    ans = max(d[-1]+d[-2],ans)
if len(d) == 1:
    ans = d[0]
    
print(ans)
    


Measured memory_bytes: 7176
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <math.h>
#define MOD 1000000007
using namespace std;

int main(void){
    int a,b,c;
    cin >> a >> b >> c;
    cout << min(c,b/a) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<ll, ll> P;
inline ll min(ll x, ll y) { return x < y ? x : y; }
inline ll max(ll x, ll y) { return x > y ? x : y; }

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#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 all(c) c.begin(), c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)

bool is_prime(int);

int main() {
    int X;
    cin >> X;
    while (true) {
        if (is_prime(X)) {
            cout << X;
            break;
        } else {
            X++;
        }
    }
    return 0;
}

bool is_prime(int X) {
    for (int i = 2; i <= int(sqrt(X)); i++) {
        if (X % i == 0) {
            return false;
        }
    }
    return true;
}

Measured memory_bytes: 384
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
#include<map>
#include<iomanip>

const long long INF = 1e17+7;
const long long MOD = 1e9+7;
const double PI=acos(-1);

using namespace std;

long long GCD(long long a,long long b){
	long long x=max(a,b),y=min(a,b);
	if(x%y==0){
		return y;
	}else{
		return GCD(y,x%y);
	}
}

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

int main(){
	int n;
	cin >> n;
	vector<long long> a(n);
	
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	
	if(n==1){
		cout << a[0] << endl;
		return 0;
	}
	
	long long ans=a[0];
	
	for(int i=1;i<n;i++){
		if(i==1){
			ans=LCM(a[i],a[i-1]);
		}else{
			ans=LCM(a[i],ans);
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
import fractions

A, B = map(int, input().split())

C = fractions.gcd(A, B)

def factorize(n):
    b = 2
    fct = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            fct.append(b)
        b += 1
    if n > 1:
        fct.append(n)
    return fct

print(len(list(set(factorize(C)))) + 1)

Measured memory_bytes: 5856
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (ll i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (ll i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,x) for (ll i = 0; i < x.size(); i++)
#define RREPALL(i,x) for (ll i = x.size()-1; i >= 0; i--)
#define REPITR(itr,x) for (auto itr = (x).begin(); itr != (x).end(); itr++)
#define ALL(x) (x).begin(), (x).end()
#define SORT(x) sort(ALL(x))
#define MIN_ELEMENT(x) min_element(ALL(x))
#define MAX_ELEMENT(x) max_element(ALL(x))
#define COUNT(x,num) count(ALL(x), num)
#define MEMSET(x,val) memset(x, val, sizeof(x))
#define MAX(a,b) a = max(a,b)
#define MIN(a,b) a = min(a,b)
#define debug(x) cerr<<__LINE__<<": "<<(#x)<<" = "<<(x)<<endl;
void YES(bool flag) {cout<<(flag ? "YES" : "NO")<<endl;}
void Yes(bool flag) {cout<<(flag ? "Yes" : "No")<<endl;}
void yes(bool flag) {cout<<(flag ? "yes" : "no")<<endl;}
#define e1 first
#define e2 second
#define nextline putchar('\n')
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef vector<ll> VLL;
typedef vector<vector<ll>> VVLL;
const int INF = 1e7;
const ll MOD = 1e9 + 7;

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

    if (k < s.size())
    	s = s.substr(0,k) + "...";

    cout<<s<<endl;



    return 0;
}


Measured memory_bytes: 3632
#include <iostream>

using namespace std;

int main()
{
  int H, W;
  while (1)
{
  cin >> H >> W;
  if (H == 0 && W == 0)
    break;
  
  for (int w = 0; w < W; ++w)
      cout << '#';
  cout << endl;
  for (int h = 1; h < H - 1; ++h)
  {
    cout << '#';
    for (int w = 1; w < W - 1; ++w)
    {
      cout << '.';
    }
    if (W > 1) cout << '#';
    cout << endl;
  }
  if (H > 1)
  for (int w = 0; w < W; ++w)
      cout << '#';
  cout << endl << endl;
}
}


Measured memory_bytes: 3092
import Data.Char
import Data.Map.Strict (fromList, insertWith, toList)

main :: IO ()
main = do
    contents <- getContents
    let counts = fromList [(c, 0) | c <- ['a' .. 'z']]
    mapM_ (\(k, v) -> putStrLn (k : " : " ++ show v)) $ toList $ foldl (\m c -> insertWith (+) c 1 m) counts $ filter isAsciiLower $ map toLower contents

Measured memory_bytes: 4080
#include<stdio.h>
#include <string>
#include <iostream>
#include <vector>
#include <sstream>
#include<math.h>
#include <algorithm>
using namespace std;



int main(void)
{
  int e,f=0;
  int i,j,k,l;
  double Max,Min,ans;
  vector<int> array;
  

  while(cin>>e)
    {
	 for(i=0;i<10;i++)
	 {
		for(j=0;j<10;j++){
			for(k=0;k<10;k++){
				for(l=0;l<10;l++){if(i+j+k+l==e)f++;}
			}}
	 }
    array.push_back(f);
	f=0;
    }
  i=0;
  while(i<array.size())
    {
	cout<<array[i]<<endl;
	i++;
    }
  array.clear();
}

Measured memory_bytes: 1216
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define DBG_N(hoge) cerr<<"!"<<" "<<(hoge)<<endl;
#define DBG cerr<<"!"<<endl;
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;
ll sum[10000];
vector<pair<ll,ll>> ans;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;cin>>n;
  if(n%2){
    //vector<pair<ll,ll>> ans;
    for(int i=1;i<n;i++){
      ans.pb(mp(i,n));
      sum[i]+=n;
      sum[n]+=i;
    }
    for(int i=1;i<=n/2;i++){
      for(int j=i+1;j<=n/2;j++){
	sum[i]+=j;
	sum[j]+=i;
	ans.pb(mp(i,j));
      }
    }
    for(int i=1;i<=n/2;i++){
      for(int j=n/2+1;j<n;j++){
	if(n-i==j)continue;
	ans.pb(mp(i,j));
      }
    }
    for(int i=n/2+1;i<n;i++){
      for(int j=i+1;j<n;j++){
	sum[i]+=j;
	sum[j]+=i;
	ans.pb(mp(i,j));
      }
    }
    //for(int i=1;i<=n;i++)cout<<sum[i]<<endl;
  }else{
  
    ans.pb(mp(1,2));
    ans.pb(mp(1,n-1));

    for(int i=3;i<n-1;i++){
      ans.pb(mp(2,i));
      ans.pb(mp(i,n-1));
    }
    ans.pb(mp(2,n));
    ans.pb(mp(n-1,n));
    for(int i=3;i<=n-2;i++)
      ans.pb(mp(1,i));
    for(int i=3;i<=n-2;i++){
      for(int j=i+1;j<=n-2;j++){
	if(i+j == n+1)continue;
	ans.pb(mp(i,j));
      }
    }
    for(int i=n-2;i>2;i--){
      ans.pb(mp(i,n));
    }
  }
  cout<<ans.size()<<endl;
  for(auto &a:ans)
    cout<<a.F<<" "<<a.S<<endl;

  return 0;
}


Measured memory_bytes: 512
/*  Success may not come to me immediately,
 *  but it will come definitely....
 */
#include<bits/stdc++.h>
//=====================================================================
using namespace std;
//=====================================================================
#define opt ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
//=====================================================================
#define li      int64_t
#define ld      float
#define ulli    uint64_t
//=====================================================================
#define rep(i,a,b)  for(i=a;i<b;i++)
#define repr(i,a,b) for(i=a;i>b;i--)
#define repi(i,v)   for(i=v.begin();i!=v.end();i++)
#define repir(i,v)  for(i=v.rbegin();i!=v.rend();i++)
#define elif        else if
#define mset(a,b)   memset(a,b,sizeof(a))
#define nl          cout<<'\n'
//=====================================================================
typedef vector<li>       vli;
typedef vector<string>   vstr;
typedef pair<li,li>      pli;
typedef pair<li,pli >    ppli;
typedef pair<li,ppli >   pppli;
typedef vector<pli >     vpl;
typedef vector<ppli >    vppli;
typedef vector<pppli >   vpppli;
//=====================================================================
#define pb  push_back
#define pob pop_back
#define pf  push_front
#define pof pop_front
#define all(v)  v.begin(),v.end()
#define itr iterator
#define rtr reverse_iterator
#define sz  size()
#define lb  lower_bound
#define ub  upper_bound
#define bs  binary_search
#define mp  make_pair
#define F   first
#define S   second
//=====================================================================
#define mod (li)(1e3)
#define inf (li)(1e18)
#define MX1 (li)(1e5+5)
#define MX2 (li)(1e6+5)
#define pi  acos(-1)
//=====================================================================
li power(li a,li b){li ans=1;while(b){if(b&1){ans=(ans*a)%mod;}
a=(a*a)%mod;b>>=1;}return ans;}
//=====================================================================
li mmi(li n){return power(n,mod-2);}
//=====================================================================
li two(li n){return (1LL<<n);}
//=====================================================================
void onbit(li &n,li x){n|=two(x);}
//=====================================================================
void offbit(li &n,li x){n&=~two(x);}
//=====================================================================
li cntbit(li n){li res=0;while(n and ++res)n-=n&-n;return res;}
//=====================================================================
li dx[]={-1,0,1,0},dy[]={0,-1,0,1};
//=====================================================================
/*------------------------MAIN CODE BEGINS NOW!------------------------*/

li a,b,c;

void solve(){
  cin>>a>>b>>c;
  if(a%2==0 or b%2==0 or c%2==0){
    cout<<"0";
    return ;
  }
  cout<<min(a*b,min(b*c,a*c));
}

int main(){
  opt
  #ifndef ONLINE_JUDGE
  #endif
  li t=1;
  //cin>>t;
  while(t--){
    solve();
  }
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
    #include <bits/stdc++.h>
    #include <cctype>
    #include <cmath>
    #include <cstdio>
    #include <iomanip>
    #include <iostream>
    #include <list>

    #include <stack>
    #include <string>
    #include <vector>
    #include <bits/stdc++.h>
    #define INFINI (1000 * 1000 * 1000)

    using namespace std;
    //#define s(T) scanf("%d", &T)
    #define sl(T) scanf("%lld", &T)
    #define fill(a, val) memset(a, val, sizeof(a))
    #define mp make_pair
    #define pb push_back
    #define all(x) x.begin(), x.end()
    #define DREP(x) sort(all(x)); x.erase(unique(all(x)), x.end())
    #define INDEX(a, val) (lower_bound(all(a), val) - a.begin())
    #define mod ll(1e9+7)
    typedef long long ll;


    bool compare_first(pair<ll,ll >a,pair<ll,ll >b)
    {
        return a.first<b.first;
    }

     bool compare_second(pair<int,pair<int , int> > a,pair<int,pair<int , int> > b)
    {
        return a.second.first<b.second.first;
    }


    ll min(ll a,ll b)
    {
        if(a>b)return b;
        return a;
    }

    ll toINT(string s)
    {
        ll a=0;
        for(ll index=0;index<s.size();index++)
            a=a*10+(s[index]-'0');
        return a;
    }



    int main() {
      ios::sync_with_stdio(false);

      ll n,k;
      cin>>n>>k;
      ll ans=k;
      for(ll index=1;index<n;index++)
        ans*=(k-1);
      cout<<ans<<endl;
return 0;
    }

/*

 }
 */


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    string s; cin>>s;
    int c0=0,c1=0;
    REP(i,s.size()){
        if(s[i]=='0') c0++;
        if(s[i]=='1') c1++;
    }
    cout<<min(c0,c1)*2<<endl;
}


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

using namespace std;

using ll = long long;

template <typename T>
vector<T> apply(const vector<T> &a, const vector<int> &s)
{
    int n = s.size();
    vector<T> b(n);
    for (int i = 0; i < n; i++)
        b[i] = a[s[i]];
    return b;
}

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

    ll N, M, K;
    cin >> N;
    vector<ll> x(N);
    for (int i = 0; i < N; i++)
        cin >> x[i];
    cin >> M >> K;
    vector<ll> a(M);
    for (int i = 0; i < M; i++)
    {
        cin >> a[i];
        a[i]--;
    }
    vector<ll> dx(N - 1);
    for (int i = 0; i < N - 1; i++)
        dx[i] = x[i + 1] - x[i];
    // 置換
    vector<int> s(N - 1);
    for (int i = 0; i < N - 1; i++)
        s[i] = i;
    for (int i = 0; i < M; i++)
        swap(s[a[i] - 1], s[a[i]]);
    for (ll i = 1; i <= K; i *= 2)
    {
        if (K & i)
            dx = apply(dx, s);
        s = apply(s, s);
    }
    vector<ll> y(N);
    y[0] = x[0];
    for (int i = 0; i < N - 1; i++)
        y[i + 1] = y[i] + dx[i];
    for (int i = 0; i < N; i++)
        cout << y[i] << endl;
    return 0;
}


Measured memory_bytes: 5584
#include <iostream>
#include <cctype>
#include <string>
using namespace std;
int main(){
    string sen;
    int a[26] = {};
    int index;
    char alpha;
    while(getline(cin, sen)){
        for(int i = 0; i < sen.size(); i++){
            if(isupper(sen[i])){
                sen[i] = tolower(sen[i]);
            }
            if(islower(sen[i])){
                index = sen[i] - 'a';
                a[index] += 1;
            }
        }
    }
    for(int i = 0; i < 26; i++){
        alpha = i + 'a';
        cout << alpha << " : " << a[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 3152
n, p = map(int, input().split())

A = list(map(int, input().split()))
B = []
for i in A:
    B.append(i%2)

zero = B.count(0)
one = B.count(1)

t = 0

from operator import mul
from functools import reduce

def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom

for i in range(1, one+1, 2):
    t += combinations_count(one, i)

if p == 1:
    print(t * 2**zero)
else:
    print(2**n - t * 2**zero)

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

#define PB push_back

using namespace std;

const int N = 1e5 + 500;

int n,g[5],g2[5],ind,col[N],par[N];
vector < int > v[N], sol[2];

void dfs(int x,int lst,int dis){
    if(g2[ind] < dis){
        g2[ind] = dis;
        g[ind] = x;
    }
    for(int k : v[x])
        if(k != lst)
            dfs(k, x, dis + 1);
}

void root(int x,int lst){
    par[x] = lst;
    for(int k : v[x])
        if(k != lst)
            root(k, x);
}

int main(){
    scanf("%d", &n);
    for(int i = 0;i<n-1;i++){
        int x,y;scanf("%d%d",&x,&y);
        v[x].PB(y);
        v[y].PB(x);
    }
    ind = 0;
    dfs(6,6,0);
    ind = 1;
    dfs(g[0], g[0], 0);
    int st = g[0];
    int en = g[1];
    for(int bla = 0;bla < 2;bla++){
        root(st, 0);
        int cur = en,lst = en;
        int cnt = n;
        while(cur){
            for(int k : v[cur])
                if(k != lst && k != par[cur])
                    col[k] = cnt--;
            col[cur] = cnt--;
            sol[bla].PB(col[cur]);
            for(int k : v[cur])
                if(k != lst && k != par[cur])
                    sol[bla].PB(col[k]);
            lst = cur;
            cur = par[cur];
        }
        reverse(sol[bla].begin(),sol[bla].end());
        if(cnt != 0){
            printf("-1\n");
            return 0;
        }
        swap(st, en);
    }
    if(sol[0] > sol[1]) swap(sol[0], sol[1]);
    for(int k : sol[0])
        printf("%d ", k);
    printf("\n");
}


Measured memory_bytes: 12664
n = int(input())
h = input().split()
c = 1
aux = False
h = list(map(int, h))
for i in range(1,n):
    for j in range(i - 1, -1, -1):
        if h[j] <= h[i]:
            aux = True
        else:
            aux = False
            break
    if aux:
        c = c + 1
        aux = 0

print(c)

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

int N;
 
signed main() {
    cin.tie(0); ios::sync_with_stdio(false);
    cin >> N;
    int ans = 100;
    rep(i, N) {
        int A; cin >> A;
        int cnt = 0;
        while (A%2==0) {
            A /= 2;
            cnt++;
        }
        ans = min(ans, cnt);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;

#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn list_patterns(n: usize, v: &mut Vec<bool>) -> Vec<Vec<bool>>{

    if v.len() == n{
        return vec![v.clone()];
    }

    let mut res: Vec<Vec<bool>> = vec![];
    v.push(false);
    let mut tmp = list_patterns(n, v);
    res.append(&mut tmp);
    v.pop();

    v.push(true);
    let mut tmp = list_patterns(n, v);
    res.append(&mut tmp);
    v.pop();

    return res;
}

fn main(){
    let line = read_as_vec::<usize>();
    let (d, g) = (line[0], line[1]);

    let mut problems = vec![];
    for i in 0..d{
        let line = read_as_vec::<usize>();
        problems.push((line[0], line[1], (i+1)*100));
    }

    problems.sort_by_key(|x| x.1);
    problems.reverse();
    let mut v = vec![];
    let patterns = list_patterns(d, &mut v);

    let mut ans = std::usize::MAX;

    for pat in patterns{
        //println!("{:?}", pat);
        let completed_sum: usize = pat.iter().zip(problems.iter()).filter(|x| *x.0)
            .map(|x| (x.1).2*(x.1).0 + (x.1).1).sum::<usize>();
        let completed_num: usize = pat.iter().zip(problems.iter()).filter(|x| *x.0)
            .map(|x| (x.1).0).sum::<usize>();

        if completed_sum >= g{
            ans = cmp::min(ans, completed_num);
            continue;
        }
        //.println!("complete_sum = {}, complete_num={}", completed_sum, completed_num);
        let (num, _, points) = *pat.iter().zip(problems.iter()).
            filter(|x| *x.0 == false).map(|x| x.1).nth(0).unwrap();
        //println!("points ={}, num = {}, g = {}", points, num, g);
        let solved = (g - completed_sum+points-1)/points;
        //println!("solved = {}", solved);
        if solved <= num{
            ans = cmp::min(ans, completed_num + solved);
        }
        //println!("ans = {}", ans);
    }

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


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

int main(){
	int a, b;
	cin >> a >> b;
	int s = b - a;
	int t = 0;
	rep(i, s) t += i+1;
	cout << t - b << endl;
	return 0;
}


Measured memory_bytes: 256
#ifdef _DEBUG
#include ".vscode/debug_print.hpp"
#else
#define debug(...)
#endif
#include <bits/stdc++.h>

using ll = long long;
using ld = long double;
using namespace std;
constexpr int INF32       = 1050000000;
constexpr long long INF64 = 4000000000000000000;
constexpr int MOD7        = 1000000007;
constexpr int MOD53       = 998244353;
constexpr long double PI  = 3.14159265358979323846;
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;
}
void print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}
void scan() {}
template <class H, class... T> void scan(H &&head, T &&... args) {
    std::cin >> head;
    scan(std::forward<T>(args)...);
}
template <class T> void scan(std::vector<T> &v) {
    for (auto &&i : v) {
        scan(i);
    }
}

void vprint() { std::cout << '\n'; }
template <class H, class... T> void vprint(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << '\n';
    vprint(std::forward<T>(args)...);
}
template <class T> void vprint(std::vector<T> &v) {
    for (auto &&i : v) {
        std::cout << i << '\n';
    }
}

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

    int a, b, c;
    scan(a, b, c);
    swap(a, b);
    swap(a, c);
    print(a, b, c);

    return 0;
}

Measured memory_bytes: 3636
#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 sz(s)    (int)(s.size())
#define PI acos(-1)
#define EPS 1e-8
#define watch(x) cout << (#x)<<" = "<<x<<endl
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);
}
class SegmentTree {
public:
	vi tree, lazy;
	SegmentTree(int n, int in) {
		tree = vi(n * 4 + 9, in), lazy = vi(n * 4 + 9);
	}
	void unlockLazy(int segIdx, int startNode, int endNode) {
		if (!lazy[segIdx])
			return;
		if (startNode == endNode) {
			tree[segIdx] = min(tree[segIdx], lazy[segIdx]);
			return;
		}
		int l = segIdx << 1, r = l | 1;
		lazy[l] = (lazy[l] == 0 || lazy[l] > lazy[segIdx] ? lazy[segIdx] : lazy[l]);
		lazy[r] = (lazy[r] == 0 || lazy[r] > lazy[segIdx] ? lazy[segIdx] : lazy[r]);
		lazy[segIdx] = 0;
	}
	void update(int segIdx, int startNode, int endNode, int s, int e, int val) {
		unlockLazy(segIdx, startNode, endNode);
		if (e < startNode || s > endNode)
			return;
		if (s <= startNode && e >= endNode) {
			lazy[segIdx] = val;
			unlockLazy(segIdx, startNode, endNode);
			return;
		}
		int mid = startNode + (endNode - startNode) / 2;
		int l = segIdx << 1, r = l | 1;
		update(l, startNode, mid, s, e, val);
		update(r, mid + 1, endNode, s, e, val);
	}
	int query(int segIdx, int startNode, int endNode, int idx) {
		unlockLazy(segIdx, startNode, endNode);
		if (startNode == endNode)
			return tree[segIdx];
		int mid = startNode + (endNode - startNode) / 2;
		int l = segIdx << 1, r = l | 1;
		if (idx <= mid)
			return query(l, startNode, mid, idx);
		else
			return query(r, mid + 1, endNode, idx);
	}
};
int main() {
	file();
	fast();
	int n, q; cin >> n >> q;
	SegmentTree row = SegmentTree(n, n);
	SegmentTree col = SegmentTree(n, n);
	ll ans = (n - 2LL) * (n - 2LL);
	while (q--) {
		int type, x; cin >> type >> x;
		if (type == 1) {
			int gt = col.query(1, 1, n, x);
			ans -= (gt - 2LL);
			row.update(1, 1, n, 1, gt, x);
		}
		else {
			int gt = row.query(1, 1, n, x);
			ans -= (gt - 2LL);
			col.update(1, 1, n, 1, gt, x);
		}
	}
	cout << ans << endl;
	return 0;
}


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

using namespace std;

#define REP(var, n)  for (int var = 0; var < (n); var++)
#define RREP(var, n)  for (auto var = n - 1; var != static_cast<int>(-1); var--)
#define FOR(var, a, b)  for (auto var = (a); var < (b); var++)
#define RFOR(var, a, b)  for (auto var = b - 1; var != a; var--)

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<int, int> pii;

#define all(c) begin(c),end(c)

#define D(x) do { std::cerr << x << " "; } while (0)
#define D2(x) do { std::cerr << #x << ": " << x << std::endl; } while (0)


template<typename T>
std::ostream &operator<<(std::ostream &out, const std::vector<T> &v) {
    if (!v.empty()) {
        out << '[';
        std::copy(v.begin(), v.end(), std::ostream_iterator<T>(out, ", "));
        out << "\b\b]";
    }
    return out;
}


template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
    return os << '(' << p.first << ',' << p.second << ')';
}


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

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

int MOD = (int) 1e9 + 7;

enum {
    A, G, C, T, NOP, SZ
};

auto solve() {
    int N;
    cin >> N;
    typedef vector<vvll> vvvll;
    typedef vector<vvvll> vvvvll;
    vvvvll dp(N + 1, vvvll(SZ, vvll(SZ, vll(SZ, -1))));
    dp[0][NOP][NOP][NOP] = 1;

    REP(i, N) {
        REP(j, 5) {
            REP(k, 5) {
                REP(l, 5) {
                    if (dp[i][j][k][l] == -1)
                        continue;

                    REP(next, 4) {
                        if (dp[i + 1][k][l][next] == -1)
                            dp[i + 1][k][l][next] = 0;

                        if (
                                (k == A && l == G && next == C) ||
                                (j == A && l == G && next == C) ||
                                (k == G && l == A && next == C) ||
                                (k == A && l == C && next == G) ||
                                (j == A && k == G && next == C)
                                ) {
                        } else {
                            dp[i + 1][k][l][next] += dp[i][j][k][l];
                            dp[i + 1][k][l][next] %= MOD;
                        }
                    }
                }
            }
        }
    }

    ll s = 0;
    REP(i, 4) REP(j, 4) REP(k, 4) {
                if (dp[N][i][j][k] == -1) continue;
                s += dp[N][i][j][k];
                s %= MOD;
            }

    return s;
}


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

//    cout << (solve() ? "Heisei" : "TBD") << endl;
//    cout << (solve() ? "YES" : "NO") << endl;
    cout << solve() << endl;
//    solve();

    return 0;
}

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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> ds(n);
    for (int& d : ds) {
        cin >> d;
    }
    sort(ds.begin(), ds.end());
    cout << ds[n/2] - ds[n/2-1] << endl;
    return 0;
}


Measured memory_bytes: 640
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())



int n;
int a[100000];
int x;


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

	cin >> n >> x;
	rep(i, n)cin >> a[i];
	long long ans = 0;
	rep(i,n-1) {
		if (a[i]+a[i+1] > x) {
			int r = min(a[i + 1], a[i] + a[i + 1] - x);
			a[i + 1] -= r;
			ans += r;
			r = a[i] + a[i + 1] - x;
			a[i] -= r;
			ans += r;
		}
	}
	if (a[n - 1] > x) ans += a[n - 1] - x;
	cout << ans << endl;


	return 0;
}

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

YES = "Yes"  # type: str
NO = "No"  # type: str

# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    S = input()
    T = input()

    print(YES if S == T[:-1] else NO)

if __name__ == '__main__':
    main()


Measured memory_bytes: 8912
import sys
   
BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001
   
   
table = [0]*26
   
letters = "abcdefghijklmnopqrstuvwxyz"
input_str = sys.stdin.read()
   
for A in input_str:
    index = 0
    for B in letters:
        if A == B or A == B.upper():
            table[index] += 1
            break
        index += 1
   
for i in range(len(letters)):
    print("%s : %d"%(letters[i],table[i]))


Measured memory_bytes: 5572
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<math.h>
#include<tuple>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

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

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(pow(10, 7)) 


# 頂点vをcolor(1 or -1)で塗り、矛盾がないか調べる
def dfs(v, color):
    colors[v] = color
    for to in edges[v]:
        # 同じ色が隣接するならFalse
        if colors[to] == color:
            return False
        # 未着手の頂点は反転した色を指定
        if colors[to] == 0 and not dfs(to, -color):
            return False
    return True


N, M = map(int, input().split())
edges = [[] for _ in range(N)]
for _ in range(M):
    a, b = map(int, input().split())
    edges[a-1].append(b-1)
    edges[b-1].append(a-1)
colors = [0] * N
if dfs(0, 1):
    print(len([i for i in colors if i == -1])*len([j for j in colors if j == 1]) - M)
else:
    print(N * (N-1) // 2 - M)


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

using namespace std;
typedef int64_t ll;
typedef uint64_t ull;
typedef long double ld;

int main() {
#ifdef cute
	freopen("in", "r", stdin);
#endif
	ios::sync_with_stdio(false);
	cin.tie(NULL);


	string s;
	cin >> s;
	int ct = 0;
	int n = s.size();
	for(int i = 0; i < (n >> 1); i++)
		if(s[i] ^ s[n-1-i]) ++ct;

	cout << ct;


#ifdef cute
	cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << " ms.\n";
#endif
}

// g++ o .cpp -O2 -std=c++11 -D cute -Wall -Wno-unused-result



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

#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);

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

    long long thousand=(x/500)*1000;

    long long rest=(x%500)/5*5;;

    long long ans=thousand+rest;
    cout<<ans<<endl;
}




Measured memory_bytes: 3652
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <string.h>
using namespace std;
int main()
{
    int n;
    while(cin >> n)
    {
        bool flag = true;
        int now = 0, now_x = 0, now_y = 0;
        for(int t, x, y, i = 0; i < n; i++)
        {
            scanf("%d%d%d", &t, &x, &y);
            int ti = t - now;
            int len = max(now_x, x) - min(now_x, x) + max(now_y, y) - min(now_y, y);
            if(len > ti)
            {
                flag = false;
            }
            else if((len - ti) % 2)
            {
                flag = false;
            }
        }
        if(flag)
        {
            puts("Yes");
        }
        else
        {
            puts("No");
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#include <math.h>
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
#define INF 999999999
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

using llong = long long;
using namespace std;

int main(){
    int x;
    cin >> x;
    if(x == 0) cout << 1 << endl;
    else cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 3636
#include "bits/stdc++.h"

using namespace std;

void solve(void)
{
	int n;
	cin >> n;
	vector<pair<string, pair<int, int>>> ps(n);
	for (int i = 0; i < n; i++)
	{
		cin >> ps[i].first >> ps[i].second.first;
		ps[i].second.first *= -1;
		ps[i].second.second = i+1;
	}
	sort(ps.begin(), ps.end());
	for (int i = 0; i < n; i++)
	{
		cout << ps[i].second.second << endl;
	}
}

int main()
{
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


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

using namespace std;

char a[110][110];

int main()
{
    int h,w;
    scanf("%d%d",&h,&w);
    for(int i=0;i<h;i++)
    {
        getchar();
        for(int j=0;j<w;j++)
        {
            scanf("%c",&a[i][j]);
        }
    }
    for(int i=0;i<h;i++)
    {
        for(int j=0;j<w;j++)
        {
            printf("%c",a[i][j]);
        }
        printf("\n");
        for(int j=0;j<w;j++)
        {
            printf("%c",a[i][j]);
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
char c;
string f(string s,string t){
  int i,j,k;
  if(0){
  }else if(s.empty()&&t.empty()){
    return "";
  }else if(s.empty()||t.empty()){
    if(c=='i')
      return "";
    else{
      if(t.empty())
	return s;
      else
	return t;
    }
  }else{
    i=0;
    for(j=1;s[j]!=','||i;j++){
      if(0){
      }else if(s[j]=='('){
	i++;
      }else if(s[j]==')'){
	i--;
      }
    }
    i=0;
    for(k=1;t[k]!=','||i;k++){
      if(0){
      }else if(t[k]=='('){
	i++;
      }else if(t[k]==')'){
	i--;
      }
    }
    return '('+f(s.substr(1,j-1),t.substr(1,k-1))+','+f(s.substr(j+1,s.length()-j-2),t.substr(k+1,t.length()-k-2))+')';
  }
}
int main(){
  string s,t;
  while(cin>>c){
    cin>>s>>t;
    cout<<f(s,t)<<endl;
  } 
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
using namespace std;
 
int main(){
	int set[] = { 0, 1, 2, 3, 5, 7, 8, 9 };
	int n;
	long ans,keta;
    while(1){
        cin >> n;
        if(n == 0){
        	break; 
     	}
        ans = 0;
        keta = 1;
        while(n != 0){
            ans += keta * set[n%8];
            keta *= 10;
            n /= 8;
        }
        cout << ans << endl;
    }
}

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

int main()
{
    int n;
    cin>>n;
    int a[n-1];
    map<int,int>m;
    for(int i=0;i<n-1;i++){
        cin>>a[i];
        m[a[i]]++;
    }
    for(int i=1;i<=n;i++)
    {
        cout<<m[i]<<endl;
    }
    return 0;
}

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

int main()
{
    long int xm=1000000,ym=10000000,a,b,m;
    long int ans=1000000;
    cin>>a>>b>>m;
    long int x[a],y[b];
    for(int i=0;i<a;i++)
        {
            scanf("%ld",&x[i]);
            xm=min(xm,x[i]);
        }
    for(int i=0;i<b;i++)
        {
            scanf("%ld",&y[i]);
            ym=min(ym,y[i]);
        }
    for(int i=0;i<m;i++)
    {
        int p,q,c;
        cin>>p>>q>>c;
        ans=min(ans,x[p-1]+y[q-1]-c);
    }
    cout<<min(ans,xm+ym);
    return 0;
}



Measured memory_bytes: 5332
from fractions import gcd

def lcm(x,y):
    return (x*y) // gcd(x,y)

A,B,C,D = map(int,input().split())

def query(a,b,k):
    r = a % k
    res = (b-(a-r))//k + (-r//k) + 1
    return res

ans = B - A + 1 - (query(A,B,C) + query(A,B,D) - query(A,B,lcm(C,D)))
print(ans)

Measured memory_bytes: 5688
def sign(pm, a)
  if pm == "+"
    a
  else
    -a
  end
end

pm = ["+", "-"]

s = gets.chomp

a = s[0].to_i
b = s[1].to_i
c = s[2].to_i
d = s[3].to_i

pm.each do |pm1|
  pm.each do |pm2|
    pm.each do |pm3|
      sum = a + sign(pm1, b) + sign(pm2, c) + sign(pm3, d)
      if sum == 7
        puts "#{a}#{pm1}#{b}#{pm2}#{c}#{pm3}#{d}=7"
        exit
      end
    end
  end
end


Measured memory_bytes: 1788
while True:
    a,op,b = [x for x in input().split( )]
    a,b = [int(y) for y in [a,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: 5604
S = input()
T = input()
def checkstr(ss):
    for (s,t) in zip(ss,T):
        check = True
        if s=="?":
            continue
        elif s!=t:
            check = False
            break
    return check
ans = ""
for i in range(len(S)-len(T)+1):
    strs = S[i:i+len(T)]
    if checkstr(strs):
        ans = S[:i].replace("?","a")+T+S[i+len(T):].replace("?","a")
if ans=="":
    print("UNRESTORABLE")
else:
    print(ans)

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

typedef long long ll;

const int INF = 1000000000;
const int MOD = 1000000007;

int main () {
    string N; cin >> N;
    cout << "ABC" + N << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int N;
cin >> N;
map<string, bool> keihin;
for(int i = 0; i < N; i++){
    string S;
    cin >> S;
keihin[S] = 1;

}
int ans = 0;
for (auto x : keihin){
ans++;

}

cout << ans <<endl;
} 

Measured memory_bytes: 19224
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
const int MAXN = 2e3, MAXM = 3e4 + 5, BOUND = 2e5, MOD = 1e9 + 7, INF = 0x3f3f3f3f, base = 10000;
const ll INFL = 0x3f3f3f3f3f3f3f3f;
const double PI = acos(-1.0), eps = 1e-9;
#define mid l + ((r-l)>>1)
#define lson o<<1,l,m
#define rson o<<1|1,m+1,r
#define lc(x) ch[x][0]
#define pii pair<int,int>
#define vi vector<int>
#define R register
#define RR register int
#define rc(x) ch[x][1]
#define rep(i,a,b) for(RR i=(a);i<=(b);++i)
#define random(a,b) ((a)+rand()%((b)-(a)+1))
int n, m, k, a[MAXN];
int main() {
	ios::sync_with_stdio(false); cin.tie(0);
	cin >> n >> m;
	if (n >= 13)cout << m << '\n';
	else if (n >= 6)cout << m / 2 << '\n';
	else cout << "0\n";
	return 0;
}

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

#define MAX_SIZE 20002
#define PLOT_DOWN '\\'
#define PLOT_FLAT '_'
#define PLOT_UP '/'

typedef struct section { int j, size; } sec_t;

int main(int argc, char **argv) {
  char buf[MAX_SIZE];
  char *ret;
  int i, j, m, n, total, sub;
  int s1[MAX_SIZE];
  sec_t tmp;
  sec_t s2[MAX_SIZE / 2];

  ret = fgets(buf, MAX_SIZE, stdin);
  if (ret == NULL) exit(1);

  for (i = m = n = total = 0; buf[i] != '\0'; ++i) {
    switch (buf[i]) {
      case PLOT_DOWN:
        s1[m++] = i;
        break;
      case PLOT_UP:
        if (m < 1) break;
        j = s1[--m];
        total += i - j;
        sub = i - j;
        while (n > 0) {
          tmp = s2[--n];
          if (j > tmp.j) {
            ++n;
            break;
          }
          sub += tmp.size;
        }
        s2[n].j = j;
        s2[n].size = sub;
        n++;
        break;
    }
  }

  printf("%d\n%d", (int) total, n);
  for (i = 0; i < n; ++i) printf(" %d", (int) s2[i].size);
  printf("\n");
  exit(0);
}


Measured memory_bytes: 2092
#pragma GCC optimize("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target ("avx")
#include <bits/stdc++.h>
constexpr int INF = 2147483647;
constexpr long long int INF_LL = 9223372036854775807;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

// *GAC
// *ACG
// *AGC

// AG*C
// AGC*
// *AGC
// A*GC

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

	//A -> 0, G -> 1, C -> 2, T -> 3
	vector<vector<vector<vector<int>>>> dp(N + 1, vector<vector<vector<int>>>(4, vector<vector<int>>(4, vector<int>(4,0))));

	for (int i = 0; i < 4; i++)for (int j = 0; j < 4; j++)for (int k = 0; k < 4; k++) {
		if (i == 0 && j == 1 && k == 2)continue;
		if (i == 0 && j == 2 && k == 1)continue;
		if (i == 1 && j == 0 && k == 2)continue;
		dp[3][i][j][k] = 1;
	}

	for (int i = 2; i < N; i++) {
		for (int j = 0; j < 4; j++)for (int k = 0; k < 4; k++)for(int s = 0; s < 4; s++) {
			for (int t = 0; t < 4; t++) {
				if (j == 0 && k == 1 && s == 2)continue;
				if (j == 0 && k == 2 && s == 1)continue;
				if (j == 1 && k == 0 && s == 2)continue;

				if (k == 1 && s == 0 && t == 2)continue;
				if (k == 0 && s == 2 && t == 1)continue;
				if (k == 0 && s == 1 && t == 2)continue;
				if (j == 0 && k == 1 && t == 2)continue;
				if (j == 0 && s == 1 && t == 2)continue;

				dp[i + 1][k][s][t] += dp[i][j][k][s];
				dp[i + 1][k][s][t] %= MOD;
			}
		}
	}

	int ans = 0;
	for (int i = 0; i < 4; i++)for (int j = 0; j < 4; j++)for(int k = 0; k < 4; k++) {
		ans += dp[N][i][j][k];
		ans %= MOD;
	}
	cout << ans << endl;
}

Measured memory_bytes: 384
# AtCoder Beginner Contest 124
# https://atcoder.jp/contests/abc124
import sys

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [sys.stdin.readline() for _ in range(n)]
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def calc(A, B):
    if A > B:
        return A + (A - 1)
    if A < B:
        return B + (B - 1)
    return A + B

def main(A, B):
    print(calc(A, B))

A, B = i2nn()
main(A, B)


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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const int N = 2e5 + 25;
vector<int> g[N];
int vis[N][4];
string s;

bool dfs(int v, int i){
	if(vis[v][i] == 2)return false;
	if(vis[v][i] == 1)return true;
	vis[v][i] = 1;
	for(int u : g[v]){
		if(s[u] == 'A'){
			if(i == 0 && dfs(u, 1))return true;
			if(i == 3 && dfs(u, 0))return true;
		}else{
			if(i == 1 && dfs(u, 2))return true;
			if(i == 2 && dfs(u, 3))return true;
		}
	}
	vis[v][i] = 2;
	return false;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout<<setprecision(32);

	int n, m;
	cin>>n>>m>>s;
	for(int i = 0; i < m; i++){
		int u, v;
		cin>>u>>v;
		u--; v--;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	memset(vis, 0, sizeof(vis));
	for(int i = 0; i < n; i++){
		if(s[i] == 'A' && vis[i][0] == 0 && dfs(i, 0)){
			cout<<"Yes\n";
			exit(0);
		}
	}
	cout<<"No\n";

	return 0;
}

Measured memory_bytes: 24416