akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N, U, V;
vector <int> Graph[int(1e5+5)];
int DistU[int(1e5+5)], DistV[int(1e5+5)];

int main(){
  cin >> N >> U >> V;
  for (int i = 0; i < N - 1; i++){
    int A, B; cin >> A >> B;
    Graph[A].push_back(B);
    Graph[B].push_back(A);
  }

  fill(DistV, DistV + N + 1, -1);
  queue <int> que; que.push(V);
  DistV[V] = 0;
  while (!que.empty()){
    int Q = que.front(); que.pop();
    for (int next : Graph[Q]){
      if (DistV[next] != -1) continue;
      DistV[next] = DistV[Q] + 1;
      que.push(next);
    }
  }

  int ans = 0;
  fill(DistU, DistU + N + 1, -1);
  que.push(U); DistU[U] = 0;
  while (!que.empty()){
    int Q = que.front(); que.pop();
    if (DistU[Q] <= DistV[Q]) ans = max(ans, DistV[Q] - 1);
    for (int next : Graph[Q]){
      if (DistU[next] != -1) continue;
      DistU[next] = DistU[Q] + 1;
      que.push(next);
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 10008
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N = 1e5 + 5;

int32_t main()
{
	IOS;
	int x, y, z;
	cin >> x >> y >> z;
	swap(x, y);
	swap(x, z);
	cout << x << " " << y << " " << z;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String line1 = scanner.nextLine();
        int count = Integer.parseInt(line1);

        if (count == 1) {
            System.out.println("Yes");
            return;
        }

        String line2 = scanner.nextLine();
        String[] token = line2.split(" ");
        int[] height = new int[count];
        for (int i = 0; i < count; i++) {
            height[i] = Integer.parseInt(token[i]);
        }

        try {
            int[] newHeight = new int[count];
            for (int i = count - 1; i > 0; i--) {
                if (i == count - 1) {
                    newHeight[i] = height[i];
                }
                int diff = height[i - 1] - newHeight[i];
                if (diff > 1) {
                    throw new RuntimeException();
                } else if (diff == 1) {
                    newHeight[i - 1] = height[i - 1] - 1;
                } else {
                    newHeight[i - 1] = height[i - 1];
                }
            }
            for (int i = 0; i < count; i++) {
                System.err.print(newHeight[i]);
                System.err.print(" ");
            }
            System.err.println();

            System.out.println("Yes");
        } catch (RuntimeException e) {
            System.out.println("No");
        }
    }

}


Measured memory_bytes: 55124
#include<iostream>
#include<math.h>
#include<algorithm>
#include<string>
using namespace std;

int main() {
	int A, B, K;
	cin >> A >> B >> K;
	for (int i = 0; i < K; i++) {
		if (i % 2 == 0) {
			if (A % 2 == 1) A--;
			B += A / 2;
			A /= 2;
		}
		else {
			if (B % 2 == 1)B--;
			A += B / 2;
			B /= 2;
		}
	}
	cout << A << " " << B << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#if __cplusplus >= 201103L
#include <unordered_map>
#include <unordered_set>
#endif
#include <vector>
#define lson rt << 1, l, mid
#define rson rt << 1 | 1, mid + 1, r
#define LONG_LONG_MAX 9223372036854775807LL
#define pblank putchar(' ')
#define ll LL
#define fastIO ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> P;
int n, m, k;
const int maxn = 1e5 + 10;
template <class T>
inline T read()
{
    int f = 1;
    T ret = 0;
    char ch = getchar();
    while (!isdigit(ch))
    {
        if (ch == '-')
            f = -1;
        ch = getchar();
    }
    while (isdigit(ch))
    {
        ret = (ret << 1) + (ret << 3) + ch - '0';
        ch = getchar();
    }
    ret *= f;
    return ret;
}
template <class T>
inline void write(T n)
{
    if (n < 0)
    {
        putchar('-');
        n = -n;
    }
    if (n >= 10)
    {
        write(n / 10);
    }
    putchar(n % 10 + '0');
}
template <class T>
inline void writeln(const T &n)
{
    write(n);
    puts("");
}
template <typename T>
void _write(const T &t)
{
    write(t);
}
template <typename T, typename... Args>
void _write(const T &t, Args... args)
{
    write(t), pblank;
    _write(args...);
}
template <typename T, typename... Args>
inline void write_line(const T &t, const Args &... data)
{
    _write(t, data...);
    puts("");
}
int main(int argc, char const *argv[])
{
#ifndef ONLINE_JUDGE
    //freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
#endif
    fastIO;
    string s;
    cin >> n >> s;
    for (int i = 0; i < s.size(); i++)
        s[i] = (s[i] - 'A' + n) % 26 + 'A';
    cout << s;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
#define int long long
#define double long double
typedef pair<int,int> P;
const int MOD = 1000000007;
const ll INF = 1e16;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 


////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////

int n,ma,mb,a[50],b[50],c[50];
vector<P> v, u;
signed main(){
  cin>>n>>ma>>mb;rep(i,n)cin>>a[i]>>b[i]>>c[i];
  int m = n/2;n -= m;
  rep(i,1<<n){
    int aa = 0, bb = 0, cc = 0;
    rep(j,n){
      if(i&(1<<j)){
        aa += a[j];bb += b[j];cc += c[j];
      }
    }
    v.push_back(P(aa*mb-bb*ma, cc));
  }
  rep(i,1<<m){
    int aa = 0, bb = 0, cc = 0;
    rep(j,m){
      if(i&(1<<j)){
        aa += a[n+j];bb += b[n+j];cc += c[n+j];
      }
    }
    u.push_back(P((bb*ma-aa*mb), cc));
  }
  int ans = INF;sort(u.begin(), u.end());

  rep(i,v.size()){
    auto itr = lower_bound(u.begin(), u.end(), P(v[i].first, (v[i].second == 0 ? 1 : 0)));
    if(itr == u.end())continue;
    if((*itr).first == v[i].first)chmin(ans, v[i].second + (*itr).second);
  }
  cout << (ans == INF ? -1 : ans) << endl;
}


Measured memory_bytes: 43108
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <math.h>
#include <string>
#include <numeric>
#include <queue>
#include <cstdio>
#include <cstring>
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define rep1(i,n) for(ll i=1;i<n;++i)
#define mrep(i,n) for(ll i=n;i>=0;--i)
#define all(a) (a).begin(),(a).end()
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vb vector<bool>
#define vvb vector<vector<bool> >
#define pl pair<ll,ll>
#define inf 1001001001001001000
//#define mod 1000000007
#define mod 998244353
#define pi 3.1415926535
using namespace std;
struct __INIT {
	__INIT() {
		cin.tie(0);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(15);
	}
}__init;



int main(void) {
	ll n;
	cin >> n;
	vl as;
	vb pitsu(1000001, false);
	vb exist(1000001, false);
	rep(i, n) {
		ll a;
		cin >> a;
		if (exist[a]) {
			pitsu[a] = true;
			continue;
		}
		if (pitsu[a]) continue;
		exist[a] = true;
		for (ll j = a + a; j <= 1000000; j += a) {
			pitsu[j] = true;
		}
		as.push_back(a);
	}
	ll cnt = 0;
	rep(i, as.size()) {
		if (pitsu[as[i]] == false) cnt++;
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 5472
#include<bits/stdc++.h>
using namespace std;
long long a[100001],n,ans;
int main()
{
    cin>>n;
    for(int i=0;i<n;i++) 
        cin>>a[i];
    sort(a,a+n);
    for(int i=0;i<n;i++) 
    {
        a[i]+=a[i-1];
        ans++;
        if(a[i]*2<a[i+1])ans=0;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1024
import numpy as np

n = int(input())
a = list(map(int,input().split()))
median = np.average(a)
idx = np.abs(np.asarray(a) - median).argmin()

ans = 0
for i in range(n):
    if a[i] == a[idx]:
        ans = i
        break
print(ans)

Measured memory_bytes: 14412
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll i,j,n,m,w,c,ans,p[109],wt[109],dp[100009][109],mp[100009];
ll func(ll w,ll i)
{
    if(mp[w]==0) mp[w]=++c;
    ll x=mp[w];
    if(dp[x][i]!=-1) return dp[x][i];
    if(i==n) return 0;
    if(w>=wt[i])
        dp[x][i]=max(p[i]+func(w-wt[i],i+1),func(w,i+1));
    else
        dp[x][i]=func(w,i+1);
    return dp[x][i];
}
int main()
{
  ios_base::sync_with_stdio(false),cin.tie(0);
  cin>>n>>w;
  memset(dp,-1,sizeof(dp));
  for(i=0;i<n;i++)
    cin>>wt[i]>>p[i];
  ans=func(w,0);
  cout<<ans<<endl;
}


Measured memory_bytes: 86272
#include <iostream>
using std::cin;
using std::cout;
using std::endl;

void swap(int& x, int& y){
    int wk = x;
    x = y;
    y = wk;
}

int main(){
    int a, b, c;
    cin >> a >> b >> c;

    if(a > b){
        swap(a, b);
    }
    // a < b
    
    if(c <= a){
        cout << c << " " << a << " " << b << endl;
    }else if(c < b){
        // a < c < b
        cout << a << " " << c << " " << b << endl;
    }else{
        // a < b < c
        cout << a << " " << b << " " << c << endl;
    }
}


Measured memory_bytes: 3088
n, k = map(int, input().split())
a = list(map(int, input().split()))
ball = {}

for i in a:
    if i in ball:
        ball[i] += 1
    else:
        ball[i] = 1

ball = sorted(ball.items(), key=lambda x: -x[1])

ans = 0
if len(ball) > k:
    for i in range(k):
        ans += ball[i][1]
    ans = n - ans
print(ans)


Measured memory_bytes: 39804
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a, b, c, d, e, k;
    cin >> a >> b >> c >> d >> e >> k;
    if(e - a > k)
    {
        cout << ":(" << endl;
    }
    else
    {
        cout << "Yay!" << endl;
    }
}



Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;

template<class T> inline T sqr(T x) {return x*x;}

void resolve() {
    int n,m,k;
    cin >> n >> m >> k;
    REP(i,0,n+1) REP(j,0,m+1) {
        int tmp = n * m - (i * m) - (j * n) + i * j * 2;
        //cerr << tmp << endl;
        if (tmp == k) {
            cout << "Yes" << endl;
            return;
        }
    }
    cout << "No" << endl;
}

int main() {
    resolve();
    
    return 0;
}

Measured memory_bytes: 256
//
//  main.cpp
//  C - Welcome to AtCoder
//
//  Created by Hashizo on 2020/01/12.
//  Copyright © 2020 Hashizo. All rights reserved.
//

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <regex>
#include <cmath>

using namespace std;
 
#undef LONG_MAX
#undef LONG_MIN
 
#define LONG_MAX    9223372036854775807
#define LONG_MIN    (-LONG_MAX  -1)
 
#define ll long long
 
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
 
#define SORT(c) sort((c).begin(), (c).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
int main(int argc, const char * argv[]) {
	ll ac = 0;
	ll ans = 0;

	ll n,m;
	cin >> n >> m;

	bool hentei[n];
	vector<ll> wa(n);

	REP(i, n) {
		hentei[i] = false;
		wa[i] = 0;
	}
	
	
	vector<ll> p(m);
	vector<string> s(m);

	REP(i, m) {
		cin >> p[i] >> s[i];
	
		if(hentei[p[i]-1] == true) {
			continue;
		}
		else {
			if(s[i] == "WA") {
				(wa[p[i]-1])++;
			}
			else if(s[i] == "AC") {
				ac++;
				hentei[p[i]-1] = true;
			}
		}
	}


	REP(i, n) {
		if(hentei[i] == true) {
			ans += wa[i];
 		}
	}
	
	cout << ac << " " << ans << endl;
	return 0;
}


Measured memory_bytes: 7424
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll sz = 1e5+5;

vector <ll> divisors(ll n)
{
    vector <ll> ara;
    for(ll i=1; i*i<=n; i++) {
        if(n%i) continue;
        ll x = i, y = n / i;
        if(x>1) ara.push_back(x);
        if(x-y) ara.push_back(y);
    }
    return ara;
}

map <ll,bool> mp;

int main()
{
    ll n;
    cin >> n;
    vector <ll> a = divisors(n);
    vector <ll> x = divisors(n-1);

    for(auto d : x) mp[d] = 1;

    for(auto d : a) {
        if(mp.find(d)==mp.end()) {
            ll y = n;
            while(y % d == 0) y /= d;
            y--;
            if(y % d == 0) mp[d] = 1;
        }
    }

    cout << mp.size() << endl;
}


Measured memory_bytes: 384
/*
    Author : manu_sy
*/
#include "bits/stdc++.h"
using namespace std;
 
/** Template Begins **/
 
typedef long long        ll;
typedef pair<int,int>    PII;
 
#define IOS         ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl        '\n'
#define pb          push_back
#define F           first
#define S           second
#define mp          make_pair
#define all(a)      (a).begin(), (a).end()
#define FOR(i,a,b)  for(int i=a;i<=b;i++)
#define LP(i,n)     for(int i=0;i< n;i++)
 
/* Debug */
 
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.F << "," << P.S << ")";
} 
 
template<class T> ostream &operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}
 
template<class TH> void _dbg(const char *sdbg, TH h){ cerr << sdbg << '=' << h << endl; }
 
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',') cerr << *sdbg++;
  cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}
 
#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif
 
/* Debug Ends */
 
const int N = 3e5+7;
 
/** Template Ends **/
int n, a[N], cnt[N];
vector<int> c, pre;

int calc(int m)
{
    int pos = lower_bound(all(c), m) - c.begin();
    int tot = (int)c.size() - pos;
    if (pos != 0)   tot += pre[pos - 1] / m;
    debug(m, tot, pos);
    return tot;
}

signed main() {
 
    IOS;
    cin >> n;
    LP(i,n)
    {
        int x;  cin >> x;
        cnt[x]++;
    }

    FOR(i,1,n) if (cnt[i] > 0) c.pb(cnt[i]);
    sort(all(c));
    pre.pb(c.front());
    FOR(i,1,(int)c.size() - 1) pre.pb(c[i] + pre[i - 1]);
    debug(c, pre);

    FOR(i,1,n)
    {
        int lo = 0, hi = n;
        while (hi - lo > 1)
        {
            int m = (hi + lo) / 2;
            if (calc(m) >= i)   lo = m;
            else hi = m;
        }
        // debug(i, lo, hi);
        if (calc(hi) >= i)  cout << hi << endl;
        else cout << lo << endl;
    }



 
    return 0;
}

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


 const int maxn = 1e6+5;
 int main(){
     int a; cin >> a;
     for(int i = 1; i <= 9; i++) {
        for(int j = 1; j <= 9; j++) {
            if(i*j==a) {
                cout << "Yes" << endl;
                return 0;
            }
        }
     }
     cout << "No" << endl;
 }


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
using namespace __gnu_pbds;
using namespace std;
/*
int dx[]={-1,1,0,0};
int dy[]={0,0,-1,1};
*/
#define ull unsigned long long int
#define ll long long int
#define MAX 1000000007
//1e9+7
#define pll pair<ll,ll>
#define pii pair<int,int>
#define IO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define FO ifstream fin("a.in");ofstream fout("a.out");
#define TEST int testcase;cin>>testcase;while(testcase--)
#define FTEST int testcase;fin>>testcase;while(testcase--)
#define all(x) (x).begin(),(x).end()
#define mset0(x) memset((x), 0, sizeof((x)));
#define mset1(x) memset((x), -1, sizeof((x)));
#define endl "\n"
#define plll pair<ll,pll>
typedef tree<ll,null_type,less<ll>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;
FO
void solve(){
    int a,b;
    cin>>a>>b;
    a*=3;
    a+=b;
    a/=2;
    cout<<a;






    return;
}
int main(){
    IO
    //TEST
    solve();
    return(0);
}


Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <map>
#include <cmath>

using ll = long long;
using namespace std;

vector <ll>  prime(ll x)
{
  vector <ll> primes;
  for( ll i=2;i<=sqrt(x);i++ )
  {
    while( x%i == 0 )
      {
	primes.push_back(i);
	x /= i;
      }
  }
  if( x!= 1 )
    primes.push_back(x);
  return primes;
}

map <ll, ll> count(vector <ll> v)
{
  map <ll, ll> counter;
  for( const auto &e: v )
    {
      auto res = counter.find(e);
      if( res == counter.end() )
	counter.insert(make_pair(e, 1));
      else
	res->second++;
    }
  return counter;
}

int main()
{
  ll N,P;
  cin >> N >> P;
 ll out = 1;
  for( const auto &e: count(prime(P)) )
    {
      for( int i=0;i<e.second/N;i++ )
	out *= e.first;
    }
  cout << out << endl;
}


Measured memory_bytes: 256
import math
import sys
n=int(input())
a=list(map(int,input().split()))
tmp=0
for i in range(n):
    if a[i]==0:
        print(0)
        sys.exit()
    else:
        t=math.log10(a[i])
        tmp+=t
    
if tmp>18:
    print(-1)
    sys.exit()
else:
    ans=1
    for i in range(n):
        ans*=a[i]
if ans>10**18:
    print(-1)
else:
    print(ans)

Measured memory_bytes: 22532
S = input()

if S == 'RRR':
    print(3)
elif S == 'RRS':
    print(2)
elif S == 'RSR':
    print(1)
elif S == 'RSS':
    print(1)
elif S == 'SRR':
    print(2)
elif S == 'SRS':
    print(1)
elif S == 'SSR':
    print(1)
else:
    print(0)


Measured memory_bytes: 9100
import java.io.InputStream;
import java.io.PrintStream;
import java.util.*;

public class Main {

  public static void main(String[] args) {
    solve(System.in, System.out);
  }

  static void solve(InputStream is, PrintStream os) {
    Scanner sc = new Scanner(is);

    /* read */
    long n = sc.nextLong();

    long sqrtn = (long) Math.sqrt(n);
    int min = Integer.MAX_VALUE;
    for (long a = 1; a <= sqrtn; a++) {
      long b = n / a;
      if (a * b != n) continue;
      min = Math.min(min, Math.max(digit(a), digit(b)));
    }
    os.println(min);
  }

  private static int digit(long x) {
    int d = 0;
    while (x > 0) {
      x /= 10;
      d++;
    }
    return d;
  }
}


Measured memory_bytes: 22740
#include<bits/stdc++.h>
#define maxn 5005
using namespace std;
const int mod = 1e9+7;
int n,coef[maxn],ans,siz[maxn],f[maxn][maxn],g[maxn];
vector<int>G[maxn];
void dfs(int u,int ff){
	siz[u]=f[u][1]=1;
	for(int v:G[u]) if(v!=ff){
		dfs(v,u);
		memset(g,0,(siz[u]+siz[v]+1)<<2);
		for(int i=1;i<=siz[u];i++)
			for(int j=1;j<=siz[v];j++){
				if(!(j&1)) g[i]=(g[i]-1ll*f[u][i]*f[v][j]%mod*coef[j])%mod;
				g[i+j]=(g[i+j]+1ll*f[u][i]*f[v][j])%mod;
			}
		siz[u]+=siz[v];
		memcpy(f[u],g,(siz[u]+1)<<2);
	}
}
int main()
{
	scanf("%d",&n);
	for(int i=1,x,y;i<n;i++) scanf("%d%d",&x,&y),G[x].push_back(y),G[y].push_back(x);
	coef[0]=1;
	for(int i=2;i<=n;i++) coef[i]=1ll*coef[i-2]*(i-1)%mod;
	dfs(1,0);
	for(int i=1;i<=n;i++) ans=(ans+1ll*f[1][i]*coef[i])%mod;
	printf("%d\n",(ans+mod)%mod);
}

Measured memory_bytes: 58700
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,b) FOR(i,0,b)
#define PB push_back
#define ALL(c) c.begin(),c.end()
using namespace std;
typedef long long LL;
typedef int ut;
typedef pair<ut,ut> pr;
typedef vector<ut> VI;
typedef vector<pr> Vpr;
const int SIZE=100;
int maps[SIZE][SIZE];
int x[SIZE],y[SIZE],t[SIZE];
int main(){
	int H,W,T,P;
	cin >> W >> H >> T >> P;
	REP(i,P){
		cin >> x[i] >> y[i] >> t[i];
	}
	REP(i,H) REP(j,W){
		cin >> maps[i][j];
	//	cout << i << j << maps[i][j] <<endl;
	}
	int ans=0;
	
	REP(j,P){
		 ans+=maps[y[j]][x[j]];
	//	 cout << x[j] <<" " <<y[j] << " " << maps[y[j]][x[j]]<< endl;
	}
	
	cout << ans << endl;

	return 0;
}

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

#define M1 1000000007
#define M2 1000000009
#define ll long long 
#define ull unsigned long long
#define ui unsigned int
#define us unsigned short
#define INF 1001001001
#define PI 3.1415926535897932384626
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define f0(i, n) for (int i = 0; i < (int)(n); ++i)
#define f1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define fc0(i,l,r) for(int i = (int)(l); i<(int)(r); ++i)
#define fc1(i, l, r) for (int i = (int)(l); i <= (int)(r); ++i)
#define fr0(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define all(x) (x).begin(), (x).end()
#define sz(a) int((a).size())
#define tr(c,i) for(typeof((c)).begin() i = (c).begin(); i != (c).end(); i++)
typedef vector<int> vi; 
typedef vector<vi> vvi; 
typedef pair<int,int> ii; 
 
void init()
{
  #ifndef ONLINE_JUDGE
      freopen("input.txt", "r", stdin);
      freopen("output.txt", "w", stdout);
      freopen("error.txt", "w", stderr);
    #endif

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(0);
    cout << fixed;
}
 
signed main()
{
    init();

    ll n;
    cin>>n;
    cout<<(n*(1+n+pow(n,2)))<<endl;

    cerr<<"time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<endl;
    return 0;
}

Measured memory_bytes: 3768
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        FastReader f = new FastReader();
        while(true) {
            String line = f.nextLine();
            int lineTemp = 0;
            if(line.equals("0")) break;

            for (char ch : line.toCharArray()) {
                lineTemp += Integer.parseInt(String.valueOf(ch));
            }
            System.out.println(lineTemp);
        }

    }

    // Helper class to speed up IO
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}


Measured memory_bytes: 24652
//-------------------------------------------
//-               Train Fare                -
//-                                         -
//-       autumn_eel niha katemasen!        -
//-------------------------------------------

#include<iostream>
#include<functional>
#include<queue>
#include<deque>
#include<vector>
#include<algorithm>
using namespace std;

inline void reader(int *x) {
	int k = getchar_unlocked(); *x = k - '0';
	while (true) {
		k = getchar_unlocked();
		if (k < '0') break;
		*x = ((*x) << 1) + ((*x) << 3) + k - '0';
	}
}
inline void writeln(int x) {
	int s = 0; char f[7];
	while (x) {
		f[s++] = x % 10;
		x /= 10;
	}
	if (!s) f[s++] = 0;
	while (s--) putchar_unlocked(f[s] + '0');
	putchar_unlocked('\n');
}
#pragma warning(disable:4996)
int n, m, q, a[200003], b[200003], c[200003], d[200003], e[100003], dist[100003], E[200003];
vector<pair<int, int> > z[100003]; vector<int> x[100003];
vector<int>D[100003];
int main() {
	reader(&n); reader(&m); reader(&q);
	fill(d, d + m + 1, 1 << 30);
	for (int i = 1; i <= m; i++) reader(&a[i]), reader(&b[i]);
	for (int i = 1; i <= q; i++) reader(&c[i]), d[c[i]] = i;
	for (int i = 1; i <= m; i++) {
		x[a[i]].emplace_back(b[i]);
		x[b[i]].emplace_back(a[i]);
	}
	fill(dist, dist + n + 1, -1); dist[1] = 0;
	queue<int> Q1; Q1.emplace(1);
	while (!Q1.empty()) {
		int a1 = Q1.front(); Q1.pop();
		for (int i : x[a1]) {
			if (dist[i] == -1) {
				dist[i] = dist[a1] + 1;
				Q1.emplace(i);
			}
		}
	}
	for (int i = 1; i <= m; i++) {
		if (dist[a[i]] > dist[b[i]]) z[a[i]].emplace_back(make_pair(b[i], d[i]));
		if (dist[b[i]] > dist[a[i]]) z[b[i]].emplace_back(make_pair(a[i], d[i]));
	}
	for (int i = 1; i <= n; i++) D[dist[i]].push_back(i);
	e[1] = (1 << 30);
	for (int i = 1; i < n; i++) {
		for (int j : D[i]) {
			for (pair<int, int>k : z[j]) {
				e[j] = max(e[j], min(e[k.first], k.second));
			}
		}
	}
	for (int i = 2; i <= n; i++) {
		if (e[i] < 300000) E[e[i]]++;
	}
	for (int i = 1; i <= q; i++) {
		E[i] += E[i - 1];
		writeln(E[i]);
	}
	return 0;
}

Measured memory_bytes: 23180
from bisect import bisect_right, bisect_left
import numpy as np

n = int(input())

top = map(int, input().split())
mid = map(int, input().split())
bot = map(int, input().split())
top = np.array(sorted(top))
mid = np.array(sorted(mid))
bot = np.array(sorted(bot))

ans = 0
for i in mid:
    top_num = len(top[:bisect_left(top,i)])
    bot_num = len(bot[bisect_right(bot,i):])
    ans += top_num * bot_num

print(ans)

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

using namespace std;

#define inputInt(a) scanf("%d", &a)
#define inputStr(a) getline(cin, a)
#define clr(a) memset(a, 0, sizeof(a))
#define print(a) cout<<a<<endl

int main()
{
    int n,k,sum,mul;
    inputInt(n);
    inputInt(k);

    int result = 1;
    for(int i = 1; i<= n; i++)
    {
        sum = result + k;
        mul = result *2;

        if(sum<mul)
            result = result + k;
        else
            result = result * 2;
    }
    print(result);

    return 0;
}


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

using namespace std;

int main()
{ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int d,n;
    cin>>d>>n;
    if(n==100)
    	n++;
   	for(int i=0;i<d;i++)
   	{
   		n=n*100;
   	}
   	cout<<n<<endl;
	return 0;

}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <iostream>
#include <utility> // pair
#include <string>
#include <vector>
#define MAX_N 51
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define FOR(i, a, b) for(ll i=a; i<b; i++)
#define REP(i, n) for(ll i=0; i<n; i++)
#define REV(i, n) for(ll i=n-1; i>=0; i--)
#define ALL(v) v.begin(), v.end()
#define pb push_back
const ll INF = 9e18;
ll n, x[MAX_N], y[MAX_N];

signed main(){
	cin >> n;
	REP(i, n) cin >> x[i] >> y[i];
	ll ret = INF;
	REP(i, n) REP(j, n){
		if(i == j) continue;
		ll p = x[i] - x[j], q = y[i] - y[j];
		vector<P> e;
		REP(k, n) REP(l, n){
			if(k == l) continue;
			if(x[k] - x[l] == p && y[k] - y[l] == q) e.pb(P(k, l));
		}
		ret = min(ret, n - (ll)e.size());

	}
	if(n == 1) ret = 1;
	cout << ret << endl;
    return 0;
}

Measured memory_bytes: 256
#include <limits.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <math.h>

#define P 1000000007

int comp(const void *a, const void *b){return *(int*)a-*(int*)b;}

int a[100000];
int main(void){
	int n, i;
	scanf("%d", &n);

	long sum=0, s=0;
	for(i=0; i<n; i++){
		scanf("%d", &a[i]);
		sum+=a[i];
		if(i&1) s+=a[i];
	}
	int b=sum-s*2;
	for(i=0; i<n; i++){
		printf("%d ", b);
		b=a[i]*2-b;
	}
	putchar(10);
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define MOD 1000000007
#define PI 3.141592653589793

int main(){
    int n;
    cin >> n;
    ull ans = 1, a = 2, b = 1;
    for(int i = 2; i <= n; i++){
        ans = a + b;
        a = b;
        b = ans;
    }
    cout << ans << endl;
}


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

const int N = 200233, mod = 1000000007;
int n, m, f[N];
char s[N];

int main() {
  scanf("%d%d%s", &n, &m, s + 1);
  if (*min_element(s + 1, s + 1 + m) == *max_element(s + 1, s + 1 + m)) {
    int x = 2, y = 1;
    for (int i = 1; i <= n; i++) {
      y = (y + x) % mod;
      x = (mod + y - x) % mod;
    }
    printf("%d\n", x);
    return 0;
  }
  int limit, x = 1;
  while (x + 1 <= m && s[x + 1] == s[1]) x++;
  limit = x | 1;
  for (int i = x + 1, j = 0; i <= m; i++) {
    if (s[i] != s[1]) {
      if (j & 1) limit = min(limit, j);
      j = 0;
    } else {
      ++j;
    }
  }
  if (n & 1) {
    puts("0");
    return 0;
  }
  n >>= 1;
  limit = min(n, (limit + 1) >> 1);
  f[0] = 1;
  for (int i = 1; i <= n; i++) {
    f[i] = ((long long) mod + f[i - 1] + f[i - 1] - (i > limit ? f[i - limit - 1] : 0)) % mod;
  }
  int ans = 0;
  for (int i = 1; i <= limit; i++) {
    ans = (ans + (long long) (mod + f[n - i] - (n > i ? f[n - i - 1] : 0)) * i * 2) % mod;
  }
  printf("%d\n", ans);
}



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

lli a, b, c, k;

int main(void){
	cin >> a >> b >> c >> k;
	if(k%2 == 0) cout << a-b << endl;
	else cout << b-a << endl;
	return 0;
}


Measured memory_bytes: 3616
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <set>
#include <map>
#include <cassert>
#include <fstream>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int main() {
    
    
    int n;
    cin >> n;
    
    priority_queue<double, vector<double>, greater<double>> q;
    
    for (int i = 0; i < n; ++i)
    {
        double v;
        cin >> v;
        q.push(v);
    }
    
    while (q.size() > 1)
    {
        double v1, v2;
        v1 = q.top();
        q.pop();
        v2 = q.top();
        q.pop();
        q.push((v1 + v2) / 2.0);
    }
    
    double ret = q.top();
    cout << fixed << setprecision(10) << ret << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<climits>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<list>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<utility>
#include<vector>

using namespace std;

#define lint long long
#define REP(i, x, n) for(int i = x ; i < n ; i++)
#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for(int i = n - 1 ; i >= 0 ; i--)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())
#define IINF (int)(1e9+10)
#define LLINF (lint)(1e18+10)

int main(){
    while(true){
        int n;
        cin >> n;
        if(n == 0){
            break;
        }
        string in;
        getline(cin, in);
        map<string, int> mp;
        set<string> st;
        rep(i, n){
            getline(cin, in);
            int j = 0;
            rep(k, in.size()){
                if(in[k] == ' '){
                    mp[in.substr(j, k-j)]--;
                    st.insert(in.substr(j, k-j));
                    j = k+1;
                }else if(k == in.size()-1){
                    k++;
                    mp[in.substr(j, k-j)]--;
                    st.insert(in.substr(j, k-j));
                }
            }
        }
        char c;
        cin >> c;
        priority_queue< pair<int, string>, vector< pair<int, string> >, greater< pair<int, string> > > que;
        for(auto x = st.begin() ; x != st.end() ; x++){
            string tmp = *x;
            if(tmp[0] == c){
                que.push(make_pair(mp[tmp], tmp));
            }
        }
        if(que.empty()){
            cout << "NA" << endl;
        }else{
            int cnt = 0;
            while(!que.empty() && cnt < 5){
                cout << que.top().second;
                que.pop();
                cnt++;
                if(que.empty() || cnt == 5){
                    cout << endl;
                }else{
                    cout << " ";
                }
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3072
n = int(input())
fll = []
pll = []

for _ in range(n):
    fl = list(map(int,input().split()))
    fll.append(fl)

for _ in range(n):
    pl = list(map(int,input().split()))
    pll.append(pl)

ans = -float("inf")
from itertools import product
for bits in product([0, 1], repeat=10):
    if sum(bits) == 0:
        continue
    tmp = 0
    for fl, pl in zip(fll, pll):
        count = 0
        for f, bit in zip(fl, bits):
            if f and bit:
                count += 1
        tmp += pl[count]
    ans = max(ans, tmp)

print(ans)


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

int main(void) {
  char a[8];
  scanf("%s",a);
  if(strcmp(a,"Sunny")==0)printf("Cloudy");
  else  if(strcmp(a,"Rainy")==0)printf("Sunny");
  else  if(strcmp(a,"Cloudy")==0)printf("Rainy");
	return 0;
}


Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String str = br.readLine();

    StringTokenizer st = new StringTokenizer(str);

    int x = Integer.parseInt(st.nextToken());
    int a = Integer.parseInt(st.nextToken());
    int b = Integer.parseInt(st.nextToken());

    if (a - b >= 0) {
      System.out.println("delicious");
    } else {
      if (x + a - b >= 0) {
        System.out.println("safe");
      } else {
        System.out.println("dangerous");
      }
    }
    
  }
}


Measured memory_bytes: 22868
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	int arr[n+2]={0};
	for(int i=1; i<=n; i++) cin>>arr[i];
	int cost = 0;
	for(int i=0; i<=n; i++) cost+=abs(arr[i]-arr[i+1]);
	for(int i=1; i<=n; i++){
		int curr = cost-abs(arr[i]-arr[i-1])-abs(arr[i]-arr[i+1]);
		curr+=abs(arr[i-1]-arr[i+1]);
		cout<<curr<<'\n';
	}
}

Measured memory_bytes: 3960
#include<bits/stdc++.h>
using namespace std;
using ll =long long;
#define SORT(i) sort((i).begin(),(i).end())
#define INF 2000000000
constexpr ll mod = 1000000007;

int coudp[100001];

int main() {
	int N, M;
	cin >> N >> M;
	priority_queue<ll>que;
	for (int i = 0;i < N;++i) {
		ll a;
		cin >> a;
		que.push(a);
	}
	for (int i = 0;i < M;++i) {
		ll b = que.top();
		que.pop();
		que.push(b / 2);
		if (que.top() == 0)break;
	}
	ll cnt = 0;
	for (int i = 0;i < N;++i) {
		cnt += que.top();
		que.pop();
	}
	cout << cnt << "\n";
	return 0;
}

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

int main(){

	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	int q;
	cin >> q;
	for (int i = 0; i < q; i++) {
		int b, m, e;
		cin >> b >>m >> e;
		rotate(a.begin() + b, a.begin() + m, a.begin() + e);
	}
	for (int i = 0; i < n; i++) cout << (i == 0 ? "" : " ") << a[i];
	cout << endl;
	return 0;
}


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

int main() {
	int N, M;
	cin >> N >> M;
	char A[N][N], B[M][M];
	for (int i=0; i<N; i++){
	    for (int j=0; j<N; j++){
	        cin >> A[i][j];
	    }
	}
	for (int i=0; i<M; i++){
	    for (int j=0; j<M; j++){
	        cin >> B[i][j];
	    }
	}
	for (int i=0; i<N-M+1; i++){
	    for (int j=0; j<N-M+1; j++){
	        bool found=true;
	        for (int k=0; k<M; k++){
	            for (int l=0; l<M; l++){
	                if (A[i+k][j+l]!=B[k][l]){
	                    found=false;
	                }
	            }
	        }
	        if (found){
	            cout << "Yes" << endl;
	            return 0;
	        }
	    }
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#n = int(input())
def prime(n):
    if n <=1:
        return False
    for i in range(2, n):
        if n%i == 0:
            return False
    return True
if __name__ == "__main__":
    n = int(input())
    while not prime(n):
        n+=1
    print(n)
    


Measured memory_bytes: 9104
package main

import (
	"fmt"
)

func main() {
	var n int
	var s string
	fmt.Scanf("%d", &n)
	fmt.Scanf("%s", &s)

	rotted := []byte{}
	for _, b := range s {
		rotted = append(rotted, byte((int(b)-65+n)%26)+65)
	}

	fmt.Println(string(rotted))
}


Measured memory_bytes: 768
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
long long mod = 177777777777777, power[300], cnt;
string S, T; vector<long long>U1[4400], U2[4400];
void solve(string S1, int r) {
	for (int i = 0; i < S1.size(); i++) {
		long long ret = 0;
		for (int j = i; j < S1.size(); j++) {
			ret += power[S1[j]]; ret %= mod;
			if (r == 1)U1[j - i + 1].push_back(ret);
			if (r == 2)U2[j - i + 1].push_back(ret);
		}
	}
}
int main() {
	cin >> S >> T; power[0] = 1; for (int i = 1; i < 300; i++)power[i] = power[i - 1] * 3141LL % mod;
	solve(S, 1); solve(T, 2); int maxn = 0;
	for (int i = 1; i < 4400; i++) {
		cnt = 0; sort(U2[i].begin(), U2[i].end());
		for (int j = 0; j < U1[i].size(); j++) {
			int pos1 = lower_bound(U2[i].begin(), U2[i].end(), U1[i][j]) - U2[i].begin();
			int pos2 = lower_bound(U2[i].begin(), U2[i].end(), U1[i][j] + 1) - U2[i].begin();
			cnt += (long long)(pos2 - pos1);
		}
		if (cnt >= 1) { maxn = max(maxn, i); }
	}
	cout << maxn << endl;
	return 0;
}

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

#define INF 1001001001
#define LINF 1001001001001001001
#define MOD 1000000007
#define MOD2 998244353

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

#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)
#define rep1(i,a,b) for(int a_=(a),b_=(b),i=a_;i<b_;++i)
#define repr(i,n) for(int _i=(n),i=_i;i>0;--i)

#define db(x) cerr<<#x<<" = "<<x<<" ";
#define db2(x,y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<") ";
#define db3(x,y,z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = ("<<x<<", "<<y<<", "<<z<<") ";
#define ln cout<<endl;

#define all(a)  (a).begin(),(a).end()
#define dig(n)  to_string(n).length()

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define se second
#define fi first

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,pii> ppii;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main(){

    bool flag=false;
    ll ans=0,sum=0;

    int a,b,c;
    cin>>a>>b>>c;

    if(a==b)cout<<c<<endl;
    else if(b==c)cout<<a<<endl;
    else cout<<b<<endl;
    //cout <<fixed<<setprecision(16)<< << endl;
    //if(flag)cout << "Yes" <<endl;
    //else cout << "No" <<endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define REPr(i,n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define FORqr(i, m , n) for(int i = (n);i >=(m);--i)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define VSCD(v,N) REP(i,N){int (x); SCD(x); v.PB(x);}
#define VSCLLD(v,N) REP(i,N){long long (x); SCLLD(x); v.PB(x);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n)
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x,S) (S.count(x) != 0)
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x,y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef pair<int,int> PII;
typedef pair<long long,long long> PLL;
typedef vector<int> VI;
typedef vector < VI > VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
const ll MOD = 1000000007;
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}

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;
}
///////////////////////////////////////////////
int main(){
    string s;
    getline(cin,s);

    REP(i,3){
        if (s[i] == '1') s[i] = '9';
        else s[i] = '1';
    }

    cout << s << "\n";
}



Measured memory_bytes: 256
s=input()
if 1<=int(s[:2])<=12:
    if 1<=int(s[2:])<=12:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if 1<=int(s[2:])<=12:
        print("YYMM")
    else:
        print("NA")

Measured memory_bytes: 9092
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <random>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int dx[] = {-1,-1,-1,0,0,1,1,1};
int dy[] = {-1,0,1,-1,1,-1,0,1};

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

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define PI acos(-1)
typedef  long long ll;
ll gcd(ll x,ll y){
   if(y==0) return x;
   else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
   return x/gcd(x,y)*y;
}
using namespace std;

int main(){
   int n;
   cin>>n;
   vector<int> a(n,0);

   rep(i,n){
      cin>>a[i];
   }

   ll count=0;

   rep(i,n){
      do{
         if(a[i]%2==0) {
            count++;
            a[i]/=2;
         }
      }while(a[i]%2!=1);
   }

   cout<<count;

   
return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int> >
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define inf 1000000000000000000

using namespace std;

signed main(){
    int h,w;
    cin>>h>>w;
    char a[h][w];
    rep(i,h){
        cin>>a[i];
    }
    set<int> vh;
    rep(i,h){
        bool f=true;
        rep(j,w){
            if(a[i][j]=='#'){
                f=false;
                break;
            }
        }
        if(f)vh.insert(i);
    }
    set<int> vw;
    rep(i,w){
        bool f=true;
        rep(j,h){
            if(a[j][i]=='#'){
                f=false;
                break;
            }
        }
        if(f)vw.insert(i);
    }
    rep(i,h){
        if(vh.find(i)==vh.end()){
            rep(j,w){
                if(vw.find(j)==vw.end()){
                    cout<<a[i][j];
                }
            }
            cout<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 896
import java.util.*;
public class Main {// Main


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

		String a = sc.next();
		if(a.equals("ABC")) {
			System.out.println("ARC");
		}else {
			System.out.println("ABC");
		}
			}

	}


Measured memory_bytes: 35596
def horizontal_input(T=str):
    return list(map(T,input().split()))

def vertical_input(n,T=str,sep=False,septype=tuple):
    data=[]
    if sep:
        for i in range(n):
            data.append(septype(map(T,input().split())))
    else:
        for i in range(n):
            data.append(T(input()))
    return data

d='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
while 1:
    n=int(input())
    if n==0:
        break
    data=horizontal_input(int)
    s=input()
    ans=[]
    i=0
    for c in s:
        ans.append(d[d.find(c)-data[i]])
        i=(i+1)%len(data)
    print(''.join(ans))


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

int main()
{
    double a,ans;
    while(cin>>a)
    {
        double ns[10]={a,0};
        ans=a;
        for(int i=1;i<10;++i){
            if(i%2)ns[i]=ns[i-1]*2;
            else ns[i]=ns[i-1]/3;
            ans+=ns[i];
        }
        cout<<setprecision(10)<<ans<<endl;
    }
}

Measured memory_bytes: 1276
// Snake Toy
#include <iostream>
#include <algorithm>
using namespace std;

int main() {
    int N, K;
    int L[60];
    int su = 0;
    cin >> N >> K;
    for (int i = 0; i < N; ++i) cin >> L[i];
    sort(L, L+N, greater<int>());
    for (int k = 0; k < K; ++k) su += L[k];
    cout << su << endl;
}

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

int main() 
{
    ll n, m;
    cin >> n >> m;
    vector<ll> dp(n+1,0);
    for (ll i=0; i<m; i++)
    {
        ll a;
        cin >> a;
        dp[a] = -1;
    }
    dp[0] = 1;
    if (dp[1] == 0)
        dp[1] = 1;
    else 
        dp[1] = 0;
    for (ll i=2; i<=n; i++)
    {
        if (dp[i] != -1)
            dp[i] = dp[i-1] + dp[i-2] % MOD;  
        else 
            dp[i] = 0;
        // cout << dp[i];
    }
    
    cout << dp[n] % MOD;
    return 0;
}

Measured memory_bytes: 1024