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

#define ll long long
#define INF_LL 1LL << 60
#define INF 99999999
#define MOD (ll)1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, a, n) for(int i = a; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

void put_double(double obj){printf("%.12f\n",obj);};

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}

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


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

    if( (abs(b-a) <= d && abs(c-b) <= d) || abs(c-a) <= d ) cout << "Yes" << endl;
    else cout << "No" << endl;

}


Measured memory_bytes: 256
def inp():
    return input()
def iinp():
    return int(input())
def inps():
    return input().split()
def miinps():
    return map(int,input().split())
def linps():
    return list(input().split())
def lmiinps():
    return list(map(int,input().split()))
def lmiinpsf(n):
    return [list(map(int,input().split()))for _ in range(n)]

s = inp()

n = len(s)

a = s[:((n-1)//2)]
b = s[((n+3)//2)-1:]

for i in range(n//2):
    if s[i] != s[n-1-i]:
        print("No")
        exit()

for j in range((len(a))//2):
    if a[j] != a[len(a)-1-j]:
        print("No")
        exit()

for k in range((len(b))//2):
    if b[k] != b[len(b)-1-k]:
        print("No")
        exit()

print("Yes")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define v(x) vector<int> x;
#define all(x) x.begin(),x.end()
#define s(x,n) memset(x,n,sizeof(x));
#define pb(x) push_back(x)

using namespace std;
int main()
{   fast 
    ll a,b;
    set<ll> s;
    s.insert(1);s.insert(2);s.insert(3);
    cin>>a>>b;
    s.erase(a);s.erase(b);
    auto it=s.begin();
    cout<<*it<<"\n";
    return 0;
}

Measured memory_bytes: 3644
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;
import java.util.stream.IntStream;

/**
 * 解説どおりに作成したソースコード
 */
public class Main {

	/** 白のコマ */
	private static final char WHITE = '.';

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int h = scanner.nextInt();
			int w = scanner.nextInt();
			scanner.nextLine();
			boolean[][] s = new boolean[h + 1][w + 1];
			IntStream.range(0, h + 1).forEach(i -> Arrays.fill(s[i], false));
			int whiteCount = 0;
			@SuppressWarnings("unchecked")
			List<Path>[] pathLists = new List[h * w];
			IntStream.range(0, h * w).forEach(i -> pathLists[i] = new ArrayList<>());
			for (int i = 1; i <= h; i++) {
				char[] l = scanner.nextLine().toCharArray();
				for (int j = 1; j <= w; j++) {
					s[i][j] = (l[j - 1] == WHITE);
					if (s[i][j]) {
						whiteCount++;
						int now = (i - 1) * w + j - 1;
						if (s[i - 1][j]) {
							int before = (i - 2) * w + j - 1;
							pathLists[now].add(new Path(now, before, 1));
							pathLists[before].add(new Path(before, now, 1));
						}
						if (s[i][j - 1]) {
							int before = (i - 1) * w + j - 2;
							pathLists[now].add(new Path(now, before, 1));
							pathLists[before].add(new Path(before, now, 1));
						}
					}
				}
			}
			int[] distances = dijkstra(pathLists, 0, h * w);
			System.out.println((distances[h * w - 1] < Integer.MAX_VALUE) ? whiteCount - distances[h * w - 1] - 1 : -1);
		}
	}

	/**
	 * @param pathLists ノード間の連結パス一覧の配列
	 * @param src       開始ノード
	 * @param n         ノードの数
	 * @return 開始ノードからの距離の配列
	 */
	private static int[] dijkstra(List<Path>[] pathLists, int src, int n) {
		int[] distances = new int[n];
		Arrays.fill(distances, Integer.MAX_VALUE);
		// 最短距離が確定したかどうか
		boolean[] fixed = new boolean[n];
		Arrays.fill(fixed, false);
		// 出発地点までの距離を0とする
		distances[src] = 0;
		Queue<Path> queue = new PriorityQueue<>();
		queue.add(new Path(src, src, 0));
		while (!queue.isEmpty()) {
			int now = queue.poll().to;
			if (!fixed[now]) {
				fixed[now] = true;
				for (Path path : pathLists[now]) {
					if (!fixed[path.to] && distances[path.to] > distances[now] + path.cost) {
						distances[path.to] = distances[now] + path.cost;
						queue.add(new Path(path.to, path.to, distances[path.to]));
					}
				}
			}
		}
		return distances;
	}

	/**
	 * ノード間の一つのパスを表すクラス
	 */
	private static class Path implements Comparable<Path> {
		/** 開始ノード */
		@SuppressWarnings("unused")
		int from;
		/** 終了ノード */
		int to;
		/** 移動コスト */
		int cost;

		Path(int from, int to, int cost) {
			super();
			this.from = from;
			this.to = to;
			this.cost = cost;
		}

		@Override
		public int compareTo(Path path) {
			return this.cost - path.cost;
		}
	}
}


Measured memory_bytes: 26836
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using in6 = int64_t;
using ind = double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  int n,k;
  cin >> n >> k;
  if(n < 10) k = 100 * (10 - n) + k;
  cout << k << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long
const int INF = 1LL << 60;

template <class M, class OM = M>
struct DelaySegmentTree{
  using FX = function<M(M, M)>;
  using FA = function<M(M, OM)>;
  using FM = function<OM(OM, OM)>;
  using FP = function<M(M, int)>;
  FX fx;
  FA fa;
  FM fm;
  FP fp;
  int n;
  M ex;
  OM em;
  vector<M> data;
  vector<OM> delay;

  DelaySegmentTree(int sz, FX fx, FA fa, FM fm, FP fp, M ex, OM em) 
  : fx(fx), fa(fa), fm(fm), fp(fp), ex(ex), em(em), data(sz*4, ex), delay(sz*4, em){
    n = 1; while(n < sz) n *= 2;
  }

  void set(int k, M x){ data[k+n-1] = x; }
  void build(){
    for(int k = n-2; k >= 0; k--){
      data[k] = fx(data[2*k+1], data[2*k+2]);
    }
  }

  void eval(int k, int len){
    if(delay[k] == em) return;
    if(k < n-1){
      delay[2*k+1] = fm(delay[2*k+1], delay[k]);
      delay[2*k+2] = fm(delay[2*k+2], delay[k]);
    }
    data[k] = fa(data[k], fp(delay[k], len));
    delay[k] = em;
  }

  void update(int a, int b, OM x){ update(a, b, x, 0, 0, n); }
  void update(int a, int b, OM x, int k, int l, int r){
    eval(k, r - l);
    if(b <= l || r <= a) return;
    if(a <= l && r <= b){
      delay[k] = fm(delay[k], x);
      eval(k, r - l);
    }else{
      update(a, b, x, 2*k+1, l, (l+r)/2);
      update(a, b, x, 2*k+2, (l+r)/2, r);
      data[k] = fx(data[2*k+1], data[2*k+2]);
    }
  }

  M getval(int a, int b){ return getval(a, b, 0, 0, n); }
  M getval(int a, int b, int k, int l, int r){
    eval(k, r - l);
    if(b <= l || r <= a) return ex;
    if(a <= l && r <= b) return data[k];
    M vl = getval(a, b, 2*k+1, l, (l+r)/2);
    M vr = getval(a, b, 2*k+2, (l+r)/2, r);
    return fx(vl, vr);
  }

  void print(int n){
    cout << "[";
    for(int i = 0; i < n; i++){
      cout << getval(i, i+1) << ", ";
    }
    cout << "]" << endl;
  }
};


signed main(){

  int n, q; cin >> n >> q;
  auto fx = [](int a, int b){ return a + b; };
  auto fa = [](int a, int b){ return b; };
  auto fm = [](int a, int b){ return b; };
  auto fp = [](int a, int b){ return a * b; };
  DelaySegmentTree<int> seg(n, fx, fa, fm, fp, 0, -INF);

  for(int i = 0; i < q; i++){
    int qt; cin >> qt;
    if(qt == 0){
      int s, t, x; cin >> s >> t >> x;
      seg.update(s, t+1, x);
    }else{
      int s, t; cin >> s >> t;
      cout << seg.getval(s, t+1) << endl;
    }
    //seg.print(n);
  }

  return 0;
}


Measured memory_bytes: 9184
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<queue>
#define ll long long
using namespace std;
const ll MOD=1e9+7;
int n,m,k,a[75],len[75],tmp[75],st[75];
ll ans,fact[205],inv[205];
char s[75];
bool flag[75];
queue<int>q;
ll quick_pow(ll x,ll a)
{
	ll ans=1;
	while(a)
	{
		if(a&1)ans=ans*x%MOD;
		x=x*x%MOD;
		a>>=1;
	}
	return ans;
}
bool check()
{
	memset(flag,0,sizeof(flag));
	while(!q.empty())q.pop();
	int tot=0;
	for(int i=m;i;i--)
	{
		for(int j=1;j<=a[i];j++)
		  tmp[++tot]=i-1;
	}
	int now=1;
	for(int i=1;i<=k;i++)
	{
		if(s[i]=='r')
		{
			q.push(i);
		}
		if(s[i]=='b')
		{
			if(now<=tot&&!q.empty())
			{
				st[now]=i;
				flag[q.front()]=flag[i]=1;
				q.pop();
				now++;
			}
		}
	}
	if(now<=tot)return 0;
	for(int i=1;i<=a[0];i++)
	{
		if(q.empty())return 0;
		flag[q.front()]=1;
		q.pop();
	}
	now=1;
	for(int i=1;i<=tot;i++)
	{
		while(now<=st[i])now++;
		for(int j=1;j<=tmp[i];j++)
		{
			while(flag[now])now++;
			if(now>k)return 0;
			flag[now]=1;
		}
	}
	return 1;
}
ll solve()
{
	if(!check())return 0;
	int l=n,tot=0;
	for(int i=0;i<=m;i++)
	{
		l-=a[i]*(len[i]+1);
		tot+=a[i];
		tot+=a[i]*(2*i+1);
	}
	l++;
	ll ans=fact[l+tot]*inv[l]%MOD*inv[tot]%MOD;
	tot=0;
	for(int i=0;i<=m;i++)
	{
		tot+=a[i];
		ans=ans*inv[a[i]]%MOD;
	}
	return ans*fact[tot];
}
void dfs(int step,int rest)
{
	if(step>m)
	{
		ans=(ans+solve())%MOD;
		return;
	}
	for(a[step]=0;a[step]*len[step]+a[step]<=rest;a[step]++)
	  dfs(step+1,rest-a[step]*len[step]-a[step]);
}
int main()
{
	scanf("%d%d",&n,&k);
	scanf("%s",s+1);
	fact[0]=1;
	for(int i=1;i<=200;i++)fact[i]=fact[i-1]*i%MOD;
	inv[200]=quick_pow(fact[200],MOD-2);
	for(int i=200;i>=1;i--)inv[i-1]=inv[i]*i%MOD;
	len[0]=len[1]=1;
	m=2;
	while(2*m-1<=n)
	{
		len[m]=2*m-1;
		m++;
	}
	m--;
	dfs(0,n+1);
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define int long long
#define all(a) a.begin(), a.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, 0, n){
        cin >> a[i];
    }
    vector<int> d = a;
    sort(a.begin(), a.end());
    int l = a[n / 2 - 1], r = a[n / 2];
    rep(i, 0, n){
        if(d[i] <= l) cout << r << endl;
        else cout << l << endl;
    }
}

Measured memory_bytes: 5376
n,a,=map(int,input().split())
x=list(map(lambda y:int(y)-a,input().split()))
w=2*n*(max(max(x),a))
dp=[[0]*(w+1) for _ in range(n+1)]
dp[0][w//2]=1
for i in range(1,n+1):
  for j in range(w+1):
    dp[i][j]=dp[i-1][j]+(dp[i-1][j-x[i-1]] if 0<=j-x[i-1]<=w else 0)
print(dp[n][w//2]-1)

Measured memory_bytes: 5236
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
using namespace std;
int main(){
  int q,x;
  string s;
  list<int> v;
  cin >> q;
  rep(i,q){
    cin >> s;
    if(s[0]== 'i'){
      cin >> x;
      v.push_front(x);
    }
    else if(s[6] == 'L') v.pop_back();
    else if(s[6] == 'F') v.pop_front();
    else if(s[0] == 'd'){
      cin >> x;
      for(list<int>::iterator j=v.begin(); j!=v.end(); j++){
        if( *j == x){
          v.erase(j);
          break;
        }
      }
    }
    }
    int i = 0;
    for(list<int>::iterator j=v.begin(); j!=v.end(); j++){
      if(i++) cout << " ";
      cout << *j;
    }
    cout << endl;
    return 0;
}



Measured memory_bytes: 34420
import sys
n = int(input())
a = [ 2*int(i) for i in sys.stdin.readline().split()]
ans = [0 for i in range(n)]
for i in range(1, n):
    ans[i] = a[i-1] - ans[i-1]
ans[0] = (a[n-1] - ans[n-1])//2
for i in range(1, n):
    ans[i] +=  ans[0]*(-1)**(i%2)
print(" ".join(map(str, ans)))


Measured memory_bytes: 19340
#include <stdio.h>
#define max(a,b) a > b ? a : b
#define min(a,b) a < b ? a : b
#define Max 100000
#define inf 1 << 30
int main(void)
{
    int a,b,c,x,y;
    scanf("%d%d%d%d%d", &a, &b, &c, &x, &y);
    int i = 0, lowcost = inf;
    while(i <= Max)
    {
        int cost = 2 * c * i;
        cost += max(0, a * (x - i));
        cost += max(0, b * (y - i));
        if(cost < lowcost)
        {
            lowcost = cost;
        }
        i ++;
    }
    printf("%d\n", lowcost);
}

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

int main() {
  int N, K, x, i;
  cin >> N >> K;
  while (N) {
    cin >> x;
    if (x > K - x) i += (K - x) * 2;
    else i += x * 2;
    N--;
  }
  cout << i << endl;
}

Measured memory_bytes: 256
# C
X = int(input())

# 一覧を求める
import numpy as np

def seachPrimeNum(N):
    max = int(np.sqrt(N))
    seachList = [i for i in range(2,N+1)]
    primeNum = []
    while seachList[0] <= max:
        primeNum.append(seachList[0])
        tmp = seachList[0]
        seachList = [i for i in seachList if i % tmp != 0]
    primeNum.extend(seachList)
    return primeNum

l = seachPrimeNum(10**5+3)


for i in l:
    if i >= X:
        print(i)
        break

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

int main(void){
	int N,L;
	cin >> N >> L;
	vector<long long> a(N);
	for(int i=0;i<N;i++){
		cin >> a[i];
	}

	int ret = -1;
	for(int i=0;i<N;i++){
		if(a[i] >= L)ret = i;
		if(i != N-1 && a[i]+a[i+1] >= L)ret = i;
	}
	if(ret != -1){
		cout << "Possible" << endl;
		for(int i=0;i<ret;i++)
			cout << i+1 << endl;
		for(int i=N-1;i>ret;i--){
			cout << i << endl;
		}
	}
	else cout << "Impossible" << endl;

	return 0;
}

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

int main(){
  int n, a, b, prob[3] = {0,0,0};
  cin >> n >> a >> b;
  int p[n];
  rep(i, n) {
    cin >> p[i];
  }
  rep(i, n) {
    if (p[i] <= a) {
      prob[0] += 1;
    }else if (p[i] <= b) {
      prob[1] += 1;
    }else {
      prob[2] += 1;
    }
  }
  if (prob[0] >= prob[1]) {
    if (prob[1] >= prob[2]) {
      cout << prob[2] << endl;
    }else{
      cout << prob[1] << endl;
    }
  }else{
    if (prob[0] >= prob[2]) {
      cout << prob[2] << endl;
    }else{
      cout << prob[0] << endl;
    }
  }
}


Measured memory_bytes: 256
N,M,C=map(int,input().split())
B=list(map(int,input().split()))
A=[0]*N
for i in range(N):
  A[i]=list(map(int,input().split()))
sum=[0]*N
count=0
for i in range(N):
  for j in range(M):
    sum[i]+=A[i][j]*B[j]
  sum[i]+=C
  if sum[i]>0 :
    count+=1
print(count)

Measured memory_bytes: 9100
fun main(args: Array<String>) {
    Program().solve()
}

class Program {
    fun solve() {
        val sc = MyScanner()
        val (a, b) = sc.intList()
        print(if ((a * b) % 2 == 0) "Even" else "Odd")
    }
}


class MyScanner() {
    private var index = 0
    private var line = listOf<String>()

    fun next(): String {
        while (line.size <= index) {
            line = readLine()!!.split(' ')
            index = 0
        }
        return line[index++]
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextDouble() = next().toDouble()
    fun nextCharArray() = next().toCharArray()
    fun nextChar() = next()[0]

    fun strList(): List<String> {
        index = line.size
        return readLine()!!.split(' ')
    }

    fun intList() = strList().map { it.toInt() }
    fun longList() = strList().map { it.toLong() }
    fun doubleList() = strList().map { it.toDouble() }
}

Measured memory_bytes: 38144
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=200010;
const ll mod=1e9+7;


vector<vector<ll>> a(3, vector<ll>(mx,-1));
vector<vector<ll>> dp(3, vector<ll>(mx,-1));


ll dfs(int x, int d){
  if(dp[x][d]!=-1){ return dp[x][d]; }
  if(d==0){ return dp[x][d] = a[x][d]; }
  
  if(x==0){dp[x][d] = max(max(dp[x][d],dfs(1,d-1)+a[x][d]),dfs(2,d-1)+a[x][d]);}
  if(x==1){dp[x][d] = max(max(dp[x][d],dfs(0,d-1)+a[x][d]),dfs(2,d-1)+a[x][d]);}
  if(x==2){dp[x][d] = max(max(dp[x][d],dfs(0,d-1)+a[x][d]),dfs(1,d-1)+a[x][d]);}
  return dp[x][d];
}

int main(){  
  int n;
  cin >> n;
  rep(i,n){
    cin >> a[0][i] >> a[1][i] >> a[2][i];
  }  
  ll ans = max(max(dfs(0,n-1),dfs(1,n-1)),dfs(2,n-1));
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 17380
N,K = list(map(int,input().split()))
A = list(map(int,input().split()))
a = N*[0]
b = N*[0]

for i in range(N):
  for j in range(N):
    if i<j and A[i]>A[j]:
      a[i]+=1
    if i<j and A[i]<A[j]:
      b[i]+=1

print((sum(a)*K*(K+1)//2+sum(b)*K*(K-1)//2)%(10**9+7))

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

typedef long long ll;
const ll MOD = 1000000007ll;
const int N_DIGITS = 60;
ll L[N_DIGITS], R[N_DIGITS];
ll Dp[1 + N_DIGITS][2][2][2]; // これまでで L<x, y<R, x,y>0 が 不成立/成立
const bool Bs[2] = {false, true};

void go(ll &tgt, ll src) { (tgt += src) %= MOD; }
int main() {
  ll l, r;
  cin >> l >> r;
  for (int i = N_DIGITS - 1; i >= 0; --i) {
    L[i] = l % 2;
    R[i] = r % 2;
    l /= 2;
    r /= 2;
  }
  Dp[0][0][0][0] = 1;
  for (int i = 0; i < N_DIGITS; ++i) {
    for (bool overL : Bs) {
      for (bool underR : Bs) {
        for (bool some : Bs) {
          ll src = Dp[i][overL][underR][some];
          // 0,0
          if (overL || L[i] == 0) {
            go(Dp[i + 1][overL][underR || R[i] == 1][some], src);
          }
          // 0,1
          if ((overL || L[i] == 0) && (underR || R[i] == 1) && some) {
            go(Dp[i + 1][overL][underR][true], src);
          }
          // 1,1
          if (underR || R[i] == 1) {
            go(Dp[i + 1][overL || L[i] == 0][underR][true], src);
          }
        }
      }
    }
    /*
    cout << "l " << L[i] << " r " << R[i] << " :";
    for (bool overL : Bs) {
      for (bool underR : Bs) {
        for (bool some : Bs) {
          cout << " " << Dp[i][overL][underR][some];
        }
      }
    }
    cout << endl;
    */
  }
  ll res = 0;
  for (bool overL : Bs) {
    for (bool underR : Bs) {
      for (bool some : Bs) {
        (res += Dp[N_DIGITS][overL][underR][some]) %= MOD;
      }
    }
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstring>
#include <iostream>
using namespace std;
int n, a[375][22]; bool vis[375][3][3][7][7][7][7], dp[375][3][3][7][7][7][7];
int solve(int pos, int x, int y, int d1, int d2, int d3, int d4) {
	if (pos == n) return true;
	int b = x * 4 + y;
	if (a[pos][b] || a[pos][b + 1] || a[pos][b + 4] || a[pos][b + 5]) return false;
	if (vis[pos][x][y][d1][d2][d3][d4]) return dp[pos][x][y][d1][d2][d3][d4];
	bool ret = false;
	for (int i = 0; i <= 2 && !ret; i++) {
		for (int j = 0; j <= 2 && !ret; j++) {
			if (i != x && j != y) continue;
			int nd1 = d1 + 1, nd2 = d2 + 1, nd3 = d3 + 1, nd4 = d4 + 1;
			if (i == 0 && j == 0) nd1 = 0;
			if (i == 0 && j == 2) nd2 = 0;
			if (i == 2 && j == 0) nd3 = 0;
			if (i == 2 && j == 2) nd4 = 0;
			if (nd1 < 7 && nd2 < 7 && nd3 < 7 && nd4 < 7 && solve(pos + 1, i, j, nd1, nd2, nd3, nd4)) ret = true;
		}
	}
	vis[pos][x][y][d1][d2][d3][d4] = true;
	dp[pos][x][y][d1][d2][d3][d4] = ret;
	return ret;
}
int main() {
	while (cin >> n, n) {
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < 16; j++) {
				cin >> a[i][j];
			}
		}
		memset(vis, 0, sizeof(vis));
		memset(dp, 0, sizeof(dp));
		bool ret = solve(0, 1, 1, 1, 1, 1, 1);
		cout << (ret ? 1 : 0) << endl;
	}
	return 0;
}


Measured memory_bytes: 18916
#include<stdio.h>
int main()
{
	int n;
	scanf("%d",&n);
	switch(n)
	{
		case 22:printf("Christmas Eve Eve Eve");break;
		case 23:printf("Christmas Eve Eve");break;
		case 24:printf("Christmas Eve");break;
		case 25:printf("Christmas");break;

	}
}

Measured memory_bytes: 128
#include<stdio.h>
#include<algorithm>
using namespace std;
int a[300008],b[2000008];
int main(){
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%d",a+i),b[i]=a[i];
        sort(b+1,b+n+1);
    for(int i=1;i<=n;i++){
        if(a[i]==b[n]){
            printf("%d\n",b[n-1]);
        }
        else
            printf("%d\n",b[n]);
    }
}


Measured memory_bytes: 3200
"use strict"
function main(arg) {
    const N = arg.split("\n")[0].split(" ").map((x)=>{return parseInt(x)})
    const inputs = arg.split("\n")[1].split(" ").map((x)=>{return parseInt(x)})
    let i, max = 0, ans = 0
    for (i = 0; i < N; ++i){
        if (max <= inputs[i]){
            max = inputs[i]
            ans++
        }
    }
    console.log(ans)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
#include <bits/stdc++.h>
#include <cctype>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template<typename key, typename val>
//using ordered_tree =
//  tree<key, val, std::less<>, rb_tree_tag, tree_order_statistics_node_update>;
using namespace std;
typedef long long int64;
typedef unsigned long long uint64;
typedef complex<double> comp;
const double pi = 3.14159265358979323846;
const int inf = (int)1e+9 + 2;
const int64 inf64 = (int64)1e+18 + 2;
const double dinf = 1e+20;
const int mod = 1'000'000'007;//*/998244353;
const int base = 2187;
const double eps = 1e-9;
const int N = 300'000;
const int LOGN = 19;

int n, m, k;

void solve(int) {
  cin >> k >> n >> m;
  for (int i = n; i <= m; ++i) {
    if (i % k == 0) {
      cout << "OK\n";
      return;
    }
  }
  cout << "NG\n";
}

void precalc() {
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  precalc();
  int test = 1;
  //cin >> test;
  //auto start = chrono::high_resolution_clock::now();
  for (int i = 1; i <= test; ++i) {
    solve(i);
  }
  //cerr << chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - start).count() << '\n';
  return 0;
}




Measured memory_bytes: 3612
import java.util.Scanner

import scala.math._

object Main extends App {
  val sc = new Scanner(System.in)
  val N, K = sc.nextInt
  val h = Array.fill(N)(sc.nextInt)

  val dp = Array.fill(N)(Int.MaxValue)

  dp(0) = 0
  for (i <- 1 until N) {
    val dps = (1 to K)
      .filter(_ <= i)
      .map(x => dp(i - x) + abs(h(i) - h(i - x)))
    dp(i) = dps.min
  }
  println(dp.last)
}


Measured memory_bytes: 115644
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define sz(x) int(x.size())
#define pb push_back
#define eb emplace_back
using ll=long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
const ll MOD=1000000007,MOD2=998244353;



int main() {
    int N,K;
    cin>>N>>K;
    vector<int> A(N);
    rep(i,N){
        cin>>A.at(i);
    }
    rep(sousa,K){
        bool check=true;
        rep(j,N){
            if(A.at(j)!=N)check=false;
        }
        if(check){
            //cout<<sousa<<endl;
            break;
        }
        vector<P> ft(0);
        rep(i,N){
            ft.pb({max(0,i-A.at(i)),i+A.at(i)});
        }
        vector<int> sa(N,0);
        rep(i,N){
            sa.at(ft.at(i).first)++;
            if(ft.at(i).second<N-1){
                sa.at(ft.at(i).second+1)--;
            }
        }
        rep(i,N){
            if(i==0){
                A.at(i)=sa.at(i);
            }
            else{
                A.at(i)=A.at(i-1)+sa.at(i);
            }
        }
    }
    rep(i,N){
        cout<<A.at(i);
        if(i<N-1){
            cout<<" ";
        }
    }
    cout<<endl;
}

Measured memory_bytes: 7752
#include<bits/stdc++.h>
#define LL long long
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPA(i,n) for(int i=1;i<(n);++i)
#define PII pair<int,int>
#define PLI pair<long long, int>
#define PLL pair<long long, long long>
#define PDD pair<double, double>
#define MOD ((int)1e9 + 7)
#define INF ((int)1e9)
#define INFLL ((LL)1e18)
#define ALL(x) (x).begin(),(x).end()
#define ctoi(x) (x - 'a') 
#define CTOI(x) (x - 'A')
#define BIT(x) (1 << (x))
using namespace std;

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

}

LL exp(LL a, LL b){
    LL res = 1;
    LL sum = a;
    while(b){
        if(b&1)res = (res * sum);
        sum = (sum * sum);
        b>>=1;
    }
    return res;
}

double exp(double a, LL b){
    double res = 1;
    double sum = a;
    while(b){
        if(b&1)res = (res * sum);
        sum = (sum * sum);
        b>>=1;
    }
    return res;
}

signed  main(){
    double a, b;
    cin >> a >> b;
    printf("%.10f\n", a/b);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#define M 1000000007L

static long long powM(long long b,long long e){
    long long r=1;
    while(e){
        if(e&1){
            r=(r*b) % M;
        }
        b=(b*b) % M;
        e >>=1;
    }
    return r;
}
using namespace std;
int main(void)
{
  long long n, k, s;
  cin >> n >> k;
  vector<long long> c = vector<long long>(k + 1, 0);

  for (long long i = k; i > 0; i--) {
    c[i] = powM(k / i, n);
    for (long long j = 2; j <= k; j++) {
      if (i * j > k) {
	break;
      } else {
	c[i] = (c[i] - c[i * j] + M) % M;
      }
    }
  } 

  s = 0;
  for (long long i = 1; i <= k; i++) {
    s = (s + i * c[i]) % M;
  }
  cout << s << endl;  
  return 0;
}


Measured memory_bytes: 4044
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
    int n, m; cin >> n >> m;
    using pii = pair<int, int>;
    vector<pii> v(m);
    for (int i = 0; i < m; ++i) {
        cin >> v[i].first >> v[i].second;
    }
    sort(v.begin(), v.end(), [](pii a, pii b){return a.second < b.second;}); //second!
    int res = 0;
    int endtime = 0;
    for (int i = 0; i < m; ++i) {
        if (v[i].first >= endtime) {
            endtime = v[i].second;
            ++res;
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 1024
//bismillahir rahmanir rahim            //Author:Fayed Anik

#include <bits/stdc++.h> 

using namespace std;


#define         ll                         long  long
#define         lf                         double 
#define         pb(x)                      push_back(x)
#define         ull                        unsigned long long
#define         sfl(a)                     scanf("%lld",&a)
#define         sf(a)                      scanf("%d",&a)
#define         pf(a)                      printf("%d\n",a)
#define         pfl(a)                     printf("%lld\n",a)
#define         pdl(a)                     printf("%llf\n",a)
#define         FOR(x,n)                   for(ll x=1;x<=n;++x)
#define         vii                        vector< ll > v
#define         pi                         3.14159265359
#define         mex                        10000000
#define         pii                        pair< ll , ll >
#define         mem(m,a)                   memset( m, a,sizeof m)
#define         mp(a,b)                    make_pair(a,b)
#define         maxn                       100000
#define         mod                        1000000007
#define         INF                        1e17
#define         f1                         first
#define         f2                         second
#define         all(v)                     v.begin(),v.end()
#define         PI                         acos(-1)
#define         printminusone              printf("-1\n")
#define         bug                        printf("bug")

int main(){
	ll n;
	sfl(n);
	cout <<3*n*n << endl;
	return 0;
}

 

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>

using ll = unsigned long long;
using namespace std;

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

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

    vector<int> ans(n);

    int ix = 1;
    int check = 0;

    for(int j = n; j > 0; --j) {
        
        int tmp = 0;
        int scale = 2;
        int check = scale * j;
        while (true) {
            if (check > n) {
                // stop
                break;
            } else {
                tmp += ans[check-1];
                check = ++scale * j;
            }
        }
        if(a[j-1] == tmp%2) {
            ans[j-1] = 0;
        } else {
            ans[j-1] = 1;
        }
    }

    bool allzero = true;
    int inball = 0;
    for(int i = 0; i < n; ++i) {
        if (ans[i] != 0) {
            inball++;
            // cout << i + 1<< endl;
            // cout << ans[i] << endl;
            // allzero = false;
        }
    }

    if (inball == 0){
         cout << 0 << endl;
    } else {
        cout << inball << endl;
        for(int i = 0; i < n; ++i) {
            if(ans[i] != 0) {
                cout << i + 1  << " ";
            }
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 2432
#include <iostream>

using namespace std;

int main()
{
	long long int N, A, B;
	cin >> N >> A >> B;
	long long int m = (N - 1) * A + B;
	long long int M = (N - 1) * B + A;
	if (M - m + 1 > 0)
		cout << M - m + 1 << endl;
	else
		cout << 0 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
 
 
 
int main(){
  long n;
  cin >> n;
  long cnt=0;
  if (n%2==0){
    int josu=1;
    long N = pow(5,josu)*2;
    while(n>=N){
      cnt += n/N;
      josu++;
      N = pow(5,josu)*2;
    } 
  }
  cout << cnt << endl;
      
      
}

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

#define all(v) v.begin(), v.end()
#define V vector
#define P pair
typedef long long ll;
const int INT_INF = 1e9;
const ll INF = 1LL << 30;

int main() {
    string s, t; cin >> s >> t;

    // 同じ文字は同じ文字に変換されるのを
    // s -> t, t -> sで調べる
    V<char> v1(100), v2(100);
    for(int i = 0; i < s.size(); i++){
        if(v1[t[i] - 'a'] == 0){
            v1[t[i] - 'a'] = s[i];
        }else if(v1[t[i] - 'a'] != s[i]){
            cout << "No" << endl;
            return 0;
        }
        if(v2[s[i] - 'a'] == 0){
            v2[s[i] - 'a'] = t[i];
        }else if(v2[s[i] - 'a'] != t[i]){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 3852
#include<iostream>

#define INF 1000000
using namespace std;

int main(){
	int data[2][110][110];
	
	int n,m;
	while(cin>>n>>m && n|m){
		for(int i=0;i<110;i++){
		for(int j=0;j<110;j++){
				data[1][i][j]=INF;
				data[0][i][j]=INF;
			
		}
	}
	int a,b,cost,time;
	for(int i=0;i<n;i++){
		cin>>a>>b>>cost>>time;
		data[0][a][b]=cost;
		data[0][b][a]=cost;
		data[1][a][b]=time;
		data[1][b][a]=time;
	}

	for(int count=0;count<2;count++){
		for(int k=1;k<=m;k++){
			for(int i=1;i<=m;i++){
				for(int j=1;j<=m;j++)data[count][i][j]=min(data[count][i][j],data[count][i][k]+data[count][k][j]);
			}
		}
	}			

	int k;
	cin>>k;
	for(int i=0;i<k;i++){
		int p,q,r;
		cin>>p>>q>>r;
		cout<<data[r][p][q]<<endl;
	}
	}
}

Measured memory_bytes: 1252
#include <bits/stdc++.h>
using namespace std;
int main () {
    int n;
    cin >> n;
    vector<int> v(n), p(n), q(n);
    for (int i = 0; i < n; i++) {
        v[i] = i+1;
    }
    for (int i = 0; i < n; i++) {
        cin >> p[i];
    }
    for (int i = 0; i < n; i++) {
        cin >> q[i];
    }
    int a, b;
    int k = 0;
    do {
        bool af, bf;
        af = bf = 1;
        for (int i = 0; i < n; i++) {
            if (v[i] != p[i]) {
                af = 0;
            }
            if (v[i] != q[i]) {
                bf = 0;
            }
        }
        if (af) a = k;
        if (bf) b = k;
        k++;
    } while (next_permutation(v.begin(), v.end()));
    cout << abs(a-b) << endl;
}

Measured memory_bytes: 256
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}

const mod = 10^^9+7;
alias mint = FactorRing!mod;

void main()
{
  int n; readV(n);
  string s; readV(s);

  auto dp = new mint[][](n, n);
  dp[0][] = mint(1);

  foreach (i; 1..n) {
    auto dps = dp[i-1].cumulativeSum;
    foreach (j; 0..n-i)
      if (s[i-1] == '<')
        dp[i][j] = dps[j+1..n-i+1];
      else
        dp[i][j] = dps[0..j+1];
  }

  writeln(dp[$-1].sum);
}

class CumulativeSum(T)
{
  size_t n;
  T[] s;

  this(T[] a)
  {
    n = a.length;
    s = new T[](n+1);
    s[0] = T(0);
    foreach (i; 0..n) s[i+1] = s[i] + a[i];
  }

  T opSlice(size_t l, size_t r) { return s[r]-s[l]; }
  size_t opDollar() { return n; }
}
auto cumulativeSum(T)(T[] a) { return new CumulativeSum!T(a); }

struct FactorRing(int m, bool pos = false)
{
  version(BigEndian) union { long vl; struct { int vi2; int vi; } } else union { long vl; int vi; }
  alias FR = FactorRing!(m, pos);
  @property static init() { return FR(0); }
  @property int value() { return vi; }
  @property void value(int v) { vi = mod(v); }
  alias value this;

  this(int v) { vi = v; }
  this(int v, bool runMod) { vi = runMod ? mod(v) : v; }
  this(long v) { vi = mod(v); }

  ref auto opAssign(int v) { vi = v; return this; }

  pure auto mod(int v) const { static if (pos) return v%m; else return (v%m+m)%m; }
  pure auto mod(long v) const { static if (pos) return cast(int)(v%m); else return cast(int)((v%m+m)%m); }

  static if (!pos) pure ref auto opUnary(string op: "-")() { return FR(mod(-vi)); }

  static if (m < int.max / 2) {
    pure ref auto opBinary(string op)(int r) if (op == "+" || op == "-") { return FR(mod(mixin("vi"~op~"r"))); }
    ref auto opOpAssign(string op)(int r) if (op == "+" || op == "-") { vi = mod(mixin("vi"~op~"r")); return this; }
  } else {
    pure ref auto opBinary(string op)(int r) if (op == "+" || op == "-") { return FR(mod(mixin("vl"~op~"r"))); }
    ref auto opOpAssign(string op)(int r) if (op == "+" || op == "-") { vi = mod(mixin("vl"~op~"r")); return this; }
  }
  pure ref auto opBinary(string op: "*")(int r) { return FR(mod(vl*r)); }
  ref auto opOpAssign(string op: "*")(int r) { vi = mod(vl*r); return this; }

  pure ref auto opBinary(string op)(ref FR r) if (op == "+" || op == "-" || op == "*") { return opBinary!op(r.vi); }
  ref auto opOpAssign(string op)(ref FR r) if (op == "+" || op == "-" || op == "*") { return opOpAssign!op(r.vi); }
}


Measured memory_bytes: 146044
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <unordered_map>
#include <numeric>
using namespace std;
using ll = long long;
#define rep(i, j, n) for(int i = (j); i < (n); ++i)

int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	int n, m; cin >> n >> m;
	int x;
	unordered_map<int, int> cnt;
	vector<vector<int>> num(100001);
	rep(i, 0, n) {
		cin >> x;
		cnt[x]++;
	}
	for (auto e : cnt)
		num[e.first % m].push_back(e.second);

	int ans = 0;

	rep(i, 0, m / 2 + 1) {
		int k = (m - i) % m;
		int a = accumulate(num[i].begin(), num[i].end(), 0);
		int b = accumulate(num[k].begin(), num[k].end(), 0);
		if (i == k) {
			ans += a / 2;
			continue;
		}
		sort(num[i].begin(), num[i].end());
		sort(num[k].begin(), num[k].end());
		ans += min(a, b);
		if (a > b) {
			swap(num[i], num[k]);
			swap(a, b);
		}

		// 同じ数が奇数個では少なくとも一つはあぶれる
		int t = a;
		rep(j, 0, (int)num[k].size()) {
			t -= num[k][j] & 1;
			num[k][j] -= num[k][j] & 1;
			t = max(t, 0);
		}

		int j = 0;
		while (j < (int)num[k].size()) {
			int d = min(num[k][j], t);
			t -= d;
			num[k][j] -= d;
			if (t == 0)
				ans += num[k][j] / 2;
			++j;
		}
	}
	cout << ans << endl;

	return 0;
}


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


int main() {
  string s;
  
  cin >> s;
  
  int flag = 0;
  
  for(int i=1; i<s.size(); i++){
    if(s.at(0) == s.at(i))
      flag++;
  }
  
  for(int i=2; i<s.size(); i++){
    if(s.at(1) == s.at(i))
      flag++;
  }
  
  for(int i=3; i<s.size(); i++){
    if(s.at(2) == s.at(i))
      flag++;
  }
  
  if(flag == 2)
    cout << "Yes";
  
  else
    cout << "No";
  
}

Measured memory_bytes: 256
#include <iostream>
#include <numeric>
#include <math.h>
#include <algorithm>
#include <float.h>
#include <limits>
#include <vector> 
#include <string.h>
#include <iomanip>

#define rep(i,a,n) for(ll int (i) = (a);(i) < (n);(i)++)
#define urep(i,a,n) for(ll int (i) = (a);(i) > (n);(i)--)
#define MOD 1000000007
#define Imax 2147483647
#define ll long long
#define asort(a) sort(a.begin(),a.end());

using namespace::std;

int jo(ll int jxo, ll int jyo){//累乗
	ll int jhogeo = 1;
	rep(jinto,0,jyo) jhogeo=jhogeo*jxo;
	return jhogeo;
}
char tobig(char toxbig){//char大文字化
  return (toxbig-0x20);
}
char tolow(char toxlow){//char小文字化
  return (toxlow+0x20);
}
int ctoi(char cctoi){//char->int
  if('0' <= cctoi && cctoi <= '9') return (cctoi-'0');
  return -1;
}
int gcd(int gcad, int gcbd) {//最大公約数
  if(gcad < gcbd) return gcd(gcbd, gcad);
  int gcrd;
  while ((gcrd=gcad%gcbd)) {
    gcad = gcbd;
    gcbd = gcrd;
  }
  return gcbd;
}
int lcm(int lcam, int lcbm){//最小公倍数
 return (lcam*lcbm)/gcd(lcam,lcbm);
}


int main(){
  string n;
  cin>>n;
  int sa=1000;
  rep(i,0,n.length()-2){
    if(abs(ctoi(n[i])*100+ctoi(n[i+1])*10+ctoi(n[i+2])-753)<sa){
      sa=abs(ctoi(n[i])*100+ctoi(n[i+1])*10+ctoi(n[i+2])-753);
    }
  }
  cout<<sa;
    
  
}
// int *p = new int[N];

//  vector<int> 変数名(要素数);
//  sort(変数名.begin(),変数名.end());//昇順ソート

// vector<vector<int>> 変数名(左の個数, vector<int>(右の個数));

//


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
#define rep(x,to) for(int x=0; x<(to); ++(x))

int main() {
    int x;
    while(cin >> x, x) {
        string ans = "";
        while(x) {
            int tmp = (x % 10 + 10) % 10;
            ans += '0' + tmp;
            x = (x - tmp) / -10;
        }
        reverse(ans.begin(), ans.end());
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 1200
// oj d https://atcoder.jp/contests/abc161/tasks/abc161_a
// g++ A.cpp && oj t
// oj s https://atcoder.jp/contests/abc161/tasks/abc161_a A.cpp

#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")

#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()

using ll = long long;
using ull = unsigned long long;
using namespace std;

int main() {
  int X, Y, Z;
  cin >> X >> Y >> Z;
  cout << Z << " " << X << " " << Y << endl;
  return 0;
}


Measured memory_bytes: 256
/****************************************************************
# @Author:      iLovePKU_zbtxdy
# @DateTime:    2020-01-28 14:21:42
# @Description: You build it. You run it
# @More: Once lots of AC, try Brute-force,dynamic programming
****************************************************************/
#include<bits/stdc++.h>
using namespace std;
#define close std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define eps 1e-8
#define int long long
typedef long long ll;
const int maxn = 1e6+10;
const int INF = 0x3f3f3f3f;
const ll linf = 0x3f3f3f3f3f3f3f3f;
const double PI = acos(-1.0);
ll mod = 1e9+7;
int a[maxn];
int32_t main()
{
    close;
    int n , k;
    cin >> n >> k;
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    sort(a , a+n);
    int ans = 0;
    for(int i = 0; i < n-k; i++){
        ans += a[i];
    }cout << ans << endl;
    system("pause");
}
/***************************************************************************
*stuff you should look for
*int overflow, array bounds
*special cases (n=1?), set tle
*do smth instead of nothing and stay organized
***************************************************************************/

Measured memory_bytes: 2040
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>

using namespace std;

int main (int argc, char *argv[]) {
    int n, a, b, c, x;
    while (cin>>n>>a>>b>>c>>x, n||a||b||c||x) {
        int y[100];
        for (int i = 0; i < n; ++i) {
            cin>>y[i];
        }
        int pos = 0;
        bool flag = true;
        for(int i = 0; i <= 10000; i++){
            if(y[pos] == x) pos++;
            if(pos == n) {
                cout << i << endl;
                flag = false;
                break;
            }
            x = (a * x + b) % c;
        }
        if(flag) cout << "-1" <<endl;
    }
    return 0;
}


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

using namespace std;

const int nmax = 1e5 + 5;
vector < int > G[nmax];
int N, M, deg[nmax], dist[nmax];
bitset < nmax > viz;

void dfs (int nod) {
  viz[nod] = true;
  for (int vec : G[nod]) {
    dist[vec] = max (dist[vec], dist[nod] + 1);
    --deg[vec];
    if (deg[vec] == 0)
      dfs(vec);
  }
}

int main () {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  cin >> N >> M;
  while (M --) {
    int x, y;
    cin >> x >> y;
    G[x].emplace_back(y);
    ++deg[y];
  }
  for (int i = 1; i <= N; ++i)
    if (!viz[i] && deg[i] == 0)
      dfs(i);
  int ans = 0;
  for (int i = 1; i <= N; ++i)
    ans = max (ans, dist[i]);
  cout << ans;
}


Measured memory_bytes: 14448
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    int n;
    cin >> n;
    vector<ll> a(n);
    vector<ll> diff(n);
    for(ll i = 0; i < n; i++){
    cin >> a[i];
    diff[i] = a[i] - (i + 1);
    }
    sort(diff.begin(),diff.end());
    ll ans = 0;
    for(ll i = 0; i <n; i++){
        ans += abs(a[i] - (diff[n / 2] + i + 1));
    }
    cout << ans << endl;
}

Measured memory_bytes: 3456
import java.io.*
import java.util.*
 
fun solve(N: Int, A: IntArray){
    A.map{ 1/it.toDouble() }.sum().let{ println(1/it) }
    return
}
 
fun main(args: Array<String>) {
    fun StringArray(size: Int, init: (Int) -> String = { "\u0000" }): Array<String> {
        return Array<String>(size, init)
    }
    class Scanner(stream: InputStream) {
        private val reader = BufferedInputStream(stream).bufferedReader()
        private var st: StringTokenizer? = null
        fun next(): String {
            while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())
            return st!!.nextToken()
        }
    }
    val sc = Scanner(System.`in`)
    val N = sc.next().toInt()
    val A = IntArray(N)
    for (i in 0 until N) {
        A[i] = sc.next().toInt()
    }
    solve(N, A)
}


Measured memory_bytes: 31496
import java.util.*;

public class Main {
	public static void main( String[] args){
    	Scanner scan = new Scanner(System.in);
      	int distance = scan.nextInt();
      	int time = scan.nextInt();
      	int speed = scan.nextInt();
      	if(distance <= time * speed){
          System.out.println("Yes");
        }else{
          System.out.println("No");
        }
    }
}

Measured memory_bytes: 35716
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<algorithm> // sort
#include<map> // pair
#include<cmath>
#include<cstring>
#include<set>
// #include<stack>
// #include<queue>
using namespace std;
typedef long long ll;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll tmp1,tmp2;
const ll mod = 1e9+7;
const int INF = 1e9;
const ll INFLONG = 1e18;
// vector<vector<ll>> vec(100,vector<ll>(100));
int main(){
  string s,t;
  cin >> s >> t;
  ll sum = 0;
  rep(i,3){
    if(s[i]== t[i]){sum++;}

  }
  cout << sum;

}


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

using namespace std;

const int M = 1e5 + 5;
int n, m, out[M], vis[M];
vector <int> adj[M], g[M];
string s;
set <pair <int, int> > st, used, there;

void DFStree (int u) {
  vis[u] = 1;
  for (int v : adj[u]) {
    if (vis[v]) continue;
    used.insert({u, v});
    DFStree(v);
  } 
}

bool dfs (int u, int p ) {
  bool id = s[u] == '1' ? 1 : 0;
  for (int v : g[u]) {
    if (v == p) continue;
    bool k = dfs(v, u);
    if (k == 0) continue;
    used.erase({u, v});
    used.insert({v, u});
    if (id) id = 0;
    else id = k;
  }
  return id;
}

int main () {
  scanf ("%d %d", &n, &m);
  for (int i = 0; i < m; i++) {
    int u, v;
    scanf("%d %d", &u, &v);
    u--; v--; 
    there.insert ({u, v});
    adj[u].push_back (v);
    adj[v].push_back (u);
  }
  //puts("here");
  DFStree (0);
  for (auto i : used) {
    g[i.first].push_back(i.second);
  }
  for (auto i : there) {
    if (used.find({i.second, i.first}) != used.end()) out[i.second]++;
    else out [i.first]++;
  }
  for (int i = 0; i < n; i++) {
    s += (out[i]%2) ? '1' : '0';
  }
  if (m % 2 || dfs (0, -1) != 0) {puts ("-1"); return 0;}
  for (auto i : there) {
    if (used.find({i.first, i.second}) != used.end() || used.find({i.second, i.first}) != used.end()) continue;
    used.insert({i.first, i.second});
  }
  memset (out, 0, sizeof out);
  for (auto i : used) out[i.first]++;
  for (int i = 0; i < n; i++) {
    if (out[i] % 2) {puts ("-1"); return 0;}
  }
  for (auto i : used) cout << i.first+1 << ' ' << 1+i.second << endl;
}

Measured memory_bytes: 32128
n = int(input())
A = list(map(int, input().split()))

for i,key in enumerate(A):
    i = i+1
    parent = A[int(i/2)-1] if int(i/2)>0 else None
    left = A[2*i-1] if 2*i<=n  else None
    right = A[2*i+1-1] if 2*i+1<=n else None 
    ans = 'node {}: key = {}, '.format(i,key)
    if parent:
        ans += 'parent key = {}, '.format(parent)
    if left:
        ans += 'left key = {}, '.format(left)
    if right:
        ans += 'right key = {}, '.format(right)
    print(ans)


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

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

int main() {

    int N;
    Scd(N);

    ll a;
    double t = 1;
    ll ans = 1;
    Rep(i,N){
        Scll(a);
        ans *= a;
        t *= a;
    }

    if( t > 1e18 || ans > 1000000000000000000LL ) {
        ans = -1;
    }

    printf ("%lld\n", ans );


    return 0;
}



Measured memory_bytes: 3816
N = int(input())
S = input()
W = [0] * N
E = [0] * N
for i in range(N - 1):
  W[i + 1] = W[i] + (1 if S[i] == 'W' else 0)
  E[-i - 2] = E[-i - 1] + (1 if S[-i - 1] == 'E' else 0)
print(min([W[i] + E[i] for i in range(N)]))

Measured memory_bytes: 39028
#include <stdio.h>
#include <string.h>
int main(){
  char c[2];

  scanf("%c", c);

  if(c[0] == 'a' || c[0] == 'i' || c[0] == 'u' || c[0] == 'e' || c[0] == 'o'){
    printf("vowel\n");
  }else{
    printf("consonant\n");
  }

}


Measured memory_bytes: 128
#include<stdio.h>

int main(void) {

    int i , j , a[3] = {0} , mem ;

    scanf("%d%d%d",&a[0],&a[1],&a[2]);

    for (i = 0 ; i < 2 ; i++) {

        for (j = i + 1 ; j < 3 ; j++) {

            if (a[i] > a[j]) {

                mem=a[i];
                a[i]=a[j];
                a[j]=mem;

            }
        }
    }

    for (i = 0 ; i < 2; i++) {

        printf("%d ",a[i]);

    }

    printf("%d\n",a[2]);
    return 0;

}

Measured memory_bytes: 596