akhauriyash/Code-Regression huggingface dataset:
//#include <boost/multiprecision/cpp_dec_float.hpp>
//#include <boost/multiprecision/cpp_int.hpp>
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <math.h>
#include <algorithm>
#include <bitset>
#include <iomanip>
using namespace std;
//namespace mp = boost::multiprecision;
//using llll = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
//using Real = mp::number<mp::cpp_dec_float<1024>>;
using ll = long long;
const double EPS = 1e-10;
const ll MOD = 9223372036854775807;

#define max 10000
ll big=1e9+7;
ll ff=0;
vector<ll> p(max,1);
vector<ll> ip(max,1);
ll pow_ans(ll x, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) {
          res *= x;
          res %= big;
        }
        x *= x;
        x %= big;
        n >>= 1;
    }
    return res;
}
void initialize(){
  for(int i=1;i<max;i++){
    p[i]=p[i-1]*i%big;
  }
  for(int i=1;i<max;i++){
    ip[i]=pow_ans(p[i],big-2);
  }
}
ll nPk(int i,int j){
  if(ff==0){
    initialize();
    ff=1;
  }
  if(i<0||j<0||i<j)return 0;
  else{
    ll tem;
    tem=p[i]*ip[i-j]%big;
    return tem;
  }
}
ll nCk(int i,int j){
  if(ff==0){
    initialize();
    ff=1;
  }
  if(i<0||j<0||i<j)return 0;
  ll tmp=nPk(i,j);
  tmp=tmp*ip[j]%big;
  return tmp;
}

int main(){
  //cout<<fixed<<setprecision(10);
  ll n,k,kk,ans=0;
  string s;
  cin>>s>>k;
  kk=k;
  n=s.size();
  ll i,j;
  for(j=0;k>0&&j<n;){
    for(i=1;i<n-j;i++){
      if(i<k)continue;
      ans+=9*nCk(i-1,k-1)*pow_ans(9,k-1);
    }
    if(!(i<k))ans+=(s[j]-'0'-1)*nCk(i-1,k-1)*pow_ans(9,k-1);
    j++;
    while(s[j]=='0'&&j<n)j++;
    k--;
  }
  ll f=0;
  for(ll q=0;q<n;q++){
    if(s[q]!='0')f++;
  }
  if(f>=kk)ans++;
  cout<<ans<<endl;
}


Measured memory_bytes: 384
open Batteries

let read_two () = Scanf.sscanf (read_line ()) "%d %d" (fun a b -> (a, b))

let read_three () =
  Scanf.sscanf (read_line ()) "%d %d %d" (fun a b c -> (a, b, c))

let read_four () =
  Scanf.sscanf (read_line ()) "%d %d %d" (fun a b c d -> (a, b, c, d))

(* a**x *)
let pow a x =
  let rec aux acc = function 0 -> acc | n -> aux (acc * a) (n - 1) in
  aux 1 x

let rec f k acc = function
  | [] -> acc
  | x :: rest ->
      let d = min x (abs (k - x)) in
      f k (acc + (d * 2)) rest

let () =
  let _ = read_int () and k = read_int () in
  let xs =
    read_line () |> String.split_on_char ' '
    |> List.map (fun s -> int_of_string s)
  in
  print_int (f k 0 xs);
  print_newline ()


Measured memory_bytes: 1024
import java.util.Arrays;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] s = sc.next().toCharArray();
		Arrays.sort(s);
		int num = 1;
		boolean c = true;
		for(int i = 0; i < s.length-1; i++) {
			if(s[i] == s[i+1]) {
				num++;
			}else {
				if(num % 2 != 0) {
					c = false;
					break;
				}
				num = 1;
			}
		}
		if(num % 2 != 0) c = false;
		if(c)System.out.println("Yes");
		else System.out.println("No");
	}
}


Measured memory_bytes: 35564
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
using namespace std;


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
    int N, K;
    cin >> N >> K;
    vector<int> a(N);
    vector<long long> b(N+1), c(N+1);

    for(int i=0; i<N; i++) cin >> a[i];
    b[0] = 0;
    c[0] = 0;
    for(int i=1; i<=N; i++){
        b[i] = b[i-1] + a[i-1];
        c[i] = c[i-1] + max(a[i-1], 0);
    }

    long long ans = 0;
    for(int i=0; i<=N-K; i++){
        int i1 = 0;
        int i2 = i;
        int i3 = i+K;
        int i4 = N;

        long long left = c[i2] - c[i1];
        long long center = max(b[i3] - b[i2], 0ll);
        long long right = c[i4] - c[i3];

        ans = max(ans, left + center + right);
    }

    cout << ans << endl;

	return 0;
}


Measured memory_bytes: 2176
N, K = map(int, input().split())


if K > (N-1)*(N-2)/2:
    print(-1)
else:
    M = int((N-1)*(N-2)/2) - K

    print(M + N - 1)
    for i in range(2, N+1):
        print(1, i)
    for i in range(2, N+1):
        for j in range(i+1, N+1):
            if M > 0:
                M -= 1
                print(i, j)
            else:
                break
        if M == 0:
            break
    


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

typedef long long ll;
const int MOD = 1e9 + 7;
int n;
vector<ll> T, A;
ll l[100010], r[100010];


int main() {
    cin >> n;
    T.resize(n); A.resize(n);
    for(auto& i : T) scanf("%lld", &i);
    for(auto& i : A) scanf("%lld", &i);
    if(T[n-1] != A[0]) {
        puts("0");
        return 0;
    }

    l[0] = 1;
    for(int i=1; i<n; i++) {
        if(T[i-1] < T[i]) {
            l[i] = 1;
            r[i] = T[i];
        } else {
            l[i] = T[i];
            r[i] = -1;
        }
    }

    bool f = true;
    l[n-1] = 1;
    for(int i=n-2; i>=0; i--) {
        if(r[i]!=-1 and A[i] < r[i]) {
            f = false;
            break;
        }
        if(A[i] > A[i+1]) l[i] = 1;
        else l[i] = min(l[i], A[i]);
    }
    if(!f) {
        puts("0");
        return 0;
    }

    ll ans = 1;
    for(int i=0; i<n; i++) ans = (ans * l[i]) % MOD;
    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 3328
#include<iostream>
#include<string.h>
#include<string>
#include<algorithm>
#include<stdio.h>
#include<map>
#include<set>
#define LL long long int
using namespace std;

const int maxn = 150;
const LL mod = 1000000007;
char str[2][maxn];
int n;
int type[maxn];
LL dp[maxn][3][3];

void init()
{
	memset(dp,0,sizeof(dp));
	memset(type,0,sizeof(type));
}

int main()
{
	while(cin >> n)
	{
		init();
		for(int i = 0;i<2;i++) scanf("%s",str[i]);
		int tot = 2;
		for(int i = 0;i<n;i++)
		{
			if(str[1][i] == str[0][i])
			{
				type[tot] = 0;
				tot ++;
			}
			else if(i - 1>=0 && str[1][i] == str[1][i-1])
			{
				type[tot] = 1;
				tot ++;
				type[tot] = 2;
				tot ++;
			}
		}
		
		int st = 0;
		if(type[2] == 0)
		{
			for(int i = 0 ;i<3;i++)
			{
				dp[2][i][1] = 1;
			}
			st = 3;
		}
		else if(type[2] == 1)
		{
			for(int i = 0;i<3;i++)
			{
				for(int j = 0;j<3;j++)
				{
					if(i != j)
					{
						dp[3][i][j] = 1;
					}
				}
			}
			st = 4;
		}
		for(int x = st;x<tot;x++)
		{
			if(type[x] == 0)
			{
				if(type[x-1] == 0)
				{
					for(int tc = 0;tc<3;tc++)
					{
						for(int i = 0;i<3;i++)
						{
							for(int j = 0;j<3;j++)
							{
								if(tc != i)
								{
									dp[x][i][tc] += dp[x-1][j][i];
									dp[x][i][tc] %= mod;
								}
							}
						}
					}
				}
				else if(type[x-1] == 2)
				{
					for(int tc = 0;tc<3;tc++)
					{
						for(int i = 0;i<3;i++)
						{
							for(int j = 0;j<3;j++)
							{
								if(tc != i && tc != j)
								{
									dp[x][i][tc] += dp[x-1][j][i];
									dp[x][i][tc] %= mod;
								}
							}
						}
					}
				}
			}
			else if(type[x] == 1)
			{
				if(type[x-1] == 0)
				{
					for(int tc = 0;tc<3;tc++)
					{
						for(int i = 0;i<3;i++)
						{
							for(int j = 0;j<3;j++)
							{
								if(tc != i)
								{
									dp[x][i][tc] += dp[x-1][j][i];
									dp[x][i][tc] %= mod;
								}
							}
						}
					}
				}
				else if(type[x-1] == 2)
				{
					for(int tc = 0;tc<3;tc++)
					{
						for(int i = 0;i<3;i++)
						{
							for(int j = 0;j<3;j++)
							{
								if(tc != j)
								{
									dp[x][i][tc] += dp[x-1][j][i];
									dp[x][i][tc] %= mod;
								}
							}
						}
					}
				}
			}
			else if(type[x] == 2)
			{
				for(int tc = 0;tc<3;tc++)
				{
					for(int i = 0;i<3;i++)
					{
						for(int j = 0;j<3;j++)
						{
							if(tc != i && tc != j)
							{
								dp[x][i][tc] += dp[x-1][j][i];
								dp[x][i][tc] %= mod;
							}
						}
					}
				}
			}
		}
		LL ans = 0;
		for(int i = 0;i<3;i++)
		{
			for(int j = 0;j<3;j++)
			{
				ans += dp[tot - 1][i][j];
				ans %= mod;
					
			}	
		}	
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
use v5.18;
use warnings;
use List::Util qw( sum );
sub read_line { chomp(my $s = <>); $s }
sub splited_read_line { split / /, read_line }

my $n = read_line;

sub all(&@) {
  my ($code, @values) = @_;
  my $count = 0;
  for my $value (@values) {
    local $_ = $value;
    $count++ if $code->($value);
  }
  $count == scalar @values;
}

sub count {
  my ($s, $c) = @_;
  my @chars = split //, $s;
  my @counter = grep { $_ eq $c } @chars;
  scalar @counter;
}

sub dfs {
  my $s = shift;
  if ( int( $s eq '' ? 0 : $s ) > $n ) {
    0;
  }
  else {
    my $is_753 = ( all { count $s, $_ } split //, '753' ) ? 1 : 0;
    sum( ( map { dfs($s . $_) } split //, '753' ), $is_753 );
  }
}

say dfs('');


Measured memory_bytes: 896
# include <bits/stdc++.h>
# define rr register
const int N=100010,INF=0x3f3f3f3f;
inline int read(void){
	int res,f=1;
	char c;
	while((c=getchar())<'0'||c>'9')
		if(c=='-')f=-1;
	res=c-48;
	while((c=getchar())>='0'&&c<='9')
		res=res*10+c-48;
	return res*f;
}
int main(void){
	char s[100];
	scanf("%s",s+1);
	int n=strlen(s+1);
	for(rr int i=1;i<=n;++i){
		if(s[i]=='7'){
			printf("Yes");
			return 0;
		}
	}
	printf("No");
	return 0;
}


Measured memory_bytes: 3724
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
 


public class Main {
	private static Scanner sc = new Scanner(System.in);
	//result = Math.pow(num1, num3)
	//StringBuffer str = new StringBuffer(hoge1);
	//String hoge2 = str.reverse().toString();
	//map.containsKey(A)

	//Map<String, Integer> map = new HashMap<String, Integer>(n);
	/*for ( キーのデータ型 key : マップの名前.keySet() ) {
		データのデータ型 data = マップの名前.get( key );
		
		// keyやdataを使った処理;
	}*/
	//int i = Integer.parseInt(s);
	//Queue<String> qq=new ArrayDeque<>(); //add,poll,peek
	//Deque<String> qq=new ArrayDeque<>();//push,pop,peek
	//ArrayList<String> cc = new ArrayList<>(n);
	//Collections.sort(list);
	//Array.sort(list);   cc.contains(tmp)
	//Arrays.asList(c).contains("a")
	//list.set(1,"walk");//1 1 2 3 5
	static long mod =1000000007;
	//static 	ArrayList<Integer> cc = new ArrayList<>(100);
	public static void main(String[] args) {
		int	a=sc.nextInt();
		int b=sc.nextInt();
		
		int ans=a;
		
		if(a>b)ans--;
		p(ans);
		
		
	}
	
	
	
	
	/*static boolean v(int i,long sum1,long sum2) {
		if(i==N) {
			long b=Math.abs(sum1-sum2);
			if(b==0) {
				if(sum1<=K) {
					return true;
				}else return false;
			}else if(b%D==0) {
				if(Math.max(sum1, sum2)<=K)return true;
				else return false;
			}
			else return false;
		}
		
		if(v(i+1,sum1,sum2+v[i]%D))return true;
		
		if(v(i+1,sum1+D-v[i]%D,sum2))return true;
		return false;
		
	}*/
	
	
	
	
	

	


	
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p() {System.out.println();};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
	public static int gcd(int a, int b) {
        return b == 0 ? a: gcd(b, a % b);
	}
	static String nextPermutation(String s) {
		ArrayList<Character> list=new ArrayList<>();
		for(int i=0;i<s.length();i++) {
			list.add(s.charAt(i));
		}
		int pivotPos=-1;
		char pivot=0;
		for(int i=list.size()-2;i>=0;i--) {
			if(list.get(i)<list.get(i+1)) {
				pivotPos=i;
				pivot=list.get(i);
				break;
			}
		}
		if(pivotPos==-1&&pivot==0) {
			return "Final";
		}
		int L=pivotPos+1,R=list.size()-1;
		
		
		
		int minPos=-1;
		char min =Character.MAX_VALUE;
		
		for(int i=R;i>=L;i--) {
			if(pivot<list.get(i)) {
				if(list.get(i)<min) {
					min=list.get(i);
					minPos=i;
				}
			}
		}
		
		Collections.swap(list, pivotPos, minPos);
		Collections.sort(list.subList(L, R+1));
		
		
		StringBuilder sb=new StringBuilder();
		for(int i=0;i<list.size();i++) {
			sb.append(list.get(i));
		}
		return sb.toString();
	}
}
	


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

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i <= (ll)(n); i++)
#define INF 10000000000
#define MOD 1000000007
using ll = long long;
using Graph = vector<vector<int>>;

int main(){
    int N; cin>>N;
    string S; cin>>S;
    int Q; cin>>Q;
    // map<char,set<int>> J;//遅い?
    vector<set<int>> J(26,set<int>({1<<30}));
    rep(i,N){
        int ind = (int)(S.at(i)-'a');
        // J[S.at(i)].insert(i);
        J.at(ind).insert(i);
    }
    rep(j,Q){
        int q; cin>>q;
        if(q==1){
            int i; cin>>i;
            i--;
            char c; cin>>c;
            int ind1 = (int)(S.at(i)-'a');
            int ind2 = (int)(c-'a');
            // J[S.at(i)].erase(i);
            J.at(ind1).erase(i);
            // J[c].insert(i);
            J.at(ind2).insert(i);
            S.at(i) = c;
        }else{
            int l,r; cin>>l>>r;
            l--;
            ll res = 0;
            //cout<<l<<r<<endl;
            // for(auto p:J){
            //     set<int> tmp = p.second;
            //     auto iter1 = lower_bound(tmp.begin(),tmp.end(),l);
            //     auto iter2 = lower_bound(tmp.begin(),tmp.end(),r);
            //     auto d1 = distance(tmp.begin(),iter1);
            //     auto d2 = distance(tmp.begin(),iter2);
            //     if(d1<d2)res++;
            // }
            rep(i,26){
                if(J.at(i).empty())continue;
                int lind = *J.at(i).lower_bound(l);
                int rind = *J.at(i).lower_bound(r);
                //cout<<lind<<" "<<rind<<endl;
                if(rind>lind)res++;
            }
            cout<<res<<endl;
            //cout<<S<<endl;
        }
    }
}


Measured memory_bytes: 24196
def b():
    a,b,c,d = map(int, input().split())
    while True:
        c -= b
        if c <= 0:
            print('Yes')
            break
        a -= d
        if a <= 0:
            print('No')
            break

def a():
    s, w = map(int, input().split())
    if w >= s:
        print('unsafe')
    else:
        print('safe')



b()

Measured memory_bytes: 9164
#include <iostream>
#include <vector>
 
int main(){
    u_int a, b;
    while(std::cin >> a >> b){
        if(a == 0 && b == 0){
            return 0;
        }
		
        std::vector<std::vector<u_int>> path(a+1);
        for(int i = 0; i < a+1; ++i){
            path[i].resize(b+1, 1);
        }
         
        u_int n;
        std::cin >> n;
        for(int i = 0; i < n; ++i){
            int x, y;
            std::cin >> x >> y;
            path[x][y] = 0;
        }
         
        for(int i = 0; i <= a; ++i) path[i][0] = 0;
        for(int i = 0; i <= b; ++i) path[0][i] = 0;
         
        for(int x = 1; x <= a; ++x){
            for(int y = 1; y <= b; ++y){
                if( path[x][y] != 0 && (x != 1 || y != 1) ){
                    path[x][y] = path[x-1][y] + path[x][y-1];
                }
            }
        }
         
        std::cout << path[a][b] << std::endl;
         
    }
    return 0;
}

Measured memory_bytes: 1196
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
using namespace std;
typedef long long ll;

const ll MOD = 1e9+7;


int main()
{
	string n;
	cin>>n;
	int ans=0;
	for(int i=0;i<2;i++)
	{
		int tmp=0;
		for(int j=0;j<2;j++)
		{
			tmp*=10;
			tmp+=n[i*2+j]-'0';
		}
		if(tmp>0 && tmp<13)
			ans+=(1<<i);
	}

	switch(ans)
	{
		case 0:
		cout<<"NA"<<endl;
		break;
		case 1:
		cout<<"MMYY"<<endl;
		break;
		case 2:
		cout<<"YYMM"<<endl;
		break;
		case 3:
		cout<<"AMBIGUOUS"<<endl;
		break;
	}
	return 0;
}

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

class Osa_k {
private:
    int n;
    vector<int> factor;
public:
    Osa_k(int _n):n(_n) {
        factor.assign(n, 0);
        iota(factor.begin(), factor.end(), 0);
        for(int i = 2; i < n; i++) {
            if(factor[i] != i)continue;
            for(int j = i + i; j < n; j += i) factor[j] = i;
        }
    }

    vector<pair<int,int>> fact(int v) {
        map<int, int> ret;
        while(v != factor[v]) {
            ret[factor[v]]++;
            v /= factor[v];
        }
        if(v != 1)ret[v]++;
		vector<pair<int,int>> t;
		for(auto i : ret)t.push_back(i);
        return t;
    }

    vector<int> divisor(int v) {
        vector<int> que = {1};
        vector<pair<int,int>> a = fact(v);
        for(auto i : a) {
            int num = 1;
            vector<int> nxt;
            for(int j = 0; j <= i.second; j++) {
                int m = que.size();
                for(int k = 0; k < m; k++)nxt.push_back(num * que[k]);
                num *= i.first;
            }
            swap(que, nxt);
        }
        sort(que.begin(), que.end());
        return que;
    }

}fact(1000001);

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> in(1000001);
    for(int i = 0; i < n; i++)cin >> a[i], in[a[i]]++;
    int sum = 0;
 
    for(int i = 0; i < n; i++) {
        vector<int> num = fact.divisor(a[i]);
        int res = 0;
        for(int j = 0; j < (int)num.size(); j++) {
            res += in[num[j]];
        }
        if(res == 1)sum++;
    }
    cout << sum << '\n';
}

Measured memory_bytes: 11908
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define LL long long
#define endl "\n"

using namespace std ;

int main( void )
{

    LL a,b,c,d ;
    
    cin >> a >> b >> c >> d ;
    
   
    
    LL ans = b-a+1 ;
 //   cout << ans << endl ;
    LL lcm_of_c_and_d = (c/__gcd(c,d))*d ;
    
  //  cout << lcm_of_c_and_d << endl ;
   
    
    ans -= ( ( b/c - a/c ) +  ( b/d - a/d )  ) ;
    
 //   cout  << ans << endl ;
    
    ans += ( b/lcm_of_c_and_d - a/lcm_of_c_and_d ) ;
    
    
    
  //  cout  << ans << endl ;
    
    if( !(a%c)  ) ans-- ;
    
    
  
    // cout << ans << endl ;
   
    /*
        if( !(a%d) && d != c && (d%c) != 0 ) ans-- ;
  
   
  
    if( !(a%lcm_of_c_and_d)    )
    if( (lcm_of_c_and_d%c) != 0 )
    if( (lcm_of_c_and_d%d) != 0 )
    ans-- ;  
    */
    
  
    if(ans>=0)
        cout << ans ;  
    else  
        cout << 0 ;
        
    return 0 ;

}


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

int main(){
    int N,M; cin >> N >> M;
    char A[N][N];
    char B[M][M];
    for(int i=0;i<N;i++){
        string a; cin >> a;
        for(int j=0;j<N;j++){
            A[i][j]=a[j];
        }
    }
    for(int i=0;i<M;i++){
        string b; cin >> b;
        for(int j=0;j<M;j++){
            B[i][j]=b[j];
        }
    }
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            bool flag=true;
            for(int k=0;k<M;k++){
                for(int l=0;l<M;l++){
                    if(i+k>=N||j+l>=N){
                        flag=false;
                        break;
                    }
                    if(B[k][l]==A[i+k][j+l]) continue;
                    flag=false;
                    break;
                }
                if(!flag) break;
            }
            if(flag){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <iomanip>

using namespace std;
using ll = long long;

#define rep(i,N) for(int i=0;i<(int)N;++i)

#include <iostream>

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

    if (B % A == 0) { cout << A + B << endl; }
    else { cout << B-A << endl; }
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cstdio>

#include<vector>
#include<queue>
#include<set>
#include<map>
#include<string>

#include<algorithm>
#include<cmath>

using namespace std;
typedef long long ll;
template <class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template <class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
const ll INF = 1e9;

ll N, M;


//数字最大のものから、ソートしたAに対して順々に貪欲に適用していく
//A以下の値しか残らなかった時点で終了

bool paircmp(pair<ll,ll> a, pair<ll,ll> b) {
    return a.first > b.first;
}

int main() {
    cin >> N >> M;
    vector<ll> A(N);
    vector<pair<ll,ll>> V(M); 
    for (ll i = 0; i < N; i++) cin >> A[i];
    for (ll i = 0; i < M; i++) {
        ll b, c;
        cin >> b >> c;
        V[i] = make_pair(c,b);
    }
    sort(A.begin(),A.end());
    sort(V.begin(),V.end(),paircmp);
    
    ll j = 0;
    for (ll i = 0; i < N; i++) {
        if (A[i] < V[j].first) {
            A[i] = V[j].first;
            V[j].second--;
        } else break;
        if (V[j].second == 0) j++;
    }

    ll res = 0;
    for (ll i= 0; i < N; i++) {
        res += A[i];
    }
    cout << res << endl;





}



Measured memory_bytes: 2560
import java.util.Scanner;

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

        int n = stdIn.nextInt();
        int m = stdIn.nextInt();

        long sum = 0;
        for(int i=0; i<m; i++){
            sum += stdIn.nextLong();
        }

        if(sum <= n){
            System.out.println(n - sum);
        }else{
            System.out.println(-1);
        }
    }
}

Measured memory_bytes: 46264
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < n; i++)
#define reps(i, m, n) for (int i = m; i < n; i++)
#define repr(i, m, n) for (int i = m; i >= n; i--)
#define db(x) cout << #x << "=" << x << endl;
template <class T>
bool maxi(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool mini(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
#define INF2 1000000000000000037
#define INF 1000000007
#define PI (acos(-1))
#define MOD 1000000007
#define EPS 1e(-9);
using namespace std;
typedef long long ll;
//--GLOBAL---------------------------------

//--MAIN-----------------------------------
void Main() {
    int N;
    cin >> N;
    int ans=0;

    ans=N/2;

    if(N%2==0) --ans;

    cout<< ans <<"\n";


}

//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    int x;
    cin>>x;
     if(x>=400&&x<=599)
    {
        cout<<"8"<<endl;
    }
     if(x>=600&&x<=799)
    {
        cout<<"7"<<endl;
    }
     if(x>=800&&x<=999)
    {
        cout<<"6"<<endl;
    }
     if(x>=1000&&x<=1199)
    {
        cout<<"5"<<endl;
    }
     if(x>=1200&&x<=1399)
    {
        cout<<"4"<<endl;
    }
     if(x>=1400&&x<=1599)
    {
        cout<<"3"<<endl;
    }
     if(x>=1600&&x<=1799)
    {
        cout<<"2"<<endl;
    }
     if(x>=1800&&x<=1999)
    {
        cout<<"1"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3632
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val a = readLine()!!.split(' ').map { it.toLong() }
    val count = hashMapOf<Long,Int>()
    count[0] = 1

    var ans = 0L
    var sum = 0L
    a.map {
        sum += it
        ans += count.getOrDefault(sum, 0)
        count[sum] = count.getOrDefault(sum, 0) + 1
    }
    println(ans)
}

Measured memory_bytes: 81172
import sys
sys.setrecursionlimit(10000)

N,M,P=map(int,input().split())
ways=[[] for _ in range(N)]
Rways=[[] for _ in range(N)]

for i in range(M):
  A,B,C=map(int,input().split())
  ways[A-1].append([B-1,C-P])
  Rways[B-1].append(A-1)
  
  
visited=[-float("inf")]*N
visited[0]=0

blacklist=[True]*N
blacklist[-1]=False
"""
for c in range(M):
  for i in range(N):
    if blacklist[i]==True:
      continue
    for to in Rways[i]:
      blacklist[to]=False
"""
def b_update(nord):
  global blacklist
  for to in Rways[nord]:
    if blacklist[to]==True:
      blacklist[to]=False
      b_update(to)
      
b_update(N-1)

for c in range(N):
  flag=False
  for i in range(N):
    debit=visited[i]
    if debit==-float("inf"):
      continue
    for to,cost in ways[i]:
      if visited[to]<debit+cost and not blacklist[to]:
        visited[to]=debit+cost
        flag=True
        
  if not flag:
    break
  if c==N-1:
    print(-1)
    exit()
      
ans=visited[-1]
if ans==-float("inf"):
  print(-1)
else:
  print(max(ans,0))
  
  


Measured memory_bytes: 81912
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>

using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

int main() {

    ll K,N;
    cin >> K >> N;
    ll A[N];
    ll sum = 0;
    ll max = 0;
    rep(i,N){
        cin >> A[i];
        if(i>0){
            ll l = abs(A[i] - A[i-1]);
            sum += l;
            if(l>max) max = l;
        }
    }
    ll c = A[0]+K - A[N-1];
    sum += c;
    if(c>max) max = c;
    ll out = sum - max;;
    cout << out << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>
#include <cstdint>



#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rrep(i, n) for(ll i = (ll)(n-1); i >= 0; i--)
#define repi(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rrepi(i,a,b) for(ll i=(ll)(b-1);i>=(ll)(a);i--)

#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;cin>>s;
  rep(i,s.length()-1){
    if(s[i]=='A'&&s[i+1]=='C'){
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  cout<<"No"<<endl;
  return 0;

}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var (
		n     int
		count int
	)

	fmt.Scan(&n)
	nums := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&nums[i])
	}

	count = 0
	f := true
	for f {
		for i, t := range nums {
			if t%2 == 0 {
				nums[i] /= 2
			} else {
				f = false
			}
		}
		if f {
			count++
		}
	}
	fmt.Println(count)
}


Measured memory_bytes: 512
X,Y = map(int,input().split())

if X == Y == 1:
    print(1000000)
else:
    if X <= 3 and Y <= 3:
        print(((4-X)+(4-Y))*10**5)
    elif X >= 4 and Y >= 4:
        print(0)
    else:
        print((4-min(X,Y))*10**5)

Measured memory_bytes: 9100
#include <iostream>
#include <algorithm>
#define INF 1000000001
using namespace std;
int dp[100005];
int main(){
      ios::sync_with_stdio(false);
      int n,tmp; cin >> n;
      fill(dp,dp+n,INF);
      for (int i = 0;i < n; i++){
            cin >> tmp;
            *lower_bound(dp,dp+n,tmp) = tmp;
      }
      cout << lower_bound(dp,dp+n,INF) - dp<<endl;
}

Measured memory_bytes: 1588
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
#include <cmath>
#include <stack>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll = long long int;

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}

const long long MOD = 1000000007;

int main(){
  int N;
  int f=1;
  
  cin>>N;
  for(int i=1; i<=N; i++)
    f*=i;
  vector<pair<ll,ll>> v(N);
  for(int i=0; i<N; i++) {
    ll x, y;
    cin>>x>>y;
    v[i] = make_pair(x,y);
  }
  sort(v.begin(), v.end());
  double ans;
  do{
    for(int i=0; i+1<N; i++) {
      ans += sqrt(pow(v[i].first-v[i+1].first, 2)+pow(v[i].second-v[i+1].second, 2));
    }
  }while(next_permutation(v.begin(), v.end()));
  std::cout << setprecision(15) << ans / (double)f << std::endl;
  return 0;
}



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

int main() {
    int h, w;
    while(true) {
        cin >> h >> w;
	if(h==0 && w==0) break;

	for(int i=0; i<h; i++){
	    for(int j=0; j<w; j++){
	        cout << '#' << flush;
		if(j==w-1)cout << endl;
	    }
	}

	cout << endl;
    }
}

Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define req(i,n) for(int i = 1;i <=n;i++)
#define pai 3.14159265358979323846
const int INF = 1001001001;
typedef long long ll;
int A[3][3], N;
bool punched[3][3];
bool ok[3][3];
using Graph = vector<vector<int>>;
vector<vector<int>> field;
vector<bool> seen;

const int MOD = 1000000007;
typedef pair<int,int> P;

//最大公約数
int gcd(int a,int b){
	if (a%b == 0){
		return b;
	}
	else{
		return gcd(b,a%b);
	}

}

//最小公倍数
int lcm(int a,int b){
	return a /gcd(a,b) * b;
}

//素数判定
bool is_prime(long long N) {
    if (N == 1) return false;
    for (long long i = 2; i * i <= N; ++i) {
        if (N % i == 0) return false;
    }
    return true;
}




#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;


   


int main() {
  int a,b,c,d,e;
  cin >> a >> b >> c >> d >> e;
  int t[5];
  
  t[0]=a%10;
  t[1]=b%10;
  t[2]=c%10;
  t[3]=d%10;
  t[4]=e%10;
  int mini=INF,cnt=0;
//cout << endl;
  rep (i,5){
   //cout << t[i] << endl;
    if (t[i]==0){

      cnt++;
    }
    else  mini=min(mini,t[i]);
  }
  if (mini>10) mini=0;
  a-=t[0];
  b-=t[1];
  c-=t[2];
  d-=t[3];
  e-=t[4];
//cout << cnt << endl;
if (cnt!=5)
cout << a+b+c+d+e+((5-cnt-1)*10)+mini << endl;
else cout << a+b+c+d+e+((5-cnt)*10)+mini << endl;
}



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

int main(void){
   int K;
   cin>>K;
   string s;
   cin>>s;
   if(s.size()<=K){
      cout<<s<<endl;
   }else{
      for(int i=0;i<K;i++){
         if(i<=K-1) cout<<s[i];
      }
      cout<<"...";
   }
   return 0;
}



Measured memory_bytes: 3624
import math
N, K = map(int, input().split())
ans = 0
deno = 0
for i in range(1, N + 1):
    tmp = i
    cnt = 0
    while tmp < K:
        tmp = tmp * 2
        cnt += 1
    deno += math.pow(1 / 2, cnt)
ans = 1 / N * deno
print(ans)

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

long long n, a[200000], sum[200000];

int main() {
	const long long mod = 1e9 + 7;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (i == 0) sum[0] = a[0];
		else sum[i] = sum[i - 1] + a[i];
	}
	long long ans = 0;
	for (int i = 0; i <= n - 2; i++) {
		ans = ((ans % mod) + (((a[i] % mod) * ((sum[n - 1] - sum[i]) % mod)) % mod)) % mod;
	}
	cout << ans;
	return 0;
}



















Measured memory_bytes: 6716
#include<stdio.h>

int main()
{
    char s1[20];
    char s2[20];
    char s3[20];
    scanf("%s%s%s", s1, s2, s3);
    int l1, l2, l3;
    for(l1=0; s1[l1]!='\0'; ++l1){
    }
    for(l2=0; s2[l2]!='\0'; ++l2){
    }
    for(l3=0; s3[l3]!='\0'; ++l3){
    }
    if(s1[l1-1]==s2[0] && s2[l2-1]==s3[0]){
        puts("YES");
    }
    else{
        puts("NO");
    }
}


Measured memory_bytes: 128
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << 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...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

int main() {
  int n;
  scanf("%d", &n);
  vector<int64> b(n);
  int64 all = 0;
  for (int i = 0; i < n; ++i) {
    scanf("%lld", &b[i]);
    b[i] *= 2;
    all += b[i];
  }
  all /= 2;
  // trace(all);
  vector<int64> L(n + 1), R(n + 1);
  for (int i = 2; i < n; ++i) {
    L[i] = L[i - 2] + b[i - 2];
  }
  for (int i = n - 2; i >= 0; --i) {
    R[i] = R[i + 2] + b[i];
  }
  // for (int i = 0; i < n; ++i) {
  //   trace(i, L[i], R[i]);
  // }
  vector<int64> ret(n);
  for (int i = 0; i < n; ++i) {
    if (i % 2 == 0) {
      ret[i] = all - R[i + 1] - L[i];
    } else {
      ret[i] = all - R[i + 1] - L[i] - b[n - 1];
    }
  }
  for (int i = 0; i < n; ++i) {
    printf("%lld%c", ret[i], " \n"[i + 1 == n]);
  }
  return 0;
}


Measured memory_bytes: 4480
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = numeric_limits<int>::max() /4;
const ll linf = numeric_limits<ll>::max() /4;
const ull ulinf = numeric_limits<ull>::max()/4;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.end(), v.begin());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////

ll n;

int main(){
    cin >> n;

    itn nx = 0,ny = 0,nt = 0;

    rep(i,0,n){
        int t,x,y;
        cin >> t >> x >> y;
        
        if(abs(x-nx) + abs(y-ny) == t-nt){
            nx = x;
            ny = y;
            nt = t;
        }else if(abs(x-nx) + abs(y-ny) < t-nt && (abs(x-nx) + abs(y-ny) -( t-nt))%2 == 0){
            nx = x;
            ny = y;
            nt = t;
        }else{
            No;
            ret 0;
        }  
    }
	
	Yes;
	return  0;
}

Measured memory_bytes: 256
def kaizyo(n)
  if(n < 2) 
    return 1
  else
    a=1
    (2..n).each do |d|
      a *= d
      a %= (10**9+7)
    end
    return a
  end
end  

def inp() a=gets.chomp.split(" ").map(&:to_i)end
n,m = inp
d = kaizyo(n) * kaizyo(m)
if ((n-m).abs >= 2)
  puts 0
  exit
end
if (n==m)
  d *= 2
end
puts (d %= (10**9+7))

Measured memory_bytes: 1788
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iterator>
#include <numeric>
#include <bitset>
#include <cassert>
#include <functional>

using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)

int main() {
	int r;
	cin >> r;
	cout << 3 * r * r << endl;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
Alist = list(map(int, input().split()))
Blist = list(map(int, input().split()))
Clist = list(map(int, input().split()))
point = sum(Blist)
for i in range(0, N - 1):
    if Alist[i + 1] == Alist[i] + 1:
        point += Clist[Alist[i] - 1]

print(point)


Measured memory_bytes: 3060
#include<iostream>
#include<cmath>
using namespace std;
int main(){
  int id,n;
  double h,w;
  while(cin>>n){
    if(n==0) break;
    double ans;
    int ansid;
    for(int i=0;i<n;i++){
      cin >> id >> h >> w;
      h /= 100;
      if(i==0){
	ans = fabs(22 - w / (h * h));
	ansid = id;
      }
      else{
	if(ans>fabs(22-w/(h * h))){
	  ans = fabs(22 - w / (h * h));
	  ansid = id;
	}
      }
    }
    cout << ansid << endl;
  }
  return 0;
}

Measured memory_bytes: 1228
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;
#define min(x,y) (x<y?(x):(y))

bool cmp(long long x, long long y){
    return x>y;
}
int main()
{
    int ca, cb, cc, k;
    cin>>ca>>cb>>cc>>k;

    //vector<long long> a, b, c; 错解，会RE
    vector<long long> a(ca), b(cb), c(cc);
    for (int i=0; i<ca; i++) cin>>a[i];
    for (int i=0; i<cb; i++) cin>>b[i];
    for (int i=0; i<cc; i++) cin>>c[i];

    vector<long long> tmp;
    for (int i=0; i<ca; i++)
        for (int j=0; j<cb; j++)
            tmp.push_back(a[i]+b[j]);
    sort(tmp.begin(), tmp.end(), cmp);

    vector<long long> ans;
    for (int i=0; i<tmp.size()&&i<k; i++)
        for (int j = 0; j < cc; j++)
            ans.push_back(tmp[i] + c[j]);
    sort(ans.begin(), ans.end(), cmp);

    for (int i = 0; i < k; i++)
        cout << ans[i] << endl;
    return 0;
}


Measured memory_bytes: 43240
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()
#define endl "\n"

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

// 最善手でたどり着いた時の余ったターンで考える
void solve() {
    int N;
    cin >> N;
    int bt = 0;
    int bx = 0;
    int by = 0;
    REP(i,N) {
        int t,x,y;
        cin >> t >> x >> y;
        t-=bt;
        x-=bx;
        y-=by;
        x = abs(x);
        y = abs(y);
        // そう移動距離
        auto d = x+y;
        if ( t >= d && (t-d)%2 == 0) continue;
        else {
            cout << "No" << endl;
            return;
        }
    }
    cout << "Yes" << endl;
    return;
}

int main() {
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
#define rep(i,n) for (int i=0; i<n;++i)
#define rep_down(i,n) for (int i=n-1; i>=0;--i)
typedef long long ll;
using namespace std;
const ll MOD = 1000000007ll;
int N;
map< int, ll > factors;

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

// 検証例

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

  cin >> N;
  rep_down(i, N+1){
    if (i==0) continue;
    prime_factor(i);
  }
  ll ans = 1ll;
  for(auto p: factors){
    ans *= (p.second +1);
    ans%=MOD;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
def preparing_boxes(a)
  b = Array.new(a.size, 0)
  (a.size).downto(1) do |i|
    sum = 0
    (i - 1).step(a.size - 1, i) do |j|
      sum += b[j]
    end

    b[i - 1] = 1 if sum % 2 != a[i - 1]
  end

  ans = []
  b.each_with_index { |n, i| ans << i + 1 if n == 1 }
  puts ans.size
  puts ans.join("\s") unless ans.empty?
end

gets
a = gets.split.map(&:to_i)
preparing_boxes(a)


Measured memory_bytes: 22148
import java.util.*;
public class Main  {
   public static void main(String[] args)  {
      Scanner sc = new Scanner(System.in);
      
      int k = sc.nextInt();
      int a = sc.nextInt();
      int b = sc.nextInt();
      
      int x = ( a/k + 1 ) * k;
            
      if (x <= b || a % k == 0 || b % k == 0 || k == 1) {
         System.out.println("OK");
      } else {
         System.out.println("NG");
      }
   }
}


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

#define REP(i, n) for(int i = 0; i < (n); i++)

const int MAX = 100000;

int function(int P, int k, int w[], int m)
{
  int j = 0;
  int c = 0;
  int nk = 0;
  int np = 0;
  while(nk < k){
    for(int i = j; i < m; i++, c++){
      np += w[i];
      if(np > P){
	np = 0;
	j = i;
	break;
      }
      if(i == m - 1)
	return m;
    }
    nk++;
  }
  return c;
}

int binarySearch(int key, int k, int w[], int m){
  int left = 0;
  int right = MAX * 10000;
  int mid;
  while(left + 1 < right){
    mid = (left + right) / 2;
    if(function(mid, k, w, m) < key)
      left = mid;
    else
      right = mid;
  }
  return right;
}

int main()
{
  int n, k;
  cin >> n >> k;
  int w[n];
  REP(i, n)
    cin >> w[i];
  cout << binarySearch(n, k, w, n) << endl;
}

Measured memory_bytes: 1552
import sys
input = sys.stdin.readline

n, q = map(int, input().split())
C = [0] + list(map(int, input().split()))
D = [-1]*(n+1)
A = [0]*q
U = 10**6
LR = tuple(tuple(map(int, input().split())) for _ in range(q))
W = sorted(r*U+i for i, (l, r) in enumerate(LR))
B = [0]*(n+1)
def add(i, a):
  while i <= n:
    B[i] += a
    i += i & -i
def acc(i):
  res = 0
  while i:
    res += B[i]
    i -= i & -i
  return res
temp = 1
for w in W:
  r, i = divmod(w, U)
  while temp <= r:
    c = C[temp]
    add(temp, 1)
    if D[c] != -1:
      add(D[c], -1)
    D[c] = temp
    temp += 1
  l = LR[i][0]
  A[i] = acc(r) - acc(l-1)
print(*A, sep="\n")

Measured memory_bytes: 226628
import java.io.*;
import java.util.*;
import java.util.function.*;

final class Solver {
	void solve(Supplier<String> sc) {
		int N = Integer.parseInt(sc.get());
		long K = Long.parseLong(sc.get());
		long[] A = new long[N];
		Arrays.setAll(A, $ -> Long.parseLong(sc.get()));
		var count = new int[40];
		for (int i = 0; i < 40; i++) {
			long bit = 1L << i;
			for (long l : A) {
				if ((l & bit) != 0) count[i]++;
			}
		}

		long[][] dp = new long[2][41]; // 0: smaller, 1: same
		Arrays.fill(dp[0], Integer.MIN_VALUE);
		dp[1] = Arrays.copyOf(dp[0], dp[0].length);
		dp[1][40] = 0;
		for (int i = 40 - 1; i >= 0; i--) {
			long bit = 1L << i;
			var cnt = count[i];
			var turnOn = (N - cnt) * bit;
			var turnOff = cnt * bit;
			if (dp[0][i + 1] != Integer.MIN_VALUE) dp[0][i] = dp[0][i + 1] + Math.max(turnOff, turnOn);
			if ((K & bit) != 0) {
				dp[0][i] = Math.max(dp[0][i], dp[1][i + 1] + turnOff);
				dp[1][i] = dp[1][i + 1] + turnOn;
			} else {
				dp[1][i] = dp[1][i + 1] + turnOff;
			}
		}

		System.out.println(Math.max(dp[0][0], dp[1][0]));
	}
}

class Main {
	public static void main(String... args) {
		System.setOut(new PrintStream(new BufferedOutputStream(System.out)));
		var reader = new BufferedReader(new InputStreamReader(System.in));
		new Solver().solve(new Supplier<>() {
			StringTokenizer line;

			public String get() {
				while (line == null || !line.hasMoreTokens()) try {
					line = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
				return line.nextToken();
			}
		});
		System.out.flush();
	}
}

Measured memory_bytes: 48416
import java.util.Scanner;

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

	int K, X;
	K = sc.nextInt();
	X = sc.nextInt();

	int count = X - K + 1;
	for (int i = 0; i < (2 * K) - 1; i++, count++)
	    System.out.print(count + " ");

	System.out.println();
    }
}

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

using namespace std;
#define _for(i,j,N) for(int i = (j);i < (N);i++)
#define _rep(i,j,N) for(int i = (j);i <= (N);i++)
#define _dec(i,N,j) for(int i = (N-1);i >= (j);i--)
#define _rec(i,N,j) for(int i = (N);i >=(j);i--)
#define ALL(x) x.begin(),x.end()
#define MEM(a,n) memset(a,n,sizeof(a))
#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define PTR2(a,j,N,k,L) for(int i = (j); i <= (N);i++) see(a[i],k,L);

typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

int get_int(){int x;scanf("%d",&x);return x;}
LL get_ll(){LL x;scanf("%lld",&x);return x;}
double get_db(){double x;scanf("%lf",&x);return x;}

template<typename T> int chmin(T &a,T b){if(a > b){a = b;return 1;}else return 0;}
template<typename T> int chmax(T &a,T b){if(a < b){a = b;return 1;}else return 0;}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {_for(i,0,v.size()) os << v[i] << " ";return os;}
template<typename T>
ostream& operator<<(ostream& os,const set<T>& v){for(auto a:v) os << a <<" ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& v){os << v.fst <<" "<<v.scd << " ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const map<T1,T2>& v){for(auto a:v) cout << a << endl;return os;}
template<typename T> void see(T a[],int from,int to){ _rep(i,from,to) cout << a[i]<<" ";cout << endl;}

static const int dx[8] = { -1,  0, 1, 0,  1, -1,  1, -1};
static const int dy[8] = {0,  1, 0,  -1,  1, -1, -1,  1};
const double pi  = acos(-1.0);
const double eps = 1e-8;
const LL  INF  = 0x3f3f3f3f3f3f3f3f;
const int inf  = 0x3f3f3f3f;


int main()
{
    int N;
    cin >> N;
    int minnum = 1e9;
    int ans = 0;
    _for(i,0,N){
        int num;
        cin >> num;
        if(num <= minnum) ans++;
        minnum = min(num,minnum);
    }
    cout << ans << endl;
    return 0;
}


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

int main()
{
    int $=1;
    //cin>>$;
    while($--)
    {
        ll x,k,d;
        cin>>x>>k>>d;
        x=abs(x);
        ll t=x/d;
        ll a=x%d;
        if(k<=t)
        {
            a=x-k*d;
        }
        else{
            k-=t;
            if(k%2==1)
            {
                a-=d;
                a=abs(a);
            }
        }
        cout<<a<<endl;
    }
}


/*
8888888888888888888888888888
    Md. Masud Mazumder
    University of Chittagong
    Department of CSE
8888888888888888888888888888
*/


Measured memory_bytes: 3632