akhauriyash/Code-Regression huggingface dataset:
n=int(input())
h=[[0,0,0] for _ in range(n)]
for j in range(n):
  h[j][0],h[j][1],h[j][2]=map(int,input().split())
dp=[[0,0,0] for _ in range(n)]
dp[0][0]=h[0][0]
dp[0][1]=h[0][1]
dp[0][2]=h[0][2]
for i in range(1,n):
    dp[i][0]=h[i][0]+max(dp[i-1][1],dp[i-1][2])
    dp[i][1]=h[i][1]+max(dp[i-1][0],dp[i-1][2])
    dp[i][2]=h[i][2]+max(dp[i-1][0],dp[i-1][1])
print(max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2])))

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

#define rep(i, a, b) for(int i = (a); i < int(b); ++i)
#define rrep(i, a, b) for(int i = (a) - 1; i >= int(b); --i)
#define trav(it, v) for(auto &it : (v))
#define all(v) (v).begin(), (v).end()
#define what_is(x) cerr << #x << " is " << x << endl;
#define sz(x) (int)(x).size()

typedef double fl;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;

int main(){
	ios::sync_with_stdio(0);
    int n, k;
    cin >> n >> k;
    puts(n >= 2*k-1 ? "YES" : "NO");
}

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

def main():
    a, b = map(int, input().split())
    c = gcd(a, b)
    pf = prime_factor(c)
    pfu = set(pf)
    print(len(pfu) + 1)

def gcd(x, y):
    if x < y:
        x, y = y, x  # x >= y
    while y > 0:
        r = x % y
        x = y
        y = r
    return x

def prime_factor(n):
    resid = n
    result = []
    i = 2
    while True:
        if resid <= 1:
            return result
        if i ** 2 > resid:
            result.append(resid)
            return result
        if resid % i == 0:
            result.append(i)
            resid /= i
        else:
            i += 1

if __name__ == "__main__":
    main()


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

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

int main(void) {
	int n,i,j,ans;
	int sum[2001];
	
	memset(sum,0,sizeof(sum));
	
	for(i = 0;i <= 1000;i++){
		for(j = 0;j <= 1000;j++){
			sum[i+j]++;
		}
	}
	
	while(~scanf("%d",&n)){
		ans = 0;
		for(i = max(0,n-2000);i <= -max(-n,-2000);i++){
			ans += sum[i]*sum[n-i];
		}
		printf("%d\n",ans);
	}
	
	return 0;
}

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

int main()
{
    int N;
    cin >> N;
    vector<int> a(N);
    for (int i = 0; i < N; i++)
    {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    int64_t total = 0;
    for (int i = 1; i < N; i++)
    {
        total += abs(a[i] - a[i - 1]);
    }
    cout << total << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 2100000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};

int main(){
  ll h;
  cin >> h;
  int s=0;
  while(h!=1){
    h/=2;
    s++;
  }
  s++;
  ll sum=0;
  rep(i,s){
    sum+=pow(2,i);
  }
  cout << sum <<endl;
}


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

using namespace std;
typedef long long ll;

#define rep(i, N) for (int i = 0; i < (int)N; i++)
const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,29)-1;

const int N_MAX = pow(10,5);

vector<int> adj[N_MAX];
int N, K;

ll dfs(int v, int p) {
  // cout << v << " " << p << endl;
  ll color = K-1, result = 1;
  if (p!=-1) color--;
  for (auto x: adj[v]) {
    if (x==p) continue;
    result *= dfs(x,v); result %= MOD;
    result *= color; result %= MOD;
    color--;
  }
  return result;
}

int main() {
  cin >> N >> K;
  rep(i,N-1) {
    int a, b; cin >> a >> b; a--; b--;
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  ll result = dfs(0,-1) * K;
  result %= MOD;
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 11520
N=int(input())

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr
ans=0
for p,c in factorization(N):
    if p==1:
        continue
    n=1

    while n*(n+1)<=2*c:
        n+=1
    n-=1
    ans+=n

print(ans)

Measured memory_bytes: 63316
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
#define int long
#define ll long long
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) x.size()
#define fi first
#define se second
const int INF = 1e12;
using namespace std;

template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;

using pi=pair<int,int>;
using vi=vc<int>;

vc<pi> G[100010];
vi d;
bool frag = false;

void dfs(int n,int m){
    d[n]=m;
    for(auto a:G[n]){
        if(d[a.fi]==INF) dfs(a.fi,a.se+m);
        else if(d[a.fi]!=d[n]+a.se){
            frag = true;
        }
    }
}

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(20);

    int N,M; cin >> N >> M;
    rep(i,M){
        int a,b,c; cin >> a >> b >> c;
        a--; b--;
        G[a].eb(b,c);
        G[b].eb(a,-c);
    }
    vi D(N,INF);
    d = D;
    rep(i,N){
        if(d[i]!=INF) continue;
        dfs(i,0);
    }
    if(frag) cout << "No" << endl;
    else cout << "Yes" << endl;
}


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

int main() {
	int x;
	cin>>x;
	if(x>=400&&x<=599)
	{
		cout<<"8";
	}
	else if(x>=600 && x<=799)
	{
		cout<<"7";
	}
	else if(x>=800 && x<=999)
	{
		cout<<"6";
	}
	else if(x>=1000 && x<=1199)
	{
		cout<<"5";
	}
	else if(x>=1200 && x<=1399)
	{
		cout<<"4";
	}
	else if(x>=1400 && x<=1599)
	{
		cout<<"3";
	}
	else if(x>=1600 && x<=1799)
	{
		cout<<"2";
	}
	else if(x>=1800 && x<=1999)
	{
		cout<<"1";
	}
	return 0;
}

Measured memory_bytes: 3616
n, k = map(int, input().split())
a = [0] + list(map(int, input().split()))

n += 1
ans = 0
m = dict()
temp = 0
b = []
for i in range(min(n, k)):
    temp = (temp + a[i]) % k
    c = (temp - (i % k) + k) % k
    b.append(c)
    if c in m.keys():
        ans += m[c]
        m[c] += 1
    else:
        m[c] = 1

for i in range(k, n):
    x = i % k
    m[b[x]] -= 1
    temp = (temp + a[i]) % k
    c = (temp - (i % k) + k) % k
    b[x] = c
    if c in m.keys():
        ans += m[c]
        m[c] += 1
    else:
        m[c] = 1

print(ans)


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

using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
ll h[100000];
ll dp[100000];
int main() {
	int N;
	cin >> N;
	for (int i = 0; i < N; i++) cin >> h[i];
	fill(dp, dp + N, 1LL << 60);
	dp[0] = 0;
	for (int i = 0; i + 1 < N; i++) {
		dp[i + 1] = min(dp[i + 1], dp[i] + abs(h[i] - h[i + 1]));
		if (i + 2 < N) dp[i + 2] = min(dp[i + 2], dp[i] + abs(h[i] - h[i + 2]));
	}
	cout << dp[N - 1] << endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll maxn=1e5+1;
vector<pair<ll,ll>> adj_list[maxn];
ll color[maxn];
void dfs(ll s,ll p,ll c)
{
	ll k=1;
	for(ll i=0;i<adj_list[s].size();i++)
	{
		if(adj_list[s][i].first!=p)
		{
			if(k==c) k++;
			color[adj_list[s][i].second]=k;
			dfs(adj_list[s][i].first,s,k);
			k++;
		}
	}
}
void solve()
{
	ll N;
	cin>>N;
	ll a[maxn];
	for(ll i=0;i<N-1;i++)
	{
		ll u,v;
		cin>>u>>v;
		adj_list[u].push_back({v,i+1});
		adj_list[v].push_back({u,i+1});
	}
	dfs(1,-1,-1);
	ll m=-1;
	for(ll i=1;i<=N-1;i++)
	{
		m=max(color[i],m);
	}
	cout<<m<<"\n";
	for(ll i=1;i<=N-1;i++)
	{
		cout<<color[i]<<"\n";
	}
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll T=1,p=0;
	//cin>>T;
	do
	{
		solve();
		p++;
	}while(p<T);
	return 0;
}



Measured memory_bytes: 10752
hi, hy = map(int, input().split())
ki, ky = map(int, input().split())
a, b, c, d = map(int, input().split())
h = hi * a + hi // 10 * c + hy * b + hy // 20 * d
k = ki * a + ki // 10 * c + ky * b + ky // 20 * d
if h > k: print("hiroshi")
elif h < k: print("kenjiro")
else: print("even")


Measured memory_bytes: 5596
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <limits>
using namespace std;
using ll = long long;

ll pow(ll x, ll n) { //x^nの計算
  ll res = 1;
  while (n > 0) {
    if (n & 1){
      res *= x;  // n の最下位bitが 1 ならば x^(2^i) をかける
    }
    x *= x;
    n >>= 1;  // n を1bit 左にずらす
  }
  return res;
}

int main(){
  ll N;
  cin >> N;
  int k=1;
  while(26*(pow(26,k)-1)<25*N){
    k++;
  }
  vector<char> alp(k);
  N-=26*(pow(26,k-1)-1)/25+1;
  for(int i=0;i<k;i++){
    alp[k-i-1]=(char)('a'+N%26);
    N/=26;
  }
  for(int i=0;i<k;i++){
    cout << alp[i];
  }
  cout << endl;
}

Measured memory_bytes: 4052
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
#include <map>
#include <iomanip>
#include <limits.h>

using namespace std;    
typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const bool DEBUG = true;
const ll MOD = 1000000007;
int main(){

    ll N;
    cin >> N;

    vector<ll> v(N);
    for(int i = 0; i < N ; i++) cin >> v[i];

    vector<int> cnt(3, -1);
    ll ans = 1;
    for(int n = 0; n < N; n++){
        ll tmp = 0;
        for(int i = 0; i < 3; i++ ){
            //cout << cnt[i] << endl;
            if(cnt[i] + 1 == v[n]){
                tmp ++;
            }
        }
        ans *= tmp;
        ans %= MOD;
        for(int i = 0; i < 3; i++ ){
            if(cnt[i] + 1 == v[n]){
                cnt[i] ++;
                break;
            }
        }

    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char a,b,c,d; cin>>a>>b>>c>>d;
  if(a==b&&b==c) cout<<"Yes"<<endl;
  else if(b==c&&c==d) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

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

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
template <typename T> using V = vector<T>;
template <typename T> using VV = V<V<T>>;

int main() {
    string s;
    cin >> s;
    int cnt = 0;
    int n = int(s.size());
    ll ans = 0;
    for (int i = n-1; i >= 0; i--) {
        if (s[i] == 'B') {
            ans += n - cnt - 1 - i;
            cnt++;
        }
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
#define fill(a,val) memset(a, (val), sizeof a)
#define pb push_back
#define lli long long int
#define scantype int
#define endl "\n"
#define unique(x) x.erase(unique(x.begin(),x.end()), x.end())
#define debug(x) cerr << #x " = " << (x) << '\n'
#define what_is(x) cerr << #x << " is " << x << endl;
 
lli MOD  = 1000000007;
lli inf = 1e15;
 
void scan(scantype &x);

lli powermod(lli _a,lli _b,lli _m){lli _r=1;while(_b){if(_b%2==1)_r=(_r*_a)%_m;_b/=2;_a=(_a*_a)%_m;}return _r;}
lli string_to_number(string s){lli x=0; stringstream convert(s); convert>>x; return x;}
lli add(lli a,lli b){lli x = (a+b)%MOD; return x; }
lli mul(lli a,lli b){lli x = (a*b)%MOD; return x; }
lli sub(lli a,lli b){lli x = (a-b+MOD)%MOD; return x; }
lli div(lli a,lli b){lli x = a;lli y = powermod(b,MOD-2,MOD);lli res = (x*y)%MOD;return res;}

bool isprime(long long int n)
{
    if(n ==1 )
        return false;
    if(n == 2)
        return true;
    for(long long int i =2;i<=n/i;i++)
    {
        if(n%i == 0)
            return false;
    }
    return true;
}
int main(void)
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);   
	int t;
	t = 1;
	while(t--)
	{
		lli a,b,c,d;
		cin>>a>>b>>c>>d;
		lli n;
		cin>>n;
		lli mi = min(4*a,min(2*b,c));
		lli mii = min(2*mi,d);

		if(n%2)
		{
			cout<<mii*(n/2)+mi;
		}
		else
			cout<<mii*(n/2);

	}    


    
    return 0;    
}
 

void scan(scantype &x)
{
    register int c = getchar(); //for negative/positive
    x = 0;
    int neg = 0;
    for(;((c<48 || c>57) && c != '-');c = getchar());
    if(c=='-') {neg=1;c=getchar();}
    for(;c>47 && c<58;c = getchar()) {x = (x<<1) + (x<<3) + c - 48;}
    if(neg) x=-x;
}


Measured memory_bytes: 256
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val Array(n, m) = sc.nextLine.split(" ").map(_.toInt)
    val gateRanges = List.fill(m)(sc.nextLine.split(" ").map(_.toInt))
    val leftMax = gateRanges.map(_(0)).max
    val rightMin = gateRanges.map(_(1)).min
    if ((rightMin - leftMax) < 0) println(0)
    else println(rightMin - leftMax + 1)
  }
}

Measured memory_bytes: 114236
import sys
input = sys.stdin.readline

s = list(input().strip())
l = []

b = ""
for v in s:
    if v in ["A", "G", "C", "T"]:
        b += v
    else:
        l.append(b)
        b = ""
l.append(b)

print(max([len(v) for v in l]))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, a) for (ll i = 0; i < (a); ++i)
#define pb push_back
#define all(v) v.begin(),v.end()
#define sort_1(v) sort(v.begin(),v.end())
#define sort_2(v) sort(v.begin(),v.end(),greater<ll>())
#define reverse(v) reverse(v.begin(),v.end())
typedef long long ll;
typedef long double la;
using namespace std;

int main(){
    ll s;
    cin >> s;
    ll l = pow(10,9);
    ll x1 = 0;
    ll y1 = 0;
    ll x2 = l;
    ll y2 = 1;
    ll x3 = (l - s%l)%l;
    ll y3 = (s+x3)/l;
    cout << x1 << " " << y1 << " " << x2 << " " << y2 << " " << x3 << " " << y3 << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

//Longest Steps
public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			int k = sc.nextInt();
			if(n==0&&k==0)break;
			int[][] a = new int[n+1][2];
			boolean[] c = new boolean[n+1];
			for(int i=0;i<k;i++)c[sc.nextInt()] = true;
			int m0 = 0;
			int m1 = 0;
			for(int i=1;i<=n;i++){
				a[i][0] = c[i]?a[i-1][0]+1:0;
				a[i][1] = c[i]?a[i-1][1]+1:a[i-1][0]+1;
				m0 = Math.max(m0, a[i][0]);
				m1 = Math.max(m1, a[i][1]);
			}
			System.out.println(c[0]?m1:m0);
		}
	}
}

Measured memory_bytes: 15000
n=int(input())
cards=[[False for _ in range(13)] for _ in range(4)]
suits={"S":0,"H":1,"C":2,"D":3}
for i in range(n):
    s,c=input().split()
    cards[suits[s]][int(c)-1] = True

suits_key=list(suits.keys())
for i in range(4):
    for j in range(13):
        if(not cards[i][j]):
            print("{0} {1}".format(suits_key[i],j+1))


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

using namespace std;

double value[45];
int size[45];

double get_value(string &pile){
    bool b_can_move = 0, w_can_move = 0;
    double b_max, w_min;
    double last_value = 0;
    for(int i=0;i<pile.length();i++){
        double value;
        if(pile[i]=='B'){
            if(b_can_move){
                b_max = max(b_max,last_value);
            }
            else{
                b_max = last_value;
            }
            b_can_move = 1;
            if(w_can_move){
                value = (b_max + w_min) / 2;
            }
            else{
                value = b_max + 1;
            }
        }
        if(pile[i]=='W'){
            if(w_can_move){
                w_min = min(w_min,last_value);
            }
            else{
                w_min = last_value;
            }
            w_can_move = 1;
            if(b_can_move){
                value = (b_max + w_min) / 2;
            }
            else{
                value = w_min - 1;
            }
        }
        last_value = value;
    }
    return last_value;
}

void enumerate(int st, int ed,map<double,int> &table ,double value_sum = 0, int size_sum = 0){
    if(st==ed){
        if(table.count(value_sum)){
            table[value_sum] = max(table[value_sum], size_sum);
        }
        else{
            table[value_sum] = size_sum;
        }
    }
    else{
        enumerate(st+1, ed, table, value_sum, size_sum);
        enumerate(st+1, ed, table, value_sum + value[st], size_sum + size[st]);
    }
}

int find_zero_value(int st,int ed,map<double,int> &table ,double value_sum = 0, int size_sum = 0){
    if(st==ed){
        if(table.count(-value_sum)){
            return table[-value_sum] + size_sum;
        }
        else return 0;
    }
    else{
        int get1 = find_zero_value(st+1, ed, table, value_sum, size_sum);
        int get2 = find_zero_value(st+1, ed, table, value_sum + value[st], size_sum + size[st]);
        return max(get1, get2);
    }
}

map<double,int> table, table2;

int main()
{
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        string pile;
        cin>>pile;
        size[i] = pile.length();
        value[i] = get_value(pile);
        //printf("%f\n",value[i]);
    }
    if(n<=20){
        enumerate(0,n,table);
        printf("%d\n",table[0]);
    }
    else{
        
        enumerate(0,20,table);
        printf("%d\n",find_zero_value(20,n,table));
        /*
        enumerate(0,20,table);
        enumerate(20,n,table2);
        int ans = 0;
        for(map<double,int>::iterator it = table.begin(); it!=table.end(); it++){
            double my_value = it->first;
            if(table2.count(-my_value)){
                int my_size = table[my_value] + table2[-my_value];
                ans = max(ans,my_size);
            }
        }
        printf("%d\n",ans);
        */
    }

    return 0;
}

Measured memory_bytes: 68792
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 2e9;
int N;
string S, T;

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

  cin >> N;
  cin >> S >> T;
  string ans = "";
  rep(i, N) {
    ans+=S[i];
    ans+=T[i];
  }
  cout << ans << "\n";
  return 0;
}

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

long long int N, a, b[100000], i;
char c;

static inline long long int p(long long int n){
    static long long int ret = 1, bi = 2;
    while(n){
        if(n & 1){
            ret *= bi;
            ret %= 1000000007;
        }
        bi *= bi;
        bi %= 1000000007;
        n >>= 1;
    }
    return ret;
}

int main(){
    for(c = getchar();c != 10;c = getchar()){
        N = ((N * 5) << 1) + c - 48;
    }
    ++(*b);
    for(i = 0; i < N; ++i){
        for(c = getchar(), a = 0;c != 32 && c != 10;c = getchar()){
            a = ((a * 5) << 1) + c - 48;
        }
        ++b[a];
    }
    for(i = ~N & 1; i < N; i += 2){
        if(b[i] != 2){
            puts("0");
            return 0;
        }
    }
    cout << p(N >> 1) << endl;
    return 0;
}


Measured memory_bytes: 1024
/*by freesteed*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define pb push_back
#define fill(x,c) memset(x,c,sizeof(x))
#define fi first
#define se second
#define sz(A) (int)(A.size())
#define all(x) (x).begin(),(x).end()
#define caset int ___T; cin>>___T; for(int cs=1;cs<=___T;cs++)
#define get_be(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
//get_be biger & equal
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
const ll mod=1e9+7;
const ll oo=1e9+10;
const int Max = 1e6+10;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
//ll a[Max];
ll n;
void solve(){
	ll k;
	cin>>n>>k;
	cout<<(n*500>=k?"Yes":"No");
}
int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//caset{
		solve();
	//}
  	return 0;
}





Measured memory_bytes: 256
import itertools
N=int(input())
xy=[list(map(int,input().split())) for i in range(N)]

l=[i for i in range(N)]
kai=N
for i in range(1,N):
  kai *= i

p = itertools.permutations(l, N)

def d(xi,xj,yi,yj):
  a=((xi - xj)**2 + (yi - yj)**2)**(1/2)
  return a

ds=0
for i in p:
  for j in range(1,N):
    ds += d(xy[i[j-1]][0],xy[i[j]][0],xy[i[j-1]][1],xy[i[j]][1])

print(ds/kai)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <cstring>
#include <cmath>
#include <cstdio>
 
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, n) for(int i = 0; i < (n); i++)
#define MP make_pair
#define X first
#define Y second
#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend()

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

const int INF = 1<<29;

int main(){
	int a, b;
	char c;
	cin >> a;
	while(cin >> c, c != '='){
		cin >> b;
		if(c == '+') a+=b;
		if(c == '-') a-=b;
		if(c == '*') a*=b;
		if(c == '/') a/=b;
	}
	cout << a << endl;

    return 0;
}

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

using ll = long long;
#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define INF 1e9
// constexpr ll INF = 1LL << 60;


int main(){
  int N, M;
  cin >> N >> M;
  cout << N*(N-1)/2 + M*(M-1)/2 << endl;
  return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
const int max0=100010;
int n,m,a,i;
	int countx[max0],data[max0],ans[max0],top;
	int dic[max0];
	bool had[max0],wrong;
int main()
{

	scanf("%d%d%d",&n,&m,&a);
	for(i=0;i<a;i++)
		scanf("%d",&data[i]);
	for(i=a-1;i>=0;i--)
		if(had[data[i]]==0){
                had[data[i]]=1,ans[top++]=data[i];
		}
    for(i=1;i<=m;i++)
        if(had[i]==0){
                had[i]=1,ans[top++]=i;
		}
    //printf("!%d %d %d\n",top,ans[1],p1);
	while(top>1&&ans[top-1]>ans[top-2])top--;
	if(ans[top-1]==1)top--;
    //printf("!%d\n",top);
	for(i=top-1;i>=1;i--)dic[ans[i]]=ans[i-1];
	for(i=a-1;i>=0;i--){
		countx[data[i]]++;
		if(dic[data[i]]!=0)
			if(countx[data[i]]>countx[dic[data[i]]])
				countx[data[i]]=countx[dic[data[i]]];
	}
	if(top!=0&&countx[ans[top-1]]<n)printf("No\n");
	else 	printf("Yes\n");
	return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
	int N;
	vector<int> X(100);

	cin >> N;

	for (int i = 0; i < N; i++) {
		cin >> X.at(i);
	}

	int min = 10000000000;
	for (int i = 0; i < 100; i++) {
		int sum = 0;
		for (int j = 0; j < N; j++) {
			sum += (X.at(j) - i) * (X.at(j) - i);
		}
		if (sum < min) {
			min = sum;
		}
	}

	cout << min << endl;

	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

def gcd(a: int, b: int):
    """ https://cocodrips.hateblo.jp/entry/2014/03/05/143623
    """
    while b:
        a, b = b, a%b
    return a

def lcm(a: int, b: int):
    return a * b // gcd(a, b)


def main():
    #N = int(input())
    K,X = map(int, input().split())
    #vA = list(map(int, input().split())
    S = input().rstrip()
    #print(S)
    #print(lcm(N, M))
    print("Yes" if X<=500*K else "No")
    #print(S.count("ABC"))


if __name__ == "__main__":
    main()


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

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

int main(){
    int     n, d[100000] = {0};

    scanf("%d", &n);
    for(int i=0; i<n; i++){ scanf("%d", &d[i]); }
    qsort( d, n, sizeof(int), compare_int );

    printf("%d\n", d[n/2] - d[(n/2)-1]);

    return 0;
}

Measured memory_bytes: 2288
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
	int n, s, r[20000], i, j, res;
	while (cin >> n >> s, n && s)
	{
		for (i = res = 0; i < n; i++)
			cin >> r[i];
		sort(r, r+n);
		for (i = n-1; i > 0; i--)
			for (j = i-1; j >= 0; j--)
				if (r[i]+r[j] > s)
					res++;
				else
					break;
		cout << res << endl;
	}
}

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

int main() {
   string S ;
  cin >> S ;
  char a = S.at(2);
  char b = S.at(3);
  char c = S.at(4);
  char d = S.at(5);
  
  if(a==b && c==d){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


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


int main()
{
	int n;
	int i;
	long long p;
	long long a;
 	double x;
  
	cin >> n;
	cin >> a;

	if(a==0){
		cout << 0 << endl;
		return 0; 
	}
	p = a;
  	x = p;
  
	for(i=1;i<n;i++){
		cin >> a;
		if(a==0){
			cout << 0 << endl;
			return 0; 
		}
		if(p>0){
          	x = p;
          	x = x * a;
 			if(x>4000000000000000000){
				p=-1;
			} else {
         			p = p * a;
					if(p>1000000000000000000){
						p=-1;
                    }
			}
		}
	}
	cout << p << endl; 
	return 0;
}

Measured memory_bytes: 3620
# AtCoder Educational DP Contest
# A - Frog 1


def main():
    n, *h = map(int, open(0).read().split())

    DP = [0 for _ in range(n)]
    DP[1] = abs(h[1] - h[0])
    for i in range(2, n):
        c1, h1 = DP[i - 1], h[i - 1]
        c2, h2 = DP[i - 2], h[i - 2]
        h_now = h[i]
        a = c1 + abs(h1 - h_now)
        b = c2 + abs(h2 - h_now)
        DP[i] = min(a, b)

    res = DP[-1]
    print(res)


if __name__ == '__main__':
    main()


Measured memory_bytes: 14132
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
  ll N,ans=0;
  cin>>N;
  vector<ll> vec(N);
  vector<ll> wa(N);
  ll maxwa=0;
  vector<ll> sa(N);
  for(ll i=0;i<N;++i){
    cin>>vec.at(i);
    wa.at(i)=vec.at(i)+i+1;
    maxwa=max(maxwa,wa.at(i));
    sa.at(i)=i+1-vec.at(i);
  }
  unordered_map<ll,ll> maxcount;
  for(ll i=0;i<N;++i){
    ++maxcount[wa.at(i)-1];
  }
  for(ll i=0;i<N;i++){
    if(sa.at(i)-1>=0 && sa.at(i-1)<maxwa){
      ans+=maxcount[sa.at(i)-1];
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 16752
#include<iostream>
#include <climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define INF (int)1e9
#define INFL (ll)1e11
using namespace std;
typedef long long ll;
typedef pair<int, int> P;



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

	int N, K;
	cin >> N >> K;
	vector<int> x;
	int i0;
	REP(i, N) {
		int a;
		cin >> a;
		if (a > 0 && (i == 0 || x[i - 1] < 0)) {
			x.push_back(0);
			i0 = i;
		}
		else if (a == 0) {
			K--;
			i0 = i;
		}
		x.push_back(a);
		if (i == N - 1 && a < 0) {
			i0 = N;
			x.push_back(0);
		}
	}
	if (K==0) {
		cout << 0 << "\n";
		return 0;
	}
	int res = INF;
	for (int i = 1;i <= K;i++) {
		if (i == K) {
			if (i0 + i < x.size()) {
				res = min(res, x[i0 + i]);
			}
			if (i0 - i >= 0) {
				res = min(res, -x[i0 - i]);
			}
		}
		else {
			if (i0 + i < x.size() && i0 - (K - i) >= 0) {
				res = min(res, 2 * x[i0 + i] - x[i0 - (K - i)]);
				res = min(res, x[i0 + i] - 2 * x[i0 - (K - i)]);
			}
		}
	}
	cout << res << "\n";

	return 0;
}

Measured memory_bytes: 892
N = int(input())
eve = [0]*4
for i in range(N):
    a = input()
    if(a == "AC"):
        eve[0]+=1
    elif(a ==  "WA"):
        eve[1]+=1
    elif(a == "TLE"):
        eve[2]+=1
    else:
        eve[3]+=1
print("AC x ",eve[0])
print("WA x ",eve[1])
print("TLE x ",eve[2])
print("RE x ",eve[3])

Measured memory_bytes: 9212
#include<iostream>

using namespace std;

int main()
{
    int N, M; 
    cin >> N >> M;
    int i,j,k,l;

    if(N%2==1){
        i = 1;
        j = N-1;
        while(M>0){
            printf("%d %d\n", i , j);
            i++;
            j--;
            M--;
        }
    }else{
        int t = (N-1)/2;
        i = 1;
        j = 1 + ((t - 1)/2) * 2 + 1;
        k = j + 1;
        l = k + (t/2)*2;
        while(M>0){
            if(M%2==0){
                printf("%d %d\n", k , l);
                k++;
                l--;
                M--;
            }else{
                printf("%d %d\n", i , j);
                i++;
                j--;
                M--;
            }
        }
    }

    return 0;
}


Measured memory_bytes: 3764
const MOD: usize = 1e9 as usize + 7;
#[derive(Default)]
//NOTE
//declare variables to reduce the number of parameters for dp and dfs etc.
struct Solver {}

impl Solver {
    fn solve(&mut self) {
        let stdin = std::io::stdin();
        let mut scn = Scanner {
            stdin: stdin.lock(),
        };
        let n: usize = scn.read();
        let k: usize = scn.read();

        let mut sum_left = 0;
        let mut sum_right = 0;

        let mut right = n;
        let mut result = 1;
        for (left, i) in (1..=n).enumerate() {
            sum_left += left;
            sum_right += right;
            if i >= k {
                result += sum_right - sum_left + 1;
                result %= MOD;
            }
            //left += 1;
            right -= 1;
        }
        println!("{}", result);
    }
}

fn main() {
    std::thread::Builder::new()
        .stack_size(64 * 1024 * 1024) // 64MB
        .spawn(|| {
            let mut solver = Solver::default();
            solver.solve()
        })
        .unwrap()
        .join()
        .unwrap();
}
pub mod utils {
    const DYX: [(isize, isize); 8] = [
        (0, 1),   //right
        (1, 0),   //down
        (0, -1),  //left
        (-1, 0),  //top
        (1, 1),   //down right
        (-1, 1),  //top right
        (1, -1),  //down left
        (-1, -1), //top left
    ];

    pub fn try_adj(y: usize, x: usize, dir: usize, h: usize, w: usize) -> Option<(usize, usize)> {
        let ny = y as isize + DYX[dir].0;
        let nx = x as isize + DYX[dir].1;
        if ny >= 0 && nx >= 0 {
            let ny = ny as usize;
            let nx = nx as usize;
            if ny < h && nx < w {
                Some((ny, nx))
            } else {
                None
            }
        } else {
            None
        }
    }
}

//snippet from kenkoooo
pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_line(&mut self) -> String {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b'\n' || b == b'\r')
            .take_while(|&b| b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 2236
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <chrono>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>

using namespace std;

int main() {
    int N, Q;
    cin >> N >> Q;
    vector<pair<int, pair<int, int>>> con(N);
    int s, t, x;
    for (int i = 0; i < N; i++) {
        cin >> s >> t >> x;
        con[i] = make_pair(x, make_pair(s - x, t - x - 1));
    }
    set<pair<int, int>> D;
    vector<int> ans(Q);
    int d;
    for (int i = 0; i < Q; i++) {
        cin >> d;
        D.insert(make_pair(d, i));
        ans[i] = -1;
    }

    sort(con.begin(), con.end());
    for (int i = 0; i < N; i++) {
        int X = con[i].first;
        int L = con[i].second.first;
        int R = con[i].second.second;
        if (D.empty()) {
            break;
        }
        auto it = D.lower_bound({L, -1});
        while (it != D.end() && (*it).first <= R) {
            ans[(*it).second] = X;
            D.erase(it++);
        }
    }
    for (int i = 0; i < Q; i++) {
        cout << ans[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 14336
#include <iostream>
#include <string>

using namespace std;


int main() {

    int n;
    cin >> n;

    string str;
    cin >> str;

    int bracketsL {};
    int invalidR {};

    for(const auto c : str) {
        switch(c) {
        case '(':
            ++bracketsL;
            break;
        case ')' :
            if(bracketsL != 0) {
                --bracketsL;
            }
            else {
                ++invalidR;
            }
            break;
        }
    }

    while(invalidR-- != 0) {
        cout << '(';
    }
    cout << str;
    while(bracketsL-- != 0) {
        cout << ')';
    }

    cout << endl;

    return 0;
}

Measured memory_bytes: 256
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define FastRead ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define ll int
#define bits_count __builtin_popcountll
#define endl '\n'
#define double long double
#define ld double
#define FOR(i,a,n) for (ll i=(a);i<=(n);++i)
#define RFOR(i,a,n) for (ll i=(n);i>=(a);--i)
#define FI(i,n) for (ll i=0; i<(n); ++i)
#define ZERO(a) memset((a),0,sizeof((a)))
#define MINUS(a) memset((a),-1,sizeof((a)))
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define all(g) g.begin(),g.end()
#define sz(x) (ll)x.size()
int fastMax(int x, int y) { return (((y-x)>>(32-1))&(x^y))^y; }
int fastMin(int x, int y) { return (((y-x)>>(32-1))&(x^y))^x; }

// #include <ext/pb_ds/assoc_container.hpp> // Common file
// #include <ext/pb_ds/tree_policy.hpp>     // Including tree_order_statistics_node_updat
// using namespace __gnu_pbds;
// typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int MAXN = 3005;
int n,S; 
int a[MAXN];

int dp[MAXN][MAXN][2];
const int MOD = 998244353;

int rec(int idx,int sum,int flag){
    if(idx == n+1) return 0;

    int &ans = dp[idx][sum][flag];

    if(ans != -1) return ans;

    ans = 0;

    ans = (ans + rec(idx+1,sum,flag));

    if(flag == 0){
        int n_S = sum + a[idx];
        if(n_S < S) ans = (ans + (idx*rec(idx+1,n_S,1)%MOD)%MOD)%MOD;
        if(n_S == S) ans = (ans + (idx*(n-idx+1))%MOD)%MOD; 
    }else {
        int n_S = sum + a[idx];
        if(n_S < S) ans = (ans + rec(idx+1,n_S,flag)%MOD)%MOD;
        if(n_S == S) ans = (ans + (n-idx+1)%MOD)%MOD; 
    }

    return ans;
}

void solve(){
    cin>>n>>S;

    FOR(i,1,n) cin>>a[i];

    MINUS(dp);

    cout<<rec(1,0,0)<<endl;
}

signed main(){

   FastRead;    


    int t = 1; 
    // cin>>t; 
    FOR(i,1,t){
        // cout<<"Case #"<<i<<": ";
        solve();
    }
}

Measured memory_bytes: 141696
import java.util.Scanner;

class Main {
    public static void main (String args[]) {
	Scanner scan = new Scanner(System.in);
	String c = scan.next(), str = "";

	for (int i=0; i<c.length(); i++) {
	    str = c.substring(i,i+1) + str; 
	}

	System.out.println(str);
    }
}

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

typedef long long ll;

string to_s(ll n){
	string s;
	do{
		s.push_back( (n % 10) + '0' );
		n /= 10;
	}while( n != 0 );
	reverse(s.begin(), s.end());
	return s;
}

bool is_prime(ll x){
	for(ll k = 2 ; k * k <= x ; k++ ){
		if( x % k == 0 ) return false;
	}
	return true;
}

ll pow10(ll x){
	ll res = 1;
	for(ll i = 0 ; i < x ; i++ ) res *= 10;
	return res;
}

int main(){
	ll n, c;
	cin >> n >> c;
	if( c < 0 ){
		if( n == 1 ){
			cout << 11 << endl;
		}else{
			for(int i=0 ; i < 2 * n ; i++ ) cout << 9;
			cout << endl;
		}
		
	}else{
		for(ll i = pow10(2 * n + 1) - 1 ; i >= pow10(2 * n) ; i-- ){
			string s = to_s(i);
			string t = s;
			reverse(s.begin(), s.end());
			if( s == t && (i / pow10(n)) % 10 == c && is_prime(i) ){
				cout << i << endl;
				return 0;
			}
		}
	}
}

Measured memory_bytes: 1208
N = int(input())
As = list(map(int, input().split()))
print(" ".join([str(a) for a in As]))

for i in range(1,N):
    tmp = As[i]
    j = i - 1
    # 上にさかのぼりながら挿入できるところを探す
    # さかのぼりきる & 今より大きいところが見つかる
    while j >= 0 and As[j] > tmp:
        As[j+1] = As[j]
        j -= 1 
    As[j+1] = tmp
    print(" ".join([str(a) for a in As]))



Measured memory_bytes: 5604
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
 
int main() {
  int n,k;
  cin >> n >> k;
  
  int h[n];
  rep(i,n)cin >> h[i];
  
  int ans=0;
  
  rep(i,n){
    if(h[i]>=k)ans++;
  }
  
  cout << ans << endl;
}



Measured memory_bytes: 640
import sys

n_bills, sum_ = map(int, sys.stdin.readline().split())

sum_k = sum_ // 1000
max_n_10k = sum_k // 10
max_n_5k = sum_k // 5

found = True
for n_10k in range(max_n_10k + 1):
  for n_5k in range(min(max_n_5k + 1, n_bills - n_10k + 1)):
    if sum_k == n_10k * 10 + n_5k * 5 + (n_bills - n_10k - n_5k):
      print(n_10k, n_5k, n_bills - n_10k - n_5k)
      break
  else:
    continue
  break
else:
  found = False
  
if not found:
  print(-1, -1, -1)

Measured memory_bytes: 3064
S = input()

N = len(S)
# 文字列がすべて同じ文字ならK=Nになるので
K = N
for i in range(N-1):
    # iとその右の文字が異なる場合、長い方を書き換えるとKをなるべく大きく保てる
    # Kの減る幅をなるべく小さように選んでいくイメージ。
    if S[i] != S[i+1]:
        tmp = max(i+1, N - (i+1))
        K = min(K, tmp)

print(K)


Measured memory_bytes: 3188
#include <iostream>
#include <cstring>
#include <algorithm>

using namespace std;

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

    int n;
    cin >> n;
    int c[n+1];
    memset(c, 0, sizeof(c));
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        c[a]++;
    }
    sort(c, c+n+1);

    int ps[n+1];
    for (int i = 0; i <= n; i++) {
        ps[i] = i == 0 ? 0 : ps[i-1] + c[i];
    }

    for (int i = 1; i <= n; i++) {
        int l = -1, r = n + 1;
        while (r - l > 1) {
            int mid = (l + r) / 2;

            int t = upper_bound(c, c + n + 1, mid) - c;
            if (ps[t-1] + 1ll * (n + 1 - t) * mid >= 1ll * i * mid) {
                l = mid;
            } else {
                r = mid;
            }
        }

        cout << l << "\n";
    }

    return 0;
}


Measured memory_bytes: 3200
#include<iostream>
#include<cstdio>

using namespace std;



int main(){
  char data[12];
  int jadge=0;//0Èçø«ª¯//PÈço//2Èçx
  while(cin >> data){
    jadge=0;
    
   
    
    
    for(int i=0, j=0;i<3;i++,j+=3){//¡ÉÀÔÆ«
      if(data[0+j]=='o'&&data[1+j]=='o'&&data[2+j]=='o')jadge=1;
      if(data[0+j]=='x'&&data[1+j]=='x'&&data[2+j]=='x')jadge=2;
      //cout << j<< endl;
    }
    
    
    //cÉÈçÔÆ«
    for(int i=0;i<3;i++){
      if(data[0+i]=='o'&&data[3+i]=='o'&&data[6+i]=='o')jadge=1;
      if(data[0+i]=='x'&&data[3+i]=='x'&&data[6+i]=='x')jadge=2;
    }
        
    //ÎßÉÈçÔÆ«
    if(data[0]=='o'&&data[4]=='o'&&data[8]=='o')jadge=1;
    if(data[0]=='x'&&data[4]=='x'&&data[8]=='x')jadge=2;
    if(data[2]=='o'&&data[4]=='o'&&data[6]=='o')jadge=1;
    if(data[2]=='x'&&data[4]=='x'&&data[6]=='x')jadge=2;

    switch(jadge){
    case 1:
      printf("o\n");
      break;
    case 2:
      printf("x\n");
      break;
    case 0:
      printf("d\n");
      break;
    }
    
  }

  return 0;
}

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

signed main () {
	int n, a, b;
	cin >> n >> a >> b;
	vector < long long > v(n);
	for (int i = 0; i < n; ++i) 
		cin >> v[i];
	sort(v.rbegin(), v.rend());
	long long m = 0;
	for (int i = 0; i < a; ++i)
		m += v[i];
	cout << fixed << setprecision(15) << double(m) / double(a) << '\n';
	long long l = lower_bound(v.begin(), v.end(), v[a - 1], greater<long long>()) - v.begin();
	long long r = upper_bound(v.begin(), v.end(), v[a - 1], greater<long long>()) - v.begin();
	long long len = r - l;
	vector < long long > c(len + 1, 1), wa(len + 1, 1);
	for (long long i = 1; i <= len; ++i) {
		c[i] = (c[i - 1] * (len - i + 1)) / i;
		wa[i] = wa[i - 1] + c[i];
	}
	if (v[a - 1] < v[0])
		cout << c[a - l] << '\n';
	else if (v[a - 1] == v[b - 1])
		cout << wa[b - l] - wa[a - l - 1] << '\n';
	else
		cout << wa[len] - wa[a - l - 1] << '\n';
}


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

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

        for (int i = 0; i < s.length(); i++) {
            if (i % 2 == 0) {
                System.out.print(s.charAt(i));
            }
        }
    }
}


Measured memory_bytes: 29112
#include<bits/stdc++.h>
using namespace std;
const long long mod=1e9+7;//10^9+7 
map<long long ,long long>dp;
long long so(long long x)
{
 	if(dp[x])
 	return dp[x];
 	else
 	{
 	return dp[x]=((so(x/2)+so((x-1)/2)+so((x-2)/2)))%mod;
 	}
}
int main()
{
 	dp[0]=1;
 	dp[1]=2;
 	long long n;
	 cin>>n;
	 cout<<so(n)<<endl;
	 return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
typedef vector<int> vi;
typedef vector<ll> vl;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define IN cin >> 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (m-1); i >= (int)(n); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

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

int n,x;


int main(){
    cin >> n >> x;
    ll a[n] = {};
    inrep(n,a);
    sort(a,a+n);

    ll ans = 0;

    rep(i,0,n-1){
        if(x >= a[i]){
            x -= a[i];
            ans++;
        }else{
            break;
        }
        if(x < 0)break;
    }

    if(a[n-1] == x)ans++;
    P(ans);
    
	return  0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)  for(int i=0;i<n;i++)
#define rep1(i,n)  for(int i=1;i<=n;i++)
#define fast_io() ios_base::sync_with_stdio(false); cin.tie(NULL)
using namespace std;
typedef long long ll;

int main() {
    int n, m,sum = 0,vote;
    
    cin >> n >> m;
    vector<int> votes(n + 1);
    rep(i,n){
        cin >> vote;
        votes[i] = vote;
        sum += vote;
    }
    long double minimun = 1.0 / (4.0 * m);
    bool flag = false;
    int mcount = 0;
    long double ans;
    //cout << "sum: " << sum << "\n";
    rep(i,n){
        ans = (votes[i] + 0.0) / (sum + 0.0);
       // cout << "ans: " << ans << '\n';
        //cout << "minimun: " << minimun << '\n';
        if (ans >= minimun) mcount++;
        if (mcount >= m){
            flag = true;
            break;
        }
    }
    cout << (flag? "Yes" : "No");
    return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.buffer.readline

def main():
    N = int(input())
    base = [i+1 for i in range(9)]
    m = 3234566667+10000
    
    while len(base) < N:
        use = base
        for num in base:
            st = str(num)
            if st[-1] == "0":
                if int(st+"0") <= m:
                    use.append(int(st+"0")) 
                if int(st+"1") <= m:
                    use.append(int(st+"1"))
            elif st[-1] == "9":
                if int(st+"8") <= m:
                    use.append(int(st+"8"))
                if int(st+"9") <= m:
                    use.append(int(st+"9"))
            else:
                s = int(st[-1])
                st = int(st)
                if st*10+s-1 <= m:
                    use.append(st*10+s-1)
                if st*10+s <= m:
                    use.append(st*10+s)
                if st*10+s+1 <= m:
                    use.append(st*10+s+1)
        base = use
        
    print(base[N-1])
    
if __name__ == "__main__":
    main()


Measured memory_bytes: 45716
n = gets.to_i
t,a = gets.split.map &:to_i
h =  gets.split.map &:to_i

best = 99999999999
result = -1

n.times do |i|
  temp = t * 1000 - h[i] * 6
  if (a * 1000 - temp).abs < best
    best = (a * 1000 - temp).abs
    result = i + 1
  end
end

puts result


Measured memory_bytes: 1788