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

constexpr int inf = 0x3f3f3f3f;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  while (cin >> n, n) {
    vector<int> a(n, inf);
    for (auto && e : a) {
      string s;
      cin >> s;
      if (s != "x") {
        e = stoi(s);
      }
    }
    [&] {
      int lower = -inf, upper = inf;
      for (int i = 0; i < n - 1; ++i) {
        if (a[i] == inf and a[i + 1] == inf) {
          cout << "none\n";
          return;
        }
        if (a[i] != inf and a[i + 1] != inf) {
          if ((i % 2 == 0 and a[i] >= a[i + 1]) or (i & 1 and a[i] <= a[i + 1])) {
            cout << "none\n";
            return;
          }
        }
        if (i % 2 == 0) {
          if (a[i] == inf) {
            upper = min(upper, a[i + 1] - 1);
          }
          if (a[i + 1] == inf) {
            lower = max(lower, a[i] + 1);
          }
        } else {
          if (a[i] == inf) {
            lower = max(lower, a[i + 1] + 1);
          }
          if (a[i + 1] == inf) {
            upper = min(upper, a[i] - 1);
          }
        }
      }
      if (lower < upper) {
        cout << "ambiguous\n";
      } else if (lower > upper) {
        cout << "none\n";
      } else {
        cout << lower << '\n';
      }
    }();
  }
}



Measured memory_bytes: 3148
#include<stdio.h>
int main()
{
    int n,i,a=0;
    scanf("%d",&n);
    for (i=1;i<=9;i++) {
        if(n%i==0 && n/i<=9){
            printf("Yes\n");
            a=1;
            break;
        }

    }
    if (a==0) {
        printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 128
N, M = map(int, input().split())
s = []
c = []
if M == 0:
    if N != 1:
        print(10**(N-1))
    else:
        print(0)
else:   
    for i in range(M):
        s_i, c_i = map(int, input().split())
        s.append(s_i)
        c.append(c_i)
    if N != 1:
        for i in range(10**(N-1), 10**N):
            for j in range(M):
                if str(i)[s[j]-1] != str(c[j]):
                    break
                if j == M - 1:
                    print(i)
                    c = 1
                    break
            if c == 1:
                break
            if i == 10**N -1:
                print(-1)
    else:
        for i in range(0, 10):
            for j in range(M):
                if str(i)[s[j]-1] != str(c[j]):
                    break
                if j == M - 1:
                    print(i)
                    c = 1
                    break
            if c == 1:
                break
            if i == 10**N -1:
                print(-1)

Measured memory_bytes: 9268
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cstdlib>
#include <cmath>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;


int main() {
    string n; cin >> n;
    vector<int> v(n.size()-2);
    rep(i, n.size()-2)  v[i] = abs(753 - stoi(n.substr(i, 3)));
    cout << *min_element(v.begin(), v.end()) << endl;
    return 0;
}


Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

def main():
	V, E = MAP()
	graph = [[] for _ in range(V)]
	for _ in range(E):
		s, t, d = MAP()
		graph[s].append((t, d))

	dp = [[INF]*V for _ in range(1<<V)]
	dp[(1<<V)-1][0] = 0
	for S in range((1<<V)-2, -1, -1):
		for v in range(V):
			for to, cost in graph[v]:
				if not ((S>>to) & 1):
					dp[S][v] = min(dp[S][v], dp[S|1<<to][to]+cost)
	if dp[0][0] != INF:
		print(dp[0][0])
	else:
		print(-1)

if __name__ == '__main__':
	main()



Measured memory_bytes: 21208
#include<iostream>
using namespace std;
string s;
int cnt,cnt2;
main(){
    cin>>s;
    for(int i=0;i*2<s.size();i++){
        if(s[i*2]!='0')cnt++;
        if(s[i*2]!='1')cnt2++;
    }
  for(int i=0;i*2+1<s.size();i++){
		if(s[i*2+1]!='1')cnt++;
    	 if(s[i*2+1]!='0')cnt2++;
  }
    cout<<(cnt>=cnt2?cnt2:cnt)<<endl;
}

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

int main()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << min(a,b)+min(c,d) << "\n";
    return 0;
}


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

int main()
{

	int n, w[110], sum, k;

    int min = 100000;

    cin >> n;

    for(int i = 0; i < n; i++) cin >> w[i];

    sum = 0;

    for(int i = 0; i < n; i++) sum += w[i];

    for(int i = 0; i < n; i++) 
    {
        k += w[i];
        if(min > abs(sum - 2*k)) min = abs(sum - 2*k);
    }

    cout << min << endl;

	return 0;

}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define int long long
#define double long double
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define ggr getchar();getchar();return 0;
#define prique priority_queue
constexpr auto mod = 1000000007;
#define inf 1e15
#define key 1e9
using namespace std;
typedef pair<int, int>P;
template<class T> inline void chmax(T& a, T b) {
	a = std::max(a, b);
}
template<class T> inline void chmin(T& a, T b) {
	a = std::min(a, b);
}
//combination(Nが小さい時はこれを使う
const int MAX = 330000;
int fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % mod;
		inv[i] = mod - inv[mod % i] * (mod / i) % mod;
		finv[i] = finv[i - 1] * inv[i] % mod;
	}
}

// 二項係数計算
long long COMB(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
bool prime(int n) {
	int cnt = 0;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n % i == 0)cnt++;
	}
	if (cnt != 1)return false;
	else return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}

//繰り返し二乗法（Nが大きい時の場合のcombination)
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= (i % mod); res %= mod;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}
//UnionFind
class UnionFind {
protected:
	int* par, * rank, * size;
public:
	UnionFind(unsigned int size) {
		par = new int[size];
		rank = new int[size];
		this->size = new int[size];
		rep(i, size) {
			par[i] = i;
			rank[i] = 0;
			this->size[i] = 1;
		}
	}
	int find(int n) {
		if (par[n] == n)return n;
		return par[n] = find(par[n]);
	}
	void unite(int n, int m) {
		n = find(n);
		m = find(m);
		if (n == m)return;
		if (rank[n] < rank[m]) {
			par[n] = m;
			size[m] += size[n];
		}
		else {
			par[m] = n;
			size[n] += size[m];
			if (rank[n] == rank[m])rank[n]++;
		}
	}
	bool same(int n, int m) {
		return find(n) == find(m);
	}
	int getsize(int n) {
		return size[find(n)];
	}
};
int dight(int n) {
	int ans = 1;
	while (n >= 10) {
		n /= 10;
		ans++;
	}
	return ans;
}
int dight_sum(int n) {
	int sum = 0;
	rep(i, 20)sum += (n % (int)pow(10, i + 1)) / (pow(10, i));
	return sum;
}
int dight_min(int n) {
	int ans = 9;
	while (n >= 10) {
		ans = min(ans, n % 10);
		n /= 10;
	}
	ans = min(ans, n);
	return ans;
}
int dight_max(int n) {
	int ans = 0;
	while (n >= 10) {
		ans = max(ans, n % 10);
		n /= 10;
	}
	ans = max(ans, n);
	return ans;
}
signed main() {
	int a, b;
	cin >> a >> b;
	if (a < b)puts("a < b");
	else if (a > b)puts("a > b");
	else puts("a == b");
	ggr
}



Measured memory_bytes: 3080
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
vector<vector<int>> g;
bool kita[51];
void dfs(int now){
	if(kita[now]) return;
	kita[now] = true;
	for(int next : g[now]){
		dfs(next);
	}
}
int main() {
	int n, m; cin >> n >> m;
	int a[51], b[51];
	for(int i=0;i<m;i++){
		cin >> a[i] >> b[i];
		a[i]--; b[i]--;
	}
	int ans = 0;
	for(int i=0;i<m;i++){
		g.clear();
		g.resize(n);
		for(int j=0;j<n;j++){
			kita[j] = false;
		}
		for(int j=0;j<m;j++){
			if(i==j) continue;
			g[a[j]].push_back(b[j]);
			g[b[j]].push_back(a[j]);
		}
		dfs(a[i]);
		if(!kita[b[i]]) ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str[] = br.readLine().split(" ");
		int n = Integer.parseInt(str[0]);
		int k = Integer.parseInt(str[1]);
		int h[] = new int[100010];

		str = br.readLine().split(" ");
		for (int i = 0; i < n; i++) {
			h[i] = Integer.parseInt(str[i]);
		}

		int dp[] = new int[100010];
		for (int i = 0; i < 100010; i++) {
			dp[i] = Integer.MAX_VALUE;
		}

		dp[0] = 0;

		for (int i = 1; i < n; i++) {
			for (int j = 1; j <= k; j++) {
				if (i > j - 1)
					dp[i] = Math.min(dp[i], dp[i - j] + Math.abs(h[i] - h[i - j]));
			}
		}

		System.out.println(dp[n-1]);
	}
}


Measured memory_bytes: 34140
#pragma region
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << "\n";
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << " ";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define dl double
#define wh while
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define tp tuple
#define ft first
#define sc second
#define ve vector
#define tos to_string
#define len length
#define rt return 0
#define br break
#define con continue
#define lcm(n, m) (n * m / gcd(n, m))
#define np next_permutation
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define repill(i, m, n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define repll(i, n) repill(i, 0, n)
#define revi(i, m, n) for(int i=(int)(m);i>(int)(n);i--)
#define rev(i, n) revi(i, 0, n)
#define revill(i, m, n) for(ll i=(ll)(m);i>(ll)(n);i--)
#define revll(i, n) revill(i, 0, n)
#define sz(v) ((int)(v).size()) 
#define each(i, n) for(auto&& i: n)
#define all(n) (n.begin(), n.end())
#define sp(n) cout << fixed << setprecision(n)
#pragma endregion
// sqrt ルート, int 2*10^9, gcd　最大公約数 __builtin_popcount bitの個数

int main() {
  st S, a = "";
  ci(S);
  rep(i, 3){
    if(S.at(i) == '1'){
      a += '9';
    }
    else{
      a += '1';
    }
  }
  co(a);
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

int n;
char s[100];

int main()
{
	scanf("%d", &n);
	scanf("%s", s);
	if (n >= 3200)
		printf("%s\n", s);
	else puts("red");
	return 0;
}

Measured memory_bytes: 128
import java.io.*;
import java.util.*;

public class Main {

    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public float nextFloat() {
            return Float.parseFloat(next());
        }

    }

    static InputReader r = new InputReader(System.in);
    static PrintWriter pw = new PrintWriter(System.out);

    /** CHECKLIST:
     * LIMITS (DOES BRUTE FORCE WORK?)
     * CHECK ALL PARAMETERS
     * INT VS LONG
     */
    public static void main(String[] args) {
        int n = r.nextInt();
        int k = r.nextInt();
        int[] arr = new int[n+1];
        for(int i = 1; i <= n; i++){
            arr[i] = r.nextInt();
        }
        int[] dp = new int[n+1];
        dp[1] = 0; // frog starts here
        for(int i = 2; i <= n; i++){
            int min = Integer.MAX_VALUE;
            for(int j = 1; j <= k; j++){
                if(i - j > 0){
                    min = Math.min(min, dp[i-j] + Math.abs(arr[i] - arr[i-j]));
                }
            }
            dp[i] = min;
        }
        pw.println(dp[n]);
        pw.close();
    }
}

/**
                _        _                 _                                                
               | |      | |               | |                                               
   ___ ___   __| | ___  | |__  _   _    __| | __ _ _ __ _ __ ___ _ __     _   _  __ _  ___  
  / __/ _ \ / _` |/ _ \ | '_ \| | | |  / _` |/ _` | '__| '__/ _ \ '_ \   | | | |/ _` |/ _ \ 
 | (_| (_) | (_| |  __/ | |_) | |_| | | (_| | (_| | |  | | |  __/ | | |  | |_| | (_| | (_) |
  \___\___/ \__,_|\___| |_.__/ \__, |  \__,_|\__,_|_|  |_|  \___|_| |_|   \__, |\__,_|\___/ 
                                __/ |                               ______ __/ |            
                               |___/                               |______|___/             
 */

Measured memory_bytes: 33296
for i in range(input()):    
	b=int(raw_input(),16)
	s=1<<31
	p=""
	if b&s!=0:
		b^=s
		p="-"
	a=int(b*1.0/(1<<7))
	print p+str(a)+str(abs(b*1.0/(1<<7)-a))[1:]

Measured memory_bytes: 4524
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<queue>
#include<set>
#include<map>
#include<stack>
using namespace std;
typedef long long LL;
const int N=4e5+100;
int gi() {
	int w=0;bool q=1;char c=getchar();
	while ((c<'0'||c>'9') && c!='-') c=getchar();
	if (c=='-') q=0,c=getchar();
	while (c>='0'&&c <= '9') w=w*10+c-'0',c=getchar();
	return q? w:-w;
}
int x[N],a[N],b[N];
int head[N],nxt[N],to[N],tot=1;
bool o[N],vis[N];
inline void link(int a,int b) {
	to[++tot]=b,nxt[tot]=head[a],head[a]=tot;
	to[++tot]=a,nxt[tot]=head[b],head[b]=tot;
}
inline void dfs(int k) {
	for (int i;i=head[k];)
		if (head[k]=nxt[i],!vis[i]) {
			vis[i^1]=true;
			dfs(to[i]);
			if (i&2)
				x[a[k]==to[i]?k:to[i]]=i&1?-1:1;
		}
}
inline void back(int k) {
	for (int i=head[k];i;i=nxt[i]) {
		x[k]-=x[i];
		back(i);
	}
}
int main()
{
	int n=gi(),i,rt;
	for (i=1;i<=n;i++) if ((a[i]=gi())==-1) a[i]=n+1,rt=i;
	for (i=1;i<=n;i++) if ((b[i]=gi())==-1) b[i]=n+1;
	for (i=1;i<=n;i++) {
		o[a[i]]^=1;o[b[i]]^=1;
		link(a[i],i);link(i,b[i]);
	}
	for (i=1;i<=n;i++) if (o[i]) return puts("IMPOSSIBLE"),0;
	puts("POSSIBLE");
	dfs(n+1);
	for (i=1;i<=n;i++) head[i]=0;
	for (i=1;i<=n;i++) nxt[i]=head[a[i]],head[a[i]]=i;
	back(rt);
	for (i=1;i<=n;i++) printf("%d ",x[i]);
	return 0;
}


Measured memory_bytes: 15360
#include <bits/stdc++.h>
#define pb push_back
#define MOD 1000000007
#define pii pair<int,int>
#define ll long long int
using namespace std;




void solve() {
    int mod = 2019;
    string s;
    cin >> s;
    int n = s.length();
    ll ans = 0;
    vector<int> suff(mod, 0);
    suff[0]++;
    int powerOften = 1;
    int suf = 0;

    for (int i = n - 1; i >= 0; --i)
    {
        int digit = s[i] - '0';
        suf = (suf + digit * powerOften) % mod;
        powerOften = (10 % mod * powerOften % mod) % mod;
        ans += suff[suf];
        suff[suf]++;
    }
    cout << ans << "\n";


}


















int main()
{

#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    //cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}




Measured memory_bytes: 3760
// 0033.cpp : コンソール アプリケーションのエントリ ポイントを定義します。
//

#include<stdio.h>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <iterator>
#include <list>
#include <map>     
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <iomanip>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define ll long long
#define ld long double
#define roop(a,t) for(int a=0;a<t;a++) 
int a[10], n;
bool bit(int n,vector<int>left,vector<int>right) {
	if (n == 10) {
		bool left_f = true;
		bool left_r = true;
		roop(i, (int)left.size() - 1) { if (left[i + 1] <= left[i]) { return false; } }
		roop(i, (int)right.size() - 1) { if (right[i + 1] <= right[i]) { return false; } }
		return true;
	}
	if (left.size() > 0 && right.size() > 0) {
		if (left[left.size() - 1] > a[n] && right[right.size() - 1] > a[n]) { return false; }
	}
	vector<int>new_l = left;
	vector<int>new_r = right;
	
	new_l.push_back(a[n]);
	new_r.push_back(a[n]);
	return (bit(n + 1, new_l, right) || bit(n + 1, left, new_r));
}
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> n;
	vector<int>emptynow;
	roop(i, n) {
		roop(j, 10) {
			cin >> a[j];
		}
		if (bit(0, emptynow, emptynow)) { cout << "YES" << endl;}
		else { cout << "NO" << endl; }
	}
	return 0;
}


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

int main() {
  int a,b,c,x; 
  cin >>a>>b>>c;
  if(c==a&&a==b){x=1;}
  else if(c!=a&&a!=b&&b!=c){x=3;}
  else{x=2;}
  
    cout<<x<<endl;
 
}


Measured memory_bytes: 256
#include <bits/stdc++.h>  // ver1.8
#define int long long
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define repreq(i,a,b) for(int i=a;i>=b;i--)
#define leng(n) (int)(log10(n)+1)
#define INF 9000000000000000000  //  9.0 * 10^18
#define MOD 1000000007  //  10^9 + 7
#define PAI 3.14159265358979
using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm

signed main() {
  cout << fixed << setprecision(14);
  int n;
  cin >> n;
  int ans = 0;
  rep(i,0,4){
    if(n%10==2) ans++;
    n /= 10;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
N, P = map(int, input().split())
A = list(map(int, input().split()))
ev = 0
od = 0
for a in A:
    if a % 2 == 0:
        ev += 1
    else:
        od += 1
if P == 0 and od == 0:
    print(2**ev)
else:
    print(2**ev * (2**od//2))


Measured memory_bytes: 38384
A, B, C, D, E, F = map(int, input().split())

con = -1
ans_w, ans_s = 0, 0
for i in range(F//(100*A) + 1):
    water = i*100*A
    for j in range((F-water)//(100*B) + 1):
        if i == 0 and j == 0:
            continue
        water += j*100*B
        for k in range((F-water)//C + 1):
            flg = 0
            sugar = k*C
            water += sugar
            if sugar > (A*i+B*j)*E:
                water = i*100*A
                break
            for l in range((F-water)//D + 1):
                sugar += l*D
                water += l*D
                if sugar > (A*i+B*j)*E:
                    water -= sugar
                    flg = 1
                    break
                tmp = 100*sugar/water
                if tmp > con:
                    con = tmp
                    ans_w = water
                    ans_s = sugar
                water -= l*D
                sugar -= l*D
            if flg == 0:
                water -= k*C

print(ans_w, ans_s)


Measured memory_bytes: 3064
#include <stdio.h>

int main()
{
	int N, M, c[30];
	scanf("%d%d", &N, &M);

	for(int i=0; i<30; i++){
		c[i] = 0;
	}

	for(int i=0; i<N; i++){
		int K;
		scanf("%d", &K);
		for(int j=0; j<K; j++){
			int A;
			scanf("%d", &A);
			c[A-1]++;
		}
	}

	int res = 0;
	for(int i=0; i<M; i++){
		if(c[i] == N){
			res ++;
		}
	}

	printf("%d\n", res);

	return 0;
}


Measured memory_bytes: 128
n=int(input())
p = list(map(int,input().split()))

k = []
for i in range(n):
    if p[i] == i+1:
        k.append(i+1)
#print(k)

ass = 0
c = 0
w = -2
for i in range(len(k)):

    if w+1 == k[i]:
        c += 1
        if i == len(k)-1:
            ass += (c//2)+(c%2)
    else:
        ass += (c//2)+(c%2)
        c = 1
        if i == len(k)-1:
            ass += 1
    w = k[i]

print(ass)

Measured memory_bytes: 14008
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,a,b) for(ll i=(a);i<=(b);++i)
#define FOD(i,a,b) for(ll i=(a);i>=(b);--i)
#define name "a"
#define pb push_back
typedef pair < ll , ll > ii;
const ll maxn=1e5+7,oo=1e18,mod=1e9+7;
ll a,b,c;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //freopen(name".inp","r",stdin);
    //freopen(name".out","w",stdout);
    cin>>a>>b>>c;
    swap(a,b);
    swap(a,c);
    cout<<a<<" "<<b<<" "<<c;
}


Measured memory_bytes: 256
#他の数字はそのままで，任意の2数の符号を同時に反転させることが可能．マイナスの数の偶奇で場合分け
n = int(input())
a = list(map(int,input().split()))
aabs = [i if i>=0 else i*(-1) for i in a]
MIN = min(aabs)
ans = 0
mcount = 0

for i in range(n):
  if a[i] < 0:
    mcount += 1
    
if mcount%2 == 0:
  for i in a:
    ans += abs(i)
  print(ans)
else:
  for i in a:
    ans += abs(i)
  print(ans - 2*MIN)

Measured memory_bytes: 14332
#include <iostream>

using namespace std;

int main()
{
	int x, y;

	cin >> x >> y;

	if(x < y)
		cout << "a < b" << endl;
	else if(y < x)
		cout << "a > b" << endl;
	else
		cout << "a == b" << endl;

	return 0;
}


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

int main(void){
    int N;
    cin>> N;
    string str(N,' ');
    cin >> str;
    if(N%2!=0){
        cout<<"No"<<endl;
    }
    else{
        for(int i=0;i<N/2;i++){
            if(str[i]!=str[i+N/2]){
                cout<<"No"<<endl;
                break;
            }
            if(i==N/2-1){
                cout<<"Yes"<<endl;
                break;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main(void){
    int n, m, wa = 0, ac = 0;
    cin >> n >> m;
    vector<int> mem(n, 0);
    for(int i=0;i<m;i++){
        int p;
        string s;
        
        cin >> p >> s;
        p--;
        if(mem[p] == -1) continue;
        if(s == "AC"){
            wa += mem[p];
            mem[p] = -1;
            ac++;
        }else{
            mem[p]++;
        }
    }
    cout << ac << " " << wa << endl;
}


Measured memory_bytes: 640
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int h = sc.nextInt();
		int w = sc.nextInt();
		int d = sc.nextInt();
		int n = sc.nextInt();
		
		char[][] map = new char[h][w];
		int sy = -1;
		int sx = -1;
		for(int i=0;i<h;i++){
			String s = sc.next();
			for(int j=0;j<w;j++){
				if(s.charAt(j)=='D'){
					sy = i;
					sx = j;
				}
				map[i][j] = s.charAt(j);
			}
		}
		
		int[] r = new int[d];
		for(int i=0;i<d;i++){
			r[i] = sc.nextInt();
		}
		
		int[][] cnt = new int[h][w];
		for(int k=0;k<n;k++){
			int x = sc.nextInt();
			int y = sc.nextInt();
			int s = sc.nextInt();
			
			int sty, edy, stx, edx;
			
			if(s==d){
				for(int i=0;i<=h-1;i++){
					for(int j=0;j<=w-1;j++){
						cnt[i][j]++;
					}
				}
			}
			if(s!=d){
				sty = Math.max(0, y-r[s]);
				edy = Math.min(h-1, y+r[s]);
				stx = Math.max(0, x-r[s]);
				edx = Math.min(w-1, x+r[s]);
				for(int i=sty;i<=edy;i++){
					for(int j=stx;j<=edx;j++){
						cnt[i][j]++;
					}
				}
			}
			if(s!=0){
				sty = Math.max(0, y-r[s-1]);
				edy = Math.min(h-1, y+r[s-1]);
				stx = Math.max(0, x-r[s-1]);
				edx = Math.min(w-1, x+r[s-1]);
				for(int i=sty;i<=edy;i++){
					for(int j=stx;j<=edx;j++){
						cnt[i][j]--;
					}
				}
			}
			
		}
		
		boolean f1 = false;
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				if(cnt[i][j]==n) f1 = true;
			}
		}
		
		String ans = "";
		if(f1){
			boolean[][] vst = new boolean[h][w];
			int[] a = new int[]{1,-1,0,0};
			int[] b = new int[]{0,0,1,-1};
			ArrayDeque<Integer> y = new ArrayDeque<Integer>();
			ArrayDeque<Integer> x = new ArrayDeque<Integer>();
			y.offer(sy);
			x.offer(sx);
			vst[sy][sx] = true;
			while(!y.isEmpty()){
				int ty = y.poll();
				int tx = x.poll();
				for(int i=0;i<4;i++){
					int ny = ty+a[i];
					int nx = tx+b[i];
					if(ny>=0 && ny<h && nx>=0 && nx<w && !vst[ny][nx] && map[ny][nx]!='#'){
						y.offer(ny);
						x.offer(nx);
						vst[ny][nx] = true;
					}
				}
			}
			
			boolean f2 = false;
			boolean f3 = false;
			for(int i=0;i<h;i++){
				for(int j=0;j<w;j++){
					if(map[i][j]!='#' && cnt[i][j]==n){
						if(vst[i][j]) f2 = true;
						else f3 = true;
					}
				}
			}
			
			if(f2 && f3) ans = "Unknown";
			else if(f2) ans = "Yes";
			else if(f3) ans = "No";
		}else{
			ans = "Broken";
		}
		
		System.out.println(ans);

	}	
}

Measured memory_bytes: 21248
if __name__ == '__main__':
    while True:
        data = [int(x) for x in input().split(' ')]
        H = data[0]
        W = data[1]

        if H == 0 and W == 0:
            break

        for i in range(H):
            if i == 0 or i == H-1:
                print('#' * W)
            else:
                print('#' + '.'*(W-2) + '#')
        print('')

Measured memory_bytes: 7628
#include <iostream>
#include <vector>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }

long long dp[100][2];

int main() {
    int N;
    long long K;
    cin >> N >> K;
    vector<long long> A(N);
    for (int i = 0; i < N; ++i) cin >> A[i];
    
    for (int i = 0; i < 100; ++i) dp[i][0] = dp[i][1] = -1;
    dp[45][0] = 0;
    for (int d = 44; d >= 0; --d) {
        long long mask = 1LL<<d;
        int num = 0;
        for (int i = 0; i < N; ++i) if (A[i] & mask) ++num;
        
        if (dp[d+1][1] >= 0) chmax(dp[d][1], dp[d+1][1] + mask * max(num, N-num));
        if (dp[d+1][0] >= 0) {
            if (K & (1LL<<d)) {
                chmax(dp[d][1], dp[d+1][0] + mask * num);
                chmax(dp[d][0], dp[d+1][0] + mask * (N-num));
            }
            else {
                chmax(dp[d][0], dp[d+1][0] + mask * num);
            }
        }
    }
    cout << max(dp[0][0], dp[0][1]) << endl;
}

Measured memory_bytes: 4060
#include <bits/stdc++.h>
#define int long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define pb push_back
#define ALL(obj) (obj).begin(), (obj).end()
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
typedef long long ll;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

signed main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  string S;
  cin >> S;
  int N = S.length();
  vector<int> v(N, 0);
  vector<int> RL;
  int init = 0;
  while(true) {
    auto pos = S.find("RL", init);
    if (pos != std::string::npos) {
      RL.pb((int)pos);
      init = (int)pos + 1;
    }
    else break;
  }

  REP(i,N) {
    if(S[i] == 'R') {
      auto itr = lower_bound(ALL(RL),i);
      int d = *itr - i;
      if (d % 2 == 0) ++v[*itr];
      else ++v[*itr+1];
    } else {
      auto itr = lower_bound(RL.rbegin(),RL.rend(),i, [](const int &a, const int &b){ return a > b; });
      int d = abs(*itr - i);
      if (d % 2 == 0) ++v[*itr];
      else ++v[*itr+1];
    }
  }

  for(auto e: v) {
    cout << e << " ";
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 1864
import sys
input = sys.stdin.readline
n,T=map(int,input().split())
t=list(map(int,input().split()))
s=t[0]
ans=0
for i in range(1,n):
    if t[i-1]+T<t[i]:
        ans+=t[i-1]+T-s
        s=t[i]
ans+=t[-1]+T-s
print(ans)


Measured memory_bytes: 77520
H, W = map(int, input().split())

field = []

field.append(' ' * (W + 2))
for i in range(H):
    field.append(' ' + input() + ' ')
field.append(' ' * (W + 2))

# print(field)
flag = True
for h in range(1,H+1):
    if not flag: break
    for w in range(1,W+1):
        if not flag: break
        if field[h][w] == '#':
            if '#' in (field[h-1][w], field[h][w-1], field[h][w+1], field[h+1][w]): pass
            else: flag = False

if flag: print('Yes')
else: print('No')

Measured memory_bytes: 3064
from collections import Counter

N = int(input())
S = [input() for _ in range(N)]
s_counter = Counter(S)
print('AC x {}'.format(s_counter['AC']))
print('WA x {}'.format(s_counter['WA']))
print('TLE x {}'.format(s_counter['TLE']))
print('RE x {}'.format(s_counter['RE']))


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

int main() {
  int n, a, b;
  cin >> n >> a >> b;
  string s;
  cin >> s;
  int pass = 0, fpass = 0;
  for (int i = 0; i < n; i ++) {
    if (s[i] == 'c') {
      cout << "No" << endl;
    } else if (s[i] == 'a') {
      if (pass < a + b) {
        cout << "Yes" << endl;
        pass ++;
      } else {
        cout << "No" << endl;
      }
    } else {
      if (pass < a + b && fpass < b) {
        cout << "Yes" << endl;
        pass ++, fpass ++;
      } else {
        cout << "No" << endl;
      }
    }
  }
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
#define int long long
using namespace std;
constexpr int mod=1e9+7;
signed main(){
    int n,l[2000];
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>l[i];
    sort(l,l+n);
    int ans=0;
    for(int i=0;i<n-2;i++)
        for(int j=i+1;j<n-1;j++)
            ans+=lower_bound(l,l+n,l[i]+l[j])-l-1-j;
    cout<<ans<<endl;
}


Measured memory_bytes: 256
// copy from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        k: usize,
    }
    println!("{}", solve(n, k))
}

fn solve(n: usize, k: usize) -> f64 {
    let mut ans: f64 = 0.0;
    for i in 1..n+1 {
        let mut score = i;
        let mut a = 1.0;
        while score < k {
            score *= 2;
            a /= 2.0;
        }
        ans += a;
    }
    (ans / (n as f64))
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn sample1() {
        let actual = solve(3, 10);
        let expected = 0.145833333333;
        assert!((actual - expected).abs() < 10e-9, "{}", actual)
    }

    #[test]
    fn sample2() {
        let actual = solve(100000, 5);
        let expected = 0.999973749998;
        assert!((actual - expected).abs() < 10e-9, "{}", actual)
    }
}


Measured memory_bytes: 4352
#include<iostream>
using namespace std;
int main() {
	bool prime[1000000];
	int a, d, n;
	prime[1] = false;
	for (int i = 2; i < 1000000; ++i) prime[i] = true;
	for (int i = 2; i*i < 1000000; ++i)
		if (prime[i])
			for (int j = 2; i*j < 1000000; ++j) prime[i*j] = false;
	while (cin >> a >> d >> n && a&&d&&n) {
		int cnt = 0;
		while (cnt != n) {
			if (prime[a]) ++cnt;
			a += d;
		}
		cout << a - d << endl;
	}
	return 0;
}


Measured memory_bytes: 4064
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define repA(i,a,n) for(int i=a;i<n;i++)
#define trav(a,x)for(auto &a: x)
#define fll(a) memset(a,0,sizeof(a));
#define mp make_pair
#define pb push_back
#define all(x) x.begin(),x.end()
#define F first
#define S second
#define itr(it,x) for(auto it=x.begin();it!=x.end();it++)
typedef long long ll;
typedef long double ld;
typedef pair<int,int>pii;
typedef vector<int>vi;
typedef map<int,int>ma;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
void fopen()
{
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);   
}
# define PI    3.14159265358979323846  
void solve()
{
  ld r;
  cin>>r;
  cout<<2*PI*r;

}
int main()
{
  fastio;
 // fopen();
  int t;
//  cin>>t;
  rep(i,1)
  { 
   // cout<<"Case #"<<i+1<<": ";
    solve();
    cout<<endl;
  }
  
}

Measured memory_bytes: 3808
import numpy as np

n = int(input())
p = []
p = list(map(int, input().split()))

cnt=0
for i in range(1, n-1):
    tmp = np.array([p[i-1], p[i], p[i+1]])
    if np.argsort(tmp)[1] == 1:
        cnt+=1

print(cnt)

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

int main(){
  
  int n, s = 0;
  string str;
  
  cin >> n;
  
  str = to_string(n);
  for(int i = 0;i < str.size();i++) s += str[i] - '0';
  
  if(n % s == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<map>
using namespace std;

const int MAX_NUM_OF_STR = 1010;

int main(){
	int len = 0, tango = 0;
	string str[MAX_NUM_OF_STR], max, maxlen;
	map<string, int> string_cnt;
	
	while(cin >>str[tango]){
		string_cnt[str[tango]]++;
		
		if(str[tango].size() > (unsigned)len){
			len = str[tango].size();
			maxlen = str[tango];
		}
		tango++;
	}
	
	map<string, int>::iterator it = string_cnt.begin();
	int cnt = -1;
	string tmp;
	for(int i = 0 ; i < string_cnt.size(); it++, i++){
		if((*it).second > cnt){
			cnt = (*it).second;
			tmp = (*it).first;
		}
	}
	max = tmp;
	
	cout <<max <<" " <<maxlen <<endl;
	return 0;
}

Measured memory_bytes: 0
// {{{
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

using namespace std;

typedef long int i32;
typedef unsigned long int u32;
typedef long long int i64;
typedef unsigned long long int  u64;
typedef pair<i32, i32> PII;
typedef vector<i32> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<i32, i32> MPII;
typedef set<i32> SETI;
typedef multiset<i32> MSETI;
#define IN(x) cin >> x;
#define SCD(t) scanf("%d",&t)
#define SCLD(t) scanf("%ld",&t)
#define SCLLD(t) scanf("%lld",&t)
#define SCC(t) scanf("%c",&t)
#define SCS(t) scanf("%s",t)
#define SCF(t) scanf("%f",&t)
#define SCLF(t) scanf("%lf",&t)
#define MEM(a, b) memset(a, (b), sizeof(a))
#define ZERO(a) memset(a, 0, sizeof(a))
#define FOR(i, j, k, in) for (int i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define BTW(A, B, C) assert( B <= A && A <= C)
#define MP make_pair
#define PB push_back
#define PF push_front
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;

template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
// }}}
const u64 MAX_N = 100000;
u64 N, x, y;
u64 a[MAX_N+1], fact[MAX_N+2], inv[MAX_N+2];

u64 powMOD(u64 a, u64 b) {
    u64 x, ret;
    x = a;
    ret = 1;
    while(b) {
        if(b&1) {
            ret = ret * x % MOD;
        }
        x = x * x % MOD;
        b >>= 1;
    }
    return ret % MOD;
}

u64 C(u64 n, u64 m) {
    if(m == 0) {
        return 1;
    }
    return (fact[n] * inv[n-m] % MOD) * inv[m] % MOD;
}

u64 solve(u64 n) {
    u64 ans = C(N+1, n) % MOD;
    if(n <= x+1 + N+1 - (y+1)) {
        ans = (ans + MOD - C(x+1 + N+1 - (y+1) - 1, n - 1)) % MOD;
    }
    return ans;
}

pair<u64, u64> search() {
    int used[MAX_N];
    memset(used, -1, sizeof(used));
    REP(i, N+1) {
        if(used[a[i]-1] != -1) {
            return MP(used[a[i]-1], i);
        }
        used[a[i]-1] = i;
    }
}

int main() {
    IN(N);
    REP(i, N+1) IN(a[i]);
    auto xy = search();
    x = xy.first;
    y = xy.second;
    fact[0] = 1;
    inv[0] = powMOD(fact[0], MOD-2);
    REP(i, N+2) {
        fact[i+1] = (i+1) * fact[i] % MOD;
        inv[i+1] = powMOD(fact[i+1], MOD-2);
    }
    REP(i, N+1) {
        cout << solve(i+1) << endl;
    }
    return 0;
}



Measured memory_bytes: 3968
import java.util.Scanner;

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

		for(int i=N;i<1000;i++) {
			if(i%111==0) {
				System.out.println(i);
				break;
			}
		}
		
		sc.close();
	}
}

Measured memory_bytes: 21844
from itertools import*
n=int(input())

points=[list(map(int,input().split()))for i in range(n)]

x=list(permutations(points))
y=0
for i in x:
    pre=i[0]
    for j in i[1:]:
        y+=((pre[0]-j[0])**2+(pre[1]-j[1])**2)**0.5
        pre=j
print(y/len(x))

Measured memory_bytes: 8180
def num2alpha(num):
    if num<=26:
        return chr(64+num)
    elif num%26==0:
        return num2alpha(num//26-1)+chr(90)
    else:
        return num2alpha(num//26)+chr(64+num%26)

if __name__ == "__main__":
    N = int(input())
    N = num2alpha(int(N)).lower()
    print(N)


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

using namespace std;

#define int long long
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define bitcnt __builtin_popcount
#define SZ(x) ((ll)(x).size())
#define fi first
#define se second
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"
#define Printv(v)                                                              \
    {                                                                          \
        FOREACH(x, v) { cout << x << " "; }                                    \
        cout << "\n";                                                          \
    }
template <typename T = string> inline void eputs(T s) {
    cout << s << "\n";
    exit(0);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    std::fill((T *)array, (T *)(array + N), val);
}
template <typename T> using PQG = priority_queue<T, vector<T>, greater<T>>;
template <typename T> using PQ = priority_queue<T>;

typedef long long ll;
typedef unsigned long long ul;
typedef vector<ll> VL;
typedef pair<ll, ll> PL;

const int INF = 1e9;
const int MOD = 1e9 + 7;
// const int MOD = 998244353;
const ll LINF = 1e18 + 1;
const ll dx[] = {1, -1, 0, 0};
const ll dy[] = {0, 0, 1, -1};

ll N, X;

signed main() {
    cin >> N >> X;
    ll now = 0;
    REP(i, N) {
        LCIN(L);
        now += L;
        if(now > X) {
            cout << i + 1 << "\n";
            return 0;
        }
    }
    cout << N + 1 << "\n";
}


Measured memory_bytes: 256
import java.util.*;
 
public class Main {
	
  	static long[] all_patty = new long[51];
    static long[] burger_size = new long[51];

    static long calc_burger_size(int level) {
        if (level == 0)
            return 1;
        if (burger_size[level] != 0)
            return burger_size[level];

        return burger_size[level] = 3 + 2 * calc_burger_size(level - 1);
    }

    static long calc_all_patty(int level) {
        if (level == 0)
            return 1;
        if (all_patty[level] != 0)
            return all_patty[level];

        return all_patty[level] = 1 + 2 * calc_all_patty(level - 1);
    }

    static long eat_patty(int level, long X) {
        if (level == 0) {
            return Math.min((long)X, 1L);
        }

        long result = 0L;
        long this_burger_size = calc_burger_size(level);

        if(X >= this_burger_size - 1){
            result =  calc_all_patty(level);
        }else if(X > this_burger_size / 2){
            result =  calc_all_patty(level - 1) + 1 + eat_patty(level - 1, X - this_burger_size / 2 - 1);
        }else if(X > 1L){
            result = eat_patty(level - 1, X - 1);
        }else{
            result = 0L;
        }

        return result;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        long X = Long.parseLong(sc.next());
        sc.close();

        all_patty[0] = 1L;
        burger_size[0] = 1L;
        System.out.println(eat_patty(N, X));
    }
}

Measured memory_bytes: 23636
import java.util.Scanner
object Main{
    def main(args:Array[String]):Unit = {
        val scan = new Scanner(System.in)
        var list = List[Int]()
        while(scan.hasNextInt()){
            val a = scan.nextInt()
            val b = scan.nextInt()
            list :+= a+b
        }
        for(i <- list){
            println(i.toString.length)
        }
    }
}

Measured memory_bytes: 45784
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    int ara[n];
    for(int i =0; i < n;i++)
    {
        cin >> ara[i];
    }
    long long int c = 0;
    for(int i =0; i< n;i++)
    {
        int x  =ara[i];
        while(x% 2 == 0)
        {
            x/=2;
            c++;
        }
    }
    cout << c << endl;
}





Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
#include <set>
using namespace std;
int main(){
  	string s;
  	cin >> s;
  	if(s.length() == 26){
		set<char> al;
      	char bef = 0;
      for(int i = s.length() - 1; 0 <= i; i--){
		if(bef < s[i]){
          	bef = s[i];
        	al.insert(s[i]);
        }
        else{
			cout << string(s.begin(), s.begin() + i) << *al.lower_bound(s[i]) << endl;
        	return 0;
        }
       }
      	cout << -1 << endl;
    }
  else{
	set<char> al;
    for(char ch = 'a'; 'z' >= ch; ch++) al.insert(ch);
    for(auto ch : s) al.erase(ch);
    cout << s << *al.begin() << endl;
  }
	return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<vector<int> > a(3,vector<int>(n+1,0));
    for(int i = 1; i <= n; i++) cin >> a[1][i];
    for(int i = 1; i <= n; i++) cin >> a[2][i];
    int sum1 = 0;
    int sum2 = 0;
    int sum = 0;
    int max = 0;
    for(int i = 1; i <= n; i++){
        sum1 += a[1][i];
        sum2 = 0;
        for(int j = i; j <= n; j++){
            sum2 += a[2][j];
        }
        sum = sum1 + sum2;
        if(sum > max) max = sum;
    }
    cout << max << endl;
}

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


class BIT {
public:
    ll n;
    vector<ll> bit;
    BIT(ll n):n(n),bit(n+1,0){}

    void add(ll i,ll x){
        if(i==0) return;
        for(ll k=i;k<=n;k+=(k & -k)){
            bit[k]+=x;
        }
    }

    ll sum(ll i){
        ll s=0;
        if(i==0) return s;
        for(ll k=i;k>0;k-=(k & -k)){
            s+=bit[k];
        }
        return s;
    }
};


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

    BIT bit(n+2);
    for (ll i = 0; i < n; i++) {
        bit.add(max(i-a[i]+1, (ll)1), 1);
        bit.add(min(n+1, i+a[i]+2), -1);
    }

    ll maxc = 0;
    for (ll j = 0; j < k-1; j++){
        BIT nex(n+1);
        maxc = 0;
        for (ll i = 1; i < n+1; i++) {
            ll bt = bit.sum(i);
            nex.add(max((ll)1, i-bt), 1);
            nex.add(min(n+1, i+bt+1), -1);
            if (bt == n) {
                maxc += 1;
            }
        }
        bit = nex;
        if (maxc == n) break;
    }
    if (maxc == n) {
        for (ll i = 0; i < n -1; i++) {
            cout << n << " ";
        }
        cout << n << endl;
        return 0;
    }
    for (ll i = 1; i < n; i++) {
        cout << bit.sum(i) << " ";
    }
    cout << bit.sum(n) << endl;
    return 0;
}

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

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

  vector<int64_t> lucas(N);

  if (N==0){
    lucas = {2};
  }else{
    lucas = {2, 1};
  }

  for(int i=2; i<N+1; i++){
    lucas.push_back(lucas[i-1] + lucas[i-2]);
  }

  cout << lucas[N] << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
//#define INF 810114514
//#define PI 3.141592653589
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "0" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl


signed main(void){
    int N,A,B;
    cin >> N >> A >> B;
    int a=0,b=0;
    a+=A*(N/(A+B));
    b+=B*(N/(A+B));
    N=(N%(A+B));
    if(N<=A){
        a+=N;
    }else{
        a+=A;
        b+=N-A;
    }
    
    cout << a << endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>

using namespace std;
int n,m,temp;
int t[10005];
long long int sum;
int main(){
	while(1){
		cin >> n;
		if(n==0)break;
		m=n;
		while(m--){
			cin >> t[m];
		}
		for(int i=0;i<n-1;i++){
			for(int j=0;j<n-1-i;j++){
				if(t[j]>t[j+1]){
					temp=t[j];
					t[j]=t[j+1];
					t[j+1]=temp;
				}
			}
		}
		sum=0;
		for(int i=0;i<n-1;i++){
			sum+=(i+1)*t[n-2-i];
		}
		cout << sum << endl;
	}
	return 0;
}

Measured memory_bytes: 3080