akhauriyash/Code-Regression huggingface dataset:
a, b, c = map(int, input().split())

# n*a /b >
if (a % 2 == 0 and b % 2 == 0 and c % 2 != 0):
    print('NO')
elif (a % 2 == 0 and b % 2 != 0 and c % 2 == 0):
    print('NO')


else:
    count = 0
    while count < 10 ** 7:
        count += 1
        if ((a * count) % b == c):
            print('YES')
            exit()

    print('NO')


Measured memory_bytes: 9136
#include <iostream>
#include <cstring>
#include <cctype>
#include <cmath>
using namespace std;

int main() {
    int d, t, s;
    cin >> d >> t >> s;
    int realTime = (int)ceil((double)d / (double)s);
    if (realTime <= t) {
        cout << "Yes";
    } else {
        cout << "No";
    }
	return 0;
}



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

using namespace std;

int main(){
	long long int N;
	cin >> N;
	vector<long long int>D(N), E(N);

	for( size_t i = 0; i < N; i++ ){
		cin >> D[i];
		E[D[i] - 1] = i;
	}
	long long int ans1 = 1;
	long long int memo = 1;
	for( size_t i = 1; i < N; i++ ){
		if( E[i - 1] < E[i] ){
			memo++;
		} else{
			ans1 = max(memo, ans1);
			memo = 1;
		}
	}
	ans1 = max(memo, ans1);
	cout << N - ans1 << endl;
}

Measured memory_bytes: 3328
//
//  ROIGold.cpp
//  Main calisma
//
//  Created by Rakhman on 05/02/2019.
//  Copyright © 2019 Rakhman. All rights reserved.
//

#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cassert>
#include <iterator>
#include<unordered_map>

#define ios ios_base::sync_with_stdio(0), cin.tie(0);
#define S second
#define F first
#define pb push_back
#define nl '\n'
#define NL cout << '\n';
#define EX exit(0)
#define all(s) s.begin(), s.end()
#define FOR(i, start, finish, k) for(llong i = start; i <= finish; i += k)

const long long MXN = 3 * 1e6 + 1;
const long long MNN = 4444;
const long long MOD = 10;
const long long INF = 1e9;
const long long OO = 1e9 + 1;
const double pi = acos(-1.0);

typedef long long llong;
typedef unsigned long long ullong;

using namespace std;

llong n, k, b[MXN], p[MXN], sum, mx, pl[MXN];

llong calc(int ind){
    llong x = pl[n] - pl[ind] + pl[ind - k];
    return max(x, x + p[ind] - p[ind - k]);
}

int main(){
    ios;
    cin >> n >> k;
    for(int i = 1; i <= n; i++){
        cin >> b[i];
        p[i] = p[i - 1] + b[i];
        pl[i] = pl[i - 1] + max(0LL, b[i]);
    }
    for(int i = k; i <= n; i++){
        mx = max(calc(i), mx);
    }
    cout << mx;
    return 0;
}


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

int main()
{
    std::ios::sync_with_stdio(false);
    lld t = 1;
    // cin >> t;
    while(t--) {
        lld n, k;
        cin >> n >> k;
        string s;
        cin >> s;
        for(lld i = 0; i < n; i++) {
            if(i == k - 1) {
                s[i] = tolower(s[i]);
            }
        }
        cout << s << "\n";
    }
}

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

int main(){
	int H , W ;
	cin >> H >> W;
	vector <int>  A(H) , B(W);
	vector<vector<char>> C (H , vector<char> (W));
	for (int i = 0; i < H; i++){
		for (int j = 0; j < W; j++){
			cin >> C.at(i).at(j);
			if(C.at(i).at(j) == '#'){
				A.at(i) = 1;
				B.at(j) = 1;
			}
		}
	}

	for (int i = 0; i < H; ++i){
		if(A.at(i)){
			for (int j = 0; j < W; ++j) {
	     		if(B.at(j)){
					 cout << C.at(i).at(j);
				 }
    		}
			cout << endl;
		}
  	} 
}

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

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

Measured memory_bytes: 3644
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>
#include<set>
#include<cstdio>

using namespace std;

#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define P pair<int, int>

typedef vector<int> vec;
typedef vector<vec> mat;

const ll mod = 1000000007;

int main(){
    int n, k, q;
    cin >> n >> k >> q;
    int a[q];
    rep(i, q){
        cin >> a[i];
        a[i]--;
    }
    int p[n];
    fill(p, p + n, 0);
    rep(i, q){
        p[a[i]]++;
    }
    rep(i, n){
        if(k - q + p[i] > 0){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl; 
        }
    }
    // rep(i, n){
    //     cout << p[i] << endl;
    // }
}

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

using namespace std;

int N,X,T;
int wak,out;

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

    wak = N/X;
    out = wak * T;

    if(N % X != 0){
        out += T;
    }

    cout<<out<<endl;
    return 0;
}


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

using namespace std;
typedef long long ll;
//#define int ll
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
#define FOR(i, a, b) for (int i = a; i < b; ++i)

typedef pair<int, int> pii;
typedef pair<double, int> pdi;

const int INF = 1000 * 1000 * 1000 + 10;
const ll INFLL = 1000ll * 1000 * 1000 * 1000 * 1000 * 1000;

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif

    int n;
    cin >> n;

    if (n & 1) {
        cout << "Np\n";
        return 0;
    }

    vector<int> a(n);
    for (int &t : a)
        cin >> t;

    sort(ALL(a));

    cout << a[n / 2] - a[n / 2 - 1];
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(v) v.begin(), v.end()
#define chmax(x,y) (x = max(x,y))
#define chmin(x,y) (x = min(x,y))

using ll = long long;
using PAIR = pair<int, int>;
using PAIRLL = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;

int main()
{
  ll Q, l, r,sum_sim=0,ans,fans;
  vi prime(0),prime_check(100000,0),similar(100000,0),ANS(100000);

  cin >> Q;

  rep(i,100000)
  {
    if(i==0||i==1)
      continue;
    else if (i==2)
    {
      prime.push_back(3);
      prime_check[2] = 1;
    }
    else
    {
      rep(j,prime.size())
      {
        if((i+1)%prime[j]==0||(i+1)%2==0)
          goto OUT;
      }
      prime.push_back(i + 1);
      prime_check[i] = 1;
    OUT:;
    }
  }

  rep(i,prime.size())
  {
    if((prime[i]*2-1)<=100000)
    {
      similar[prime[i]*2-2] = 1;
    }
    if((prime[i]*2)-1>=100000)
      break;
  }
  similar[2] = 1;

  ans = 0;

  rep(i, 100000)
  {
    if (prime_check[i] == 1 && similar[i] == 1)
      {
        ans++;
      }
      ANS[i] = ans;
  }

  rep(i,Q)
  {
    cin >> l >> r;
    if(prime_check[l-1]==1&&similar[l-1]==1)
      {
        fans = ANS[r - 1] - ANS[l - 1]+1;
      }
    else fans = ANS[r - 1] - ANS[l - 1];

    cout << fans<< endl;
  }
  return 0;
}


Measured memory_bytes: 4540
import java.util.*;

public class Main {

	public static void main(String[] args) {
		@SuppressWarnings("resource")
		Scanner stdin = new Scanner(System.in);

		long inX = stdin.nextLong();
		long inY = stdin.nextLong();

		int length = 0;
		for (; inX <= inY; inX *= 2) {
			length++;
		}

		System.out.println(length);
	}

}


Measured memory_bytes: 23632
// Words are flowing out like endless rain into a paper cup
// They slither while they pass they slip away across the universe
// Pools of sorrow, waves of joy are drifting through my open mind
// Possessing and caressing me

#include <bits/stdc++.h>
using namespace std;

using LL = long long;

namespace _buff {

const size_t BUFF = 1 << 21;
char ibuf[BUFF], *ib = ibuf, *ie = ibuf;
char getc() {
    if (ib == ie) {
        ib = ibuf;
        ie = ibuf + fread(ibuf, 1, BUFF, stdin);
    }
    return ib == ie ? -1 : *ib++;
}

}

LL read() {
    using namespace _buff;
    LL ret = 0;
    bool pos = true;
    char c = getc();
    for (; (c < '0' || c > '9') && c != '-'; c = getc()) {
        /* assert(~c); */
    }
    if (c == '-') {
        pos = false;
        c = getc();
    }
    for (; c >= '0' && c <= '9'; c = getc()) {
        ret = (ret << 3) + (ret << 1) + (c ^ 48);
    }
    return pos ? ret : -ret;
}

int main() {
    int n = read();
    vector<int> a(n);
    generate_n(begin(a), n, read);
    sort(begin(a), end(a), greater<int>());

    int p = 0;
    for (; p < n; ++p) {
        if (p >= a[p]) {
            break;
        }
    }
    --p;
    int q = 0;
    for (; q < n; ++q) {
        if (a[q] <= p) break;
    }

    puts(~(a[p] - p) & 1 || ~(q - p) & 1 ? "First" : "Second");

    return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
#define inc(i, l, r) for (int i = l; i <= r; i++)

const int maxn = 1e6 + 5;

int a[15][10005], c[15][10005];
int w, h, res, ans;

int main() {
    while (scanf("%d%d", &h, &w) != EOF && h) {
        ans = 0;
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) scanf("%d", &a[i][j]);
        }
        for (int i = 0; i < (1 << h); i++) {
            int res = 0;
            for (int j = 0; j < h; j++) {
                if ((i >> j) & 1)
                    for (int k = 0; k < w; k++) c[j][k] = a[j][k];
                else
                    for (int k = 0; k < w; k++) c[j][k] = 1 - a[j][k];
            }
            for (int j = 0; j < w; j++) {
                int tmp = 0;
                for (int k = 0; k < h; k++) tmp += c[k][j];
                res += max(tmp, h - tmp);
            }
            ans = max(ans, res);
        }
        printf("%d\n", ans);
    }
}


Measured memory_bytes: 3992
def gcd(a,b):
    for xx in range(1000001):
        a,b=b,a%b
        if b==0:
            break
    return a

def lcm_base(x, y):
    return (x * y) // gcd(x, y)

P = 10**9 + 7
N = 1000001
inv_t = [0]+[1]
for i in range(2,N):
    inv_t += [inv_t[P % i] * (P - int(P / i)) % P]

n=int(input())
A=[int(i) for i in input().split()]

#kyodai=lcm_list(A)
kyodai=A[0]
for i in range(1,n):
    kyodai=lcm_base(kyodai,A[i])

ans=0

for i in range(n):
    ans+=inv_t[A[i]]
    ans=ans%P
ans=ans*kyodai
ans=ans%P

print(ans)


Measured memory_bytes: 43692
import itertools
import math
n = int(input())
city = []
for i in range(n) :
    x, y = map(int, input().split())
    city.append([x, y])

def dist(a,b) :
    return math.sqrt((a[0]-b[0])**2 + (a[1]-b[1])**2)

order_num = 1
order = list(itertools.permutations(range(n)))
for i in range(1,n+1) :
    order_num *= i

dist_list = []
for i in range(order_num) :
    total = 0
    for j in range(n-1) :
        prev = order[i][j]
        next = order[i][j+1]
        total += dist(city[next], city[prev])
    dist_list.append(total)
print(sum(dist_list)/order_num)


Measured memory_bytes: 15468
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

#define N 110
#define Initial 0
#define Medium 1
#define End 2
#define Gard -1

int Graph[N][N];
int Length[N]; 
int Storage[N]; 
int Fin[N];
int start=0;
int finish=0;
int loop;

void EnQueue(int );
int DeQueue();

int main(){
  int i,j;
  int vertex,adja;
  int adnum;
  int locate=0;
  
  scanf("%d",&loop);
  for(i=1;i<loop+1;i++){
    scanf("%d %d",&vertex,&adja);

    for(j=1;j<adja+1;j++){
      scanf("%d",&adnum);

      if(adnum!=0){
	Graph[vertex][adnum]=1;
      }

      else{
	Graph[vertex][adnum]=0;
      }
      
    }
  }

  for(i=1;i<loop+1;i++){
    Fin[i]=Initial;
    Length[i]=Gard;
  }

  Fin[Medium]=Medium;
  Length[Medium]=0;

  EnQueue(Medium);

  while(start!=finish){
    locate=DeQueue();
    
    for(i=1;i<loop+1;i++){

      if(Graph[locate][i]==Initial){
	continue;
      }

      else if(Length[i]!=Gard){
	continue;
      }
      
 
      else if(Fin[i]==Initial){
	Fin[i]=Medium;
	Length[i]=Length[locate]+1;
	EnQueue(i);
      }
    }
    

    Fin[locate]=End;
  }
  
  for(i=0;i<loop;i++){
    printf("%d %d\n",i+1,Length[i+1]);
  }

  return 0;
}

void EnQueue(int queue){

  Storage[finish]=queue;

  if(finish+1==loop){
    finish=0;
  }

  finish++;
}

int DeQueue(){
  int queue;

  queue=Storage[start];

  if(start+1==loop){
    start=0;
  }

  start++;

  return queue;
}



Measured memory_bytes: 2096
import java.util.Scanner;
public class Main{
 	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String A = sc.next();
		String s = sc.next();
		String C = sc.next();
		System.out.println(A.substring(0,1)+s.substring(0,1)+C.substring(0,1));
		sc.close();
	}
 }

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

const string YES = "Yes";
const string NO = "No";

void solve(long N, long A, long B, string S){
  long passed = 0;
  long passed_b = 0;
  for (auto s = S.cbegin(); s != S.cend(); ++s) {
    switch (*s) {
    case 'a':
      if (passed < A + B) {
	cout << YES << endl;
	passed++;
      } else {
	cout << NO << endl;
      }
      break;
    case 'b':
      if (passed < A + B && passed_b < B) {
	cout << YES << endl;
	passed++;
	passed_b++;
      } else {
	cout << NO << endl;
      }
      break;
    default:
      cout << NO << endl;
    }
  }
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
  long N, A, B;
  cin >> N >> A >> B;
  string S;
  cin >> S;
  solve(N, A, B, S);
  return 0;
}


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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
using ll = long long;
using ld = long double;
const int MOD =  1000000007;
const ll INF = 1LL << 60;


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

    int ans = 8;
    for(int i = 600; i <= 2000; i+=200){
        if(x < i){
            cout << ans << endl;
            return 0;
        }else{
            ans--;
        }

    }

    return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
long long int power(long long int x, long long int y, long long int p)  
{    long long int res = 1;  
    x = x % p; 
    if (x == 0) return 0;
    while (y > 0)  
    {   if (y & 1)  
            res = (res*x) % p;  
        y = y>>1;  
        x = (x*x) % p;  
    }  
    return res;  
} 
int main() {
    cin.tie(NULL); cout.tie(NULL);
    ios_base::sync_with_stdio(false);
   long long int n; cin>>n;
   long long int m=1000000007;
   cout<<(power(10,n,m)+power(8,n,m)-2*power(9,n,m)+2*m)%m;
   
	return 0;
}


Measured memory_bytes: 3604
import sys
sys.setrecursionlimit(100000)
n, k = map(int,input().split())
stones = list(map(int, input().split()))
stones.reverse()

bottum_up = [0 for i in range(n)]
bottum_up[0] = 0
bottum_up[1] = abs(stones[0] - stones[1])

for i in range(2,len(stones)):
    min_score = abs(stones[i] - stones[i-1]) + bottum_up[i-1]
    for j in range(2, min(i+1,k+1)):
        min_score = min(min_score, abs(stones[i] - stones[i-j]) + bottum_up[i-j])
    bottum_up[i] = min_score

print(bottum_up[-1])

Measured memory_bytes: 56800
#include<stdio.h>
int main()
{
    int n,i,p,A[n];
    scanf("%d\n",&n);
    for(i=0;i<n;i++)
    {
        scanf("%d",&p);
        A[p-1]=i+1;
    }
    for(i=0;i<n;i++){
        printf("%d ",A[i]);
    }
    return 0;
}


Measured memory_bytes: 1152
from numba import jit
import numpy as np
n=10**7
@jit("i8[:](i8)")
def Make(n):
    return np.array([i for i in range(n)])
@jit ("i8(i8[:])")
def f(a):
    mod=10**9+7
    ans=0
    for i in a:
        ans+=i
        ans%=mod
    return ans
k=Make(n)
f(k)
a,b=map(int,input().split())
print(a*b)

Measured memory_bytes: 187912
import javax.management.monitor.CounterMonitor;
import java.lang.reflect.Array;
import java.math.BigDecimal;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        //
        //Euclid e1=new Euclid();//ユークリッドの互除法
        //Compute c1=new Compute();//累積和，
        //変数
        int count = 0;
        boolean sw = false;
        int max = Integer.MIN_VALUE;
        int min = Integer.MAX_VALUE;
        double dMax = Double.MIN_VALUE;
        double dMin = Double.MAX_VALUE;
        //int answer = 0;
        String answer="";
        //StringBuilder answer=new StringBuilder();
        //List<Integer> list = new ArrayList<>();
        //int array[] = new int[];

        //入力
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        String s[]=new String[S.length()];
        int oCount=0;
        for(int i=0;i<S.length();i++)
        {
            s[i]=S.substring(i,i+1);
            if(s[i].equals("o"))
            {
                oCount++;
            }
        }
        int k=15;
        k-=S.length();
        int a=k+oCount;
        if(a>=8)
        {
            answer="YES";
        }else
        {
            answer="NO";
        }
        //出力
        //BigDecimal bd = new BigDecimal(answer);
        //System.out.println(bd.setScale(12,BigDecimal.ROUND_DOWN));
        //System.out.println(String.format("%.0f",answer));
        System.out.println(answer);
    }
}

Measured memory_bytes: 22228
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n := scanInt()
	ro := make([]pii, n)
	for i := 0; i < n; i++ {
		ro[i] = pii{scanInt(), scanInt()}
	}
	sort.Slice(ro, func(i, j int) bool { return ro[i].x < ro[j].x })

	f := make([]int, n)
	for i := 0; i < n; i++ {
		f[i] = sort.Search(n, func(idx int) bool { return ro[i].x+ro[i].d <= ro[idx].x })
	}

	seg := segmentTreeInit(n, max, 0)
	seg.build(f)

	dp := make([]int, n+1)
	dp[n] = 1
	for i := 0; i < n; i++ {
		r := seg.query(n-1-i, f[n-1-i])
		seg.update(n-1-i, r)
		dp[n-1-i] = (dp[n-i] + dp[r]) % mod
	}
	fmt.Fprintln(wr, dp[0])
}

const mod = 998244353

type pii struct{ x, d int }

type segmentTree struct {
	arr []int
	e   int
	n   int
	fn  func(a, b int) int
}

func segmentTreeInit(n int, fn func(a, b int) int, e int) segmentTree {
	a := 1
	for a < n {
		a <<= 1
	}
	res := segmentTree{make([]int, 2*a), e, a, fn}
	for i := 0; i < 2*a; i++ {
		res.arr[i] = e
	}
	return res
}

func (seg segmentTree) build(arr []int) {
	for i := 0; i < len(arr); i++ {
		seg.arr[i+seg.n] = arr[i]
	}
	for i := seg.n - 1; i > 0; i-- {
		seg.arr[i] = seg.fn(seg.arr[2*i], seg.arr[2*i+1])
	}
}

func (seg segmentTree) update(i, a int) {
	i += seg.n
	seg.arr[i] = a
	for i > 1 {
		i = i / 2
		seg.arr[i] = seg.fn(seg.arr[2*i], seg.arr[2*i+1])
	}
}

func (seg segmentTree) query(a, b int) int {
	var query func(a, b, k, l, r int) int
	query = func(a, b, k, l, r int) int {
		if r <= a || b <= l {
			return seg.e
		}
		if a <= l && r <= b {
			return seg.arr[k]
		}
		return seg.fn(query(a, b, 2*k, l, (l+r)/2), query(a, b, 2*k+1, (l+r)/2, r))
	}
	return query(a, b, 1, 0, seg.n)
}


Measured memory_bytes: 15928
// abc121_c
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

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

    ll N, M;
    cin >> N >> M;

    vector<P> AB(N);
    REP(i, N) cin >> AB[i].first >> AB[i].second;
    sort(ALL(AB));

    ll ans = 0;
    REP(i, N){

        if (M - AB[i].second > 0){
            ans += AB[i].first * AB[i].second;
            M -= AB[i].second;
        } else {
            ans += AB[i].first * M;
            break;
        }
    }

    print(ans);

    return 0;
}


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

int main() {
	ll n;
	cin>>n;
	for(ll i=1;i<=9;i++)
	{
		if(n%i==0 && n/i>=1 && n/i<=9)
		{
			cout<<"Yes";
			return 0;
		}
	}
	cout<<"No";
	return 0;
}

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

using namespace std;

#define MAX_N  101
#define MAX_W   100001
int N, W;
vector<vector<long long> >  Lookup(MAX_N,vector<long long> (MAX_W,-1));
vector<int> wei(MAX_N);
vector<long long> val(MAX_N);

long long Knapsack(int c,int  n){
	if(c==0|| n==0)return 0;
	if(Lookup[n][c]!=-1) return 	Lookup[n][c];
	if(c-wei[n]>=0)
		return Lookup[n][c] = max(Knapsack(c-wei[n],n-1)+val[n],Knapsack(c,n-1));
	return Knapsack(c,n-1);
	}
void fillDp(){
	for(int i =0;i<MAX_N;i++){
		for (int j=0;j<MAX_W;j++)
			Lookup[i][j]=-1;
	}	
}

int main(int argc, char** argv) 
{
	cin>>N>>W;
	for (int i =1;i<=N;i++){
		cin>>wei[i]>>val[i];
	}
	//fillDp();
	cout<<Knapsack(W,N)<<endl;

	return 0;
}


Measured memory_bytes: 80256
#include <bits/stdc++.h>
#include <cmath>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
const ll INF = 1e18;
#define foreach(ix,a) for(auto& (ix) : (a)) 
vector<vector<pair<ll,ll>>> edge(110000);
ll seen[110000];
void dfs(ll i,ll co){    
    for(pair<ll,ll> v : edge[i]){
        ll p=v.first,dis=v.second;
        if(seen[p]!=-1)continue;
        seen[p]=(co+dis)%2;
        dfs(p,seen[p]);
    }
}
int main(){
    int n,m;
    cin>>n;
    rep(i,n)seen[i]=-1;
    rep(i,n-1){
        ll u,v,w;cin>>u>>v>>w;u--;v--;
        edge[u].push_back({v,w});
        edge[v].push_back({u,w});
    }
    seen[0]=0;
    dfs(0,seen[0]);
    rep(i,n){
        cout<<seen[i]<<endl;
    }

}

Measured memory_bytes: 9600
#include <iostream>
#include <stdio.h>
#include <vector>
#include <cstring>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>

#define INF 1e9
#define nmax 200010
#define fst first
#define snd second
#define pb push_back
#define SZ(x) ((int)(x.size()))

#define MOD 998244353

#define MOD1 998244353
#define MOD2 666013
#define P1 255
#define P2 2059

using namespace std;

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

int n, m;
char s[100];

int main()
{
    scanf("%d %d", &n, &m);

    for (int i = 1; i <= n; i++) s[i] = '@';

    for (int i = 1; i <= m; i++) {

        int p; char c;

        scanf("%d %c", &p, &c);

        if (s[p] != '@' && s[p] != c) { puts("-1"); return 0; }

        s[p] = c;
    }

    if (n == 1) {

        if (s[1] == '@') s[1] = '0';

        puts(s + 1);

        return 0;
    }

    if (s[1] == '0') { puts("-1"); return 0; }

    if (s[1] == '@') s[1] = '1';
    
    for (int i = 1; i <= n; i++)
        if (s[i] == '@') s[i] = '0';

    puts(s + 1);

    // IMPORTANT!!!!!
    // Are you missing something????
    // check limits, int or ll

    return 0;
}

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

const int N = 1005, M = 1005, MOD = 1E9 + 7;

int m, n, pr = 0, pc = 0, r = 0, c = 0, a[M], b[N];
long long ans = 1;

int main()
{
    scanf("%d%d", &m, &n);
    for (int i = 0; i < m; i++)
        scanf("%d", a + i);
    for (int i = 0; i < n; i++)
        scanf("%d", b + i);
    sort(a, a + m, greater<int>());
    sort(b, b + n, greater<int>());
    for (int i = m * n, cnt = 0; i > 0; i--, cnt++)
    {
        int cr = 0, cc = 0;
        for (; a[pr] == i; pr++)
            cr++;
        for (; b[pc] == i; pc++)
            cc++;
        if (max(cr, cc) > 1)
            return printf("0"), 0;
        r += cr; c += cc;
        if (cc == 0 && cr == 0)
            (ans *= r * c - cnt) %= MOD;
        else if (cc == 0)
            (ans *= c) %= MOD;
        else if (cr == 0)
            (ans *= r) %= MOD;
    }
    printf("%lld", ans);
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std; 
#define vll vector<long long>
#define mll map<long long,long long>
#define pb push_back
typedef  long long ll;
typedef long double ld;
long double pi=3.14159265358979323846;

vll al[500005];
ll vis[500005],color[500005],I[101][101];

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

bool isPrime(int n)
{
    if (n<=1) return false; 
    if (n<=3) return true; 
    if (n%2==0||n%3==0) return false; 
    for (int i=5;i*i<=n;i=i+6) if (n%i==0||n%(i+2)==0) return false; 
    return true; 
}

ll bpow(ll n, ll po)
{
	ll res=1;
	while(po>0)
	{
		if(po%2)
		{
			res*=n;
			po--;
		}
		else
		{
			n*=n;
			po/=2;
		}
	}
	return res;
}

ll binpow(ll n, ll po, ll mod)
{
	ll res=1;
	while(po>0)
	{
		if(po%2)
		{
			res=(res*n)%mod;
			po--;
		}
		else
		{
			n=(n*n)%mod;
			po/=2;
		}
	}
	return res;
}

ll swap(ll a, ll b)
{
	a=a+b;
	b=a-b;
	a=a-b;
}

ll fact(ll n) { 
   if ((n==0)||(n==1))
      return 1;
   else
      return n*fact(n-1);
}

ll C(ll n, ll r) {
    if(r > n - r) r = n - r; 
    ll ans = 1;
    ll i;

    for(i = 1; i <= r; i++) {
        ans *= n - r + i;
        ans /= i;
        ans=ans%1000000007;
    }

    return ans;
}

//bool bipartite_dfs(ll node, ll flag)
//{
//	vis[node]=1;
//	ll cflag=flag;
//	color[node]=cflag;
//	for(ll child : al[node])
//	{
//		if(!vis[child])
//		{
//			bool n=bipartite_dfs(child,1-cflag);
//			if(n==false) return false;
//		}
//		else if(color[child]==color[node]) return false;
//	}
//	return true;
//}

void mmul(ll A[][101], ll B[][101], ll dim)
{
	ll res[dim][dim];
	for(ll i=0;i<dim;i++) for(ll j=0;j<dim;j++)
	{
		res[i][j]=0;
		for(ll k=0;k<dim;k++) res[i][j]=(res[i][j]+A[i][k]*B[k][j])%1000000007;
	}
	for(ll i=0;i<dim;i++) for(ll j=0;j<dim;j++) A[i][j]=res[i][j];
}

void mpow(ll A[][101],ll dim, ll po)
{
	for(ll i=0;i<dim;i++) for(ll j=0;j<dim;j++)
	{
		if(i==j) I[i][j]=1;
		else I[i][j]=0;
	}
	while(po>0)
	{
		if(po%2==1)
		{
			mmul(I,A,dim);
			po--;
		}
		else
		{
			mmul(A,A,dim);
			po/=2;
		}
	}
	for(ll i=0;i<dim;i++) for(ll j=0;j<dim;j++) A[i][j]=I[i][j];
}



int main()
{
	ll x,a,b;
	cin>>x;
	for(ll i=-200;i<=200;i++)
	{
		for(ll j=-200;j<=200;j++)
		{
			if(bpow(i,5)-bpow(j,5)==x)
			{
				a=i;
				b=j;
				goto label;
			}
		}
	}
	label:
	cout<<a<<" "<<b;
}


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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

template<typename T>
void trace(T *a, int s, int n) {
    for (int i=s; i<n; i++) {
	cout<<a[i]<<" ";
    }
    cout<<endl;
}



typedef long long ll;
const ll mod = 1e9+7;
const int maxn = 1e6 + 5;





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

    int x,y,z;
    cin>>x>>y>>z;
    swap(x,y);
    swap(x,z);
    cout<<x<<" "<<y<<" "<<z<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int a,b;
   char op;
        while(1){
          scanf("%d %c %d",&a,&op,&b);
           if( op =='?')
               break;
           else if( op == '+')
               printf("%d\n",a+b);
           else if( op == '-')
               printf("%d\n",a-b);
           else if( op == '*')
               printf("%d\n",a*b);
           else if( op == '/')
               printf("%d\n",a/b);
           }
              return 0;
}
     

        

Measured memory_bytes: 600
#include <iostream>
#include <vector>
#include <set>
using namespace std;
typedef long long ll;
const int SVSZ = 1000009;

int spf[SVSZ]; //Smallest Prime Factor

void buildSieve() {
	vector<int> primes; spf[0] = spf[1] = 1;
	for (int i = 2; i < SVSZ; i++) {
		if (spf[i] == 0) { primes.push_back(i);	spf[i] = i; }
		for (int j = 0; j < int(primes.size()) && primes[j] <= spf[i] && i * primes[j] < SVSZ; j++)
			spf[i * primes[j]] = primes[j];
	}
}

vector<int> v; int g = 0;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

bool check() {
	set<int> p; for (auto &x : v) {
		while (x != 1) {
			int s = spf[x]; if (p.count(s)) return false;
			p.insert(s); while (x % s == 0) { x /= s; }
		}
	}
	return true;
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);

	int n; cin >> n; buildSieve(); v.resize(n);
	for (auto &x : v) { cin >> x; g = gcd(g, x); }
	if (g != 1) { cout << "not coprime" << '\n'; return 0; }
	cout << (check() ? "pairwise coprime" : "setwise coprime") << '\n';

	cin.ignore(2); return 0;
}

Measured memory_bytes: 11512
#include<bits/stdc++.h>
using namespace std;
bool use[12];
bool ok(int n)
{
	while(n>0)
	{
		if(use[n%10])
		return false;
		n/=10; 
	}
	return true;
}
int main()
{
	int c,k;
	cin>>c>>k;
	for(int i=0;i<k;i++)
	{
		int d;
		cin>>d;
		use[d]=true;
	}
	while(!ok(c))
	c++;
	cout<<c<<endl;
	return 0;
}

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

int main(){
    int N, M;
    cin >> N >> M;
    int P[1000000];
    int Y[1000000];
    vector<int> yd[1000000];
    for (int i = 0; i < M; i++){
        cin >> P[i] >>Y[i];
        yd[P[i]].push_back(Y[i]);
    }

    for (int i = 0; i < N; i++){
        sort(yd[i + 1].begin(), yd[i + 1].end());
    }
    for (int i = 0; i < M; i++){
        int j = lower_bound(yd[P[i]].begin(), yd[P[i]].end(), Y[i]) - yd[P[i]].begin() + 1;
        printf("%06d%06d\n",P[i],j);
    }
    return 0;
}

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	vector<vector<int>>c(3,vector<int>(3));
	for(auto&&i:c)for(auto&&j:i)cin>>j;
	vector<int>a(3,101),b(3,101);
	string ans="Yes"s;
	for(int i=0;i<3;++i){
		for(int j=0;j<3;++j){
			if(a.at(i)==101&&b.at(j)==101){
				a.at(i)=c.at(i).at(j);
				b.at(j)=0;
			}
			else if(a.at(i)==101){
				a.at(i)=c.at(i).at(j)-b.at(j);
			}
			else if(b.at(j)==101){
				b.at(j)=c.at(i).at(j)-a.at(i);
			}
			else if(a.at(i)+b.at(j)!=c.at(i).at(j)){
				ans="No"s;
			}
		}
	}
	cout<<ans<<"\n"s;
}


Measured memory_bytes: 3528
import sys

def solve():
    input = sys.stdin.readline
    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

    return 0

if __name__ == "__main__":
    solve()

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


int main() {
  ll X;
  cin >> X;
  ll yen = 100;
  ll count = 0;
  while(yen < X){
      yen *= 1.01;
      count++;
  }
  cout << count << endl;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


int main(){
  int N;
  cin >> N;
  ll sum = 0;
  vector<ll> v;
  rep(i,N){
    ll l;
    cin >> l;
    v.push_back(l);
    sum += l;
  }

  sort(ALLOF(v));
  reverse(ALLOF(v));

  sum -= v[0];
  if(v[0] < sum){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}



Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


YES = "APPROVED"
NO = "DENIED"

def solve(N: int, A: "List[int]"):
    for a in A:
        if a % 2 == 0 and a % 3 != 0 and a % 5 != 0:
            print(NO)
            return
    print(YES)

# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))
    A = [int(next(tokens)) for _ in range(N)]
    solve(N, A)

if __name__ == '__main__':
    main()


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

int main() {
	int n;
	string s;
	cin >> n >> s;
	int m = 0;
	for(int i = 1;i < n;i++)
	{
		string s1 = s.substr(0,i),
		       s2 = s.substr(i);
		sort(s1.begin(),s1.end());
		sort(s2.begin(),s2.end());
		int m1 = 0;
		for(int j = 0;j < s1.size();j++)
		{
			if(j > 0 && s1.at(j) == s1.at(j-1))
			{
				continue;
			}
			else
			{
				int m2 = 0;
				for(int l = 0;l < s2.size();l++)
				{
					if(s1.at(j) == s2.at(l))
					{
						m2++;
						break;
					}
				}
				m1 += m2;
			}
			m = max(m,m1);
		}
	}
    cout << m << endl;
	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#include <vector>
#include <algorithm>
using namespace std;
using UL = unsigned int;
using ULL = unsigned long long;
using LL = long long;

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




int main() {
  int n; scanf("%d",&n);

  int ans;
  if (n>=1800) ans = 1;
  else if (n>=1600) ans = 2;
  else if (n>=1400) ans = 3;
  else if (n>=1200) ans = 4;
  else if (n>=1000) ans = 5;
  else if (n>=800) ans = 6;
  else if (n>=600) ans = 7;
  else if (n>=400) ans = 8;


  // 全てのコインmを使ってnを実現するのでT[m][n]が答え
  printf("%d\n", ans);
  return 0;
}



Measured memory_bytes: 3756
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <queue>
using namespace std;

char A[2010], B[2010];
int res;
int n;
char AA[2010];
char BB[4010];
int cnt1[4010];
int L[2010], R[2010], m;
int nxt1[4010];
int last1[4010];
int idx[4010];

int cmp(const void *aa, const void *bb)
{
	int i1 = *((int *)aa);
	int i2 = *((int *)bb);
	if(R[i1] > R[i2])
		return 1;
	else if(R[i1] < R[i2])
		return -1;
	return L[i1] - L[i2];
}

void solve()
{
	int i, j;
	for(i=0; i<n; i++)
		cnt1[i] = 0;
	strcpy(BB, B);
	strcpy(BB+n, B);
	if(BB[0] == '1')
		cnt1[0] = 1;
	else
		cnt1[0] = 0;
	for(i=0; i<2*n; i++){
		if(BB[i] == '1'){
			cnt1[i] = cnt1[i-1] + 1;
		}
		else
			cnt1[i] = cnt1[i-1];
	}
	int tmp;
	tmp = 1000000;
	for(i=2*n-1; i>=0; i--){
		if(BB[i] == '1'){
			tmp = i;
		}
		nxt1[i] = tmp;
	}
	tmp = -1;
	for(i=0; i<2*n; i++){
		if(BB[i] == '1')
			tmp = i;
		last1[i] = tmp;
	}
	int sum;
	int mx;
	int st;
	for(i=0; i<n; i++){
		sum = 0;
		for(j=0; j<n; j++){
			AA[(j+i)%n] = A[j];
		}
		for(j=0; j<n; j++){
			if(AA[j]=='1' && B[j]=='0'){
				if( cnt1[j+n] - cnt1[j-i+n] > 0 || BB[j-i+n]=='1'){
					AA[j] = '0';
					sum ++;
				}
			}
		}
		m = 0;
		for(j=0; j<n; j++){
			if(AA[j]=='1' && B[j]=='0'){
				R[m] = nxt1[j]-j;
				//L[m] = last1[j-i+n] - (j-i+n);///
				L[m] = (j-i+n) - last1[j-i+n];
				m ++;
				sum ++;
			}
		}
		if(m>0){
			/*if(m==1){
				if(L[0] > R[0])
					sum += R[0];
				else
					sum += L[0];	
			}
			else{*/
				for(j=0; j<m; j++)
					idx[j] = j;
				qsort(idx, m, sizeof(int), cmp);
				mx = 0;
				st = 1000000;
				for(j=m-1; j>=0; j--){
					if(R[idx[j]]+mx < st)
						st = R[idx[j]]+mx;
					if(mx < L[idx[j]])
						mx = L[idx[j]];
				}
				if(st > mx)
					st = mx;
				sum += st*2;
			//}
			//sum += m;
		}
		sum += i;
		//for(i=0; i<n; i++){///
		for(j=0; j<n; j++){//0->1
			if(AA[j]=='0' && BB[j]=='1')
				sum ++;
		}
		if(sum < res)
			res = sum;
	}
}

void solve_a()
{
	int i;
	n = strlen(A);
	for(i=0; i<n; i++){
		if(B[i] == '1')
			break;
	}
	if(i==n){
		for(i=0; i<n; i++){
			if(A[i] == '1')
				break;
		}
		if(i==n)
			printf("0\n");
		else
			printf("-1\n");
		return ;
	}
	res = 1000000000;
	solve();
	for(i=0; i<n/2; i++){
		swap(A[i], A[n-1-i]);
		swap(B[i], B[n-1-i]);
	}
	solve();
	printf("%d\n", res);
}

int main()
{
	scanf("%s", A);
	scanf("%s", B);
	solve_a();
	return 0;
}

Measured memory_bytes: 384
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.NoSuchElementException;

public class Main {

	static PrintWriter out;
	static InputReader ir;

	static void solve() {
		char[] s=ir.next().toCharArray();
		StringBuilder sb=new StringBuilder();
		for(int i=0;i<s.length;i+=2)
			sb.append(Character.toString(s[i]));
		out.println(sb);
	}

	public static void main(String[] args) throws Exception {
		ir = new InputReader(System.in);
		out = new PrintWriter(System.out);
		solve();
		out.flush();
	}

	static class InputReader {

		private InputStream in;
		private byte[] buffer = new byte[1024];
		private int curbuf;
		private int lenbuf;

		public InputReader(InputStream in) {
			this.in = in;
			this.curbuf = this.lenbuf = 0;
		}

		public boolean hasNextByte() {
			if (curbuf >= lenbuf) {
				curbuf = 0;
				try {
					lenbuf = in.read(buffer);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (lenbuf <= 0)
					return false;
			}
			return true;
		}

		private int readByte() {
			if (hasNextByte())
				return buffer[curbuf++];
			else
				return -1;
		}

		private boolean isSpaceChar(int c) {
			return !(c >= 33 && c <= 126);
		}

		private void skip() {
			while (hasNextByte() && isSpaceChar(buffer[curbuf]))
				curbuf++;
		}

		public boolean hasNext() {
			skip();
			return hasNextByte();
		}

		public String next() {
			if (!hasNext())
				throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while (!isSpaceChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		public int nextInt() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			int res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}

		public long nextLong() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			long res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}

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

		public int[] nextIntArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		public long[] nextLongArray(int n) {
			long[] a = new long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextLong();
			return a;
		}

		public char[][] nextCharMap(int n, int m) {
			char[][] map = new char[n][m];
			for (int i = 0; i < n; i++)
				map[i] = next().toCharArray();
			return map;
		}
	}
}


Measured memory_bytes: 25684
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cassert>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define rep(i,n) FOR(i,0,n)
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define vint vector<int>
#define vdouble vector<double>
#define vstring vector<string>
using namespace std;
# define LL long long

/*
1≦N≦100
1≦Ti≦105
1≦M≦100
1≦Pi≦N
1≦Xi≦105

N
T1 T2 … TN
M
P1 X1
P2 X2
:
PM XM
*/

int main() {
	//
	const int NN = 10000;
	int N, M;
	int T[NN];
	LL P[NN];
	LL X[NN];

	cin >> N;
	rep(n, N){ cin >> T[n]; }
	cin >> M;
	rep(m, M) { cin >> P[m] >> X[m]; }

	rep(m, M){
		LL ret = 0;
		rep(n, N){ ret += T[n]; }
		int p = P[m] - 1;
		ret -= T[p];
		ret += X[m];
		cout << ret << endl;
	}
	
}

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

#define INF 1 << 30
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)

using namespace std;

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

void gen_sosuu(int sosuu[]){
  REP(i,100010){
    sosuu[i] = true;
  }
  sosuu[0] = false;
  sosuu[1] = false;
  sosuu[2] = true;
  FOR(i,2,sqrt(100000)+1){
    if(sosuu[i] == false) continue;
    for(int j = 2; i*j<=100000;j++){
      //printf("%d %d %d\n",i*j,i,j);
      sosuu[i*j] =false;
    }
  }
}

int n,m;

int graph[100][100]={{0}};
bool visit[100][100] = {{false}};
int main(){
  cin >>n>>m;
  REP(i,m){
    int a,b,c;
    cin >>a>>b>>c;
    a--;b--;
    graph[a][b] = c;
    graph[b][a] = c;
  }
  REP(i,n){
    int d[100];
    bool used[100];
    int from[100];
    REP(j,n){
      d[j] = INF;
      used[j] = false;
      from[j] = -1;
    }
    d[i] = 0;
    REP(l,n){
      int id=-1;
      REP(j,n){
        if(!used[j] && (id==-1||d[id]>d[j])) id = j;
      }
      used[id] = true;
      REP(j,n){
        if(graph[id][j]==0)continue;
        if(d[j] > d[id]+graph[id][j]){
          d[j] = d[id]+graph[id][j];
          from[j] = id;
          //cout << id<<j<<endl;
        }
      }
    }
    REP(j,n){
      if(i==j) continue;
      if(from[j]==-1) continue;
      visit[j][from[j]]=true;
      visit[from[j]][j]=true;
    }
  }
  int sum = 0;
  REP(i,n)FOR(j,i+1,n){
    if(visit[i][j]) sum++;
  }
  cout << m-sum<<endl;
  return 0;
  REP(i,n){
    REP(j,n){
      cout << visit[i][j];
    }
    cout <<endl;
  }
}


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

int main(){
	int n,y;
	cin>>n>>y;
	
	rep(i,n+1){
		rep(j,n+1){
			if(y==10000*i+5000*j+1000*(n-i-j)&&n-i-j>=0){
				cout << i << " " << j << " " << n-i-j << endl;
				return 0;
			}
		}
	}
	cout << "-1 -1 -1" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <deque>
#include <tuple>
using namespace std;
typedef long long ll;
#define for1(i,n) for (ll i=0;i<(n);(i)++)
#define for2(i,m,n) for (ll (i)=(m);(i)<(n);(i)++)
#define for3(i,m,n,d) for (ll (i)=(m);(i)<(n);(i)+=(d))
#define INF (1LL << 60)
#define STRING(str) #str
#define DEBUG 0
#if DEBUG
    #define dump(var) dump2(STRING(var), var)
#else
    #define dump(var)
#endif

void dump2(const string& name, const ll value)
{
    cerr << name << ": " << value << endl;
}
void dump2(const string& name, const tuple<ll,ll,ll>& value)
{
    ll a,b,c;
    tie(a,b,c) = value;
    cerr << name << ": " << a << ", " << b << ", " << c << endl;
}

void solve()
{
    ll ans = 0;
    ll N,Q;
    cin >> N >> Q;
    vector<tuple<ll,ll,ll>> data;
    for1(i,N) {
        ll s,t,x;
        cin >> s >> t >> x;
        s -= x;
        t -= x;
        data.emplace_back(s,1,x);
        data.emplace_back(t,-1,x);
    }

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

    ll idx = 0;
    ll datasize = data.size();
    set<ll> roadwork;
    for1(i,Q) {
        ll q;
        cin >> q;
        while (idx < datasize && get<0>(data[idx]) <= q) {
            if (get<1>(data[idx]) == 1) {
                roadwork.insert(get<2>(data[idx]));
            } else {
                roadwork.erase(get<2>(data[idx]));
            }
            ++idx;
        }
        if (roadwork.size() == 0) {
            ans = -1;
        } else {
            ans = *roadwork.begin();
        }

        cout << ans << endl;
    }
}

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


Measured memory_bytes: 20456
//
//  main.cpp
//  A
//
//  Created by Hashizo on 2020/03/07.
//  Copyright © 2020 Hashizo. All rights reserved.
//

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <regex>
#include <cmath>

using namespace std;
 
#undef LONG_MAX
#undef LONG_MIN
 
#define LONG_MAX    9223372036854775807
#define LONG_MIN    (-LONG_MAX  -1)
 
#define ll long long
 
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
 
#define SORT(c) sort((c).begin(), (c).end())
#define REVERSE(v) reverse((v).begin(), (v).end())


int main(int argc, const char * argv[]) {

	string s;
	cin >> s;

	if (s == "AAA" || s == "BBB") {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (ll(i) = 0; (i) < (n); (i)++)
#define all(x) (x).begin(), (x).end()
#define print(x) cout << (x) << endl;

typedef long long ll;
const ll INF = 99999999999999;
const ll MOD = 1000000007;
const double PI = acos(-1.0);

using namespace std;

int main()
{
    int n, ans = 0;
    string x;
    cin >> n;
    vector<string> s(n);
    vector<int> t(n);
    rep(i, n)
    {
        cin >> s[i] >> t[i];
    }
    cin >> x;
    int flag = 0;
    rep(i, n)
    {
        if (flag == 1)
        {
            ans += t[i];
        }
        if (s[i] == x)
        {
            flag = 1;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 764
import java.util.Scanner;

public class Main{
    public static void main(String [] args){
        Scanner am = new Scanner(System.in);
        int x =am.nextInt();
        int y =am.nextInt();
        int c=1;
        while(true){
        if(x>y){
            x=x%y;
            if(x==0){
                c=y;
                break;
            }
        }
        else{
            y=y%x;
            if(y==0){
                c=x;
                break;
            }
        }
        
    }

        /*for(int a=1;a<=x && a<=y;a++){
            if(x%a==0 && y%a==0)c=a;
        }
        */
        System.out.println(c);
      am.close();  
    }
}


Measured memory_bytes: 26240
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>

using namespace std;

#define PI 3.14159264348979323
#define EPS 1e-7
#define PARTITION 1000

int main() {
	int n;
	while (cin >> n && n) {
		double x[100], y[100];
		for (int i = 0; i < n; i++)
			scanf("%lf,%lf\n", &x[i], &y[i]);
		int ans = 0;
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < PARTITION; j++) {
				double cx, cy;
				cx = x[i] + cos(2 * PI * j / PARTITION);
				cy = y[i] + sin(2 * PI * j / PARTITION);
				int cnt = 0;
				for (int k = 0; k < n; k++)
					if ((cx - x[k]) * (cx - x[k]) + (cy - y[k]) * (cy - y[k]) < 1.0 + EPS)
						cnt++;
				ans = max(ans, cnt);
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1276
#include<bits/stdc++.h>
using namespace std;
 int main(){
   int a,b,c;

cin>>a>>b>>c;
 1<=a<=100;
 1<=b<=100;
 1<=c<=100;
if((b-a)==(c-b)) {
        cout<<"YES";
    }

    else {
            cout<<"NO";

    }


return 0;
}


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

n, m = map(int, input().split())
l = list(map(int, input().split()))

if n >= m:
    print(0)
    sys.exit()
    
l.sort()
le = len(l) - 1
nl = [0] * le
for i in range(0, len(l) - 1):
    nl[i] = l[i + 1] - l[i]
    
nl.sort()
print(sum(nl[:le - n + 1]))

Measured memory_bytes: 13308