akhauriyash/Code-Regression huggingface dataset:
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let (N, K): (usize, usize) = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap()
        )
    };
    let mut H: Vec<usize> = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|x| x.parse().unwrap())
            .collect()
    };
    H.insert(0, 0);

    const INF: usize = 1_000_000_000_000;

    let mut dp = vec![vec![INF; N + 1]; K + 1];
    dp[0][0] = 0;
    for i in 1..(N + 1) {
        let mut dp2 = vec![vec![INF; N + 1]; K + 1];
        for k in (1..(K + 1)).rev() {
            for j in 0..i {
                // println!("{} {} {}", i, k , j);
                dp2[k][j] = dp[k - 1][j];
                // println!("{}", dp2[k][i])
            }
            for j in 0..i {
                let d = if H[i] > H[j] { H[i] - H[j] } else { 0 };
                dp2[k][i] = std::cmp::min(dp2[k][i], dp[k][j] + d);
            }
            // println!("{:?}", dp2);
        }
        let d = if H[i] > H[i - 1] { H[i] - H[i - 1] } else { 0 };
        dp2[0][i] = dp[0][i - 1] + d;
        // println!("{:?}", dp);
        // println!("{:?}", dp2);
        // println!("----");
        dp = dp2;

    }
    let ans = *dp[K].iter().min().unwrap();

    println!("{}", ans);
}


Measured memory_bytes: 4352
n=int(input())
A=list(map(int,input().split()))
dic={tl:0 for tl in range(n)}

l=1
while max(A)>0:
  Q=[a%2 for a in A]
  A=[a//2 for a in A]
  s=sum(Q)
  if s%2==1:
    for i in range(n):
      if Q[i]==0:
       dic[i]+=l
  else:
    for i in range(n):
      if Q[i]==1:
       dic[i]+=l
  l*=2

for i in range(n):
  print(dic[i])

Measured memory_bytes: 49736
import java.util.*;
import java.math.BigInteger;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.HashMap;

public class Main {
	
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int K = sc.nextInt();
		int[] l = new int[N];
		for(int i = 0; i < N; i++) {
			l[i] = sc.nextInt();
		}
		Arrays.sort(l);
		int sum = 0;
		for(int i = 0; i < K; i++) {
			sum += l[N - 1 - i];
		}
		System.out.println(sum);
	}
}

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


bool p[1000000];

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

  for (int i = 2; i < 1000000; i++){
    p[i] = true;
  }
  for (int i = 2; i * i < 1000000; i++){
    if (p[i]){
      for (int j = 2 * i; j < 1000000; j += i){
        p[j] = false;
      }
    }
  }

  int n;

  while (cin >> n, n){
    int sum = 0;
    int f = 0;
    
    for (int i = 0; f != n; i++){
      if (p[i]){
        sum += i;
        f++;
      }
    }
    cout << sum << endl;
  }
}

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

#define INF INT_MAX
typedef long long ll;

using namespace std;

int main(void){
	int a,b;
	cin >> a >> b;

	int ans = 0;
	for(int i = 0;i < 2;i++){
		if(a > b){
			ans += a;
			a--;
		}else{
			ans += b;
			b--;
		}
	}

	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
N = int(input())
d = []
mochi = 101
ans = 0

for _ in range(N):
    d += [int(input())]

d.sort(reverse=True)

for i in range(N):
    if mochi > d[i]:
        mochi = d[i]
        ans += 1
    else:
        pass

print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define ll long long int
#define fl(i,x,y) for( int i=x;i<y;i++)
#define w(t) while(t--)
#define vi vector<ll>
#define vvi vector< vi >
#define si set<ll>
#define msi multiset<ll>
#define si_d set<ll, greater<ll> >
#define mii map<ll,ll>
#define pb push_back
#define msi_it  multiset<ll> :: iterator
#define si_it set<ll> :: iterator
#define sort1(v) sort(v.begin(),v.end());
#define F first
#define S second
using namespace std;
#define N 1000000007
#define mod 15000000000031
int main()
{
	int n,k,ans=0;
	cin>>n>>k;
	int a[k],b[k];
	fl(i,0,k) cin>>a[i];
	fl(i,0,k-1)
	{
		b[i]=a[i+1]-a[i];
	}
	b[k-1]=n-(a[k-1]-a[0]);
	sort(b,b+k);
	fl(i,0,k-1)
	{
	    ans+=b[i];
	}
	cout<<ans;
}

Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Text;

namespace AOJ
{
    class Program
    {
        static void Main(string[] args)
        {
            var m = new bool[30];
            Enumerable.Range(1, 28)
                .Select(i => Console.ReadLine())
                .Select(int.Parse)
                .ToList()
                .ForEach(i => m[i - 1] = true);
            m.Select((v, i) => new { v, i })
                .Where(vi => !vi.v)
                .Select(vi => (vi.i + 1).ToString())
                .ToList()
                .ForEach(s => Console.WriteLine(s));
        }
    }
}

Measured memory_bytes: 6000
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	long long a, b, c, s, i, j, k, aa, bb, cc;

	cin >> a >> b;
	if ((a <= 0) && (b >= 0)) cout << "Zero\n";
	else if (a > 0) cout << "Positive\n";
	else {
		if ((b - a) % 2 == 0) cout << "Negative\n";
		else cout << "Positive\n";
	}

	return 0;
}


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

long long n,x[1005],y[1005],p,sd[35];

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

    cin>>n;
    cin>>x[0]>>y[0];
    p=abs(x[0]+y[0])%2;
    int ind=0;
    for(int i=1;i<n;i++)
    {
        cin>>x[i]>>y[i];
        if(abs(x[i]+y[i])%2!=p)
            ind=1;
    }
    if(ind)
    {
        cout<<-1<<endl;
        return 0;
    }
    sd[0]=1;
    for(int i=1;i<35;i++)
        sd[i]=sd[i-1]*2;

    if(p==0)
    {
        cout<<32<<endl;
        cout<<1<<" ";
        for(int i=0;i<=30;i++)
            cout<<sd[i]<<" ";
        cout<<endl;
        for(int i=0;i<n;i++)
        {
            y[i]--;
            //cout<<x[i]<<y[i]<<endl;
            int br=31;
            vector<char> slova;
            while(br)
            {
                if(llabs(x[i]-sd[br-1])+llabs(y[i])<=sd[br-1]-1)
                {
                    slova.push_back('R');
                    x[i]-=sd[br-1];
                }
                else if(llabs(x[i]+sd[br-1])+llabs(y[i])<=sd[br-1]-1)
                {
                    slova.push_back('L');
                    x[i]+=sd[br-1];
                }
                else if(llabs(y[i]+sd[br-1])+llabs(x[i])<=sd[br-1]-1)
                {
                    slova.push_back('D');
                    y[i]+=sd[br-1];
                }
                else if(llabs(y[i]-sd[br-1])+llabs(x[i])<=sd[br-1]-1)
                {
                    slova.push_back('U');
                    y[i]-=sd[br-1];
                }
                br--;
            }
            //cout<<x[i]<<y[i]<<endl;
            cout<<'U';
            reverse(slova.begin(),slova.end());
            for(int i=0;i<slova.size();i++)
                cout<<slova[i];
            cout<<endl;
        }
    }
    else
    {
        cout<<31<<endl;
        for(int i=0;i<=30;i++)
            cout<<sd[i]<<" ";
        cout<<endl;
        for(int i=0;i<n;i++)
        {
            int br=31;
            vector<char> slova;
            while(br)
            {
                if(llabs(x[i]-sd[br-1])+llabs(y[i])<=sd[br-1]-1)
                {
                    slova.push_back('R');
                    x[i]-=sd[br-1];
                }
                else if(llabs(x[i]+sd[br-1])+llabs(y[i])<=sd[br-1]-1)
                {
                    slova.push_back('L');
                    x[i]+=sd[br-1];
                }
                else if(llabs(y[i]+sd[br-1])+llabs(x[i])<=sd[br-1]-1)
                {
                    slova.push_back('D');
                    y[i]+=sd[br-1];
                }
                else if(llabs(y[i]-sd[br-1])+llabs(x[i])<=sd[br-1]-1)
                {
                    slova.push_back('U');
                    y[i]-=sd[br-1];
                }
                br--;
            }
            reverse(slova.begin(),slova.end());
            for(int i=0;i<slova.size();i++)
                cout<<slova[i];
            cout<<endl;
        }
    }

}


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

const int MXN = 1e5 + 9;

struct robot {
	int l, r;
	robot() {
		l = r = 0;
	}
	robot(int l, int r) : l(l), r(r) {}
	bool operator < (const robot &w) const {
		return r == w.r ? l < w.l : r < w.r;
	}
} a[MXN];

int n, x, l;

int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; ++i) 
		scanf("%d %d", &x, &l), a[i].l = x - l, a[i].r = x + l;
	sort(a, a + n);
	int tot = 0, pos = -0x7fffffff;
	for (int i = 0; i < n; ++i) {
		// printf("%d %d\n", a[i].l, a[i].r);
		
		if (a[i].r == pos) {
			continue;
		} else {
			if (a[i].l >= pos) 
				pos = a[i].r, tot++;
		}
	}
	printf("%d\n", tot);
	return 0;
}

Measured memory_bytes: 1024
N, M = list(map(int, input().split()))
A =[0]*M
for i in range(M):
    A[i] = int(input())

amari = 1000000007
cnt = [0]*(N+2)
cnt[0] = 0
cnt[1] = 1
for i in range(2,N+2):
    t = (cnt[i-1]+cnt[i-2])
    cnt[i] = t % amari

ans = 1
def calc(ans):
    if M == 0:
        return cnt[N+1]

    for i in range(M): 
        if i == 0:
            ans*= cnt[A[i]]
        elif i > 0 and i < M:
            ans*=cnt[A[i] - A[i-1]-1]

        if i == M-1:
            ans*= cnt[N - A[i]]
        
        if ans == 0:
            break
    
        ans %= amari
        
    return ans

print(calc(ans))

Measured memory_bytes: 10868
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#define rep(i,x) for(int i = 0; i < x; i++)
typedef long long ll;
using namespace std;
const ll N = 1e9+7;

int main(){
    string s; cin >> s;
    bool ok = true;
    rep(i,4){
        if(i < 3 &&  s[i] == s[i+1]){
            ok = false;
        }
    }
    int ans = 0;
    if(ok) cout << "Good" << endl;
    else cout << "Bad" << endl;
    // cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int a,b,i,j,m1,m2,x;
	m1=2000;
	m2=2000;
	for(i=1;i<=3;i++) {
		scanf("%d",&a);
		if(a<m1) {
			m1=a;
		}
	}
	for(j=1;j<=2;j++) {
		scanf("%d",&b);
		if(b<m2) {
			m2=b;
		}
	}
	x=(m1+m2)-50;
	printf("%d\n",x);
	return 0;
}

Measured memory_bytes: 592
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int[] v = new int[n];
		int[] c = new int[n];
		
		for(int i= 0; i<n;i++) {
			v[i]=sc.nextInt();
		}
		for(int i=0;i<n;i++) {
			c[i] = sc.nextInt();
		}
		
		int res=0;
		int sum = 0;
		for(int i = 0; i < n; i++) {
			if(c[i]<v[i]) {
				res+=c[i];
				sum+=v[i];
			}
		}
		System.out.println(sum-res);
	}

}


Measured memory_bytes: 21972
import java.util.Scanner;

public class Main {
    Main(){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int count = 0;
        for (int i=a; i<=b; i++ ){
            if(c%i==0) count++;
        }
        System.out.printf("%d\n", count);


    }

    public static void main(String[] args){
        new Main();
    }
}



Measured memory_bytes: 26432
#include <cstdio>
#include <cmath>
using namespace std;

int main(){
    double x[20], y[20], area = 0;
    int i = 0;
    while( scanf("%lf,%lf", &x[i], &y[i]) != EOF) i++;
    for(int j = 2; j < i; j++){
        double dx1 = x[j]-x[0], dy1 = y[j]-y[0];
        double dx2 = x[j-1]-x[0], dy2 = y[j-1]-y[0];
        double dx3 = x[j]-x[j-1], dy3 = y[j]-y[j-1];
        double a = sqrt(dx1*dx1+dy1*dy1);
        double b = sqrt(dx2*dx2+dy2*dy2);
        double c = sqrt(dx3*dx3+dy3*dy3);
        double z = (a+b+c)/2;
        area += sqrt(z*(z-a)*(z-b)*(z-c));
    }
    printf("%.6lf\n", abs(area));
    return 0;
}

Measured memory_bytes: 1088
import fractions
import itertools

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


def gcds(list_):
    return list(itertools.accumulate(list_, fractions.gcd))


def reversed_gcds(list_):
    return list(itertools.accumulate(reversed(list_), fractions.gcd))


as_accum_gcd, as_rev_accum_gcd = gcds(as_), reversed_gcds(as_)

dropped_gcds = []
for i in range(len(as_)):
    if i == 0:
        dropped_gcd = as_rev_accum_gcd[-2]
    elif i == len(as_) - 1:
        dropped_gcd = as_accum_gcd[-2]
    else:
        dropped_gcd = fractions.gcd(as_accum_gcd[i - 1], as_rev_accum_gcd[-2 - i])
    dropped_gcds.append(dropped_gcd)

print(max(dropped_gcds))


Measured memory_bytes: 16088
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(signed i=0;i<n;++i)
#define repi(n) rep(i,n)
#define repvin(n) vint a(n);r(i,n)cin>>a[i];
#define int long long
#define str string
#define vint vector<signed>
#define pint pair<signed,signed>
#define pb(a) push_back(a)
#define all(v) v.begin(),v.end()
#define yn(b) cout<<((b)?"Yes":"No")<<endl
#define YN(b) cout<<((b)?"YES":"NO")<<endl
#define call(a) for(auto t:a)cout<<t<<" ";cout<<endl
#define ENDL printf("\n");
#define debg(a) cout<<#a<<":"<<a<<endl;

signed main(){
  int n,m;
  cin>>n>>m;
  int d=m/n,res=0;
  for(int i=1;i<=d;i*=2)res++;
  cout<<res;
  
  return 0;
}


Measured memory_bytes: 256
from sys import stdin

BTC_RATE = 380000.0

N = int(stdin.readline().rstrip())


xu_list = [[x for x in stdin.readline().rstrip().split()] for _ in range (N)]

sum_num = 0
for x, u in xu_list:
    x = float(x)
    if u == "JPY":
        sum_num += x
    else:
        sum_num += x * BTC_RATE

print(sum_num)


Measured memory_bytes: 38512
# import sys
# sys.setrecursionlimit(10 ** 6)
# import bisect
# from collections import deque

def divisor(x):
    """約数"""
    from math import floor
    re = []
    _x = floor(x ** 0.5)
    for i in range(1, _x + 1):
        if x % i == 0:
            re.append(i)
            if x // i != i:
                re.append(x // i)
    re.sort()
    return re


# from decorator import stop_watch
#
#
# @stop_watch
def solve(N, M):
    div = divisor(M)
    div.sort()
    ans = 0
    for d in div:
        if M // d >= N:
            ans = d
    print(ans)


if __name__ == '__main__':
    # S = input()
    # N = int(input())
    N, M = map(int, input().split())
    # A = [int(i) for i in input().split()]
    # B = [int(i) for i in input().split()]
    # AB = [[int(i) for i in input().split()] for _ in range(N)]
    solve(N, M)

    # # test
    # from random import randint
    # from func import random_str
    # solve()


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

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (m); i < (int)(n); ++i)
#define INF 2000000000

#ifdef LOCAL
  #define eprintf(...) fprintf(stdout, __VA_ARGS__)
#else
  #define eprintf(...) 0
#endif

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned int uint;

int ctoi(char c) {
  return c - '0';
}

template <class C>
void printContainer(C &container, const char *delim=",") {
  for(const auto &e : container) {
    std::cout << e << delim;
  }
  std::cout << "\n";
}

// Greatest common divisor
template<class T>
T gcd(T x, T y) {
  if(x < y) {
    std::swap(x, y);
  }
  T r = x % y;
  while(r != 0) {
    x = y;
    y = r;
    r = x % y;
  }
  return y;
}

// Least common multiple
template<class T>
T lcm(T x, T y) {
  return (x*y)/gcd(x,y);
}

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  map<int, int> mp;
  mp[5] = 0;
  mp[7] = 0;
  mp[a]++;
  mp[b]++;
  mp[c]++;
  if(mp[5] == 2 && mp[7] == 1) {
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    unsigned long long a,b;
    cin>>a>>b;


        unsigned long long x=a%b;
        unsigned long long z=x*x;
        unsigned long long y=b-x;
        if(z<b)
        {
            cout<<x<<endl;
        }
        else
        {
            cout<<y<<endl;
        }



    return 0;
}


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

int main(void){
	int n, r;
	while(1){
		cin >> n >> r;
		if(n == 0 && r == 0) break;

		vector<int> card;
		vector<int> card2;
		for(int i=n; i>0; i--){
			card.push_back(i);
		}

		for(int i=0; i<r; i++){
			int p, c;
			cin >> p >> c;
			p--;
			for(int j=p; j<p+c; j++){
				card2.push_back(card[j]);
			}
			for(int j=0; j<p; j++){
				card2.push_back(card[j]);
			}
			for(int j=p+c; j<n; j++){
				card2.push_back(card[j]);
			}
			card = card2;
			card2.clear();

			/*
			for(int j=0; j<n; j++){
				printf("%d ", card[j]);
			}
			puts("");
			*/
		}

		cout << card[0] << endl;



	}


	return 0;
}

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

using namespace std;

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

const char sp = ' ';
const char cmm = ',';
const int MOD = 1000000007;

using ll = long long;

ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll b, ll e, ll m){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<typename T>
void ppp(T n){cout << n << endl;}
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
    int len = v.size();
    cout << '[';
    for (int i = 0; i < len; ++i) {
        s << v[i]; if (i < len-1) s << ", ";
    }
    cout << ']';
    return s;
}


int n, q;
string s;
vector<pair<char, char>> mov;


int check(int x){
    char now = s[x];
    for(auto inst : mov){
        char t = inst.first;
        char d = inst.second;
        if(t != now) continue;
        if(d == 'R') ++x;
        else --x;

        if(x < 0) return 1;
        else if(x >= n) return -1;
        now = s[x];
    }
    return 0;
}

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    cin >> n >> q;
    cin >> s;
    mov.resize(q);
    rep(i, q){
        char t, d;
        cin >> t >> d;
        mov[i] = make_pair(t, d);
    }

    int ok = n;
    int ng = -1;

    while(ok-ng > 1){
        int mid = ng + (ok-ng)/2;
        if(check(mid) == 0){
            ok = mid;
        }
        else{
            ng = mid;
        }
    }

    int left = ok;

    ng = n;
    ok = -1;

    while(ng - ok > 1){
        int mid = ok+(ng-ok)/2;
        if(check(mid) == 0){
            ok = mid;
        }
        else{
            ng = mid;
        }
    }

    int right = ng;


    ppp(max(right-left, 0));

    return 0;
}


Measured memory_bytes: 976
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vll vector<ll>
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(int argc, char const *argv[]) {
  ll n;std::cin >> n;
  string x;
  vector<pair<string, ll>> d(n);
  re(i, n) std::cin >> d[i].first >> d[i].second;
  std::cin >> x;
  ll ans = 0;
  re(i, n){
    if(x==d[i].first){
      for(int j=i+1;j<n;j++){
        ans += d[j].second;
      }
      std::cout << ans << '\n';
      return 0;
    }
  }
  return 0;
}


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

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define REPr(i, n) for(int i = (n)-1; i >= 0; --i)
#define FORq(i, m, n) for(int i = (m); i <= (n); ++i)
#define FORqr(i, m, n) for(int i = (n); i >= (m); --i)
#define MP make_pair
#define SIN(x, S) (S.count(x) != 0)
#define M0(x) memset(x, 0, sizeof(x))
#define FILL(x, y) memset(x, y, sizeof(x))
#define MM(x) memset(x, -1, sizeof(x))
#define ALL(x) (x).begin(), (x).end()
#define DB(x) cerr << #x << " = " << x << endl
#define DB2(x, y)                                                              \
    cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n";
#define DEBUG                                                                  \
    int x12345;                                                                \
    cin >> x12345;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
const long long MOD = 1e9 + 7;
///////////////////////////////////////////////
// for template
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
///////////////////////////////////////////////
/// 🍈( '-' 🍈 |AC|
int main() {
    int N,K;
    cin >> N >> K;
    vector<int> p(N);
    REP(i,N){
        cin >> p[i];
    }

    sort(ALL(p));

    int ans = 0;
    REP(i,K){
        ans += p[i];
    }

    cout << ans << endl;
}

Measured memory_bytes: 3552
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
using namespace std;
string s;
bool solve(){
  stack<char> st;
  rep(i,s.size()){
    if(s[i] == '(') st.push(s[i]);
    else if(s[i] == '[' ) st.push(s[i]);
    else if(s[i] == ')'){
      if(st.empty()) return false;
      if(st.top() != '(') return false;
      st.pop();
    }
    else if(s[i] == ']'){
      if(st.empty()) return false;
      if(st.top() != '[') return false;
      st.pop();
    }
  }
  return st.empty();
}
int main(){
  while(1){
    getline(cin,s);
    if(s == ".") break;
    if(solve()) cout << "yes" << endl;
    else cout << "no" << endl;
  }
  return 0;
}



Measured memory_bytes: 3160
from functools import lru_cache

T = int(input())

for t in range(T):
    N, A, B, C, D = map(int, input().split())

    @lru_cache(maxsize=None)
    def dist(n):
        if n == 0:
            return 0
        if n == 1:
            return D

        ret = min(
            D * n,
            D * abs(n - n // 5 * 5) + C + dist(n // 5),
            D * abs(n - (n + 4) // 5 * 5) + C + dist((n + 4) // 5),
            D * abs(n - n // 3 * 3) + B + dist(n // 3),
            D * abs(n - (n + 2) // 3 * 3) + B + dist((n + 2) // 3),
            D * abs(n - n // 2 * 2) + A + dist(n // 2),
            D * abs(n - (n + 1) // 2 * 2) + A + dist((n + 1) // 2),
        )

        return ret

    print(dist(N))

Measured memory_bytes: 92028
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = (ll)1e18;  

int main(){
  string s;
  cin >> s;
  string t;
  cin >> t;
  string ss = s+s;
  if(ss.find(t)!=string::npos){
    cout << "Yes";
  }else{
    cout << "No";
  }
  
}
  
  

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
try:
    from typing import List
except ImportError:
    pass


def solve(x: "List[int]", y: "List[int]"):
    x1, x2 = x
    y1, y2 = y
    x3 = x2 - (y2 - y1)
    y3 = y2 + (x2 - x1)
    x4 = x3 - (y3 - y2)
    y4 = y3 + (x3 - x2)
    print(x3, y3, x4, y4)


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    x = [int()] * (2)  # type: "List[int]"
    y = [int()] * (2)  # type: "List[int]"
    for i in range(2):
        x[i] = int(next(tokens))
        y[i] = int(next(tokens))
    solve(x, y)


if __name__ == '__main__':
    main()


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

using namespace std;

int main()
{
    char str[128];
    
    while (scanf("%s", str) && str[0] != '#'){
        int len = strlen(str);
        reverse(str, str + len);
        int n = 0, ct = -1;
        for (int i = 0; str[i]; i += (str[i] == 'h' ? 5 : 4)){
            if (str[i] == 't') n = n * 2 + 90;
            else {
                n = n * 2 - 90;
                if (i == 0) n = 0;
            }
            ct++;
        }
        int g = __gcd(n, 1 << ct);
        printf("%d", n / g);
        if ((1 << ct) / g != 1) printf("/%d", (1 << ct) / g);
        printf("\n");
    }
    
    return (0);
}

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

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

int N;

int main()
{
	int i, j;

	ll ans=0;
	scanf("%d", &N);
	for(i=1; i<=N; i++)
	{
		ll t=N/i;
		ans+=i*t*(t+1)/2;
	}
	printf("%lld\n", ans);
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  int a[200];
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < n; i++) {
    int key = a[i];
    int j = i - 1;
    while (j >= 0 && a[j] > key) {
      a[j + 1] = a[j];
      j--;
    }
    a[j + 1] = key;
    for (int i = 0; i < n - 1; i++) {
      cout << a[i] << " ";
    }
    cout << a[n - 1] << endl;
  }
  return 0;
}

Measured memory_bytes: 3160
def getN():
    return int(input())

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

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

MOD = 1000000007
n,m = getlist()

broken = [0 for i in range(n+1)]
for i in range(m):
    broken[getN()] = 1

dp = [0 for i in range(n+1)]

dp[0] = 1
if broken[1] == 0:
    dp[1] = 1

for i in range(2,n+1):
    if broken[i] == 0:
        dp[i] = dp[i-1] + dp[i-2]
        dp[i] = dp[i] % MOD

print(dp[n])


Measured memory_bytes: 7832
#include <bits/stdc++.h>
#define Phuong_ ios_base::sync_with_stdio(0); cin.tie(0);

using namespace std;
using ll = long long;


int main()
{
#ifndef RICARDO
    //freopen("input.txt", "r",stdin);
#endif
    Phuong_;
    string s;
    cin >> s;
    s='0' + s;
    int len=s.size() -1;
    int dem=0;
    for(int i=1; i<=(len/2); ++i)
    {
        int j= len -i+1;
        if (s[i]!=s[j]) dem++;
    }
    cout << dem;
    return 0;
}



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

int main(){

  int N, n;
  uint64_t X;
  uint64_t paty[51];
  uint64_t mx=1,mn=1;
  uint64_t ans=0,ans2=0,num;
  paty[0]=1;
  cin >> N >> X;
  n = N;

  for(int i=1; i<=N; i++) mx = 2*mx+3;
  for(int i=1; i<51; i++) paty[i] = paty[i-1]*2+1;
  while(mn!=X&&mx!=X){
    num = (mx+mn)/2;
    if(num==X){
      ans+=paty[--N]+1;
      mn = num;
      break;
    }else if(num<X){
      mn = num;
      ans+=paty[--N]+1;
    }else{
      mx = num;
      ans2+=paty[--N]+1;
    }
    mx--;
    mn++;
  }

  if(mn==X){
    if(mx-mn<2) ans++;
    cout << ans << endl;
  } else {
  if(mx-mn<2) ans2++;
    cout << paty[n]-ans2 << endl;
  }

  return 0;
}


Measured memory_bytes: 256
import sys
from math import factorial, ceil, floor
from bisect import bisect_right as bsr
from operator import itemgetter as ig
from collections import defaultdict as dd
from collections import deque

# お約束
args = None
INF = float("inf")
MOD = int(1e9 + 7)
def input(*ps):
    if type(ps[0]) is list:
        return [input(*ps[0][:-1]) for _ in range(ps[0][-1])]
    elif len(ps) == 1:
        return ps[0](next(args))
    else:
        return [p(next(args)) for p in ps]

from decimal import Decimal

# エントリーポイント
def main():
    M, D = input(int, int)

    cnt = 0
    for m in range(1, M + 1):
        for d in range(1, D + 1):
            if 2 <= d // 10 and 2 <= d % 10 and m == ((d // 10) * (d % 10)):
                cnt += 1
    print(cnt)

if __name__ == '__main__':
    args = iter(sys.stdin.read().split())
    main()


Measured memory_bytes: 5156
#include <iostream>
#include <string>

int main (void){
  int N;
  std::cin >> N;

  std::string S;
  std::cin >> S;

  int K;
  std::cin >> K;

  for(auto i=S.begin(); i!=S.end(); ++i){
    if ( *i != S[K-1] ) std::cout << "*";
    else std::cout << *i ;
  }
  std::cout << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPR(i, n) for(int i=n-1; i>=0; i--)
#define FOR(i, m, n) for(int i=m; i<n; i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(x) ll(x.size()) 
using P = pair<int, int>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 2e9;
const ll LINF = (1LL<<60);

struct UnionFind {
  vector<int> par;
   
  UnionFind(int n) : par(n, -1) { }
  void init(int n) { par.assign(n, -1); }
   
  int root(int x) {
    if (par[x] < 0) return x;
    else return par[x] = root(par[x]);
  }
    
  bool issame(int x, int y) {
    return root(x) == root(y);
  }
    
  bool merge(int x, int y) {
    x = root(x); y = root(y);
    if (x == y) return false;
    if (par[x] > par[y]) swap(x, y); // merge technique
    par[x] += par[y];
    par[y] = x;
    return true;
  }
    
  int size(int x) {
    return -par[root(x)];
  }
};

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n,m; cin >> n >> m;

  UnionFind uf(n);
  REP(i,m){
    int a,b; cin >> a >> b;
    a--, b--;
    uf.merge(a,b);
  }

  int ans = 0;
  REP(i,n) chmax(ans, uf.size(i));
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 3952
// inputに入力データ全体が入る
function Main(input) {
	var ans = 'APPROVED'
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.trim().split("\n");
	s = input[1].split(' ').map((n) => (parseInt(n)))
	for (i = 0; i < s.length; i++) {
		if (s[i] % 2 == 0) {
		    if (s[i] % 3 != 0 && s[i] % 5 != 0) {
				ans = 'DENIED'
					break
				}
			}
	}

	//出力
	console.log(ans)
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
// Main(require('fs').readFileSync('./input.txt', 'utf-8'));

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

int n, k;

int main() {
	while (scanf("%d%d", &n, &k) != EOF) {
		if (k == 1) {
			puts("0");
		} else {
			printf("%d\n", n - k);
		}
	}
	return 0;
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, 1000000009)
	sc.Split(bufio.ScanWords)

	str := oneStr()

	strRune := []rune(str)

	n := len(strRune)

	dp := make([][]int64, n+1)

	dp[0] = []int64{1, 0}

	const mod = 1e9 + 7

	for i := 1; i < n+1; i++ {
		//fmt.Println(i)
		dp[i] = []int64{0, 0}
		switch strRune[i-1] {
		case '0':
			dp[i][0] = dp[i-1][0]
			dp[i][1] = 3 * dp[i-1][1] % mod
		case '1':
			dp[i][0] = 2 * dp[i-1][0] % mod
			dp[i][1] = (3*dp[i-1][1] + dp[i-1][0]) % mod
		}

		//dp[i][0] %= (1e9 + 7)
		//dp[i][1] %= (1e9 + 7)
		//fmt.Printf("%#v\n", dp)
	}

	fmt.Println((dp[n][0] + dp[n][1]) % (1e9 + 7))
}

func oneInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func oneStr() string {
	sc.Scan()
	return sc.Text()
}

func scanNums(len int) (nums []int) {
	for i := 0; i < len; i++ {
		nums = append(nums, oneInt())
	}
	return nums
}

func scanStrings(len int) (strs []string) {
	for i := 0; i < len; i++ {
		strs = append(strs, oneStr())
	}
	return strs
}

func abs(a int) int {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func pow(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

func strSearch(a []string, b string) bool {
	for i := 0; i < len(a); i++ {
		if a[i] == b {
			return true
		}
	}
	return false
}

func sortAsc(a []int) []int {
	sort.Ints(a)
	return a
}

func sortDesc(a []int) []int {
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
	return a
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func lcm(a, b int) int {
	if a == 0 && b == 0 {
		return 0
	}
	return a * b / gcd(a, b)
}

func cumSum(nums []int) []int {
	sums := []int{0}

	for i := 0; i < len(nums); i++ {
		sums = append(sums, sums[i]+nums[i])
	}
	return sums
}


Measured memory_bytes: 5120
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<cmath>
#include<map>
#include<stack>
#include<vector>
#include<queue>
#include<set>
#include<algorithm>
#define INF 0x3f3f3f3f
#define mod 1000000009
#define e  2.718281828459045
#define eps 1.0e18
#define PI acos(-1)
#define lowbit(x) (x&(-x))
#define memset(x,y) memset(x,y,sizeof(x))
#define lson i << 1,l,m
#define rson i << 1 | 1,m + 1,r
#define ll long long
using namespace std;
const int N = 2e5+5; 
ll arr[N]={0},cha[N]={0};
map<int,int> mp;
int main(){
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	//freopen("text1.in","r",stdin);
	//freopen("text1.out","w",stdout);
	int n;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>arr[i];
		mp[arr[i]+i]++;
	}	
	ll cnt=0;
	for(int i=1;i<=n;i++){
		if(mp[i-arr[i]])	cnt+=mp[i-arr[i]];
	}
	cout<<cnt<<endl;
	return 0;
}


Measured memory_bytes: 22052
import sys
import heapq
n, q = map(int, input().split())

queues = {str(i): [] for i in range(n)}

lines = sys.stdin.readlines()
for i in range(q):
    query, *arg = lines[i].split()
    if query == '0':    # insert t x
        heapq.heappush(queues[arg[0]], -int(arg[1]))
    elif query == '1':  # getMax
        if len(queues[arg[0]]):
            print(-queues[arg[0]][0])
    elif query == '2':  # deleteMax
        if len(queues[arg[0]]):
            heapq.heappop(queues[arg[0]])
    else:
        raise AssertionError


Measured memory_bytes: 28928
h,w=map(int,input().split())
if h*w%3==0:
  print(0)
else:
  a=sorted([(h//3)*w,(h-h//3)*(w//2),(h-h//3)*(w//2+w%2)])
  b=sorted([(h//3+1)*w,(h-h//3-1)*(w//2),(h-h//3-1)*(w//2+w%2)])
  c=sorted([(w//3)*h,(w-w//3)*(h//2),(w-w//3)*(h//2+h%2)])
  d=sorted([(w//3+1)*h,(w-w//3-1)*(h//2),(w-w//3-1)*(h//2+h%2)])
  print(min(h,w,abs(a[2]-a[0]),abs(b[2]-b[0]),abs(c[2]-c[0]),abs(d[2]-d[0])))

Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007

int now,n,k;

int main(){
  int ans=0;
  cin >> n ;
  vector<int> a(n);
  REP(i,n) cin>>a[i];

  vector<int> v(3);
  REP(i,n-2){
    v[0]=a[i];
    v[1]=a[i+1];
    v[2]=a[i+2];
    sort(v.begin(), v.end());
    if  (v[1]==a[i+1])ans++;
  } 

  cout<<ans<<endl;
  return 0;
}

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

using namespace std;

#define int long long

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int a, b, k;
    cin >> a >> b >> k;
    int a1 = min(a, k);
    k -= a1;
    a -= a1;
    int b1 = min(b, k);
    k -= b1;
    b -= b1;
    cout << a << " " << b << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
#ifdef __LOCAL
#define debug(x) cerr << __LINE__ << ": " << #x << " = " << x << endl
#define debugArray(x, n)                           \
  cerr << __LINE__ << ": " << #x << " = {";        \
  for (long long hoge = 0; (hoge) < (n); ++(hoge)) \
    cerr << ((hoge) ? "," : "") << x[hoge];        \
  cerr << "}" << endl
#else
#define debug(x) (void(0))
#define debugArray(x, n) (void(0))
#endif

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  long long D;
  cin >> N >> D;
  int ans = 0;
  for (int i = 0; i < N; i++) {
    long long X, Y;
    cin >> X >> Y;
    ans += X * X + Y * Y <= D * D;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3660
#include <iostream>
using namespace std;
int main(){
    int n=0,m=0,sum=1;
    cin>>n>>m;
    for(int i=0;i<n;++i){
       if(sum+m<sum*2){
        sum+=m;
       }
       else{
            sum*=2;
       }
    }
    cout<<sum;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int X;
    
    scanf("%d",&X);
    
    if(X == 3){
        printf("YES");
    }else if(X == 5){
        printf("YES");
    }else if(X == 7){
        printf("YES");
    }else{
        printf("NO");
    }
    
    return 0;
}


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

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <cmath>
#include <cstring>

using namespace std;

inline int main1();
inline int main2();
inline int main3();

int main() {

	main2();

	return 0;
}

inline int main2() {

	int i, j, k;
	int num;
	int a, b;
	long long int max_a, min_b;

	max_a = 0;
	min_b = 1000000000;

	cin >> num;

	for (i = 0; i < num; i++) {
		cin >> a >> b;
		if (max_a < a){
			max_a = a;
			min_b = b;
		}

	}

	cout << max_a + min_b;

}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <set>
#include <array>
#include <stdio.h>
#include <string.h>
using ll = long long;
using ull = unsigned long long;
using namespace std;
#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define ARY_REVERSE(v,a) (reverse((v), (v)+(a)))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
void YesNo(bool b) { cout << (b ? "Yes" : "No"); }
void Yes() { cout << "Yes"; }
void No() { cout << "No"; }
//max_element


signed main()
{
	int a, b, c;
	cin >> a >> b >> c;
	cout << ((a + b + c <= 21) ? "win" : "bust") << endl;
}




Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.InputStreamReader;

/**
 * Built using CHelper plug-in Actual solution is at the top
 */
public class Main {
	public final static double MAX_T = 1000000;
	public final static double MIN_T = 0;
	public static int s = 0;

	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskC solver = new TaskC();
		solver.solve(1, in, out);
		out.close();
	}

	static class TaskC {

		public void solve(int testNumber, InputReader in, PrintWriter out) {
			String s = in.next();
			out.println("ABC" + s);
			
		}

	}

	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}

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

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

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

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

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

	}
}


Measured memory_bytes: 22612
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int ct = 0;
		int A = scan.nextInt();
		int B = scan.nextInt();
		int C = scan.nextInt();
		for(int i = A; i <= A * B; i = i + A) {
			if(i % B == C) {
				ct++;
			}
		}
		if(ct == 0) System.out.println("NO");
		else System.out.println("YES");
		scan.close();
	}
}


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

A, B, AB, an, bn = map(int, input().split())
L = []
L += [AB*max(an, bn)*2]
L += [A*an+B*bn]
if an < bn:
    L += [B*(bn-an) + AB*min(an, bn)*2]
else:
    L += [A*(an-bn) + AB*min(an, bn)*2]
print(min(L))

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;
using ll = long long;
using vi = vector<int>;

#define ALL(a) (a).begin(),(a).end()
#define SORT(c) sort(ALL(c))
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ITER(it,v) for(auto it=v.begin();it!=v.end();++it)
#define IN(v) int v;cin>>v;
#define OUT(v) cout<<v<<"\n"

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  IN(N);

  vi A(N);
  REP(i, N)
    cin >> A[i];

  SORT(A); reverse(ALL(A));

  int edge = -1;
  ITER(it, A) {
    if (it + 1 != A.end() && *it == *(it+1)) {
      if (edge != -1) {
        OUT((ll)edge * (*it));
        return 0;
      }
      edge = *it;
      ++it;
    }
  }
  OUT(0);


  return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a, b;
  cin >> a >> b;
  if(a < b){
    for(int i=0; i<b; i++){
      cout << a;
    }
  }
  else {
    for(int i=0; i<a; i++){
      cout << b;
    }
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, A, B = MAP()
if A > B or N == 1 and A != B:
	print(0)
	exit()
mi = A*(N-1)+B
ma = A+B*(N-1)
print(ma-mi+1)


Measured memory_bytes: 5144
#include <bits/stdc++.h>
//#define DEBUG
#define REP(i, nn ) for(int i = 0 ; i < (int) nn; i++)
#define deb(x) std::cout << #x << " " << x << endl;

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;

template<typename... T>
void read(T& ... a){
    ((cin >> a),...);
}
template<typename... T>
void write(T... a){
    ((cout << a << "\n"),...);
}

void solve(){
    int a, b, c, x, y;
    read(a, b, c, x, y);
    int min_cost = a * x + b * y;
    for(int z = 0; z <= max(x,y) * 2; z++){
        int cost = a * max(x - z /2, 0) + b * max(y - z/2, 0) + c * z;
        if( cost < min_cost){
            min_cost = cost;
        }
    }
    write(min_cost);
} 

int main()
{
    //making data IO Fast
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);
    /****************************/

    #ifdef DEBUG
    int TEST_CASES = 2;
    while(TEST_CASES--){
    #endif // DEBBUG

    solve();

    #ifdef DEBUG
    }
    #endif // DEBUG
    
    return 0;
}

//Thanks to CSES problemset
// I am trained with this kind of problem

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
int n,l,k,ans,a[500];
int main()
{
	scanf("%d%d",&n,&l);
	l--;
	ans=n*(n+1)/2+n*l;
	if(l<0&&abs(l)<=n)
		printf("%d",ans);
	else {
		for(int i=1;i<=n;++i)
			a[i]=i+l;
		if(a[n]<0)
			printf("%d",ans-a[n]);
		else
			printf("%d",ans-a[1]);
	}
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env ruby
def selection(ary)
  n = ary.size
  cnt = 0

  n.times do |i|
    minj = i
    i.upto(n - 1) do |j|
      next if ary[minj] <= ary[j]
      minj = j
    end
    next if minj == i
    ary[i], ary[minj] = ary[minj], ary[i]
    cnt += 1
  end
  puts ary.join(' '), cnt
end

gets
selection(gets.chomp.split.map(&:to_i))

Measured memory_bytes: 8920
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

int main(void){
    ll n;
    cin >> n;

    ll a[n];
    ll sum = 0;
    rep(i, 0, n){
        cin >> a[i];
        sum ^= a[i];
    }

    if(sum == 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 1024
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
//#include <conio.h>
using namespace std;

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

#define rep(i,n)	for(ll i=0;i<(n);i++)
#define SZ(x) ((ll)x.size())
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define F first
#define S second
#define int ll
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const ll MOD = INT_MAX;
const double PI = acos(-1);

void openfile(){
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
}

const int mod = 1e9+7;
int powmod(int n, int expo){
	int sum = 1;
	while(expo){
		if(expo & 1)	sum = sum * n % mod;
		n = n*n % mod;
		expo >>= 1;
	}
	return sum;
}

signed main(){
	IOS
	int n;	cin >> n;
	// ans = 10^n-2*9^n+8^n
	int x = (powmod(10, n)-2*powmod(9, n)+powmod(8, n)+2*mod)%mod;
	cout << x << endl;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> W(N);
  for(int i = 0; i < N; i++) cin >> W.at(i);
  int Sall = 0;
  int S1, S1next;
  int dS, dSnext;
  int mindS;
  for(int i = 0; i < N; i++) Sall += W.at(i);
  for(int i = 0; i < N - 1; i++){
    S1 = 0;
    S1next = 0;
    for(int j = 0; j <= i; j++) S1 += W.at(j);
    for(int j = 0; j <= i + 1; j++) S1next += W.at(j); 
    dS = abs((Sall - S1) - S1);
    dSnext = abs((Sall - S1next) - S1next);
    if(dS < dSnext){
      mindS = dS;
      break;
    }
    else if(i == N - 2) mindS = dSnext;
  }
  cout << mindS << endl;
}


Measured memory_bytes: 256