akhauriyash/Code-Regression huggingface dataset:
n = gets.to_i
m = gets.split(" ").map(&:to_i)
h = gets.split(" ").map(&:to_i)

t = 0

n.times do |i|
  if m[i] <= h[i]
    t += m[i]
    h[i] -= m[i]
    if m[i + 1] <= h[i]
      t += m[i + 1]
      m[i + 1] = 0
    else
      t += h[i]
      m[i + 1] -= h[i]
      h[i] = 0
    end
  else
    t += h[i]
  end
end

puts t

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

int main() {
  int n,m;
  cin>>n>>m;
  vector<int> L(m),R(m);
  rep(i,m){
    cin>>L[i]>>R[i];
  }
  sort(L.begin(),L.end());
  sort(R.begin(),R.end());
  
  int a=R[0]-L[m-1]+1;
  if(a>0){
  cout<<a<<endl;
}
  else cout<<0<<endl;
  
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename T> inline T sqr(T t) {return t*t;}
#define pb push_back
#define mp make_pair
#define endl "\n"

inline void files()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    #ifdef _WIN32
        return;
    #endif // _WIN32
    //freopen("C.in", "r", stdin);freopen("C.out", "w", stdout);
}

set<int> q;

int main(){
    files();
    int n;
    cin >> n;
    while(n--){
        int num;
        cin >> num;
        if (q.find(num)==q.end())
            q.insert(num); else
            q.erase(num);
    }
    cout << q.size();
}


Measured memory_bytes: 4992
N, K = map(int, input().split())
H = []
for _ in range(N):
    H.append(int(input()))
H = sorted(H, reverse=True)

X = []
for n in range(N-K+1):
    x = H[n] - H[n+K-1]
    X.append(x)

print(min(X))

Measured memory_bytes: 10892
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int m = scanner.nextInt();
        int[] c = new int[m];
        for (int i = 0; i < m; i++) {
            c[i] = scanner.nextInt();
        }
        int[] t = new int[n + 1];
        for (int i = 1; i <= n; i++) {
            t[i] = Integer.MAX_VALUE;
        }
        for (int i = 0; i < m; i++) {
            for (int j = c[i]; j <= n; j++) {
                t[j] = Math.min(t[j], t[j - c[i]] + 1);
            }
        }
        System.out.println(t[n]);
    }
}


Measured memory_bytes: 26960
#include<stdio.h>
#include<stdlib.h>
#define S 10000
#define T 500

int main()
{
  int n,q,i,j,cnt = 0;
  int A[S],B[T];

  scanf("%d",&n);
  for(i = 0 ; i < n ; i++){
    scanf("%d",&A[i]);
    if(A[i] < 0 || A[i] > 1000000000)exit(1);
  }

  scanf("%d",&q);
  for(i = 0 ; i < q ; i++){
    scanf("%d",&B[i]);
    if(B[i] < 0 || B[i] > 1000000000)exit(1);
  }

  for(i = 0 ; i < q ; i++){
    for(j = 0 ; j < n ; j++){
      if(A[j] == B[i]){
	cnt++;
	break;
      }
    }
  }
  printf("%d\n",cnt);
  return 0;
}
  
    



Measured memory_bytes: 2048
#include<bits/stdc++.h> 
//#define <- プログラムの文字列を置換する
//typedef <- 新しい型に名前を付けるためのキーワード

using namespace std;

#define MAX_N 1

typedef long long ll;

const double PI = 3.141592653589793;
const long long MOD = 1e9 + 7;
const long long INF = 1e15;
const int INF_INT = 1e9;

int main(){
    int N;
    cin >> N;
    vector<int> a(N+1);
    vector<int> box(N+1);
    stack<int> s;
    for(int i = 1; i <= N;i++) cin >> a[i];
    for(int i = N; i >= 1;--i){
        if(2 * i > N){
            box[i] = a[i];
            if(a[i] == 1) s.push(i);
        }
        else{
            int maxi = N / i;
            int mini = 2;
            int sum = 0;
            while(1){
                if(maxi < mini) break;
                if(maxi == mini){
                    sum += box[maxi * i];
                    break;
                }
                else sum += box[maxi * i] + box[mini * i];
                maxi--;mini++;
            }
            if((sum + a[i]) % 2 == 1){
                box[i] = 1;
                s.push(i);
            }
            else box[i] = 0;
        }    
    }
    if(s.empty()) cout << 0 << endl;
    else{
        cout << s.size() << endl;
        while(!s.empty()){
            cout << s.top() << endl;
            s.pop();
        }
    }
    return 0;
}

Measured memory_bytes: 3072
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]
debugmode = False

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

n = INT()
ans = 0
for i in range(1, n + 1, 2):
    arr = make_divisors(i)
    if len(arr) == 8:
        ans += 1
print(ans)

Measured memory_bytes: 5328
use std::io;

fn main() {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let s:Vec<char> = buf.trim().chars().collect();
	let mut flag = false;
	let mut cnt = 0;
	let mut c = 0;
	/*for i in 0..s.len() {
		println!("{}", (s[i] as i16) - ('A' as i16));
	}*/
	if s[0] == 'A' {
		//if s.len() != 4 {
			for i in 2..(s.len() - 1) {
				if s[i] == 'C' {
					cnt += 1;
					c = i;
				}
				if cnt > 1 {
					break;
				}
			}
			if cnt == 1 {
				for i in 1..s.len() {
					if (s[i] as i32) - ('A' as i32) <= 25 && c != i {
							break;
					}
					if i == s.len() - 1 {
						flag = true;
					}
				}
			}
		//}
	}
	if flag {
		println!("AC");
	}else{
		println!("WA");
	}
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
LL R,C;

LL dist(LL x,LL y){
    if(x!=0&&x!=R&&y!=0&&y!=C) return -1;
    if(y==0) return x;
    if(x==R) return R+y;
    if(y==C) return 2*R+C-x;
    if(x==0) return 2*(R+C)-y;
    return -1;
}

int main(){
    map<LL,int> mp;
    stack<int> s;
    int N;
    cin >> R >> C >> N;
    for(int i=0;i<N;i++){
        LL x1,y1,x2,y2;
        cin >> x1 >> y1 >> x2 >> y2;
        if(dist(x1,y1)!=-1&&dist(x2,y2)!=-1){
            mp[dist(x1,y1)]=i;
            mp[dist(x2,y2)]=i;
        }
    }
    s.push(-1);
    for(auto p : mp){
        if(p.second!=s.top()) s.push(p.second);
        else s.pop();
    }
    if(s.size()==1) puts("YES");
    else puts("NO");
    return 0;
}

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

using namespace std;

typedef short sho;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef double db;
typedef string str; 
 
typedef pair<int,int> pii;
typedef pair<ll,ll> pll; 
typedef pair<ld,ld> pld;
 
typedef vector<int> vi; 
typedef vector<ll> vl; 
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
typedef vector<pld> vpd;

#define mp make_pair 
#define FF first
#define SS second
#define sz(x) (int)x.size()
#define begin(x) (x).begin() 
#define end(x) (x).end()
#define rbegin(x) (x).rbegin()
#define rend(x) (x).rend()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define rsz resize
#define ins insert
#define ft front()
#define bk back()
#define pf push_front
#define pb push_back
#define pp push
#define lb lower_bound 
#define ub upper_bound

inline void checkmin(int &x,int y){x=min(x,y);}
inline void checkmax(int &x,int y){x=max(x,y);}

int n;

int main() {
//	freopen("in.txt","r",stdin);
//	freopen("out.txt","w",stdout);
	ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    /* start code */
    cin>>n;
    cout<<(n+1)/2<<endl;
    /* end code */
	return 0;
}

Measured memory_bytes: 256
def binary_search(A, key):
    left = 0
    right = len(A)

    while left < right:  # 見つからなければ最後にleft == rightになる。
        mid = (left + right) // 2
        if A[mid] == key:
            return mid
        elif key < A[mid]:
            right = mid
        else:
            left = mid + 1

    return None


import sys
input = sys.stdin.readline

n = int(input())
S = list(map(int, input().split()))
q = int(input())
T = list(map(int, input().split()))

count = 0

for t in T:
    match = binary_search(S, t)
    if match is not None:
        count += 1

print(count)



Measured memory_bytes: 16176
#include<cstdio>
#include <set>
#include<iostream>
#include<string.h>
#include<algorithm>
using namespace std;

typedef long long LL;

/*

题意：
略；
思路：
这本来就是个多重背包。
但是不知道这个路径应该怎么记录，原因就是不会利用好自己手中的条件。

*/
int dx[4]={1,-1,0,0};
int dy[4]={0,0,-1,1};

char s[1010];

int solve()
{
    int len=strlen(s);
    int sx=0;
    int sy=0;
    int x=0;
    int y=0;
    int f1,f2,f3,f4;
    f1=f2=f3=f4=0;
    for(int i=0;i<len;i++)
    {
        if(s[i]=='S')
        {
            f1=1;
        }
        if(s[i]=='N')
        {
            f2=1;
        }
        if(s[i]=='E')
        {
            f3=1;
        }
        if(s[i]=='W')
            f4=1;
    }
    if(f1!=f2)
        return 0;
    if(f3!=f4)
        return 0;
    return 1;
}

int main()
{
    scanf("%s",s);
    int ans;
    ans=solve();
    if(ans)
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}




Measured memory_bytes: 256
#include <stdio.h>

int maxn(int a[], int n)
{
  int max = a[0];
  int i;
  for (i = 0; i < n; i++)
    if (a[i] > max)
      max = a[i];
  return max;
}

int main(void)
{
  int l[10];
  int i, n;

  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d", &l[i]);
  }

  int max = maxn(l, n);
  int sum = 0;
  for (i = 0; i < n; i++) {
    sum += l[i];
  }

  if (max < sum - max)
    printf("Yes\n");
  else
    printf("No\n");

  return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

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

        int W = scanner.nextInt();
        int H = scanner.nextInt();
        String c = scanner.next();
        int x = (W - 1) / 2;
        int y = (H - 1) / 2;

        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                if (j == 0 && i == 0 || j == 0 && i == H - 1 || j == W - 1 && i == 0 || j == W - 1 && i == H - 1) {
                    System.out.print("+");
                } else if (j != 0 && j != W - 1 && i == 0 || j != 0 && j != W - 1 && i == H - 1) {
                    System.out.print("-");
                } else if (i != 0 && i != H - 1 && j == 0 || i != 0 && i != H - 1 && j == W - 1) {
                    System.out.print("|");
                } else if (j == x && i == y) {
                    System.out.print(c);
                } else {
                    System.out.print(".");
                }
            }
            System.out.println();
        }
    }
}



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

int main(){
  int d,g;
  cin >> d >> g;
  vector<int>ten(d);
  vector<int>bo(d);
  for(int i=0;i<d;i++)
    cin >> ten.at(i) >> bo.at(i);
  int ans=1000,now=0,te=0;
  for(int i=0;i<(d<<10);i++){
    bitset<10>b=i;
    te=0;
    now=0;
    for(int j=0;j<d;j++){
      if(b.test(j)){
        te+=ten.at(j)*(j+1)*100+bo.at(j);
        now+=ten.at(j);
      }
    }
    if(te<g){
      int n=d-1;
      while(te<g&&n>=0){
        while(b.test(n))
          n--;
        if(n<0)
          break;
        int x=ceil((double(g)-te)/((n+1)*100));
        int a=min(ten.at(n),x);
        te+=a*(n+1)*100;
        now+=a;
        if(a==ten.at(n))
          te+=bo.at(n);
        n--;
      }
    }
    if(te>=g)
      ans=min(ans,now);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3588
#include<stdio.h>
int main(void){
    char str[500];
    char a;
    int stack[100],cnt=0,n=0;
    int x,y;
    while((a=getchar())!='\n'){
        if(a=='+'){
            y=stack[cnt-1];
            x=stack[cnt-2];
            stack[cnt-2]=x+y;
            cnt--;
        }else if(a=='*'){
            y=stack[cnt-1];
            x=stack[cnt-2];
            stack[cnt-2]=x*y;
            cnt--;
        }else if(a=='/'){
            y=stack[cnt-1];
            x=stack[cnt-2];
            stack[cnt-2]=x/y;
            cnt--;
        }else if(a=='-'){
            y=stack[cnt-1];
            x=stack[cnt-2];
            stack[cnt-2]=x-y;
            cnt--;
        }else if(a==' '){
            n=0;
        }else{
            x=(int)(a-'0');
            if(n==1){
                stack[cnt-1]=(stack[cnt-1]*10)+x;
            }else{
                stack[cnt]=x;
                cnt++;
            }
            n=1;
        }
    }
    printf("%d\n",stack[0]);
    return 0;
}



Measured memory_bytes: 2128
#include<cstdio>
#include<iostream>
#include<cstring>
#include<queue>
#include<algorithm>

using namespace std;

#define il inline

constexpr int N=1e5+5;

struct EDGE
{
    int to,nxt,w;
};

int n,cnt;
EDGE e[N*2];
int dis[N],head[N];
bool vis[N];
queue<int>q;

il void add(int x,int y,int z)
{
    e[++cnt].to=y;
    e[cnt].nxt=head[x];
    e[cnt].w=z;
    head[x]=cnt;
}
void SPFA()
{
    for(int i=0;i<n;++i) dis[i]=1e9;
    dis[1]=1,q.push(1);
    while(!q.empty())
    {
        int x=q.front();
        q.pop();
        vis[x]=0;
        for(int i=head[x];i;i=e[i].nxt)
        {
            if(dis[e[i].to]>dis[x]+e[i].w)
            {
                dis[e[i].to]=dis[x]+e[i].w;
                if(!vis[e[i].to]) q.push(e[i].to),vis[e[i].to]=1;
            }
        }
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cout.tie(0),cin.tie(0);
    cin>>n;
    for(int i=0;i<n;++i) add(i,(i+1)%n,1);
    for(int i=0;i<n;++i) add(i,(i*10)%n,0);
    SPFA();
    printf("%d\n",dis[0]);
    return 0;
}


Measured memory_bytes: 3584
#include <cstdio>

using namespace std;
const int MOD(998244353);

constexpr int Mult(int a, int b)
{
	return a * 1LL * b % MOD;
}

constexpr int Add(int a, int b)
{
	return a + b >= MOD ? a + b - MOD : a + b;
}

constexpr int Sub(int a, int b)
{
	return a - b < 0 ? a - b + MOD : a - b;
}

void exgcd(int a, int b, int &x, int &y)
{
	if (b == 0)
		x = 1, y = 0;
	else
		exgcd(b, a % b, y, x), y -= x * (a / b);
}

inline int inverse(int a)
{
	int invx, invy;
	exgcd(a, MOD, invx, invy);
	return (invx % MOD + MOD) % MOD;
}

const int Max_N(500050);

int N, M, Fac[Max_N], Inv[Max_N], Ans;

inline int Com(int n, int m)
{
	return 0 <= m && m <= n ? Mult(Fac[n], Mult(Inv[m], Inv[n - m])) : 0;
}

/*
Ò»¸ö±äÉ«ÁúºÏ·¨£¬µ±ÇÒ½öµ±³ÔµÄºìÇò±ÈÀ¶Çò¶à£¬»òÕßÏàµÈµ«×îºóÒ»¸ö³ÔµÄÊÇÀ¶Çò
¼ÙÉèÒ»¹²ÓÐR¸öºìÇòºÍB¸öÀ¶Çò£¬Ê×ÏÈÒ»¶¨ÓÐR >= max(B, N)
Í¬Ê±×îÓÅ²ßÂÔÏÔÈ»ÊÇ£¬ÕÒÒ»¸ö±³¹øÁú£¬ÆäËûÁúµÄÐòÁÐÎªRB»òÕßR£¬Ê£ÏÂµÄÇòÈ«²¿¸ø±³¹øÁú¡£ÄÇÃ´±³¹øÁú»á»ñµÃR - N + 1¸öºìÇò
¿¼ÂÇÔÚ¶þÎ¬Æ½ÃæÉÏ×ßµ½(x, y)±íÊ¾µ±Ç°ÐòÁÐÖÐÓÐx¸öRºÍy¸öB£¬ÄÇÃ´ÐòÁÐ¾ÍÊÇ´Ó(0, 0)×ßµ½(R, B) 
´ÓÇ°ÍùºóÉ¨£¬µ±Åöµ½y - x = R - N + 1µÄÇé¿öÊ±£¬ÓÐÈçÏÂÊÂ£º
£¨1£©ÐòÁÐÒ»¶¨Ã»ÓÐ×ßÍê¡£×ßÍêÊ±B - R <= 0£¬R - N + 1 >= 1£¬ËùÒÔ²»»áÕâÖÖÇé¿ö
£¨2£©¶ÔÓÚÆäËüÇé¿ö£¬ÕâÊ±ºò×îºÃÒ²Ö»ÄÜÈÃ±³¹øÁú³ÔµÄºìÇòºÍÀ¶ÇòÒ»Ñù¶à£¬¶ø×îºóÒ»¸öÓÖ²»ÄÜ³ÔÀ¶Çò·ñÔò±³¹øÁú³ÔµÄÀ¶ÇòÊýÄ¿ÓÖÔö¼ÓÁË£¬ËùÒÔÕâ¸ö±³¹øÁú¾ÍÎÞ·¨±ä³ÉºìÉ« 
Ö±½Ó·­ÕÛ·¨¼ÆÊý 
*/

int main()
{
	scanf("%d%d", &N, &M);
	Fac[0] = 1;
	for (int i = 1;i <= M;++i)
		Fac[i] = Mult(Fac[i - 1], i);
	Inv[M] = inverse(Fac[M]);
	for (int i = M - 1;i >= 0;--i)
		Inv[i] = Mult(Inv[i + 1], i + 1);
	for (int R = N;R <= M;++R)
		Ans = Add(Ans, Sub(Com(M, R), Com(M, R * 2 - N + 1)));
	printf("%d", Ans);
	return 0;
}

Measured memory_bytes: 4096
N = int(input())
A = [2 for i in range(10 ** 7 + 1)]
A[1] = 1
for i in range(2, 10 ** 7 + 1):
    for j in range(2*i, 10 ** 7 + 1, i):
        A[j] +=1

ans = 0
for i in range(1, N+1):
    ans += i * A[i]
    
print(ans)

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

int main(void){
    int N;
    //char *S;
    char S[2000000][4];
    char *AC="AC";
    char *WA="WA";
    char *TLE="TLE";
    char *RE="RE";
    int Nac = 0;
    int Nwa = 0;
    int Ntle = 0;
    int Nre = 0;
    int i;
    
    scanf("%d",&N);
    //S = (char *)malloc(N * sizeof(char));
 
    for (i=0; i<N; i++) {
        scanf("%s",&S[i]);
        
    }

    for (i=0; i<N; i++) {
        if (strncmp(S[i],AC,2)==0) {
            Nac = Nac + 1;
        } else if (strncmp(S[i],WA,2)==0) {
            Nwa = Nwa + 1;
        } else if (strncmp(S[i],TLE,2)==0) {
            Ntle = Ntle + 1;
        } else if (strncmp(S[i],RE,2)==0) {
            Nre = Nre + 1;
        }
    }

    printf("AC x %d\n", Nac);
    printf("WA x %d\n", Nwa);
    printf("TLE x %d\n", Ntle);
    printf("RE x %d\n", Nre);
    
    return 0;
}

Measured memory_bytes: 2128
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, std.bigint;

void main()
{
    auto N = readln.chomp.to!int;
    int r, b;
    foreach (c; readln.chomp.to!(char[])) {
        if (c == 'R') {
            ++r;
        } else if (c == 'B') {
            ++b;
        }
    }
    writeln(r > b ? "Yes" : "No");
}

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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define FOR(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define FORR(i,a,b) for(ll (i)=(b)-1;(i)>=(a);(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
/*}}}*/

void proc(ll nr,ll nl){
  ll odd = (nr+nl)/2;
  ll evn = nr+nl - odd;
  ll oi,ei;
  if(nr&1){
    oi = nr;
    ei = nr-1;
  }else{
    oi = nr-1;
    ei = nr;
  }
  REP(i,nr+nl){
    if(i==oi) cout << odd;
    else if(i==ei) cout << evn;
    else cout << 0;
    cout << " ";
  }
}
int main() {
  string s;
  cin >> s;
  bool searchR = true;
  ll nr=0,nl=0;
  REP(i,s.length()){
    if(searchR){
      if(s[i]=='R'){
        nr++;
      }else{
        searchR = false;
        nl++;
      }
    }else{
      if(s[i]=='R'){
        searchR = true;
        proc(nr,nl);

        nr = 1;
        nl = 0;
      }else{
        nl++;
      }
    }
  }
  proc(nr,nl);
  cout << endl;
  return 0;
}


Measured memory_bytes: 640
import heapq
n = int(input())
p = list(map(int,input().split()))

h = []
heapq.heapify(h)
ans=0
for i in range(len(p)):
    heapq.heappush(h,p[i])
    m = heapq.heappop(h)
    if m==p[i]:
        ans+=1
    heapq.heappush(h,m)
print(ans)

Measured memory_bytes: 24872
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using st=string;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(ll i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
#define pb push_back
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
st abc="abcdefghijklmnopqrstuvwxyz";
st ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
struct edge{ll to,cost;};
struct edge2{ll from,to,cost;};

ll pow_mod(ll x,ll y){
    if(y==0){
        return 1;
    }
    if(y%2==0){
        ll k=pow_mod(x,y/2);
        return k*k%MOD;
    }
    return x*pow_mod(x,y-1)%MOD;
}

ll inv(ll k){
    return pow_mod(k,MOD-2);
}

int main() {
    ll N;
    cin >> N;
    vl A(N);
    rep(i,N){
        cin >> A[i];
    }
    vl a=A;
    vl memo(1000001,0);
    rep(i,N){
        FOR(j,2,1001){
            ll k=0;
            while(a[i]%j==0){
                k++;
                a[i]/=j;
            }
            memo[j]=max(memo[j],k);
        }
        memo[a[i]]=1;
    }
    ll ans=0;
    ll init=1;
    FOR(i,1,1000001){
        init*=pow_mod(i,memo[i]);
        init%=MOD;
    }
    rep(i,N){
        ans+=init*inv(A[i])%MOD;
        ans%=MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 11188
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		
		if(a < b && b < c) {
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
		
		sc.close();
	}

}



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

#define int long long
#define endl "\n"
#define pb push_back
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define IN freopen("input.txt","r",stdin);
#define OUT freopen("output.txt","w",stdout);

const int N = 2e5 + 5;
const double pi = 3.141592653589793238;

template<class T> bool ckmax(T& a, const T& b){return a<b?a=b,1:0;}

int32_t main()
{
    IOS;
    int n,m,k;
    cin >> n >> m >> k;
    int a[n],b[m];
    for(int i=0;i<n;i++)
        cin >> a[i];
    for(int i=0;i<m;i++)
        cin >> b[i];

    int as = 0;
    for(int i=0;i<n;i++)
        as += a[i];
    int bs=0, bp=0;
    int cnt=0;
    for(int i=n;i>=0;i--){
        if(i<n)
            as -= a[i];
        if(as<=k){
            while(bp<m && as+bs+b[bp]<=k){
                bs += b[bp];
                bp++;
            }
            ckmax(cnt,i+bp);
        }
    }
    cout << cnt << endl;
}


Measured memory_bytes: 6772
def B():
    mat = [list(map(int,input().split())) for i in range(3)]
    n = int(input())
    #b = [list(map(int,input().split())) for i in range(n)]
    for bingo in  (int(input()) for _ in range(n)):
        for i in range(3):
            for j in range(3):
                if mat[i][j] == bingo:
                    mat[i][j] = 0
    for i in range(3):
        if all(mat[i][j] == 0 for j in range(3)):
            print('Yes')
            break
        if all(mat[j][i] == 0 for j in range(3)):
            print('Yes')
            break
    else:
        if mat[0][0] == mat[1][1] == mat[2][2] == 0 or\
                mat[0][2] == mat[1][1] == mat[2][0] == 0:
            print('Yes')
        else:
            print('No')
B()

Measured memory_bytes: 3064
if __name__ == '__main__':
    N, T = map(int, input().split())
    ts = list(map(int, input().split()))
    
    
amount =0


    
for index in range(N-1):
    t_sub = ts[index+1]-ts[index]
    amount+=min(t_sub,T)

        
amount +=T

print(amount)

Measured memory_bytes: 26708
#coding:utf-8
#1_6_C
def partition(A, p, r):
    x = int(A[r][1])
    i = p - 1
    for j in range(p, r):
        if int(A[j][1]) <= x:
            i += 1
            A[i], A[j] = A[j], A[i]
    A[i + 1], A[r] = A[r], A[i + 1]
    return i + 1

def quick_sort(A, p, r):
    if p < r:
        q = partition(A, p, r)
        quick_sort(A, p, q - 1)
        quick_sort(A, q + 1, r)
    return A

class CheckStable:
    def __init__(self):
        self.d = dict() # Key is number. Value is array of suit.

    def store_cards(self, cards):
        for i in range(n):
            if cards[i][1] in self.d:
                self.d[cards[i][1]].append(cards[i][0])
            else:
                self.d[cards[i][1]] = [cards[i][0]]

    def is_stable(self, cards):
        for item in reversed(cards):
            if self.d[item[1]].pop() != item[0]:
                return "Not stable"
        return "Stable"

n = int(input())
cards = [tuple(input().split()) for i in range(n)]
d = CheckStable()
d.store_cards(cards)

quick_sort(cards, 0, n - 1)

print(d.is_stable(cards))
for i in range(n):
    print(' '.join(cards[i]))

Measured memory_bytes: 24912
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <functional>
#include <climits>
#include <string>
int main() {
	int n; std::cin >> n;
	std::vector<std::string> words(n);
	for (auto& s : words) std::cin >> s;
	int end_with_a{ 0 }, start_with_b{ 0 }, sand{ 0 }, include{ 0 };
	for (const auto &s : words) {
		if (s[0] == 'B') ++start_with_b;
		if (s[s.size() - 1] == 'A') ++end_with_a;
		if (s[0] == 'B' && s[s.size() - 1] == 'A') ++sand;
		for (auto i = 1; i < s.size(); ++i) {
			if (s[i - 1] == 'A' && s[i] == 'B') ++include;
		}
	}
	if (end_with_a > sand && start_with_b > sand) std::cout << std::min(end_with_a, start_with_b) + include << std::endl;
	else if (end_with_a == sand && start_with_b == sand && sand > 0) std::cout << sand - 1 + include << std::endl;
	else std::cout << sand + include << std::endl;
}

Measured memory_bytes: 1144
#ifdef __GNUC__
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#endif

#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <cmath>

#include <string>
#include <cstring>
#include <vector>
#include <valarray>
//#include <array>//x C++ (G++ 4.6.4)

#include <queue>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <cassert>//assert();
#include <fstream>
#include <random>
/////////
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)

/////////
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
#define PII pair<int,int>
/////////
using namespace::std;

// 最大公約数
template<class T>
inline T gcd(T a, T b){return b ? gcd(b, a % b) : a;}
//inline T gcd(T a, T b){return b == 0 ? a : gcd(b, a % b);}
/*inline T gcd(T a,T b){
	while(b != 0 ){
		a = a % b;
		swap(a,b);
	}
	return a;
}*/

// 最小公倍数
template<class T>
inline T lcm(T a, T b){return a / gcd(a, b) * b;}
//inline T lcm(T a, T b){return a * b / gcd(a, b);}
////////////////////////////////

inline void solve(){
	int N;
	cin >> N;
	cout << N*800-200*(N/15) << endl;
}

signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	//std::cout << std::fixed;//小数を10進数表示
	//cout << setprecision(16);//小数点以下の桁数を指定
	
	solve();
}


Measured memory_bytes: 256
import numpy as np

n,m,q  = map(int,input().split())
rails=[tuple(map(int,input().split())) for i in range(m)]
qs=[tuple(map(int,input().split())) for i in range(q)]

xlist = np.array([[0 for j in range(n)] for i in range(n)],dtype=np.int32)
for (l,r) in rails:
    xlist[l-1,r-1]+=1

sumsumlist = np.cumsum(np.cumsum(xlist,axis=1),axis=0)


for (p,q) in qs:
    if p>1:
        ans = sumsumlist[q-1][q-1] - sumsumlist[q-1][p-2] - sumsumlist[p-2][q-1] + sumsumlist[p-2][p-2]
    elif p==1:
        ans = sumsumlist[q-1][q-1]

    print(ans)


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

using namespace std;

const int N = 100000 + 10;

struct Point
{
	int a, b;
};

struct Edge
{
	int v, id;
};

Point P[N];
vector<Edge> G[N];
int tmp[N];
bool vis[N];
vector<int> ans;

bool cmp(const Point& lhs, const Point& rhs)
{
	return lhs.a < rhs.a;
}

int dfs(int u)
{
	int s, v, x, i;
	vis[u] = true;
	s = tmp[u];
	for (i=0; i<G[u].size(); i++)
	{
		v = G[u][i].v;
		if (vis[v]) continue;
		x = dfs(v);
		if (x % 2 == 1) ans.push_back(G[u][i].id);
		s += x;
	}
	return s;
}

int main()
{
	int n, m, u, v, i;
	cin>>n>>m;
	for (i=1; i<=n; i++) cin>>P[i].a>>P[i].b;
	sort(P + 1, P + n + 1, cmp);
	for (i=1; i<=n; i++) tmp[i] = P[i].a;
	for (i=1; i<=m; i++)
	{
		cin>>u>>v;
		u = lower_bound(tmp, tmp + n + 1, u) - tmp;
		v = upper_bound(tmp, tmp + n + 1, v) - tmp;
		if (u == v) continue;
		G[u].push_back((Edge){v, i});
		G[v].push_back((Edge){u, i});
	}
	for (i=1; i<=n; i++) tmp[i] = P[i].b ^ P[i-1].b;
	tmp[n+1] = P[n].b;
	cout<<endl;
	for (i=1; i<=n; i++)
		if (!vis[i] && dfs(i) % 2 == 1) break;
	if (i <= n)	cout<<-1<<endl;
	else
	{
		cout<<ans.size()<<endl;
		if (ans.size())
		{
			sort(ans.begin(), ans.end());
			for (i=0; i<ans.size()-1; i++) cout<<ans[i]<<" ";
			cout<<ans[ans.size()-1]<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 15228
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define i_inf int(1e9)
#define i_half_inf int(1e5)
#define ll_inf ll(1e9)*ll(1e9)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

const int max_n = i_half_inf;
ll n, k, h[max_n];

void solve() {
    sort(h, h + n);
    ll ans = i_inf;
    rep(i, n - k + 1) {
        ans = min(ans, abs(h[i] - h[i + k - 1]));
    }
    cout << ans << endl;
}

int main() {
    cin >> n >> k;
    rep(i, n) cin >> h[i];
    solve();
    return 0;
}

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

int main(void)
{
  string s;
  cin >> s;

  bool flag = true;
  int len = s.length();
  if (len % 2 == 0) {
    cout << "No" << endl;
    return 0;
  }

  for (int i = 0; i < len / 2; i++) {
    if (s[i] != s[len - 1 - i]) {
      cout << "No" << endl;
      return 0;
    }
  }
  for (int i = 0; i < (len - 1) / 4; i++) {
    if (s[i] != s[(len - 1) / 2 - 1 - i]) {
      cout << "No" << endl;
      return 0;
    }
  }

  int b = (len + 3) / 2 - 1, e = len - 1;
  for (int i = 0; i < e - b; i++) {
    if (s[b++] != s[e--]) {
      cout << "No" << endl;
      cout << "HERE" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){

int N;
scanf("%d", &N);
long long int sum = 0;

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

	printf("%lld\n", sum);


return 0;
}

Measured memory_bytes: 1736
#include <stdio.h>

int main(void){
    long long a,b,c,k;
    scanf("%lld %lld %lld %lld",&a,&b,&c,&k);
    if (k%2==0){
        printf("%lld\n",a-b);
    } else {
        printf("%lld\n",b-a);
    }
	return 0 ;
}

Measured memory_bytes: 128
n = int(input())
x = input()
memo = {0:0}
for i in range(1, n+1):
    j = i
    a = 0
    while True:
        if j in memo:
            memo[i] = memo[j]+a
            break;
        else:
            b = 0
            k = j
            while k > 0:
                if k%2 == 1:
                    b += 1
                k //= 2
            j %= b
            a += 1
n1 = 0
for i in range(n):
    if x[i] == "1":
        n1 += 1
if n1 > 1:
    mup = [1]
    mdown = [1]
    for i in range(1, n):
        mup.append(mup[-1]*2%(n1+1))
        mdown.append(mdown[-1]*2%(n1-1))
    mup.reverse()
    mdown.reverse()
    mmup = 0
    mmdown = 0
    for i in range(n):
        mmup = (mmup+mup[i]*int(x[i]))%(n1+1)
        mmdown = (mmdown+mdown[i]*int(x[i]))%(n1-1)
    for i in range(n):
        if x[i] == "0":
            state = "up"
            n1i = n1+1
        else:
            state = "down"
            n1i = n1-1
        if state == "up":
            mm = (mmup+mup[i])%n1i
        else:
            mm = (mmdown-mdown[i])%n1i
        print(memo[mm]+1)
elif n1 == 1:
    for i in range(n):
        if x[i] == "1":
            print(0)
        else:
            if x[-1] == "0" and i != n-1:
                print(1)
            else:
                print(2)
else:
    for i in range(n):
        print(1)

Measured memory_bytes: 44088
#include <stdio.h>
int main(void){
    int h,w,i,j;
    char s[102][102];
    scanf("%d%d",&h,&w);
    for(i=0;i<=h+1;i++){
        for(j=0;j<=w+1;j++){
            s[i][j]='#';
        }
    }
    for(i=1;i<=h;i++){
        scanf("%s",s[i]);
        for(j=w;j>0;j--){
            s[i][j]=s[i][j-1];
        }
        s[i][0]='#';
    }
    for(i=0;i<=h+1;i++){
        for(j=0;j<=w+1;j++){
            printf("%c",s[i][j]);
        }
        putchar('\n');
    }
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <stack>
#include <climits>
#include <map>
#include <set>

using namespace std;

int gcd(int a, int b) {
    //printf("gcd(%d, %d)\n", a, b);
    if (b == 0) {
	return a;
    } else {
	return gcd(b, a % b);
    }
}

int main(){
   int K,a=1,b=1,c=1,total=0;
   cin >> K;
for(a=1;a<=K;a++){
    for(b=1;b<=K;b++){
        for(c=1;c<=K;c++){
           if(a==1||b==1)
            total+=gcd(1,c);
        else if(a==1){
        int GCD2=gcd(a,c);
        total+=gcd(GCD2,b);
        }
    else{
    total+=gcd(a,gcd(b,c));
    }
        }
        }
    }
    cout << total <<endl;
}

Measured memory_bytes: 3596
/**/
#include<bits/stdc++.h>
using namespace std;
int a,b,c,d,ans;
int main(){
	ios::sync_with_stdio(false);
	cin>>a>>b>>c>>d;
	for(int i=0;i<=a;i++){
		for(int j=0;j<=b;j++){
			for(int k=0;k<=c;k++){
				if(i*500+j*100+50*k==d){
					ans++;
				}
				if(i*500+j*100+50*k>d){
					break;
				}
			}
		}
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <queue>
#include <deque>
#include <string>
#include <sstream>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <stack>
#include <cstdio>
#include <climits>
#include <tuple>
#include <ctime>
#define FOR(i,a,n) for (int i = a; i < n; i++)
#define IFOR(i,n,a) for (int i = n; i >= a; i--)
#define mp make_pair
#define full(a) a.begin(), a.end()
#define SZ(x) ((int)(x).size())
#define TC(tc) while (tc--)
#define VI vector<int>
#define PII pair<int, int>
#define trav(a,x) for (auto& a : x)
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
using namespace std;
const int mod = 1e9 + 7;

int main()
{
	ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	int n, k; cin >> n >> k;
	priority_queue<int, vector<int>, greater<int>> pq;
	FOR(i, 0, n)
	{
		int a; cin >> a;
		pq.push(a);
	}
	int sum = 0;
	while (k--)
	{
		sum += pq.top();
		pq.pop();
	}
	cout << sum;
	return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int J, L, i, o;
	while(~scanf("%d%d%*d%d%d%*d%*d", &i, &o, &J, &L))
	{
		int cnt = J % 2 + L % 2 + i % 2;
		if(J > 0 && L > 0 && i > 0 && 3 - cnt < cnt)
			cnt = 3 - cnt;
		printf("%lld\n", 0LL + J + L + i + o - cnt);
	}
	return 0;
}

Measured memory_bytes: 256
from collections import Counter
n, k, q = map(int, input().split())
a = [int(input()) for _ in range(q)]
count = Counter(a)
ans = [(k - q) for _ in range(n)]

list = ["No" for _ in range(n)]

for key, value in count.items():
    ans[key - 1] = k - q + value
    if ans[key - 1] > 0:
        list[key - 1] = "Yes"

for i in list:
    if k - q > 0:
        print("Yes")
    else:
        print(i)


Measured memory_bytes: 102104
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace Tasks
{
    public class B
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var (N, A, B) = Scanner.Scan<long, long, long>();
            if (A == 0)
            {
                Console.WriteLine(0);
                return;
            }
            var answer = N / (A + B) * A;
            answer += Math.Min(A, N % (A + B));
            Console.WriteLine(answer);
        }

        public static class Scanner
        {
            private static Queue<string> queue = new Queue<string>();
            public static T Next<T>()
            {
                if (!queue.Any()) foreach (var item in Console.ReadLine().Trim().Split(" ")) queue.Enqueue(item);
                return (T)Convert.ChangeType(queue.Dequeue(), typeof(T));
            }
            public static T Scan<T>() => Next<T>();
            public static (T1, T2) Scan<T1, T2>() => (Next<T1>(), Next<T2>());
            public static (T1, T2, T3) Scan<T1, T2, T3>() => (Next<T1>(), Next<T2>(), Next<T3>());
            public static (T1, T2, T3, T4) Scan<T1, T2, T3, T4>() => (Next<T1>(), Next<T2>(), Next<T3>(), Next<T4>());
            public static (T1, T2, T3, T4, T5) Scan<T1, T2, T3, T4, T5>() => (Next<T1>(), Next<T2>(), Next<T3>(), Next<T4>(), Next<T5>());
            public static IEnumerable<T> ScanEnumerable<T>() => Console.ReadLine().Trim().Split(" ").Select(x => (T)Convert.ChangeType(x, typeof(T)));
        }
    }
}


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

int main()
{
    char s[100001];
    int a[26] = {};
    int i;
    scanf("%s", s);
    for (i=0; i<strlen(s); i++)
    {
        a[s[i] - 97] = 1;
    }
    for (i=0; i<26; i++)
    {
        if (a[i] == 0) {
            printf("%c\n", i + 97);
            return 0;
        }
    }
    printf("None\n");
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	Scanner sc = new Scanner(System.in);
	
	
	void run(){
		int [] h = new int[10];
		for(int i = 0;i < 10; i++){
			h[i] = sc.nextInt();
		}
		for(int i = 0; i < 3; i++){
			for(int j =i; j < 10; j++){
				if(h[i] < h[j]){
					int temp = h[j];
					h[j] = h[i];
					h[i] = temp;
				}
			}
			System.out.println(h[i]);
		}
		
	}
	public static void main(String[] args){
		Main m = new Main();
		m.run();
		
	}
}

Measured memory_bytes: 11000
#define ll long long
#define MOD 1000000007
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define set2d(array, val, m, n) memset(array, val, sizeof(array[0][0]) * m * n);
#include <bits/stdc++.h>
using namespace std;
ll gcd(ll a, ll b)
{
    if (!b)
        return a;
    return gcd(b, a % b);
}
ll power(ll x, ll y, ll p)
{
    ll res = 1;
    x %= p;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}
ll po(ll base, ll powerRaised)
{
    if (powerRaised != 0)
        return (base * po(base, powerRaised - 1));
    else
        return 1;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
// #ifndef ONLINE_JUDGE
//     freopen("input.txt", "r", stdin);
//     freopen("output.txt", "w", stdout);
// #endif //*/
    ll n, k, s;
    cin >> n >> k >> s;
    for (int i = 1; i <= k; i++)
        cout << s << " ";
    if (s == 1)
    {
        for (int i = k + 1; i <= n; i++)
            cout << "2 ";
        return 0;
    }
    else
    {
        ll start = 2;
        if (s == 2)
            start = 3;
        ll i = k;
        while (i <= n)
        {
            if (i == n)
                break;
            cout << start << " ";
            i++;
            if (i == n)
                break;
            cout << s - start + 1 << " ";
            i++;
        }
    }
    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
}

Measured memory_bytes: 1280
#include "bits/stdc++.h"
using namespace std;
//debug() << imie(x) imie(y);
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
int main()
{

int a,b,c,d;
cin>>a>>b>>c>>d;
cout<<max(a*b,c*d);
return 0;
}


Measured memory_bytes: 256
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

def s(generator, splitter, mapper):
    return [ mapper(s) for s in generator().split(splitter) ]

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

l,r = get_nums_l()
d = r-l

lm = l % 2019
rm = r % 2019


nums = [0] * 2019
for imod in range(2019):
    if (imod+(2019-lm))%2019 <= d:
        nums[imod] += 1 + (d - (imod+(2019-lm))%2019)//2019

min_ = 999999999999999999999
for a in range(2019):
    for b in range(2019):
        if a==b and nums[a] < 2:
            continue
        if nums[a] < 1 or nums[b] < 1:
            continue
        mo = a*b%2019
        if min_ > mo:
            min_ = mo
print(min_)

# m3   = 3 - l % 3
# m673 = 673 - l % 673

# if (m3==3 or m3 <= d) and (m673==673 or m673 <= d):
#     print(0)
# else:
#     print((l*(l+1)) % 2019)

Measured memory_bytes: 41948
#include<stdio.h>

int main(){
  int a,b,c,n,i;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d %d %d",&a,&b,&c);

    if(c*c==a*a+b*b || a*a==b*b+c*c || b*b==a*a+c*c){
      printf("YES\n");
    }
    else printf("NO\n");


  }
  return 0;
}

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

using namespace std;
#define lint long long


int main() {
    string s;
    lint K;
    cin >> s >> K;
    
    vector<int> list;
    
    for(lint i = 0; i < s.size(); ++i){
        int a = 'z' - s[i];
        list.push_back((a + 1) % 26);
    }
    
    lint pos = 0;
    
    while(K > 0 && pos < s.size()){
        if(list[pos] <= K){
            K -= list[pos];
            s[pos] = 'a';
        }
        ++pos;
    }
    
    if(K > 0){
        for(lint i = 0; i < s.size(); ++i){
            if(s[pos] != 'a'){
                s[pos] += (K % 26);
                break;
            }
        }
    }
    
    if(K > 0){
        s[s.size() - 1] += (K % 26);
    }
    
        cout << s << endl;
}

Measured memory_bytes: 1020
S = input()
AA = int(S[:2])
BB = int(S[2:])
 
if 1 <= BB <= 12 and (AA > 12 or AA == 0):
    print('YYMM')
elif 1<= AA <=12 and (BB > 12 or BB == 0):
    print('MMYY')
elif 1 <= AA <= 12 and 1 <= BB <= 12:
    print('AMBIGUOUS')
else:
    print('NA')

Measured memory_bytes: 38256
using System;
using System.Collections.Generic;
using System.Linq;

namespace AizuOnlineJudge
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.ReadLine();
            var target = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            Console.ReadLine();
            var from = Console.ReadLine().Split(' ').Select(int.Parse);

            var count = 0;
            foreach(var v in from)
            {
                if (Search(target, v)) count++;
            }
            Console.WriteLine(count);
        }

        private static bool Search(int[] target, int v)
        {
            var left = 0;
            var right = target.Length;
            var p = 0;
            while (left < right)
            {
                p = (left + right) / 2;
                if (target[p] == v) return true;
                else if (target[p] < v) left = p + 1;
                else right = p;
            }
            return false;
        }
    }
}


Measured memory_bytes: 30704
#include<bits/stdc++.h>
using namespace std;
 
template<typename T1, typename T2> istream& operator>>(istream& is, pair<T1,T2>& a){ return is >> a.first >> a.second; }
template<typename T1, typename T2> ostream& operator<<(ostream& os, pair<T1,T2>& a){ return os << a.first << " " << a.second; }
template<typename T> istream& operator>>(istream& is, vector< T >& vc){ for(int i = 0; i < vc.size(); i++) is >> vc[i]; return is; }
template<typename T> ostream& operator<<(ostream& os, vector< T >& vc){ for(int i = 0; i < vc.size(); i++) os << vc[i] << endl; return os; }
 
#define ForEach(it,c) for(__typeof (c).begin() it = (c).begin(); it != (c).end(); it++)
#define ALL(v) (v).begin(), (v).end()
#define UNQ(s) { sort(ALL(s)); (s).erase( unique( ALL(s)), (s).end());}

typedef pair< int , int > Pi;
typedef pair< int , Pi > Pii;
typedef long long int64;

int nextright[100];
int nextleft[100];
int java[100];
int emacs[100];
int dp[100];


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

int64 dfs(int idx){
  if(dp[idx]) return dp[idx];
  int64 left = 1, right = 1;
  if(nextright[idx] != -1) right = dfs(nextright[idx]);
  if(nextleft[idx] != -1) left = dfs(nextleft[idx]);
  int ret = lcm( right * java[idx], left * emacs[idx]);
  return dp[idx] = ret / java[idx] + ret / emacs[idx];
}

int main(){
  int n;
  while(cin >> n, n){
    fill_n( dp, 100, 0);
    for(int i = 0; i < n; i++){
      int p, q, r, b;
      cin >> p >> q >> r >> b;
      r--, b--;
      nextright[i] = r;
      java[i] = p;
      nextleft[i] = b;
      emacs[i] = q;
    }
    int64 ret = 0;
    for(int i = 0; i < n; i++){
      ret = max( ret, dfs(i));
    }
    cout << ret << endl;
  }
}

Measured memory_bytes: 1156
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
    int n; ll x, d;
    cin>>n>>x>>d;
    ll m[55];
    vector<int> g[55];
    for(int i=0; i<n; i++){
        cin>>m[i];
        if(i==0) continue;
        int p;
        cin>>p; p--;
        g[p].push_back(i);
        g[i].push_back(p);
    }
    int cnt[55]={};
    auto dfs=[&](auto dfs, int x, int p)->void{
        cnt[x]=1;
        for(auto y:g[x]){
            if(y==p) continue;
            dfs(dfs, y, x);
            cnt[x]+=cnt[y];
          m[x]+=m[y];
        }
    };
    dfs(dfs, 0, -1);
    ll dp[125050];
    const ll INF=1e18;
    fill(dp, dp+n*n*n, INF);
  ll mx[55];
  mx[0]=n-1;
  for(int i=1; i<n; i++) mx[i]=min(d, (ll)n-1);
  dp[0]=0;
  for(int i=0; i<n; i++){
    ll tmp[125050];
    deque<int> deq[50];
    for(int j=0; j<n*n*n; j++){
      int r=j%cnt[i];
      while(!deq[r].empty()){
        int k=deq[r].back();
        if(dp[k]-k*m[i]/cnt[i]<dp[j]-j*m[i]/cnt[i]) break;
        deq[r].pop_back();
      }
      deq[r].push_back(j);
      if(deq[r].front()==j-cnt[i]*(mx[i]+1)){
        deq[r].pop_front();
      }
      int k=deq[r].front();
      tmp[j]=dp[k]+(j-k)/cnt[i]*m[i];
    }
    for(int j=0; j<n*n*n; j++) dp[j]=tmp[j];
  }
  vector<int> ind(n);
  iota(ind.begin(), ind.end(), 0);
  sort(ind.begin(), ind.end(), [&](int i, int j){ return cnt[i]*m[j]>cnt[j]*m[i];});
  ll ans=0;
  for(int i=0; i<n*n*n; i++){
    if(dp[i]>x) continue;
    ll x1=x-dp[i], s=i;
    for(auto j:ind){
      ll c=x1/m[j];
      if(j) c=min(d-mx[j], c);
      s+=cnt[j]*c;
      x1-=c*m[j];
    }
    ans=max(ans, s);
  }
  cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 2304
using System;
using System.Collections.Generic;
using System.Linq;

public class Hello{
    public static void Main(){
        var n = Int32.Parse(Console.ReadLine());

        var memo = new Dictionary<int, bool>(100000);

        for(var i = 0; i < n; ++i){
            var j = Int32.Parse(Console.ReadLine()) - 1;
            if(!memo.ContainsKey(j)){
                memo.Add(j, true);
            }else{
                memo[j] = !memo[j];
            }
        }

        Console.WriteLine(memo.Values.Count(i => i));
    }
}



Measured memory_bytes: 16736
#include <cstdio>
#include <iostream>
#include <queue>
using namespace std;

int main(){
  queue<int> q[3];
  for (int i = 0; i < 3; i++) {
    string s; cin >> s;
    for (int j = 0; j < s.size(); j++) {
      q[i].push(s[j]-'a');
    }
  }
  int t = 0;
  while(!q[t].empty()){
    int u = q[t].front(); q[t].pop();
    t = u;
  }
  printf("%c\n", 'A'+t);
  return 0;
}


Measured memory_bytes: 256