akhauriyash/Code-Regression huggingface dataset:
S=input()
ans=0
listS=[]
for i in range(len(S)):
    listS.append(int(S[i]))
#print(listS)

for j in range(2**(len(listS)-1)):
    l=j
    list1=[]
    for k in range(len(listS)-1):
        if int(l/(2**(len(listS)-2-k)))==0:
            list1.append("")
        else:
            list1.append("+")
        l=l%(2**(len(listS)-2-k))
    #print(list1)
    SUB=str(listS[0])
    for m in range(len(list1)):
        SUB=SUB+list1[m]+str(listS[m+1])
    #print(eval(SUB))
    ans+=eval(SUB)
print(ans)
        

Measured memory_bytes: 3064
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e18;
const long long int mod = 1e9+7;

typedef pair<ll, ll> pairs;
typedef vector<pairs> p;

struct Edge{
    ll to, weight;
    Edge(ll t, ll w) : to(t), weight(w){}
};
using graph = vector<vector<ll>>;
using Graph = vector<vector<Edge>>;


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

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

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

// 回文
bool kai(string S){
    bool flag = true;
    for(ll i=0;i<S.size()/2;++i){
        if(S[i] != S[S.size()-i-1]){
            flag = false;
            break;
        }
    }
    return flag;
}
// ---------------------------------------------

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

    m /= 2;
    ll k = (m - n) / 2;
    ll ans = min(k + n, m);
    cout<<ans<<endl;

    return 0;
}

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

int main(void) {
    string s;
    cin >> s;
    map<char, int> m;
    for (int i = 0; i < (int)s.size(); i++) {
        m[s.at(i)]++;
    }
    for (char i = 'a'; i <= 'z'; i++) {
        if (m[i] == 0) {
            cout << i << endl;
            return 0;
        }
    }
    cout << "None" << endl;
    return 0;
}

Measured memory_bytes: 3656
def getinput(_debug):
    N = 0
    M = 0
    p = []
    S = []
    
    if _debug == 0:
        N, M = map(int,input().split())
        lines = [input() for x in range(M)]

    elif _debug == 1:
        f = open("3_sample1.txt").readlines()
        f = [x.rstrip() for x in f]
        N, M = map(int,f[0].split())
        lines = f[1:]
    
    elif _debug == 2:
        f = open("3_sample2.txt").readlines()
        f = [x.rstrip() for x in f]
        N, M = map(int,f[0].split())
        lines = f[1:]
    
    elif _debug == 3:
        f = open("3_sample3.txt").readlines()
        f = [x.rstrip() for x in f]
        N, M = map(int,f[0].split())
        lines = f[1:]
    
    # データ取得
    for l in lines:
        ls = l.split(" ")
        p.append(int(ls[0]))
        S.append(ls[1])

    return N,M,p,S

N,M,p,S = getinput(0)

AC = [0] * N  # 実施した問題数は1,まだの場合0
WA = [0] * N  # ペナルティのカウント
wa = 0

#       
for i in range(M):
    q = int(p[i]) - 1
    if AC[q] == 0 and S[i] == "AC":
        AC[q] = 1
        wa += int(WA[q])
    WA[q] += 1        

print("%d %d"%(sum(AC),wa))

Measured memory_bytes: 20524
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

x,y=mii()
cnt=10**10

#0-0
a,b=x,y
if b-a>=0:
    cnt=min(cnt,b-a)

#1-0
a,b=-x,y
if b-a>=0:
    cnt=min(cnt,b-a+1)

#0-1
a,b=x,-y
if b-a>=0:cnt=min(cnt,b-a+1)

#1-1
a,b=-x,-y
if b-a>=0:cnt=min(cnt,b-a+2)
print(cnt)

Measured memory_bytes: 65388
var a:array[1..4] of integer;n1,n2,n3,n4,s,tmp,i,j:integer;
begin
for i:=1 to 4 do begin
read(a[i]);
end;
for i:=1 to 3 do begin
if(a[i]>a[i+1])then begin
j:=i+1;
while(j>1)do begin
if(a[j-1]>a[j])then begin
tmp:=a[j];
a[j]:=a[j-1];
a[j-1]:=tmp;
end;
j:=j-1;
end;
end;
end;
s:=1000*a[1]+100*a[2]+10*a[3]+a[4];
if(s=1479)then writeln('YES') else writeln('NO');
end.

Measured memory_bytes: 1364
#include<iostream>
using namespace std;
int main(){
    int x,y;
    while(1){
        cin >> x >> y;
        if(x==0 && y==0)break;
        if(x<y){
            cout << x << " " << y << "\n";
        }else{
            cout << y << " " << x << "\n";
        }
    }
    return 0;
}


Measured memory_bytes: 3084
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
using namespace std;
const int Mod=1000000007;
char s[300010];
int l,t[8][2],f[300010][8];
int main()
{
	t[0][0] = 2;
	t[0][1] = 1;
	t[1][0] = 3;
	t[1][1] = 5;
	t[2][0] = 4;
	t[2][1] = 7;
	t[3][0] = 6;
	t[3][1] = 1;
	t[4][0] = 2;
	t[4][1] = 2;
	t[5][0] = 5;
	t[5][1] = 5;
	t[6][0] = 3;
	t[6][1] = 3;
	t[7][0] = 2;
	t[7][1] = 1;
	scanf("%s",s);
	l=strlen(s);
	f[l][1]=f[l][5]=1;
	for (int i=l-1;i>=0;i--)
	{
		for (int j=0;j<8;j++)
		{
			if (s[i]!='1')
			{
				f[i][j]=(f[i][j]+f[i+1][t[j][0]])%Mod;
			}
			if (s[i]!='0')
			{
				f[i][j]=(f[i][j]+f[i+1][t[j][1]])%Mod;
			}
		}
	}
	printf("%d\n",f[0][0]);
    return 0;
}
//汉之广矣，不可泳思。江之永矣，不可方思。
//——《诗经·国风·周南·汉广》

Measured memory_bytes: 9856
N = int(input())
# N, N-7, N-14, N-21 の余りは重複しないので、どれかが必ず4の倍数
# そのため21以上はかならずYes. 21未満は個別に調べればいい
ans = 'No' if N in [1, 2, 3, 5, 6, 9, 10, 13, 17] else 'Yes'
print(ans)  

Measured memory_bytes: 2940
#include <bits/stdc++.h>
int main(){
	
	const int NodeNum = 50;
	const int EdgeNum = 50;
	
	int N, M;
	int ans=0;
	bool visited[NodeNum]={};
	bool nodes[NodeNum][EdgeNum] = {};
	int a[NodeNum], b[NodeNum];
	std::queue<int> q;
	
	std::cin >> N >> M;
	for(int i=0;i<M;++i){
		std::cin >> a[i] >> b[i];
		//対応する頂点を紐付ける
		nodes[a[i]-1][b[i]-1] = true;
		nodes[b[i]-1][a[i]-1] = true;
	}
	//すべての辺において
	for(int i=0;i<M;++i){
		bool all_visited=true;
		//適当に開始地点を設定する
		q.push(0);
		//全て0(false)にする
		memset(visited,0,sizeof(bool)*NodeNum);
		while(!q.empty()){
			//探索すべき頂点をコピー
			int now = q.front();
			//先頭をデキュー(削除する)
			q.pop();
			//探索済みにする
			visited[now] = true;
			//すべての頂点において
			for(int j=0;j<N;++j){
				//その頂点に行けないなら無視
				if(!nodes[now][j])continue;
				//辺を通れなくする
				if(
					(now==a[i]-1&&j==b[i]-1) ||
					(now==b[i]-1&&j==a[i]-1)
				)continue;
				//未訪問なら
				if(!visited[j]){
					//探索地点として追加
					q.push(j);
				}
			}
		}
		//すべて訪問済みかどうか
		for(int j=0;j<N;++j){
			if(!visited[j]){
				all_visited = false;
				break;
			}
		}
		//訪問できていなければその辺は橋であった
		if(!all_visited)++ans;
	}
	std::cout << ans << std::endl;
}

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


using namespace std;



int f(int a, int b)
{
    int r = a % b;
    if (r == 0) {
        return b;
    }
    else {
        return f(b,r);
    }
}

vector< int64_t > divisor(int64_t n) 
{
  vector< int64_t > ret;
  for(int64_t i = 1; i * i <= n; i++) {
    if(n % i == 0) {
        //cout << i << endl;
      ret.push_back(i);
      if(i * i != n) {
          //cout << i << endl;
          ret.push_back(n / i);
      }
    }
  }
  sort(begin(ret), end(ret),greater<int>());
  return (ret);
}

int main() 
{

    int A,B,K;
    cin >> A >> B >> K;
    int c = f(A, B);

    auto v = divisor(c);

    cout << v[K-1] << endl;

    return 0;    
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
#define mod 1000000007
#define chmax(a,b) a=max(a,b)
#define chmin(a,b) a=min(a,b)
ll n,m;
vector<pair<ll,ll> >v;
int main(){
  cin>>n>>m;
  for(int i=0;i<n;i++){
      ll l,r; cin>>l>>r;
      v.push_back(make_pair(l,0));
      v.push_back(make_pair(r,1));
  }
  sort(v.begin(),v.end());
  ll cnt=0,ma=0;
  for(int i=0;i<v.size();i++){
      if(v[i].second==0)cnt++;
      else cnt--;
      chmax(ma,cnt);
  }
  cnt=0;
  if(ma%2==0){
      ll res=1e17;
      for(int i=0;i<v.size();i++){
	  if(v[i].second==0)cnt++;
	  else cnt--;
	  if(ma==cnt)chmin(res,v[i].first);
      }
      cout<<(ma-1)*m+m-res<<endl;
  }
  if(ma%2==1){
      ll res=-1;
      for(int i=0;i<v.size()-1;i++){
	  if(v[i].second==0)cnt++;
	  else cnt--;
	  if(ma==cnt)chmax(res,v[i+1].first);
      }
      cout<<(ma-1)*m+res<<endl;
  }
  return 0;
}



Measured memory_bytes: 11216
n, c, k = map(int, input().split())
t = [int(input()) for _ in range(n)]
t.sort()

ans = 1

earl = t[0]
count = 0
for i in range(n):
    if t[i]-earl > k or count == c:
        count = 0
        earl = t[i]
        ans += 1
    count += 1

print(ans)

Measured memory_bytes: 7384
#include<bits/stdc++.h>
using namespace std;
using Int = long long;

template<typename T1,typename T2> void chmin(T1 &a,T2 b){if(a>b) a=b;};
template<typename T1,typename T2> void chmax(T1 &a,T2 b){if(a<b) a=b;};


signed main(){
  int n;
  string s;
  
  while(cin>>n>>s,n){
    using ull = unsigned long long;
    ull m=0;

    auto calc=[](char c){if(isdigit(c)) return c-'0';return c-'A'+10;};
  
    for(int i=0;i<(int)s.size();i++){
      m=m*n+calc(s[i]);
    }

    using P = pair<int, int>;
    vector<P> vp;
    int k=n;
    for(int i=2;i<=50;i++){
      if(k%i) continue;
      vp.emplace_back(i,0);
      while(k%i==0) k/=i,vp.back().second++;
    }
  
    ull ans=m;

    for(auto p:vp){
      ull k=p.first;
      ull res=0;
      while(k<=m){
	res+=m/k;
	if(k>=ULLONG_MAX/p.first-1) break;
	k*=p.first;
      }
      chmin(ans,res/p.second);
    }
  
    cout<<ans<<endl;
  }
  return 0;
}



Measured memory_bytes: 3160
#define _USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <queue>
#include <stack>
#include <deque>
#include <climits>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
//#include <tuple>

#define break break
#define continue continue
#define INF INT_MAX>>1 
#define SIZE 100010
#define MOD 1000000007
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define rep2(i, from, to) for(int i=(from); i<(int)(to); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define LLPair pair<ll, ll>
#define vint vector<int>
#define vll vector<ll>
typedef long long ll;

using namespace std;


int main(void){
	string s1, s2; cin>> s1 >> s2;
	cout << s2 << s1 << endl;
	return 0;
}

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

bool first_cmp(pair<ll,ll> a,pair<ll,ll> b){
    if(a.first != b.first)
        return a.first < b.first;
    else
        return a.second < b.second;
}

int main(){
    ll n;
    cin >> n;
    vector<pair<ll,ll>> a(n);
    for(ll i=0; i<n ;++i){
        cin >> a[i].first;
        a[i].second = i+1;
    }
    sort(a.begin(),a.end(),first_cmp);

    for(ll i=0; i<n ; ++i)cout << a[i].second << " ";

    return 0;
}

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


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


		// 読み込み
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;
		String[] temp;

		line=br.readLine();
		temp=line.split(" ");

		int a = Integer.valueOf(temp[0]);
		int b = Integer.valueOf(temp[1]);
		int c = Integer.valueOf(temp[2]);


		if (b-a == c-b){
			System.out.println("YES");
		}else{
			System.out.println("NO");
		}

	}
}


Measured memory_bytes: 21460
import sys
from collections import deque
input = sys.stdin.buffer.readline

N = int(input())
adj = [[] for _ in range(N+1)]
for _ in range(N-1):
    a, b = map(int, input().split())
    adj[a].append(b)
    adj[b].append(a)

que = deque()
que.append(1)
seen = [0] * (N+1)
seen[1] = 1
par = [0] * (N+1)
child_num = [0] * (N+1)
while que:
    v = que.popleft()
    for u in adj[v]:
        if seen[u] == 0:
            seen[u] = 1
            par[u] = v
            child_num[v] += 1
            que.append(u)

seq = deque()
for i in range(1, N+1):
    if child_num[i] == 0:
        seq.append(i)

while seq:
    c = seq.pop()
    seen[c] = 0
    if seen[par[c]] == 0:
        print('First')
        exit()
    seen[par[c]] = 0
    child_num[par[par[c]]] -= 1
    if child_num[par[par[c]]] == 0:
        seq.append(par[par[c]])

print('Second')


Measured memory_bytes: 60192
fun main (args : Array<String>) {
    readLine()!!
    val list = readLine()!!.split(" ")

    var aList : MutableList<Int> = mutableListOf()
    var flag : Boolean = true

    for (i in list) {
        if ( (i.toInt() % 2) == 0) {
            aList.add(i.toInt())
        }
    }

    for (i in 0..aList.size - 1) {
        if ( (aList[i] % 3 != 0) && (aList[i] % 5 != 0) ) {
            flag = false
            break
        }
    }

    if (flag) {
        println("APPROVED")
    } else {
        println("DENIED")
    }

}

Measured memory_bytes: 37936
import numpy as np

N, K = map(int, input().split())
A = np.array([int(x) for x in input().split()])
B = np.zeros(N)
C = np.zeros(N)
pos = 0
# B[0] = 1
for i in range(N*2):
    if i + 1 == K:
        print(A[pos])
        exit()
    B[pos] += 1
    if C[pos] == 0:
        C[pos] = i+1
    pos = A[pos] - 1

ans = K - len(B[B <= 1]) + len(B[B == 0])
ans %= len(B[B > 1])
D = sorted(C[B > 1])
tmp = D[ans]
index = np.where(C == tmp)
print(*index[0] + 1)

Measured memory_bytes: 51068
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#include "boost/multiprecision/cpp_int.hpp"
//typedef boost::multiprecision::cpp_int LL;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"
#define SORT(v) sort(v.begin(),v.end())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define POSL(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define POSU(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

void mod_print(ll k){
    ll P=1000;
    rep(y,1,P){
        ll x=mod(y*k);
        if(x+P>=i_7){
            x-=i_7;
        }
        if(abs(x)<=P){
            cout<<x<<"/"<<y<<endl;
            return;
        }
    }
    cout<<"nun"<<endl;
}
//////////////////////////


#define N 200005
ll n;
vector<ll>v[N];
l_l val[N];
ll gk[N];
void dfs(ll pos,ll par){
    for(auto x:v[pos]){
        if(x==par)continue;
        dfs(x,pos);
        chmax(val[pos].fi,val[x].fi-1);
        chmin(val[pos].se,val[x].se+1);
    }
    if(val[pos].fi>val[pos].se){
        cout<<"No";exit(0);
    }
}
void gks(ll pos,ll par){
    for(auto x:v[pos]){
        if(x==par)continue;
        gks(x,pos);
        if(gk[x]!=-1){
            if(gk[pos]==-1)gk[pos]=1-gk[x];
            else{
                if(gk[pos]+gk[x]!=1){
                    cout<<"No";exit(0);
                }
            }
        }
    }
}

int main(){fastio
    cin>>n;
    rep(i,1,n-1){
        ll a,b;cin>>a>>b;
        v[a].pb(b);
        v[b].pb(a);
    }
    ll k;cin>>k;
    rep(i,1,n)val[i]={-inf,inf};
    memset(gk,-1,sizeof(gk));
    while(k--){
        ll a,b;cin>>a>>b;
        val[a]={b,b};
        gk[a]=b%2;
    }
    gks(1,-1);
    dfs(1,-1);
    cout<<"Yes"<<endl;
    queue<ll>q;q.push(1);
    ll ans[N];rep(i,1,n)ans[i]=inf;
    ans[1]=val[1].fi;
    while(!q.empty()){
        ll t=q.front();q.pop();
        for(auto x:v[t]){
            if(ans[x]!=inf)continue;
            chmax(val[x].fi,val[t].fi-1);
            ans[x]=val[x].fi;
            q.push(x);
        }
    }
    rep(i,1,n)cout<<ans[i]<<endl;
    
    return 0;
}


Measured memory_bytes: 20480
n = int(input())

arr = [[0 for i in range(n)] for j in range(26)]

for i in range(n):
	s = list(raw_input())
	for t in s:
		arr[ord(t) - ord("a")][i] += 1
ans = ''
for i in range(26):
	ans += chr(ord("a") + i) * min(arr[i])

print ans


Measured memory_bytes: 2568
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;cin>>n;
    set<int>s;
    for(int i=0;i<n;i++)
    {
        int x;cin>>x;s.insert(x);
    }
    if(s.size()==n)
        cout<<"YES\n";
    else
        cout<<"NO\n";
}


Measured memory_bytes: 9600
object Main{
    def main(args:Array[String]) = {
    val sc = new java.util.Scanner(System.in)
    val n = sc.nextInt()
    val array = new Array[(Long, Long)](n)
    for (i <- 0 until n) {
      val a = sc.nextLong()
      val b = sc.nextInt()
      array(i) = (a, b)
    }

    val sorted = array.sortBy(_._2)

    var time : Long = 0

    for(i <- 0 until n){
        time += sorted(i)._1
        if(time > sorted(i)._2){
            println("No")
            sys.exit()
            }
        }
    println("Yes")
    }
}
// why is this CE ?

Measured memory_bytes: 129364
import java.util.*;
import java.util.function.*;
import java.util.stream.*;

public class Main{
	Scanner s=new Scanner(System.in);

	void solve(){
		int n=gInt();
		int m=gInt();
		System.out.println(n*(n-1)/2+m*(m-1)/2);
	}

	public static void main(String[] A){
		new Main().solve();
	}

	int gInt(){
		return Integer.parseInt(s.next());
	}
	long gLong(){
		return Long.parseLong(s.next());
	}
	double gDouble(){
		return Double.parseDouble(s.next());
	}

	SupplyingIterator<Integer> ints(int n){
		return new SupplyingIterator<>(n,this::gInt);
	}
	SupplyingIterator<Long> longs(int n){
		return new SupplyingIterator<>(n,this::gLong);
	}
	SupplyingIterator<Double> doubles(int n){
		return new SupplyingIterator<>(n,this::gDouble);
	}
	SupplyingIterator<String> strs(int n){
		return new SupplyingIterator<>(n,s::next);
	}

	Range rep(int i){
		return Range.rep(i);
	}
	Range rep(int f,int t,int d){
		return Range.rep(f,t,d);
	}
	Range rep(int f,int t){
		return rep(f,t,1);
	}
	Range rrep(int f,int t){
		return rep(t,f,-1);
	}

	IntStream REP(int v){
		return IntStream.range(0,v);
	}
	IntStream REP(int l,int r){
		return IntStream.rangeClosed(l,r);
	}

	IntStream INTS(int n){
		return IntStream.generate(this::gInt).limit(n);
	}
	LongStream LONGS(int n){
		return LongStream.generate(this::gLong).limit(n);
	}
	Stream<String> STRS(int n){
		return Stream.generate(s::next).limit(n);
	}

}

class SupplyingIterator<T> implements Iterable<T>,Iterator<T>{
	int t;
	Supplier<T> supplier;

	SupplyingIterator(int t,Supplier<T> supplier){
		this.t=t;
		this.supplier=supplier;
	}

	@Override
	public Iterator<T> iterator(){
		return this;
	}

	@Override
	public boolean hasNext(){
		return t>0;
	}

	@Override
	public T next(){
		--t;
		return supplier.get();
	}

}

class Range implements Iterable<Integer>,PrimitiveIterator.OfInt{
	int to,cur,d;

	Range(int from,int to,int d){
		this.cur=from-d;
		this.to=to;
		this.d=d;
	}

	Range(int n){
		this(0,n-1,1);
	}

	@Override
	public Iterator<Integer> iterator(){
		return this;
	}

	@Override
	public boolean hasNext(){
		return (cur+d==to)||(d<0^cur+d<to);
	}

	@Override
	public int nextInt(){
		return cur+=d;
	}
	static Range rep(int i){
		return new Range(i);
	}
	static Range rep(int f,int t,int d){
		return new Range(f,t,d);
	}
	static Range rep(int f,int t){
		return rep(f,t,1);
	}
	static Range rrep(int f,int t){
		return rep(f,t,-1);
	}
}


Measured memory_bytes: 23764
#include <iostream>

using namespace std;

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

    int n;
    cin >> n;

    long long sum = 0;
    for (int i = 1; i <= n; i++) {
        if (i % 3 != 0 && i % 5 != 0) {
            sum += i;
        }
    }

    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 3160
import java.io.*;
import java.math.*;
import java.util.*;

public class Main {
    private static boolean debug = false;
    private static boolean elapsed = false;

    private static PrintWriter _out = new PrintWriter(System.out);
    private static PrintWriter _err = new PrintWriter(System.err);

    private void solve(Scanner sc) {
        StringBuilder sb = new StringBuilder(sc.next());
        String s1 = sb.toString();
        String s2 = sb.reverse().toString();
        if (s1.equals(s2)) {
            _out.println("Yes");
        } else {
            _out.println("No");
        }
    }
    private static BigInteger C(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        for (long i = r; i > 1; --i) {
            res = res.divide(BigInteger.valueOf(i));
        }
        return res;
    }
    private static BigInteger P(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        return res;
    }
    /*
     * 10^10 > Integer.MAX_VALUE = 2147483647 > 10^9
     * 10^19 > Long.MAX_VALUE = 9223372036854775807L > 10^18
     */
    public static void main(String[] args) {
        long S = System.currentTimeMillis();

        Scanner sc = new Scanner(System.in);
        new Main().solve(sc);
        _out.flush();

        long G = System.currentTimeMillis();
        if (elapsed) {
            _err.println((G - S) + "ms");
        }
        _err.flush();
    }
}

Measured memory_bytes: 21844
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
#include <random>
#include <string.h>
#include <cmath>
#include <unordered_map>
#include <cstdio>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 998244353
#define int long long
#define P pair<int,int>
#define all(vec) vec.begin(),vec.end()

int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}

int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}

int n, a[100010];
int cum[100010];
int ans = 1, cnt = 1;

signed main() {
	cin >> n;
	for (int i = 0; i <= n; i++)cin >> a[i];
	for (int i = n; i >= 0; i--)cum[i] = cum[i + 1] + a[i];
	if (n&&a[0]) {
		cout << -1 << endl;
		return 0;
	}
	if (1 < a[0]) {
		cout << -1 << endl;
		return 0;
	}
	for (int i = 1; i <= n; i++) {
		if (cnt * 2 < a[i]) {
			cout << -1 << endl;
			return 0;
		}
		cnt = min(2 * cnt, cum[i]);
		ans += cnt;
		cnt -= a[i];
	}
	cout << ans << endl;
}

Measured memory_bytes: 5240
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define DEBUG
#ifdef DEBUG
#define debug_printf printf
#else
#define debug_printf 1 ? 0 : printf
#endif

using namespace std;
typedef long long int ll;
typedef vector<ll> Vl;
typedef vector<int> Vi;
typedef pair<int, int> Pi;

#define FST first
#define SND second

#define MAX_N   (100000)                  // 10^5
// #define MAX_N   (1000000000)              // 10^9
// #define MAX_N   (1000000000000000000)     // 10^18
#define BASE    (1000000000 + 7)          // 10^9 + 7
#define INFI    (1000000000 + 7)          // 10^9 + 7
#define INFL    (1000000000000000000 + 7) // 10^18 + 7

ll N, A, B;

ll solve() {
  if (A > B) return 0;
  if (N == 1) return (A == B)? 1: 0;
  ll mn = (N - 1) * A + B;
  ll mx = A + (N - 1) * B;
  return mx - mn + 1;
}

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

  cout << solve() << endl;

  return 0;
}


Measured memory_bytes: 256
// 動的計画法

#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <climits>
#include <cmath>
#include <functional>
#include <map>
#include <queue>
#include <set>
#include <stack>

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define size_t unsigned long long
#define ll long long
#define rep(i,a) for(int i=0;i<(a);i++)
#define repr(i,a) for(int i=(int)(a)-1;i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(int)(b)-1;i>=a;i--)
#define ALL(a) a.begin(), a.end()
using namespace std;
int si() { int x; scanf("%d", &x); return x; }
long long sl() { long long x; scanf("%lld", &x); return x; }
string ss() { string x; cin >> x; return x; }
void pi(int x) { printf("%d ", x); }
void pl(long long x) { printf("%lld ", x); }
void pd(double x) { printf("%.15f ", x); }
void ps(const string &s) { printf("%s ", s.c_str()); }
void br() { putchar('\n'); }

const int MOD = 1e9 + 7;

struct mint {
    int n;
    mint(int n_ = 0) : n(n_) {}
};

mint operator+(mint a, mint b) { a.n += b.n; if (a.n >= MOD) a.n -= MOD; return a; }
mint operator-(mint a, mint b) { a.n -= b.n; if (a.n < 0) a.n += MOD; return a; }
mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }

const int n_max = 1e5 + 5;

int n,k;
int h[n_max];

int dp[n_max]; //足場iにいるときのコストの最小値

int rec(int i) {
  if(i==0) dp[i] = 0;
  else {
    int m = dp[i-1] + abs(h[i] - h[i-1]);
    for(int j = 1; j<=k; j++) {
      if(i-j < 0) break;
      m = min(m, dp[i-j] + abs(h[i] - h[i-j]));
    }
    dp[i] = m;
  }
  // cout << dp[i] << endl;
  if(i<n-1) rec(i+1);
  return 0;
}

int main() {
  rep(i,n_max) dp[i] = INF;
  cin >> n >> k;
  rep(i,n) cin >> h[i];
  rec(0);
  cout << dp[n-1] << endl;
}


Measured memory_bytes: 2560
//#pragma comment(linker, "/stack:200000000")
    #pragma GCC optimize ("Ofast")
    #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
    #include <bits/stdc++.h>
    using namespace std;
    
    #define TRACE
    
    #ifdef TRACE
    #define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
      cerr << name << " : " << arg1 << std::endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
      const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
    #else
    #define trace(...)
    #endif
    
    #define rep(i, n)    for(int i = 0; i < (n); ++i)
    #define repA(i, a, n)  for(int i = a; i <= (n); ++i)
    #define repD(i, a, n)  for(int i = a; i >= (n); --i)
    #define trav(a, x) for(auto& a : x)
    #define all(x) x.begin(), x.end()
    #define sz(x) (int)(x).size()
    #define fill(a)  memset(a, 0, sizeof (a))
    #define fst first
    #define snd second
    #define mp make_pair
    #define pb push_back
    typedef long double ld;
    typedef long long ll;
    typedef pair<ll, ll> pii;
    typedef vector<ll> vi;
    const int maxN = 100224;

    void solve(){
      ll k,a,b,x=0;
      cin>>k>>a>>b;
      ll ok = k;
      if( a > b || k < a-1) x = 1 + k;
      else {
        k-=(a-1);
        x = a;
        x+=(k/2)*(b-a); k = k%2; 
        k%2 ? x++:0;
      }
      //cout<<k+1<<endl;
      x = max(x,ok+1);
      cout<<x<<endl;
    } 
    
    int main() {
      cin.sync_with_stdio(0); cin.tie(0);
      cin.exceptions(cin.failbit);
      solve();
      return 0;
    } 


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
const int INF = 2147483647;//int max
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;
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; }
//ミョ(-ω- ?)
int main() {
    int a,b,c;
    cin >> a >> b >> c;
    int ma = max({a,b,c});
    if((a+b+c)%2 == ma*3%2){
        cout << (ma*3 - (a+b+c))/2 << endl;
    }else{
        cout << ((ma+1)*3 - (a+b+c))/2 << endl;
    }
    return 0;
}

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

using namespace std;

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

    vector<tuple<string, int, int>> vs;
    for (int i = 0; i < N; ++i) {
        string s; cin >> s;
        int p; cin >> p;
        vs.push_back(tuple<string, int, int>(s, -p, i + 1));
    }

    sort(vs.begin(), vs.end());

    for (const auto& v : vs) {
        cout << std::get<2>(v) << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstring>
using namespace std;
typedef long long ll;
#define ip(arr, n) for(int i=0; i<n; i++) cin>>arr[i];
#define op(arr, n) for(int i=0; i<n; i++) cout<<arr[i]<<" ";
#define fstIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define mod 1000000007
#define MAX 1002

int n,m;
ll dp[MAX][MAX];
char arr[MAX][MAX];

void bottomUp(){
    memset(dp, 0, sizeof(dp));

    dp[0][0]=1;
    for(int i=0; i<n; i++){
        for(int j=0; j<m; j++){
            if(arr[i][j] == '#'){
                dp[i][j]=0;
                continue;
            }
            if(i>0) dp[i][j] = (dp[i][j]+dp[i-1][j])%mod;
            if(j>0) dp[i][j] = (dp[i][j]+dp[i][j-1])%mod;
        }
    }
    cout<<dp[n-1][m-1]<<endl;
}

ll solve(int i, int j){
    if(i==0 && j==0) return 1;
    if(i<0||j<0) return 0;
    if(arr[i][j] == '#'){
        dp[i][j]=0;
        return 0;
    }

    if(dp[i][j] != -1) return dp[i][j];
    
    return dp[i][j] = (solve(i-1, j)+solve(i, j-1))%mod;
}

void topDown(){
    memset(dp, -1, sizeof(dp));
    cout<<solve(n-1, m-1)<<endl;
}
int main(){
    cin>>n>>m;
    for(int i=0; i<n; i++){
        for(int j=0; j<m; j++){
            cin>>arr[i][j];
        }
    }
    // bottomUp();
    topDown();
    return 0;
}

Measured memory_bytes: 9216
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>

using namespace std;

struct Edge {
    int nod, cost;

    Edge(){}

    Edge(int nod, int cost) {
        this->nod = nod;
        this->cost = cost;
    }

    bool operator< (const Edge &other) const {
        return this->cost < other.cost;
    }
};

vector <Edge> G[100005];
bool visited[100005];
long long D[100005];

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

    int n;
    cin >> n;

    int a, b, c;
    for (int i = 1; i < n; ++i) {
        cin >> a >> b >> c;

        G[a].push_back(Edge(b, c));
        G[b].push_back(Edge(a, c));
    }

    int q, k;
    cin >> q >> k;

    const long long INF = (long long)1e18;

    for (int i = 0; i <= n; ++i) {
        D[i] = INF;
    }

    priority_queue< Edge > pq;
    pq.push(Edge(k, 0));

    D[k] = 0;

    while (!pq.empty()) {
        Edge top = pq.top();
        pq.pop();

        if (visited[top.nod]) continue;

        visited[top.nod] = true;

        for (Edge edge: G[top.nod]) {
            if (D[top.nod] + edge.cost < D[edge.nod]) {
                D[edge.nod] = D[top.nod] + edge.cost;

                pq.push(Edge(edge.nod, -D[edge.nod]));
            }
        }
    }

    while (q--) {
        cin >> a >> b;

        cout << D[a] + D[b] << "\n";
    }

    return 0;
}


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

using namespace std;

typedef long long lli;
typedef double lld;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<double> vdl;
typedef vector<vector<lli>> mat;
typedef vector<vdl> mad;
typedef unordered_map<lli,unordered_map<lli,lli>> graph;
typedef complex<double> cmp;
typedef vector<cmp> vcl;

lli n;
vll l;

int main(){
  cin >> n;
  l = vll(n);
  for(lli i = 0;i < n;i++) cin >> l[i];
  lli all = accumulate(l.begin(), l.end(), 0ll);
  lli one = *max_element(l.begin(), l.end());
  if(all-one > one) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#define ll long long
#define MOD_P 1000000007
using namespace std;

int main()
{
	bool masu[20][20];
	int h, w;
	char tmp;
	queue<pair<int, int>> bfs;
	int weigh[20][20];
	pair<int, int> sur;
	int max = 0, tmax = 0;

	cin >> h >> w;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cin >> tmp;
			masu[i][j] = (tmp == '.' ? true : false);
		}
	}

	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (masu[i][j]) {
				tmax = 0;
				for (int k = 0; k < h; k++) {
					for (int l = 0; l < w; l++) {
						weigh[k][l] = -1;
					}
				}
				bfs.push(make_pair(i, j));
				weigh[i][j] = 0;
				while (!bfs.empty()) {
					sur = bfs.front();
					bfs.pop();
					if (sur.first + 1 < h && masu[sur.first + 1][sur.second] && weigh[sur.first + 1][sur.second] == -1) {
						weigh[sur.first + 1][sur.second] = weigh[sur.first][sur.second] + 1;
						bfs.push(make_pair(sur.first + 1, sur.second));
					}
					if (sur.first - 1 >= 0 && masu[sur.first - 1][sur.second] && weigh[sur.first - 1][sur.second] == -1) {
						weigh[sur.first - 1][sur.second] = weigh[sur.first][sur.second] + 1;
						bfs.push(make_pair(sur.first - 1, sur.second));
					}
					if (sur.second + 1 < w && masu[sur.first][sur.second + 1] && weigh[sur.first][sur.second + 1] == -1) {
						weigh[sur.first][sur.second + 1] = weigh[sur.first][sur.second] + 1;
						bfs.push(make_pair(sur.first, sur.second + 1));
					}
					if (sur.second - 1 >= 0 && masu[sur.first][sur.second - 1] && weigh[sur.first][sur.second - 1] == -1) {
						weigh[sur.first][sur.second - 1] = weigh[sur.first][sur.second] + 1;
						bfs.push(make_pair(sur.first, sur.second - 1));
					}
				}

				for (int k = 0; k < h; k++) {
					for (int l = 0; l < w; l++) {
						if (tmax < weigh[k][l]) {
							tmax = weigh[k][l];
						}
					}
				}
				if (max < tmax) {
					max = tmax;
				}
			}
		}
	}

	printf("%d", max);
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=2e18;
const ll MOD=1e9+7;

ll N;
ll T[100010];
ll A[100010];

ll u[100010];
ll d[100010];
ll uA[100010];
ll dA[100010];

int main(){
    cin>>N;
    for(ll i=0;i<N;i++){
        cin>>T[i];
    }
    for(ll i=0;i<N;i++){
        cin>>A[i];
    }
    u[0]=T[0];
    d[0]=T[0];
    for(ll i=1;i<N;i++){
        if(T[i]>u[i-1]){
            u[i]=T[i];
            d[i]=T[i];
        }else if(T[i]==u[i-1]){
            u[i]=u[i-1];
            d[i]=1;
        }else{
            cout<<"0"<<endl;
            return 0;
        }
    }
    uA[N-1]=A[N-1];
    dA[N-1]=A[N-1];
    for(ll i=N-2;i>=0;i--){
        if(A[i]>uA[i+1]){
            uA[i]=A[i];
            dA[i]=A[i];
        }else if(A[i]==uA[i+1]){
            uA[i]=uA[i+1];
            dA[i]=1;
        }else{
            cout<<"0"<<endl;
            return 0;
        }
    }
    ll ans=1;
    for(ll i=0;i<N;i++){
        ll tmp=min(u[i],uA[i])-max(d[i],dA[i])+1;
        ans=ans*tmp%MOD;
        if(ans<=0)ans=0;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 4992
N, M = map(int, input().split())

s = {1}
cnt = [1] * (N + 1)
for i in range(M):
    x, y = map(int, input().split())
    cnt[x] -= 1
    cnt[y] += 1
    if x in s:
        s.add(y)
        if cnt[x] == 0:
            s.discard(x)

print(len(s))

Measured memory_bytes: 12780
#include <bits/stdc++.h>
typedef long long ll;
#define MOD 1000000007
#define INF 99999999 
using namespace std;
 
int main()
{
    int N; cin >> N;
    int A[N+1] = {0};
    for (int i = 0; i < N-1; i++)
    {
        int a; cin >> a;
        A[a]++;
    }
    for (int i = 0; i < N; i++)
    {
        cout << A[i+1] << endl;
    }
    
}

Measured memory_bytes: 4352
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;

#[allow(dead_code)]
struct Scanner<'a> {
    cin: StdinLock<'a>,
}
#[allow(dead_code)]
impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }

    fn read<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }

    fn input<T: FromStr>(&mut self) -> T {
        self.read().unwrap()
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    let m: isize = sc.input();
    println!("{}", 24 + 24 - m);
}


Measured memory_bytes: 4352
H, W = [int(hw) for hw in input().split()]
A = []
A.append("." * (W+2))
for h in range(H):
  A.append("." + input() + ".")
A.append("." * (W+2))

for h in range(1, H+1):
  for w in range(1, W+1):
    P = A[h][w]
    if P == ".":
      P_around = [A[h-1][w-1], A[h-1][w], A[h-1][w+1], \
                  A[h][w-1], A[h][w+1], \
                  A[h+1][w-1], A[h+1][w], A[h+1][w+1]]
      howmany_sharp = P_around.count("#")
      A[h] = A[h][:w] + str(howmany_sharp) + A[h][w+1:]

for h in range(1, H+1):
  print(A[h][1:W+1])

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int main()
{
	int x[1000],y[1000],z[2];
	int a,b,c,d,e,f=0;
	scanf("%d%d%d%d",&a,&b,&z[0],&z[1]);
	for(c=0;c<a;c++)scanf("%d",&x[c]);
	for(c=0;c<b;c++)scanf("%d",&y[c]);
	d=x[0];
	for(c=1;c<a;c++)
		if(d<x[c])d=x[c];
	e=y[0];
	for(c=1;c<b;c++)
		if(e>=y[c])e=y[c];
	if(d>=e){printf("War\n");return 0;}
	if(d<=z[1]-1&&d>=z[0])
	{
		if(e>=z[0]&&e<=z[1])
		{
			for(f=d+1;f<=e;f++)
				if(d<f&&e>=f){printf("No War\n");return 0;}
		}
		else if(e>=z[1]){printf("No War\n");return 0;}
	}
	else if(d<z[0])
	{
		if(e<=z[1]&&e>z[0])
		{
			for(f=z[0]+1;f<=z[1];f++)
				if(d<f&&e>=f){printf("No War\n");return 0;}
		}
		else if(e>=z[1]){printf("No War\n");return 0;}
	}
	else if(d>=z[1]){printf("War\n");return 0;}
	printf("War \n");
	return 0;
}

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

int main(int argc, char const *argv[]) {
  double n, m;
  cin >> n >> m;
  vector<double> v;
  double sum = 0;
  rep(i, n) {
    int tmp;
    cin >> tmp;
    v.push_back(tmp);
    sum += tmp;
  }
  double threshold = sum / 4 / m;
  sort(v.rbegin(), v.rend());
  bool flag = true;
  rep(i, m) {
    if (v[i] < threshold) {
      flag = false;
      break;
    }
  }
  if (flag)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3728
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,s,e) for(int i=s;i<e;i++)
#define REP(i,n) FOR(i,0,n)
#define all(a) (a).begin(),(a).end()
typedef long long LL;

int main() {
   int n;
   cin>>n;
   vector<int> a(n);
   REP(i,n) cin>>a[i];
   int ans=0;
   REP(i,n)while(a[i]%2==0){
     a[i] /= 2;
     ans++;
     }
   cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin>>n>>k;
  vector<int> vc(n + 1);
  for (int i = 1; i <= n; i++) cin>>vc[i];
  for(int i = k + 1; i <= n; i++)
  {
    if (vc[i - k] < vc[i]) cout<<"Yes\n";
    else cout<<"No\n";
  }
}

Measured memory_bytes: 3984
#!/usr/bin/env python3

import math

N, X = map(int, input().split())
A = sorted(list(map(int, input().split()))+[X])
B = []

for i in range(len(A)-1):
    B.append(A[i+1] - A[i])

g = B[0]

for b in B[1:]:
    g = math.gcd(b, g)

print(g)



Measured memory_bytes: 20216
#include<bits/stdc++.h>
using namespace std;
//mod逆元を使ったnCkの計算(速)
const int64_t MAX = 3000010;
const int64_t MOD = 1000000007;

int64_t fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++){
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

// 二項係数計算
int64_t COM(int64_t n, int64_t k){
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//繰り返し二乗法
int64_t powmod(int64_t x, int64_t n) { 
  int64_t ans = 1;
  while (n > 0) {
    if ((n & 1) == 1) {
      ans = ans * x;
      ans %= MOD;
    }
    x = x * x;//一周する度にx, x^2, x^4, x^8となる
    x %= MOD;
    n >>= 1; //桁をずらす n = n >> 1
  }
  return ans;
}


int main(){
  int64_t K;
  cin >> K;
  string S;
  cin >> S;
  int64_t N = S.size();
  
  /*dp[0][0] = 25;
  dp[0][1] = 1;
  for(int i=0; i<N+K; i++){
    for(int j=0; j<N+1; j++){
      if(j == 0){
        dp[i+1][j] = dp[i][j]*25;
      }
      else if(j != N){
        dp[i+1][j] = dp[i][j-1] + dp[i][j]*25;
      }
      else{
        dp[i+1][j] = dp[i][j]*26 + dp[i][j-1];
      }
      dp[i+1][j] %= MOD;
    }
  }
  cout << dp[N+K-1][N] << endl;*/
  
  COMinit();
  int64_t ans = 0;
  for(int i=0; i<=K; i++){
    int64_t plus = COM(N+i-1,i);
    plus *= powmod(25,i);
    plus %= MOD;
    plus *= powmod(26,K-i);
    plus %= MOD;
    ans += plus;
    ans %= MOD;
  }
  cout << ans << endl;
}

Measured memory_bytes: 74648
#include <iostream>
#include <string>
#include <string.h>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <stdio.h>
#include <vector>
#include <thread>
#include <atomic>
#include <mutex>
#include <future>
#define int long long
#define endre getchar();getchar();return 0
#define INF 1000000007
#define rep(i,n) for(int i=0;i<n;i++)
#define input(a,n) for(int i=0;i<n;i++)cin>>a[i];
#define P pair<int,int>
#define prique priority_queue<int,vector<int>,greater<int>>
using namespace std;
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return (y, x%y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int n) {
	if (n == 0)return 1;
	return (kai(n - 1)*n) % INF;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x%mod;
		}
		x = x * x%mod;
		y >>= 1;
	}
	return res;
}
int mystoi(string s) {
	int cnt = 0;
	for (int i = 0; i < s.size(); i++) {
		cnt += (int)(s[i] - '0') * pow(10, s.size() - i - 1);
	}
	return cnt;
}
int h, w, d[55][55], all;
int hox[5] = { 0,1,0,-1 }, hoy[5] = { 1,0,-1,0 };
char c[55][55];
int bfs() {
	queue<P>que;
	que.push({ 0, 0 });
	rep(i, h) {
		rep(j, w)d[i][j] = INF;
	}
	d[0][0] = 0;
	while (que.size()) {
		P p = que.front();
		que.pop();
		if (p.first == h - 1 && p.second == w - 1)break;
		rep(i, 4) {
			int nx = p.first + hox[i], ny = p.second + hoy[i];
			if (nx < h&&nx >= 0 && ny < w&&ny >= 0 && d[nx][ny] == INF && c[nx][ny] == '.') {
				que.push({ nx,ny });
				d[nx][ny] = d[p.first][p.second] + 1;
			}
		}
	}
	return d[h - 1][w - 1];
}
signed main() {
	cin >> h >> w;
	rep(i, h) {
		rep(j, w) {
			cin >> c[i][j];
			if (c[i][j] == '.')all++;
		}
	}
	if (bfs() != INF)cout << all - bfs() - 1 << endl;
	else cout << -1 << endl;
	endre;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define int ll
//#define double ld
#define faster ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
ifstream in("input.txt");ofstream out("output.txt");
const int inf=1e18;
const int mod=1e9+7;
int n;
vector<double> vec;
vector<vector<double> > dp;

void init()
{
    cin>>n;
    vec.resize(n);
    for(int i=0;i<n;i++)
        cin>>vec[i];
    dp.resize(n+1,vector<double>(n+1));
    dp[0][0]=1.;
    for(int lev=0;lev<n;lev++)
    {
        for(int j=0;j<=lev;j++)
        {
            int oth=lev-j;
            dp[j+1][oth]+=dp[j][oth]*vec[lev];
            dp[j][oth+1]+=dp[j][oth]*(1.-vec[lev]);
        }
    }
    double ans=0;
    for(int i=0;i<=n;i++)
    {
        int heads=i;
        int oth=n-heads;
        if(heads>oth)
            ans+=dp[heads][oth];
    }
    cout<<fixed<<setprecision(14)<<ans;
}

signed main()
{
    init();
    return 0;
}




Measured memory_bytes: 70784
import java.util.Arrays;
import java.util.Scanner;

public class Main {
  
  public static void main(String[] args) {
    
    Scanner sc = new Scanner(System.in);
    
    String s = sc.next();
    String t = sc.next();
    
    char sArray[] = new char[s.length()];
    for (int i = 0; i < s.length(); i++) {
      sArray[i] = s.charAt(i);
    }
    Arrays.sort(sArray);
    char tArray[] = new char[t.length()];
    for (int i = 0; i < t.length(); i++) {
      tArray[i] = t.charAt(i);
    }
    Arrays.sort(tArray);
    char tReverse[] = new char[t.length()];
    for (int i = 0; i < t.length(); i++) {
      tReverse[i] = tArray[t.length() - 1 - i];
    }
    
    String sF = String.valueOf(sArray);
    String tR = String.valueOf(tReverse);
    
    if (tR.compareTo(sF) > 0) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
    
  }
}

Measured memory_bytes: 21844
//============================================================================
// Name        : AOJ.cpp
// Author      : Akari Fujii
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cctype>
#include <string>
#include<algorithm>

using namespace std;
typedef long long ll;
int main(){

	int n,a[101];
	int total1=0,total2=0;

	cin>>n;

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

	sort(a, a + n, greater<int>());

	for(int i=0; i<n; ++i){
		if(i%2==0){
			total1+=a[i];
		}else{
			total2+=a[i];
		}
	}

	cout<<total1-total2<<endl;
	return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
ll n,dp[5005][5005],cnt,ans;
string s;
int main() {
  cin >> n >> s;
  rep(i,n) if (s[n-1]==s[i]) dp[n-1][i]=1;
  for (int i=n-2; i >= 0; --i){
    for (int j=n-1; j >= 0; --j){
      if (s[i]==s[j]) dp[i][j]=dp[i+1][j+1]+1;
      cnt=dp[i][j];
      if (abs(i-j)<cnt) cnt=abs(i-j);
      ans=max(cnt,ans);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 195712