akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>
#include<functional>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;
const long long ll_max = 9223372036854775807;
const long long ll_min = -9223372036854775807;
const int int_max = 2147483647;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> ret;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			ret[i] ++;
			n /= i;
		}
	}
	if (n != 1) ret[n] = 1;
	return ret;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

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



// 繰り返し二乗法
ll pow2(ll n, ll p, ll mod) {
	if (p == 0 || n == 1) {
		return 1;
	}
	else {
		ll ret = pow2(n * n % mod, p / 2, mod);
		if (p % 2 == 1) {
			ret *= n;
		}
		return ret % mod;
	}
}


#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)


int main() {
	ll N, D;
	cin >> N >> D;
	vector<vector<double>> X(N, (vector<double>(D)));
	ll ans = 0;
	rep(i, 0, N) {
		vector<double> sub(i, 0.0);
		rep(j, 0, D) {
			cin >> X[i][j];
			rep(k, 0, i) {
				sub[k] += (X[i][j] - X[k][j]) * (X[i][j] - X[k][j]);
			}
		}
		rep(k, 0, i) {
			sub[k] = sqrt(sub[k]);
			if (sub[k] -(int)sub[k] == 0.0) {
				ans++;
			}
		}
	}
	cout << ans << endl;
	return 0;
}


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

int main(){
    int a,b,c; cin >> a >> b >> c;
    if(a == b && b == c){
        if(a %2 == 0) cout << -1  << endl;
        else cout << 0 << endl;
        return 0;
    }
    int cnt = 0;
    while(a%2 == 0 && b %2 == 0 && c%2 == 0){
        int na = (b+c)/2, nb = (a+c)/2, nc = (a+b)/2;
        a = na; b = nb; c = nc;
        cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
  int b1, b2, b3;

  scanf("%d %d %d", &b1, &b2, &b3);

  if (b1 == 1 && b2 == 0 && b3 == 0)
    printf("Close\n");
  else if (b1 == 0 && b2 == 1 && b3 == 0)
    printf("Close\n");
  else if (b1 == 1 && b2 == 1 && b3 == 0)
    printf("Open\n");
  else if (b1 == 0 && b2 == 0 && b3 == 1)
    printf("Open\n");
  else
    printf("Close\n");

  return 0;
}

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

using namespace std;


int main()
{
  int n;
  cin>> n;
  vector<vector<long long>> v(n,vector<long long>(3,0));
  for(int i=0;i<n;i++)
  {
    cin>>v[i][0]>>v[i][1]>>v[i][2];
  }
  for(int i=1;i<n;i++)
  {
    v[i][0]+=max(v[i-1][1],v[i-1][2]);
    v[i][1]+=max(v[i-1][0],v[i-1][2]);
    v[i][2]+=max(v[i-1][1],v[i-1][0]);
  }
  cout<<*max_element(v[n-1].begin(),v[n-1].end());
  return 0;
}

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

public class Main {
    int n;
    char[][] ss;
    int MOD = 1000000007;

    public static void main(String args[]) {
        new Main().run();
    }

    void run() {
        FastReader sc = new FastReader();
        n = sc.nextInt();
        ss = new char[2][n];
        for (int i = 0; i < 2; i++) {
            ss[i] = sc.next().toCharArray();
        }
        solve();
    }

    void solve() {
        long num = 1;
        int prevBlock = 0;
        for (int i = 0; i < n; i++) {
            if (ss[0][i] == ss[1][i]) {
                switch (prevBlock) {
                    case 0:
                        num *= 3;
                        break;
                    case 1:
                        num *= 2;
                        break;
                }
                num %= MOD;
                prevBlock = 1;
            } else {
                switch (prevBlock) {
                    case 0:
                        num *= 6;
                        break;
                    case 1:
                        num *= 2;
                        break;
                    case 2:
                        num *= 3;
                        break;
                }
                num %= MOD;
                prevBlock = 2;
                i++;
            }
        }
        System.out.println(num);
    }

    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: 22740
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<ll, ll>
#define PP pair<P,P>
using namespace std;

int main(){
    int n,q; cin >> n >> q;
    string s; cin >> s;
    vector<int> num(s.length(),0);
    rep(i,s.length()-1){
        if(s[i+1]=='C' && s[i]=='A') num[i+1]=num[i]+1;
        else num[i+1]=num[i];
    }
    rep(i,q){
        int a,b; cin >> a >> b;
        a--; b--;
        cout << num[b]-num[a] << endl;
    }
return 0;
}


Measured memory_bytes: 1408
#include<stdio.h>
#include<string.h>
int main(){
	char wea[10];
	scanf("%s",wea);
	if(strcmp(wea,"Sunny")==0){
		printf("Cloudy\n");
	}else if(strcmp(wea,"Cloudy")==0){
		printf("Rainy\n");
	}else if(strcmp(wea,"Rainy")==0){
		printf("Sunny\n");
	}
	return 0;
}

Measured memory_bytes: 128
N = int(input())
A = list(map(int,input().split()))
Adic = [0]*N
for i in range(N):
    Adic[A[i]-1] += 1
counter = 0
for i in range(N):
    num = Adic[i]
    counter += num*(num-1)/2
    
for k in range(N):
    num = Adic[A[k]-1]
    plusminus = (num-1)*(num-2)/2-num*(num-1)/2
    print(int(counter+plusminus))

Measured memory_bytes: 84044
#include <iostream>
#include <cmath>
#include <string>
#include <numeric>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <limits>
using namespace std;
#define MOD 1000000007
#define INF 1000000009
#define ll long long
#define rep(i_, start, end) for(ll i_=(ll)start; i_<(ll)end; i_++)
#define print(a) cout << a << endl;
#define printarray(a, len) rep(ii,0,len) cout << a[ii] << " ";
#define printarray2(aa, len) rep(ij,0,len) printarray(aa[ij], aa[ij].size()); print("");
 
ll dp[100010] = {};
int main(){
  ll n, k, input;
  vector<ll> h;
  cin >> n >> k;
  rep(i, 0, n){
    cin >> input;
    h.push_back(input);
  }
  
  rep(i, 1, n){
    dp[i] = INF;
    rep(j, 1, k+1){
      if (i - j >= 0){
        dp[i] = min(dp[i], dp[i - j] + labs(h[i] - h[i-j]));
      }
    }
  }
  //printarray(dp, n+1);
  print(dp[n-1]);
  return 0;
}

Measured memory_bytes: 1908
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
const ll INF = 1LL<<60;
/////////////////////////////////
int main(){
    int a,b,c;
    cin>>a>>b;
    if(a==1){
        if(b==2)
            c = 3;
        else
            c = 2;
    }
    else if(a==2){
        if(b==1)
            c = 3;
        else
            c = 1;
    }
    else{
        if(b==1)
            c = 2;
        else
            c = 1;
    }
    cout << c << endl;
}

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


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define eb emplace_back
#define f first
#define s second
#define ll long long int
#define ull unsigned long long int
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
#define mod 1000000007
ll n;
ll a[444];
ll dp[444][444],sum[444];
int main()
{
    fast;
    cin>>n;
    for(ll i=0;i<n;i++){cin>>a[i];sum[i+1]=sum[i]+a[i];}
    for(ll gap=0;gap<n;gap++)
    {
        for(ll i=0;i<n-gap;i++)
        {        
            ll j=gap+i;
            if(i==j)dp[i][j]=a[i];
            else{
                ll ans = LONG_LONG_MAX;
                for(ll k=i;k<j;k++)
                {
                    ans = min(ans , dp[i][k]+dp[k+1][j]+sum[j+1]-sum[i]);
                }
                dp[i][j]=ans;
            }
        }
    }
//    for(ll i=0;i<=n;i++)
//    {
//        for(ll j=0;j<=n;j++)cout<<dp[i][j]<<" ";cout<<"\n";
//    }
    cout<<dp[0][n-1]-sum[n]<<"\n";
return 0;
}

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

#define endl "\n"

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

//REPEAT
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//container util
//------------------------------------------
#define pb push_back
#define paired make_pair
#define ALL(a) (a).begin(),(a).end()
#define PRINT(V) for (auto v : (V)) cout << v << " "
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())

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

//math
//------------------------------------------
int QP(int a,int b){int ans=1;do{if(b&1)ans=1ll*ans*a%MOD;a=1ll*a*a%MOD;}while(b>>=1);return ans;}
int QP(int a,int b,int MOD){int ans=1;do{if(b&1)ans=1ll*ans*a%MOD;a=1ll*a*a%MOD;}while(b>>=1);return ans;}
int GCD(int a,int b){return b?GCD(b,a%b):a;}

//debug
//------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//grobal variable
//------------------------------------------
int N,M;
VI Vec;

//動的計画法で役に立つ関数
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

//最大公約数と最小公倍数
ll gcd(ll a, ll b) {
    if(b==0)return a;
    return gcd(b, a%b);
}

ll lcm(ll a, ll b) {
  ll g = gcd(a, b);
  return a/g*b;
}

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

vector<string> S(60);

bool check(int i, int j)
{
    bool is_ok = true;
    if (S[i][j] == '#' && S[i][j+1]=='.' && S[i][j-1]=='.' && S[i-1][j]=='.' && S[i+1][j]=='.')
    {
        is_ok=false;
    }
    return is_ok;
}

int main() 
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    int H, W; cin >> H >> W;
    
    string dots = "";
    REP(i, W+2)
    {
        dots += ".";
    }
    S[0] = dots;
    S[H+1] = dots;
    FOR(i, 1, H+1)
    {
        cin >> S[i];
    }
    
    bool is_ok=true;
    REP(i, H)
    {
        REP(j, W)
        {
            if (!check(i+1, j+1)) 
            {
                is_ok=false;
                break;
            }
        }
        if (!is_ok) break;
    }
    string res = is_ok ? "Yes" : "No";
    cout << res << endl;
    return 0;
}



Measured memory_bytes: 256
#include<cstdio>
#include<math.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<set>
#include<cstring>
#include<map>
 
 
using namespace std;
#define int long long int
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define mp make_pair
#define pb push_back
#define mod 1000000007

int N;
vector<int > edges[100005];
vector<pair<int,int>> edges2;
int ans[100005];
signed main(){
    scanf("%lld",&N);
    rep(i,N-1){
        int a,b;
        scanf("%lld %lld",&a,&b);
        a--;b--;
        edges[a].pb(b);
        edges[b].pb(a);
        edges2.pb(mp(a,b));
    }

    int colornum=0;
    map<pair<int,int>,int> M;
    vector<int> cols(N,0);
    vector<int> usednode(N,0);
    queue<int> q1;
    usednode[0]=1;
    q1.push(0);
    while(!q1.empty()){
        int v=q1.front();q1.pop();
        if(colornum<edges[v].size())colornum=edges[v].size();
        int cur=1;
        rep(i,edges[v].size()){
            int e=edges[v][i];
            if(usednode[e])continue;
            if(cur==cols[v])cur++;
            cols[e]=M[mp(e,v)]=M[mp(v,e)]=cur++;
            usednode[e]=1;
            q1.push(e);
        }
    }
    printf("%lld\n",colornum);
    rep(i,N-1){
        printf("%lld\n",M[edges2[i]]);
    }
    
    return 0;
}


Measured memory_bytes: 22128
Big=10**9+7
_=list(map(int,input().split(" ")))
N=_[0]
K=_[1]
gcd_list=[0 for _ in range(K)]
for i in range(K):
  s=K-i-1
  gcd_list[s]=(pow(K//(K-i), N, Big)-(sum(gcd_list[2*s+1::s+1]))%Big)%Big
answer=[(x+1)*gcd_list[x]%Big for x in range(K)]
print(sum(answer)%Big)

Measured memory_bytes: 15664
import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())

N = int(input())
A = list(sorted(map(int, input().split()), reverse=True))

ans = A[0]
for i in range(2, N):
    ans += A[i // 2]
print(ans)

Measured memory_bytes: 32344
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
#define fi first
#define se second
using namespace std;
using ll = long long;
using P = pair<int,int>;
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;}
const int inf = 1001001001;

int main() {
    ll a,b,k;
    cin >> a >> b >> k;
    if(k >= a) {
        k -= a;
        a = 0;
    } else {
        a -= k;
        k = 0;
    }
    if(k >= b) {
        b = 0;
    } else {
        b -= k;
    }
    cout << a << " " << b << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <ctime>
#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 <numeric>
#include <cassert>
using namespace std;
static const double EPS = 1e-10;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define all(a) a.begin(),a.end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define SS stringstream
#define DBG1(a) rep(_X,sz(a)){printf("%d ",a[_X]);}puts("");
#define DBG2(a) rep(_X,sz(a)){rep(_Y,sz(a[_X]))printf("%d ",a[_X][_Y]);puts("");}
#define bitcount(b) __builtin_popcount(b)
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)

#define delete(a,n) a.erase(remove(all(a),n),a.end())
template<typename T, typename S> vector<T>& operator<<(vector<T>& a, S b) { a.push_back(b); return a; }
template<typename T> void operator>>(vector<T>& a, int b) {while(b--)if(!a.empty())a.pop_back();}
bool isprime(int n){ if(n<2)return false;  for(int i=2;i*i<=n;i++)if(n%i==0)return false;  return true;} 
ll b_pow(ll x,ll n){return n ? b_pow(x*x,n/2)*(n%2?x:1) : 1ll;}
string itos(int n){stringstream ss;ss << n;return ss.str();}


vector< map<int,int> > wa,ac;
int T,P,R;
int main(){
	int n;
	while(cin >> T >> P >> R && T){
		wa.clear();
		wa.resize(T);
		ac.clear();
		ac.resize(T);
		
		for(int i = 0 ; i < R ; i++){
			int a,b,c;
			string d;
			cin >> a >> b >> c >> d;
			a--;
			if(ac[a].count(b)) continue;
			
			if( d == "CORRECT" ) ac[a][b] = c;
			else wa[a][b]++;
		}
		int id[50] = {};
		for(int i = 0 ; i < T ; i++) id[i] = i;
		for(int i = 0 ; i < T ; i++){
			for(int j = 0 ; j < T ; j++){
				if( ac[j-1].size() < ac[j].size() ){
					swap(ac[j-1],ac[j]);
					swap(wa[j-1],wa[j]);
					swap(id[j-1],id[j]);
				}else if(ac[j-1].size() == ac[j].size()){
					int penaltyA = 0 , penaltyB = 0;
					EACH(it,ac[j-1]) penaltyA += it->second + wa[j-1][it->first] * 1200;
					EACH(it,ac[j]) penaltyB += it->second + wa[j][it->first] * 1200;
					if( penaltyA != penaltyB ){
						if( penaltyA > penaltyB ){
							swap(ac[j-1],ac[j]);
							swap(wa[j-1],wa[j]);
							swap(id[j-1],id[j]);
						}
					}else{
						if( id[j-1] > id[j] ){
							swap(ac[j-1],ac[j]);
							swap(wa[j-1],wa[j]);
							swap(id[j-1],id[j]);
						}
					}
				}
			}
		}
		for(int i = 0 ; i < T ; i++){
			int p = 0;
			EACH(it,ac[i]) p += it->second + wa[i][it->first] * 1200;
			cout << id[i]+1 << " " << ac[i].size() << " " << p << endl;
		}
		
	}
}

Measured memory_bytes: 972
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {


		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int m = sc.nextInt();
		int[] aPrice = new int[a];
		for(int i = 0; i<a;i++) {
			aPrice[i] = sc.nextInt();
		}
		int[] aPrice2 = aPrice.clone();
		Arrays.sort(aPrice2);
		int[] bPrice = new int[b];
		for(int i = 0; i<b;i++) {
			bPrice[i] = sc.nextInt();
		}
		int[] bPrice2 = bPrice.clone();
		Arrays.sort(bPrice2);
		int min = aPrice2[0] + bPrice2[0];
		for(int i =0; i < m; i++) {
			int x = sc.nextInt();
			int y = sc.nextInt();
			int c = sc.nextInt();
			int price = aPrice[x-1] + bPrice[y-1] -c;
			if(price < min) {
				min = price;
			}
		}

		System.out.println(min);
	}
}

Measured memory_bytes: 136036
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
typedef struct node{
  int key;
  struct node *p, *l, *r;
}T_node;
T_node *rt;
void n_insert(T_node *, int);
void n_find(T_node *, int);
void n_print(T_node *);
void preo(T_node *);
void ino(T_node *);
void psto(T_node *);
int main(){
  int n;
  scanf("%d", &n);
  char *buf;
  buf = (char *)malloc(sizeof(char) * 256);
  int key;
  rt = NULL;
  int i;
  for(i = n - 1; i >= 0; i--){
    scanf("%s", buf);
    if(!strcmp(buf, "insert")){
      scanf("%d", &key);
      n_insert(rt, key);
    }
    else if(!strcmp(buf, "find")){
      scanf("%d", &key);
      n_find(rt, key);
    }
    else if(!strcmp(buf, "print"))
      n_print(rt);
  }
  free(buf);
  return 0;
}

void n_insert(T_node *x, int key){
  T_node *y;
  y = NULL;
  while(x != NULL){
    y = x;
    if(key < x->key)
      x = x->l;
    else
      x = x->r;
  }
  T_node *new;
  new = (T_node *)malloc(sizeof(T_node));
  new->p = x;
  new->key = key;
  new->l = new->r = NULL;
  
  if(y == NULL)
    rt = new;
  else if(key < y->key)
    y->l = new;
  else
    y->r = new;
}

void n_find(T_node *x, int key){
  if(x != NULL){
    if(key == x->key){
      printf("yes\n");
      return;
    }
    if(key < x->key)
      n_find(x->l, key);
    else
      n_find(x->r, key);
  }
  else
    printf("no\n");
}

void n_print(T_node *rt){
  if(rt != NULL){
    ino(rt);
    printf("\n");
    preo(rt);
    printf("\n");
  }
}

void preo(T_node *t){
  printf(" %d", t->key);
  if(t->l != NULL)
    preo(t->l);
  if(t->r != NULL)
    preo(t->r);
}
void ino(T_node *t){
  if(t->l != NULL)
    ino(t->l);
  printf(" %d", t->key);
  if(t->r != NULL)
    ino(t->r);
}
void psto(T_node *t){
  if(t->l != NULL)
    psto(t->l);
  if(t->r != NULL)
    psto(t->r);
  printf(" %d", t->key);
}

Measured memory_bytes: 19360
#include <bits/stdc++.h>
using namespace std;
const int N=1e4+5;
const int MD=1e9+7;
unordered_map<int,int> ma,tmp;
int a[N];
int quick_pow(int x,int y) {
	int ans=1;
	while(y) {
		if(y&1) ans=1LL*ans*x%MD;
		y>>=1;
		x=1LL*x*x%MD;
	}
	return ans;
}
void add(int &x,int y) {
	x+=y;
	if(x>=MD) x-=MD;
}
int main() {
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++) {
		scanf("%d",&a[i]);
		int t=a[i];
		for(int j=2;j*j<=t;j++) {
			while(t%j==0) tmp[j]++,t/=j;
		}
		if(t!=1) tmp[t]++;
		for(auto it:tmp) {
			ma[it.first]=max(ma[it.first],it.second);
		}
		tmp.clear();
	}
	int g=1;
	for(auto it:ma) {
		g=1LL*g*quick_pow(it.first,it.second)%MD;
	}
	//printf("%d\n",g);
	int ans=0;
	for(int i=0;i<n;i++) {
		add(ans,1LL*g*quick_pow(a[i],MD-2)%MD);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 768
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<cstdio>
#define ll long long
using namespace std;
const int maxn=500010,mod=1e9+7;
struct poi{int too,pre,dis;}e[maxn];
ll n,m,k,x,y,z,tot;
ll dis[maxn],d[maxn],last[maxn],f[maxn][20];
void read(ll &k)
{
	int f=1;k=0;char c=getchar();
	while(c<'0'||c>'9')c=='-'&&(f=-1),c=getchar();
	while(c<='9'&&c>='0')k=k*10+c-'0',c=getchar();
	k*=f;
}
void add(int x,int y,int z){e[++tot].too=y;e[tot].dis=z;e[tot].pre=last[x];last[x]=tot;}
void dfs(int x,int fa)
{
	d[x]=d[fa]+1;f[x][0]=fa;
	for(int i=last[x];i;i=e[i].pre)
	if(e[i].too!=fa)dis[e[i].too]=dis[x]+e[i].dis,dfs(e[i].too,x);
}
ll query(int x,int y)
{
	int ans=0;
	if(d[x]<d[y])swap(x,y);
	for(int i=19;i>=0;i--)
	if(d[f[x][i]]>=d[y])x=f[x][i];
	if(x==y)return x;
	for(int i=19;i>=0;i--)
	if(f[x][i]!=f[y][i])x=f[x][i],y=f[y][i];
	return f[x][0];
}
int main()
{
	read(n);
	for(int i=1;i<n;i++)read(x),read(y),read(z),add(x,y,z),add(y,x,z);
	dfs(1,0);for(int j=1;j<20;j++)for(int i=1;i<=n;i++)f[i][j]=f[f[i][j-1]][j-1];
	read(m);read(k);
	for(int i=1;i<=m;i++)
	{
		read(x);read(y);
		printf("%lld\n",dis[x]+dis[k]-2*dis[query(x,k)]+dis[k]+dis[y]-2*dis[query(k,y)]);
	}
}

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

typedef pair<int,int> P;
P arr[100];
bool flag[100];

int main() {
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++) {
        scanf("%d %d",&arr[i].first,&arr[i].second);
        flag[i]=(arr[i].first==arr[i].second);
    }
    for(int i=0;i<n-2;i++) {
        if (flag[i]&&flag[i+1]&&flag[i+2]) {
            printf("Yes");
            return 0;
        }
    }
    printf("No");
}

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

int solve_x(int _x, int _r, int _D){
  return _x*_r - _D;
}

int main(){
  int r, D, x;
  cin >> r >> D >> x;
  for(int i=0; i<10; i++){
    x = solve_x(x,r,D);
    cout << x << endl;
  }
  return 0;
}

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

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H, W;
    while (1)
    {
        cin >> H >> W;
        if (H == 0 && W == 0)
            return 0;

        REP(i, H)
        {
            REP(j, W)
            {
                if (i == 0 || i == H - 1 || j == 0 || j == W - 1)
                    cout << "#";
                else
                    cout << ".";
            }
            cout << endl;
        }
        cout << endl;
    }
    return 0;
}


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




int main(){
    ll S;cin>>S;
    cout<<0<<" "<<0<<" "<<1000000000<<" "<<1<<" "<<((S+1000000000-1)/1000000000)*1000000000-S<<" "<<(S+1000000000-1)/1000000000<<endl;
}







Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) GET_MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cout<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cout<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 1120000000

int main(){
  int n;
  cin>>n;
  vector<int> vec(n);
  rep(i,n) cin>>vec[i];

  int ans = 0;
  rep(i,n){
    if(vec[i] == i+1){
      int d = 0;
      while(i+d < n && vec[i+d] == i+d+1) d++;
      ans += (d+1)/2;
      i += d;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main(void){
  int r,g,b;
  cin >> r >> g >> b;
  int s = (r*100) + (g*10) + b;
  if (s%4 == 0) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}


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

using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
using Graph = vector<vector<int>>;
const int MOD = 1000000007;
const int INF_32 = 1LL << 30;
const int64_t INF_64 = 1LL << 60;

template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T& val)
{
    std::fill((T*)array, (T*)(array + N), val);
}

// dp[c1][c2][c3]: (1個の皿がc1枚，2個の皿がc2枚，3個の皿がc3枚の状態ですべて食べるまでの操作回数の期待値)
double dp[305][305][305];
int N;

double rec(int c1, int c2, int c3)
{
    if (dp[c1][c2][c3] != -1.0)
        return dp[c1][c2][c3];

    double ret = N;
    if (c1 >= 1) {
        ret += c1 * rec(c1 - 1, c2, c3);
    }
    if (c2 >= 1) {
        ret += c2 * rec(c1 + 1, c2 - 1, c3);
    }
    if (c3 >= 1) {
        ret += c3 * rec(c1, c2 + 1, c3 - 1);
    }
    ret /= (c1 + c2 + c3);

    return dp[c1][c2][c3] = ret;
}
int main()
{
    cin >> N;
    Fill(dp, -1.0);
    dp[0][0][0] = 0;
    int c1, c2, c3;
    c1 = c2 = c3 = 0;
    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;
        if (a == 1)
            c1++;
        if (a == 2)
            c2++;
        if (a == 3)
            c3++;
    }

    cout << fixed << setprecision(9);
    cout << rec(c1, c2, c3) << endl;

    return 0;
}

Measured memory_bytes: 225488
#include <iostream>

typedef long long ll;

using namespace std;

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

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

int main() {
    ios::sync_with_stdio(false);
    ll a, b;
    cin >> a >> b;
    cout << lcm(a, b) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include<iostream>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<set>
#include<string>
#include <sstream>
#include<bitset>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>
const int INF = 0x7fffffff;
const int MOD = 1000000007;
using lll = long long;
using ull = unsigned long long;
using namespace std;


int main(){
  lll ii,jj,kk;
  vector<int> ret;
  int n,k;

  cin >> n >> k;

  lll minNum,maxNum;
  lll sum = 0;
  lll cnt;
  for(ii=k;ii<=n+1;ii++){

    minNum = 0;
    maxNum = 0;

    //for(jj=0,cnt=0;jj<ii;jj++,cnt++){
    //  minNum += cnt;
    //  maxNum += (n-cnt);
    //}
    minNum = (ii * (ii-1))/2;
    maxNum = n * ii - minNum;
    //cout << "maxNum:" << maxNum << "minNum:" << minNum << endl;
    
    sum = (sum + maxNum-minNum + 1) % MOD;
  }

  cout << sum << endl;


  return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#include <string>
#include <set>
#include <map>
using namespace std;
int main()
{
 int i,l,n;
 string s;
 
  cin >> n;
  map<string,int> m;
  set<string> x;
  string a[n];
  for(i=0;i<n;i++)
  {
   cin >> a[i];
   m[a[i]]++;
  }
  l=0;
  for(auto it=m.begin();it!=m.end();it++)
  l=max(l,it->second);
  for(auto it=m.begin();it!=m.end();it++)
  {
   if(l==it->second)
   x.insert(it->first);
  }
  for(auto it=x.begin();it!=x.end();it++)
  cout << *it << "\n";
 return 0;
}

Measured memory_bytes: 36096
from functools import reduce
from math import gcd

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

c=max(A)+1
D=[0]*c
div=[0]*c
P=[]

for i in range(2,c):
    if D[i]==0:
        P.append(i)
        D[i]=i
    for j in P:
        if i*j>=c  or j>D[i] :
           break
        D[i*j]=j
f=0
for i in A:
    if i==1:
        continue
    temp=i
    while temp!=1:
        if div[D[temp]]==1:
            f=1
            break
        div[D[temp]]+=1
        temp2=D[temp]
        while temp%temp2==0 and temp>=temp2:
            temp=temp//temp2
    if f==1:
        break
        


if max(div)<=1 and f==0:
    print('pairwise coprime')

elif reduce(gcd, A) == 1:
    print('setwise coprime')

else:
    print('not coprime')

Measured memory_bytes: 199184
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<climits>//long long型の最大値(LLONG_MAX)など
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;
typedef long double lb;

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

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

  vector<ll> P(N),Q(N);
  for(ll i=0;i<N;i++){
    cin >> P[i];
  }

  for(ll i=0;i<N;i++){
    cin >> Q[i];
  }
  vector<ll> perm(N);
  for (ll i=0; i<N;i++){
      perm[i] = i+1;
  }

  ll num=0,a=0,b=0;
  do {
    num++;
    for(ll i=0;i<N;i++){
      if(P[i] == perm[i]){
        if(i == N-1){
          a = num;
        }
      }else{
        break;
      }
    }

    for(ll i=0;i<N;i++){
      if(Q[i] == perm[i]){
        if(i == N-1){
          b = num;
        }
      }else{
        break;
      }
    }

  } while(next_permutation(perm.begin(), perm.end()));

  int result = abs(a-b);
  cout << result << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int[] num = new int[100000];
        int i = 0;

        while(true) {
            num[i] = scan.nextInt();
            if(num[i] == 0) {
                break;
            }
            i++;
        }
        for(int j = 0 ; j < i ; j++) {
            System.out.println("Case " + (j + 1) + ": " + num[j]);
        }
        scan.close();
    }
}


Measured memory_bytes: 43024
#include <iostream>
#include <vector>
#include <string>
#include <climits>
#include <algorithm>

using namespace std;

int main(){
	
	int pay;
	int c[4]={0}, type[]={10,50,100,500};
	bool f=false;
	
	while(cin>>pay, pay){
		
		if(f)
			cout << endl;
		
		int sum=0;
		f=true;
		
		for(int i=0; i<4; ++i){
			cin>>c[i];
			sum+=c[i]*type[i];
		}
		
		int tmp=sum-pay;
		int cng[4]={0};
		
		while(tmp){
			
			for(int i=3; i>=0; --i){
				if(tmp >= type[i]){
					cng[i]++;
					tmp-=type[i];
					break;
				}
			}
			
		}
		
		for(int i=0; i<4; ++i){
			
			if(c[i]-cng[i]>0){
				cout << type[i] << " " << c[i]-cng[i] << endl;
			}
		}
	}
	
	return 0;
}

Measured memory_bytes: 1160
H, W, K = list(map(int, input().split(' ')))
# mat[i][j] = mat[i-1][j-1] * hoge + mat[i-1][j-1] * fuga + mat[i+1][j-1] * piyo
# hoge, fuga, piyo は隣接していない自由に置いて良い | | | ... | で固定値で決まる
# |-| -> hoge(2)=2
# |-|-| -> hoge(3)=3
# |-|-|-| -> hoge(4)=5
# |-|-|-|-| -> hoge(5)=8
# |-|-|-|-|-| -> hoge(6)=13
# |-|-|-|-|-|-| -> hoge(7)=21?
mat = []
for i in range(H+1):
    mat.append([0] * (W))
mat[0][0] = 1

def get(h, w):
    if h < 0 or w < 0:
        return 0
    if h >= H or w >= W:
        return 0
    return mat[h][w]

def hoge(w):
    d={1:1, 2:2, 3:3, 4:5, 5:8, 6:13, 7:21}
    return d.get(w, 1)

for i in range(1,H+1):
    for j in range(W):
        mat[i][j] = get(i-1, j-1) * hoge(j-1) * hoge(W-j-1) +\
                    get(i-1, j)   * hoge(j)   * hoge(W-j-1) +\
                    get(i-1, j+1) * hoge(j)   * hoge(W-j-1-1)
print(mat[H][K-1] % 1000000007)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include<algorithm>
using namespace std;
long long int __lcm(long long int a,long long int b){
  long long int n;
  n=a*b/__gcd(a,b);
  return n;
}
 //__gcd 最大公約数
 //__lcm 最小公倍数

int main() {
  int a;
  cin>>a;
  vector<double> b(a);
  vector<string> c(a);
  for(int i=0;i<a;i++)
    cin>>b[i]>>c[i];
  double e=0;
  for(int i=0;i<a;i++){
    if(c[i]=="JPY")
      e+=b[i];
    else
      e+=380000.0*b[i];
  }
  cout<<e;
}

Measured memory_bytes: 256
#N = int(input())
A,B = map(int,input().split())
#X=list(map(int,input().split()))

a = int(A/0.08)
b = int(B/0.1)
aa=[]
bb=[]
if int(a*0.08)==A:
    aa.append(a)
if int(b*0.1)==B:
    bb.append(b)
au=a+1
ap=a-1
bu=b+1
bs=b-1
f1=True
f2=True
f3=True
f4=True

while f1==True or f2==True:
    if int(au*8/100) == A:
        aa.append(au)
        au += 1
    else:
        f1=False

    if int(ap*8/100) == A:
        aa.append(ap)
        ap -=1
    else:
        f2=False

while f3==True or f4==True:
    if int(bu*10/100) == B:
        bb.append(bu)
        bu += 1
    else:
        f3=False

    if int(bs*8/100) == B:
        bb.append(bs)
        bs -=1
    else:
        f4=False
cc=[]
for i in aa:
    for j in bb:
        if i==j:
            cc.append(j)
if len(cc)==0:
    print(-1)
else:
    print(min(cc))


Measured memory_bytes: 3188
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include <iomanip>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define EVEL 1
#define KETA 2
#ifndef EVEL
#define DEB(X) cout << #X << ":" <<std::setw(KETA) << std::setfill('0')<<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {X;}
#define TF(f) {f;}
#define END {}
#endif
const int MOD = 1000000007;
const int INF = 1000000;
#define NMAX 50
//#define MAX 10
 
    ll N,K,id=9;
    ll A[100010],sum=0,ans=0;
 
 
int main(){
    cin>>N>>K;
    
    N-=11;
    
    int temp=N%11+11;
    ans+=(N/11)*5;
    
    ll test[11] = {};
    
    for(int i = 0; i < temp-2; i++){
        for(int j = 0; j < 5;j++ ){
            test[(81+9*j+7*9*i)%11]++;
        }
    }
    /*
        REP(i,temp){
            ll a=id;
            REP(j,5){
                if(i==0||i==N-1)break;
                    if(j==0){
                        sum=a*9;
                    }else{
                        a++;
                        sum=a*9;
                    }
                    if(sum%11==K){ans++;}
            }
            //END;
            if(!(i==0||i==N-1))id+=7;
            //DEB(id) END
        }
    */
    cout<<test[K]+ans<<endl;
}

Measured memory_bytes: 256
"use strict"
const create = () => {
    const input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
    const res = {
        "list": input, "index": 0, "max": input.length,
        "hasNext": function() {return this.index < this.max},
        "next": function() { if (!this.hasNext()) {throw "ArrayIndexOutOfBoundsException";}else{return this.list[this.index++];}}
    };
    return res;
}
const o = create();
const next = () => o.next()
const nextInt = () => parseInt(o.next())
const nextStrArray = () => o.next().split(" ")
const nextIntArray = () => o.next().split(" ").map(el => parseInt(el))
const nextCharArray = () => o.next().split("")
const hasNext = () => o.hasNext()
const myout = (...x) => console.log(...x)
const Main = () => {
    const N = nextInt()
    let h = nextIntArray()
    h.push(-1)

    let sum = 0
    let arr = []
    let dir = true // up:true, down:false
    for(let i = 0; i<h.length-1;i++){
        if(dir && h[i] > h[i+1]){
            arr.push(h[i])
            dir = !dir
        }else if(!dir && h[i] < h[i+1]){
            arr.push(h[i])
            dir = !dir
        }
    }
    sum += arr[0]
    for(let i = 2; i<arr.length;i+=2){
        sum += arr[i]-arr[i-1]
    }
    console.log(sum)
}
Main()


Measured memory_bytes: 29580
#include<stdio.h>
#include<math.h>
#include<queue>
#include<stack>
#include<string.h>
#include<algorithm>
#include<cctype>
#include<map>
#include<set>
typedef long long ll;
using namespace std;
ll mod=1e9+7;
ll a[100]; 
int main()
{
	ll n;
	scanf("%lld",&n);
	for(ll i=1;i<=n;i++){
		ll s,u=0;
		scanf("%lld",&s);
		while(s){
			a[u++]+=s%2;s/=2;
		}
	}
	ll cou=0,s=1;
	for(int i=0;i<=60;i++){
		cou=(cou+s%mod*a[i]%mod*(n-a[i])%mod)%mod;
		s*=2;
	}printf("%lld\n",cou);
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string.h>

using namespace std;

#define ll long long
#define ull unsigned long long
#define REP(i, n) for(int i=0; i<n; i++)

int r[200];
int b[200];
bool rrr[200];
bool bbb[200];
int main(){
    int N;
    cin >> N;

    int inpx, inpy;
    REP(i,N){
        cin >> inpx >> inpy;
        r[inpx] = inpy;
        rrr[inpx] = true;
    }
    REP(i,N){
        cin >> inpx >> inpy;
        b[inpx] = inpy;
        bbb[inpx] = true;
    }

    //sort(r, r+N, greater<int>());
    //sort(b, b+N, greater<int>());
    int num = 0;
    for(int rx = 2*N-1; rx >= 0; rx--){
        if(!rrr[rx]) continue;
        int bx = rx+1;
        int diff = 200;
        int close_bx = -1;
        while(bx < 2*N){
            if(bbb[bx]){
                if(b[bx] > r[rx] && (b[bx] - r[rx]) < diff){
                    diff = b[bx] - r[rx];
                    close_bx = bx;
                }
            }
            bx++;
        }

        if(close_bx != -1){
            num++;
            rrr[rx] = false;
            bbb[close_bx] = false;
        }
    }

    cout << num << endl;

    return 0;
}


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

#define pb push_back
#define fst first
#define scd second
#define all(x) x.begin(), x.end()
#define N int(1e6+10)
#define mkp make_pair

using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef list<int> li;
typedef list<ll> llong;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef map<int,int> mii;
typedef map<ll,ll> mll;

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

ll lcm(ll a, ll b){
	ll g=gcd(a,b);
	return (a/g)*b;
}

ll inv_mod(ll a, ll b){
	ll x=0, y=1, r, q, ta=a;
	while(b){
		q=a/b;
		r=a%b;
		a=b;
		b=r;
		r=x;
		x=y;
		y=r-q*y;
	}
	x+=ta;
	return x%ta;
}

int main(){
	int n;
	cin>>n;
	ll ans=pow(3,n);
	ll s=1;
	for(int i=0; i<n; i++){
		int a;
		cin>>a;
		int cnt=0;
		if(!(a&1)) s<<=1;
	}

	cout<<ans-s<<endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
// #include <boost/lexical_cast.hpp>
using namespace std;

#define ll long long int
#define vll vector<ll>
#define vllv vector<vector<ll>> 
#define vpii vector<pair<ll,ll>>
#define sz size()
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

ll ceil1(ll n,ll m){if(n%m==0){return n/m;}return n/m +1;}
vll factor(ll n){
    vll ans;
    if(n>0)ans.pb(1);if(n==2)ans.pb(2);
    for(ll i=2;i*i<=n;i++){if(n%i==0){ans.pb(i);if(n/i!=i)ans.pb(n/i);}}if(n>2)ans.pb(n);
    return ans;
}
ll fact(ll n){
	
    ll res = 1; 
    for (ll i = 2; i <= n; i++) 
        res = res * i; 
    return res; 
} 
  
int nCr(ll n, ll r) 
{ 
    return fact(n) / (fact(r) * fact(n - r)); 
} 
  
void dfs(vllv &v,ll k,vll &par,vll &dis,ll p)
{
 
    par[k]=p;
    dis[k]=dis[p]+1;
    for(ll i=0;i<v[k].sz;i++){
        if(v[k][i]!=p){
            dfs(v,v[k][i],par,dis,k);
        }
    }
}
bool sortbysec(const pair<string,int> &a,const pair<string,int> &b){return (a.second<b.second);} 


ll ston(string s) 
{ 
    stringstream geek(s); 
    ll x = 0; 
    geek >> x; 
    
  
    return x; 
}
ll pow2(ll n,ll k){ll ans=1;
    while(k>0){
        if(k%2==1)ans=ans*n;n=n*n;k/=2;
    }return ans;}
bool prime(int n){
    int i,j;
    for(i=2;i<=sqrt(n);i++){
        if(n%i==0){
            return false;
        }
    }
    return true;
}
bool bserch(vector<string> a, string s){
	ll l=0,r=a.sz-1,mid;
	while(l<=r){
		mid=(l+r)/2;
		if(a[mid]==s)return true;
		if(a[mid]<s){
			l=mid+1;
		}else{
			r=mid-1;
		}
	}
	return false;
}

bool sortcol(const vector<int>& v1, 
               const vector<int>& v2){ 
 return v1[0] < v2[0]; } 

 ll degit(ll n)
 {
 	ll t=0;
 	while(n>0)
 	{
 		t++;
 		n/=10; 	}
 		return t;
 }

void solve()
{
	string s;
	cin>>s;
	cout<<s[0]<<s[1]<<s[2];
	return;
}

int main()
{
	fast;
    ll q;
    q=1;
    // cin>>q;
    while(q--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3612
"use strict";

main(require("fs").readFileSync("/dev/stdin", "utf8"));

function main(input) {
  const [[h, w], [colorCount], fillCounts] = input.split("\n").map(s => s.split(" ").map(Number));

  // 1次元配列に格納
  let line = [];

  fillCounts.forEach((fillCount, i) => {
    const color = String(i + 1);
    line.push(...new Array(fillCount).fill(color));
  });

  // 偶数列を反転しつつ2次元配列に格納
  const box = (() => {
    const arr = [];
    const i = 0;
    while(line.length !== 0) {
      arr[i] = line.splice(0, w);
      if(i % 2 === 1) {
        arr[i].reverse();
      }
      i++;
    }
    return arr;
  })();

  const ans = box.map(e => e.join(" ")).join("\n"));
  console.log(ans);
}

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

int main() {
	int d;
	cin >> d;
	const int n = 26;
	vector<int> c(n);
	vector<vector<int>> s(d, vector<int>(n));
	rep(i, n) cin >> c[i];
	rep(i, d) rep(j, n) cin >> s[i][j];
	vector<int> t(d), last(n);
	
	
	vector<vector<int>> nex(d);
	// 貪欲
	ll ans = 0;
	rep(i, d) {
		ll mx = -1001001001;
		int now = 0;
		
		vector<int> nlast = last;
		rep(j1, n) {
			ll t1 = ans;
			t1 += s[i][j1];
			rep(k, n) {
				if(j1 == k) continue;
				t1 -= c[k] * (i+1-last[k]);
			}
			nlast[j1] = i;
			rep(j, n) {
				ll tmp = t1;
				tmp += s[i][j];
				rep(k, n) {
					if(j == k) continue;
					tmp -= c[k] * (i+1-nlast[k]);
				}
				if(mx < tmp) {
					nex[i].push_back(now+1);
					mx = tmp;
					now = j1;
				}
			}
		}
		
		ans = mx;
		last[now] = i+1;
		t[i] = now+1;
	}
	int cnt = 0;
	while(1) {
		// 局所探索法
		cnt++;
		if(cnt > 150000) break;
		vector<int> old = t;
		const int CH = rand()%5 + 1; // CH箇所変える
		rep(i, CH) {
			// int nd = rand()%d;
			// int nq = rand()%n + 1;
			// t[nd] = nq;
			int nd = rand()%d;
			t[nd] = nex[nd][rand()%nex[nd].size()];
		}
		
		// 点数の再計算
		vector<int> nlast(n);
		ll now = 0;
		rep(i, d) {
			now += s[i][t[i]];
			nlast[t[i]-1] = i+1;
			rep(j, n) {
				now -= c[j] * (i+1-nlast[j-1]);
			}
		}
		
		// 良くなれば更新
		if(now > ans) {
			ans = now;
		} else {
			t = old;
		}
	}
	
	rep(i, d) printf("%d\n", t[i]);
	return 0;
}

Measured memory_bytes: 3832
n = int(input())
l = list(map(int,input().split()))
ans = 0
for s in range(n):
    for t in range(s+1,n):
        for u in range(t+1,n):
            a = l[s]
            b = l[t]
            c = l[u]
            if a+b>c and b+c>a and a+c>b and a!=b and b!=c and a!=c:
                ans += 1

print(ans)


Measured memory_bytes: 9180
#include <stdio.h>
#define MAX 10

int main(){
	int n, flag = 0, station[MAX];
	while(scanf("%d", &n) != EOF){
		if(n == 0){
			printf("%d\n", station[flag - 1]);
			station[flag--] = 0;
		}else{
			station[flag++] = n;
		}
	}
	return 0;
}

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

using namespace std;

#define sqr(x) ((x) * (x))
#define pb push_back
#define mp make_pair
#define ins insert
#define f first
#define s second
#define fin(name) freopen(name, "r", stdin)
#define fout(name) freopen(name, "w", stdout)
#define files(name) fin(name".in"); fout(name".out")
#define endl "\n"
#define fi(st,n) for (int i = (st); i <= (int)(n); ++i)
#define fj(st,n) for (int j = (st); j <= (int)(n); ++j)
#define fk(st,n) for (int k = (st); k <= (int)(n); ++k)
#define fq(st,n) for (int q = (st); q <= (int)(n); ++q)
#define fw(st,n) for (int w = (st); w <= (int)(n); ++w)
#define ff(i, st, n) for (int (i) = (st); (i) <= (int)(n); ++(i))
#define ei(st,n) for (int i = (st); i >= (int)(n); --i)
#define ej(st,n) for (int j = (st); j >= (int)(n); --j)
#define ek(st,n) for (int k = (st); k >= (int)(n); --k)
#define ef(i, st, n) for (int (i) = (st); (i) >= (int)(n); --(i))
#define ri(st,n) for (int i = (st); i < (int)(n); ++i)
#define rj(st,n) for (int j = (st); j < (int)(n); ++j)
#define rk(st,n) for (int k = (st); k < (int)(n); ++k)
#define rq(st,n) for (int q = (st); q < (int)(n); ++q)
#define rf(i, st, n) for (int (i) = (st); (i) < (int)(n); ++(i))
#define clean(a) memset((a),0,sizeof (a))
#define sync ios_base::sync_with_stdio(0);cin.tie(0)
#define y1 dsklmlvmd

typedef long long ll;
typedef unsigned long long ull;
typedef double dbl;
typedef long double ldbl;

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const dbl eps = (dbl) 1e-8;
const int mod = (int) 1e9 + 7;
const int maxn = (int) 1e5 + 5;
//const dbl M_PI = (dbl)2 * (dbl)acos(0);

//cout<<fixed<<setprecision(10);
//srand(time(0));

ll a, b, c, na, nb, nc;
set <pair <ll, pair <ll, ll> > > q;

int main() {
//    fin("t.in");
    sync;
    int k = 0;
    cin >> a >> b >> c;
    while (a % 2 == 0 && b % 2 == 0 && c % 2 == 0) {
        ++k;
        if (q.count(mp(a, mp(b, c)))) {
            cout << -1 << endl;
            return 0;
        }
        q.ins(mp(a, mp(b, c)));
        na = (b + c) / 2;
        nb = (a + c) / 2;
        nc = (a + b) / 2;
        a = na;
        b = nb;
        c = nc;
    }
    cout << k << endl;
    return 0;
}

Measured memory_bytes: 256