akhauriyash/Code-Regression huggingface dataset:
from sys import stdin
from fractions import gcd

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

a, b, c, d = (int(x) for x in stdin.readline().rstrip().split())

lcm = lcm(c, d)

total = b - (a - 1)
mc = b // c - (a - 1) // c
md = b // d - (a - 1) // d
mlcm = b // lcm - (a - 1) // lcm

print(total - (mc + md - mlcm))

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

int main() {
	

	
		for(int rows=1;rows<10;rows++){
			
				for(int colm=1;colm<10;colm++){
					cout <<rows <<"x" <<colm<<"="<<rows*colm<<endl;
				}
			}
		
	
	
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  
  for(int i = 0; i < N; i++){
    string S;
    cin >> S;
    
    if(S == "Y"){
      cout << "Four" << endl;
      break;
    }
    else if(i == N-1){
      cout << "Three" << endl;
    }
  }
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**7) #再帰関数の上限,10**5以上の場合python
import math
from copy import copy, deepcopy
from copy import deepcopy as dcp
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque
#deque(l), pop(), append(x), popleft(), appendleft(x)
##listでqueの代用をするとO(N)の計算量がかかってしまうので注意
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate,combinations,permutations#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
#import fractions#古いatcoderコンテストの場合GCDなどはここからimportする
from functools import lru_cache#pypyでもうごく
#@lru_cache(maxsize = None)#maxsizeは保存するデータ数の最大値、2**nが最も高効率
from decimal import Decimal

def input(): 
    x=sys.stdin.readline()
    return x[:-1] if x[-1]=="\n" else x
def printl(li): _=print(*li, sep="\n") if li else None
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def main():
    mod = 1000000007
    #w.sort(key=itemgetter(1),reversed=True)  #二個目の要素で降順並び替え

    #N = int(input())
    N, M = map(int, input().split())
    #A = tuple(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    #S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列

    if N==1 and M==1:
        print(1)
        return
    if N==1 or M==1:
        print(max(N-2,M-2))
        return 
    
    ans=0

    ans+=(N-2)*(M-2)

    print(ans)



if __name__ == "__main__":
    main()

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

int main() {
  int N;
  cin >> N;
  string S;
  cin >> S;
  
  int wcount = 0, rcount = 0;
  for (int i = 0; i < N; i++) {
    if (S[i] == 'R') {
      rcount++;
    } else {
      wcount++;
    }
  }
  
  int count = 0;
  for (int i = 0; i < rcount; i++) {
    if (S[i] == 'R') count++;
  }
  
  cout << rcount - count << endl;
}

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

void read(int &x)
{
    int f=1;x=0;char s=getchar();
    while(s<'0'||s>'9'){if(s=='-')f=-1;s=getchar();}
    while(s>='0'&&s<='9'){x=x*10+s-'0';s=getchar();}
    x*=f;
}

const int N = 2e5;
char a[N+3];

int main()
{
	scanf("%s",a+1); int n = strlen(a+1);
	int tmp = 2,ans = 0;
	for(int i=1; i<=n; i++)
	{
		if(tmp==2) {tmp = 1; ans++;}
		else if(a[i]!=a[i-1]) {tmp = 1; ans++;}
		else if(i<n) {tmp = 2; i++; ans++;}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 384
import java.util.*;
import java.lang.*;
import java.math.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	void run(){
		for(;;){
			String buffer = sc.nextLine();
			
			Scanner in = new Scanner(buffer);
			
			
			int data[] = new int[24];
			
			for(int i = 0; i < 23 && in.hasNextInt() ; i++){
				data[i] = in.nextInt();
			}
			
			if(data[0] == 0){
				break;
			}
			
			int vkv = 0;
			boolean one = false;
			for(int i = 0; data[i] != 0; i++){
				if(data[i] == 1){
					one = true;
				}
				vkv += Math.min(data[i], 10);
			}
			
			if(vkv+10 <= 21){
				if(one){
					vkv += 10;
				}
			}
			if(vkv > 21){
				vkv = 0;
			}
			System.out.println(vkv);
		}
		
	}
	public static void main(String[] args){
		Main m = new Main();
		m.run();
	}
}

Measured memory_bytes: 13000
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
using namespace std;

int main() {

    string s;
    cin >> s;

    long long int ans = 0;

    for ( long long int i = 0; i < s.size() / 2; i++ ) {
        if ( s[i] != s[ s.size() - 1 - i ] ) ans++;
    }

    cout << ans << endl;

    return 0;

}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
# ----------------------------------------------------------------
# Use Solve Function

def solve(lines):
    A,B = map(int, lines.pop(0).split(' '))
    if A >= 13:
        print(B)
    elif A >= 6:
        print(B // 2)
    else:
        print(0)

#
# main
#

# 1. use list instead of stdin

lines = [x.strip() for x in sys.stdin.readlines()]

#
# solve !!
#
solve(lines)

Measured memory_bytes: 3060
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt(), B = sc.nextInt(), C = sc.nextInt();
		if (A+B>C && A<=C){
			System.out.println("YES");
		}else{
			System.out.println("NO");
		}

	}

}


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

int main() {
  int n;cin>>n;
  set <int> a;
	
  for(int i=0;i<n;++i){
	  
    int n;cin>>n;
    bool ch=a.count(n);
    if(ch){
      a.erase(n);	
    }else{
      a.insert(n);
    }
  }
  
  int ans=a.size();
  cout<<ans<<endl;
}

Measured memory_bytes: 4864
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<string, string> P;
const ll MOD = 1000000007LL;
int a[100];
int main() {
	int N, x;
	cin >> N >> x;
	for (int i = 0; i < N; i++) {
		cin >> a[i];
	}
	sort(a, a + N);
	ll s = 0;
	ll ans = 0;
	for (int i = 0; i < N; i++) {
		s += a[i];
		if (i + 1 < N) {
			if (s <= x) {
				ans++;
			}
		}
		else {
			if (s == x) ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author NikuKyabe
 */

#include "bits/stdc++.h"
using namespace std;
#define int long long


class COneQuadrillionAndOneDalmatians {
public:
  constexpr int mpow(const int &a, int n) noexcept  {
    if(n == 0) return 1;
    auto t = mpow(a, n / 2);
    t = t * t;
    if(n & 1) t = t * a;
    return t;
  }
	void solve(std::istream& in, std::ostream& out) {
    int n;
    in >> n;
    n--;
    string ans = "";
    if(n == 0){
      out << "a" << endl;
    }
    else {
      int i = 0;
      while(n >= 0) {
        int t = n % mpow(26, (i + 1));
        char c = 'a' + t /mpow(26, i);
        ans = c + ans;
        n -= mpow(26, (i + 1));
        i++;
      }
      out << ans << endl;
    }
	}
};


signed main() {
  ios::sync_with_stdio(false);
  cout.tie(0);
  cout << fixed;
	COneQuadrillionAndOneDalmatians solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

namespace ABC130
{
	class Program
	{
		static void Main(string[] args)
		{
			int[] vs = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
			int x = vs[0];
			int a = vs[1];
			if (x < a) Console.WriteLine(0);
			else Console.WriteLine(10);
		}
	}
}


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

using namespace std;

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

typedef long long ll;
typedef vector<int> vi;

ll mod = 1e9+7;

ll solve() {
    int n, m, a; cin >> n >> m;
    rep(i, m) {
        cin >> a;
        n -= a;
    }

    return n >= 0 ? n : -1;
}

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

	cout << solve() << endl;
}


Measured memory_bytes: 3572
import java.util.Arrays;
import java.util.Scanner;

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

    int N = scanner.nextInt();
    int[] a = new int[N];
    for (int i = 0; i < N; i++) a[i] = scanner.nextInt();
    Arrays.sort(a);

    boolean check = true;
    for (int i = 0; i < N; i++) {
      if (N % 2 == 0) {
        check = check && a[i] == i / 2 * 2 + 1;
      } else {
        check = check && a[i] == (i + 1) / 2 * 2;
      }
    }
    if (!check) System.out.println(0);
    else System.out.println(modpow(2, N / 2, 1_000_000_007L));
  }

  public static long modpow(long a, long n, long mod) {
    long res = 1;
    while (n > 0) {
      if (n % 2 == 1) res = (res * a) % mod;
      a = (a * a) % mod;
      n >>= 1;
    }
    return res % mod;
  }
}

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

int main(void){
    int N, D; cin >> N >> D;
    vector<vector<int>> X(N, vector<int>(D));
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < D; ++j) cin >> X[i][j];
    }
    int ans = 0;
    for (int i = 0; i < N; ++i) {
        for (int j = i+1; j < N; ++j) {
            int norm = 0;
            for (int k = 0; k < D; ++k) {
                int diff = abs(X[i][k] - X[j][k]);
                norm += diff * diff;
            }
            // check whether norm = k for some k
            bool flag = false;
            for (int k = 0; k <= norm; ++k) {
                if (k * k == norm) flag = true;
            }
            if (flag) ++ans;
        }
    }
    cout << ans << endl;

    return 0;
}

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

int main()
{
	
  long long int n,k;
  cin>>n>>k;
  long long int arr[n];
  for(long long int i=0;i<n;i++)
  {
  	cin>>arr[i];
  }
  sort(arr,arr+n);
  long long int sum=0;
  if(k>=n)
  {
  	sum=0;
  }
  else
  {
	for(long long int i=0;i<n-k;i++)
	{
	  	sum+=arr[i];
	}
  }
  cout<<sum<<endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include "bits/stdc++.h"

using namespace std;
#define print(x) cout<<x<<endl;
#define rep(i, a, b) for(ll i=a;i<b;i++)
#define REP(i, a) for(ll i=0;i<a;i++)
#define jkl ll debug = 0;
#define RREP(i, a) for(ll i=a;i>0;i--)
#define rrep(i, a, b) for(ll i=a-1;i>=b;i--)
#define printall(n, array) {for(ll i=0;i<n;i++){cout<<array[i]<<" ";}cout<<endl;}
#define U() cout<<endl;
#define mp make_pair
typedef long long ll;
typedef pair<ll, ll> Pi;
typedef pair<ll, Pi> V;
typedef vector<ll> VE;
typedef vector<vector<ll>> VVE;
const ll mod = 1e9 + 7; //10^9+7

ll a, b;

// n % 2 == 0のとき n xor (n+1) = 1
ll f(ll n) {
    ll ret = 0;
    switch (n % 4) {
        case 0:
            ret = n;
            break;
        case 1:
            ret = n xor (n - 1);
            break;
        case 2:
            ret = 1 xor n;
            break;
        case 3:
            ret = 0;
            break;
    }
    return ret;
}

int main() {
    cin >> a >> b;
    ll ans = f(a - 1) xor f(b);
    print(ans);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define all(x) (x).begin(),(x).end()


ll combination(ll n, ll r){
    if(n < r) return 0;
    if(r == 0||r == n) return 1;
    else if(r == 1) return n;
    return (combination(n - 1, r - 1) + combination(n - 1, r));
}

bool checkKaibun(string str){
    string checkStr = str;
    reverse(checkStr.begin(), checkStr.end());
    if(str == checkStr) return true;
    else return false;
}

int keta(ll num){
    int digits = 0;
    while(num > 0){
        num /= 10;
        digits++;
    }
    return digits;
}


int main(){//どこかを境目に同じaとbが出てきそう
    ll N;
    cin >> N;
    bool flag = false;
    ll ans = 10000000000;
    for(ll a = 1; a*a <= N; a++){
        if(N % a == 0){
            ll b = N / a;
            if(b < a) flag = true;
            else{
                int tmp = max(keta(a),keta(b));
                if(ans > tmp) ans = tmp;
            }
        }
    if(flag == true) break;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
n = int(input())
S = {"1":1, "2":2, "3":3, "4":4, "5":5, "6":6, 
     "7":7, "8":8, "9":9, "10":10, "11":11, "12":12, "13":13}
H = {"1":1, "2":2, "3":3, "4":4, "5":5, "6":6, 
     "7":7, "8":8, "9":9, "10":10, "11":11, "12":12, "13":13}
C = {"1":1, "2":2, "3":3, "4":4, "5":5, "6":6, 
     "7":7, "8":8, "9":9, "10":10, "11":11, "12":12, "13":13}
D = {"1":1, "2":2, "3":3, "4":4, "5":5, "6":6, 
     "7":7, "8":8, "9":9, "10":10, "11":11, "12":12, "13":13}
for i in range(n):
    pat, num = map(str, input().split(" "))
    if pat == "S":
        for i in range(1, 14):
            if int(num) == i:
                S.pop(num)
    elif pat == "H":
        for i in range(1, 14):
            if int(num) == i:
                H.pop(num)
    elif pat == "C":
        for i in range(1, 14):
            if int(num) == i:
                C.pop(num)
    elif pat == "D":
        for i in range(1, 14):
            if int(num) == i:
                D.pop(num)
for a in S.keys():
    print("S {}".format(S[a]))
for a in H.keys():
    print("H {}".format(H[a]))
for a in C.keys():
    print("C {}".format(C[a]))
for a in D.keys():
    print("D {}".format(D[a]))


Measured memory_bytes: 5620
from heapq import *
f_inf = float('inf')

def dijkstra(start,node,edge):
    #始点sから各頂点への最短距離
    #node:頂点数
    #d:各頂点へのコスト(存在しないときはinf)
    #q:キュー(スタートからのコスト,頂点)
    d = [[f_inf, f_inf, f_inf] for _ in [0]*node]
    d[start][0] = 0
    #スタートをキューに入れる
    q = [(0,start)]

    while(len(q) != 0):
    #キューの先頭を取得
      ci,i = heappop(q)
    #キューの先頭から繋がっている頂点を探索
      for j in edge[i]:
        nc = ci + 1
        if (d[j][nc%3] > nc):
          d[j][nc%3] = nc
          heappush(q,(nc, j))
    return d
#入力
N,M = (int(x) for x in input().split())
#エッジ
E = [[] for _ in [0]*N]

for i in range(M):
  a,b = (int(x) for x in input().split())
  E[a-1].append(b-1)

S,T = (int(x)-1 for x in input().split())
d = dijkstra(S, N, E)
ans = d[T][0]

if ans == f_inf:
  print(-1)
else:
  print(ans//3)

Measured memory_bytes: 39200
#include <iostream>
#include <fstream>
#include <iomanip>

#include <vector>
#include <set>
#include <bitset>
#include <map>
#include <deque>
#include <string>

#include <algorithm>
#include <numeric>
#include <random>

#include <cstdio>
#include <cassert>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>

using namespace std;

#define forn(i, n) for (ll i = 0; i < (ll) (n); ++i)
#define sz(a) static_cast<int>((a).size())
#define endl '\n'

using ll = long long;

const ll INF = static_cast<ll>(1e9) + 7;
const int MAXN = static_cast<int>(1e6) + 17;

int n, k;
int a[MAXN];

bool read() {
    if (!(cin >> n >> k))
        return false;

    forn (i, n)
        cin >> a[i];

    return true;
}

void solve() {
    int j = -1;

    forn (i, n)
        if (a[i] == 1)
            j = i;

    int ans = INF;

    forn (i, n)
        if (i + k <= n && i <= j && j < i + k) {
            int res = 1;
            int pref = i, suff = n - (i + k);
            res += (pref + k - 2) / (k - 1);
            res += (suff + k - 2) / (k - 1);
            ans = min(ans, res);
        }

    cout << ans << endl;
}

int main() {
    cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::mt19937 rand('S' + 'E' + 'R' + 'E' + 'Z' + 'H' + 'K' + 'A');

#ifdef SEREZHKA
    freopen("file.in", "r", stdin);
#endif

    while (read())
        solve();

    return 0;
};



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

int main() {
	string s;
	int a;

	cin >> s;
	a = (int)s.size();

	REP(i,a){
		cout << "x";
	}

	return(0);
}


Measured memory_bytes: 256
N=int(input())
S=input()
ans=S.count("W")
ans1=-10
for i in range(N):
  if S[i]=="W":
    ans-=1
  if i!=0:
    if S[i-1]=="E":
      ans+=1
  ans1=max(ans,ans1)
print(N-1-ans1)

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

int main(){
  int a,b,c,d,count=0;
  cin>>a>>b>>c>>d;
  while(a>0 and c>0){
    if(count%2==0){
      c-=b;
    }
    if(count%2==1){
      a-=d;
    }
    count+=1;
  }
  if(a<=0)cout<<"No";
  else cout<<"Yes";
}

Measured memory_bytes: 3556
from collections import defaultdict
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
AtoZ = [chr(i) for i in range(65,65+26)]
atoz = [chr(i) for i in range(97,97+26)]

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

li = [1]

for i in range(2,33):
	SUM = i
	while SUM <= 1000:
		SUM *= i
		li.append(SUM)

li = list(set(li))
li.sort()

N = int(input())
ind = bisect.bisect_right(li,N)
print(li[ind-1])


Measured memory_bytes: 4204
k, n = map(int, input().split())
a = list(map(int, input().split()))

d_max = 0
for i in range(n):
  if i==n-1:
    dis = a[0] + k - a[i]
  else:
    dis = a[i+1] - a[i]
  if d_max < dis:
    d_max = dis

print(k - d_max)

Measured memory_bytes: 26444
using System;
using System.Collections.Generic;

//namespace _4_C

class Program
{
    static void Main(string[] args)
    {
        while (true)
        {

            //???????????????3????????????????????????????????????
            string readData = Console.ReadLine();

            //???????????¨??????????????????????????????a,b,c???????????????????????????
            string[] readDataValues = readData.Split(' ');
            int a = int.Parse(readDataValues[0]);
            string op = readDataValues[1].ToString();
            int b = int.Parse(readDataValues[2]);


            int c = 0;
            if (op == "?")
            {
                break;
            }
            //???????????????????????£????????????
            if (op == "+")
            {
                c = a + b;
                Console.WriteLine(c);
            }
            else if (op == "-")
            {
                c = a - b;
                Console.WriteLine(c);
            }
            else if (op == "*")
            {
                c = a * +b;
                Console.WriteLine(c);
            }
            else if (op == "/")
            {
                c = a / b;
                Console.WriteLine(c);
            }

        }
    }
}

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

void main() {
    int n; scan(n);
    auto g = readln.split.to!(int[]).reduce!((a, b) => gcd(a, b));

    int[] div;

    for (int i = 1; i*i <= g; i++) {
        if (g % i == 0) {
            div ~= i;
            div ~= g / i;
        }
    }

    div.sort().uniq.each!(d => writeln(d));
}






void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}



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

typedef long long ll;
static const ll MOD = 1e9+7;

int main(){
    ll N,M;
    cin>>N>>M;

    ll dif = abs(N-M);
    ll ans;

    if(dif >= 2){
        ans = 0;
    }

    else if(dif == 0){
        ans = 1;
        ans *= 2;

        for(int i=2; i<=M; i++){
            ans *= i;
            ans %= MOD;
        }

        for(int i=2; i<=N; i++){
            ans *= i;
            ans %= MOD;
        }
    }

    else if(dif == 1){
        ans = 1;
        for(int i=2; i<=M; i++){
            ans *= i;
            ans %= MOD;
        }

        for(int i=2; i<=N; i++){
            ans *= i;
            ans %= MOD;
        }
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 3592
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>
using ll = long long int;
using namespace std;

int main()
{
    int X, Y, ans = 0;
    cin >> X >> Y;
    if (X == 1)
    {
        ans += 300000;
    }
    else if (X == 2)
    {
        ans += 200000;
    }
    else if (X == 3)
    {
        ans += 100000;
    }
    if (Y == 1)
    {
        ans += 300000;
    }
    else if (Y == 2)
    {
        ans += 200000;
    }
    else if (Y == 3)
    {
        ans += 100000;
    }
    if ((X == 1) && (Y == 1))
    {
        ans += 400000;
    }
    cout << ans << endl;

    return 0;
}

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



int main(){
    int n,k;
    cin >> n >> k;
    vector<int> v(n);
    for(int i=0;i<n;i++){
        cin >> v[i];    
    }
    sort(v.begin(),v.end());
    int mi = 1000000000;
    for(int i=0;i<n-k+1;i++){
        mi = min(mi,v[i+k-1]-v[i]);
    }
    cout << mi << endl;
    return 0;
}

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

#define ull unsigned long long
#define ll long long
#define imei(...)   "[ "<< #__VA_ARGS__ <<" = "<< __VA_ARGS__ <<" ] "

using namespace std;

void solve(int t) {
    int n;
    cin >> n;
}

int main(int argc, char *argv[])
{
    int n, k, l = 1, r = 1;
    vector<int> a;

    cin >> n >> k;
    a.resize(n);

    for (int i = 0; i < n; i++) {
        cin >> a[i];
        r = max(r, a[i]);
    }

    while(l <= r) {
        int m = l + (r-l)/2;
        int need = 0;

        for (int &v : a)
            need += (v-1)/m;

        if (need > k)
            l = m + 1;
        else
            r = m - 1;

    }
    cout << l << endl;
    return 0;
}


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

#define REP(i,n) for(int i=0;i<(n);i++)
#define REAP(i,a,n) for(int i=(a);i<(n);i++)
#define YES cout<<"Yes"<<endl
#define NO cout<<"No"<<endl
#define fr first
#define sc second
#define pb push_back
#define All(v) v.begin(),v.end()
typedef long long ll;

#define N 100000
int table[N+1];

int main(){
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int l,r;
    REP(i,n){
        cin >> l >> r;
        table[l-1]++;
        table[r]--;
    }

    int sum=0,a=0;
    REP(i,N){
        a+=table[i];
        sum+=a;
    }
    cout << sum << endl;
}


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

int main()
{
  int N, L;
  int res =0;
  cin >> N >> L;

  for(int i=1;i<=N;i++){
    res += L + i-1;
  }

  if(L>=0){ // all positive
    res -= L;
  }
  else if(L+N-1<0){ // all negative
    res -= L + N -1;
  }
  else{
    // none
  }
  cout << res << endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		int[] a = new int[n];

		String s = br.readLine();
		String[] str = s.split(" ");
		for (int i=0; i<n; i++) {
			a[i] = Integer.parseInt(str[i]);
		}

		int p = partition(a,0,n-1);

		StringBuilder sb = new StringBuilder();
		for (int i=0; i<n-1; i++) {
			if(i != p){
				sb.append(a[i]).append(" ");
			}else {
				sb.append("[").append(a[i]).append("] ");
			}
		}
		if (n-1 != p) {
			System.out.println(sb.append(a[n-1]));
		}else {
			System.out.println(sb.append("[").append(a[n-1]).append("]"));
		}

		br.close();
	}

	static int partition(int[] a,int p,int r) {
		int x = a[r];
		int i = p-1;
		for (int j=p; j<r; j++) {
			if (a[j] <= x) {
				i = i+1;
				swap(a,i,j);
			}
		}
		swap(a,i+1,r);
		return i+1;
	}

    static void swap(int[] a,int idx1,int idx2){
        int temp = a[idx1];
        a[idx1] = a[idx2];
        a[idx2] = temp;
    }

}

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

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
            var x = long.Parse(Console.ReadLine());

            var fiveHundred = x / 500;
            var five = (x - 500 * fiveHundred) / 5;

            Console.WriteLine(fiveHundred * 1000 + five * 5);
		}
	}
}


Measured memory_bytes: 13140
import java.util.HashMap;
import java.util.Scanner;

public class Main {

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

		int n = sc.nextInt();
		long k = sc.nextLong();

		HashMap<Integer, Long> map = new HashMap<Integer, Long>();
		for(int i = 0; i < n; i++){
			int a = sc.nextInt();
			int b = sc.nextInt();

			if(!map.containsKey(a)){
				map.put(a, (long)b);
			}
			else {
				map.put(a, map.get(a) + b);
			}
		}

		for(int i = 1; i <= 100000; i++){
			if(!map.containsKey(i)){
				continue;
			}
			k -= map.get(i);

			if(k <= 0){
				System.out.println(i);
				break;
			}
		}
	}
}


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

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n; cin >> n;
	vector<int> v(n);
	for(auto &x:v) cin >> x;
	int cnt = 0;
	for(int i=0;i<n;i++) if(i+1 != v[i]) cnt++;
	if(cnt > 2) puts("NO");
	else puts("YES");
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

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




int main() {
    ll n;
    cin >> n;
    vector<pair<ll, ll>> v(n);
    ll mn1 = INF, mx1 = 0, mn2 = INF, mx2 = 0;
    REP(i, n){
        ll x, y;
        cin >> x >> y;
        if(x > y) swap(x, y);
        mn1 = min(mn1, x);
        mx1 = max(mx1, x);
        mn2 = min(mn2, y);
        mx2 = max(mx2, y);
        v[i] = {x, y};
    }
    
    ll ans = (mx1 - mn1) * (mx2 - mn2);
    
    sort(v.begin(), v.end());
    
    ll mx3 = 0, mn3 = INF, mx4 = max(mx1, mx2), mn4 = min(mn1, mn2);
    ll t = INF;
    mx3 = v[n - 1].first;
    REP(i, n - 1){
        t = min(t, v[i].second);
        mx3 = max(mx3, v[i].second);
        mn3 = min(v[i + 1].first, t);
        ans = min(ans, (mx4 - mn4) * (mx3 - mn3));
    }
    cout << ans << endl;
}

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

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

    int RH = H - B;
    int RW = W - A;

    for ( int b = 0; b < B; b++) {
        for(int i = 0; i < W;i++){
            if (i < A){
                cout << 0;
            } else {
                cout << 1;
            }
        }
        cout << endl;
    }
    for ( int b = 0; b < RH; b++) {
        for(int i = 0; i < W;i++){
            if (i < A){
                cout << 1;
            } else {
                cout << 0;
            }
        }
        cout << endl;
    }
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define REP(i, N) for (int i = 0; i < (N); ++i)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define PB push_back
#define MP make_pair
using namespace std;
typedef long long ll;
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll div_ceil(ll, ll);

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

int main() {
  double W, H, x, y;
  std::cin >> W >> H >> x >> y;
  std::cout << W * H / 2 << ' ';
  std::cout << (x == W / 2 && y == H / 2) << '\n';
}

ll div_ceil(ll a, ll b) {
  ll quotient = a / b;
  ll remainder = a % b;
  if (remainder == 0) {
    return quotient;
  } else {
    return quotient + 1;
  }
}


Measured memory_bytes: 384
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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; }

void see(vector<vector<int>> &a){
	rep(i,a.size()){
		rep(j,a[i].size()) cout << a[i][j] << " ";
		cout << endl;
	}
	cout << endl;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int h, w, k;
	cin >> h >> w >> k;
	vector<vector<int>> ori(h, vector<int>(w, 0));
	rep(i,h)rep(j,w){
		char c;
		cin >> c;
		ori[i][j] = c - '0';
	}
	int ans = 0;
	rep(I,h)rep(J,w){
		vector<vector<int>> a = ori;
		int score = 0;
		a[I][J] = 0;
		for(int i = I; i > 0; i--){
			a[i][J] = a[i-1][J];
			a[i-1][J] = 0;
		}
		int two = 1;
		bool changed = true;
		while(changed){
			//see(a);
			changed = false;
			rep(i,h){
				vector<bool> used(w, false);
				rep(j,w-k+1){
					if(a[i][j] == 0) continue;
					bool same = true;
					rep(l,k-1){
						if(a[i][j+l] != a[i][j+l+1]) same = false;
					}
					if(same){
						rep(l,k) used[j+l] = true;
					}
				}
				rep(j,w){
					if(used[j]){
						score += two * a[i][j];
						a[i][j] = 0;
						changed = true;
					}
				}
			}
			rep(j,w){
				for(int i = h-1; i > 0; i--){
					if(a[i][j] == 0){
						int cur = i-1;
						while(cur > 0 && a[cur][j] == 0) cur--;
						a[i][j] = a[cur][j];
						a[cur][j] = 0;
					}
				}
			}
			two *= 2;
		}
		chmax(ans, score);
	}
	cout << ans << endl;
	return 0;
}

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

typedef pair<pint,pint> ppi;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};
pint ss[2001];
int s[31][31],c[4];
int d[1001][4];
int INF=1000100010;
int n,w,h;
int dijkstra(){
    priority_queue<ppi,vector<ppi>,greater<ppi> > pq;
    rep(i,n)rep(j,4) d[i][j]=INF;
    d[w+1][0]=0;
    pq.push({{0,0},{0,1}});
    while(!pq.empty()){
        ppi pi=pq.top();pq.pop();
        int cost=pi.first.first,dr=pi.first.second;
        int x=pi.second.first,y=pi.second.second;
        int tx=x+dx[dr],ty=y+dy[dr];
        if(tx>0&&tx<=w&&ty>0&&ty<=h){
            if(ty==h&&tx==w) return cost;
            rep(i,4){
                if(i==s[ty][tx]){
                    int tt=0;
                    if(d[tx+ty*(w+1)][(dr+i)%4]>cost+tt){
                        d[tx+ty*(w+1)][(dr+i)%4]=cost+tt;
                        pq.push({{cost+tt,(dr+i)%4},{tx,ty}});
                    }
                }
                else{
                    int tt=c[i];
                    if(d[tx+ty*(w+1)][(dr+i)%4]>cost+tt){
                        d[tx+ty*(w+1)][(dr+i)%4]=cost+tt;
                        pq.push({{cost+tt,(dr+i)%4},{tx,ty}});
                    }
                }
            }
        }
    }
    return -1;
}
int main(){
    while(cin>>w>>h,w|h){
        n=(w+1)*(h+1);
        rep(i,h)rep(j,w){
            cin>>s[i+1][j+1];
        }
        rep(i,4) cin>>c[i];
        cout<<dijkstra()<<endl;
    }
    return 0;
}


Measured memory_bytes: 3152
object Main {
  def main(args:Array[String]) = {
   // val seq = readLine.split("")
    val input=io.Source.stdin.getLines().mkString("\n")
    println(solve(input).trim())
  }

def solve(aaa:String): String={
  val seq = aaa.split(" ").map(_ .toInt)
  val ret = if(seq(0) <= 5){
  	"0"
  } else if (seq(0) <= 12 ){
  	(seq(1)/2).toString
  }else{
  seq(1).toString
  }
  ret
}
}


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

#define INF 1000000007
#define mem(dp,a) memset(dp,a,sizeof dp)
#define flash ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
#define f(i,n) for (ll i=0;i<n;i++)
#define sieve(j,mp) for(ll j=2*i ; j<=mp ; j+=i)
#define pb(x) push_back(x)
#define mp(x,y) push_back(make_pair(x,y))
#define tr(c,it) for(((c).begin())it=(c).begin();it!=(c).end();it++)
#define test ll t=1; while(t--)
#define F first
#define S second
main()
{
    flash
    clock_t launch=clock();
    test
    {
        int n,w;
        cin>>n>>w;
        ll dp[n+1][w+1],wt[n+1],vl[n+1];
        rep(i,1,n+1)cin>>wt[i]>>vl[i];
        mem(dp,0);
        rep(i,1,n+1) rep(j,1,w+1)
        if(wt[i]<=w&&j-wt[i]>=0) dp[i][j]=max(dp[i-1][j],dp[i-1][j-wt[i]]+vl[i]);
        else dp[i][j]=dp[i-1][j];
        cout<<dp[n][w]<<endl;
    }
    clog<<((long double)(clock()-launch)/CLOCKS_PER_SEC)<<"\n";
    return 0;
}



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

using namespace std;

struct item
{
	int weight;
	int value;
};

int main()
{
	ios_base::sync_with_stdio(NULL); cin.tie(NULL); cout.tie(NULL);
  
	int n, w; cin >> n >> w;
	vector<item> items(n);
	for (int i = 0; i < n; ++i) {
		cin >> items[i].weight >> items[i].value;
	}
	vector<vector<int>> dp(n, vector<int>(100001, -1));
	if (items[0].weight <= w) {
		dp[0][items[0].value] = w - items[0].weight;
	}
	dp[0][0] = w;
	for (int i = 1; i < n; ++i) {
		for (int j = 0; j <= 100000; ++j) {
			if (j >= items[i].value) {
				dp[i][j] = max(dp[i - 1][j - items[i].value] - items[i].weight, dp[i - 1][j]);
			} else {
				dp[i][j] = dp[i - 1][j];
			}
		}
	}
	for (int i = 100000; i >= 0; --i) {
		if (dp[n - 1][i] >= 0) {
			cout << i << endl;
			break;
		}
	}
}

Measured memory_bytes: 39936
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));

console.log(main());
function main(){
  var n = o.a();
  var m = o.a();
  var a = [];
  var b = [];
  var c = Array(n+m-1).fill(9e9);
  for(var i = 0; i < n+m-1; i++){
    var t = o.l().map(a=>a-1);
    if(a[t[1]])a[t[1]].push(t[0]);
    else a[t[1]] = [t[0]];
    if(b[t[0]])b[t[0]].push(t[1]);
    else b[t[0]] = [t[1]];
  }
  var ans = [];
  for(i=0;;i++){
    if(!a[i]){
      var q = b[i];
      ans[i] = 0;
      c[i] = 0;
      break;
    }
  }
  var l = 1, d = 1;
  while(l < n){
    var x = [];
    for(i = 0; i < q.length; i++){
      var y = q[i], f = 1;
      for(var j = 0; j < a[y].length; j++){
        if(c[a[y][j]] >= d){f=0; break;}
        if(c[a[y][j]] === d-1)ans[y] = a[y][j] + 1;
      }
      if(f){c[y] = d; l++; if(b[y])x = x.concat(b[y]);}
    }
    q = x;
    d++;
  }
  return ans.join("\n");
}

Measured memory_bytes: 73464
n = int(input())
s = list(map(int,input().split()))
dp = [[0 for _ in range(n)] for _ in range(n)]
for i in range(n):
    if n%2 ==0:
        dp[i][i]=-s[i]
        turn =0
    else:
        dp[i][i]=s[i]
        turn = 1
def findMax(i,j):
    dp[i][j] = max(dp[i+1][j]+s[i],dp[i][j-1]+s[j])
def findMin(i,j):
    dp[i][j]= min(dp[i+1][j]-s[i],dp[i][j-1]-s[j])
for length in range(2,n+1):
    for j in range(n-length+1):
        if not turn:
            findMax(j,j+length-1)
        else:
            findMin(j,j+length-1)
    turn^=1

print(dp[0][n-1])



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

int main(){
    int n;
    cin>>n;
    vector<int>a(n),b(n);
    vector<tuple<int,int,int>>t(n);
    rep(i,n){
        cin>>a[i]>>b[i];
        t[i]=make_tuple(a[i]+b[i],a[i],b[i]);
    }
    ll ans=0;
    sort(t.rbegin(),t.rend());
    rep(i,n){
        if(i%2==0)ans+=get<1>(t[i]);
        else ans-=get<2>(t[i]);
    }
    cout<<ans<<endl;
    return 0;
}

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

int main() {
	double a, b, c, d, e, f, g, h;
	while (cin >> a >> b >> c >> d >> e >> f >> g >> h) {
		if (g < a || h < b || c < e || d < f)cout << "NO" << endl;
		else cout << "YES" << endl;
	}
	return 0;
}

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

int main(){
    int n; cin>>n;
    int c[510],s[510],f[510];
    for(int i=1;i<=n-1;i++){
        cin>>c[i]>>s[i]>>f[i];
    }
    for(int i=1;i<=n-1;i++){
        int t=0;
        for(int j=i;j<=n-1;j++){
            if(t<s[j])t=s[j];
            else t=(t+f[j]-1)/f[j]*f[j];
            t+=c[j];
        }
        cout<<t<<endl;
    }
    cout<<0<<endl;
}


Measured memory_bytes: 256
/// Kazuki Hoshino
/// Lost July

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;
typedef vector<pi> vpi;
#define inf 1000000000
#define mod 1000000007
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define rep1(i, a, b) for(int i =a; i >=b; i--)
#define f first
#define ss second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple

ld n, m,d;
int cnt;

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

//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);

cin >> n >> m >> d;
ld temp = (n-d)*(m-1);
cout << fixed << setprecision(12);
if(d==0)
    cout << temp/(n*n) << endl;
else
cout << (temp*2)/(n*n) << endl;




return 0;}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#define debug(x) cout << #x << " = " << x << endl
#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); i > -1; i--)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const double EPS = 1e-9;

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

  string o,e;
  cin>>o>>e;
  rep(i, e.size()) {
    cout << o[i] << e[i];
  }
  if(o.size() > e.size()) {
    cout << o[o.size() - 1] << endl;
  } else {
    cout << endl;
  }
    

  return 0;
}


Measured memory_bytes: 256
/* {{{ Definitions */
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <ios>
#include <utility>
#ifdef _WIN32
#include "debug.hpp"
#endif
using namespace std;

#define rep(i, N)  for(int i = 0; i < (N); i++)
#define reps(i, N) for(int i = 1; i <= (N); i++)
#define repr(i, N) for(int i = (N) - 1; i >= 0; i--)
#define pub push_back

template<typename T> 
void chmax(T &a, T b){ a = max(a, b); };
template<typename T> 
void chmin(T &a, T b){ a = min(a, b); };

typedef long long ll;
typedef pair<int, int> P;
const int INF = 100000000;
const ll LINF = 10000000000000000;
const int MOD = 1000000007;
/* }}}------------------------------------------- */
int H, W, h, w;
void solve(){
	cout << (H - h) * (W - w) << endl;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> H >> W >> h >> w;
	solve();
	return 0;
}


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

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
typedef vector<vector<vector<vector<int>>>> vvvvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
typedef vector<vector<vector<vector<ll>>>> vvvvl;
typedef vector<pair<int, int>> vpii;
typedef pair<int, int> pii;

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

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

# A - Two Integers
x, y = map(int, input().split())

if x % y == 0:
	print(-1)
else:
	i = 2
	
	while True:
		if (x * i) % y != 0:
			print(x * i)
			break
		else:
			i += 1

Measured memory_bytes: 2940
#include <stdio.h>
#include <algorithm>

using namespace std;

int main() {
  int x[2], y[2];
  for (int i = 0; i < 2; i++) {
    scanf("%d %d", x+i, y+i);
  }

  int x_diff = x[1] - x[0];
  int y_diff = y[1] - y[0];

  printf("%d %d %d %d\n", x[1] - y_diff, y[1] + x_diff, x[0] - y_diff, y[0] + x_diff);

  return 0;
}


Measured memory_bytes: 128
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>

#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 62;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll conbinationMemo[100][100];

ll cmemoInit(){
    rep(i, 100){
        rep(j, 100){
            conbinationMemo[i][j] = -1;
        }
    }
}
 
ll nCr(ll n, ll r){
    if(conbinationMemo[n][r] != -1) return conbinationMemo[n][r];
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return conbinationMemo[n][r] = (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------
int main(void){
    int n;
    cin >> n;
    vector<int> p(n);
    rep(i, n) cin >> p[i];

    vector<int> pos(n + 1);

    rep(i, n){
        pos[p[i]] = i + 1;
    }

    multiset<int> st;
    st.insert(pos[n]);
    st.insert(n + 1);
    st.insert(n + 1);
    st.insert(0);
    st.insert(0);
    ll ans = 0;
    for(int i = n - 1; i >= 1; i--){
        int nowidx = pos[i];
        auto itr = st.lower_bound(nowidx);
        auto a = itr;
        auto a2 = ++itr;
        itr = st.lower_bound(nowidx);
        auto b = --itr;
        auto b2 = --itr;
        //cout << i << endl;
        //cout << *b2 << " " << *b << " " << nowidx << " " << *a << " " << *a2 << endl;
        ll tmp = (*a - nowidx) * (*b - *b2);
        tmp += (nowidx - *b) * (*a2 - *a);
        ans += tmp * i;
        st.insert(nowidx);
    }

    cout << ans << endl;
}

Measured memory_bytes: 5760
from operator import itemgetter
import sys
input = sys.stdin.readline

N, M = map(int,input().split()) # 複数の数字を変数に格納
List = [list(map(int,input().split())) for i in range(N)] # [[1,2],[3,4],[5,6]]

List.sort(key=itemgetter(0))
List_S = [0]
 
result = 0
p = 0

for i in range(1, M+1):
    add = 0
    add_list = []
    while p < N and List[p][0] == i:
        if List_S[len(List_S)-1] < List[p][1]:            
            List_S.append(List[p][1])
        else:
            add_list.append(List[p][1])
            add += 1
        p += 1
            
    if len(List_S) != 1:
        result += List_S.pop()
        if add > 0:
            List_S.extend(add_list)
            List_S.sort()
 
print(result)

Measured memory_bytes: 28992
#include<cstdio>
#include<iostream>
#include<sstream>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<list>
#include<vector>
#include<stack>
#include<queue>
#include<string>
#include<iomanip>
#include<fstream>
#include<ctime>
using namespace std;
typedef vector<int> VI;
typedef pair <int,int> ii;
typedef long long LL;
#define pb push_back
const int INF = 2147483647;
const int N = 200005;

int h, w, n, a, b, i, co, res;
set<ii> s;
vector<int> wek[N];

int main() {
scanf("%d %d %d", &h, &w, &n);
for (i=1;i<=w;i++) {
	wek[i].clear();
	wek[i].pb(h + 1);
}
s.clear();
while (n--) {
	scanf("%d %d", &a, &b);
	wek[b].pb(a);
	s.insert(ii(a, b));
}
for (i=1;i<=w;i++) {
	sort(wek[i].begin(), wek[i].end());
	reverse(wek[i].begin(), wek[i].end());
}
res = INF;
a = b = 1;
co = 0;
while (a <= h && b <= w) {
	while (wek[b].back() < a) wek[b].pop_back();
	//printf("%d %d %d\n", a, b, wek[b].back());
	res = min(res, co + wek[b].back() - a);
	if (s.find(ii(a + 1, b)) != s.end()) break;
	a++;
	co++;
	if (s.find(ii(a, b + 1)) == s.end()) b++;
}
printf("%d\n", res);
return 0;
}



Measured memory_bytes: 20992
# 高速版input
import sys
input = sys.stdin.readline

n, q = (int(i) for i in input().split())
s = input()

mem = [0]
count = 0
for i in range(1, len(s)):
    if s[i-1]+s[i] == "AC":
        count +=1
    mem.append(count)
    
for x in [[int(i)-1 for i in input().split()] for i in range(q)]:
    res = mem[x[1]] - mem[x[0]]
    print(res)


Measured memory_bytes: 24448
#include <iostream>

int main(void){
	int N;
	std::cin >> N;
	int s[N];
	int i;
	int ans = 0;
	int min = -1;
	for(i=0;i<N;i++){
		std::cin >> s[i];
		ans += s[i];
		if(s[i]%10 !=0){
			if(min == -1)min = s[i];
			else min = std::min(min,s[i]);
		}
	}
	if(ans%10 != 0){
	}else{
		ans -= min;
		if(min == -1)ans = 0;
	}
	std::cout << ans;
	return 0;
}
	

Measured memory_bytes: 256
import java.math.BigDecimal;
import java.util.*;

public class Main {
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String w = sc.next();
       
        String res = "Yes";
        for (int i=0; i<w.length(); i++){
            int count = 0;
            for (int j=0; j<w.length(); j++){
                if (w.charAt(j) == w.charAt(i)){
                    count++;
                }
            }
            if (!(count%2 == 0)){
                res = "No";
                break;
            }
        }
        System.out.println(res);
    }
}

Measured memory_bytes: 21716