akhauriyash/Code-Regression huggingface dataset:
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int l = sc.nextInt();
		int taste[] = new int[n];
		int minTaste = l + 1;
		for(int i = 0 ; i < n ; i++) {
			taste[i] = l + i;
			if(Math.abs(minTaste) > Math.abs(taste[i])) {
				minTaste = taste[i];
			}
		}
		int sum = Arrays.stream(taste).sum();
		System.out.println(sum - minTaste);

		sc.close();

	}

}


Measured memory_bytes: 28500
#include <stdio.h>

int A[1000000], n;

/* 二分探索 */
int binarySearch(int key) {
  int left = 0;
  int right = n;
  int mid;
  while(left < right) {
    mid = (left + right) / 2;
    if(key == A[mid]) return 1; /* keyを発見 */
    if(key > A[mid]) left = mid + 1; /* 後半を探索 */
    else if(key < A[mid]) right = mid; /* 前半を探索 */
  }
  return 0;
}

int main(void) {
  int i, q, k, sum = 0;
  scanf("%d",&n);
  for(i=0; i<n; i++) {
    scanf("%d",&A[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++) {
    scanf("%d",&k);
    if(binarySearch(k))
      sum++;
  }
  printf("%d\n",sum);
  return 0;
}



Measured memory_bytes: 2192
#include <iostream>
#include <iomanip>

using namespace std;

int main()
{
  int N, t;
  int x, h;
  double tan_max = 0.0;
  double tan;
  double Height;
  
  cin >> N >> t;
  while (N--) {
    cin >> x >> h;
    tan = (double)h / x;
    if (tan >= tan_max) tan_max = tan;
  }
  Height = tan_max * t;

  cout << fixed << setprecision(6) <<  Height << endl;
}



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

ll sum[2][101010];
int dx[3]={0,-1,0},dy[3]={0,0,-1};

int main(){
  int N; cin>>N;
  vector<int> L(N),R(N);
  rep(i,N) cin>>L[i]>>R[i];
  sort(L.rbegin(),L.rend());
  sort(R.begin(),R.end());
  rep(i,N){
    sum[0][i+1]=sum[0][i]+L[i];
    sum[1][i+1]=sum[1][i]+R[i];
  }
  ll ans=0;
  for(int k=1;k<=N;k++){
    rep(i,3) ans=max(ans,2*(sum[0][k+dx[i]]-sum[1][k+dy[i]]));
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;
typedef tuple<ll, ll, ll> T;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

ll factorial(ll a){
    ll sum=1;
    for(int i=a;i>1;i--){
        sum *= i;
        sum %= MOD;
    }
    return sum;
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,m;
    cin>>n>>m;
    if(abs(n-m)>=2) cout<<0<<endl;
    else if(abs(n-m)==1) cout<<(factorial(n)*factorial(m))%MOD<<endl;
    else cout<<(2*factorial(n)*factorial(m))%MOD<<endl;
}

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

#define REP(i,m,n) for(int i=(m); i<(int)(n); i++)
#define RREP(i,m,n) for(int i=(int)(n-1); i>=m; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define fi first
#define se second
#define debug(...) {cerr<<"[L"<<__LINE__<<"] "; _debug(__VA_ARGS__);}

template<typename T>
string join(const vector<T>&v, string del=", "){ stringstream s;
    for(auto x : v) s << del << x; return s.str().substr(del.size());
}
template<typename T>
ostream& operator<<(ostream& o, const vector<T>&v){
    if(v.size()) o << "[" << join(v) << "]"; return o;
}
template<typename T>
ostream& operator<<(ostream& o, const vector<vector<T> >&vv){
    int l = vv.size();
    if(l){ o<<endl; rep(i,l) o << (i==0 ? "[ " : ",\n  " ) << vv[i] << (i==l-1 ? " ]" : ""); }
    return o;
}
inline void _debug(){cerr<<endl;}
template<class First, class... Rest>
void _debug(const First& first, const Rest&... rest){cerr<<first<<" ";_debug(rest...);}

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

const double PI = (1*acos(0.0));
const double EPS = 1e-9;
const int INF = 0x3f3f3f3f;
const ll INFL = 0x3f3f3f3f3f3f3f3fLL;
const ll mod = 1e9 + 7;

inline void finput(string filename) {
    freopen(filename.c_str(), "r", stdin);
}

int main(){
    ios_base::sync_with_stdio(0);
    // finput("./input");
    ll n; cin >> n;
    ll a = 1;
    set<ll> ans;
    while((n-1) >= a*a){
        if((n-1) % a == 0){
            ans.insert(a);
            ans.insert((n-1)/a);
        }
        a++;
    }

    a = 1;
    vl primes;
    while(n >= a*a){
        if(n % a == 0){
            primes.push_back(a);
            primes.push_back(n/a);
        }
        a++;
    }
    for(auto k : primes){
        if(ans.count(k)) continue;
        ll x = n;
        while(x % k == 0) x /= k;
        if(x % k == 1){
            ans.insert(k);
        }
    }
    cout << ans.size() - 1 << endl;
    return 0;
}

Measured memory_bytes: 3608
import java.util.*;
import java.io.PrintWriter;
public class Main {
	
	static PrintWriter out;
	static Scanner sc;
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		sc=new Scanner(System.in);
		out=new PrintWriter(System.out);
		
		int n=sc.nextInt();
		int k=sc.nextInt();
		int a[]=new int[n];
		for(int i=0;i<n;i++) {
			a[i]=sc.nextInt();
		}
		long ans=0,l=1,r=(long)(1e18);
		while(l<=r) {
			long mid=(l+(r-l)/2);
			//out.println(l+" "+r+" "+mid+" "+ok(mid,a,k));
			if(ok(mid,a,k)) {
				ans=mid;
				r=mid-1;
			}
			else {
				l=mid+1;
			}
		}
		out.print(ans);
		
		sc.close();
		out.close();
		
	}
	static boolean ok(long mid,int a[],int k) {
		for(int i=0;i<a.length;i++) {
			if(k+(a[i]%mid==0?1:0)>=(a[i])/mid) {
				k-=(a[i])/mid;
				if(a[i]%mid==0)k++;
			}
			else return false;
		}
		return true;
	}
}


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

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

/*-------------------------------------------*/

int main(){
    int x;
    cin>>x;
    cout<<3*x*x<<endl;
}

Measured memory_bytes: 256
N = int(input())
import math

prime=[]
for n in range(2,55556):
    for i in range(2,math.floor(math.sqrt(n))+1):
        if n % i == 0:
            break
    else:
        if n % 5 == 1:
            prime.append(n)
#print(prime)
#print(len(prime))
print(' '.join(list(map(str, prime[:N]))))


Measured memory_bytes: 45416
#include <bits/stdc++.h>
using namespace std;
vector <int> v;
int main(){
	int a;
  	cin >> a;
	for(int i = 1; i < 10; i++)
      for(int j = 1; j < 10; j++)
        if(i*j == a){
          cout << "Yes";
          return 0;
        }
	cout <<"No";
 
	return 0;
}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>0;(i)--)
#define rrep(i,n,m) for(int (i)=(n);(i)<(m);(i)++)
#define rrepr(i,n,m) for(int (i)=(n);(i)>(m);(i)--)
#define SORT(s) sort((s).begin(),(s).end())
#define SORTR(s,t) sort((s).begin(),(s).end(),greater<t>())

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<vector<int>> vvi;

const int INF = 1000000000;
const ll LINF = 1000000000000000000ll;
const double PI = acos(-1.0);
const double EPS = 1e-10;

const ll MOD = 1000000007ll;
const int MAX=510000;

ll A,B; vll G;
void input(){
    cin>>A>>B;
    return;
}

ll gcd(ll a,ll b){
    if(a<b) {ll tmp=a; a=b; b=tmp;}
    ll c=a%b;
    if(c==0) return b;
    else return gcd(b,c);
}

bool is_prime(ll a){
    bool ans=true;
    // rrep(i,2,(int)sqrt(a)+1){
    for(ll i=2; i<=sqrt(a); ++i){
        if(a%i==0){
            ans=false;
            break;
        }
    }
    return ans;
}

ll count_prime(ll a){
    ll rtn=0;
    if(a==1) return 1ll;
    for(ll i=1; i*i<=a; i++){
        if(a%i==0){
            G.emplace_back(i);
            G.emplace_back(a/i);
        }
    }
    for(auto g: G){
        // cout<<g<<" ";
        if(is_prime(g)) ++rtn;
    }
    // cout<<"\n";
    return rtn;
}

void solve(){
    ll g=gcd(A,B);
    cout<<count_prime(g)<<endl;
    return;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    solve();
    return 0;
}

Measured memory_bytes: 384
<?php
        $n = trim(fgets(STDIN));
        $k = trim(fgets(STDIN));
        $x = trim(fgets(STDIN));
        $y = trim(fgets(STDIN));
        if($n>$k){
            echo $k*$x + ($n-$k)*$y;
        } else {
            echo $n*$x;
        }
?>  


Measured memory_bytes: 3452
n,a,b,k=map(int,input().split())
mod1,mod2=10**9+7,998244353
mod=mod2
fact=[1]*(n+1)
inv=[1]*(n+1)
for i in range(2,n+1):
    fact[i]=i*fact[i-1]%mod
inv[-1]=pow(fact[-1],mod-2,mod)
for i in range(n,1,-1):
    inv[i-1]=inv[i]*i%mod
def comb(x,y):return fact[x]*inv[y]%mod*inv[x-y]%mod if x>=y>=0 else 0
ans=0
for i in range(n+1):
    if (k-(a*i))%b:continue
    o=(k-(a*i))//b
    ans=(ans+comb(n,i)*comb(n,o)%mod)%mod
print(ans)

Measured memory_bytes: 85200
# coding: UTF-8
import sys
#sys.setrecursionlimit(n)
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

n = int(input())
a = list(map(int, input().split()))

count = 0
s = 0
b = []
for i in range(n):
    count += 1 if a[i] < 0 else 0
    b.append(abs(a[i]))
flg = False
if count % 2 == 1:
    flg = True
ans = sum(b)
if flg:
    ans -= min(b) * 2
print(ans)

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair

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

const int inf = 1e9;
const ll linf = 1e18;
const ll mod = 1e9 + 7;

ll power(ll a, ll b)
{
   if(b == 1) return a; 

   return (power(a*a%mod, b/2) * (b%2 ? a : 1)) % mod;
}

int main()
{
  int h, w, a, b;
  cin >> h >> w >> a >> b;

  ll fac[300000], inv[100000], finv[100000];
  fac[0] = inv[0] = finv[0] = 1;
  rep(i, 3e5-1) fac[i+1] = fac[i]*(i+1)%mod;
  rep(i, 1e5) inv[i] = power(i, mod-2);
  rep(i, 1e5-1) finv[i+1] = finv[i] * inv[i+1] % mod;

  ll ans = 0;
  rep(i, h-a){
    ll cnt = 1;

    cnt *= fac[i+b-1];
    cnt %= mod;

    cnt *= finv[i];
    cnt %= mod;

    cnt *= finv[b-1];
    cnt %= mod;

    cnt *= fac[h-i-1+w-b-1];
    cnt %= mod;

    cnt *= finv[h-i-1];
    cnt %= mod;

    cnt *= finv[w-b-1];
    cnt %= mod;

    ans += cnt;
    ans %= mod;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4224
fn read_stdin() -> String {
    use std::io::Read;
    let mut input = String::new();
    std::io::stdin().read_to_string(&mut input).unwrap();
    input
}

fn scan<'a, I: Iterator<Item = &'a str>, T: std::str::FromStr>(tokens: &mut I) -> T {
    tokens.next().unwrap().parse().ok().unwrap()
}

fn main() {
    let input = read_stdin();
    let tokens = &mut input.split_whitespace();
    let n: usize = scan(tokens);
    let mut rev = vec![0; n];
    for i in 1..n + 1 {
        let ai: usize = scan(tokens);
        rev[ai - 1] = i;
    }
    for i in 0..n {
        if i > 0 {
            print!(" ");
        }
        print!("{}", rev[i]);
    }
    println!("");
}


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;
typedef vector<vector<int>> VVi;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e18+18;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

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

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<std::setprecision(10);

    ll n;
    cin>>n;
    Vec a(n);
    rep(i,n)cin>>a[i];
    double avg = 0.00000;
    rep(i,n){
        avg += a[i];
    }
    avg /= n;
    ll ans=0;
    double tmp = INF;
    rep(i,n){
        if(chmin(tmp,abs(avg-a[i]))){
            ans = i;
        }
    }
    cout<<ans<<endl;
    return  0;
}


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

using namespace std;
inline int read() {
    int x = 0;
    bool f = 1;
    char c = getchar();
    for (; !isdigit(c); c = getchar()) if (c == '-') f = 0;
    for (; isdigit(c); c = getchar()) x = (x << 3) + (x << 1) + c - '0';
    if (f) return x;
    return 0 - x;
}
typedef long long ll;
const int maxn = 100010;
const int inf = 0x3f3f3f3f;
const ll mod = 1000000000 + 7;


int main() {
    int h, n, x, sum = 0;
    cin >> h >> n;
    for (int i = 1; i <= n; i++) {
        cin >> x;
        sum += x;
    }
    if (sum >= h) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <tuple>
#include <algorithm>
#include <string>
using namespace std;

vector<tuple<long long, long long, string>>vec;
string V; int N; long long fact[15];

void dfs(int pos, long long sum, long long prod, string S) {
	if (pos == N) {
		vec.push_back(make_tuple(sum, prod, S));
		return;
	}
	int v = 0; if (S.size() >= 1) v = (S[S.size() - 1] - '0');

	for (int i = v; i < 10; i++) {
		string SS = S; SS += ('0' + i);
		dfs(pos + 1, sum + i, prod * (i + 1), SS);
	}
}

long long anagram(string A1, string A2) {
	int t[10]; for (int i = 0; i < 10; i++) t[i] = 0;
	for (int i = 0; i < A1.size(); i++) t[A1[i] - '0']++;

	long long rem = 0;
	for (int i = 0; i < A2.size(); i++) {
		for (int j = 0; j < (A2[i] - '0'); j++) {
			if (t[j] == 0) continue;
			t[j]--;
			long long D = fact[N - 1 - i];
			for (int k = 0; k < 10; k++) D /= fact[t[k]];
			t[j]++;
			rem += D;
		}
		t[A2[i] - '0']--;
		if (t[A2[i] - '0'] == -1) return rem;
	}
	return rem + 1;
}

long long anagram2(string A1) {
	int t[10]; for (int i = 0; i < 10; i++) t[i] = 0;
	for (int i = 0; i < A1.size(); i++) t[A1[i] - '0']++;

	long long r = fact[N];
	for (int i = 0; i < 10; i++) r /= fact[t[i]];
	return r;
}

int main() {
	fact[0] = 1; for (int i = 1; i <= 14; i++) fact[i] = 1LL * fact[i - 1] * i;
	cin >> V; N = V.size();
	dfs(0, 0, 1, "");
	sort(vec.begin(), vec.end());

	tuple<long long, long long, string>W;
	long long s1 = 0, s2 = 1; for (int i = 0; i < V.size(); i++) { s1 += (V[i] - '0'); s2 *= (long long)(V[i] - '0' + 1); }
	W = make_tuple(s1, s2, V); sort(get<2>(W).begin(), get<2>(W).end());

	long long ans = 0;
	for (int i = 0; i < vec.size(); i++) {
		if (make_pair(get<0>(vec[i]), get<1>(vec[i])) < make_pair(get<0>(W), get<1>(W))) {
			string D = get<2>(vec[i]); sort(D.begin(), D.end()); reverse(D.begin(), D.end());
			ans += anagram2(get<2>(vec[i]));
		}
		else if (make_pair(get<0>(vec[i]), get<1>(vec[i])) == make_pair(get<0>(W), get<1>(W))) {
			ans += anagram(get<2>(vec[i]), V);
		}
	}
	cout << ans - 1 << endl;
	return 0;
}


Measured memory_bytes: 73228
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define pi pair<ll,ll>
using namespace std;
int main(){
	//	freopen("in.txt","r",stdin);
	char A[110],B[110],C[110];
	scanf("%s%s%s",A,B,C);
	printf("%c%c%c\n",A[0],B[0],C[0]);
	return 0;
}

Measured memory_bytes: 256
a_1 = list(map(int, input().split()))
a_2 = list(map(int, input().split()))
a_3 = list(map(int, input().split()))

N = int(input())

c_1=[0,0,0]
c_2=[0,0,0]
c_3=[0,0,0]
b = []

count = 0

for i in range(N):
    b.append(int(input()))
    
for i in range(N):
    for j in range(3):
        if b[i] == a_1[j]:
            c_1[j] = 1
        if b[i] == a_2[j]:
            c_2[j] = 1
        if b[i] == a_3[j]:
            c_3[j] = 1
            
if c_1[0] == 1 and c_1[1] == 1 and c_1[2]:
    count += 1
if c_2[0] == 1 and c_2[1] == 1 and c_2[2]:
    count += 1
if c_3[0] == 1 and c_3[1] == 1 and c_3[2]:
    count += 1
if c_1[0] == 1 and c_2[0] == 1 and c_3[0]:
    count += 1
if c_1[1] == 1 and c_2[1] == 1 and c_3[1]:
    count += 1
if c_1[2] == 1 and c_2[2] == 1 and c_3[2]:
    count += 1
if c_1[0] == 1 and c_2[1] == 1 and c_3[2]:
    count += 1
if c_1[2] == 1 and c_2[1] == 1 and c_3[0]:
    count += 1


#print(c_1)
#print(c_2)
#print(c_3)
#print(count)

if count >= 1:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
n,m=map(int,input().split())
a=list(map(int,input().split()))
cnt=0
b=sum(a)
for i in range(n):
 if a[i]<b/(4*m):
  continue
 else:
  cnt+=1
if cnt>=m:
 print('Yes')
else:
 print('No')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
  int n,x;
  cin>>n>>x;
  int ans=0;
  vector<int> m(n);
  REP(i,n){
    cin>>m[i];
    x -= m[i];
    ans++;
  }
  sort(m.begin(),m.end());
  ans += x/m[0];
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
  int r,c,sum;
  cin>>r>>c;
  int t[r+1][c+1];

  for(int i=0;i<r;i++)
  {
    sum=0;
    for(int j=0;j<c;j++)
    {cin>>t[i][j];sum+=t[i][j];}
    t[i][c]=sum;
  }
  for(int i=0;i<=c;i++)
  {
    sum=0;
    for(int j=0;j<r;j++)
      sum+=t[j][i];
    t[r][i]=sum;
  }

  for(int i=0;i<=r;i++)
    for(int j=0;j<=c;j++)
      cout<<t[i][j]<<(j==c?'\n':' ');
}

Measured memory_bytes: 3068
#include<bits/stdc++.h>
using namespace std;
#define loop(i,x,z) for (int i=x;i<z;i++)
using ll = long long;
const int M = 1000000007;
int n, l, A[100],minm=INT_MAX;
int dp[100002][2];
bool game(int sum, int turn)
{
	//minm++;
	//if (minm == 20) return 0;
	if (sum < 0)
	{
		return 0;
	}
	if (dp[sum][turn] != -1)
	{
		if(dp[sum][turn])
		return 0;
		return 1;
	}
	loop(i, 0, n)
		if(sum-A[i]==0 || game(sum - A[i], (turn + 1) % 2))
			dp[sum][turn] = 1;
	//cout << sum<<"-"<<turn << ":" << dp[sum][turn] << " ";
	if(dp[sum][turn]>0)return 0;
	dp[sum][turn]=0;
	return 1;
}
int main()
{
	cin >> n >> l;
	memset(dp, -1, sizeof(dp));
	//dp[0][0] = 1;
	loop(i, 0, n)
	{
		cin >> A[i];
		minm = min(minm, A[i]);
	}
	/*loop(i, 0, n)
	{
		int k = i % 2;
		loop(j, 0, 100001)
		{
			if (dp[j][k])
			{
				dp[A[i] + j][k] = 1;
			}
		}
	}*/
	//loop(i, 0, 7) cout << dp[i][0] << ":" << dp[i][1] << " ";
	game(l,0);
	if (dp[l][0])
	{
		cout<<"First";
		return 0;
	}
	cout << "Second";
}



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

using namespace std;

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


const ll LongINF=1e13+7;
const int INF=1e9+7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template <class T, class Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
void clear(queue<pair<int, int>> &q){queue<pair<int, int>> empty;swap(q, empty);} //queueの中身の型は適時変更を忘れない

#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define rv reverse
#define ALL(a) (a).begin(),(a).end()

int main(){
    string A;
    cin>>A;
    if(A[0]=='9'||A[1]=='9'){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }

    return 0;
}

//a=97,z=122

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

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; }
#define ll long long 
#define INF 999999999
#define rep(i,n) for(int i=0;i<n;i++)
using Graph = vector<vector<int>>;
queue<int> quex,quey;

int main(){
    int a,b;    cin >> a >> b;
    cout << 6-a-b << endl;
}


Measured memory_bytes: 256
// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}

const int N = 2e5 + 10;
int n , a[N] , pos[N];

int main(){
    scanf("%d",&n);
    rep(i,1,n+1) scanf("%d",a + i) , pos[a[i]] = i;
    int t = 0 , last = -1;
    per(i,1,n) {
        if(t == 0) {
            if(pos[i] > pos[i + 1])
                t++ , last = pos[i + 1];
        } else {
            int a = pos[i] , b = pos[i + 1] , c = last;
            if((b < a && a < c) || (a < c && c < b) || (c < b && b < a))
                t++ , last = pos[i + 1];
        }
    }
    printf("%d\n",t);
    return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#define ll long long
using namespace std;


ll length[50];
ll p[50];

ll paty(int L,ll X){
    if(X == 0) return 0;
    if(L == 0) return 1;
    if(X <= length[L-1]+1) return paty(L-1,X-1);
    else return p[L-1] + 1 + paty(L-1,X-2-length[L-1]);
}

int main(){
    length[0] = 1;
    p[0] = 1;
    for(int i=1;i<50;i++){
        length[i] = 2*length[i-1]+3;
        p[i] = 2*p[i-1]+1;
    }
    int N;
    ll X;
    cin >> N >> X;
    cout << paty(N,X) << endl;
    return 0;
}


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

using namespace std;
#define rep(i, l, r) for (int i = l; i<r;i++)
#define vi vector<int>
#define all(v) v.begin(),v.end()
#define pb(c) push_back(c)
#define vii vector<pair<int,int>>
#define ii pair<int,int>
#define max(a, b) (((a)<(b))?b:a)
#define min(a, b) ((a>b)?b:a)
#define mp(i, j) make_pair(i,j)
#define ull unsigned long long int
#define ll  long long int
#define pi 3.141592653589793238
#define inf ((ll)1e18)
#define eps 1e-14
#define maxlg 18
#define left(i) ((i)<<1)
#define right(i) (((i)<<1)+1)
#define maxn 551000

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
#ifndef ONLINE_JUDGE
 #endif

    int n;
    cin>>n;
    int px=0,py=0;
    int time=0;
    rep (i,0,n) {
        int x,y,t;
        cin>>t>>x>>y;
        int avail = (t-time);
        if (abs(px-x)+abs(py-y)<=avail && (abs(px-x)+abs(py-y)-avail)%2==0){

        } else {
            cout<<"No";
            return 0;
        }
        time = t;
        px = x,py=y;
    }
    cout<<"Yes";
    return 0;


}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <sstream>
using namespace std;

int main() {
    int n;
    std::string str;
    while(cin >> n >> str && n!=0) {
        for(int i=0; i<n; ++i) {
            string ret;
            for(int j=0; j<str.length();) {
                int counter = 0;
                while(counter < str.length() && str[j] == str[j+(++counter)]);
                stringstream ss;
                ss << counter << str[j];
                ret += ss.str();
                j += counter;
            }
            str = ret;
        }
        cout << str << endl;
    }
}

Measured memory_bytes: 1356
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 0
constexpr int kMod = 1000000007;
constexpr int kMax = 1000;
typedef long long LL;
typedef std::pair<int, int> Point;

int main() {
  LL cells[kMax][kMax];
  int H, W; std::cin >> H >> W;
  for (int i = 0; i < H; ++i) {
    std::string line; std::cin >> line;
    for (int j = 0; j < W; ++j) {
      if (line[j] == '#') cells[i][j] = -1;
      else cells[i][j] = 0;
    }
  }

  for (int j = 0; j < W; ++j) {
    if (cells[0][j]<0) break;
    cells[0][j] = 1;
  }
  for (int i = 0; i < H; ++i) {
    if (cells[i][0]<0) break;
    cells[i][0] = 1;
  }

  for (int i = 1; i < H; ++i) {
    for (int j = 1; j < W; ++j) {
      if (cells[i][j]<0) continue;

      LL way1 = (cells[i-1][j]<0) ? 0 : cells[i-1][j];
      LL way2 = (cells[i][j-1]<0) ? 0 : cells[i][j-1];

      cells[i][j] = (way1 + way2) % kMod;
    }
  }

#if DEBUG
  for (int i = 0; i < H; ++i) {
    for (int j = 0; j < W; ++j) {
      if (cells[i][j] < 0) std::cout << "x";
      else std::cout << cells[i][j];
    }
    std::cout << std::endl;
  }
#endif

  std::cout << cells[H-1][W-1] << std::endl;
}


Measured memory_bytes: 8064
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define vb vector<bool>
#define vi vector<ll>
#define vs vector<string>
#define vvi vector<vi>
#define vii vector<pair<ll, ll>>
#define pii pair<ll, ll>
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define all(a) (a).begin(), (a).end()
#define INF 1000*1000*1000
#define mod (INF + 7)
#define mod1 (mod-1)
#define endl '\n'
#define fio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
using namespace std;

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

    if(s[0] != 'A')
    {
        cout << "WA" << endl;
        return 0;
    }

    int c =0;
    for(int i = 1; i < s.size(); i++)
    {
        if(i != 1 && (i != s.size()-1) && s[i] == 'C')
            c++;
        else if( 'a' <= s[i] && 'z' >= s[i])
        {
            continue;
        }
        else
        {
            cout << "WA" << endl;
            return 0;
        }
    }

    if(c == 1)
        cout << "AC" << endl;
    else
        cout << "WA" << endl;
    return 0;
}


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

int main() {
  int h, a, b;
  cin >> h >> a >> b;
  int result = 0;
  int i;
  for (i = a; i <= b; i++) {
    if (h % i == 0) {
      result++;
    }
  }
  cout << result << endl;
  return 0;
}



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

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define REPRl(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < (int)n; i++)
#define FORl(i, m, n) for(ll i = m; i < (ll)n; i++)
#define ALL(v) v.begin(), v.end()
ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}

int main() {
  int n,k;cin>>n>>k;
  string s;cin>>s;
  s[k-1]=s[k-1]+('a'-'A');
  cout << s << endl;
}

Measured memory_bytes: 256
n = int(input())
jobs = []
for _ in range(n):
    a, b = map(int, input().split())
    jobs.append((a, b))
jobs.sort(key=lambda x: x[1])
t = 0
for job in jobs:
    a, b = job
    t += a
    if (t > b):
        print('No')
        exit()
print('Yes')

Measured memory_bytes: 31872
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>
#include <unordered_map>

using namespace std;
typedef long long int ll;

#define SP(x) setprecision((int)x)
#define SW(x) setw(x)    // 桁数指定
#define SF(c) setfill(c) // 埋め文字指定('0')
#define ALL(v) v.begin(), v.end()

int main(int argc, char const *argv[])
{
    ll a;
    cin>>a;
    cout << a + a * a + a * a * a << endl;
}

Measured memory_bytes: 3592
#include <iostream>
#include <algorithm>

using namespace std;

int main(void){
	int sum = 0;
	int best = 10;
	for(int i=0; i<5; i++){
		int num; cin >> num;
		if(num % 10 != 0){
			best = min(best, num%10);
		}
		num = ((num+9)/10)*10;
		sum += num;
	}
	cout << sum - 10 + best << endl;
}

Measured memory_bytes: 256
/* Everything happens for a reason.
Be patient, things will be at their rightful place.
It was meant to happen this way, accept it.
And now decide what you can do about it.
*/
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
#define ip pair<ll,ll>
#define vii vector<ll>
#define vpp vector<ip>
#define vdd vector<ld>
#define vb vector<bool>
#define pi  pair<ll,ip>
#define sc(x) scanf("%lli",&x)
#define c(x) cin >> x
#define fo(i,k,n) for( int i=k;i<n;i++)
#define hu 200010
#define pq priotity_queue<ll>
#define pqs priority_queue<ll,vii,greater<ll>>
#define ppq priority_queue<ip,vpp,greater<ip>>
#define INF INT_MAX
#define ff first
#define ss second
using namespace std;
const ll M = 1000000000+7;
//Grid Movement
ll dx[] = {-1, 0, 1, 0};
ll dy[] = {0, -1, 0, 1};

ld Pi= acos(-1);

ll lcm(ll a,ll b)
{
    return (a*b)/(__gcd(a,b));
}

ll mex(ll x, ll y) 
{ 
	ll res = 1;	  
	x = x % M; 
	if (x == 0) return 0; 
	while (y > 0) 
	{ 
		if (y & 1) 
		res = (res*x) % M; 
		y = y>>1; 
		x = (x*x) % M; 
	} 
	return res; 
} 

bool comp(ll comp1,ll comp2)
{
    return comp1>comp2;
}

void yes()
{
    printf("YES\n");
}

void no()
{
    printf("NO\n");
}

ll inv(ll a, ll m)
{
    ll m0 = m;
    ll y = 0, x = 1;
 
    if (m == 1)
      return 0;
 
    while (a > 1)
    {
        int q = a / m;
        int t = m;
        m = a % m, a = t;
        t = y;
        y = x - q * y;
        x = t;
    }
 
    if (x < 0)
       x += m0;
 
    return x;
}

void sieve(ll n)
{
    vii primes(n+1);
    vb is_prime(n+1);
	is_prime.resize(n+1);
	primes.resize(n+1);
 
	is_prime[0] = is_prime[1] = false;
	for(int i = 2; i<=n; i++)
	{
	    if(is_prime[i])
	    {
	    	primes.pb(i);
	        for (int j = i*i; j<=n; j+=i)
	            is_prime[j] = false;
	    }
	}
}

void solve()
{
    ll x;
    sc(x);
    cout << (1-x);
}

int main()
{
//	ios_base::sync_with_stdio(0); cin.tie(0);
    ll t=1;
  //  sc(t);
    while(t--) solve();
}





Measured memory_bytes: 3696
N = int(input())
H = list(map(int, input().split()))
H = H[::-1]

for i in range(1, N):
    if H[i-1]<H[i]:
        H[i] -= 1
    
    if H[i-1]<H[i]:
        print('No')
        exit()
    
print('Yes')

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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

//#pragma GCC target("avx2")
//#pragma GCC optimization("unroll-loops")
//#pragma GCC optimize("O2")
//#pragma GCC optimize("O3")

#define FOR(i,a) for (int i=0;i<(a);++i)
#define FORD(i,a) for (int i=(a)-1;i>=0;i--)
#define FORT(i,a,b) for (int i=(a);i<=(b);++i)
#define FORTD(i,b,a) for (int i=(b);i>=(a);--i)
#define trav(i,v) for (auto i : v)
#define all(v) v.begin(),v.end()
#define ad push_back
#define fr first
#define sc second
#define mpr(a,b) make_pair(a,b)
#define pir pair<int,int>
#define make_unique(v) v.erase(unique(all(v)),v.end())
#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define srng mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define y1 EsiHancagorcRepa

const int N=2e5+6;
const ll MOD=998244353;

ll k[N];
ll ans;
int main(){
	fastio;
	int n,s;
	cin>>n>>s;
	FOR(z,n){
		int tv;
		cin>>tv;
		k[0]++;
		FORD(i,s+1){
			if (i<tv)break;
			k[i]+=k[i-tv];
			k[i]%=MOD;
		}
		ans+=k[s];
		ans%=MOD;
	}
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;

bool Compare(int a, int b)
{
	int d1 = a % 10;
	int d2 = b % 10;

	return d1 > d2;
}

int main()
{
	int n = 5;
	vector<int> arr(5);
	for (int i = 0; i < n; i++)
	{
		cin >> arr[i];
	}

	sort(arr.begin(), arr.end(), Compare);

	int sum = 0;

	int i = n - 1;
	while (arr[i] % 10 == 0 && i >= 0)
	{
		sum += arr[i];
		i--;
		n--;
	}

	i = 0;
	while (arr[i] % 10 != 0 && i < n)
	{
		sum += arr[i];

		if (i == n - 1)
		{
			break;
		}

		if (sum % 10 != 0)
		{
			while (sum % 10 != 0)
			{
				sum++;
			}
		}
		i++;
	}

	printf("%d\n", sum);
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int max = 0;
        for(int i = 0; i < s.length(); i++) {
            A: for(int j = i; j < s.length(); j++) {
                String sub = s.substring(i, j+1);
                for(int k = 0; k < sub.length(); k++) {
                    char c = sub.charAt(k);
                    if(c != 'A' && c != 'C' && c != 'G' && c != 'T') {
                        break A;
                    }
                }
                max = Math.max(max, sub.length());
            }
        }
        System.out.println(max);
    }
}


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

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second

template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> P;

const ll INF = 1ll<<30;
const ll MOD = 1000000007;
const double EPS  = 1e-10;

int N, M, Q;
string S[2000];
pii d[2000][2000]; // TreeIndex, depth
vector<pii> rootPos; // y,x
int sum[2001][2001]; // 根の数の累積和

int cnt[4][2001][2001]; // cnty[i][j] : y=iまででx1=jのときの累積和, x2=jのときの累積和, x=iまででy1=jのときの累積和, y2=jのときの累積和

void dfs(int num, int depth, int y, int x) {
	d[y][x] = pii(num, depth);
	
	int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};
	REP(i, 4) {
		int nx = x + dx[i], ny = y + dy[i];
		if (!(nx >= 0 && nx < M && ny >= 0 && ny < N)) continue;
		if (!S[ny][nx] || d[ny][nx] != pii(-1, 0)) continue;
		dfs(num, depth + 1, ny, nx);
	}
}

int main() {
	cin >> N >> M >> Q;
	REP(i, N) cin >> S[i];
	REP(i, N) REP(j, M) S[i][j] -= '0';
	
	fill(d[0], d[N], pii(-1, 0));
	
	int tcnt = 0;
	REP(i, N) REP(j, M) {
		if (S[i][j] && d[i][j] == pii(-1, 0)) {
			rootPos.push_back(pii(i, j));
			sum[i + 1][j + 1]++;
			
			dfs(tcnt, 0, i, j);
			tcnt++;
		}
	}
	
	REP(i, N) REP(j, M) sum[i + 1][j + 1] += sum[i + 1][j];
	REP(i, N) REP(j, M) sum[i + 1][j + 1] += sum[i][j + 1];
	
	REP(i, N) REP(j, M) {
		// y=iでx1=jのとき
		if (j - 1 >= 0 && S[i][j] && S[i][j - 1] && d[i][j].se > d[i][j - 1].se) cnt[0][i + 1][j + 1]++;
		
		// y=iでx2=jのとき
		if (j + 1 < M && S[i][j] && S[i][j + 1] && d[i][j].se > d[i][j + 1].se) cnt[1][i + 1][j + 1]++;
	}
	
	REP(j, M) REP(i, N) {
		// x=iでy1=iのとき
		if (i - 1 >= 0 && S[i][j] && S[i - 1][j] && d[i][j].se > d[i - 1][j].se) cnt[2][j + 1][i + 1]++;
		// x=iでy2=iのとき
		if (i + 1 < N && S[i][j] && S[i + 1][j] && d[i][j].se > d[i + 1][j].se) cnt[3][j + 1][i + 1]++;;
	}
	
	// 累積和
	REP(i, N) REP(j, M) {
		cnt[0][i + 1][j + 1] += cnt[0][i][j + 1];
		cnt[1][i + 1][j + 1] += cnt[1][i][j + 1];
	}
	REP(j, M) REP(i, N) {
		cnt[2][j + 1][i + 1] += cnt[2][j][i + 1];
		cnt[3][j + 1][i + 1] += cnt[3][j][i + 1];
	}
	
	while (Q--) {
		int x1, x2, y1, y2;
		scanf("%d %d %d %d", &y1, &x1, &y2, &x2);
		x1--; y1--; x2--; y2--;
		
		int ans = sum[y2 + 1][x2 + 1] - sum[y2 + 1][x1] - sum[y1][x2 + 1] + sum[y1][x1];
		
		
		ans += cnt[0][y2 + 1][x1 + 1] - cnt[0][y1][x1 + 1];
		ans += cnt[1][y2 + 1][x2 + 1] - cnt[1][y1][x2 + 1];
		ans += cnt[2][x2 + 1][y1 + 1] - cnt[2][x1][y1 + 1];
		ans += cnt[3][x2 + 1][y2 + 1] - cnt[3][x1][y2 + 1];
		
		printf("%d\n", ans);
	}
	
	
	return 0;
}


Measured memory_bytes: 131432
#include <bits/stdc++.h>
using namespace std;
int n;
const long long mod=1e9+7;
string in;
char s[300050];
int Edge[8][2]={{2,1},{4,3},{6,5},{3,3},{7,1},{2,1},{2,2},{4,4}};
long long f[300050][8];
int main(){
    cin>>in;n=in.length();f[0][0]=1;
    for (int i=0;i<n;++i) s[i+1]=in[i];
    for (int i=1;i<=n;++i)
        for (int j=0;j<=7;++j){
            if(s[i]!='0') f[i][Edge[j][1]]=(f[i][Edge[j][1]]+f[i-1][j])%mod;
            if(s[i]!='1') f[i][Edge[j][0]]=(f[i][Edge[j][0]]+f[i-1][j])%mod;
        }
    printf("%d\n",(f[n][1]+f[n][3])%mod);
    return 0;
}

Measured memory_bytes: 19716
package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Scan()
	n, _ := strconv.Atoi(sc.Text())

	var root *elem
	for i := 0; i < n; i++ {
		sc.Scan()
		line := sc.Text()
		if line == "print" {
			printIn(root)
			fmt.Println(strings.Join(in, ""))
			printPre(root)
			fmt.Println(strings.Join(pre, ""))
			in = []string{}
			pre = []string{}
		} else {
			sc.Scan()
			num, _ := strconv.Atoi(sc.Text())
			root = insert(root, num)
		}
	}
}

var pre []string

func printPre(elem *elem) {
	if elem == nil {
		return
	}
	pre = append(pre, " "+strconv.Itoa(elem.key))
	printPre(elem.left)
	printPre(elem.right)
}

var in []string

func printIn(elem *elem) {
	if elem == nil {
		return
	}
	printIn(elem.left)
	in = append(in, " "+strconv.Itoa(elem.key))
	printIn(elem.right)
}

type elem struct {
	paremnt *elem
	left    *elem
	right   *elem
	key     int
}

func insert(root *elem, zkey int) *elem {
	// new Value
	z := &elem{nil, nil, nil, zkey}
	if root == nil {
		return z
	}

	// search parent
	parentOfZ := root
	for {
		if parentOfZ.key > z.key {
			if parentOfZ.left == nil {
				parentOfZ.left = z
				break
			}
			parentOfZ = parentOfZ.left
		} else {
			if parentOfZ.right == nil {
				parentOfZ.right = z
				break
			}
			parentOfZ = parentOfZ.right
		}
	}

	z.paremnt = parentOfZ
	return root
}



Measured memory_bytes: 96236
import math

while True:
    n, x = map(int,input().split())

    if n == 0 and x == 0:
        break

    count = 0

    u = math.ceil(x/3)
    while u<=n and u<=x-3:
        v = (x-u)//2 + 1
        while v < (x-u):
            w = (x-u) - v
            if u > v > w:
                count +=1
                #print(u, v,w)
            v+=1
        u+=1
    print(count)


Measured memory_bytes: 5664
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<set>
#include<map>
#include<queue>
using namespace std;
typedef long long  LL;
#define sqr(x) ((x)*(x))
#define mp make_pair
#define F first
#define S second
inline int read(){
	int x = 0; char ch = getchar(); bool positive = 1;
	for (; !isdigit(ch); ch = getchar())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = getchar())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(int a){
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(int a){
    if(a<0){
    	a=-a; putchar('-');
	}
	write(a); puts("");
}
#include<string>
int flag;
char ch[100005];
#define DEBUG 0
int main(){
	cin>>ch;
	for(int i=0;i<strlen(ch)-1;i++)if(ch[i]=='A'&&ch[i+1]=='C'){
		puts("Yes"); return 0;
	}
	puts("No");
}


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

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class FLISOnTree {
public:
    vector<int> dp, A;
    int N;
    vector<vector<int>> G;
    vector<int> res;

    void dfs(int v, int p) {
        int val = A[v];
        int idx = lower_bound(dp.begin(), dp.end(), val) - dp.begin();
        int before = dp[idx];
        dp[idx] = val;
        res[v] = lower_bound(dp.begin(), dp.end(), INF) - dp.begin();
        for (auto to : G[v]) {
            if (to == p) continue;
            dfs(to, v);
        }
        dp[idx] = before;
    }

    void solve(std::istream& cin, std::ostream& cout) {
        cin >> N;
        A.resize(N), res.resize(N);
        dp = vector<int>(N + 1, INF);
        REP(i, N) cin >> A[i];
        G.resize(N);
        REP(i, N - 1) {
            int a, b;
            cin >> a >> b;
            a--, b--;
            G[a].push_back(b);
            G[b].push_back(a);
        }
        dfs(0, -1);
        REP(i, N) cout << res[i] << endl;
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    FLISOnTree solver;
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 33292
#include <iostream>
#include <vector>
#include <list>

using namespace std;
typedef long long ll;

void Search(const int n, vector<list<pair<int, int>>> &d, vector<ll> &ans) {
	for (auto itr = d[n].begin(); itr != d[n].end(); itr++) {
		if (ans[(*itr).first] == -1) {
			ans[(*itr).first] = ans[n] + (*itr).second;
			Search((*itr).first, d, ans);
		}
	}
	return;
}

int main(void) {
	int num, i = 0, a, b, c, q, k;
	cin >> num;
	vector<list<pair<int, int>>> d(num + 1);
	vector<ll> ans(num + 1, -1);
	for (i = 0; i < num - 1; i++) {
		scanf("%d%d%d", &a, &b, &c);
		d[a].push_back(make_pair(b, c));
		d[b].push_back(make_pair(a, c));
	}
	cin >> q >> k;
	ans[k] = 0;
	Search(k, d, ans);
	for (i = 0; i < q; i++) {
		scanf("%d%d", &a, &b);
		cout << ans[a] + ans[b] << "\n";
	}
	return 0;
}

Measured memory_bytes: 15104
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;

using namespace std;
ll n,k,a[1010];
vector<ll> v;
int main(){
    cin>>n>>k;
    lol(i,n)cin>>a[i];
    lol(i,n){
	ll sum=0;
	for(ll j=i;j<n;j++){
	    sum+=a[j];
	    v.push_back(sum);
	}
    }
    //for(auto x:v)cout<<x<<" ";
    ll p=0;
    for(ll i=50;i>=0;i--){
	p+=((ll)1<<i);
	ll cnt=0;
	for(auto x:v){
	    bool ok=1;
	    lol(r,51)if((p&((ll)1<<r))>=1&&(x&((ll)1<<r))==0)ok=0;
	    cnt+=ok;
	}
	if(cnt<k)p-=((ll)1<<i);
	//cout<<cnt<<" "<<p<<endl;
    }
    cout<<p<<endl;
    return 0;
}


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

typedef long long ll;
typedef long double Double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

// chmax, chmin
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;
}

void solve(std::vector<long long> A) {
  if( A[0] + A[1] + A[2] >= 22 ) cout << "bust" << endl;
  else cout << "win" << endl;
}

int main() {
  std::vector<long long> A(3);
  for (int i = 0; i < 3; i++) {
    scanf("%lld", &A[i]);
  }
  solve(std::move(A));
  return 0;
}


Measured memory_bytes: 768
#include<iostream>
#include<vector>
#include<string>
#include<iomanip>
#include<set>

using namespace std;

int main()
{
	long long n,k;
	cin >> n >> k;
	vector<int> d(k);
	for(int i=0;i<k;i++)
		cin >> d[i];

	long long ans=n;
	while(true)
	{
		bool flag=true;
		long long now=ans;
		while(true)
		{
			if(now<=0)break;
			int tmp=now%10; 
			now/=10;
			for(int i=0;i<k;i++)
				if(tmp==d[i])
				{
					flag=false;
					break;
				}
			if(!flag)break;
		}

		if(flag)break;
		ans++;
	}

	cout << ans << endl;





}


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

// #define int long long

#define pb          push_back
#define F           first
#define S           second
#define endl        "\n"
#define rep(i,a,b)  for(int i = a; i < (int)b; i++)
#define req(i,a,b)  for(int i = (int)b - 1; i >= a; i--)
#define all(a)      (a).begin(),(a).end()
#define ret(x)      {cout << x << endl; return;}
#define sz(x)       (int)x.size()
#define type(x)     typeid(x).name()

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<vector<int>> vii;

int gcd(int a, int b) {return b?gcd(b,a%b):a;}

#ifdef LOCAL
	#define wa(x)       cerr << (#x) << " --- " << (x) << endl
	#define pvi(v)      {for(auto it:v) cerr << it << " "; cerr << endl;}
	#define line1	    cerr << "---------------------------" << endl;
#else
	#define wa //
	#define line1 //
	#define pvi //
	#define printf //
#endif

void solve();
signed main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	cout << fixed << setprecision(10);

	int t=1; 
	// cin>>t;
	while(t--) {solve();line1;}
	printf("Time : %fms\n", (1000*(double)clock())/CLOCKS_PER_SEC);
	return 0;
}

//___________________________________________________________________________________________________

void solve() {

	string a,b;
	cin >> a >> b;
	int la = a.size();
	int lb = b.size();

	// dp[i][j] : 
	// Length of LCS when we consider the first i characters 
	// of string_a and first j characters of string_b.
	vector<vi> dp(la+1, vi(lb+1,0));

	// rep(i,0,la+1) dp[i][0] = 0;
	// rep(i,0,lb+1) dp[0][i] = 0;

	rep(i,1,la+1){
		rep(j,1,lb+1){
			if(a[i-1] == b[j-1]) dp[i][j] = max(dp[i-1][j-1]+1, dp[i][j]);
			dp[i][j] = max({dp[i][j], dp[i-1][j], dp[i][j-1]});
		}
	}

	int i=la, j=lb;
	string ans = {};
	while(i != 0 && j != 0){

		if(j>0 && dp[i][j] == dp[i][j-1]) j--;
		else if(i>0 && dp[i][j] == dp[i-1][j]) i--;
		else if(i>0 && j>0 && dp[i][j] == dp[i-1][j-1]+1){
			ans += a[i-1];
			i--, j--;
		}		
	}

	reverse(all(ans));
	cout<<ans<<endl;
}


Measured memory_bytes: 38584
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(void){
    // Your code here!
    int A, B, C, D, E;
    cin >> A >> B >> C >> D >> E;
    
    vector<int> Time = {A, B, C, D, E};
    vector<int> NextTime(5);
    for (int i = 0; i < 5; i++){
        if (Time[i] % 10 == 0) {
            NextTime[i] = Time[i];
        }
        else {
            NextTime[i] = Time[i] - Time[i] % 10 + 10;
        }
    }
    
    int BestTime = 999999;
    for (int i = 0; i < 5; i++) {
        int SumTime = 0;
        for (int j = 0; j < 5; j++) {
            if (i == j) {
                SumTime += Time[i];
            }
            else {
                SumTime += NextTime[j];
            }
        }
        BestTime = min(BestTime, SumTime);
    }
    cout << BestTime << endl;
}

Measured memory_bytes: 256