akhauriyash/Code-Regression huggingface dataset:
import math
import fractions
#import sys
#input = sys.stdin.readline

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

def ValueToBits(x,digit):
    res = [0 for i in range(digit)]
    now = x
    for i in range(digit):
        res[i]=now%2
        now = now >> 1
    return res

def BitsToValue(arr):
    n = len(arr)
    ans = 0
    for i in range(n):
        ans+= arr[i] * 2**i
    return ans

def ZipArray(a):
    aa = [[a[i],i]for i in range(n)]

    aa.sort(key = lambda x : x[0])
    for i in range(n):
        aa[i][0]=i+1
    aa.sort(key = lambda x : x[1])
    b=[aa[i][0] for i in range(len(a))]
    return b

def ValueToArray10(x, digit):
    ans = [0 for i in range(digit)]
    now = x
    for i in range(digit):
        ans[digit-i-1] = now%10
        now = now //10
    return ans

def Zeros(a,b):
    if(b<=-1):
        return [0 for i in range(a)]
    else:
        return [[0 for i in range(b)] for i in range(a)]

class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)
 
    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s
 
    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i
            
'''
def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

p = 2
N = 10 ** 6 + 2
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用

for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

'''

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

#################################################
#################################################
#################################################
#################################################


n = int(input())
c = list(map(int, input().split()))
a = []
for i in range(n):
    temp = list(map(int, input().split()))
    a.append(temp)

ans = [(i%26) for i in range(n)]

def cost(a,c,ans):
    val = 0
    last = [0 for i in range(26)]
    for i in range(n):
        for j in range(26):
            last += 1
        here = ans[i]
        val += a[i][here]
        last[here] = 0
        for j in range(26):
            val -= last[j]*c[j]
    return val
#

for i in range(n):
    maxim = -10**9
    idx = -1
    for j in range(26):
        if(maxim < a[i][j]):
            idx = j
            maxim = a[i][j]
    ans[i] = idx
#print(ans)

#d = [[i,c[i]]]

for i in range(n):
    if(i//26%2==0):
        print(ans[i]+1)
    else:
        print(i%26+1)










Measured memory_bytes: 79000
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<string>
#include <iomanip>
#include<deque>
#include<queue>
#include<stack>
#include<set>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e9;

//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用
#define ret return 0

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

#define keta setprecision(15) //15桁表示


int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	ll x;
	cin >> x;
	ll tmp = x;
	ll ket = 0;
	while (tmp>0)
	{
		ket++;
		tmp /= 10;
	}

	if (x % 100 <= x / 100 * 5)
	{
		cout << 1 << endl;
	}
	else
	{
		cout << 0 << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

long long int n, res, a[200002];
int main()
{
    cin >> n;
    for(int i = 1; i <= n; ++i)
    {
        cin >> a[i];
    }
    for(int i = 1; i < n; ++i)
    {
        if(a[i+1] < a[i])
        {
            res += (a[i] - a[i+1]);
            a[i+1] = a[i];
        }
    }
    cout << res;
    return 0;
}


Measured memory_bytes: 5152
#!/usr/bin/env python3


def main():
    N = list(input())
    if N[-1] in ['2' , '4', '5', '7', '9']:
        print('hon')
    elif N[-1] == '3':
        print('bon')
    else:
        print('pon')


if __name__ == "__main__":
    main()


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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int MAXN = 2e5 + 5;

int ans[MAXN];
int used[MAXN];

void add_number(int pos, int val){
	ans[pos] = val;
	used[val] = 1;
}

void solve(){
	int n, k;
	scanf("%d%d", &n, &k);
	if (k == 1 || k == 2 * n - 1){
		printf("No\n");
		return;
	}
	add_number(n, k);
	add_number(n - 1, k - 1);
	add_number(n + 1, k + 1);
	if (n > 2 && k == 2){
		add_number(n - 2, k + 2);
	} else if (n > 2 && k > 2){
		add_number(n + 2, k - 2);
	}
	for(int i = 1, ind = 1; i <= 2 * n - 1; i++){
		if (ans[i] == 0){
			for(; used[ind] == 1; ind++);
			add_number(i, ind);
		}
	}
	printf("Yes\n");
	REPN(i, 1, 2 * n - 1){
		printf("%d\n", ans[i]);
	}
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


Measured memory_bytes: 3072
#include <iostream>
#include <stdio.h>
using namespace std;

int main(void) {
	int H, W;
	while (1) {
		cin >> H >> W;
		if (H ==0 && W == 0) break;
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				if (i == 0 || j == 0 || i == H - 1 || j == W - 1)
					cout << "#";
				else
					cout << ".";
			}
			cout << endl;
		}
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 3080
r, g, b, n = map(int, input().split())

ans = 0
for i in range(1+n//r):
  tmp = n - r*i
  for j in range(1+tmp//g):
    mod = (n - g*j - r*i)%b
    if mod == 0:
      ans += 1
        
print(ans)

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

using namespace std;

int main(){
    int a, b, c;
    cin>>a>>b>>c;
    string s="Yes";
    if(a==b&&b==c){
        s="No";
    }
    else if(a!=b&&b!=c&&c!=a){
        s="No";
    }
    cout<<s<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
using namespace std;
int main(void){
   int n;
   cin >> n;
   vector<bool> isPrime(10e5 + 1,true);
   isPrime[0] = isPrime[1] = false;
   for(int i = 2;i * i <= 100000;i++){
       for(int j = 2;i * j <= 100000;j++){
           isPrime[i * j] = false;
       }
   }
   
   for(int i = n;i <= 100000;i++){
       if(isPrime[i]){
           cout << i << endl;
           return 0;
       }
   }
   cout << 100003 <<endl;
    
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define len(x) ((ll)(x).size())
#define debug(var) cout << "[" << #var << "]\n" << var << "\n\n"
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;
const double EPS = 1e-9;

template <typename T>
ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i];
    if (i < len - 1)
      s << ' ';
  }
  return s;
}

template <typename T>
ostream& operator<<(ostream& s, const vector<vector<T>>& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i];
    if (i != len - 1)
      cout << '\n';
  }
  return s;
}

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

__attribute__((constructor)) void initial() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}


signed main() {
  int N, K;
  cin >> N >> K;
  vector<ll> a(N);
  rep(i, N) {
    cin >> a[i];
  }

  vector<ll> sum(N + 1);
  rep(i, N) {
    sum[i + 1] = sum[i] + a[i];
  }

  vector<ll> wa;
  rep(l, N) {
    repp(r, l + 1, N) {
      wa.pb(sum[r] - sum[l]);
    }
  }
  int M = len(wa);

  // rep(i, len(wa)) {
  //   cout << bitset<4>(wa[i]) << "\n";
  // }

  set<ll> s;
  rep(i, M) {
    s.insert(wa[i]);
  }

  ll ans = 0;
  repr(b, 60, 0) {
    int cnt = 0;
    for (ll elem : s) {
      if ((1LL << b) & elem)
        cnt++;
    }
    if (cnt < K)
      continue;

    ans += (1LL << b);
    rep(i, M) {
      if (!((1LL << b) & wa[i]))
        s.erase(wa[i]);
    }
  }
  cout << ans << "\n";
}

Measured memory_bytes: 29732
t = 0
while t == 0:	
	p = 0
	try:
		n = int(input())
	except:
		break
	else:
		for a in range(10):
			for b in range(10):
				for c in range(10):
					for d in range(10):
						if (a+b+c+d == n):
							p += 1
	print(p)

Measured memory_bytes: 7704
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define pii pair<int,int>
main()
{
    int n;
    cin>>n;
    int temp=n,k=0;
    while(temp>0)
    {
       if(temp%10==7) k++;
       temp=temp/10;
    }
    if(k>0) cout<<"Yes"<<endl; else cout<<"No"<<endl;
}


Measured memory_bytes: 3640
import java.util.ArrayList;
import java.util.Scanner;
 
public class Main {
 
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
	    int n=sc.nextInt();
	    long a=-1;long b=-1; 
	    for(int i=1;i<=n;i++)
	    {
	        long x=sc.nextLong();
	        long y=sc.nextLong();
	        if(x>=a&&y>=b)
	        {
	            a=x;
	            b=y;
	        }
	        else
	        {
	           long st=(a%x==0)?a/x:a/x+1;
	           long en=(b%y==0)?b/y:b/y+1;
	           long dx=Math.max(st,en);
	           a=dx*x;
	           b=dx*y;
	        }
	    }
	    System.out.println(a+b);
	}}

Measured memory_bytes: 26452
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const ld EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

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

const int MAX_V = 1000;
vector<edge> es;
vector<ll> d(MAX_V);

//sから到達可能な負の経路を検出
bool bellman_ford(int s){
    fill(all(d), INF);
    d[s] = 0;
    bool ret = false;
    rep(i, 2*MAX_V){
        for(auto &e: es){
            if(d[e.from] == INF) continue;
            if(chmin(d[e.to], d[e.from]+e.cost)){
                if(i >= MAX_V-1) d[e.to] = -INF, ret = true;
            }
        }
    }
    return ret;
}

//全ての負の閉路を検出
bool negative_loop(){
    fill(all(d), 0);
    rep(i, MAX_V){
        for(auto &e: es){
            if(chmin(d[e.to], d[e.from]+e.cost)){
                if(i == MAX_V-1) return true;
            }
        }
    }
    return false;
}

int main(){
    int N, M;
    cin >> N >> M;
    rep(i, M){
        int u, v; ll c;
        cin >> u >> v >> c;
        u--, v--;
        es.eb((edge){u, v, -c});
    }
    bellman_ford(0);
    if(d[N-1] == -INF) cout << "inf" << endl;
    else cout << -d[N-1] << endl;
}

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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
 
    string s; cin >> s;
  	int n = s.size();
  	int a = 0; int b = 0;
  	for(auto u:s){
    	if(u=='g'){
          a++;
        }
      	else{
          b++;
        }
        
    }
  	cout << (a-b)/2;
    
 
    return 0;
}


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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFやMODの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const ll MOD = 1000000007;

int main() {
  int n;
  cin >> n;
  ll ans = 0;
  rep(i, n + 1) if (i % 3 && i % 5) ans += i;
  cout << ans << endl;
}


Measured memory_bytes: 3620
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
#include<iostream>
#include<map>
#include<string>
#include<bitset>

#define maxn 5005
#define MOD 1000000007

using namespace std;

inline long long getint()
{
	long long num=0,flag=1;char c;
	while((c=getchar())<'0'||c>'9')if(c=='-')flag=-1;
	while(c>='0'&&c<='9')num=num*10+c-48,c=getchar();
	return num*flag;
}

int n;
int fir[maxn],nxt[maxn<<1],to[maxn<<1],cnt;
int f[maxn][maxn],g[maxn],tmp[maxn];
int sz[maxn];

inline void newnode(int u,int v)
{to[++cnt]=v,nxt[cnt]=fir[u],fir[u]=cnt;}

inline void dfs(int u,int fa)
{
	sz[u]=1;f[u][1]=1;
	for(int i=fir[u];i;i=nxt[i])if(to[i]!=fa)
	{
		int v=to[i];dfs(v,u);
		for(int j=0;j<=sz[u]+sz[v];j++)tmp[j]=0;
		for(int j=1;j<=sz[u];j++)for(int k=0;k<=sz[v];k++)
			tmp[j+k]=(tmp[j+k]+1ll*f[u][j]*f[v][k])%MOD;
		sz[u]+=sz[v];
		for(int j=1;j<=sz[u];j++)f[u][j]=tmp[j];
	}
	for(int i=2;i<=sz[u];i+=2)f[u][0]=(f[u][0]+MOD-1ll*f[u][i]*g[i]%MOD)%MOD;
}

int main()
{
	n=getint();
	for(int i=1;i<n;i++)
	{
		int u=getint(),v=getint();
		newnode(u,v),newnode(v,u);
	}
	g[0]=1;
	for(int i=2;i<=n;i+=2)g[i]=1ll*g[i-2]*(i-1)%MOD;
	dfs(1,0);
	printf("%d\n",MOD-f[1][0]);
}

Measured memory_bytes: 58224
#include <stdio.h>
#include <math.h>
int main(){
int a,b,i=100000;
double d;
scanf ("%d",&a);
for (b=0;b<a;b++){
d=i;
d*=1.05;
i=d;
if (i%1000 > 0){
i=i/1000*1000;
i+=1000;
}
}
printf ("%d\n",i);
return 0;
}


Measured memory_bytes: 2020
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int x,y;
    while (1){
    scanf("%d %d",&x,&y);
    if(x==0&&y==0){
            break;
        }

    if(x<y){
        printf("%d %d\n",x,y);
    } else {
        printf("%d %d\n",y,x);
    }
    }
    return 0;
}

Measured memory_bytes: 600
//
// Created by yuu on 2019-04-23.
//

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <math.h>
#include <stack>
#include <queue>

using namespace std;

struct data{
    int a;
    int b;
};


int main(void){
    int N,M;

    cin>>N>>M;

    vector<data>test(100100);


    for (int i = 0; i < N; ++i) {
        cin>>test[i].a>>test[i].b;
    }

    sort(test.begin(), test.begin()+N, [](const data& pre, const data& next){
        return pre.a < next.a;
    });

//    for (int i = 0; i < N; ++i) {
//        cout<<test[i].a<<"b is "<<test[i].b<<endl;
//    }

    long long ans = 0;
    for (int i = 0; i < N; ++i){

        while(test[i].b > 0){
            if(M==0){
                break;
            }
            M--;
            test[i].b --;
            ans += test[i].a;
        }
        if(M==0){
            break;
        }
    }

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int c = 0;
string s, t;
int main()
{
    cin.sync_with_stdio(0); cin.tie(0);
    cin >> s >> t;
    for(int i = 0; i < s.length(); i++){
        if(s[i] != t[i])c++;
    }cout << c << endl;
    return 0;
}


Measured memory_bytes: 3808
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  double A, B, H, M;
  double PI = 3.14159265358979;
  cin >> A >> B >> H >> M;
  double t0 = 2.0 * PI * H / 12.0;
  t0 += 2.0 * PI / 12.0 * M / 60.0;
  double t1 = 2.0 * PI * M / 60.0;
  double C2 = A * A + B * B - 2 * A * B * cos(t0 - t1);
  double C = sqrt(C2);
  printf("%.12f\n", C);
}

Measured memory_bytes: 4244
//ABC136 A - Transfer
//20190905

using System;
using System.Linq;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            // Console.WriteLine("Hello World!");
            var INPUT = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int A = INPUT[0];
            int B = INPUT[1];
            int C = INPUT[2];

            int OUTPUT = C - (A-B);
            
            Console.WriteLine(OUTPUT >=0 ? OUTPUT : 0);

        }
    }
}


Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define ANS cout << ans << endl
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define REVERSE(a) reverse(all(a))
#define int long long
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define VIin(a) for(int i=0; i<a.size(); i++) cin >> a[i]
#define OUT(a) cout << a << endl
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
/*最大公約数*/int gcd(int x, int y) { return y ? gcd(y,x%y) : x;}
/*最小公倍数*/int lcm(int a, int b) { int g = gcd(a, b); return a / g * b; }
/*素数判定*/int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*約数列挙*/vector<int> getDivisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------------------------------------
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout<<fixed<<setprecision(15);
    
    double a,b,x; cin >> a >> b >> x;
    double h = x / a/ a*2-b;
    double ans;
    if(h >= 0) ans = atan2(b-h,a);
    else{
        h = x / a*2 / b;
        ans = atan2(b,h);
    }
    ans = ans / M_PI * 180;
    ANS;

    return 0;
}

Measured memory_bytes: 256
H, W, K = map(int, input().split())
C = []
for _ in range(H):
  C.append(input())

ans = 0
for h in range(2 ** H):
  for w in range(2 ** W):
    count = 0
    for i in range(H):
      for j in range(W):
        if ((h >> i) & 1) == 0 and ((w >> j) & 1) == 0:
          if C[i][j] == '#':
            count += 1
    if K == count:
      ans += 1

print(ans)

Measured memory_bytes: 9136
#include<iostream>
#include<queue>
#include<algorithm>
#include<cstring>
using namespace std;

int main()
{
  int w,h;
  for(;cin>>w>>h,w;)
    {
      int maps[h][w];
      for(int i=0;i<h;i++)
	for(int j=0;j<w;j++)
	  {
	    cin>>maps[i][j];
	  }
      int c[4];
      for(int i=0;i<4;i++)
	cin>>c[i];

      //cost,move,now;
      priority_queue<pair<pair<int,int>,pair<int,int> > > qu;
      qu.push(make_pair(make_pair(0,0),make_pair(0,0)));
      
      pair<int,int> goal=make_pair(h-1,w-1);
      int dx[]={0,1,0,-1};
      int dy[]={1,0,-1,0};
      bool closed[4][h][w];
      memset(closed,false,sizeof(closed));
      while(!qu.empty())
	{
	  int cost=-qu.top().first.first;
	  int move=qu.top().first.second;
	  pair<int,int> now=qu.top().second;
	  qu.pop();
	  if(now==goal)
	    {
	      cout<<cost<<endl;
	      break;
	    }
	  int x=now.first;
	  int y=now.second;
	  //  cout<<cost<<" "<<move<<" <"<<x<<","<<y<<">"<<endl;
	  if(closed[move][x][y])
	    continue;
	  closed[move][x][y]=true;
	  
	  for(int i=0;i<4;i++)
	    {
	      int add=0;
	      if(maps[x][y]!=i)
		add=c[i];
	      if(x+dx[move]>=0 && x+dx[move]<h &&
		 y+dy[move]>=0 && y+dy[move]<w &&
		 !closed[move][x+dx[move]][y+dy[move]])
		qu.push(make_pair(make_pair(-(cost+add),move),
				  make_pair(x+dx[move],y+dy[move])));
	      move=(move+1)%4;
	    }
	}
    }

}

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

int main(void){
  while(1){
    int n, m;
    cin >> n;
    cin >> m;
    if(n == 0 && m == 0){return 0;}

    int t[n]; int sumt = 0;
    int h[m]; int sumh = 0;
    for(int i = 0 ; i < n ; i++){cin >> t[i]; sumt += t[i];}
    for(int i = 0 ; i < m ; i++){cin >> h[i]; sumh += h[i];}

    int diff = sumt - sumh;
//    cout << diff << endl;

    int tans, hans;
    int min = 99999;

    for(int i = 0 ; i < n ; i++){
      for(int j = 0 ; j < m ; j++){

//        cout << "> " << t[i] - h[j] << endl;

        if(diff == 2*(t[i] - h[j])){

          if(t[i] + h[j] < min){
            min = t[i] + h[j];
            tans = t[i];
            hans = h[j];
          }

        }

      }
    }

    if(min != 99999){
      cout << tans << " " << hans << endl;
    }else{
      cout << -1 << endl;
    }
  }
}

Measured memory_bytes: 3068
import java.util.Map.Entry;
import java.io.*;
import java.util.*;

public class Main {
	
	public static void main(String[] args) throws IOException {
		FastScanner sc = new FastScanner(System.in);
		
		int N = sc.nextInt();
		long[] a = new long[3*N];
		for(int i = 0; i < 3*N; i++) a[i] = sc.nextLong();
		Arrays.sort(a);
		long ans = 0;
		for(int i = N; i < 3*N; i += 2) ans += a[i];
		System.out.println(ans);
	}
}

class Edge{
	int to;
	long cost;
	public Edge(int t, long c){
		to = t;
		cost = c;
	}
}

class FastScanner {
    private InputStream in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    public FastScanner(InputStream in) {
		this.in = in;
	}
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() {
    	if (hasNextByte()) return buffer[ptr++];
    	else return -1;
    }
    private static boolean isPrintableChar(int c){
    	return 33 <= c && c <= 126;
    }
    public boolean hasNext() {
    	while(hasNextByte() && !isPrintableChar(buffer[ptr]))
    		ptr++; return hasNextByte();
    }
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() {
    	return Double.parseDouble(next());
    }
}


Measured memory_bytes: 26460
#include <iostream>

using namespace std;

int main(){
  	int N,res=0;
  	cin >> N;
  	for(int i=1; i <= N; i++){
    	if( (1<=i&&i<=9) || (100<=i&&i<=999) || (10000<=i&&i<=99999)){
        	res++;
        }
    }
  	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
def s():
 W=int(input().split()[1])
 C=[0]*-~W
 for e in sys.stdin:
  v,w=map(int,e.split())
  for i in range(W,w-1,-1):
   t=v+C[i-w]
   if t>C[i]:C[i]=t
 print(C[W])
s()


Measured memory_bytes: 5928
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
#include <cassert>
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;
typedef pair<int,int> PI;
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define MP make_pair
#define PB push_back

char s,e;

main(){
  int n;
  while(cin>>n,n){
    queue<int> in[26],out[26];
    string str;
    rep(i,n){
      cin>>str;
      s=str[0]-'a',e=str[str.size()-1]-'a';
      in[s].push(e);
      out[e].push(s);
    }

    bool ok=true;
    rep(i,26){
      if(in[i].size()!=out[i].size()){
        ok=false;
      }
    }

    queue<int> Q;
    Q.push(s);

    while(!Q.empty()){
      int n=Q.front();Q.pop();
      while(!in[n].empty()){
        Q.push(in[n].front());in[n].pop();
      }
    }
    rep(i,26){
      if(!in[i].empty())ok=false;
    }
    if(ok)puts("OK");
    else puts("NG");
  }
}

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

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

using namespace std;

/*
ll pw(ll a, ll b) {
	ll ans = 1;
	while (b) {
		while (!(b & 1))
			b >>= 1, a = (a * a) % MOD;
		--b;
		ans = (ans * a) % MOD;
	}
	return ans;
}
*/
const ld PI = acos(-1.0);

const ld profit = 20 - 10 * PI / 2;
const ld fuckit = 10 * PI - 20;

const int MX = 1e8 - 1;

const int INF = 1e8;
vector<pair<int, int> > vv;
vector<int> vs;
int d[(int)1e6];

int main() {
	int x1, y1, x2, y2;
	scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; ++i) {
		int x, y;
		scanf("%d%d", &x, &y);
		if (x < min(x1, x2) || x > max(x1, x2) || y < min(y1, y2) || y > max(y1, y2))
			continue;
		if (x1 > x2)
			x = MX - x;
		if (y1 > y2)
			y = MX - y;
		vv.push_back(make_pair(x, y));
	}
	sort(vv.begin(), vv.end());
	for (int i = 0; i < vv.size(); ++i)
		vs.push_back(vv[i].second);
	sort(vs.begin(), vs.end());
	for (int i = 0; i < vv.size(); ++i)
		vv[i].second = lower_bound(vs.begin(), vs.end(), vv[i].second) - vs.begin();
	fill(d, d + vv.size() + 1, INF);
	d[0] = -1;
	int ans = 0;
	for (int i = 0; i < vv.size(); ++i) {
		int x = upper_bound(d, d + vv.size() + 1, vv[i].second) - d;
		d[x] = vv[i].second;
		ans = max(ans, x);
	}
	ld go = abs(x2 - x1) + abs(y2 - y1);
	go *= 100;
	if (ans == min(abs(x2 - x1), abs(y2 - y1)) + 1) {
		--ans;
		go += fuckit;
	}
	go -= profit * ans;
	printf("%.20Lf\n", go);
	return 0;
}




Measured memory_bytes: 4848
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
typedef long long ll;


int main(void){
  int a,b;
  string s,t,u;
  
  cin >> s >> t >> a >> b >> u;
  if (s==u) a--;
  else b--;
  
  cout << a << ' ' << b << endl;
  
  return 0;
}

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


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

	int n;
	cin >> n;

	long long count = 0;

	for (int a = 1; a < n; a++) {
		for (int b = 1; b < n; b++) {
			if (a * b < n)
				count++;
			else
				break;
		}
	}

	cout << count;

	return 0;
}

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

const ll mod = 1e9 + 7;

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

/*-------------------------------------------*/

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

    string s, t;
    int a, b;
    cin >> s >> t >> a >> b;
    string u;
    cin >> u;
    if(u == s)
        a--;
    else
        b--;
    cout << a << " " << b << endl;
}

Measured memory_bytes: 256
import java.util.LinkedList;
import java.util.Scanner;
import java.util.Iterator;

class Graph {
	private int totalVertex;
	//adjMatrix[u][v] = 1 if there is an edge from u to v, otherwise 0
	private int[][] adjMatrix;
	//adjWeight[u][v] -- the weight of the edge from u to v if there is one
	private int[][] adjWeight;
	//if a node is settled (e.g., processed in the Dijkstra's algorithm)
	private Boolean[] ifSettled;
	public Graph() { totalVertex = 0; }
	public int getTotalVertex() { return totalVertex; }
	//load graph from standard input
	public void loadAdjMatrix() {
		Scanner in = new Scanner(System.in);
		totalVertex = in.nextInt();
		adjMatrix = new int[totalVertex][totalVertex];
		adjWeight = new int[totalVertex][totalVertex];
		ifSettled = new Boolean[totalVertex];
		int i, j;
		for(i = 0; i < totalVertex; i ++) {
			ifSettled[i] = false;
			for(j = 0; j < totalVertex; j ++) {
				adjMatrix[i][j] = adjWeight[i][j] = 0;
			}
		}
		int u, v;
		for(i = 0; i < totalVertex; i ++) {
			u = in.nextInt();
			int degree = in.nextInt();
			for(j = 0; j < degree; j ++) {
				v = in.nextInt(); 
				adjMatrix[u][v] = 1;
				adjWeight[u][v] = in.nextInt();
			}	
		}
		in.close();
	}
	//return weight of the edge from u to v if there is one
	public int getWeight(int u, int v) {
		return adjWeight[u][v];
	}
	//return neighbors of u as a LinkedList
	public LinkedList<Integer> getNeighbors(int u) {
		LinkedList<Integer> tmp = new LinkedList<Integer>();
		for(int v = 0; v < totalVertex; v ++) {
			if(adjMatrix[u][v] == 1) tmp.add(v);
		}
		return tmp;
	}
	//return unsettled neighbors of u as a LinkedList
	public LinkedList<Integer> getUnsettledNeighbors(int u) {
		LinkedList<Integer> tmp = new LinkedList<Integer>();
		for(int v = 0; v < totalVertex; v ++) {
			if((adjMatrix[u][v] == 1) && (ifSettled[v] == false)) tmp.add(v);
		}
		return tmp;
	}
	//return the unsettled node that has the smallest dist
	public int getUnsettledNearest(int[] dist) {
		int md = Integer.MAX_VALUE;
		int mv = -1;
		int v;
		for(v = 0; v < totalVertex; v ++) {
			if((ifSettled[v] == false) && (dist[v] < md)) {
				md = dist[v];
				mv = v;
			}
		}
		return mv;
	}
	//implement the following	
	public int[] Dijkstra(int s) {
		int [] D = new int[totalVertex];
		for(int i=0; i<totalVertex; i++){
			D[i] = Integer.MAX_VALUE;
		}
		D[s] = 0;
		for(int i=0; i<totalVertex; i++){			
			ifSettled[s] = true;
//			if(D[s] == Integer.MAX_VALUE) return void; // unreachable
			LinkedList<Integer> UnsettleNeighbors = getUnsettledNeighbors(s);
			Iterator<Integer> it = UnsettleNeighbors.iterator();
			while(it.hasNext()){
				int v = it.next();
				if(D[v] > (D[s] + adjWeight[s][v]))
					D[v] = D[s] + adjWeight[s][v];
			}
			s = getUnsettledNearest(D);
		}		
		return D;
	}
}

public class Main {
	public static void main(String[] argv) {
		Graph g = new Graph();
		g.loadAdjMatrix();
		int[] dist = g.Dijkstra(0);
		for(int i = 0; i < g.getTotalVertex(); i ++) {
			System.out.println(i + " " + dist[i]);
		}
	}
}


Measured memory_bytes: 39972
a = input()
count = 0
if a[0] != "A":
    print("WA")
else:
    if a[2:len(a)-1].count("C") != 1:
        print("WA")
    else:
        for i in range(len(a)):
            if a[i].islower():
                count += 1
        if count == len(a) - 2:
            print("AC")
        else:
            print("WA")
            

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

using namespace std;

typedef long long ll;
typedef pair<int, int> PII;

const int MM = 1e9 + 7;
const double eps = 1e-8;
const int MAXN = 2e6 + 10;
const ll INF = 1ll << 60;

int n, m;

ll f[MAXN][2];

int a[MAXN];

void prework(){

}

int b[MAXN];

void read(){
	scanf("%d", &n);
	for(int i = 1; i <= n; i++){
		scanf("%d", &a[i]);
		char s[10];
		if (i < n){
			scanf("%s", s);
			if (s[0] == '+')
				b[i + 1] = 1;
			else
				b[i + 1] = -1;
		}
	}
	b[0] = b[1] = 1;
	f[0][0] = 0;
	f[0][2] = f[0][1] = -INF;
	for(int i = 1; i <= n; i++){
		if (b[i] == 1){
			f[i][1] = max(f[i-1][1] - a[i], f[i-1][2] + a[i]);
			f[i][2] = f[i-1][2] + a[i];
			f[i][0] = max(f[i-1][0] + a[i], f[i-1][1]);
		}
		else{
			f[i][2] = max(f[i-1][1] + a[i], f[i-1][2] - a[i]);
			f[i][0] = max(f[i-1][0] - a[i], f[i][2]);
			f[i][1] = f[i][0];
		}
		//cout<<f[i][0]<<' '<<f[i][1]<<endl;
	}
	cout<<max(f[n][1],max(f[n][0], f[n][2]))<<endl;
}

void solve(int casi){

}

void printans(){

}


int main(){
	prework();
	int T = 1;
//	cin>>T;
	for(int i = 1; i <= T; i++){
		read();
		solve(i);
		printans();
	}
	return 0;
}




Measured memory_bytes: 2560
def count_two(n):
  count = 0
  while n % 2 == 0:
    count += 1
    n //= 2
  return count

def main():
  input()
  ary = list(map(int, input().split()))
  ans = 128
  for v in ary:
    ans = min(ans, count_two(v))

  print(str(ans))

if __name__ == '__main__':
  main()


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

namespace ABC144
{
    class A
    {
        static void Main(string[] args)
        {
            int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int A = input[0];
            int B = input[1];
            if (9 < A || 9 < B) { Console.WriteLine(-1); return; }
            else Console.WriteLine(A * B);
        }
    }
}


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

//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<PII> VP;


//REPEAT
//------------------------------------------
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define RFOR(i, m, n) for(int i = m;i > n;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,m)  RFOR(i,m,0)

//container util
//------------------------------------------
#define pb(a) push_back(a)
#define fst first
#define snd second
#define SORT(V) sort((V).begin(),(V).end())
#define REV(V) reverse((V).begin(),(V).end())

//constant
//------------------------------------------
const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

//grobal variable
//------------------------------------------

//def function, class
//------------------------------------------

//main
//------------------------------------------
signed main(){
  string S;
  cin >> S;

  SORT(S);

  if(S[0]==S[1]&&S[1]!=S[2]&&S[2]==S[3]){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int min(int a, int b) {
  return a < b ? a : b;
}

int main(){
  int H, W, A, B;

  cin >> H >> W >> A >> B;

  int wnum = min(A, W-A);
  int hnum = min(B, H-B);

  for(int j=0; j<H; j++) {
    for(int i=0; i<W; i++) {
      if(i<wnum) {
	cout << (j<hnum ? "1" : "0");
      } else {
	cout << (j<hnum ? "0" : "1");
      }
    }
    cout << endl;
  }
  
  return 0;
}


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

int main()
{
    string A, B, C;
    cin >> A >> B >> C;
    if ((A.back() == B.front()) && (B.back() == C.front()))
    {
        cout << "YES";
    }
    else
    {
        cout << "NO";
    }
}

Measured memory_bytes: 256
import math

N, D = map(int, input().split())
xy = [map(int, input().split()) for _ in range(N)]
x, y = [list(i) for i in zip(*xy)]
count = 0

for i in range(N):
  z = (int(x[i]) **2) + (int(y[i]) **2)
  h = math.sqrt(z)
  if D >= h:
    count += 1
  else:
    pass
  
print(count)

Measured memory_bytes: 116800
#include<bits/stdc++.h>
using namespace std;
const int maxn=2002;
int a[maxn];
bool dp[maxn][100001];
signed main() {
	int n;
	cin>>n;
	int sum=0;
	for(int i=1 ; i<=n ; i++) {
		cin>>a[i];
		sum+=a[i];
	}
	for(int i=0 ; i<=n ; i++) {
		for(int j=0 ; j<=100000 ; j++) {
			dp[i][j]=false;
		}
	}
	dp[1][a[1]]=1;
	for(int i=1 ; i<n ; i++) {
		for(int j=0 ; j<=100000 ; j++) {
			if(dp[i][j]==true) {
				//cout<<"i j "<<i<<" "<<j<<endl;
				if(j>=a[i+1]) {
					dp[i+1][j-a[i+1]]=true;
				}
				else {
					dp[i+1][a[i+1]-j]=true;
				}
				if(j+a[i+1]<=100000) dp[i+1][a[i+1]+j]=true;
			}
		}
	}
	for(int i=0 ; i<=100000 ; i++) {
		if(dp[n][i]) {
			cout<<(sum+i)/2;
			return 0;
		}
	}
}

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

using namespace std;

typedef long long int ll;

const int N = (int) 2e5 + 10;

struct node {
    int l, r;
    node *left, *right;
    ll val;
    node(int L, int R) {
        val = 0, l = L, r = R;
        if(l == r) return;
        int m = l + r >> 1;
        left = new node(l, m);
        right = new node(m + 1, r);
    }
    ll query_max(int L, int R) {
        if(r < L || l > R) return 0;
        if(L <= l && r <= R) return val;
        return max(left->query_max(L, R), right->query_max(L, R));
    }
    void update(int i, ll x) {
        if(r < i || i < l) return;
        if(l == r) {
            val = x;
            return;
        }
        left->update(i, x);
        right->update(i, x);
        val = max(left->val, right->val);
    }
};

int n;
int a[N], h[N];
node *st;

void solve() {
    cin >> n;
    st = new node(1, n);
    for(int i = 1; i <= n; ++i) {
        cin >> h[i];
    }
    for(int i = 1; i <= n; ++i) {
        cin >> a[i];
    }
    for(int i = 1; i <= n; ++i) {
        int height = h[i];
        ll max_val = st->query_max(1, height);
        ll cur = max_val + a[i];
        st->update(height, cur);
    }
    cout << st->query_max(1, n) << endl;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(20);
    cout << fixed;
    solve();
    return 0;
}

Measured memory_bytes: 20608
import sys
sys.setrecursionlimit(4100000)

import math

import logging

logging.basicConfig(level=logging.DEBUG)

logger = logging.getLogger(__name__)


def resolve():
    # S = [x for x in sys.stdin.readline().split()][0]  # 文字列 一つ
    # N = [int(x) for x in sys.stdin.readline().split()][0]  # int 一つ
    N, M = [int(x) for x in sys.stdin.readline().split()]  # 複数int
    # grid = [list(sys.stdin.readline().split()[0]) for _ in range(N)]  # 文字列grid
    # grid = [[int(x) for x in sys.stdin.readline().split()]
    #         for _ in range(N)]  # int grid

    logger.debug('{}'.format([]))

    if N == M:
        print('Yes')
    else:
        print('No')


if __name__ == "__main__":
    resolve()

# AtCoder Unit Test で自動生成できる, 最後のunittest.main は消す
# python -m unittest template/template.py で実行できる
# pypy3 -m unittest template/template.py で実行できる

import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """3 3"""
        output = """Yes"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """3 2"""
        output = """No"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """1 1"""
        output = """Yes"""
        self.assertIO(input, output)


Measured memory_bytes: 6436
#include<bits/stdc++.h>
#define rep(i,a,...) for(int i = (a)*(strlen(#__VA_ARGS__)!=0);i<(int)(strlen(#__VA_ARGS__)?__VA_ARGS__:(a));++i)
#define per(i,a,...) for(int i = (strlen(#__VA_ARGS__)?__VA_ARGS__:(a))-1;i>=(int)(strlen(#__VA_ARGS__)?(a):0);--i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
using ll = long long;
//const ll MOD = (ll)1e9+7;
const ll MOD = 998244353;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}
#ifdef DEBUG
#define debug(x) cout<<"LINE "<<__LINE__<<": "<<#x<<" = "<<x<<endl;
#else
#define debug(x) (void)0
#endif

namespace templates{
  ll modpow(ll x, ll b){
    ll res = 1;
    while(b){
      if(b&1)res = res * x % MOD;
      x = x * x % MOD;
      b>>=1;
    }
    return res;
  }

  ll modinv(ll x){
    return modpow(x, MOD-2);
  }

  bool was_output = false;
  template<class t>
  void output(t a){
    if(was_output)cout << " ";
    cout << a;
    was_output = true;
  }
  void outendl(){
    was_output = false;
    cout << endl;
  }
  ll in(){
    ll res;
    scanf("%lld", &res);
    return res;
  }

  template<class t>
  istream& operator>>(istream&is, vector<t>&x){
    for(auto &i:x)is >> i;
    return is;
  }

  template<class t, class u>
  istream& operator>>(istream&is, pair<t, u>&x){
    is >> x.first >> x.second;
    return is;
  }

  template<class t>
  void in(t&x){
    cin >> x;
  }

  template<class t>
  t in(){
    t res; cin >> res; return res;
  }

  template<class t>
  void out(t x){
    cout << x;
  }

  template<class t>
  vector<t> sorted(vector<t> line,function<bool(t,t)> comp=[](t a,t b){return a<b;}){
    sort(line.begin(),line.end(),comp);
    return line;
  }

  template<class t>
  vector<t> reversed(vector<t> line){
    reverse(line.begin(),line.end());
    return line;
  }
}

using namespace templates;

bool func(){
  string str = in<string>();
  int n = str.size();
  function<bool(int,int)> func =
    [&](int l,int r){
      if(l>=r)return true;
      if(str[l]!='m')return false;
      if(str[r]!='w')return false;
      static vvector<int> dp(n,vector<int>(n,0));
      int &res = dp[l][r];
      if(res)return res==2?true:false;
      rep(i,l+1,r){
        if(str[i]!='e')continue;
        if(func(l+1,i-1) and func(i+1,r-1)){
          res = 2;
          return true;
        }
      }
      res = 1;
      return false;
    };
  return func(0,n-1);
}

int main(){
  cout << (func()?"Cat":"Rabbit") << endl;
  return 0;
}



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

int main()
{
    int n, ans, t;
    cin >> n;
    vector<int> x(n), y(x), h(n);
    for(int i = 0;i < n;i++){
        cin >> x[i] >> y[i] >> h[i];
        if(h[i] != 0) t = i;
    }

    for(int i = 0;i < 101;i++){
        for(int j = 0;j < 101;j++){
            ans = h[t] + abs(x[t] - i) + abs(y[t] - j);bool f = true;
            for(int k = 0;k < n;k++){
                int v = ans - abs(x[k] - i) - abs(y[k] - j); v = max(v,0);
                if(v != h[k]){
                    f = false;
                }
            }
            if(f){
                cout << i << " " << j << " " << ans;
                return 0;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <cmath>
using namespace std;

int N;

int t[100010];
int x[100010];
int y[100010];

int main()
{
    cin.tie(0);
    std::ios_base::sync_with_stdio(false);
    cin >> N;
    for(int i = 1;i <= N;i++)
    {
        cin >> t[i] >> x[i] >> y[i];
    }

    for(int i = 1;i <= N;i++)
    {
        int dist = 0;
        dist += abs(x[i] - x[i - 1]);

        dist += abs(y[i] - y[i - 1]);

        int limit = t[i] - t[i - 1];

        if(dist <= t[i] && limit % 2 == dist % 2)
        {

        }
        else
        {
            cout << "No";
            return 0;
        }
    }

    cout << "Yes";
    return 0;
}

Measured memory_bytes: 1408
import java.util.*;

public class Main {
	public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
      	String ch = sc.next();
      	switch(ch) {
          case "A":
            System.out.println("T");
            break;
          case "T":
            System.out.println("A");
            break;
          case "G":
            System.out.println("C");
            break;
          case "C":
            System.out.println("G");
            break;
        }
    }
}

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

int main()
{
    int q, query, i, cnt;
    int bit[64];
    bool judge;

    for( int j = 0; j < 64; j++ )
        bit[j] = 0;

    cin >> q;

    while( q-- )
    {
        cin >> query;

        switch( query )
        {
            case 0:
                cin >> i;
                if( bit[i] == 0 )
                    cout << 0 << endl;
                else
                    cout << 1 << endl;
                break;
            case 1:
                cin >> i;
                bit[i] = 1;
                break;
            case 2:
                cin >> i;
                bit[i] = 0;
                break;
            case 3:
                cin >> i;
                if( bit[i] == 0 )
                    bit[i] = 1;
                else
                    bit[i] = 0;
                break;
            case 4:
                judge = true;
                for( int j = 0; j < 64; j++ )
                    if( bit[j] == 0 )
                        judge = false;
                cout << judge << endl;
                break;
            case 5:
                judge = false;
                for( int j = 0; j < 64; j++ )
                    if( bit[j] == 1 )
                        judge = true;
                cout << judge << endl;
                break;
            case 6:
                judge = true;
                for( int j = 0; j < 64; j++ )
                    if( bit[j] == 1 )
                        judge = false;
                cout << judge << endl;
                break;
            case 7:
                cnt = 0;
                for( int j = 0; j < 64; j++ )
                    if( bit[j] == 1 )
                        cnt++;
                cout << cnt << endl;
                break;
            case 8:
                unsigned long long sum = 0;
                unsigned long long z = 1;
                for( int j = 0; j < 64; j++ )
                {
                    if( bit[j] == 1 )
                        sum += z;
                    z *= 2;
                }
                cout << sum << endl;
                break;
        }
    }
    return 0;
}


Measured memory_bytes: 3112