akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define srt(x) sort((x).begin(), (x).end());
#define rsrt(x) sort((x).rbegin(), (x).rend());
#define deb(x) cout<<#x<<" = "<<(x)<<" (L"<<LINE<<")"<<endl;
#define vdeb(x) {cout<<#x<<" = { "; rep(i, x.size()) cout<<x[i]<<' '; cout <<'}'<<" (L"<<LINE<<")"<<endl;}
using namespace std;
using ll = long long;
using vi = vector<int>;
using vivi = vector<vi>;
using vll = vector<long long>;
using vllvll = vector<vll>;
using vs = vector<string>;
using um = unordered_map<long long, long long>;
const long long INF = 1LL << 60;
const long long MOD = 1e9 + 7;

int main()
{
    ll n, x;
    vll res;
    do {
        cin >> n >> x;
        if (n == 0 and x == 0) break;
        vll nums(n);
        rep(i, 0, n) {
            nums[i] = i+1;
        }
        ll cnt = 0;
        rep(i, 0, n) {
            rep(j, i+1, n) {
                rep(k, j+1, n) {
                    if (nums[i]+nums[j]+nums[k] == x) {
                        ++cnt;
                    }
                }
            }
        }
        res.push_back(cnt);
    } while (true);
    for (ll el : res) {
        cout << el << endl;
    }
}


Measured memory_bytes: 3136
// author: Saman Mahdanian
#include <bits/stdc++.h>

using namespace std;
const int N = 2e5 + 10;

int n, m, a[N], cnt[N], f[N];

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

	for (int i = 0; i <= n; i++)
		for (int j = max(0, i - cnt[i]); j < i; j++)
			f[j]++;

	int bads = 0;
	for (int i = 0; i < n; i++)
		if (f[i] == 0)
			bads++;

	for (int i = 0; i < m; i++) {
		int x, y;
		cin >> x >> y;
		x--;

		if (a[x] - cnt[a[x]] >= 0 && (--f[a[x] - cnt[a[x]]]) == 0)
			bads++;
		cnt[a[x]]--;
		a[x] = y;
		cnt[a[x]]++;
		if (a[x] - cnt[a[x]] >= 0 && (f[a[x] - cnt[a[x]]]++) == 0)
			bads--;
		cout << bads << endl;
	}
}

// SamMHD :: May23-2019 :: Another SOALE-NAMAKI...

Measured memory_bytes: 3840
import java.util.Scanner;


	public class Main {
		
		

		public static void main(String[] args) {

			Scanner sc = new Scanner(System.in);
			
			int n = sc.nextInt();
			int k = sc.nextInt();
			int spoint = sc.nextInt();
			int ppoint = sc.nextInt();
			int rpoint = sc.nextInt();
			int[] p = new int[n];
			int ret = 0;
			
			char[] t = sc.next().toCharArray();
			
			for(int i=k;i<n;i++) {
				if(t[i]==t[i-k]) {
					t[i] = 'x';
				}
			}
			
			
			for(int i=0;i<n;i++) {
				if(t[i]=='s') {
					p[i] = spoint;
				}else if(t[i]=='p') {
					p[i] = ppoint;
				}else if(t[i]=='r') {
					p[i] = rpoint;
				}
			}
			
			
			
			for(int i=0;i<n;i++) {
				ret += p[i];
			}
			
			System.out.println(ret);
	    }
				
	}
	


Measured memory_bytes: 40164
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, a, b) for(int i = a; i < b; i++)
#define rrep(i, a, b) for(int i = b - 1; i >= a; i--)
#define ALL(a) a.begin(), a.end()
#define pii pair<int,int>
#pragma GCC optimize("Ofast")
#define pcnt __builtin_popcount
#define buli(x) __builtin_popcountll(x)
#define pb push_back
#define mp make_pair
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
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; };
inline void IN(void){return;}
template <typename First, typename... Rest> void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
inline void OUT(void){cout << "\n";return;}
template <typename First, typename... Rest> void OUT(First first, Rest... rest){cout << first << " ";OUT(rest...);return;}
const double EPS = 1e-9;
const int mod = 1e9 + 7;
long long lcm(ll a, ll b){return a * b / __gcd(a,b);}
struct IoSetup { IoSetup() {
    cin.tie(nullptr);ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
} } iosetup;
template< int mod > struct ModInt {
    int x; ModInt() : x(0) {}
    ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
    ModInt &operator+=(const ModInt &p) {if((x += p.x) >= mod) x -= mod;return *this;}
    ModInt &operator-=(const ModInt &p) {if((x += mod - p.x) >= mod) x -= mod;return *this;}
    ModInt &operator*=(const ModInt &p) {x = (int) (1LL * x * p.x % mod);return *this;}
    ModInt &operator/=(const ModInt &p) {*this *= p.inverse();return *this;}
    ModInt operator-() const { return ModInt(-x); }
    ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
    ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
    ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
    ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
    bool operator==(const ModInt &p) const { return x == p.x; }
    bool operator!=(const ModInt &p) const { return x != p.x; }
    ModInt inverse() const {int a = x, b = mod, u = 1, v = 0, t;
    while(b > 0) { t = a / b; swap(a -= t * b, b); swap(u -= t * v, v); }return ModInt(u);}
    ModInt pow(int64_t n) const {ModInt ret(1), mul(x); while(n > 0) {if(n & 1) ret *= mul;mul *= mul;n >>= 1;}return ret;}
    friend ostream &operator<<(ostream &os, const ModInt &p) { return os << p.x;}
    friend istream &operator>>(istream &is, ModInt &a) { int64_t t; is >> t; a = ModInt< mod >(t); return (is); }
    static int get_mod() { return mod; }
}; using modint = ModInt< mod >;

void solve(long long a, long long b){
    if(b < a) swap(a,b);
    rep(i, 0, b) cout << a;
    cout << endl; 
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long a;
    scanf("%lld",&a);
    long long b;
    scanf("%lld",&b);
    solve(a, b);
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
    int th,ta,ah,aa;
    scanf("%d %d %d %d",&th,&ta,&ah,&aa);
    int p= th/aa>=ah/ta ? th/aa : ah/ta;
    int th2=th-aa*p;
    int ah2=ah-ta*p;
    if((th2>0 && ah2>0 && ah2-ta<=0) || (ah2<=0)){
        printf("Yes");
    }else{
        printf("No");
    }
    return 0;
}

Measured memory_bytes: 1728
#include<iostream>
#include<algorithm>
using namespace std;
int a[105];

void trace(int a[], int N)
{
	for(int i = 0; i < N; i++)
	{
		if(i > 0)
			cout << " ";
		cout << a[i];	
	} 
	cout << endl;
} 

void insertion_sort(int a[], int N)
{
	int key, j;
	for(int i = 1; i < N; i++)
	{
		key = a[i];
		j = i - 1;
		while(j >= 0 && a[j] > key)
		{
			a[j+1] = a[j];
			j--;
		}
		a[j+1] = key;
		trace(a, N);
	}
}

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


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

BegEndTbl = []
for _ in range(10):
    BegEndTbl.append([0] * 10)

ans = 0
for i in range(1, N + 1):
    left = int(str(i)[0])
    right = i % 10
    if left == right:
        ans += 1
    ans += BegEndTbl[right][left] * 2
    BegEndTbl[left][right] += 1
print(ans)

Measured memory_bytes: 3060
import java.util.Scanner;

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

        for (int i=1;i<=5;i++) {
            int x = sc.nextInt();
            if (x == 0) {
                System.out.println(i);
                return;
            }
        }
    }
}


Measured memory_bytes: 35664
#include<bits/stdc++.h>
#define int long long int
using namespace std;
#define pb push_back
int32_t main()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif

	int n;cin >> n;
	int a[n];
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	int ans=0;
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			for(int k=j+1;k<n;k++){
				if(a[i]!=a[j]&&a[i]!=a[k]&&a[j]!=a[k]&&(a[i]+a[j]>a[k])&&(a[i]+a[k]>a[j])&&(a[j]+a[k]>a[i])){
					ans++;
				}
			}
		}
	}
	cout << ans << endl;


	return 0;
}


Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;

int calc_keta(int n){
    int cnt=0;
    while(n>0){
        cnt++;
        n/=10;
    }
    return cnt;
}
int main()
{
    int N;
    cin >> N;

    int cnt=0;
    REP(i,N+1){
        if(calc_keta(i)%2==1) cnt++;
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 256
import itertools
N,M,Q = map(int,input().split())
abcd = [list(map(int,input().split())) for i in range(Q)]
#print(N,M,Q)
#print(abcd)

A_list = list(itertools.combinations_with_replacement(range(1,M+1),N))
#print(A_list)
score_max=0
for A in A_list:
    score = 0
#    print("A=",A)
    for row in abcd :
#        print("row=",row)
        if A[row[1]-1]-A[row[0]-1]==row[2]:
#            print('get')
            score += row[3]
    if score > score_max:
            score_max = score
#            print('max_revised: ', score_max)
    else:
        pass
print(score_max)

Measured memory_bytes: 21552
#include <iostream>
#include<string>
using namespace std;
int main(void){
    int N;
    cin>>N;
    int A,B,C,P;
    P=300;
    for(int i=1;i<N;i++){
        A=i%10+(i/10)%10+(i/100)%10+(i/1000)%10+(i/10000)%10+(i/100000)%10;
        C=N-i;
        B=C%10+(C/10)%10+(C/100)%10+(C/1000)%10+(C/10000)%10+(C/100000)%10;
        if(P>A+B){
            P=A+B;
           
        }
        
        
    }
    
    
    cout<<P<<endl;
    
    return 0;
    
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main{
	public static void main(String[] args){

	Scanner sc = new Scanner(System.in);

    int p = 700;

    String s = sc.next();
    for(int i = 0; i < s.length(); i++){
    	if(s.charAt(i)== 'o' ){
          p+=100;
        }
    }
    System.out.println(p);
    }
}

Measured memory_bytes: 26836
void main() {
    int n = readln.chomp.to!int;
    long[] d = readln.split.to!(long[]);
    long mod = 998244353;
    long ans;
    if (d[0] == 0) {
        long[] a = d[1..$];
        a.sort!"a < b";
        if (a[0] == 1) {
            ans = 1;
            auto g = a.group.array;
            long b = 1;
            long c;
            foreach (x; g) {
                if (x[0] == 1) {
                    c = x[1].to!long;
                } else if (x[0] == b + 1) {
                    long tmp = 1;
                    foreach (i; 0 .. x[1]) {
                        tmp = tmp * c % mod;
                    }
                    ans = ans * tmp % mod;
                    ++b;
                    c = x[1].to!long;
                } else {
                    ans = 0;
                    break;
                }
            }
        }
    }
    ans.writeln;
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.container;
import std.typecons;

Measured memory_bytes: 7412
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#define fi first
#define se second
#define pb push_back
#define forn(i,n) for(int i=0;i<(n);i++)
#define for1(i,n) for(int i=1;i<=n;i++)
#define forr(i,n) for(int i=n;i>=0;i--)
#define all(x) x.begin(), x.end()
const int MAXN = 3e3 +5;

void fio(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}

int dp[MAXN][MAXN];
int fr[MAXN][MAXN];

int main(){
  fio();
  string s,t; cin>>s>>t;
  int n = s.size();
  int m = t.size();
 
  forn(i,n){
  		forn(j,m){
  			if(s[i]==t[j]){
  			 if((i>=1 &&j>=1?dp[i-1][j-1]:0) + 1 > dp[i][j]){
  			 	dp[i][j] = (i>=1 &&j>=1?dp[i-1][j-1]:0) + 1;
  			 	fr[i][j] = 2;
  			 }
  			}
  			if((i>=1?dp[i-1][j]:0) > dp[i][j]){
  				dp[i][j] = (i>=1?dp[i-1][j]:0);
  			 	fr[i][j] = 1;
  			}
  			if(( j>=1?dp[i][j-1]:0) > dp[i][j]){
  				dp[i][j] =  j>=1?dp[i][j-1]:0;
  			 	fr[i][j] = 0;
  			}
  		}
  }
  string an = "";
  int x = n-1, y = m-1;
  while((x>=0)&&(y>=0)){
  	if(fr[x][y]==0){
  		y--;
  	}
  	else if(fr[x][y]==1){
  		x--;
  	}
  	else{
  		an+=s[x];
  		x--,y--;
  	}
  }
  reverse(all(an));
  cout<<an<<endl;
  return 0;
}

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

#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;

constexpr int MOD = 1000000007;

struct Node {
    int location;
    int p, l, r;
    Node() {}
    Node(int _p, int _l, int _r) : p(_p), l(_l), r(_r) {}
    Node(const Node& n) : p(n.p), l(n.l), r(n.r) {}
};

struct Point {
    int id, x, y;
    Point() {}
    Point(int _id, int _x, int _y) : id(_id), x(_x), y(_y) {}
    Point(const Point& p) : id(p.id), x(p.x), y(p.y) {}
    bool operator<(const Point& p) const { return id < p.id; }
};

bool less_id(const Point& l, const Point& r) { return l.id < r.id; };
bool less_x(const Point& l, const Point& r) { return l.x < r.x; };
bool less_y(const Point& l, const Point& r) { return l.y < r.y; };

class KdTree {
private:
    vector<Point> points;
    vector<Node> nodes;
    int n;

public:
    KdTree() : points(), nodes(), n(0) {}
    KdTree(const vector<Point>& points) : points(points), nodes(points.size()), n(0) { make_tree(0, points.size(), 0); }

    int make_tree(int l, int r, int depth) {
        if (!(l < r)) { return -1; }

        int mid = (l + r) / 2;
        int t = n++;

        if (depth % 2 == 0) {
            sort(next(points.begin(), l), next(points.begin(), r), less_x);
        } else {
            sort(next(points.begin(), l), next(points.begin(), r), less_y);
        }

        nodes[t].location = mid;
        nodes[t].l = make_tree(l, mid, depth + 1);
        nodes[t].r = make_tree(mid + 1, r, depth + 1);

        return t;
    }

    void find(int v, int sx, int tx, int sy, int ty, int depth, vector<Point>& ans) {
        int x = points[nodes[v].location].x;
        int y = points[nodes[v].location].y;

        if (sx <= x && x <= tx && sy <= y && y <= ty) { ans.push_back(points[nodes[v].location]); }
        if (depth % 2 == 0) {
            if (nodes[v].l != -1 && sx <= x) { find(nodes[v].l, sx, tx, sy, ty, depth + 1, ans); }
            if (nodes[v].r != -1 && x <= tx) { find(nodes[v].r, sx, tx, sy, ty, depth + 1, ans); }
        } else {
            if (nodes[v].l != -1 && sy <= y) { find(nodes[v].l, sx, tx, sy, ty, depth + 1, ans); }
            if (nodes[v].r != -1 && y <= ty) { find(nodes[v].r, sx, tx, sy, ty, depth + 1, ans); }
        }
    }
};

void print(vector<Point>& ans) {
    sort(ans.begin(), ans.end());
    for (auto p : ans) { printf("%d\n", p.id); }
    printf("\n");
}

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

    int n;
    scanf("%d", &n);

    vector<Point> points(n);
    rep(i, 0, n) {
        points[i].id = i;
        scanf("%d %d", &(points[i].x), &(points[i].y));
    }

    KdTree tree(points);
    int q;
    scanf("%d", &q);
    rep(i, 0, q) {
        int sx, tx, sy, ty;
        scanf("%d %d %d %d", &sx, &tx, &sy, &ty);
        vector<Point> ans;
        tree.find(0, sx, tx, sy, ty, 0, ans);
        print(ans);
    }

    return 0;
}


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


#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T, class T2> void amin(T& a,T2 b){ if(a > b) a = b;}

int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n;;
	string s;
	cin >>n >>s;

	int fc=0, tc=0;
	for(auto z: s){
		if(z=='(') fc++;
		else{
			if(fc>0) fc--; else tc++;
		}
	}
	cout<< string(tc, '(') + s + string(fc, ')') <<"\n";
	return 0;
}


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

long long count;
long long pCnt;
int N;
long long X;
long long ansP[51] = { 1 };
long long ansC[51] = { 1 };

void b()
{
	count++;

	if (count >= X) {
		printf("%lld\n", pCnt);
		exit(0);
	}
}

void p()
{
	count++;
	pCnt++;

	if (count >= X) {
		printf("%lld\n", pCnt);
		exit(0);
	}
}

void barger(int level)
{
	if (X - count > ansC[level]) {
		count += ansC[level];
		pCnt += ansP[level];
		return;
	}
	if (level == 0) {
		p();
		return;
	}
	b();
	barger(level - 1);
	p();
	barger(level - 1);
	b();
	return;
}

int main() {

	for (int i = 1; i < 51; i++) {
		ansP[i] = 2 * ansP[i - 1] + 1;
		ansC[i] = 2 * ansC[i - 1] + 3;
	}

	scanf("%d %lld", &N, &X);

	barger(N);

	printf("%lld\n", pCnt);
	return 0;
}


Measured memory_bytes: 128
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def com(com_n, com_r):
    return fac[com_n] * inv[com_r] * inv[com_n - com_r] % md
def way(h, w):
    if h < 0 or w < 0:
        return 0
    else:
        return com(h + w, h)

# combinationの準備
# md>n_maxの条件
md = 10 ** 9 + 7
n_max = 200005
fac = [1]
inv = [1] * (n_max + 1)
k_fac_inv = 1
for i in range(1, n_max + 1):
    k_fac_inv = k_fac_inv * i % md
    fac.append(k_fac_inv)
k_fac_inv = pow(k_fac_inv, md - 2, md)
for i in range(n_max, 1, -1):
    inv[i] = k_fac_inv
    k_fac_inv = k_fac_inv * i % md

def main():
    h, w, n = MI()
    rc = [LI1() for _ in range(n)]
    # i番目の壁まで無傷で来る方法の数
    # (全ルート)－(i-1までの壁にぶつかる分)
    rc.sort(key=lambda x: x[0] + x[1])
    dp = [0] * n
    for i, (r, c) in enumerate(rc):
        dp[i] = way(r, c) - sum(v * way(r - pr, c - pc) % md for v, (pr, pc) in zip(dp[:i], rc[:i]))
        dp[i] %= md
    h, w = h - 1, w - 1
    ans = way(h, w) - sum(v * way(h - r, w - c) % md for v, (r, c) in zip(dp, rc))
    print(ans % md)

main()


Measured memory_bytes: 55768
#include <bits/stdc++.h>
#include <iostream>
typedef long long ll;
using namespace std;
int main()
{
    
    int a,b,c,d,e,i;
    cin >> a;
    cin >> b;
    cin >> c;
    cin >> d;
    cin >> e;
    vector<int>z{a,b,c,d,e};
    vector<int> v;
    int x = 10;
    for (i = 0;i<=4;i++)
        if (z[i] % 10 != 0)
            x = min(x,z[i] % 10);

    int ans = -(10 - x);    
    for (i = 0; i<=4; i++)
        if (z[i] % 10 != 0)
            ans += z[i] + 10 - z[i] % 10;
        else
            ans += z[i];
        

    cout << ans;

    
}


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

struct edge{
  int to, cost;
};

int main(int argc, char *argv[]){
  int n, m, r;
  cin >> n >> m >> r;
  vector<vector<edge> > g(n);
  int from;
  for (int i = 0; i < m; i++) {
    edge e;
    cin >> from >> e.to >> e.cost;
    g[from].push_back(e);
  }
  int dp[n];
  for (int i = 0; i < n; i++) {
    dp[i] = 1e9;
  }
  dp[r] = 0;
  //???????????§?????????
  //????????????????????????????????????
  bool update = true;
  int cnt = 0;
  while(update){
    if(cnt > n)break;
    cnt++;
    update = false;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < g[i].size(); j++) {
        edge e = g[i][j];
        if(dp[e.to] > dp[i] + e.cost){
          dp[e.to] = dp[i] + e.cost;
          update = true;
        }
      }
    }
  }
  if(cnt > n){
    std::cout << "NEGATIVE CYCLE" << std::endl;
  }else{
    for (int i = 0; i < n; i++) {
      if(dp[i] == 1e9)std::cout << "INF" << std::endl;
      else std::cout << dp[i] << std::endl;
    }
  }
  return 0;
}

Measured memory_bytes: 10248
#include <math.h>

#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define PI 3.14159265358979323846264338327950L
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define SIZE_OF_ARRAY(array) (sizeof(array) / sizeof(array[0]))

int main() {
  int A, B;

  cin >> A >> B;

  int num = 1100;
  bool ans = false;
  int ans_num = 0;

  rep(i, num) {
    if ((i * 8 / 100 == A) && (i / 10 == B)) {
      ans = true;
      ans_num = i;
      break;
    }
  }

  if (ans == true)
    cout << ans_num << endl;
  else
    cout << -1 << endl;
}


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

int main(){
  int A,B,C;
  cin>>A>>B>>C;
  int tmp1=10*A+B+C;
  int tmp2=10*B+A+C;
  int ans =max(tmp1,tmp2);
  int tmp3=10*C+A+B;
  ans =max(ans,tmp3);
  cout<<ans<<endl;
  return 0;
}


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

int main(){
    int i=0;
    int j=0;
    int a=0;
    int b=0;
    int c=0;
    int d=0;
    int e=0;
    int f=0;
    int g=0;
    int mojiretu=0;
    char array[101];
    char array2[101];
    int tori=0;
    char key[8];
    key[0]='k';
    key[1]='e';
    key[2]='y';
    key[3]='e';
    key[4]='n';
    key[5]='c';
    key[6]='e';
    key[7]='\0';
    //printf(key);
    scanf("%s",array);
    for(i=0; array[i]!='\0'; i++){
        mojiretu++;        
    }
    //printf("%d",mojiretu);
    //printf("%d\n",tori);
    //printf(array);
    //printf(key);
    if(mojiretu==7){
        if(strcmp(array,key)==0){
            
            printf("YES\n");
        }
        else{
            printf("NO\n");
        }
    }
    else{

        //printf(array2);
        for(i=0; i<=7; i++){
            for(j=0;j<=mojiretu;j++){
                array2[j]=array[j];
            } 
            //printf("%d\n",i);
            //(i==0){
            //    for(j=7;j<=mojiretu-1;j++){
            //        array2[j] = 'a';
            //    }
            //}
            for(j=i;j<=mojiretu-8+i;j++){
                array2[j]='a';
            }
            //printf(array2);
            //printf("\n");
            for(j=0; j<=mojiretu-1;j++){
                //printf("%c",array2[j]);
                if(array2[j]=='k'){
                    a++;
                }
                if(array2[j]=='e' && a==1 && b==0){
                    b++;
                }
                if(array2[j]=='y'&&b==1&&c==0){
                    c++;
                }
                if(array2[j]=='e'&&c==1&&d==0){
                    d++;
                }
                if(array2[j]=='n'&&d==1&&e==0){
                    e++;
                }
                if(array2[j]=='c'&&e==1&&f==0){
                    f++;
                }
                if(array2[j]=='e'&&f==1&&g==0){
                    g++;
                }
            }

            if(g==0){
                a=0;
                b=0;
                c=0;
                d=0;
                e=0;
                f=0;
            
                             
            }

        
        }
        if(g>0){
            printf("YES\n");
        }
        else{
            printf("NO\n");
        }
    }
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e9+7;
int mod = 998244353;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main() {
    int N;
    cin >> N;
    cout << 0 << endl;
    string S;
    cin >> S;
    if(S == "Vacant") {
        return 0;
    }
    int l = 0,r = N;
    while(true) {
        int mid = (l+r)/2;
        cout << mid << endl;
        string T;
        cin >> T;
        if(T == "Vacant") {
            return 0;
        }
        if(mid%2 == 0) {
            if(S == T) {
                l = mid;
            }
            else {
                r = mid;
            }
        }
        else {
            if(S != T) {
                l = mid;
            }
            else {
                r = mid;
            }
        }
    }
}


Measured memory_bytes: 3804
package main

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

func main() {
	stdin := bufio.NewScanner(os.Stdin)

	for stdin.Scan() {
		n, _ := strconv.Atoi(stdin.Text())
		if n == 0 {
			break
		}
		sales := make(map[string]int)
		existed := make(map[string]bool)
		order := make([]string, 4000)
		flg := false
		for i := 0; i < n; i++ {
			stdin.Scan()
			l := strings.Split(stdin.Text(), " ")
			e := l[0]
			p, _ := strconv.Atoi(l[1])
			q, _ := strconv.Atoi(l[2])
			sales[e] += p * q
			if !existed[e] {
				order = append(order, e)
				existed[e] = true
			}
		}
		for _, v := range order {
			if sales[v] >= 1000000 {
				fmt.Println(v)
				flg = true
			}
		}
		if flg == false {
			fmt.Println("NA")
		}
	}
}



Measured memory_bytes: 2148
N,H=list(map(int,input().split()))
sword=[list(map(int,input().split())) for i in range(N)]
through=[i[1] for i in sword]
through.sort(reverse=True)
max_atk=max([i[0] for i in sword])
ans=0
for i in through:
   ans+=1
   if i > max_atk:
      H-=i
   else:
      H-=max_atk
   if H <= 0:
      break
import math
if 0 < H:
   ans+=math.ceil(H/max_atk)
print(ans)

Measured memory_bytes: 29148
#include <iostream>

using namespace std;

int main() {
  int x, y;
  while (1) {
    cin>>x>>y;
    if (x == 0 && y == 0) { break; }
    if (y < x) {
      cout<<y<<" "<<x<<endl;
    } else {
      cout<<x<<" "<<y<<endl;
    }
  }

  return 0;
}



Measured memory_bytes: 3048
fun main(args: Array<String>) {
    a65(readLineList())
}

fun readLineList(): Array<String> {
    val lineList = mutableListOf<String>()
    while (true) {
        val line = readLine()
        if (line.isNullOrBlank()) {
            break
        } else {
            lineList.add(line!!)
        }
    }
    return lineList.toTypedArray()
}

fun a65(args: Array<String>) {
    if (args.size != 1) {
        throw IllegalArgumentException()
    }
    val (x, tillExpire, days) = args[0].split(" ").map { it.toInt() }
    println(when {
        tillExpire - days >= 0 -> "delicious"
        days - tillExpire <= x -> "safe"
        else -> "dangerous"
    })
}

Measured memory_bytes: 37960
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp(a, b) make_pair(a, b)
#define ls (rt << 1)
#define rs (rt << 1 | 1) 
typedef pair<int, int> pii; 
const ll mod = 1e9 + 7;
template <class T> T lowbit(T x){return ((x)&(-(x)));}
const int maxn = 2e5 + 10;
int a, b;
int main()
{
	cin >> a >> b;
	for(int i = 1; i <= 2000; ++i)
		if(int(i * 0.08) == a && int(i * 0.1) == b)
		{
			printf("%d\n", i);
			return 0;
		}
	puts("-1");
	return 0;
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define BIT(X, i) ((X>>i)&1)

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pii;
typedef vector<pii> vii;
typedef priority_queue<ll> pq;

const int MOD = 1e9+7;
const int INF = (1<<30);
const ll INFL = (1L<<62);

int N, Q;
string s;
vector<char> t, d;

int main() {
  int ans = 0;
  cin >> N >> Q >> s;
  t.resize(Q); d.resize(Q);
  for (int i = 0; i < Q; i++) {
    cin >> t[i] >> d[i];
  }
  s = "_" + s + "_";

  int l = 0, r = N+1;
  while (l < r - 1) {
    int mid = (l + r)/2;
    int pos = mid;
    bool exist = true;
    for (int i = 0; i < Q; i++) {
      if (s[pos] == t[i]) {
        if (d[i] == 'L') pos--;
        else pos++;
      }
      if (pos == 0) exist = false;
      if (s[pos] == '_') break;
    }
    if (exist) r = mid;
    else l = mid;
  }
  ans -= r;
  l = 0, r = N+1;
  while (l < r - 1) {
    int mid = (l + r)/2;
    int pos = mid;
    bool exist = true;
    for (int i = 0; i < Q; i++) {
      if (s[pos] == t[i]) {
        if (d[i] == 'L') pos--;
        else pos++;
      }
      if (pos == N+1) exist = false;
      if (s[pos] == '_') break;
    }
    if (exist) l = mid;
    else r = mid;
  }
  ans += l;
  ans = max(0, ans+1);

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1156
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1LL << 30;
int MOD = 1e9+7;
main(){
    string S;
    cin >> S;
    for(int i = 1;i < S.length();i++){
        if(S[i] == S[i-1]){
            cout << i << " " << i+1 << endl;
            return 0;
        }
    }
    for(int i = 2;i < S.length();i++){
        if(S[i] == S[i-2]){
            cout << i-1 << " " << i+1 << endl;
            return 0;
        }
    }
    cout << -1 << " " << -1 << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef complex<double> P;
typedef pair<double,double> P1;
const double EPS = 1e-10;
typedef pair<P,P> L;
int n;


//kaitenn
P rotate(P p, double rad){
  double x = real(p) * cos(rad) - imag(p) * sin(rad);
  double y = real(p) * sin(rad) + imag(p) * cos(rad);
  return P(x,y);
}
 
//???
struct Circle{
  P c; //?????????
  double r; //??????
  Circle(P c=P(0,0), double r=0):c(c),r(r){}
};
Circle c[2][51];
 
L getIntangent(Circle a,Circle b,double f=1.0){
  P base=b.c-a.c;
  double w=a.r+b.r;
  double h=sqrt(max(0.0,norm(base)-w*w));
  P k=base*P(w,h*f)/norm(base);
  return L(a.c+k*a.r,b.c-k*b.r);
}
 
L getOuttangent(Circle a,Circle b,double f=1.0){
  P base=b.c-a.c;
  double h=b.r-a.r;
  double w=sqrt(max(0.0,norm(base)-h*h));
  P k=base*P(w,h*f)/norm(base)*P(0,f);
  return L(a.c+k*a.r,b.c+k*b.r);
}
 
vector<L> tangentCC(Circle a,Circle b){
  double dis=abs(a.c-b.c),R=a.r+b.r;
  vector<L> res;
  if(dis>R+EPS)res.push_back(getIntangent(a,b));
  if(dis>R-EPS)res.push_back(getIntangent(a,b,-1));
  if(dis>abs(a.r-b.r)+EPS)res.push_back(getOuttangent(a,b));
  if(dis>abs(a.r-b.r)-EPS)res.push_back(getOuttangent(a,b,-1));
  return res;
}

int cal(P a,P b){
  int res=0;
  b-=a;
  for(int i=0;i<n;i++){
    P t=(c[0][i].c-a)*conj(b)/abs(b);
    if(c[0][i].r<=abs(t.imag())+EPS&&abs(t.imag())<=c[1][i].r+EPS)res++;
  }
  return res;
}
 
int main(){
  while(cin>>n,n){
    for(int i=0,a,b,r,m;i<n;i++){
      cin>>a>>b>>r>>m;
      c[0][i]=Circle(P(a,b),r);
      c[1][i]=Circle(P(a,b),r+m);
    }

    int ans=1;
    for(int i=0;i<n;i++)
      for(int j=i+1;j<n;j++){
	for(int k=0;k<4;k++){
	  vector <L> res=tangentCC(c[k&1][i],c[(k>>1)&1][j]);
	  for(int l=0;l<res.size();l++) ans=max(ans,cal(res[l].first,res[l].second));
	}
      }
    cout <<ans<<endl;
  }

  return 0;
}

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

int main(){
    int64_t x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    vector<int64_t> aka, midori, mushoku;
    for(int64_t i = 0; i < a; i++){
        int64_t tmp;
        cin >> tmp;
        aka.push_back(tmp);
    }
    for(int64_t i = 0; i < b; i++){
        int64_t tmp;
        cin >> tmp;
        midori.push_back(tmp);
    }
    for(int64_t i = 0; i < c; i++){
        int64_t tmp;
        cin >> tmp;
        mushoku.push_back(tmp);
    }
    sort(aka.begin(), aka.end());
    if(x < a){
        int64_t tmp = a - x;
        aka.erase(aka.begin(), aka.begin() + tmp);
    }
    sort(midori.begin(), midori.end());
    if(y < b){
        int64_t tmp = b - y;
        midori.erase(midori.begin(), midori.begin() + tmp);
    }
    aka.insert(aka.end(), midori.begin(), midori.end());
    aka.insert(aka.end(), mushoku.begin(), mushoku.end());
    sort(aka.begin(), aka.end());
    reverse(aka.begin(), aka.end());
    int64_t ans = 0;
    for(int64_t i = 0; i < x + y; i++){
        ans += aka[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 5476
//@author :  |< U $ |-|
#include<cmath>
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<deque>
#include<queue>
#include<algorithm>
#include<list>
#include<cstring>
#include<unordered_map>
#define ll long long
#define vi vector<long long>
#define pb push_back
#define po pop_back
#define pi pair<long long ,long long>
#define vp vector<pair<long long,long long> >
#define mkp make_pair
#define in(i,n) for(i=0;i<n;i++)
#define fon(i,n,m) for(i=n;i<m;i++)
#define rfon(i,n,m) for(i=n;i>=m;i--)
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define jaldi ios_base::sync_with_stdio(false);cin.tie(NULL);
#define map map<long long,long long>
#define inm1(b)  memset(b,-1,sizeof(b))
#define in0(b) memset(b,0,sizeof(b))
#define ininf(b) memset(b,1000000001,sizeof(b))
#define MOD         1000000007
#define I 1000000000000000001
#define TakeInput freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
using namespace std;
ll gcd(ll a, ll b) {  if (a == 0)  return b; return gcd(b % a, a); }
ll power(ll x, ll y)
{
    if (y == 0)
        return 1;
    else if (y % 2 == 0)
        return power(x, y / 2) * power(x, y / 2);
    else
        return x * power(x, y / 2) * power(x, y / 2);
}
int main()
{
    jaldi
    #ifndef ONLINE_JUDGE
    //TakeInput
    #endif
    ll n;
    cin>>n;
    ll count=0;
    while(n>0){
        n/=2;
        count++;
    }
    cout<<power(2,count)-1;
}








 




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 int ll;
const ll MOD = 1000000007;

int main() {
  int x, y;
  cin >> x >> y;
  cout << x + y / 2 << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#include <float.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = 0; i <= (n); i++)
using namespace std;
typedef long long ll;
 
const ll INF = 1LL<<62;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
const int MOD = 1000000007;

ll gcd(ll x, ll y){
    if (y==0) return x;
    else return gcd(y, x%y);
}

int main(){
    int N, K; cin >> N >> K;
    vector<int> A(N);
    rep(i,N) cin >> A[i];

    int g = A[0];
    for(int i = 1; i < N; i++){
        g = gcd(g,A[i]);
    }

    sort(A.rbegin(), A.rend());

    if (A[0] < K || K%g != 0){
        cout << "IMPOSSIBLE" << endl;
    }
    else{
        cout << "POSSIBLE" << endl;
    }
}

Measured memory_bytes: 3624
N = int(input())
F = ["".join(input().split()) for _ in range(N)]
P = [list(map(int,input().split())) for _ in range(N)]

Ans = -9999999999
for i in range(1 << 10):
    xx = bin(i)[2::].zfill(10)
    if xx == "0000000000":
        continue
    
    ans = 0
    for i in range(N):
        cnt = 0
        for j in range(10):
            if xx[j]=="1" and F[i][j]=="1":
                cnt += 1
        ans += P[i][cnt]

    Ans = max(Ans,ans)

print(Ans)



Measured memory_bytes: 3064
#include<stdio.h>
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using lb=long double;
using db=double;
const ll mod=1e9+7;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define INF 1e9+7
int n;
const long double pi=2*asin(1.0);
const int maxn = 2e5+2;
int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    int a[55];
    for(int i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }
    sort(a,a+n);
    int sum=0;
    for(int i=n-m;i<n;i++)
    {
        sum+=a[i];
    }
    cout<<sum<<endl;

    return 0;
}


Measured memory_bytes: 256
package main

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

func main() {
	_ = ReadInt()
	c := ReadString()

	cw := 0
	cr := 0
	for _, char := range []byte(c) {
		if char == 'W' {
			cw++
		} else {
			cr++
		}
	}
	tr := 0
	for _, char := range []byte(c[:cr]) {
		if char == 'R' {
			tr++
		}
	}
	fmt.Println(cr - tr)
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 3208
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < int(n); i++)
using namespace std;
 
int main() {
  int p,q,r,ABC,ACB,CAB;
  cin >> p >> q >> r;
  ABC = p + q;
  ACB = r + q;
  CAB = r + p;
  cout << min(min(ABC,ACB),CAB) << endl;

}

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

using namespace std;

int main()
{
	string S;
	cin >> S;
	if (S.at(0) == 'S')
		cout << "Cloudy" << endl;
	else if (S.at(0) == 'C')
		cout << "Rainy" << endl;
	else
		cout << "Sunny" << endl;

	return 0;
}

Measured memory_bytes: 256
# python 3.4.3
import sys
input = sys.stdin.readline

# -------------------------------------------------------------
# function
# -------------------------------------------------------------
N = 100010
primes = []
is_prime = [True]*N
for i in range(2,N):
    if is_prime[i]:
        primes.append(i)
        j = 2
        while i*j < N:
            is_prime[i*j] = False
            j += 1


# -------------------------------------------------------------
# main
# -------------------------------------------------------------

Q = int(input())
LR = [tuple(map(int,input().split())) for _ in range(Q)]

# 2017数の判定リストを作る
Ans = [0]*N
for p in primes:
    if p==2:
        continue
    # pは素数であるので、(p+1)//2が素数であれば 2017数
    if (p+1)//2 in primes:
        Ans[p] = 1

# 範囲計算なので累積和
for i in range(1,N):
    Ans[i] += Ans[i-1]

# クエリを処理
for l,r in LR:
    print(Ans[r] - Ans[l-1])



Measured memory_bytes: 21468
n,q=[int(i) for i in input().split()]
g={}
val=[0]*n
vis=[0]*n
for i in range(n-1):
  a,b=[int(i) for i in input().split()]
  if a-1 in g:g[a-1].append(b-1)
  else:g[a-1]=[b-1,]
for i in range(q):
  a,b=[int(i) for i in input().split()]
  val[a-1]+=b
stack=[]
stack.append(0)
vis[0]=1
while(len(stack)>0):
  p=stack.pop()
  if p in g:
    for i in g[p]:
      if vis[i]==0 :
        val[i]=val[i]+val[p]
        stack.append(i)
        vis[i]=1
for i in val:print(i,end=" ")
print(" ") 


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

int main(){
    ll n; cin >> n;
    ll a[n];
    for(ll i = 0; i < n; ++i) cin >> a[i];
    ll tate = 0;
    ll yoko = 0;
    sort(a, a + n);
    reverse(a, a + n);
    for(ll i = 0; i < n - 1; ++i){
        if(a[i] == a[i + 1]){
            if(!tate){
                tate = a[i];
            }else if(!yoko){
                yoko = a[i];
            }
            ++i;
        }
    }
    cout << tate * yoko << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double lld;
ll MOD = (1e9)+7;
const int dr[] = {+1, -1, +0, +0, +1, -1, +1, -1};
const int dc[] = {+0, +0, +1, -1, +1, -1, -1, +1};
const int kx[] = {+1, +2, -1, -2, +1, +2, -1, -2};
const int ky[] = {+2, +1, +2, +1, -2, -1, -2, -1};
//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")
inline void fastIO(){
  ios_base::sync_with_stdio(0);cin.tie(0);
}
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep; for (const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<typename T, size_t size> ostream& operator<<(ostream &os, const array<T, size> &arr) { os << '{'; string sep; for (const auto &x : arr) os << sep << x, sep = ", "; return os << '}'; }
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }

void debug_out() { cerr << endl; }
template<typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << ' ' << H; debug_out(T...); }

#ifdef LOCAL
#define debug(...) cerr << "(" << #__VA_ARGS__ << "):", debug_out(__VA_ARGS__)
#else
#define debug(...) 47
#endif

int main(){
  fastIO();
  cout<<fixed;
  long double n,x,val=1;
  bool greater=false,zero=false;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>x;
    val*=x;
    if(x==0)zero=true;
    if(val>1e18){
      val=1,greater=true;
    }
  }
  if(zero){
    cout<<0<<endl;
  }else if(greater){
    cout<<-1<<endl;
  }else{
    cout<<(ll)val<<endl;
  }
  return 0;
}


Measured memory_bytes: 3760
#include <stdio.h>
#include <stdbool.h>

int main() {
  int N=0,K=0;
  int d[101]={0};
  int A[101][101]={0};
  int count=0;
  bool flag[101]={false};

  scanf("%d %d",&N,&K);
  for(int i=1;i<=K;i++){
    scanf("%d",&d[i]);
    for(int j=1;j<=d[i];j++){
      scanf("%d",&A[i][j]);
      flag[A[i][j]]=true;
    }
  }
  for(int i=1;i<=N;i++){
    if(!flag[i]){
      count++;
    }
  }
  printf("%d\n",count);
  return 0;
}

Measured memory_bytes: 1772
using System;

class Program
{
    static void Main(string[] args)
    {
        var xy = Console.ReadLine().Split(' ');
        var x = long.Parse(xy[0]);
        var y = long.Parse(xy[1]);

        y /= x;
        var ans = 0;
        while (0 < y)
        {
            ans++;
            y /= 2;
        }

        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 13140
#include<iostream>
#include<cstdio>
#include<map>
#include<cmath>
#define ll long long
#define N 100100
#define MZ 400
using namespace std;

ll n,a[N],b[N],zs[N],zz,ans;
bool P[N];
map<ll,ll>cnt;
map<ll,bool>vis;

inline void get()
{
	ll i,j;
	for(i=2; i<=100000; i++)
	{
		if(!P[i]) zs[++zz]=i;
		for(j=1; j<=zz&&zs[j]*i<=100000; j++) P[zs[j]*i]=1;
	}
}

int main()
{
	ll i,j,k,p,q,t,tmp;
	get();
	cin>>n;
	for(i=1; i<=n; i++)
	{
		scanf("%lld",&a[i]);
	}
	for(i=1; i<=n; i++)
	{
		t=a[i];
		b[i]=q=1;
		for(j=1; j<=MZ&&t!=1; j++)
		{
			p=0;
			for(; t%zs[j]==0; t/=zs[j]) p++;
			p%=3;
			if(!p) continue;
			for(k=1; k<=p; k++) q*=zs[j];
			for(k=p+1; k<=3; k++) b[i]*=zs[j];
		}
		if(t)
		{
			tmp=sqrt(t);
			if(tmp*tmp==t)
			{
				q*=t;
				b[i]*=tmp;
			}
			else
			{
				q*=t;
				b[i]*=t*t;
			}
		}
		a[i]=q;
		cnt[a[i]]++;
	}
	for(i=1; i<=n; i++)
	{
		if(vis[a[i]] || vis[b[i]] || a[i]==1) continue;
		vis[a[i]]=1;
		ans+=max(cnt[a[i]],cnt[b[i]]);
	}
	cout<<ans+(!!cnt[1]);
}

Measured memory_bytes: 27008
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;

#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
typedef complex<double> P;
double dot(P a, P b){ //内積
    return (a.real() * b.real() + a.imag() * b.imag());
}

double cross(P a, P b){ //外積
    return (a.real() * b.imag() - a.imag() * b.real());
}

bool is_orth(P a1, P a2, P b1, P b2){ //垂直か
    return EQ(dot(a1 - a2, b1 - b2), 0.0);
}

bool is_para(P a1, P a2, P b1, P b2){ //平行か
    return EQ(cross(a1 - a2, b1 - b2), 0.0);
}

bool is_online(P a, P b, P c){ //cが線分上か
    return (abs(a-c) + abs(c-b) < abs(a-b) + EPS);
}

bool distance_lp(P a, P b, P c){ //直線abと点cの距離
    return abs(cross(b-a, c-a)) / abs(b-a);
}

double norm(P a){
  return a.real() * a.real() +a.imag() *a.imag();
}

ll ccw(P p0,P p1,P p2){
  P a = p1-p0;
  P b = p2-p0;
  if(cross(a,b) > EPS) return 1;
  if(cross(a,b) < -EPS) return -1;
  if(dot(a,b) < -EPS) return 2;
  if(abs(a) < abs(b)) return -2;
  return 0;
}

bool is_intersect(P p1, P p2, P p3, P p4){
  return (ccw(p1,p2,p3) * ccw(p1,p2,p4) <= 0 &&
      ccw(p3,p4,p1) * ccw(p3,p4,p2) <= 0 );
}

P intersect_pos(P a1, P a2, P b1, P b2){ //直線同士の交点
    P a = a2 - a1;
    P b = b2 - b1;
    return a1 + a * cross(b, b1 - a1) / cross(b, a);
}

#define printP(P) cout << "(" << P.real() << ", " << P.imag() << ")" << endl;




int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll q;
    cin >> q;
    while(q--){
        double x0, y0, x1, y1, x2, y2, x3, y3;
        cin >> x0 >> y0 >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
        P p0(x0,y0), p1(x1, y1), p2(x2, y2), p3(x3, y3);
        P res = intersect_pos(p0, p1, p2, p3);
        cout << setprecision(16) << res.real() << " " << res.imag() << endl;

    }
}


Measured memory_bytes: 3312
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <memory>
#include <algorithm>

#ifndef JHELPER1_COMMON_H
#define JHELPER1_COMMON_H





#include <sstream>



typedef long long ll;
using namespace std;

constexpr ll MOD = 1000 * 1000 * 1000 + 7;

// Returns x^y modulo MOD. O(log2(y)).
ll modPow(ll x, ll y) {
  ll res = 1, a = x;
  while (y > 0) {
    if ((y & 1) > 0) {
      res = (res * a) % MOD;
    }
    a = (a * a) % MOD;
    y >>= 1;
  }
  return res;
}

// Returns a^-1 module MOD.
ll inverse(ll a) {
  /*
   * Fermat's little theorem
   * http://en.wikipedia.org/wiki/Proofs_of_Fermat's_little_theorem
   *
   * <pre>
   * a^p = a (mod p)
   * a^(p-1) = 1 (mod p)
   * ..
   * 1/a = a^(p-2) (mod p)
   * </pre>
   */
  return modPow(a, MOD - 2);
}

#endif //JHELPER1_COMMON_H


class CTsundoku {
public:
  void solve(std::istream &in, std::ostream &out) {
    ll N, M, K;
    in >> N >> M >> K;
    ll A[N];
    ll B[M];
    ll tot = 0;
    ll ai = -1;
    for (int i = 0; i < N; ++i) {
      in >> A[i];
      tot += A[i];
      A[i] = tot;
      if (tot <= K) ai++;
    }
    tot = 0;
    for (int i = 0; i < M; ++i) {
      in >> B[i];
      tot += B[i];
      B[i] = tot;
    }

    ll bi = -1;
    ll ma = 0;
    while(ai >= -1) {
      ll av = ai == -1 ? 0: A[ai];
      while (bi + 1 < M && av + B[bi + 1] <= K) {
        bi++;
      }
      ma = max(ma, ai + bi + 2);
      ai--;
    }
    out << ma << endl;
  }
};


int main() {
	CTsundoku solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 6240
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);    
    int n;
    cin>>n;
    int h[n];
    int c=0;
    int ans=0;
    int hnow=0;

    for(int i=0;i<n;i++){
    cin>>h[i];
    if(h[i]<=hnow){
        hnow=h[i];
        c++;

    }else{
        c=0;
        hnow=h[i];
    }
    if(c>ans){
        ans=c;
    }
    }
cout<<ans;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int a[n],ans=0-n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		ans+=a[i];
	}
	cout<<ans;
	return 0;
} 

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let month = read::<String>().split("/").collect::<Vec<&str>>()[1]
        .parse::<i32>()
        .unwrap();
    println!("{}", if month <= 4 { "Heisei" } else { "TBD" });
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define int long long
#define double long double
#define all(a) a.begin(), a.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;

//ABC137
signed main(void){

    int k, x; cin >> k >> x;
    bool first = false;
    for(int i = x - k + 1; i <= x + k - 1; i++){
        if(first)cout << ' ';
        cout << i;
        first = true;
    }

}

Measured memory_bytes: 256