akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int dp[5][20020];
//dp[i][j]表示选择前i个商品时拥有的选法,这是很简单的背包问题
//那么dp[i][j]=dp[i-1][j-c]+dp[i-1][j-2*c]+.....dp[i-1][j-k*c]
int main(void)
{
    dp[0][0]=1;
    int a[4];
    int c[4];
    c[1]=500;
    c[2]=100;
    c[3]=50;
    int x;
    cin>>a[1]>>a[2]>>a[3]>>x;
    for(int i=1;i<=3;++i)
    {
        for(int j=0;j<=x;j+=50)
        {
            for(int k=0;k<=j/c[i]&&k<=a[i];k++)
            {
                dp[i][j]=dp[i][j]+dp[i-1][j-k*c[i]];
            }
        }
    }
    cout <<dp[3][x]<<endl;
    return 0;
}


Measured memory_bytes: 512
let () =
  let n, k = Scanf.scanf "%d %d" (fun n k -> n, k) in
  let a = Array.init n (fun _ -> Scanf.scanf " %d" (fun x -> x)) in
  Array.sort (fun x y -> y - x) a;
  Array.sub a 0 k |> Array.fold_left (+) 0
  |> Printf.printf "%d\n"


Measured memory_bytes: 384
#include<bits/stdc++.h> 
using namespace std;   
int main()  
{  
    int a,b;
	cin>>a>>b;
	if(a%3==0||b%3==0||(a+b)%3==0)
		cout<<"Possible"<<endl;
	else
		cout<<"Impossible"<<endl;
}  

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#define maxn 200010
int a[maxn],head[maxn],tot,n,d[maxn],ans,mx[maxn];
using namespace std;
struct node{
	int to,next;
}e[maxn<<1];
void add_edge(int u,int v){
	tot++,e[tot].to=v,e[tot].next=head[u],head[u]=tot;
}
void dfs(int u,int fa){
	int b,v,save,flag,l,r,mid;;
	for(b=head[u];b;b=e[b].next){
		v=e[b].to;
		if(v==fa)continue;
		save=ans,flag=0;
		if(d[ans]<a[v])d[++ans]=a[v];
		else{
			l=0,r=ans;
			while(l+1<r){
				mid=(l+r)/2;
				if(d[mid]<a[v])l=mid;
				else r=mid;
			}
			flag=d[r],d[r]=a[v];
		}
		mx[v]=ans;
		dfs(v,u);
		ans=save;
		if(flag)d[r]=flag;
	}
}
void init(){
	int i,u,v;
	scanf("%d",&n);
	for(i=1;i<=n;i++)scanf("%d",&a[i]);
	for(i=1;i<n;i++){
		scanf("%d%d",&u,&v);
		add_edge(u,v),add_edge(v,u);
	}
}
int main(){
	init();
	ans=1,d[1]=a[1],mx[1]=1;
	dfs(1,0);
	for(int i=1;i<=n;i++)printf("%d\n",mx[i]);
	return 0;
}

Measured memory_bytes: 21484
import sys

readline = sys.stdin.buffer.readline
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))

def solve():
    n, m = nm()
    G = [list() for _ in range(n)]
    for _ in range(m):
        u, v = nm()
        u -= 1; v -= 1
        G[u].append(v)
        G[v].append(u)
    if (set(G[0]) & set(G[n-1])):
        print('POSSIBLE')
    else:
        print('IMPOSSIBLE')
    return

solve()

# T = ni()
# for _ in range(T):
#     solve()


Measured memory_bytes: 48612
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
#include <map>
using namespace std;

int main() {
    int count = 0;
    int i;
    int a;
    cin >> a;
    for (i=1;a>=i;i++) {
        count = count + i;
    }
    cout << count << endl;
}

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

int main(){
  string N;
  cin>>N;
  int sum=0;
  for(int i=0; i<N.length();i++){
    sum+=N[i]-'0';
  }
  
  if(sum%9==0)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 3700
#include<bits/stdc++.h>
using namespace std;
int isperfect(long long n)
{
    long long xp=sqrt(n);
    if(n==(xp*xp))
        return 1;
    else
        return 0;
}
int main(){
	string s,t;
	cin>>s>>t;
	s+=t;
	int a[s.length()];
	long long n=0;
	for(int i=0;i<s.length();i++)	a[i]=s[i]-'0';
	for(int i=0;i<s.length();i++){
		n=n*10+a[i];
	}
	if(isperfect(n)==1)		cout<<"Yes";
	else					cout<<"No";
	return 0;
}

Measured memory_bytes: 256
import math
a,b = map(int,input().split())
ans = 0
a_min = math.ceil(12.5 * a)
a_max = 12.5 * (a + 1)
b_min = math.ceil(10 * b)
b_max = 10 * (b + 1)
min = max(a_min,b_min)
if min < a_max and min < b_max:
    ans = min
else:
    ans = -1
print(int(ans))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
#define de(x) cout << #x << "=" << x << endl;
template <class T> bool maxi(T &a, const T &b) {
    if (a < b) { a = b; return 1;} return 0;}
template <class T> bool mini(T &a, const T &b) {
    if (b < a) { a = b; return 1;} return 0;}
#define dame {cout<< "-1" <<"\n"; return;}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD  1000000007
#define PI (acos(-1))
using namespace std;
using ll = long long;
using ld = long double;
using P  = pair<ll,ll>;
//--GLOBAL---------------------------------

//--MAIN-----------------------------------
void Main() {
    ll H,W; cin>>H>>W;

    char faze[H+1][W+1]={};
    rep(i,H){
        rep(j,W){
            cin>>faze[i][j];
        }
    }
    const ll MAXN=21; // 変える // warshall_floyd
    ll N=MAXN*MAXN;
    ll dist[N][N];
    rep(i,N){
        rep(j,N){
            dist[i][j]=INF;
            dist[j][i]=INF;
        }
        dist[i][i]=0;
    }
    
    rep(i,H){
        rep(j,W){
            ll ii=i+1,jj=j+1;
            if(faze[i][j]=='.' and faze[i][jj]=='.'){
                dist[i+j*MAXN][i+jj*MAXN]=1;
                dist[i+jj*MAXN][i+j*MAXN]=1;
            }
            if(faze[i][j]=='.' and faze[ii][j]=='.'){
                dist[i+j*MAXN][ii+j*MAXN]=1;
                dist[ii+j*MAXN][i+j*MAXN]=1;
            }
        }
    }
    rep(k,N) rep(i,N) rep(j,N) dist[i][j]=min(dist[i][j],dist[i][k]+dist[k][j]);
    //warshall_floyd end

    ll ans=0;
    rep(i,N){
        rep(j,N){
            if(i==j) continue;
            if(dist[i][j]>=INF) continue;
            maxi(ans,dist[i][j]);
        }
    }
    cout<< ans <<"\n";
}

//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


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

int main()
{
	int N,i,temp,ans;
	vector<int> d;
	cin>>N;
	for(i=0;i<N;i++){
		cin>>temp;
		d.push_back(temp);
	}
	sort(d.begin(),d.end());
	cout<<d.at(N/2)-d.at(N/2-1);
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
#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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define ll long long
#define INF 999999999

const ll mod = 1e9+7;

int main(){
	ll n;
	cin >> n;
	ll ans = 0;
	ll a;
	REP(i, n){
		cin >> a;
		while(a%2 == 0){
			ans += 1;
			a /= 2;
		}
	}
	cout << ans << endl;
}


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

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

const int maxn = 1e6 + 5;

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
  cout << fixed << setprecision(12);
  int n, x; cin>>n>>x;
  int ans = n*n -x;
  cout<<ans;
  

  return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<string>
#include <bits/stdc++.h>
#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++)
#define ll long long 
#define all(v) v.begin(),v.end()
using namespace std;
int main(){
  int n; cin>>n;
  vector<int> v(n);
  rep(i,n) cin >>v[i];
  int ans=0;
  rep(i,n){
    if(i+1==v[v[i]-1]) ans++;
  }
  cout<<ans/2<<endl;
}

Measured memory_bytes: 640
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
       Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
        String answer = "";
        int length = line.length();
        for(int i=0;i<length;i++){
            char ch = line.charAt(i);
            if(Character.isLowerCase(ch)){
                ch=Character.toUpperCase(ch);
            }else{
                ch=Character.toLowerCase(ch);
            }
            answer = String.valueOf(ch);
             System.out.print(answer);
        }   
             System.out.println();
    }
}


Measured memory_bytes: 26968
import math

a, b, h, m = map(int, input().split())

h_angle = h * 30 + m / 2
m_angle = m * 6

angle_rd = math.radians(abs(h_angle - m_angle))

print(math.sqrt(a * a + b * b - 2 * a * b * math.cos(angle_rd)))


Measured memory_bytes: 9488
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()

ll N;
VS S;//ここでVS(N)は定義できない N何も入ってないから
int main(){
    cin>>N;
    S = VS(N);
    rep(i,0,N)cin>>S[i];
    //ソートしてから判別にすると O(N^2)→O(N) (N<=2*10^5)
    sort(ALL(S));
    ll now=1;
    rep(i,0,N-1){
        if(S[i]==S[i+1]);
        if(S[i]!=S[i+1])now++;
    }
    cout<<now;
    return 0;
}

Measured memory_bytes: 9568
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef pair<int, int> pi;
const int MAXN = 222222;

int n;
char x[MAXN], y[MAXN];

bool Do(char p, char q, int x, int nn){
	for(int i=0; i<n; i++){
		if(::x[i] == p) x--;
		if(x <= 0) return 1;
		if(y[i] == q && x < nn) x++;
	}
	return 0;
}

int main(){
	int w, h, p, q;
	scanf("%d %d %d",&w,&h,&n);
	scanf("%d %d",&p,&q);
	scanf("%s %s",x, y);
	if(Do('D', 'U', w + 1 - p, w)) puts("NO");
	else if(Do('U', 'D', p, w)) puts("NO");
	else if(Do('R', 'L', h + 1 - q, h)) puts("NO");
	else if(Do('L', 'R', q, h)) puts("NO");
	else puts("YES");
}


Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
 
using namespace std;


int MOD=1000000007;


int main(){
    int A,B;
    cin >> A >> B;
    if(A>B) swap(A,B);
    for(int a=A; a<=B; a++){
        if(abs(a-A)==abs(a-B)){
        cout << a << endl;
        return 0;
        }
    }
    cout << "IMPOSSIBLE" << endl;
}


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

struct mountain{
	int h;
	int good;
};

int main(void){
	int n,m,i,h,a,b,x;
	
	struct mountain mt[100001];
	
	scanf("%d %d",&n,&m);
	
	//get h
	for(i=1;i<=n;i++){
		scanf("%d",&h);
		mt[i].h = h;
		mt[i].good = 1;
	}
	
	//get load
	for(i=1;i<=m;i++){
		scanf("%d %d",&a,&b);
		if(mt[a].h > mt[b].h)
			mt[b].good = 0;
		else if(mt[a].h < mt[b].h)
			mt[a].good = 0;
		else if(mt[a].h == mt[b].h){
			mt[a].good=0;
			mt[b].good=0;
		}
	}
	
	x=0;
	for(i=1;i<=n;i++){
		if(mt[i].good)	x++;
	}
	
	printf("%d\n",x);
	
	return 0;
}

Measured memory_bytes: 2936
nums = [int(x) for x in input().split()]
N = nums[0]
K = nums[1]
arr = []
for i in range(N):
	nums = [int(x) for x in input().split()]
	arr.append(tuple(nums))

arr = sorted(arr, key=lambda x: x[0])

vol = 0
for i in range(len(arr)):
	vol = vol + arr[i][1]
	if vol >= K:
		print(arr[i][0])
		break

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

int main() {
	ios::sync_with_stdio(0);cin.tie(0);
	int n, k;
	cin >> n >> k;
	int ans = 0;
	for(int i=0; i<n; i++) {
		int t;
		cin >> t;
		ans += t>=k;
	}
	cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,C,D,E,K;
  cin>>A>>B>>C>>D>>E>>K;
  if(max(A,max(B,max(C,max(D,E))))-min(A,min(B,min(C,min(D,E))))>K){
    cout<<":("<<endl;
  }
  else{
    cout<<"Yay!"<<endl;
  }
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
constexpr int N = 2e5 + 100;

int fa[N], son_num[N];

int Find(int x) {
    if (fa[x] == x) return fa[x];
    else return fa[x] = Find(fa[x]);
}

void Union(int x, int y) {
    int fax = Find(x);
    int fay = Find(y);
    if (fax != fay) {
        fa[fay] = fax;
        son_num[fax] += son_num[fay];
    }
}

void Init() {
    for (int i = 0; i < N; i++) {
        fa[i] = i;
        son_num[i] = 1;
    }
}

int main() {
    Init();
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        int x, y;
        cin >> x >> y;
        Union(x, y);
    }
    cout << *max_element(son_num, son_num + N) << "\n";
}


Measured memory_bytes: 5156
#include<bits/stdc++.h>
#include <iomanip>
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll INF = 1LL << 30;

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

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


int main(void){
    ll N,K; cin >> N >> K;
    vector<ll> A(N); for(int i = 0; i < N; i++) cin >> A[i];
    
    ll base = 0;
    for(int i = 0; i < N; i++){
        for(int j = i+1; j < N; j++){
            if(A[i] > A[j]) base++;
        }
    }
    // cout << base << endl;
    
    ll base2 = 0;
    for(int i = 0; i < N; i++){
        for(int j = 0; j < N; j++){
            if(A[i] > A[j]) base2++;
        }
    }
    // cout << base2 << endl;
    
    ll ans = base2%1000000007*(K-1)%1000000007*modinv(2,1000000007)%1000000007*K%1000000007;
    ans = (ans + base*K)%1000000007;
    
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <utility>
using namespace std;

const int N = 50;
const int INF = 1e9;

typedef pair<int, double> P;

int main(){
    int n;
    int dp[N + 1];
    int ps[] = {380, 550, 850};
    int ws[] = {2, 3, 5};
    P ds[] = { make_pair(5, 0.8), make_pair(4, 0.85), make_pair(3, 0.88) };
    
    while(cin >> n, n){
        fill(dp, dp + N + 1, INF);
        dp[0] = 0;
        n /= 100;
        for(int i = 0;i < n - 2;++i){
            for(int j = 0;j < 3 && i + ws[j] <= n;++j){
                dp[i + ws[j]] = min(dp[i + ws[j]], dp[i] + ps[j]);
                int idx = i + (ws[j] * ds[j].first);
                if(idx <= n){
                    dp[idx] = min(dp[idx], (int)(dp[i] + ps[j] * ds[j].second * ds[j].first));
                }
            }
        }
        cout << dp[n] << endl;
    }
    return 0;
}

Measured memory_bytes: 1160
#include"bits/stdc++.h"
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;

struct UnionFind {
    vector<int> d; // 根なら (-サイズ), そうでないなら親の番号
    UnionFind(int N) : d(N, -1){} // 全て根として初期化

    int root(int x) { // データ x が属する木の根を再帰で得る
        if (d[x] < 0) return x;
        return d[x] = root(d[x]);
    }

    bool unite(int x, int y) { // x と y の木を併合. 併合した場合 true
        x = root(x); y = root(y); // x <- x の根, y <- y の根
        if (x == y) return false; 
        // merge technique（データ構造をマージするテク. 小を大にくっつける）
        if (d[x] > d[y]) swap(x, y);    // x の木のサイズ > y の木のサイズにする. d[x], d[y] < 0 に注意.
        d[x] += d[y];   // x の木のサイズ += y の木のサイズ
        d[y] = x;   // y の親は x
        return true;
    }

    bool same(int x, int y) { // 2つのデータ x, y が属する木が同じなら true
        return root(x) == root(y);
    }
    
    int size(int x) { // 素集合のサイズ
        return -d[root(x)]; // d[root(x)] < 0 に注意.
    }
};

void Main(){
    ll n; cin >> n;
    vector<P> d(n);
    rep(i, n) cin >> d[i].se;
    rep(i, n) cin >> d[i].fi;
    sort(all(d));
    
    vi a(n), b(n);
    vector<P> ap(n);
    rep(i, n) {
        a[i] = d[i].se;
        b[i] = d[i].fi;
        ap[i] = {a[i], i};
    }
    sort(all(ap));
    
    UnionFind UF(n);
    rep(i, n){
        if(ap[i].fi > b[i]){
            cout << "No" << endl;
            return;
        }else{
            UF.unite(i, ap[i].se);
        }
    }
    rep(i, n){
        if(UF.size(i) != n){
            cout << "Yes" << endl;
            return;
        }
    }
    rep(i, n-1){
        if(ap[i+1].fi <= b[i]){
            cout << "Yes" << endl;
            return;
        }
    }    
    cout << "No" << endl;
    return;
}

int main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}

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

using namespace std;

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15);
  }
} initializer;

int main() {
  string s;
  cin >> s;
  cout << ((s.size() % 2 == 0u) == (s[0] == s.back()) ? "First" : "Second") << endl;
}



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

//def
#define debug(x) cout << #x << ": " << x << '\n'
#define out(x) cout << x << '\n'
#define repeat(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define revrepeat(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define foreach(e, v) for (auto &e : v)
#define all(x) (x).begin(), (x).end()
#define CYES cout << "Yes" << endl
#define CNO cout << "No" << endl
#define SPC(x) cout << fixed << setprecision(x)
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;
typedef vector<vector<ll>> vll;
typedef pair<int, int> P;
constexpr int MOD = 1e9 + 7;
constexpr int INF = __INT_MAX__;               // 2^31 - 1
constexpr long long INFLL = __LONG_LONG_MAX__; // 2^61 - 1
constexpr int MAX_N = 1e5 + 5;
constexpr double PI = acos(-1);

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

    string n;
    cin >> n;
    char ch = n.back();
    int c = ch - '0';
    if (c == 3) {
        out("bon");
    } else if (c == 0 or c == 1 or c == 6 or c == 8) {
        out("pon");
    } else {
        out("hon");
    }

    return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
#include <assert.h>
typedef long long ll;
using namespace std;
const ll MAXN=1e5+4;
const ll INF=1e18;
ll a[MAXN];
map<ll,char> b[MAXN];
char gett(ll x,ll y) {
	auto it=b[x].find(y);
	if (it==b[x].end()) return '!';
	else return it->second;
}
const ll MAXK=5;
int main() {
	ll n; scanf("%lld",&n);
	for (ll i=0;i<n;i++) scanf("%lld",&a[i]);
	sort(a,a+n); reverse(a,a+n);
	for (ll y=a[n-1],k=0;y>=1&&k<MAXK;y--,k++) {
		b[n-1][y]=(0==k%2)?'L':'W';
		//printf("%d %d:%c\n",n-1,y,b[n-1][y]);
	}
	for (ll x=n-2;x>=0;x--) {
		ll t=a[x];
		for (ll y=t,k=0;y>=1&&k<MAXK;y--,k++) {
			char c1=gett(x+1,y);
			char c2=gett(x,y+1);
			if (c1=='L'||c2=='L') b[x][y]='W';
			else b[x][y]='L';
			//if (x==17||x==18||x==19) printf("%d %d: %c from %c %c\n",x,y,b[x][y],c1,c2);
		}
		t=a[x+1];
		for (ll y=min(t+2,a[x]),k=0;y>=1&&k<MAXK;y--,k++) {
			char c1=gett(x+1,y);
			char c2=gett(x,y+1);
			if (y+1>=t+1&&y+1<=a[x]) {
				if (0==(abs(y+1-a[x])%2)) c2='L';
				else c2='W';
			}
			if (c1=='L'||c2=='L') b[x][y]='W';
			else b[x][y]='L';
			//if (x==17||x==18||x==19) printf("%d %d: %c from %c %c\n",x,y,b[x][y],c1,c2);
		}
	}
	ll lo=INF;
	for (ll x=0;x<n;x++) {
		ll prevwy=-1;
		for (auto &w:b[x]) {
			if (w.second=='W') {
				if (prevwy==w.first-1) {
					ll y0=w.first-x;
					//printf("Found %d %d. y0:%d\n",x,w.first,y0);
					if (y0>0) lo=min(lo,y0);
				}
				prevwy=w.first;
			}
		}
	}
	if (lo==INF) {
		auto it=b[0].begin();
		ll y=it->first;
		char c=it->second;
		if (0==y%2) {
			if (c=='W') c='L';
			else c='W';
		}
		if (c=='L') printf("Second\n");
		else printf("First\n");
	}
	else {
		if (lo==1) printf("First\n");
		else {
			if (1==lo%2) printf("Second\n");
			else printf("First\n");
		}
	}
}



Measured memory_bytes: 51968
#include<bits/stdc++.h>
using namespace std;
#define F(i,s,e) for(int i=s;i<e;++i)

int main()
{
    int x;
    cin >> x;
    if(x == 7 || x == 5 || x == 3)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
#define white 0
#define gray 1
#define black 2
const int N=100;
int n,color[N],c[N][N],tt,f[N],d[N];
void dfs_visit(int u){
    color[u]=gray;
    f[u]=++tt;
    for(int v=0;v<n;v++){
        if(c[u][v]==0)continue;
        if(color[v]==white){
            dfs_visit(v);
        }
    }
    color[u]=black;
    d[u]=++tt;
}
void dfs(){
    memset(color,0,sizeof(color));
    memset(f,0,sizeof(f));
    memset(d,0,sizeof(d));
    tt=0;
    for(int u=0;u<n;u++){
        if(color[u]==white)
        dfs_visit(u);
    }
    for(int u=0;u<n;u++)
    {
        cout<<u+1<<" "<<f[u]<<" "<<d[u]<<endl;
    }
}
int main(){
    int u,v,k;
    cin>>n;
    memset(c,0,sizeof(c));
    for(int i=0;i<n;i++){
        cin>>u>>k;u--;
        for(int j=0;j<k;j++){
            cin>>v;v--;
            c[u][v]=1;
        }
    }
    dfs();
    return 0;
}


Measured memory_bytes: 3108
list = []
while True:
  line = raw_input().split(" ")
  if line[0] == "0" and line[1] == "0":
    break
  line = map(int, line)
  #print line
  if line[0] > line[1]:
    temp = line[0]
    line[0] = line[1]
    line[1] = temp
  print " ".join(map(str, line))

Measured memory_bytes: 4212
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
using namespace std;
#define REP(i,n) for(int i = 0;i < (int)(n);i++)

int main() {
	int a,b,c;
	cin >> a >> b >> c;
	if(((a<c)&&(b>c))||((a>c)&&(b<c)))cout <<"Yes";
	else cout << "No";
	return(0);
}


Measured memory_bytes: 256
<?php
while(true){
    list($H,$W) = explode(" ",trim(fgets(STDIN)));
    if($H == 0 && $W == 0) break;   // ??\????????????
    for($i = 0; $i < $H; $i++){
        for($j = 0; $j < $W; $j++){
            if($i == 0 || $i == ($H - 1) || $j == 0 || $j == ($W - 1)){
                echo "#";
            } else {
                echo ".";
            }
        }
        echo "\n";
    }
    echo "\n";
}

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

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

Measured memory_bytes: 1792
t = ord("t")
z = ord("z")
a = ord("a")

def _decode(tv, v):
    spam = ord(v)
    if not (a <= spam <= z):
        return v

    x = t - ord(tv)
    y = spam + x

    if y > z:
        y = a + (y % z) - 1
    elif y < a:
        y = z - (a - y - 1)

    return chr(y)

while 1:
    try:
        txt = input()
        for s in [x for x in txt.split() if 3 <= len(x) <= 4]:
            tv = s[0]
            dec_val = ''.join(list(map(lambda x:_decode(tv,x),s)))

            if (dec_val in ('this', 'the', 'that')):
                print(''.join(list(map(lambda x:_decode(tv,x),txt))))
                break
    except:
        break

Measured memory_bytes: 7528
def calcCons(nA, nB, nC, nD):
    W = (nA * a + nB * b) * 100
    S = nC * c + nD * d
    if W + S == 0:
        return -1
    return S / (W + S)


a, b, c, d, e, f = map(int, input().split())
nA, nB, nC, nD, W, S, M = 0, 0, 0, 0, 0, 0, 0
while nA * a * 100 + nB * b * 100 + nC * c + nD * d <= f:
    while nA * a * 100 + nB * b * 100 + nC * c + nD * d <= f:
        while nA * a * 100 + nB * b * 100 + nC * c + nD * d <= f:
            while nA * a * 100 + nB * b * 100 + nC * c + nD * d <= f:
                cons = calcCons(nA, nB, nC, nD)
                if cons > M and cons <= e / (100 + e):
                    M = cons
                    W, S = nA * a * 100 + nB * b * 100, nC * c + nD * d
                nD += 1
            nD = 0
            nC += 1
        nC = 0
        nB += 1
    nB = 0
    nA += 1

if M == 0:
    W = a * 100
print(W + S, S)


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

int main()
{
ll r ;
cin >> r ;
ans=r*2*3.1415;
cout << ans << endl;
return 0;
}

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

using namespace std;

long long fact (int n)
{
    if (n == 0)
        return 1;
    else
        return n*(fact(n-1));
}

int main()
{
    int n;
    cin >> n;
    long long result = fact(n);
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define FORR(I,A,B) for(ll I = (B-1); I >= (A); --I)
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;else return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll H,W,N;
	cin >> H >> W >> N;
	vector<ll> a(N+1);
	FOR(i,1,N+1)cin >> a[i];

	ll in=1;
	ll ans[H][W];
	FOR(i,0,H){
		if(i&1){
			FOR(j,0,W){
				ans[i][j] = in;
				a[in]--;
				if(a[in]==0)in++;
			}
		}else{
			FORR(j,0,W){
				ans[i][j] = in;
				a[in]--;
				if(a[in]==0)in++;
			}
		}
	}
	FOR(i,0,H){
		cout << ans[i][0];
		FOR(j,1,W){
			cout << " " << ans[i][j];
		}
		cout << endl;
	}
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;;
#define 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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define INF 1<<30
#define LINF 1LL<<62
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define pb push_back
const int MOD = 1000000007;
 
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll r,g,b,n;cin >> r >> g >> b >> n;
  ll ans = 0;
  rep(i,n+1){
      rep(j,n+1){
          ll tmp = n-i*r - j*g;
          if(tmp>=0 && tmp%b==0){
              ans++;
          }
      }
  }
  cout << ans << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
ll mod=1e9+7;

int main() {
  ll n,x;
  cin >> n >> x;
  vector<ll> a(n);
  ll sa=0;
  for(ll i=0;i<n;i++) {
    cin >> a[i];
    sa+=a[i];
  }
  vector<vector<ll>> dp(n+1,vector<ll>(sa+1));
  dp[0][0]=1;
  for(ll i=0;i<n;i++) {
    for(ll j=sa;j>-1;j--) {
      for(ll k=i;k>-1;k--) {
        if(j+a[i]<sa+1) {
          dp[k+1][j+a[i]]+=dp[k][j];
        }
      }
    }
  }
  ll ans=0;
  for(ll i=1;i<=n;i++) {
    if(x*i<sa+1) {
      ans+=dp[i][x*i];
    }
  }
  cout << ans << endl;
}

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

public class Main {

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

    private Scanner scan = new Scanner(System.in);
    private final boolean[] notFound;

    public Main() {
	notFound = new boolean[26];
	Arrays.fill(notFound, true);
	
	String S = scan.next();
	for (int i = 0; i < S.length(); i++) {
	    notFound[S.charAt(i) - 'a'] = false;
	}

	scan.close();
    }

    public final void answer() {

	String ans = "None";
	for (int i = 0; i < notFound.length; i++) {
	    if(notFound[i]) {
		ans = String.valueOf((char)('a' + i));
		break;
	    }
	}
	System.out.println(ans);
    }
}


Measured memory_bytes: 22544
#include <stdio.h>

int n;
char grid[256][256];

int max(int y, int x);

int main(void)
{
    while (scanf("%d", &n), n != 0){
        int i, j;
        int maxi = 0;

        for (i = 0; i < n; i++) scanf("%s", grid[i]);
        for (i = 0; i < n; i++){
            for (j = 0; j < n; j++){
                if (grid[i][j] == '1'){
                    int t = max(i, j);

                    if (maxi < t) maxi = t;
                }
            }
        }
        printf("%d\n", maxi);
    }

    return 0;
}

int max(int y, int x)
{
    int maxi = 0;
    int i, j;
    int cnt;

    for (i = y, cnt = 0; i < n && grid[i][x] == '1'; i++, cnt++);
    if (maxi < cnt) maxi = cnt;
    for (j = x, cnt = 0; j < n && grid[y][j] == '1'; j++, cnt++);
    if (maxi < cnt) maxi = cnt;
    for (i = y, j = x, cnt = 0; i < n && j < n && grid[i][j] == '1'; i++, j++, cnt++);
    if (maxi < cnt) maxi = cnt;
    for (i = y, j = x, cnt = 0; i >= 0 && j < n && grid[i][j] == '1'; i--, j++, cnt++);
    if (maxi < cnt) maxi = cnt;

    return maxi;
}

Measured memory_bytes: 668
def main():

    TaroScore = HanaScore = 0
    n = int(input())
    for _ in range(n):
        [Taro, Hana] = list(input().lower().split())

        lenT = len(Taro)
        lenH = len(Hana)
        lenMin = min(lenT, lenH)

        if Taro == Hana:
            TaroScore += 1
            HanaScore += 1
        
        else:
            for i in range(lenMin+1):
                if Taro == '':
                    HanaScore += 3
                    break
                elif Hana == '':
                    TaroScore += 3
                    break
                elif ord(Taro[0]) > ord(Hana[0]):
                    TaroScore += 3
                    break
                elif ord(Taro[0]) < ord(Hana[0]):
                    HanaScore += 3
                    break
                else:
                    Taro = Taro[1:]
                    Hana = Hana[1:]

    print(TaroScore, HanaScore)

if __name__ == '__main__':
    main()



Measured memory_bytes: 5604
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int D;
  cin >> D ;
  if(D==25){
  cout << "Christmas" << endl;
  }
  else if(D==24){
  cout << "Christmas Eve" << endl;
  }
  else if(D==23){
  cout << "Christmas Eve Eve" << endl;
  }
  else if(D==22){
  cout << "Christmas Eve Eve Eve" << endl;
  }
}

Measured memory_bytes: 256
N = int(input())
 
ans = 0
f = 2
while True:
  if N%f==0:
    c = 0
    while N%f==0:
      N /= f
      c += 1
    n = 1
    while n*(n+1)//2<=c:
      n += 1
    ans += n-1
  if f*f>N:
    break
  f += 1
if N>1:
  ans += 1
print(ans)

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> ii;

int main() {
	int n;
	cin >> n;
	int a[100100];
	memset(a, 0, sizeof a);
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		x++;
		a[x]++;
		a[x+1]++;
		a[x-1]++;
	}

	int mx = 0;
	for (int i = 0; i < 100005; i++) {
		if (a[i] > mx) {
			mx = a[i];
		}
	}

	cout << mx << '\n';
}

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

long long count_product(long long, long long, long long);
long long gcd(long long, long long);

int main(){
    long long a,b,c,d;
    cin >> a >> b >> c >> d;
    long long pro_c, pro_d, pro_cd;
    long long res = 0;
    long long lcm = 1;
    lcm = c*d / gcd(c,d);

    pro_c = count_product(a, b, c);
    pro_d = count_product(a, b, d);
    pro_cd = count_product(a, b, lcm);
    res = (b - a + 1) - (pro_c + pro_d - pro_cd);

    cout << res << endl;
}

long long count_product(long long left, long long right, long long m){
    if (left >= right){
	return (left == right)*(left % m == 0);
    }else{
	long long res = 0;
	res = right / m - (left-1) / m;
	return res;
    }
}

long long gcd(long long a, long long b){
    if (a == 0 || b == 0){
	return max(a, b);
    }else{
	long long gcd = 1;
	long long r = 1;
	while (1){
	    if (a % b == 0){
		gcd = b;
		break;
	    }else{
		r = a % b;
		a = b;
		b = r;
	    }
	}
	return gcd;
    }
}


Measured memory_bytes: 256
INFTY = 10**9+7
N = int(input())
A = list(map(int,input().split()))
C = {}
for i in range(N):
    if A[i] not in C:
        C[A[i]] = 0
    C[A[i]] += 1
if N%2==0:
    flag = 0
    for i in range(1,N,2):
        if i in C and C[i]==2:
            pass
        else:
            flag = 1
            break
else:
    flag = 0
    for i in range(2,N,2):
        if i in C and C[i]==2:
            pass
        else:
            flag = 1
            break
    if 0 not in C or C[0]!=1:
        flag = 1
cnt = 0
if flag==0:
    cnt = 1
    for i in range(N//2):
        cnt = (cnt*2)%INFTY
print(cnt)

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

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define RFOR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX/3

const double EPS = 1e-14;
const double PI  = acos(-1.0);


int main(){
  int n, k;
  cin >> n >> k;

  int h = n / k;
  LL ans = pow(h, 3);
  if (k % 2 == 0) {
    int d;
    if (n % k >= (k / 2))
      d = h + 1;
    else
      d = h;
    ans += pow(d, 3);
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define rep(i, a, b) for(int i=(a); i<(b); i++)
#define per(i, a, b) for(int i=(b)-1; i>=(a); i--)
#define sz(a) (int)a.size()
#define de(a) cout << #a << " = " << a << endl
#define dd(a) cout << #a << " = " << a << " "
#define all(a) a.begin(), a.end()
#define pw(x) (1ll<<(x))
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	int n;
	while(cin >> n) {
		bool ans = 0;
		rep(i, 0, 3) {
			if(n % 10 == 7) ans = 1;
			n /= 10;
		}
		if(ans) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 3652
/**
 *    Author:  Oak_limy
 *    Created: 2020-09-13 20:00:33
**/
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cerrno>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <limits>
#include <list>
#include <map>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <utility>
#include <vector>
#include <cwchar>
#include <cwctype>
#define endl '\n'
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define zy -2147382637
#define bql 2147483647
#define ll long long
#define ull unsigned long long
#define ld long double
#define il inline
#define sz(x) x.size()
#define rp(i, l, r) for (int i = l; i <= r; i++)
#define rb(i, r, l) for (int i = r; i >= l; i--)
#define fi first
#define se second
#define pb push_back
#define up upper_bound
using namespace std;
ll max(ll a,ll b){if(a>b)return a;else return b;}
ll min(ll a,ll b){if(a<b)return a;else return b;}
ll lowbit(ll x){return x&(-x);}
ll prime(ll x){
   if(x<=1)return false;
   for(int i=2;i<=int(sqrt(x));i++){
       if(x%i==0)return false;
   }return true;
}bool cmp(ll a,ll b){return a>b;}
ll gcd(ll a,ll b){ll r;while(b>0){r=a%b;a=b;b=r;}return a;}
ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod;for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
inline int readint() {
    char c = getchar(); int w = 1; int x = 0;
    while (!isdigit(c))
        (c == '-') && (w = -w), c = getchar();
    while (isdigit(c))
        x = (x << 3) + (x << 1) + (c ^ '0'), c = getchar();
    x *= w;
    return x;
}
inline ll readll() {
    char c = getchar(); ll w = 1; ll x = 0;
    while (!isdigit(c))
        (c == '-') && (w = -w), c = getchar();
    while (isdigit(c))
        x = (x << 3) + (x << 1) + (c ^ '0'), c = getchar();
    x *= w;
    return x;
}
void fl(string name){
    freopen((name+".in").c_str(),"r",stdin);
    freopen((name+".out").c_str(),"w",stdout);
}
const int dx[8] = {-1, 1, 0, 0, -1, 1, -1, 1},
          dy[8] = {0, 0, -1, 1, -1, -1, 1, 1};

int main(){
    ll x;
    cin>>x;
    if(x==0)cout<<1<<endl;
    if(x==1)cout<<0<<endl;
    return 0;
}
/* stuff to remember
    * int overflow, array bounds
    * special cases (n=1? n=0?)
    * do something instead of nothing and stay organized
    * USE STATIC ARRAYS
    * DEFINING ARRAYS BEFORE main()
    * DO NOT DEFINE ARRAYS IN main()
    * USE INT INSTEAD OF LL,NOTICE THE MLE
*/

Measured memory_bytes: 3620
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
#include<math.h>
using namespace std;
#define ll long long
int main(){
	ll i,j,k;
	long double a,b,N,K,x;
	ll l,r,t;
	cin >> a >> b >>x;
	long double ans;
	long double pi=acos(-1);
	if(x<a*a*b/2.0)ans=atan2(b,2.0*x/a/b)/2/pi*360;else ans=atan2(2.0*(a*a*b-x)/a/a,a)/2/pi*360; 
	cout << setprecision(13) << ans;
    return 0;
}


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

int main() {
    int n;
    cin >> n;
    int a[n];
    rep(i,n) {
        cin >> a[i];
    }
    sort(a, a+n);
    cout << a[n-1] - a[0] << endl;
}   

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int n,m,s;
int main()
{
	scanf("%d%d",&n,&m);
	s = (1900*m+100*(n-m))*(pow(2,m));
	printf("%d\n",s);
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    static long[][] dp;
    static final long MOD = 1_000_000_007;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        int[] a = new int[N];
        for (int i = 0; i < N; i++) {
            a[i] = sc.nextInt();
        }
        dp = new long[N + 1][K + 1];
        dp[0][0] = 1;
        for (int k = 1; k < K + 1; k++) {
            dp[0][k] = 0;
        }
        for (int i = 0; i < N; i++) {
            long[] diff = new long[K + 1];
            for(int k = 0; k < K + 1; k++) diff[k] = 0;
            for (int k = 0; k < K + 1; k++) {
                diff[k] += dp[i][k];
                diff[k] = properMod(diff[k]);
                int end = k + a[i] + 1;
                if (end < K + 1) {
                    diff[end] -= dp[i][k];
                    diff[end] = properMod(diff[end]);
                }
            }
            dp[i + 1][0] = diff[0];
            for (int k = 1; k < K + 1; k++) {
                dp[i + 1][k] = dp[i + 1][k - 1] + diff[k];
                dp[i + 1][k] = properMod(dp[i + 1][k]);
            }
        }
        long ans = dp[N][K];
        System.out.println(ans);
    }
    public static long properMod(long n) {
        if (n >= 0) {
            return n%MOD;
        } else {
            return (MOD + n%MOD);
        }
    }
}

Measured memory_bytes: 170140
#include <bits/stdc++.h>
#include <vector>
using namespace std;
const long mod=1000000007;
int main(){
    int n;
    cin>>n;
    vector<long>ans(n+1),ag(n+1),ac(n+1),ga(n+1),at(n+1),a(n+1),g(n+1),c(n+1),t(n+1);
    ans[1]=4;
    ans[2]=16;
    ag[1]=ac[1]=ga[1]=0;
    ag[2]=ac[2]=ga[2]=at[2]=1;
    a[2]=g[2]=c[2]=t[2]=4;
    for(int i = 3; i <= n; i++){
        a[i]=ans[i-1];
        g[i]=ans[i-1]-ac[i-1];
        c[i]=ans[i-1]-ag[i-1]-ga[i-1]-ag[i-2]*3;
        t[i]=ans[i-1];
        ag[i]=a[i-1];
        ac[i]=a[i-1]-ga[i-1];
        ga[i]=g[i-1];
        
        ans[i]=((a[i]+g[i]+c[i]+t[i])%mod+mod)%mod;
    }
    cout<<ans[n]<<endl;
}


Measured memory_bytes: 256
let () = Scanf.scanf "%d %d\n" @@ fun n k ->
  let xys = Array.init n @@ fun _ ->
    Scanf.scanf "%d %d\n" @@ fun x y -> x, y in
  Array.sort compare xys;
  Printf.printf "%d\n" @@ Array.fold_left (Array.fold_left min) max_int @@
    Array.init (n - k + 1) @@ fun i ->
      Array.init (n - i - k + 1) @@ fun j ->
        let xys' = Array.init (j + k) (fun k -> snd xys.(i + k)) in
        Array.sort compare xys';
        (fst xys.(i + j + k - 1) - fst xys.(i)) * 
        Array.fold_left min max_int (Array.init (j + 1) (fun j -> xys'.(j + k - 1) - xys'.(j)))


Measured memory_bytes: 1792
import java.util.Scanner;

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

        String o = sc.next();
        String e = sc.next();

        String[] oSub = o.split("");
        String[] eSub = e.split("");

        String result = "";
        for (int i = 0; i < oSub.length; i++) {
            result += oSub[i];

            if (i < eSub.length) {
                result+= eSub[i];
            }
        }

        System.out.println(result);
    }
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
#define FAST_IO                     \
  ios_base::sync_with_stdio(false); \
  cin.tie(0);                       \
  cout.tie(0);
typedef long long ll;
/**
 * Uncomment the #define below if problem contains multiple test cases
 */
// #define MULTIPLE_TESTS 1

void solve() {
  int n;
  cin >> n;
  vector<int> adj[n + 1];
  int x;
  for (int i = 1; i < n; ++i) {
    cin >> x;
    adj[x].push_back(i + 1);
  }
  for (int i = 1; i <= n; ++i) {
    cout << adj[i].size() << endl;
  }
}

int main() {
  FAST_IO;
  int t = 1;
#ifdef MULTIPLE_TESTS
  cin >> t;
#endif

  while (t--) {
    solve();
  }

  return 0;
}

Measured memory_bytes: 14424
#include <iostream>
#include <typeinfo>
#include <cmath>
#include <vector>
using namespace std;

int main()
{
  // input data
  int N, M;
  cin >> N >> M;
  vector<vector<int>> s(M);
  vector<int> p(M);

  for (int i = 0; i < M; i++)
  {
    int k;
    cin >> k;
    s[i].resize(k);
    for (int j = 0; j < k; j++)
    {
      cin >> s[i][j];
      s[i][j]--;
    }
  }

  for (int i = 0; i < M; i++)
  {
    cin >> p[i];
  }

  int ans = 0;

  // bit search
  for (int sw = 0; sw < (1 << N); sw++)
  {
    bool ok = true;
    for (int lb = 0; lb < M; lb++)
    {
      vector<int> s_for_lb = s[lb];

      int num = 0;

      for (int i = 0; i < s_for_lb.size(); i++)
      {
        if (sw & (1 << (s_for_lb[i])))
        {
          num++;
        }
      }

      if (num % 2 != p[lb])
      {
        ok = false;
        break;
      }
    }

    if (ok)
      ans++;
  }

  cout << ans << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mit map<int,int>::iterator
#define sit set<int>::iterator
#define itrm(g,x) for(mit g=x.begin();g!=x.end();g++)
#define itrs(g,x) for(sit g=x.begin();g!=x.end();g++)
#define ltype int
#define rep(i,j,k) for(ltype(i)=(j);(i)<=(k);(i)++)
#define rap(i,j,k) for(ltype(i)=(j);(i)<(k);(i)++)
#define per(i,j,k) for(ltype(i)=(j);(i)>=(k);(i)--)
#define pii pair<int,int>
#define fi first
#define se second
#define mpr make_pair
#define pb push_back
#define fastio ios::sync_with_stdio(false)
const int inf=0x3f3f3f3f,mod=1000000007;
const double pi=3.1415926535897932,eps=1e-6;
void chmax(int &x,int y){if(x < y) x = y;}
void chmin(int &x,int y){if(x > y) x = y;}
int n,m;ll ans,msk[25];
vector<int> v[55],id[55];
vector<int> path;
bool fnd;
void dfs(int x,int fa,int ter){
    //printf("%d %d %d\n",x,fa,ter);
    if(x == ter){
        fnd = 1;
        return;
    }
    rap(i,0,v[x].size()){
        int to = v[x][i];
        if(to == fa) continue;
        path.pb(id[x][i]);
        dfs(to,x,ter);
        if(fnd) return;
        path.pop_back();
    }
}
void dfs2(int x,int num,ll cur){
    if(x == m + 1) {
        int u = __builtin_popcountll(cur);
        if(num & 1) ans -= 1ll << (n - 1 - u);
        else ans += 1ll << (n - 1 - u);
        return;
    }
    dfs2(x+1, num+1, cur | msk[x]);
    dfs2(x+1, num  , cur);
}
int main()
{
    scanf("%d",&n);
    rep(i,1,n-1){
        int t1,t2;
        scanf("%d%d",&t1,&t2);
        v[t1].pb(t2);v[t2].pb(t1);
        id[t1].pb(i);id[t2].pb(i);
    }
    scanf("%d",&m);
    rep(i,1,m) {
        int t1,t2;
        scanf("%d%d",&t1,&t2);
        fnd = 0;
        dfs(t1,0,t2);
        //rap(j,0,path.size()) printf("%d ",path[j]);
        //puts("");
        rap(j,0,path.size()) msk[i] |= 1ll<<(path[j]-1);
        path.clear();
    }
    dfs2(1,0,0);
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 3792
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <math.h>

using namespace std;


int main() {

	string S;
	cin >> S;


	vector<vector<int>> dp(100005, vector<int>(13,0));

	int N = S.size();

	vector<int> m(N, 0);

	for (int j = 0; j < N; j++) {
		if (S[j] == '?') {
			m[j] = -1;
		}
		else {
			m[j] = S[j] - '0';
		}

		
	}


	for (int i = 0; i < 10; i++) {
		if (m[0] == -1 || m[0] == i) {
			dp[0][i] = 1;
		}
	}

	for (int i = 1; i < N; i++) {
		for (int j = 0; j < 10; j++) {

			if (m[i] != -1 && m[i] != j) continue;

			for (int k = 0; k < 13; k++) {
				dp[i][(10 * k + j) % 13] += dp[i - 1][k];
				dp[i][(10 * k + j) % 13] %= 1000000007;
			}
		}
		for (int k = 0; k < 13; k++) {
			
		}
	}

	cout << dp[N - 1][5] << endl;

	

	


}

Measured memory_bytes: 9344
#include <iostream>
#include <string>
#include <cstdio>
#include <cstdlib>

using namespace std;

int main()
{
        const int DATE[] = {18680907, 19120729, 19261224, 19890107};
        const int YEAR[] = {1868, 1912, 1926, 1989};
        const string ERA[] = {"meiji", "taisho", "showa", "heisei"};
        int y, m, d;
        char dt[9];

        while (cin >> y >> m >> d) {
                sprintf(dt, "%d%02d%02d", y, m, d);
                dt[8] = '\0';
                int date = atoi(dt);
                if (date <= DATE[0]) {
                        cout << "pre-meiji";
                } else {
                        int idx = 0;
                        while (idx < 4 && date > DATE[idx]) {
                                idx++;
                        }
                        cout << ERA[idx - 1];
                        int era = y - YEAR[idx - 1] + 1;
                        cout << " " << era << " " << m << " " << d;
                }
                cout << '\n';
        }

        return 0;
}

Measured memory_bytes: 3264
#include<bits/stdc++.h>
using namespace std;
using ll  = long long;
using vl  = vector<ll>;
using vi  = vector<int>;
#define _GLIBCXX_DEBUG
#define IO_STREAM cin.tie(0);ios::sync_with_stdio(false)
#define all(x) x.begin(),x.end()
#define rep(i,sta,end) for(int i=sta;i<end;++i)
#define lcm(a,b) (a)/__gcd((a),(b))*(b)
#define pb push_back
const ll INF = 1000000000000000;
const ll MOD = 1000000007;
const double PI = acos(-1);
//||
#define DBG(a,b,c,d) //cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<endl
//DBG("","","","");

int main(){
	IO_STREAM;
	int K;	cin>>K;
	int x=7%K;
	rep(i,1,1e7){
		if(x==0){
			cout<<i<<endl;
			return 0;
		}
		x=(x*10+7)%K;
	}
	cout<<-1<<endl;
	return 0;
}


Measured memory_bytes: 3628
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	// ans := 0
	sc.Scan()
	N, _ := strconv.Atoi(sc.Text())
	sc.Scan()
	D, _ := strconv.Atoi(sc.Text())
	var ans int
	for i := 0; i < N; i++ {
		sc.Scan()
		x, _ := strconv.Atoi(sc.Text())
		sc.Scan()
		y, _ := strconv.Atoi(sc.Text())
		if D*D < x*x+y*y {
			continue
		}
		ans++
	}
	fmt.Println(ans)
}


Measured memory_bytes: 4904