akhauriyash/Code-Regression huggingface dataset:
#### import ####
import sys
import math
from collections import defaultdict

#### 設定 ####
sys.setrecursionlimit(10**7)
def input():
  return sys.stdin.readline()[:-1]

#### 定数 ####
mod = 10**9 + 7

#### 読み込み ####
def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
  read_all = [tuple(map(int, input().split())) for _ in range(N)]
  return map(list,zip(*read_all))

#################

S = str(input())

alphabet = [chr(i) for i in range(ord('a'),ord('z')+1)]

if len(S)!=26:
  for i in range(len(S)):
    alphabet.remove(S[i])
  print(S+alphabet[0])
else:
  if S == ''.join(list(reversed(alphabet))):
    print(-1)
  else:
    for i in range(1,len(S))[::-1]:
      if S[i]>S[i-1]:
        break
    temp = 'z'
    for j in range(i,len(S)):
      if S[j]>S[i-1] and temp > S[j]:
        temp = S[j]
    print(S[:i-1]+temp)

Measured memory_bytes: 38484
import copy
import heapq
import math

def j(n):
    if n:print("Yes")
    else:print("No")
    exit(0)
rem = 10 ** 9 + 7

"""
def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")
"""

def ip():
    return int(input())
def iprow():
    return [int(i) for i in input().split()]
def ips():
    return (int(i) for i in input().split())
def ipmultiplerow(n):
    a = []
    for i in range(n):
        a.append(ip())
    return a
def printrow(a):
    for i in a:
        print(i)

a = ip()
b = ip()
if a*b == 2:
    print(3)
if a*b == 6:
    print(1)
if a*b == 3:
    print(2)

Measured memory_bytes: 3444
n, m = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
bc = [list(map(int, input().split())) for _ in range(m)]
bc.sort(key=lambda x: x[1], reverse=True)


def f():
    s = sum(a)
    i = 0
    for v in bc:
        b, c = map(int, v)
        while b > 0:
            if i >= n:
                return s
            if c <= a[i]:
                return s
            s += c - a[i]
            b -= 1
            i += 1
    return s


print(f())

Measured memory_bytes: 32960
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f(a,b,c) for(int a=(b);a<=(c);++a)
#define wer rd()
char buf[1<<20],*p1,*p2;
#define GC (p1==p2&&(p1=buf,p2=buf+fread(buf,1,1<<20,stdin),p1==p2)?0:*p1++)
inline ll wer{
    ll ans=0,fl=1;char t=GC;
    while(!isdigit(t)){if(t=='-')fl=-1;t=GC;}
	while(isdigit(t))ans=ans*10+t-'0',t=GC;
	return ans*fl;
}
 
//#define double long double 
const double eps=1e-8;
int sb(double x)
{
	if(-eps<x&&x<eps)return 0;
	return x>0?1:-1;
}
struct pv{
	double x,y;int id;
	friend pv operator+(const pv&a,const pv&b)
	{
		return {a.x+b.x,a.y+b.y};
	}
	friend pv operator-(const pv&a,const pv&b)
	{
		return {a.x-b.x,a.y-b.y};
	}
	friend double operator*(const pv&a,const pv&b)
	{
		return a.x*b.y-a.y*b.x;
	}
	friend bool operator<(const pv&a,const pv&b)
	{
		return a.x<b.x;
	}
	friend bool operator==(const pv&a,const pv&b)
	{
		return a.x==b.x&&a.y==b.y;
	}
	friend double operator/(const pv&a,const pv&b)
	{
		return a.x*b.x+a.y*b.y;
	}
	
	
}p[10001];
const double PI=acos(-1);
double cross(pv a,pv b,pv c)
{
	return (b-a)*(c-a);
}
double ans[10001];
int n,st,xt,zt,ids[10001],idx[10001],idz[10001];
pv sm[10001],xm[10001],zm[10001];
double agl(pv a,pv b)
{
	if(sb(a*b)==0){if(sb(a.x*b.x)>=0||sb(a.y*b.y)>=0)return 0;return PI;}
	return acos((a/b)/sqrt((a.x*a.x+a.y*a.y)*(b.x*b.x+b.y*b.y)));
}
int main()
{
	cin>>n;
	f(i,1,n)cin>>p[i].x>>p[i].y,p[i].id=i;
	f(i,1,n)
	{
		complex<double>a(p[i].x,p[i].y);
		a*=complex<double>(cos(1),sin(1));
		p[i]={a.real(),a.imag(),p[i].id};
	 } 
//	f(i,1,n)cout<<p[i].x<<" "<<p[i].y<<"\n";
	sort(p+1,p+n+1);
	f(i,1,n)
	{
//		cout<<p[i].x<<" "<<p[i].y<<"\n";
		while(st>=2&&sb(cross(sm[st-1],sm[st],p[i]))>0)st--;
		sm[++st]=p[i];ids[st]=p[i].id;
	}
//	f(i,1,st)cout<<ids[i]<<" \n"[i==st];
	for(int i=n;i;i--)
	{
		while(xt>=2&&sb(cross(xm[xt-1],xm[xt],p[i]))>0)xt--;
		xm[++xt]=p[i];idx[xt]=p[i].id;
	}
	f(i,1,st)
	{
		if(zt==0||!(zm[zt]==sm[i]))
		zm[++zt]=sm[i],idz[zt]=ids[i];
	}
	f(i,1,xt)
	{
		if(zt==0||!(zm[zt]==xm[i]))
		zm[++zt]=xm[i],idz[zt]=idx[i];
	}
	while(zt>1&&zm[zt]==zm[1])--zt;
	f(i,1,zt)
	{
//		cout<<idz[i]<<"\n";
		int ne=i%zt+1,pre=(i==1?zt:i-1);
//		cout<<idz[ne]<<" "<<idz[pre]<<"\n";
		ans[idz[i]]=(PI-agl(zm[ne]-zm[i],zm[pre]-zm[i]))/(PI*2);
	}
	f(i,1,n)
	{
		if(ans[i]<0)ans[i]=0;
		printf("%.20lf\n",ans[i]);
	}
}

Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<math.h>
#include<map>
using namespace std;
using ll = long long;
int main() {
    int n,x,t;
    cin >> n >> x >> t;
    int times = (n + x - 1) / x;
    int ans = times * t;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll mxn= 5e4+5;
// check for forloop
// intialize variable
// overflow
// go for easy solution
#define mod 1000000007
ll INF = 1000000000000000005LL;
//#define endl '\n'
void rishabh(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}
int main(){
    rishabh();
    ll n,a,b;
    cin>>n>>a>>b;
    ll mx=a+(n-1)*b;
    ll mi=a*(n-1)+b;
    cout<<max(mx-mi+1,0LL);
}

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

int main() {
  string s;
  cin >> s;
  string a,b,c;
  a=s.at(0) ;
  b=s.at(1);
  c=s.at(2);
  
  cout << a << b << c << endl;

}



Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define dbg(x) #x "=" << x << " "
#define fore(i,a,b) for(int i=a,gon=b;i<gon;++i)
#define pb push_back
#define F first
#define S second
typedef double lf;
typedef long long ll;
typedef pair<int, int> pii;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    #ifdef LOCAL
        freopen("in.txt", "r", stdin);
        //freopen("out.txt", "w", stdout);
    #else
        #define endl '\n'
    #endif
    int n;
    cin >> n;
    int v[n];
    fore(i,0,n) cin >> v[i];
    sort(v, v+n);
    cout << v[n/2]-v[n/2-1] << endl;
}


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

template<class T>
class SparseTable {
	const int MAX_LOG=22;
	vector<vector<T>>t;
	vector<int>l2;
	function<T(T,T)>F;
public:
	int n;
	T INIT;
	void init(int n_,function<T(T,T)>f){
		n=n_;
		F=f;
		t=vector<vector<T>>(MAX_LOG);
		rep(i,MAX_LOG)t[i].assign(n,INT_MAX);
		l2.assign(n+1,0);
		int k=0;
		rep(i,n+1){
			while((1<<(k+1))<=i)k++;
			l2[i]=k;
		}
	}
	void build(int n_,T*a,function<T(T,T)>f){
		init(n_,f);
		rep(i,n)t[0][i]=a[i];
		for (int i=1;i<MAX_LOG;i++) {
			for(int j=0;j+(1<<i)<=n;j++){
				t[i][j]=F(t[i-1][j],t[i-1][j+(1<<(i-1))]);
			}
		}
	}
	T query(int a,int b) {
		int l=l2[b-a];
		return min(t[l][a],t[l][b-(1<<l)]);
	}
};

const int B=400;
char S[500000];
string s[200000];

struct node{
	unordered_map<char,node*>nx;
	int vid,cnt;
	vector<int>v;
}pool[500000];
node*root=&pool[0];
int pointer=1;


node*last[200000];
int node_cnt=0;
map<node*,int>vid;
int vs[1000000];
int pos[26];

SparseTable<int>tab;

void add(int id){
	node*x=root;
	for(char c:s[id]){
		x->v.push_back(id);
		if(x->nx[c]==NULL)x->nx[c]=&pool[pointer++];
		x=x->nx[c];
	}
	x->v.push_back(id);
	last[id]=x;
	x->cnt++;
}

bool Less(int a,int b){
	int A=s[a].size(),B=s[b].size();
	int l=last[a]->vid,r=last[b]->vid;if(l>r)swap(l,r);
	int ok=tab.query(l,r+1);
	if(min(A,B)==A&&ok==A)return true;
	if(min(A,B)==B&&ok==B)return false;
	return pos[s[a][ok]-'a']<pos[s[b][ok]-'a'];
}

void dfs(node*v,int dep){
	v->vid=node_cnt;
	vs[node_cnt++]=dep;
	for(auto&p:v->nx){
		dfs(p.second,dep+1);
		vs[node_cnt++]=dep;
	}
}

char C[27];

int main(){
	int n;cin>>n;
	rep(i,n){
		scanf("%s",S);
		s[i]=S;
		add(i);
	}
	dfs(root,0);
	tab.build(node_cnt,vs,[](int a,int b){return min(a,b);});
	int q;cin>>q;
	rep(i,q){
		int K;scanf("%d",&K);K--;
		scanf("%s",C);
		rep(j,26){
			pos[C[j]-'a']=j;
		}
		int ans=1;
		node*x=root;
		for(char c:s[K]){
			if(x->v.size()<=B){
				for(int j:x->v){
					if(j==K)continue;
					if(Less(j,K))ans++;
				}
				break;
			}
			for(auto&p:x->nx){
				if(pos[p.first-'a']<pos[c-'a'])ans+=p.second->v.size();
			}
			ans+=x->cnt;
			x=x->nx[c];
		}
		printf("%d\n",ans);
	}
}

Measured memory_bytes: 184540
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pll = pair<ll, ll>;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define rrep(i, m, n) for(ll i = m; i > n; i--)
#define Rep(i, m, n) for(ll i = m; i < n; i++)
#define all(vec) vec.begin(), vec.end()
#define lmax(x, y) max<ll>(x, y)
#define lmin(x, y) min<ll>(x, y)
#define tmax(x, y, z) lmax((x), lmax((y), (z)))
#define tmin(x, y, z) lmin((x), lmin((y), (z)))
#define MINUS(a) memset(a, 0xff, sizeof(a))
#define ZERO(a) memset(a, 0, sizeof(a))
const ll INF = 1LL << 60;
const ll MM = 1000000000; const ll MOD = MM + 7; const ll MMM=9223372036854775807;//2^63 -1
#define ADD(a,b) a = (a + ll(b)) % MOD
#define MUL(a,b) a = (a * ll(b)) % MOD
ll GCD(ll x, ll y){ if(y == 0) return x; else return GCD(y, x % y);}
ll LCM(ll x, ll y){ return x / GCD(x, y) * y;}
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<typename A, size_t N, typename T> void FILL(A (&array)[N], const T &val){ fill( (T*)array, (T*)(array+N), val );}
// struct edge{ ll from, to, cost; };
// struct edge{ ll to, cost; };
// using Graph = vector<vector<ll>>;  // 重み無し
// using Graph = vector<edge>;  // 辺
// using Graph = vector<vector<edge>>;  // 重み付き
ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
ll ddx[8] = {1, 1, 0, -1, -1, -1, 0, 1}, ddy[8] = {0, 1, 1, 1, 0, -1, -1, -1};


int main(){
    string s; cin >> s;
    if(s[s.size()-1] == 's') cout << s + "es" << endl;
    else cout << s + "s" << endl;
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
int main(){
    int ans;
    int n;
    cin >> n;
    vector<int> msa(n);
    vector<int> msb(n);
    for(int i = 0;i<n;i++){
        int tmp;
        cin >> tmp;
        msa[i] = tmp;
        cin >> tmp; 
        msb[i] = tmp;
    }
    sort(msa.begin(),msa.end());
    sort(msb.begin(),msb.end());
    if(n%2 == 0){
        int t = (n/2)-1;
        ans = (msb[t] + msb[t+1]) - (msa[t] + msa[t+1]) + 1;
    }else{
        int t = ((n+1)/2)-1;
        ans = msb[t] - msa[t] + 1;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 4844
def square(list):
    return [i ** 2 for i in list]
m = 1000000007
n = int(input())
A = list(map(int, input().split()))
sq = square(A)
s1 = sum(A)
s2 = sum(sq)
 
result = (s1**2-s2)//2
print(result%m)

Measured memory_bytes: 31580
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int) (n); i++)
#define rep3(i, s, n) for (int i = (s); i <=(int) (n); i++)
#define chmax(x,y) x = max(x,y)

	long long a[3005][3005];
	long long dp[3005][3005][5];


int main() {
	int R,C,n;
	cin >> R >> C >> n;

	rep(i, n) {
	int r,c,v;
		cin >> r >> c >> v;
		a[r-1][c-1]=v;
	}

	rep(i,R){
 		rep(j,C) {
			for (int k=2;k>=0; k--){
				chmax(dp[i][j][k+1],dp[i][j][k]+a[i][j]);
			}
			rep(k,4) {
				chmax(dp[i+1][j][0],dp[i][j][k]);
				chmax(dp[i][j+1][k],dp[i][j][k]);
			}
			
		}
	}
	long long ans =0;
	rep(k,4) chmax(ans,dp[R-1][C-1][k]);

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


Measured memory_bytes: 426244
K=int(input())
List=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(List[K-1])



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

typedef long long ll;
const ll MOD = 1000000007;

using namespace std;

int n, m, ans = 0;

int dfs(int v, vector<vector<int> >& g, vector<int>& d) {
    int temp = 0;
    if ((int)g[v].size() == 0) {
        d[v] = 0;
        return 0;
    }
    for (int c : g[v]) {
        if (d[c] == -1) {
            dfs(c, g, d);
        }
        temp = max(temp, d[c]);
    }
    d[v] = temp + 1;
    ans = max(ans, d[v]);
    return d[v];
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n >> m;
    vector<vector<int> > g(n);
    vector<int> d(n, -1);
    for (int i = 0; i < m; i++) {
        int u, v;
        cin >> u >> v;
        u--, v--;
        g[u].push_back(v);
    }
    for (int i = 0; i < n; i++) {
        if (d[i] == -1) dfs(i, g, d);
        // cout << d[i] << " ";
    }
    // cout << endl;
    cout << ans;

    return 0;
}

Measured memory_bytes: 10240
#include <fstream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <cmath>
#include <climits>

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())

using namespace std;
typedef long long ll;

int main() {
#ifdef RUN_LOCAL
  ifstream in("../input.txt");
  cin.rdbuf(in.rdbuf());
#endif

  cin.tie(0);
  ios::sync_with_stdio(false);

  ll h, w;
  cin >> h >> w;
  if (h == 1 || w == 1) {
    cout << 1 << endl;
  }
  else if ((h * w) % 2) {
    cout << h * w / 2 + 1 << endl;
  }
  else {
    cout << h * w / 2 << endl;
  }


  return 0;
}

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

 class Main{

	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

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

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

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

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}
	}

	static boolean prime[] = new boolean[1001];

	public static void main(String[] args) {
		FastReader sc = new FastReader();
		stones(sc);
		/*
		 * String str =sc.nextLine(); int q=sc.nextInt(); while(q-->0){ int
		 * len=sc.nextInt(); int[] ch=new int[26]; boolean chk=false; for(int
		 * i=0;i<str.length()-len+1;i++){ String sub=str.substring(i, i+len);
		 * System.out.println(sub); boolean p=method(sub); if(p){ chk=true; //
		 * break; } } System.out.println(chk?len:-1);
		 */
	}

	private static void stones(FastReader sc) {
		int x = sc.nextInt(),ans=0;
		int[] aa = { 1, 4, 8, 9, 16, 25, 27, 32, 36, 49, 64, 81, 100, 121, 125, 128, 144, 169, 196, 216, 225, 243, 256,
				289, 324, 343, 361, 400, 441, 484, 512, 529, 576, 625, 676, 729, 784, 841, 900, 961, 1000 };
		for(int i=0;i<aa.length;i++){
			if(aa[i]<=x){
				ans=aa[i];
			} else{
				break;
			}
		}
		System.out.println(ans);
	}
}

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

int main(){

ios::sync_with_stdio(false);
  cin.tie(0);
	
int n,k;
cin>>n>>k;
int arr[n];
for(int i=0;i<n;i++){
	cin>>arr[i];
}

vector<int> dp(k+1,0);

for(int i=1;i<=k;i++){
	for(int j=0;j<n;j++){
		if( i-arr[j]>=0 && dp[i-arr[j]]==0 ){
			dp[i]=1;
		}
	}
}
if(dp[k])cout<<"First";
else cout<<"Second";

}

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

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

    long long sum = 0;
    int tmp;
    for (int i = 0; i < m; i++) {
        cin >> tmp;
        sum += tmp;
    }

    if (sum > n) {
        cout << -1 << endl;
    } else {
        cout << n - sum << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3652
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;

static const int MAX = 100000;
int n;

class DoT {
	vector<pair<int, int> > G[MAX]; //??£??\?????¨??????
	vector<pair<int, int> > dis; //index, distance
	int parent[MAX];
public:
	void setG(int s, int t, int w) {
		G[s].push_back(make_pair(t, w));
		G[t].push_back(make_pair(s, w));
	}

	void bfs(int start) {
		for (int i = 0; i < n; i++) {
			parent[i] = -1;
		}

		queue<pair<int, int> > Q; //dis
		Q.push(make_pair(start, 0));
		while (!Q.empty()) {
			pair<int, int> q = Q.front();
			dis.push_back(q);
			Q.pop();
			int u = q.first;
			for (int v = 0; v < G[u].size(); v++) {
				if (G[u][v].first != parent[u]) {
					Q.push(make_pair(G[u][v].first, q.second + G[u][v].second));
					parent[G[u][v].first] = u;
				}
			}
		}
	}

	int maxdis() {
		int maxd = 0, index;
		for (int i = 0; i < dis.size(); i++) {
			if (maxd < dis[i].second) {
				maxd = dis[i].second;
				index = i;
			}
		}
		return index;
	}

	int ans() {
		bfs(0);
		int x = maxdis();
		dis.clear();
		bfs(x);
		int maxd = 0;
		for (int i = 0; i < dis.size(); i++) {
			maxd = max(maxd, dis[i].second);
		}
		return maxd;
	}
};

int main() {
	cin >> n;
	DoT dot = DoT();
	int s, t, w;
	for (int i = 0; i < n - 1; i++) {
		cin >> s >> t >> w;
		dot.setG(s, t, w);
	}

	cout << dot.ans() << endl;

	return 0;
}

Measured memory_bytes: 9124
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define ALL(a) (a).begin(), (a).end()
const ll mod = 1e9 + 7;

int main()
{
    string s;
    cin >> s;
    int n = s.length(), flag = 0;
    rep(i, n)
    {
        int cntr = 0, cntl = 0;
        while (true)
        {
            if (s[i] == 'L')
                break;
            i++;
        }
        while (i < n)
        {
            if (s[i] == 'R')
            {
                i--;
                break;
            }
            i++;
        }
        string str = s.substr(flag, i + 1 - flag);
        flag = i + 1;
        rep(j, str.length())
        {
            if (str[j] == 'R')
                cntr++;
            else
                cntl++;
        }
        rep(j, cntr - 1)
        {
            cout << 0 << " ";
        }
        if (cntr % 2 == 1)
        {
            cout << cntr / 2 + 1 + cntl / 2 << " ";
        }
        else
        {
            cout << cntr / 2 + cntl / 2 << " ";
        }
        if (cntl % 2 == 1)
        {
            cout << cntr / 2 + cntl / 2 + 1 << " ";
        }
        else
        {
            cout << cntr / 2 + cntl / 2 << " ";
        }
        rep(j, cntl - 1)
        {
            cout << 0 << " ";
        }
    }
    cout << endl;
    return 0;
}

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

int n;
int planA(int a){
    return a*n;
}

int planB(int b){
    return b;
}

int main (){
    int a, b;
    cin >> n >> a >> b;
    if(planA(a)<=planB(b)){
        cout << planA(a);
    }else{
        cout << planB(b);
    }
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
using ll = long long;
using ld = long double;

#define ALL(x) begin(x), end(x)
#define REP(i, n) for (size_t i = 0, i##_len = (n); i < i##_len; ++i)

void solve(string S) {
  cout << S.substr(0,S.size()-8) << endl;
}

int main() {
  string S;
  cin >> S;
  solve(S);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define PI 3.14159265359
#define sz(c) (int)c.size()
#define len(c) (int)c.length()
#define hcf(a, b) __gcd(a, b)
#define all(c) c.begin(), c.end()
#define vint vector<int>
#define vll vector<ll>
#define vpint vector<pair<int, int>>
#define vpll vector<pair<ll, ll>>
#define fr(it, a, b) \
    for (int it = (a); it < (b); it++)
#define tr(c, it) \
    for (auto it = c.begin(); it != c.end(); it++)
#define cpresent(c, e) (find(all(c), e) != c.end())
#define present(c, e) (c.find(e) != c.end())
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef unsigned long long lu;
const ll mod = 1e9 + 7;
int32_t main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int x;
    cin >> x;
    cout << (x >= 30 ? "Yes" : "No") << "\n";
    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
using namespace std;
int main(){
 
  int n;
  cin>>n;
  
  if(n ==1) cout<< "Hello World"<<endl;
  else {
   
    int a,b;
    cin>>a>>b;
    cout<<a+b<<endl;
    
  }
  
  return 0;
  
}

Measured memory_bytes: 256
#pragma GCC optimize("-O3")

#include <bits/stdc++.h>

using namespace std;

#define ll long long

//#define TEST

int index_inv[1000001]; // iが何番目か

signed main() {
	int n; cin >> n;
	vector<ll> p(n);
	for (int i = 0; i < n; ++i) {
		cin >> p[i];
		index_inv[p[i]] = i;
	}

	ll ans = 0;
	set<int> big_index_inv; // 自分より大きい奴のインデックス
	big_index_inv.insert(index_inv[n]);
	big_index_inv.insert(n);
	big_index_inv.insert(n + 1);
	set<int> big_index_inv_inv;
	big_index_inv_inv.insert(-index_inv[n]);
	big_index_inv_inv.insert(1);
	big_index_inv_inv.insert(2);
	for (int i = n - 1; i > 0; --i) {
		int ind = index_inv[i];// iのインデックス
		int r1 = *(big_index_inv.upper_bound(ind));
		int r2 = *(big_index_inv.upper_bound(r1));
		int l1 = -*(big_index_inv_inv.upper_bound(-ind));
		int l2 = -*(big_index_inv_inv.upper_bound(-l1));
#ifdef TEST
		cout << i << " : " << endl;
		for (auto ii : big_index_inv)
			cout << ii << " ";
		cout << endl;
		cout << "ind : " << ind << endl;
		cout << l2 << " " << l1 << " " << r1 << " " << r2 << endl;
#endif
		ll c = 0;
		bool r_ok = r1 != n;
		bool l_ok = l1 != -1;
		if (r_ok && l_ok) {
			c = ((ll)l1 - l2) * ((ll)r1 - ind) + ((ll)r2 - r1) * ((ll)ind - l1);
		}
		else if (r_ok) {
			c = ((ll)ind + 1) * ((ll)r2 - r1);
		}
		else if (l_ok) {
			c = (n - (ll)ind) * ((ll)l1 - l2);
		}
#ifdef TEST
		cout << "c : " << c << endl;
#endif
		ans += i * c;
		big_index_inv.insert(ind);
		big_index_inv_inv.insert(-ind);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 10752
#include<bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <stack>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;
//typedef tree<int, nuint_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> new_data_set; 
#define int long long
#define MOD 1000000007
#define what_is(x) cerr << #x << " is " << x << endl;
#define loop(i,a,n) for(int i=a;i<n;i++)

#define pb emplace_back
#define mp make_pair
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, szof(x))
#define sortall(x) sort(aint(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
typedef pair<int, int> pt;
unordered_map<int, int> used;
 
int arr[200010],q;
vector<int> arr1(200010);

signed main() {
	
	fastio();
	//#define LOCAL_DEFINE
	#ifdef LOCAL_DEFINE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
	//https://codeforces.com/contest/1084/problem/D
	int a,b,n;
	cin>>a>>b>>n;
	cout<<b*(n/a)<<endl;	
	return  0;


}


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

int64_t luca(int n, vector<int64_t> &vec) {
  if (vec.at(n) <= 0) vec.at(n) = luca(n-1, vec) + luca(n-2, vec);
  return vec.at(n);
}

int main() {
  int N;
  cin >> N;
  
  vector<int64_t> vec(87, 0);
  vec.at(0) = 2;
  vec.at(1) = 1;
  
  cout << luca(N, vec) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { 
  INIT(){cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


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

  vector<int> A(N);
  REP(i, N) cin >> A[i];

  vector<bool> ans(N, false);
  RREP(i, N){
    int cnt = 0;
    for(int j = 1; j*(i+1)-1 < N; j++){
      if(ans[j*(i+1)-1]) cnt++;
    }
    if(cnt%2 != A[i]) ans[i] = true;
  }

  int cnt = 0;
  REP(i, N) if(ans[i]) cnt++;
  cout << cnt << "\n";
  REP(i, N) if(ans[i]) cout << i+1 << "\n";


  return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,count=0;
  string s,t;
  cin>>n>>s>>t;
  for(int i=1; i<=n; i++){
    if(s.substr(n-i,i)==t.substr(0,i)){//substr(開始地点,取り出す長さ)
      count=i;
    }
  }
  cout<<n*2-count<<'\n';
  return 0;
}



Measured memory_bytes: 256
# coding: utf-8

N = input()
v = [int(i) for i in input().split()]
c = [int(i) for i in input().split()]
vc = [_v - _c for _v, _c in zip(v, c)]

sum = 0
for _vc in vc:
    if _vc >0:
        sum += _vc
print(sum)


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

double eps = 1e-9;
double pi = acos(-1);

#define fast_io ios_base::sync_with_stdio(false); cin.tie(0);
#define ll long long
#define en "\n"
#define ff first
#define ss second
#define sp(x) fixed << setprecision(x)
#define VECT(v)  vector<int>v
#define SCAN(v)  int temp; for(int i=0; i<n; i++) {cin>>temp; v.push_back(temp);}
#define PRINT(v) for(int i = 0; i < v.size(); i++) cout << v[i] << " "; cout << en;
#define SORT(v)  sort(v.begin(), v.end());
#define RSORT(v) sort(v.begin(), v.end(), greater<>())
#define CASEP(v) cout<<"Case "<<tc<<": "<<v<<"\n"
#define DEBUG(v) cout << v << " "; cout << en;

string check(string a, string b)
{
	string ans = "";

	if(a.size() > b.size())
	{
		ans = "GREATER";
		return ans;
	}
	else if(a.size() < b.size())
	{
		ans = "LESS";
		return ans;
	}
	else
	{
		ll len = a.size();
		for(int i = 0; i < len; i++)
		{
			if(a[i] > b[i])
			{
				ans = "GREATER";
				return ans;
			}
			else if(a[i] < b[i])
			{
				ans = "LESS";
				return ans;
			}
			else
				ans = "EQUAL";
		}
		return ans;
	}
}

int main(void)
{
	#ifndef ONLINE_JUDGE
		freopen("in.txt", "r", stdin);
		freopen("out.txt", "w", stdout);
	#endif

	fast_io

	string a, b;
	cin >> a >> b;

	cout << check(a, b) << en;

	return 0;
}

Measured memory_bytes: 3600
#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<52;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const vi emp;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,-0};
const int DX[8]={-1,-1,-1,0,0,1,1,1},DY[8]={1,0,-1,1,-1,1,0,-1};

map<int,ll> m;

void Prime_Factor(int n){
	for(int i=2;i*i<=n;i++) while(n%i==0){
		m[i]++;
		n/=i;
	}
	if(n!=1) m[n]++;
}

int n;

int main(){
	cin>>n;
	for(int i=2;i<=n;i++) Prime_Factor(i);
	ll ans=1;
	for(auto i=m.begin();i!=m.end();i++){
		(ans*=(i->second+1))%=mod;
	}
	cout<<ans<<endl;
}

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

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

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

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

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

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

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

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
use std::collections::HashMap;
use std::cmp::{max,min};
const DIV:usize = 1000000007;
fn main(){
    input!{
        h:usize,
        w:usize,
        sn:[chars;h],
    }
    let mut field:Vec<Vec<usize>> = vec![vec![0;w];h];
    for j in 0..h {
        let mut done = vec![false;w];
        for k in 0..w {
            if sn[j][k] == '#'{continue;}
            if done[k] {continue;}
            let mut c = 0;
            while k+c<w {
                if sn[j][k+c] == '#' {break};
                c +=1;
            }
            for l in 0..c {
                field[j][k+l] += c;
                done[k+l] = true;
            }
        }
    }
    for j in 0..w {
        let mut done = vec![false;h];
        for k in 0..h {
            if sn[k][j] == '#'{continue;}
            if done[k] {continue;}
            let mut c = 0;
            while k+c< h {
                if sn[k+c][j] == '#' {break};
                c +=1;
            }
            for l in 0..c {
                field[k+l][j] += c;
                done[k+l] = true;
            }
        }
    }
    let mut ans = 0;
    for j in 0..h {
        for k in 0..w {
            ans = max(ans,field[j][k]);
        }
    }
    println!("{}",ans-1);
}

Measured memory_bytes: 61692
from itertools import product

def is_light(sw_conn, sw_status, p):
    num_on = 0
    for sw in sw_conn:
        if sw_status[sw] == 1:
            num_on += 1
    return num_on % 2 == p

N, M = [int(x) for x in input().split()]

sw_conn = []
for i in range(M):
    sw_conn.append([int(x)-1 for x in input().split()][1:])

p = [int(x) for x in input().split()]

ans = 0
for sw_status in product(range(2), repeat=N):
    lights = []
    for j in range(M):
        lights.append(is_light(sw_conn[j], sw_status, p[j]))
    if all(lights):
        ans += 1

print(ans)


Measured memory_bytes: 3064
#include <stdio.h>
#include <cmath>
#include <bits/stdc++.h>



using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;


//container util
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)



int main(void){

	int R, G; cin >> R >> G;
	cout << 2*G - R << endl;


	return 0;

}


Measured memory_bytes: 256
/*
    -ensure correct output format
    -ensure printing required output
    -reread the problem statement
  */

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll>pll;
typedef pair<ll,pair<ll,ll>>plll;
#define fastread() (ios_base:: sync_with_stdio(false),cin.tie(NULL));
#define vll(v) v.begin(),v.end()
#define all(x) x.rbegin(),x.rend()
#define min3(a, b, c)   min(a, min(b, c))
#define max3(a, b, c)   max(a, max(b, c))
#define F first
#define S second
#define in  freopen("input.txt", "r", stdin)
#define out  freopen("output.txt", "w", stdout)
#define minheap int,vector<int>,greater<int>
#define pb push_back
#define eb emplace_back
#define ischar(x)  (('a' <= x && x <= 'z') || ('A' <= x && x <= 'Z'))
#define isvowel(ch) ((ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u')||(ch=='A'|| ch=='E' || ch=='I'|| ch=='O'|| ch=='U'))
#define bug cout<<"BUG"<<endl;
const int Max = 2e6 + 10;
const int Mod = 1e9 + 7;
const double PI  =3.141592653589793238463;
bool compare(const pair<ll,ll> &a, const pair<ll,ll> &b)
{
       return (a.first > b.first);
}
ll lcm(ll a,ll b)
{
    if(a==0 || b==0)return 0;

    return a/__gcd(a,b)*b;
}

void input(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)cin>>ara[i];
}
void print(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)
        cout<<ara[i]<<" ";
    cout<<endl;
}


int main()
{

   fastread();

   ll i,j,n,m,p,a,sum=0,k,t,b,c,d,cnt=0,q,l,r;

      bool flag=false;

      string str;

     cin>>n;

     ll mx=0;

     for(i=0; i<n; i++)
     {
         cin>>a;

         mx=max(mx,a);

         sum+=(mx-a);
     }


     cout<<sum<<endl;


}



Measured memory_bytes: 3624
import java.util.Scanner;

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

		n = sc.nextInt();
		for (int i = 0; i < n ;i++) {
			int k = sc.nextInt();
			a = new int[k][k];
			int x = 0;
			int y = k - 1;
			int dir = 1;
			if (k == 1) {
				a[0][0] = 1;
			} else if (k == 2) {
				a[0][0] = 1;
				a[0][1] = 1;
				a[1][0] = 1;
				a[1][1] = 0;
			} else {
				while (true) {
					a[y][x] = 1;
					if (dir == 1) {
						if (y == 0 || (0 <= y - 2 && a[y - 2][x] == 1)) {
							if (a[y][x + 2] == 1 || a[y + 1][x + 1] == 1) {
								break;
							} else {
								dir = 2;
								x++;
							}
						} else {
							y--;
						}
					} else if (dir == 2) {
						if (x == k - 1 || (x + 2 < k && a[y][x + 2] == 1)) {
							if (a[y + 2][x] == 1 || a[y + 1][x - 1] == 1) {
								break;
							} else {
								dir = 3;
								y++;
							}
						} else {
							x++;
						}
					} else if (dir == 3) {
						if (y == k - 1 || (y + 2 < k && a[y + 2][x] == 1)) {
							if (a[y][x - 2] == 1 || a[y - 1][x - 1] == 1) {
								break;
							} else {
								dir = 4;
								x--;
							}
						} else {
							y++;
						}
					} else {
						if (x == 0 || (0 <= x - 2 && a[y][x - 2] == 1)) {
							if (a[y - 2][x] == 1 || a[y - 1][x + 1] == 1) {
								break;
							} else {
								dir = 1;
								y--;
							}
						} else {
							x--;
						}
					}
				}
			}
			System.out.print(enter);
			for (int j = 0; j < k; j++) {
				for (int l = 0; l < k; l++) {
					System.out.print((a[j][l] == 1) ? "#" : " ");
				}
				System.out.println();
			}
			enter = "\n";
		}
	}
}

Measured memory_bytes: 12000
//ようこ
#include<stdio.h>
#include<string.h>

char n[8];

int sw(int a,int b,int c,int ans){
	if(n[a] == n[b] && n[b] == n[c]){
		if(n[a] == 'o'){return 1;}
		if(n[a] == 'x'){return 0;}
	}
	return ans != -1 ? ans : -1;
}

int main(void){
	
	while(scanf("%s",n) != EOF){
		int ans = -1;
		ans=sw(0,1,2,ans);
		ans=sw(3,4,5,ans);
		ans=sw(6,7,8,ans);
		ans=sw(0,4,8,ans);
		ans=sw(2,4,6,ans);
		ans=sw(0,3,6,ans);
		ans=sw(1,4,7,ans);
		ans=sw(2,5,8,ans);
		
		if(ans == 0)printf("x\n");
		else if(ans == 1)printf("o\n");
		else printf("d\n"); 
	}
}

Measured memory_bytes: 948
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>    // abs() for float, and fabs()
using namespace std;
 
int main() {
    int N, ans;
    double T, A, x;
    double temp_ave, min_abs=100000000;
    cin >> N;
    cin >> T >> A;
    vector<double> H;
    for(int i=1; i<=N ; i++){
      cin >> x;
      H.push_back(T - x*0.006);
      temp_ave = T - x*0.006;
      if (abs(A - temp_ave) < min_abs){
        ans=i;
        min_abs = abs(A - temp_ave);
      }
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h> 
#define LL long long
#define clr(x,i) memset(x,i,sizeof(x))
using namespace std;
const int N=2011;
#define pii pair<int,int>
#define x first
#define y second
int n,K,len[N];
bitset<N*50> ok[N];
string s[N],ans;
pii f[2][N*50];
int main()
{
	ios::sync_with_stdio(0);
	cin>>n>>K;
	for(int i=1;i<=n;i++){
		cin>>s[i];
		len[i]=s[i].size();
	}
	ok[n+1][0]=1;
	for(int i=n;i>0;i--){
		ok[i]=ok[i+1]|(ok[i+1]<<len[i]);
//		cout<<i<<' ';
//		for(int j=0;j<=K;j++){
//			ok[i][j]|=ok[i+1][j];
//			if(j+len[i]<=K)ok[i][j+len[i]]|=ok[i+1][j];
//			printf("%d ",ok[i][j]);
//		}
//		cout<<endl;
	}
	int qcnt=0,tcnt=0;
	for(int i=1;i<=n;i++)
	  if(ok[i+1][K-len[i]])
	    f[1][++qcnt]=pii(i,0);
	for(int t=1;t<=K;t++)
	{
		int i=t&1;
//		cout<<' '<<i<<endl;
		qcnt=min(qcnt,K);
//		cout<<qcnt<<"  ";
		char ch='z';
		for(int j=1;j<=qcnt;j++)
		  ch=min(ch,s[f[i][j].x][f[i][j].y]);//cout<<f[i][j].x<<' '<<f[i][j].y<<"  ";
//		cout<<endl;
		ans.push_back(ch);
		int head=n+1;
		for(int j=1;j<=qcnt;j++)
		{
			if(s[f[i][j].x][f[i][j].y]!=ch) continue;
			if(f[i][j].y==len[f[i][j].x]-1)
			  head=min(head,f[i][j].x);
			else
			  f[i^1][++tcnt]=pii(f[i][j].x,f[i][j].y+1);
		}
//		cout<<head<<endl;
		for(int j=head+1;j<=n;j++)
		  if(K-t-len[j]>=0&&ok[j+1][K-t-len[j]])
		    f[i^1][++tcnt]=pii(j,0);
		qcnt=tcnt; tcnt=0;
	}
	cout<<ans<<endl;
	return 0;
}



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

typedef long long ll;
const int maxn = 1e5 + 7;
ll a[maxn];
int n;


int main() {
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> a[i];
    for (int i = 0; i < n; i++) {
        if (a[i] % 2 == 1) {
            cout << "first" << endl;
            return 0;
        }
    }
    cout << "second" << endl;
}

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

int main() {
  
  int n,a,b;
  cin >> n >> a;
  
  b = n / 500;
  
  if ( n - 500 * b <= a ){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  
  
  
}



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

int main() {
  int64_t A,B,N;
  cin >> A >> B >> N;
  if (B <= N){
    if (A%B != 0)
      cout << A - A/B - 1 << endl;
    else
      cout << A - A/B;
  }
  else
    cout << N*A/B << endl;
}


Measured memory_bytes: 3644
#include<stdio.h>
double abs(double t){
	if(t<0)return -t;
	return t;
}
int main(){
	int a;
	while(scanf("%d",&a),a){
		double dist=100000;
		int id;
		for(int i=0;i<a;i++){
			int b;
			double c,d;
			scanf("%d%lf%lf",&b,&c,&d);
			if(abs(d*10000/c/c-22)<dist){
				dist=abs(d*10000/c/c-22);
				id=b;
			}
			//printf("%lf",dist);
		}
		printf("%d\n",id);
	}
}

Measured memory_bytes: 0
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
//#include "MyMath.h"
//#include "DataStructure.h"
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <functional>
#include <stdio.h>
using namespace std;
typedef pair<int, int> p;
const int INF = 1000000000;
int dp[101][10001];
int main(){
	int n, W; cin >> n >> W;
	int *v = new int[n];
	int *w = new int[n];
	int sumv = 0;
	for (int i = 0; i < n; i++) {
		cin >> v[i] >> w[i];
		sumv += v[i];
	}
	fill(dp[0], dp[n + 1], INF);
	dp[0][0] = 0;
	for (int i = 0; i < n; i++)for (int j = 0; j <= sumv; j++) {
		if (v[i] > j) dp[i + 1][j] = dp[i][j];
		else dp[i + 1][j] = min(dp[i][j], dp[i][j - v[i]] + w[i]);
	}
	for(int i = sumv; i >= 0; i--)
		if (dp[n][i] <= W) {
			cout << i << endl;
			break;
		}
	delete[] v, w;
	return 0;
}

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

long long n, x, a[100], ta = 0;

int main() {
	cin >> n >> x;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a, a + n);
	for (int i = 0; i < n; i++) {
		if (x >= a[i]) {
			x = x - a[i];
			ta++;
		}
		else {
			break;
		}
	}
	if (x > 0 && n == ta) {
		ta--;
	}
	cout << ta << endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;

class SlideRangeQuery {
 public:
  using Compare = function<bool(int, int)>;

 private:
  Compare comp;
  deque<int> deq;
  int x = 0;

 public:
  SlideRangeQuery(const Compare& comp_) : comp(comp_) {}

  // [a, b)
  int query(int a, int b) {
    while (!deq.empty() && deq.front() < a) {
      deq.pop_front();
    }
    for (x = max(a, x); x < b; x++) {
      while (!deq.empty() && not comp(deq.back(), x)) {
        deq.pop_back();
      }
      deq.push_back(x);
    }
    return deq.empty() ? -1 : deq.front();
  }
};

int main() {
  int M, N, K;
  while (cin >> N >> M >> K) {
    vector<ll> A(N);
    for (int i = 0; i < N; i++) cin >> A[i];
    vector<ll> dp = A;
    for (int i = 2; i <= K; i++) {
      vector<ll> ndp(N);
      SlideRangeQuery sq([&](int a, int b) { return dp[a] > dp[b]; });
      for (int j = i - 1; j < N; j++) {
        ndp[j] = i * A[j] + dp[sq.query(j - M, j)];
      }
      dp = ndp;
    }
    ll res = *max_element(dp.begin(), dp.end());
    cout << res << endl;
  }
  return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
#define int long long
struct P{
  int t,c,x;
  bool f;
  P(){}
  P(int t,int c):t(t),c(c){x=f=0;}
  bool operator<(const P a)const{
    return t>a.t;
  } 
};
signed main(){
  int n;
  while(cin>>n,n){
    int t[n],c[n];
    for(int i=0;i<n;i++) cin>>t[i]>>c[i];
    priority_queue<P> q[2];
    for(int i=0;i<n;i++) q[0].push(P(t[i],c[i]*2-1));
    deque<P> v[2];
    while(!q[0].empty()){
      v[0].push_back(q[0].top());q[0].pop();
    }
    int ans=0;
    while(!v[0].empty()||!v[1].empty()){
      ans++;
      for(int k=0;k<2;k++){
	for(int i=0;i<(int)v[k].size();i++){
	  v[k][i].x++;
	  P p=v[k][i];
	  if((!i&&p.x>=p.t)||(i&&v[k][i-1].f&&p.x>=p.t)){
	    //cout<<ans<<":"<<k<<":"<<i<<" "<<p.t<<" "<<p.x<<" "<<p.c<<endl;
	    v[k][i].f=1;
	    if(p.c){
	      p.x=0;
	      p.c--;
	      q[!k].push(p);
	    }
	  }
	}
	while(!v[k].empty()&&v[k].front().f) v[k].pop_front();
      }
      for(int k=0;k<2;k++){
	while(!q[k].empty()){
	  v[k].push_back(q[k].top());q[k].pop();
	}
      }
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 3108
#include <iostream>
using namespace std;
    int main(){
    int X,A,B;
    cin >> X >> A >> B;
    if(A >= B){
        cout << "delicious" << endl;
    }else if(A+X >= B){
        cout << "safe" << endl;
    }else{
        cout << "dangerous" << endl;
    }
    }

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repo(i, n) for(int i=1; i<=n; i++)
#define ssort(a) sort(a.begin(), a.end())
#define INF 1001001001
#define INFll 100100100100100
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << endl;

using namespace std;
using ull = unsigned long long;
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;

int main(){
  ll n, a,b;
  cin >> n >> a >> b;
  vector<ll> h(n);
  vector<ll> h2(n);
  rep(i, n){
    cin >> h[i];
  }
  ll l=0, r=1e9;
  while(l+1<r){
    h2=h;
    ll m=(r+l)/2;
    rep(i, n){
      h2[i]-=b*m;
    }
    ll num=0;
    rep(i, n){
      if(h2[i]>0){
        num+=(h2[i]-1)/(a-b)+1;
      }
    }
    if(num<=m){
      r=m;
    } else {
      l=m;
    }
  }
  cout << r << endl;
  return 0;
}


Measured memory_bytes: 4844
#include <bits/stdc++.h>
#define ios ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
using namespace std;
typedef long long ll;
const int maxn = 1e5+7,mod = 1e9+7;
ll n,p,ans = 1;
ll Pow(ll a,int b,ll ans = 1){
    for(;b;b>>=1,a *= a)
        if(b&1)
            ans *= a;
    return ans;
}
int main(){
    ios;
    cin>>n>>p;
    for(ll i=2;i*i<=p;i++){
        if(p%i)continue;
        int cnt = 0;
        while(p%i==0)
            cnt++,p/=i;
        ans *= Pow(i,cnt/n);
    }
    if(p!=1){
        if(n == 1)
            ans *= p;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O2")

#include <bits/stdc++.h>
#ifdef DEBUG
	#include "debug.hpp"
#endif

using namespace std;

#define all(c) (c).begin(), (c).end()
#define traverse(c, it) for(auto it = (c).begin(); it != (c).end(); it++)
#define rep(i, N) for(int i = 0; i < (N); i++)
#define rep1(i, N) for(int i = 1; i <= (N); i++)
#define rep2(i, s, e) for(int i = (s); i <= (e); i++)
#define rep3(i, s, e, d) for(int i = (s); (d) >= 0 ? i <= (e) : i >= (e); i += (d))
#define pb push_back


#ifdef DEBUG
	#define debug(x...) {dbg::depth++; string dbg_vals = dbg::to_string(x); dbg::depth--; dbg::fprint(__func__, __LINE__, #x, dbg_vals);}
	#define light_debug(x) {dbg::light = 1; dbg::dout << __func__ << ":" << __LINE__ << "  " << #x << " = " << x << endl; dbg::light = 0;}
#else
	#define debug(x...)
	#define light_debug(x) 
#endif


using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;


signed main(){

	ios_base::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);

	#ifdef DEBUG
		freopen("debug", "w", stderr);
	#endif
	
	int X;
	cin >> X;

	cout << 360 / __gcd(X, 360) << '\n';

	#ifdef DEBUG
		dbg::dout << "\nExecution time: " << clock() << "ms\n";
	#endif

	return 0;
}


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

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<ll, ll> P;
typedef vector<P> vP;
int main() {
	int n;
	cin >> n;
	vl X(n), Y(n);
	for (int i = 0; i < n; i++) {
		ll x, y;
		cin >> x >> y;
		X[i] = min(x, y);
		Y[i] = max(x, y);
	}
	ll MIN = X[0], MAX = 0;
	ll xmax = 0;
	ll ymin = Y[0];
	for (int i = 0; i < n; i++) {
		MIN = min(MIN, X[i]);
		MAX = max(MAX, Y[i]);
		xmax = max(xmax, X[i]);
		ymin = min(ymin, Y[i]);
	}
	ll ans = (xmax - MIN)*(MAX - ymin);
	vP xy(n);
	for (int i = 0; i < n; i++) {
		xy[i] = P(X[i], Y[i]);
	}
	sort(xy.begin(), xy.end());
	ll yl = MAX;
	ll yr = MIN;
	ll mlen = min(xmax - MIN,MAX-ymin);
	for (int i = 0; i < n-1; i++) {
		yl = min(yl, xy[i].second);
		yr = max(yr, xy[i].second);
		mlen = min(mlen, max(yr, xmax) - min(xy[i + 1].first, yl));
	}
	ans = min(ans, mlen*(MAX - MIN));
	cout << ans << endl;
}

Measured memory_bytes: 6528
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll N,T; cin >> N >> T;vector<ll> A(N);
  for(ll i = 0; i < N; i++){ cin>> A[i];}
  vector<ll> max_A(N); max_A[N-1] = A[N-1];
  for(ll j = N-2; j >= 0; j--){
    max_A[j] = max( A[j], max_A[j+1]);}
  
  vector<ll> B(N); ll res = -1LL << 60;
  for(ll i = 0; i < N; i++){ B[i] = max_A[i] - A[i]; res = max( res, B[i]);}
  ll cnt = 0;
  for(ll i = 0; i < N; i++){ if(res == B[i]){ cnt++;}}
  
  cout << cnt << endl; return 0;}
  
  
  

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

const int N = 110;

int n, a, b, x, y;
char s[N];

int main(){
	a = b = 0;
	scanf("%d", &n);
	scanf("%s", s);
	x = y = 0;
	for(int i=0; i<n; i++){
        if(s[i] == '('){
            x++;
		} else {
			if(x == 0){
				a++;
			} else {
				x--;
			}
		}
	}
	for(int i=n-1; i>=0; i--){
        if(s[i]==')'){
			y++;
        } else {
			if(y == 0){
				b++;
			} else {
				y--;
			}
        }
	}
	for(int i=0; i<a; i++)	putchar('(');
	printf("%s", s);
	for(int i=0; i<b; i++)	putchar(')');
	puts("");
	return 0;
}


Measured memory_bytes: 256