akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>//Carefully Crafted by hetp111
using namespace std;
#define int long long
#define double long double
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vii vector<pii>
#define MOD 1000000007
#define MOD2 998244353
#define MOD3 1000000009
#define PI acos(-1)
#define eps (1e-8)
#define INF (1e18)
#define FASTER ios_base::sync_with_stdio(0);cin.tie(0)
template<class A,class B>ostream&operator<<(ostream&out,const pair<A,B>&a){return out<<"("<<a.first<<","<<a.second<<")";}
template<class A>ostream&operator<<(ostream&out,const vector<A>&a){for(const A &it:a)out<<it<<" ";return out;}
template<class A,class B>istream&operator>>(istream&in,pair<A,B>&a){return in>>a.first>>a.second;}
template<class A>istream&operator>>(istream&in,vector<A>&a){for(A &i:a)in>>i;return in;}
//ifstream cinn("in.in");ofstream coutt("out.out");
int poww(const int &a,int b,const int &m=MOD){if(b==0)return 1;int x=poww(a,b/2,m);x=x*x%m;if(b&1)x=x*a%m;return x;}
int ceil(const int &a,const int &b){return (a+b-1)/b;}
////Read:
//Check corner cases, n==1;
//
////Some function:
//__builtin_popcountll(), is_sorted(),


signed main(){
    FASTER;
    int n;cin>>n;
    string s;cin>>s;
    vi preR(n),preW(n);
    preR[0]=(s[0]=='R');
    preW[0]=(s[0]=='W');
    for(int i=1;i<n;i++){
        preR[i]=preR[i-1]+(s[i]=='R');
        preW[i]=preW[i-1]+(s[i]=='W');
    }
    int ans=min(preR[n-1],preW[n-1]);
    for(int i=0;i<n;i++){
        ans=min(ans,preW[i]+preR[n-1]-preR[i]);
    }
    int red=preR[n-1];
    int white=preW[n-1];
    ans=min(ans,red-(red-1>=0?preR[red-1]:0));
    ans=min(ans,white-(preW[n-1]-(n-white-1>=0?preW[n-white-1]:0)));
    cout<<ans;
}



Measured memory_bytes: 6780
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const ll MOD=1000000007;
const ll MAX_N=500010;
const ll INF=999999999999;

int main(){
    ll a,b,q,x;
    ll s0,s1,t0,t1;
    cin>>a>>b>>q;
    vector<ll> ans(q);
    vector<ll> s(a); for(int i=0;i<a;i++) cin>>s[i];
    vector<ll> t(b); for(int i=0;i<b;i++) cin>>t[i];
    //for(int i=0;i<a;i++) cout<<s[i]<<" ";
    //for(int i=0;i<b;i++) cout<<t[i]<<" "; 
    //cout<<endl;
    for(int i=0;i<q;i++){
        cin>>x;
        if(lower_bound(s.begin(),s.end(),x)-s.begin()==0){
            s0=-INF;
            s1=s[0];
        }else if(s[lower_bound(s.begin(),s.end(),x)-s.begin()]<x){
            s0=s[lower_bound(s.begin(),s.end(),x)-s.begin()-1];
            s1=INF;
        }else{
            s0=s[lower_bound(s.begin(),s.end(),x)-s.begin()-1];
            s1=s[lower_bound(s.begin(),s.end(),x)-s.begin()];
        }
        if(lower_bound(t.begin(),t.end(),x)-t.begin()==0){
            t0=-INF;
            t1=t[0];
        }else if(t[lower_bound(t.begin(),t.end(),x)-t.begin()]<x){
            t0=t[lower_bound(t.begin(),t.end(),x)-t.begin()-1];
            t1=INF;
        }else{
            t0=t[lower_bound(t.begin(),t.end(),x)-t.begin()-1];
            t1=t[lower_bound(t.begin(),t.end(),x)-t.begin()];
        }
        //cout<<s0<<" "<<s1<<" "<<t0<<" "<<t1<<endl;
        if(s0<=t0){
            if(s1<=t1){
                ans[i]=min(x-s0,min(x-t0+s1-t0,min(s1-x+s1-t0,t1-x)));
            }else{
                ans[i]=min(x-s0,s1-x);
            }
        }else{
            if(s1<=t1){
                ans[i]=min(x-t0,t1-x);
            }else{
                ans[i]=min(x-t0,min(x-s0+t1-s0,min(t1-x+t1-s0,s1-x)));
            }
        }
    }
    for(int i=0;i<q;i++) cout<<ans[i]<<endl;
}

Measured memory_bytes: 3712
#include<iostream>
using namespace std;
using ll = long long;

int main(){
    ll n,a,b,c,d,e;
    cin>>n>>a>>b>>c>>d>>e;
    ll m=min(a,min(b,min(c,min(d,e))));
    cout<<(n+m-1)/m+4<<endl;
}

Measured memory_bytes: 3636
import sys

def enum_div(n):
    ir=int(n**(0.5))+1
    ret=[]
    for i in range(1,ir):
        if n%i == 0:
            ret.append(i)
            if (i!= 1) & (i*i != n):
                ret.append(n//i)
    return ret


import math

def get_primenumber(number):#エラトステネスの篩
    prime_list = []
    search_list = list(range(2,number+1))
    #search_listの先頭の値が√nの値を超えたら終了
    while search_list[0] <= math.sqrt(number):
      #search_listの先頭の値が√nの値を超えたら終了
      #search_listの先頭をprime_listに入れて、先頭をリストに追加して削除
        head_num = search_list.pop(0)
        prime_list.append(head_num)
        #head_numの倍数を除去
        search_list = [num for num in search_list if num % head_num != 0]
    #prime_listにsearch_listを結合
    prime_list.extend(search_list)
    return prime_list

#p=get_primenumber(79000)

n=int(input())
ap=list(map(int,input().split()))
amin=min(ap)
amax=max(ap)

if amax==1:
    print("pairwise coprime")
    sys.exit()

if amin!=1:
    bp=enum_div(amin)+[amin]
    bp=bp[1:]
    for bpi in bp:
        yn=""
        for ai in ap:
            if ai%bpi!=0:
                yn="coprime"
                break
        if yn=="":
            print("not coprime")
            sys.exit()

if n>=78500 :
    print("setwise coprime")
    sys.exit()

p=get_primenumber(amax)

aa=[0]*(amax+1)
for ai in ap:
    aa[ai]+=1
    
#for pp in range(2,amax+1):
for pp in p:
    psum=0
    for pi in range(pp,amax+1,pp):
        psum+=aa[pi]
#    psum=sum(aa[pp: :pp])
#    print("pp:",pp,psum)
    if psum>=2:
            print("setwise coprime")
            sys.exit()
## max_13.txt ... max_16.txt : "setwise coprime"
print("pairwise coprime")
   


Measured memory_bytes: 219236
import math
N, M = map(int, input().split())

ans = 1
if(N < M//N):
  i = N
  while(ans == 1 and i <= math.sqrt(M)):
    if(M % i == 0):
      ans = M//i
    i += 1
if(N >= M//N or ans == 1):
  i = M//N
  while(ans == 1 and i >= 1):
    if(M % i == 0):
      ans = i
    i -= 1
  
print(ans)

Measured memory_bytes: 3064
fun main (args : Array<String>) {
	val n = readLine()
	val N : Int = n!!.toInt()
	val l = readLine()!!.split(" ")
	var list : MutableList<Int> = mutableListOf()
	var count : Int = 0
	for (i in l) {
		list.add(i.toInt())
	}
	for (i in 1..N - 2) {
		if ( ( (list[i] > list[i - 1]) && (list[i] < list[i + 1]) ) || ( (list[i] < list[i - 1]) && (list[i] > list[i + 1]) ) ) {
			count++
		}
	}
	println("${count}")
}

Measured memory_bytes: 36160
#pragma GCC optimize(2)
#include<bits/stdc++.h>
using namespace std;
const int man = 1e6+10;
#define IOS ios::sync_with_stdio(0)
#define ull unsigned ll
#define uint unsigned
#define pai pair<int,int>
#define pal pair<ll,ll>
#define IT iterator
#define pb push_back
#define fi first
#define se second
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);++i)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);--i)
#define endl '\n'
#define ll long long
const ll mod = 1e9+7;

template<typename T>T gcd(T a, T b) {return b==0?a:gcd(b, a%b);}
template<typename T>T exgcd(T a,T b,T &g,T &x,T &y){if(!b){g = a,x = 1,y = 0;}
else {exgcd(b,a%b,g,y,x);y -= x*(a/b);}}

int a[man],vis[man];

signed main() {
    #ifndef ONLINE_JUDGE
        //freopen("in.txt", "r", stdin);
        //freopen("out.txt","w",stdout);
    #endif
    int n;cin >> n;
    int g = 0,maxx = -1;
    for(int i = 1;i <= n;++i){
        cin >>a[i];
        g = gcd(g,a[i]);
        maxx=  max(maxx,a[i]);
        vis[a[i]]++;
    }
    bool f = 1;
    for(int i = 2;i <= maxx;++i){
        int num = 0;
        for(int j = i;j <= maxx;j += i){
            num += vis[j];
        }
        if(num>=2){
            f = 0;
            break;
        }
    }
    if(f){
        cout<<"pairwise coprime\n";
    }else if(g==1){
        cout<<"setwise coprime\n";
    }else cout<<"not coprime\n";
    return 0;
}

Measured memory_bytes: 11432
using System;
using System.Linq;

public class Test
{
	public static void Main()
	{
		// your code goes here
		
		  var c = Console.ReadLine().Split().Select(y => int.Parse(y)).ToArray();
		  int k = c[0];
		  int x = c[1];
		  int[] ans = new int[2*k-1];
		  
		  for(int i=0; i!=2*k-1; i++){
		  	ans[i] = x-k+1+i;
		  }
		  
		  Console.WriteLine(string.Join(" ", ans));
		
	}
}

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

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
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; }
typedef long long ll;

const long long INF = 1LL << 60;

int main()
{
    int n;
    int cnt = 0;
    cin >> n;

    vector<int> p(n);
    rep(i, n) {
        cin >> p[i];
    }

    for (int i = 1; i <= n - 2; i++) {
        if (p[i - 1] < p[i] && p[i] < p[i + 1]) {
            cnt++;
        }
        else if (p[i + 1] < p[i] && p[i] < p[i - 1]) {
            cnt++;
        }
    }

    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)


int main(){
   int n;
   cin >> n;
   long long h;
   long long mae;
   int count = 0;
   vector<int> ans={0};
   vector<string> de;
   REP(i,n){
      cin >> h;
      if(i==0){
         mae = h;
         continue;
      }
      if(mae >= h){
         count++;
         mae = h;
      }else{
         
         ans.push_back(count);
         count = 0;
         mae = h;
      }
      
   }
   ans.push_back(count);
   sort(ans.begin(), ans.end(), greater<int>());
   
   
   cout << ans[0] << endl;
   
   
   
   
   return 0;
}

Measured memory_bytes: 892
package main 

import (
	"fmt"
	"unicode/utf8"
	"strconv"
	"math"
)

func main () {
	var s string
	var x, y, z, an, zx  int
	fmt.Scan(&s)
	na :=utf8.RuneCountInString(s)
	var ff float64

	for x = 0 ; x < 1000 ; x ++{
		y = x + 1
		z = y +1
		zx = z + 1
		if z < na  {
			k := s[x:y]
			ka :=s[y:z]
			ki := s[z:zx]
			d := k + ka + ki
			i, _ := strconv.Atoi(d)
			i = 753 - i
			ff = float64(i) 
			ff = math.Abs(ff)
			i = int(ff)

			if an == 0 {
				an = i
			}  else if an > i {
				an = i
			}
		}  else if z >= na {
			break 
		}
	}
	fmt.Println(an)
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define F first
#define S second
bool b[1005][1005];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int h,w;
    cin>>h>>w;
    int a,b;
    cin>>a>>b;
    for(int i=0;i<h;i++)
    {
        for(int j=0;j<w;j++)
        {
            bool x=0;
            if(i>=b) x=!x;
            if(j>=a) x=!x;
            if(x) cout<<'1';
            else cout<<'0';
        }
        cout<<'\n';
    }
}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
#define ull unsigned long long
#define ll long long
#define pb push_back
#define endl '\n'
#define line cout<<"----------------------"<<endl
#define mp make_pair
#define mod 1000000007
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL)
#define filein freopen("input.txt","r",stdin)
#define fileout freopen("output.txt","w",stdout)
using namespace std;
const ll  mx=2000009;
ll  dp[3009][3009];
ll  ara[3009];
ll  call(ll  i,ll  j)
{
    if(i>j) return 0;
    ll  &ret=dp[i][j];
    if(ret!=-1) return ret;
    ll  a=0,b=0;
    a=ara[i]-call(i+1,j);
    b=ara[j]-call(i,j-1);
    return ret=max(a,b);
}
int main()
{
    ll  n;
    cin>>n;
    for(ll  i=0;i<n;i++) cin>>ara[i];
    memset(dp,-1,sizeof dp);
    cout<<call(0,n-1)<<endl;
}





Measured memory_bytes: 71168
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(i,a,b) for (int i=a; i<b; ++i)
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll X; cin >> X;
    ll ans;
    if (X<600) ans=8;
    else if (X<800) ans=7;
    else if (X<1000) ans=6;
    else if (X<1200) ans=5;
    else if (X<1400) ans=4;
    else if (X<1600) ans=3;
    else if (X<1800) ans=2;
    else if (X<2000) ans=1;
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3644
from itertools import permutations

N, M = map(int, input().split())
E = []
for _ in range(M):
    a, b = map(int, input().split())
    E.append((a, b))
    E.append((b, a))
ans = 0
for p in permutations(range(2, N+1)):
    perm = [1] + list(p)
    for i in range(N-1):
        if (perm[i], perm[i+1]) not in E:
            break
    else:
        ans += 1
print(ans)

Measured memory_bytes: 3064
integer(16) N
integer(16),allocatable,dimension(:)::RX,RY,BX,BY
logical,allocatable,dimension(:)::sold
integer cnt
integer(16) i,j

read*,N
allocate(RX(N),RY(N),BX(N),BY(N))
do i=1,N
  read*,RX(i),RY(i)
end do
do i=1,N
  read*,BX(i),BY(i)
end do
call HeapsortPair(N,BX,BY)
call HeaPsortPair(N,RY,RX)

allocate(sold(N))
sold=.False.
cnt=0
do i=1,N
  do j=N,1,-1
    if(sold(j))cycle
    if(RX(j)<BX(i).and.RY(j)<BY(i))then
      sold(j)=.true.
      cnt=cnt+1
      exit
    endif
  end do
end do

print"(i0)",cnt

contains

subroutine HeapsortPair(n,array,array2)
  implicit none
!ここの入力は状況に応じて変更すること
  integer(16),intent(in) :: n
  integer(16),intent(inout) :: array(1:n),array2(1:n)
  integer(16)::i,k,j,l
  integer(16):: t,t2

  l=n/2+1
  k=n
  do while(k /= 1)
     if(l > 1)then
        l=l-1
        t=array(L)
        t2=array2(L)
     else
        t=array(k)
        t2=array2(k)
        array(k)=array(1)
        array2(k)=array2(1)
        k=k-1
        if(k == 1) then
           array(1)=t
           array2(1)=t2
           exit
        endif
     endif
     i=l
     j=l+l
     do while(j<=k)
        if(j < k)then
           if(array(j) < array(j+1))j=j+1
        endif
        if (t < array(j))then
           array(i)=array(j)
           array2(i)=array2(j)
           i=j
           j=j+j
        else
           j=k+1
        endif
     enddo
     array(i)=t
     array2(i)=t2
  enddo
  return
end subroutine HeapsortPair
end

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

const int INF = 1 << 29;

int N;
vector<int> L;
vector<int> A;

int rec(vector<int> sums, vector<int> nums, int id){
    if(id == N){
        for(int i = 0; i < 3; i++){
            if(nums[i] == 0)return INF;
        }

        long long score = 0;
        for(int i = 0; i < 3; i++){
            score += abs(sums[i] - A[i]);
            score += (nums[i] - 1) * 10;
        }
        return score;
    }

    int res = INF;

    res = min(res, rec(sums, nums, id+1));

    for(int i = 0; i < 3; i++){
        sums[i] += L[id], nums[i]++;
        res = min(res, rec(sums, nums, id+1));
        sums[i] -= L[id], nums[i]--;
    }
    return res;
}

int main(){
    cin >> N;
    A.resize(3);
    for(int i = 0; i < 3; i++)cin >> A[i];
    L.resize(N);
    for(int i = 0; i < N; i++)cin >> L[i];
    vector<int> sums(3, 0), nums(3, 0);
    cout << rec(sums, nums, 0) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define f first
#define s second
#define mp make_pair
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n,k;
	cin>>n>>k;
	vector<vector<int> > a(n);
	int r[n][n];
	vector<pair<int, int> > v(n);
	for(int i =0,b,c; i<n-1; i++)
	{
		cin>>b>>c, --b,--c;
		a[b].push_back(c);
		a[c].push_back(b);
		r[b][c]=r[c][b]=1;
		v.push_back({b,c});
	}
	int k2= k;
	k /=2;
	vector<array<int,2> >ans;
	for(int i =0; i<n; i++)
	{
		queue<int> 	q;
		q.push(i);
		bool vis[n]={false};
		int dist[n]={0};
		vis[i]=1;
		while(!q.empty())
		{
			int h = q.front();
			q.pop();
			for(auto it: a[h])
			{
				if(!vis[it])
				{
					dist[it]=dist[h]+1;
					vis[it]=true;
					q.push(it);
				}
			}
		}
		int count=0;
		for(int j =0; j<n ;j++)
		{
			r[i][j]=dist[j];
			if(dist[j]>k)
				count++;
		}
		ans.push_back({count,i});
	}
	
	sort(ans.begin(),ans.end());
	if(k2 &1)
	{
	    int y = INT_MAX;
		int h = ans[0][1],j = ans[1][1];
		for(auto it: v)
		{
		    int h=it.f,j=it.s,count=0;
		    for(int i=0;i<n; i++)
		    {
    			if(r[h][i]<=k || r[j][i]<=k)
    				;
    			else
    				count++;
		    }
		    y = min(y,count);
		}
		cout<<y<<endl;
	}
	else
		cout<<ans[0][0]<<endl;
	return 0;
}

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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s;
	cin>>s;
	int n = s.size();
	int min_ans = 0;
	int mid = n/2;
	for(int move=0; move<mid; ++move){
		if( s[move] != s[n-1-move] ){ min_ans++; }
	}
	cout<<min_ans<<'\n';

	return 0;
}


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

using namespace std;

#define OnlineJudge1

#define loop(x,a,n) for(int x = a;x < n;x++)
#define NumofDigits(n) ((int)log10(n)+1)
#define CountofNumber(array,n,x)  (upper_bound(array, array+n, x)-lower_bound(array, array+n, x))
#define readline(s) getline(cin,s)
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define EPS 1e-7
#define modulo ll (1e9 + 7)
const long double PI = 3.141592653589793238L;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<int,ll> pill;
typedef pair<ll,ll> pll;

#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)

#define time__(d) \
    for ( \
        auto blockTime = make_pair(chrono::high_resolution_clock::now(), true); \
        blockTime.second; \
        debug("%s: %lld ms\n", d, chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - blockTime.first).count()), blockTime.second = false \
    )

void init(){
    cin.tie(0);
    ios::sync_with_stdio(0);
#ifdef OnlineJudge
    freopen("in.txt","r",stdin);
    freopen("out.txt","w",stdout);
#endif
}

int main(){
    init();
    int r;  cin >> r;
    cout << 3 * (r * r);
}

Measured memory_bytes: 256
while True:
    n=int(input())
    if n==0:
        break
    lst=list(map(float, input().split()))
    s=sum(lst)  
    a=s/n
    ans=0
    for i in range(n):
        ans+=((lst[i]- a)**2)/n
    ans=ans**0.5
    print(ans)


Measured memory_bytes: 5736
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC048A___AtCoder_Contest
{
    class Program
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();
            string[] contestName = input.Split(' ');

            string output = "";

            foreach (string word in contestName)
            {
                char[] alphabet = word.ToCharArray();

                output += alphabet.First();
            }

            Console.WriteLine(output);
        }
    }
}


Measured memory_bytes: 13268
N,M = map(int,input().split())
P = list(map(int,input().split()))
XY = [tuple(map(int,input().split())) for i in range(M)]

class UnionFind:
    def __init__(self,N):
        self.parent = [i for i in range(N)]
        self._size = [1] * N
        self.count = 0
    def root(self,a):
        if self.parent[a] == a:
            return a
        else:
            self.parent[a] = self.root(self.parent[a])
            return self.parent[a]
    def is_same(self,a,b):
        return self.root(a) == self.root(b)
    def unite(self,a,b):
        ra = self.root(a)
        rb = self.root(b)
        if ra == rb: return
        if self._size[ra] < self._size[rb]: ra,rb = rb,ra
        self._size[ra] += self._size[rb]
        self.parent[rb] = ra
        self.count += 1
    def size(self,a):
        return self._size[self.root(a)]

uf = UnionFind(N)
for x,y in XY:
    x,y = x-1,y-1
    if uf.is_same(x,y): continue
    uf.unite(x,y)
for i in range(N):
    uf.root(i)

from collections import defaultdict
ps = defaultdict(lambda: set())
ids = defaultdict(lambda: set())
rs = set()
for i,p in enumerate(P):
    r = uf.root(i)
    ps[r].add(p-1)
    ids[r].add(i)
    rs.add(r)

ans = 0
for r in rs:
    ans += len(ps[r] & ids[r])
print(ans)

Measured memory_bytes: 93312
#include <queue>
#include <vector>
#include <iostream>
using namespace std;
vector<int> dir = { 0, 1, 0, -1 };
int H, W;
int main() {
	while (cin >> W >> H, H) {
		vector<vector<int> > d(H, vector<int>(W));
		int sx = 1, sy = -1, gx = -1, gy = -1;
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				cin >> d[i][j];
				if (d[i][j] == 2) sx = i, sy = j;
				if (d[i][j] == 3) gx = i, gy = j;
			}
		}
		vector<vector<vector<int> > > dist(H, vector<vector<int> >(W, vector<int>(6, 999999999))); dist[sx][sy][5] = 0;
		queue<vector<int> > que; que.push({ sx, sy, 5 });
		while (!que.empty()) {
			vector<int> u = que.front(); que.pop();
			if (u[2] == 0) continue;
			for (int i = 0; i < 4; i++) {
				int tx = u[0] + dir[i], ty = u[1] + dir[i ^ 1];
				int hp = u[2] - 1;
				if (0 <= tx && tx < H && 0 <= ty && ty < W && d[tx][ty] != 0) {
					if (d[tx][ty] == 4) hp = 5;
					if (dist[tx][ty][hp] == 999999999) {
						dist[tx][ty][hp] = dist[u[0]][u[1]][u[2]] + 1;
						que.push({ tx, ty, hp });
					}
				}
			}
		}
		int ret = 999999999;
		for (int i = 0; i <= 5; i++) ret = min(ret, dist[gx][gy][i]);
		cout << (ret != 999999999 ? ret : -1) << endl;
	}
	return 0;
}

Measured memory_bytes: 3072
#include <algorithm>
#include<iostream>
#include<stdio.h>
#include <algorithm>
#include<iostream>
#include<stdio.h>
#include<vector>
#include<set>
#include<string>
#include <iomanip>
#define rep(i,n) for(int i=0; i<(int)n; i++)//n回繰り返す
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
	int N; cin >> N;
    int A[210000];
	rep(i, N) {
		cin >> A[i];
	}
	sort(A, A + N);
	rep(i, N-1) {
		if (A[i] == A[i + 1]) {
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
	
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define PII pair<int,int>
#define VI vector<int>
#define VL vector<long long>
#define VPII vector<pair<int,int> >
#define PLL pair<long long,long long>
#define VPLL vector<pair<long long,long long> >
#define F first
#define S second
typedef long long LL;
using namespace std;
const int MOD = 1000000007;
const int SIZE = 1<<20;
VI e[SIZE];
LL fac[SIZE],inv[SIZE];
LL mypow(LL x,LL y){
    LL res=1;
    while(y){
        if(y&1)res=res*x%MOD;
        y>>=1;
        x=x*x%MOD;
    }
    return res;
}
LL C(int x,int y){
    if(y<0||y>x)return 0;
    return fac[x]*inv[y]%MOD*inv[x-y]%MOD;
}
void build(){
    fac[0]=1;
    REPP(i,1,SIZE)fac[i]=fac[i-1]*i%MOD;
    inv[SIZE-1]=mypow(fac[SIZE-1],MOD-2);
    for(int i=SIZE-2;i>=0;i--)inv[i]=inv[i+1]*(i+1)%MOD;
}
LL BIT[SIZE];
void ins(int x,LL v){
    for(;x;x-=x&-x)BIT[x]=BIT[x]*v%MOD;
}
LL qq(int x){
    LL res=1;
    for(;x<SIZE;x+=x&-x)res=res*BIT[x]%MOD;
    return res;
}
int ll[SIZE],rr[SIZE],id,N;
LL INV(int x){return mypow(x,MOD-2);}
void dfs0(int x,int lt){
    ll[x]=rr[x]=++id;
    REP(i,SZ(e[x])){
        int y=e[x][i];
        if(y==lt)continue;
        dfs0(y,x);
        rr[x]=rr[y];
    }
}
int dfs(int x,int lt){
    int num=1;
    LL me_inv=1;
    VI sons;
    REP(i,SZ(e[x])){
        int y=e[x][i];
        sons.PB(0);
        if(y==lt)continue;
        int res=dfs(y,x);
        sons[i]=res;
        num+=res;
        me_inv=me_inv*inv[res]%MOD;
    }
    LL v=me_inv*inv[N-num]%MOD*fac[N-1]%MOD;
    ins(ll[x],v);
    ins(ll[x]-1,INV(v));
    v=me_inv*fac[num-1]%MOD;
    ins(N,v);
    ins(rr[x],INV(v));
    ins(ll[x]-1,v);
    REP(i,SZ(e[x])){
        int y=e[x][i];
        if(y==lt)continue;
        v=me_inv*fac[sons[i]]%MOD*inv[N-num]%MOD*fac[N-sons[i]-1]%MOD;
        ins(rr[y],v);
        ins(ll[y]-1,INV(v));
    }
    return num;
}
int main(){
    REP(i,SIZE)BIT[i]=1;
    build();
    RI(N);
    REPP(i,1,N){
        DRII(x,y);
        e[x].PB(y);
        e[y].PB(x);
    }
    dfs0(1,1);
    dfs(1,1);
    for(int i=1;i<=N;i++){
        cout<<qq(ll[i])<<endl;
    }
    return 0;
}


Measured memory_bytes: 62336
def bit_dp(N, Adj):
    dp = [[0]*N for i in range(1 << N)]
    #dp[{0},0] = 1

    dp[1][0] = 1

    for S in range(1 << N):
        for v in range(N):
            # v がSに含まれていないときはパス
            if (S & (1 << v)) == 0:
                continue

            #sub = S - {v}
            sub = S ^ (1 << v)

            for u in range(N):
                # sub に uが含まれていて、かつ uとvがへんで結ばれている
                if (sub & (1 << u)) and (Adj[u][v]):
                    dp[S][v] += dp[sub][u]
    ans = sum(dp[(1 << N) - 1][u] for u in range(1, N))
    return ans


def main():
    N, M = map(int, input().split())
    Adj = [[False]*N for _ in range(N)]

    for _ in range(M):
        a, b = map(int, input().split())
        Adj[a-1][b-1] = 1
        Adj[b-1][a-1] = 1
    ans = bit_dp(N, Adj)

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.StringReader;
import java.util.ArrayList;
import java.util.StringTokenizer;

public class Main  implements Runnable {

    public static void main(String[] args) {

        new Thread(null, new Main(), "", 16 * 1024 * 1024).start();

    }

    public void run() {
    	FastScanner sc = new FastScanner(System.in);
		//long n = Long.parseLong(sc.next());
    	//int[] ar = new int[3];
    	//ar[0]=Integer.parseInt(sc.next());
    	//ar[1]=Integer.parseInt(sc.next());
    	//ar[2]=Integer.parseInt(sc.next());
    	//Arrays.parallelSort(ar);
		int n = Integer.parseInt(sc.next());
		int x = Integer.parseInt(sc.next());
		//int k = Integer.parseInt(sc.next());
		//String s = sc.next();
		//int k = Integer.parseInt(sc.next());
		//int m = Integer.parseInt(sc.next());
		//int x2000 = Integer.parseInt(sc.next());
		//int t = Integer.parseInt(sc.next());
		//int k = 0;
		//int k = Integer.parseInt(sc.next());
		///String str = sc.next();
		//char c[] = str.toCharArray();
		//char a[][] = new char[n];
		//int atmp[] = new int[h];
		//int max= 0;
		//int blackar[][] = new int[h*w][2];
		//int p=0;
		//ArrayList<Integer> lists = new ArrayList<Integer>();
		//lists = new ArrayList;
		int cl = 0;
		int ans = 1;
		for(int i = 0; i < n; i++)
		{
			cl += Integer.parseInt(sc.next());
			if(cl <= x)
			{
				ans++;
			}
		}
		PrintWriter out = new PrintWriter(System.out);

			out.println(ans);


		out.flush();
	}

    static class FastScanner {
        private BufferedReader reader = null;
        private StringTokenizer tokenizer = null;
        public FastScanner(String in) {
        	StringReader sr = new StringReader(in);
            reader = new BufferedReader(new BufferedReader(sr));
            tokenizer = null;
        }
        public FastScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }

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

        public String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }

            return tokenizer.nextToken("\n");
        }

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

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

    }

}

Measured memory_bytes: 21332
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
#define int long long
bool used[50];
typedef pair<int,int>P;
int n,k,a[11];
signed main(){
  vector<int>v;
  v.push_back(2);
  v.push_back(3);
  for(int i=5;i<10001;i++){
    int c=0;
    for(int j=2;j*j<=i;j++)if(i%j==0)c++;
    if(!c)v.push_back(i);
  }
  map<int,int>m;
  int n;
  cin>>n;
  for(int i=2;i<=n;i++){
    int c=0,x=i,t=0;
    while(x>1){
      if(x%v[t]==0)m[v[t]]++,x/=v[t];
      else t++;
    }
  }
  int ans=0;
  for(map<int,int>::iterator it=m.begin();it!=m.end();it++){
    if(it==m.begin())ans=(*it).second+1;
    else{
      ans=ans*((*it).second+1);
      ans=ans%1000000007;
    }
    //cout<<ans<<endl;
  }
  if(n==1)cout<<1<<endl;
  else cout<<max(ans,(int)0)<<endl;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val mod = 1000000007L
    val (n, m) = readLine()!!.split(' ').map(String::toLong)
    val aList = mutableListOf<Long>()
    if (m > 0L) {
        aList.add(readLine()!!.toLong())
    }
    (1 until m).forEach {
        val a = readLine()!!.toLong()
        if (aList.last() + 1 == a) {
            println(0)
            return
        }
        aList.add(a)
    }

    val dp = LongArray(n.toInt() + 1) { 0L }
    dp[0] = 1L
    aList.forEach { dp[it.toInt()] = -1L }

    for (i in 0..n.toInt() - 2) {
        if (dp[i] == -1L) continue
        if (dp[i + 1] != -1L) dp[i + 1] = (dp[i + 1] + dp[i]) % mod
        if (dp[i + 2] != -1L) dp[i + 2] = (dp[i + 2] + dp[i]) % mod
    }
    if (dp[n.toInt() - 1] != -1L) dp[n.toInt()] = (dp[n.toInt()] + dp[n.toInt() - 1]) % mod
    println(dp[n.toInt()])
}


Measured memory_bytes: 41416
#include<stdio.h>
#define N 105
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n, time = 0;
int color[N], d[N], f[N], array[N][N];

void DFS(){
  int i, time;
  for(i = 1; i < n+1; i++){
      color[i] = WHITE;
  }

  for(i = 1; i < n+1; i++){
    if(color[i] == WHITE) DFSvisit(i);
  }
}

void DFSvisit(int u){
  int i;
  color[u] = GRAY;
  d[u] = ++time;
  
  for(i = 1; i < n+1; i++){
    if((color[i] == WHITE) && (array[u][i] == 1)) DFSvisit(i);
  }
  color[u] = BLACK;
  f[u] = ++time;
}

main(){

  scanf("%d", &n);

  int i, u, v, j, e;
  for(i = 1; i < n+1; i++){
    for(j = 1; j < n+1; j++){
      array[i][j] = 0;
    }
  }

  for(i = 1; i < n+1; i++){
    scanf("%d%d", &u, &e);
    for(j = 1; j < e+1; j++){
      scanf("%d", &v);
      array[i][v] = 1;
    }
  }

  DFS();
  
  for(i = 1; i < n+1; i++){
    printf("%d ", i);
    printf("%d ", d[i]);
    printf("%d\n", f[i]);
  }
  return 0;
}

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

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<'\n';
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;

ll mult(ll n,ll m){//n^m%modを求める
    if(m==0) return 1;
    if(m==1){
        return n%mod;
    }else if(m%2==0){//オーバーフロー防止のためにn^(m/2)*n^(m/2)を考える
        ll t=mult(n,m/2);
        return (t*t)%mod;
    }else{//奇数の時はn^(m-1)*nを考える
        ll t=mult(n,m-1);
        return (t*n)%mod;
    }
}

ll d1[3000],d2[3000];

void make_table(ll N){
	for(ll i=0;i<=N;i++){
		if(i==0){
			d1[i]=1;
			d2[i]=1;
		}else{
			d1[i]=(i*d1[i-1])%mod;
			d2[i]=mult(d1[i],mod-2);
		}
	}
}

template <class T>
T comb_mod_2(T n,T k){
    if(n<k) return 0;
    return (((d1[n]*d2[n-k])%mod)*d2[k])%mod;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,k;
    cin>>n>>k;
    make_table(2500);
    FOR(i,1,k+1){
      ll ans=comb_mod_2(n-k+1,i)*comb_mod_2(k-1,i-1);
      ans%=mod;
      cout<<ans<<endl;
    }
}


Measured memory_bytes: 256
#include <iostream>

 

using namespace std;

 

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


Measured memory_bytes: 3100
#include <cstdio>
#include <queue>
#include <iostream>
#include <bits/stdc++.h>
#include<stdio.h>
#include<string.h>
#include<fstream>

#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
using namespace std;

int main() {
    cin.tie(0);
   	ios::sync_with_stdio(false);
       
    ll i,j,k,x,y,z,p,q;
    ll n,m,tmp;
    string s[200000];
    string str;
    ll sum=0;
    ll strr[200005];
    cin>>x>>y;
    rep(i,10001){
        
            if((long long)(i*0.08)==x&&(long long)(i*0.1)==y){
                cout<<i<<endl;
                return 0;
            
        }
    }
    cout<<-1<<endl;

    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>

using namespace std;
#define MOD 1000000007
#define rint register int
#define gc() getchar()
inline int read(int r=0,int s=0,int c=gc()){for(;c<48||c>57;s=c,c=gc());for(;c>=48&&c<=57;(r*=10)+=c-48,c=gc());return s^'-'?r:-r;}
inline int fxp(int s, int n=MOD-2){int a=1; for(; n; n&1 ? a = 1ll*a*s%MOD : 0, s = 1ll*s*s%MOD, n >>= 1); return a;}
int A[20], fac[65537], efac[65537], f[20][65537], N, M, E, Ans; bool c[65537]; inline void Add(int &x, int v){(x+=v)<MOD?:x-=MOD;}
inline int C(int n, int k){return n<0||k<0||n<k?0:1ll*fac[n]*efac[k]%MOD*efac[n-k]%MOD;}
int main()
{
	N = read(), M = read(), E = 1<<N, f[0][0] = 1; for(rint i = 0; i < M; A[i++] = read()); reverse(A,A+M);
	for(rint i = fac[0] = 1; i <= E; fac[i] = 1ll*i*fac[i-1]%MOD, i++); efac[E] = fxp(fac[E]); for(rint i = E; i; efac[i-1] = 1ll*i*efac[i]%MOD, i--);
	for(rint i = 0, j, S, r; i < M; i++) for(S = 0; S < E; S++) if(f[i][S])
		for(Add(f[i+1][S],f[i][S]), r = E-A[i]-S, j = 1; j < E && j-1 <= r; !(S&j) ? Add(f[i+1][S|j],1ll*f[i][S]*C(r,j-1)%MOD*fac[j]%MOD),0 : 0, j <<= 1);
	for(rint S = 0; S < E; S?c[S]=c[S-(S&-S)]^1:0, Ans = (Ans+(c[S]?MOD-1ll:1ll)*f[M][S]%MOD*fac[E-S-1])%MOD, S++); printf("%d\n",1ll*Ans*E%MOD); return 0;
}

Measured memory_bytes: 4224
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.StringTokenizer;

public class Main {
	static ArrayList<Integer>[] tree=null;
	static long [] v = null;
	static long [] vi = null;
	static boolean[] visited = null;
	public static void main(String[] args) {
		FastReader s = new FastReader();
		int n = s.nextInt();
		int q = s.nextInt();
		tree = new ArrayList[n+1];
		visited = new boolean[n+1];
		vi = new long[n+1];
		v = new long[n+1];
		for (int i = 0; i <n-1; i++) {
			int a = s.nextInt();
			int b = s.nextInt();
			if(tree[a]!=null) {
				ArrayList dat = tree[a];
				dat.add(b);
				tree[a]=dat;
			}else {
				ArrayList dat = new ArrayList<>();
				dat.add(b);
				tree[a]=dat;
			}
			if(tree[b]!=null) {
				ArrayList dat = tree[b];
				dat.add(a);
				tree[b]=dat;
			}else {
				ArrayList dat = new ArrayList<>();
				dat.add(a);
				tree[b]=dat;
			}
		}
		for (int i = 0; i < q; i++) {
			int p = s.nextInt();
			long x = s.nextLong();
			v[p]=v[p]+x;
		}		
		solveDfs(1,0L);
		
		for (int i = 1; i <=n; i++) {
			System.out.print(vi[i]+" ");
		}
	}
	public static void solveDfs(int x,long value_parent) {
		if(!visited[x]) {
			visited[x]=true;
			long vix = v[x];
			vi[x]=vix+value_parent;
				ArrayList<Integer> vals = tree[x];
				for (int i = 0; i < vals.size(); i++) {
					if(!visited[vals.get(i)])solveDfs(vals.get(i),vix+value_parent);
				}
			
		}
	}
	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; 
	    } 
	} 
}


Measured memory_bytes: 144700
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
using namespace std;
vector<int> e[1005];
int cl[1005][1005][2],u[200005],v[200005];
void dfs(int x,int ro,int c,int t){
	if(cl[ro][x][t])return;
	cl[ro][x][t]=c;
	for(int i=0;i<e[x].size();i++)if(!cl[ro][e[x][i]][t])dfs(e[x][i],ro,c,t);
}
int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++){
		scanf("%d%d",&u[i],&v[i]);
		e[u[i]].push_back(v[i]);
	}
	for(int i=1;i<=n;i++){
		cl[i][i][0]=i;
		for(int j=0;j<e[i].size();j++){
			dfs(e[i][j],i,e[i][j],0);
		}
		cl[i][i][1]=i;
		for(int j=(int)e[i].size()-1;j>=0;j--){
			dfs(e[i][j],i,e[i][j],1);
		}
	}
	for(int i=1;i<=m;i++){
		if(cl[v[i]][u[i]][0]){
			if(cl[u[i]][v[i]][0]!=v[i]||cl[u[i]][v[i]][1]!=v[i])puts("same");
			else puts("diff");
		}else{
			if(cl[u[i]][v[i]][0]!=v[i]||cl[u[i]][v[i]][1]!=v[i])puts("diff");
			else puts("same");
		}
	}
	return 0;
}

Measured memory_bytes: 12160
#include<iostream>
#include<string>
#include<stdio.h>
#include<cctype>
#include<algorithm>
#include<climits>
#include<cmath>
#include<map>
#include<vector>
#define INF INT_MAX
using namespace std;

int N, K;
int p[1010];
int ans;


int main(){
	cin >> N >> K;
	for (int i = 0; i < N; i++){
		cin >> p[i];
	}
	sort(p, p + N);
	for (int i = 0; i < K; i++){
		ans += p[i];
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3624
import sys
sys.setrecursionlimit(10 ** 6)  # 再帰関数の再帰の深さを設定
to_index = lambda x: int(x) - 1  # 入力した数字に1を引いたものを返す
print_list_in_2D = lambda x: print(*x, sep="\n")  # リストの要素を改行を挟んで表示する関数

# 入力を整数に変換して受け取る
def input_int():
    return int(input())

def map_int_input():
    return map(int, input())

MII = map_int_input

def MII_split():
    return map(int, input().split())

def MII_to_index():
    return map(to_index, input())

def MII_split_to_index():
    return map(to_index, input().split())

# 入力全てを整数に変換したものの配列を受け取る
def list_int_inputs():
    return list(map(int, input()))

LII = list_int_inputs

def LII_split():
    return list(map(int, input().split()))

# 2次元リスト化
def LII_2D(rows_number):
    return [LII() for _ in range(rows_number)]

def LII_split_2D(rows_number):
    return [LII_split() for _ in range(rows_number)]

N = input_int()
N %= 10
if N == 3:
    ans = 'bon'
elif N in [0, 1, 6, 8]:
    ans = 'pon'
else:
    ans = 'hon'
print(ans)

Measured memory_bytes: 9240
N, M, C = map(int, input().split())
B = list(map(int, input().split()))
ans = 0
for _ in range(N):
	A = list(map(int, input().split()))
	AB = [0] * M
	for i in range(M):
		AB[i] = A[i] * B[i]
	if sum(AB) + C > 0:
		ans += 1
print(ans)


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

int a[505][505];
int n,m,k;

int main(){
	scanf("%d%d%d",&n,&m,&k);
	for(int i=0;i<m;i++){
		int x,y;
		scanf("%d%d",&x,&y);
		a[x][y]++;
	}
	for(int i=1;i<=n;i++) for(int j=1;j<=n;j++) a[i][j]+=a[i][j-1];
	for(int i=1;i<=n;i++) for(int j=1;j<=n;j++) a[i][j]+=a[i-1][j];
	for(int i=0;i<k;i++){
		int x,y;
		scanf("%d%d",&x,&y);
		int ans=a[y][y]+a[x-1][x-1]-a[x-1][y]-a[y][x-1];
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 1920
from itertools import accumulate
from bisect import bisect_left

ri = lambda S: [int(v) for v in S.split()]


def rii():
    return ri(input())


N, M, K = rii()
A = rii()
B = rii()

i = j = 0

pA = [0] + list(accumulate(A))
pB = [0] + list(accumulate(B))

ans = 0
for i, a in enumerate(pA):
    br = 0
    if K >= a:
        r = K - a
        br = i
    
    if r:
        j = bisect_left(pB, r)
        if j != len(pB):
            if pB[j] > r:
                j -= 1
            br += j
    
    ans = max(ans, br)

print(ans)

Measured memory_bytes: 50764
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main
{
    public static void main(String[] args)
    {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA
    {
        public void solve(int testNumber, Scanner in, PrintWriter out)
        {
            long A = in.nextLong();
            long B = in.nextLong();
            long K = in.nextLong();
            long AA = A;
            A = Math.max(0, A - K);

            if (A != 0)
            {
                out.print(A + " " + B);
                return;
            }

            K -= AA;
            B = Math.max(0, B - K);
            out.print(A + " " + B);

        }

    }
}



Measured memory_bytes: 22996
N = int(input())
S = list(input())

if N % 2 == 0:
    ans = 'No'
    for i in range(N // 2):
        if S[i] != S[i + N // 2]: break
    else:
        ans = 'Yes'
    #
    print(ans)
else:
    print('No')

Measured memory_bytes: 3060
N, x = map(int, input().split())
a = list(map(int, input().split()))
a.sort()

ans = 0
for i in range(N):
    if a[i] <= x:
        x -= a[i]
        ans += 1
    else:
        break
if x == 0 or ans != N:
    print(ans)
else:
    print(max(ans - 1, 0))

Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<cstdlib>
using namespace std;
#define long long ll;
bool solve(int a,int b){
  //足して奇数だったら引いてつくれないじゃん
  return (a + b) % 2 == 1 || b - a < 0;
}
int main(){
  string s;
  int ans = 0;
  cin >> s;
  for(int i = 0 ; i < s.size() ; i++ ){
    if(s[i] == '0') continue;
    ans += !solve(atoi(s.substr(0,i).c_str()),atoi(s.substr(i).c_str()));
  }
  cout << ans << endl;
}

Measured memory_bytes: 1200
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <utility>
#include <memory>
#include <functional>
#include <deque>
#include <cctype>
#include <ctime>
#include <numeric>
#include <list>
#include <iomanip>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <forward_list>

#define cauto const auto&
#else

#endif

using namespace std;


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

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll;
typedef vector<vector<long long> > vvll;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define _rep(i,n) _rep2((i),0,(n))
#define _rep2(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) GET_MACRO(__VA_ARGS__, _rep2, _rep)(__VA_ARGS__)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define fi first
#define se second
#define mkp make_pair
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif

#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)

bool mainmain(){
	int n;
	cin>>n;
	int a=0;
	int b=0;
	rep(i,n){
		int t;
		cin>>t;
		if(t%4==0) a++;
		else if(t%2==0) b++;
	}
	if(a==0){
		if(n==b) return true;
		else return false;
	}
	else if(b==0){
		if(2*a+1>=n) return true;
		else return false;
	}
	else{
		n -= 2*a;
		if(b>=n) return true;
		else return false;
	}
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(20);
    cout<<(mainmain()?"Yes":"No")<<endl;
}

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

long long n,c,x[100001],v[100001],ni[100001],cur;
long long res=0,ji,nv[100001],book,ans,qian[100001],hou[100001];
struct node
{
    int r,l;
    long long mx;
}tr[800001];
void build1(int rt,int l,int r)
{
    tr[rt].l=l,tr[rt].r=r;
    if(l==r)
    {
        tr[rt].mx=hou[l];
        return;
    }
    int mid=(l+r)>>1;
    build1(rt<<1,l,mid);
    build1(rt<<1|1,mid+1,r);
    tr[rt].mx=max(tr[rt<<1].mx,tr[rt<<1|1].mx);
}
void build2(int rt,int l,int r)
{
    tr[rt].l=l,tr[rt].r=r;
    if(l==r)
    {
        tr[rt].mx=qian[l];
        return;
    }
    int mid=(l+r)>>1;
    build2(rt<<1,l,mid);
    build2(rt<<1|1,mid+1,r);
    tr[rt].mx=max(tr[rt<<1].mx,tr[rt<<1|1].mx);
}
long long query(int rt,int L,int R)
{
    int l=tr[rt].l,r=tr[rt].r;
    if(L<=l&&r<=R)
    {
        return tr[rt].mx;
    }
    long long ret=0;
    int mid=(l+r)>>1;
    if(L<=mid)
    ret=max(ret,query(rt<<1,L,R));
    if(R>mid)
    ret=max(ret,query(rt<<1|1,L,R));
    return ret;
}  
int main()
{
	scanf("%lld%lld",&n,&c);
	for(int i=1;i<=n;i++)
	scanf("%lld%lld",&x[i],&v[i]);
	for(int i=1;i<=n;i++)
	{
		ni[i]=c-x[n-i+1];
		nv[i]=v[n-i+1];
		qian[i]=qian[i-1]+v[i];
		hou[i]=hou[i-1]+nv[i];
	}
	for(int i=1;i<=n;i++)
	{
		qian[i]-=x[i];
		hou[i]-=ni[i];
	}
	build1(1,1,n);	
	for(int i=1;i<=n;i++)
	{
		res=max(res,qian[i]);
//		cout<<res<<" ";
		cur=qian[i];
		book=0;
		ji=0;
		if(n-i>0)
		ji=query(1,1,n-i);
//		cout<<ji<<" ";
		res=max(res,cur+ji-x[i]);
//		cout<<res<<endl;
	}
	build2(1,1,n);
	for(int i=1;i<=n;i++)
	{
		ans=max(ans,hou[i]);
		cur=hou[i];
		book=0;
		ji=0;
/*		for(int j=1;j<=n-i;j++)
		{
			if(qian[j]>ji)
			{
				ji=qian[j];
				book=j;
			}
		}*/
		if(n-i>0)
		ji=query(1,1,n-i);
		ans=max(ans,cur+ji-ni[i]);
	}
	res=max(res,ans);
	printf("%lld\n",res);
	return 0;
}

Measured memory_bytes: 11264