akhauriyash/Code-Regression huggingface dataset:
/*
 *  author : Atul Anand   
 *  created on : Thu Apr 02 2020
 */

import java.io.*;
import java.util.*;

public class Main{

    public static void main(String[] args) throws IOException {
        String S = in.next();
        int a = Integer.parseInt(S.substring(0, 2));
        int b = Integer.parseInt(S.substring(2));

        if(a >= 0 && a <= 99 && b >= 1 && b <= 12){
            if(a >= 1 && a <= 12 && b >= 0 && b <= 99){
                println("AMBIGUOUS");
            }
            else{
                println("YYMM");
            }
        }
        else if(a >= 1 && a <= 12 && b >= 0 && b <= 99){
            println("MMYY");
        }
        else{
            println("NA");
        }
        
        in.close();
        out.close();
    }

    static int MIN = Integer.MIN_VALUE;
    static int MAX = Integer.MAX_VALUE;
    static Reader in = new Reader();
    static PrintWriter out = new PrintWriter(System.out);

    static void read(int arr[], int N) throws IOException { 
    	for(int i = 0; i < N; i++){ 
    		arr[i] = in.nextInt(); 
    	} 
    }
    
    static void read(long arr[], int N) throws IOException { 
    	for(int i = 0; i < N; i++){ 
    		arr[i] = in.nextLong(); 
    	} 
    }
    
    static void read(String arr[], int N) throws IOException { 
    	for(int i = 0; i < N; i++){ 
    		arr[i] = in.next(); 
    	} 
    }
    
    static void print(Object O) {  
    	out.print(O); 
    }
    
    static void println(Object O) { 
    	out.println(O); 
    }
    
    static void println(int arr[]) { 
    	for(int i = 0; i < arr.length; i++){ 
    		print(arr[i]+" "); 
    	} 
    	println(""); 
    }

    static void println(int arr[][]) { 
    	for(int i = 0; i < arr.length; i++){ 
    		println(arr[i]); 
    	}
    }
    
    static void debug(Object O) { 
    	System.out.println(O); 
    }
}

class Reader {
    BufferedReader reader;
    StringTokenizer tokenizer;

    Reader() {
        reader = new BufferedReader(new InputStreamReader(System.in));
        tokenizer = new StringTokenizer("");
    }

    String next() throws IOException {
        while (!tokenizer.hasMoreTokens() ) { 
            tokenizer = new StringTokenizer(reader.readLine()); 
        }
        return tokenizer.nextToken();
    }

    int nextInt() throws IOException { 
        return Integer.parseInt(next()); 
    }
    
    double nextDouble() throws IOException { 
        return Double.parseDouble(next());
    }
    
    long nextLong() throws IOException { 
        return Long.parseLong(next()); 
    }
    
    String nextLine() throws IOException { 
        return reader.readLine(); 
    }
    
    void close() throws IOException { 
        reader.close(); 
    }
}

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

int main(){
	int N;
  cin>>N;
  int a,b,c,d,e,f,g,h,i,j;
  a=N/1000000000;
  b=N/100000000-10*a;
  c=N/10000000-100*a-10*b;
  d=N/1000000-1000*a-100*b-10*c;
  e=N/100000-10000*a-1000*b-100*c-10*d;
  f=N/10000-100000*a-10000*b-1000*c-100*d-10*e;
  g=N/1000-1000000*a-100000*b-10000*c-1000*d-100*e-10*f;
  h=N/100-10000000*a-1000000*b-100000*c-10000*d-1000*e-100*f-10*g;
  i=N/10-100000000*a-10000000*b-1000000*c-100000*d-10000*e-1000*f-100*g-10*h;
  j=N-1000000000*a-100000000*b-10000000*c-1000000*d-100000*e-10000*f-1000*g-100*h-10*i;
  int sum=a+b+c+d+e+f+g+h+i+j;
 
  if(N%sum==0)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long l,t,n,s,c;
inline long long read()
{
    long long sum=0,x=1;
    char ch=getchar();
    while (ch<'0'||ch>'9')
	{
        if (ch=='-')
          x=-1;
        ch=getchar();
    }
    while (ch>='0'&&ch<='9')
	{
        sum=sum*10+ch-'0';
        ch=getchar();
    }
    return sum*x;
}
inline void write(long long x)    
{
    if (x<0)
    {
    	putchar('-');
    	x=-x;
	}
	if (x>9)
      write(x/10);
    putchar(x%10+'0');
}
int main()
{
    l=read();
    t=l;
	while (t)
	{
		++n;
		t/=2;
	}
    s=__builtin_popcount(l)-1;
    write(n);putchar(' ');
	write(2*(n-1)+s);putchar('\n');
    c=1<<(n-1);
    for (register int i=n-2;i>=0;--i)
	{
        write(i+1);putchar(' ');
		write(i+2);putchar(' ');
		write(1<<i);putchar('\n');
        write(i+1);putchar(' ');
		write(i+2);putchar(' ');
		write(0);putchar('\n');
        if ((1<<i)&l)
		{
            write(i+1);putchar(' ');
			write(n);putchar(' ');
			write(c);putchar('\n');
            c+=1<<i;
        }
    }
    return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
typedef long long   signed int LL;
typedef long long unsigned int LU;
#define incID(i, l, r) for(LL i = (l)    ; i <  (r); ++i)
#define incII(i, l, r) for(LL i = (l)    ; i <= (r); ++i)
#define decID(i, l, r) for(LL i = (r) - 1; i >= (l); --i)
#define decII(i, l, r) for(LL i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
template<typename T> bool setmin  (T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmax  (T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
LL mo(LL a, LL b) { assert(b > 0); a %= b; if(a < 0) { a += b; } return a; }
LL fl(LL a, LL b) { assert(b > 0); return (a > 0 ? a / b : (a - b + 1) / b); }
LL ce(LL a, LL b) { assert(b > 0); return (a < 0 ? a / b : (a + b - 1) / b); }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
#define bit(b, i) (((b) >> (i)) & 1)
#define BC __builtin_popcountll
#define SC static_cast
#define SI(v) SC<int>(v.size())
#define SL(v) SC<LL >(v.size())
#define RF(e, v) for(auto & e: v)
#define ef else if
#define UR assert(false)

// ---- ----

string s, t;
set<int> se[26];
int INF = 1e6;

int main() {
	cin >> s >> t;
	
	inc(i, SI(s)) { se[s[i] - 'a'].insert(i + 1); }
	inc(i, SI(t)) { if(se[t[i] - 'a'].empty()) { cout << -1 << endl; return 0; } }
	
	inc(i, 26) { se[i].insert(INF); }
	
	int x = 0, y = 0;
	inc(i, SI(t)) {
		y = * se[t[i] - 'a'].upper_bound(y);
		if(y == INF) { x++; y = 0; i--; }
	}
	
	cout << SL(s) * x + y << endl;
	
	return 0;
}


Measured memory_bytes: 5120
#include <iostream>
using namespace std;
int main()
{
    int x,y;
  cin>>x>>y;
  if(((y>=(2*x))&&(y<=(4*x)))&&(y%2==0))
     {cout<<"Yes"<<endl;}
    else
     {cout<<"No"<<endl;}
   return 0; 
}

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

int main(void){
	int i,n,x[104],search;
	int l,r,c;
	int count;

	while(cin>>n && n){
		for(i=0;i<n;i++) cin>>x[i];
		cin>>search;

		for(count=l=0,r=n-1,c=(l+r)/2;l<=r;c=(l+r)/2,count++){
			if(search < x[c]) r = c - 1;
			else if(search > x[c]) l = c + 1;
			else{count++; break;}
		}
		cout<<count<<endl;
	}

	return 0;
}

Measured memory_bytes: 0
"""
B - Digital Gifts
"""


def solve():
    N = int(input())
    sum_ochotama = 0
    for n in range(N):
        x, u = input().split()
        x = float(x)
        sum_ochotama += x if u == 'JPY' else x * 380000
    print(sum_ochotama)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 2940
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <list>

using namespace std;

typedef pair<long long int, long long int> P;

long long int INF = 1e18;
long long int MOD = 1e9 + 7;

long long int DP[1100000] = {};

int main(){
	
	DP[1] = 2;
	
	for(int loop = 2; loop <= 1000000; loop++){
		int n = loop;
		int dum = n;
		
		vector<int> v;
		
		for(int i = 2; i * i <= dum; i++){
			if(dum % i == 0){
				v.push_back(i);
			}
			while(dum % i == 0){
				dum /= i;
			}
		}
		if(dum != 1){
			v.push_back(dum);
		}
		
		int num = v.size();
		long long int ans = 0;
		
		for(int i = 1; i < (1 << num); i++){
			int hoge = i;
			int ret = 1;
			int cnt = 0;
			for(int j = 0; j < num; j++){
				if(hoge % 2 == 1){
					ret *= v[j];
					cnt++;
				}
				hoge /= 2;
			}
			if(cnt % 2 == 1){
				ans += n / ret;
			}else{
				ans -= n / ret;
			}
		}
		DP[n] = n - ans + DP[n - 1];
	}
	
	int t;
	cin >> t;
	
	for(int i = 0; i < t; i++){
		int n;
		cin >> n;
		cout << DP[n] << endl;
	}
	
	return 0;
}



Measured memory_bytes: 10928
'use strict'

function Main(input){
    let temp = input.trim().split('\n');
    let temp2 = temp[0].split(' ').map((v)=>parseInt(v));
    let n = temp2.shift();
    let k = temp2.shift();
    let s = temp[1];

    let ans = s.slice(0,k-1) + s[k-1].toLowerCase() + s.slice(k);
    //s[k-1].toLowerCase();
    console.log(ans);

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


Measured memory_bytes: 21064
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <iomanip>
#include <cassert>
#include <random>


int main() {
    long long n; std::cin >> n;
    long long ans = 1e18;
    for (long long i = 1; i*i <= n; i++) {
        if (n%i != 0) continue;
        ans = std::min(ans, i + n / i - 2);
    }
    std::cout << ans << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <stdlib.h>
#include <functional>
#include <string>
#include <list>
#include <fstream>
#include <iomanip>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <chrono>
#include <bitset>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) ((a) <= (x) && (x) <= (b))
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define MODU 1000000007
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int

#include <nmmintrin.h>
#ifdef _MSC_VER

#define __builtin_popcount _mm_popcnt_u32
#define __builtin_popcountll _mm_popcnt_u64
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*)array, (T*)(array + N), val);
}

struct Edge {
	int from, to, s;
};

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	int sum = 0;
	REP(i, n) {
		scanf("%d", &a[i]);
		sum += a[i] - 1;
	}cout << sum << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
//#define int long long
typedef pair<int,int> P;
typedef long long ll;
#define rep(i,a,n) for(int i=a;i<n;i++)
#define FOR(i,n) for(int i=0;i<n;i++)
const int MOD = 1e9 + 7;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n,a;
    cin>>n;
    rep(i,0,n){
        cin>>a;
        if(a%2){continue;}
        else{
            if(a%3!=0&&a%5!=0){cout<<"DENIED";return 0;}
        }
    }
    cout<<"APPROVED";
}

Measured memory_bytes: 256
a,b,c,x,y= map(int, input().split())
p=[0]*3
p[0]=a*x+b*y
if x<=y:
    p[1]=2*c*y
    p[2]=2*c*x+b*(y-x)
elif x>y:
    p[1]=2*c*x
    p[2]=a*(x-y)+2*c*y
print(min(p))


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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)
#define PI 3.14159265358979

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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



i64 a;
void solve(){
	cin >> a;
	
	int cnt = 0;
	i64 c = 100;
	while(c < a){
		cnt++;
		c=c+c*0.01;
	}
	cout << cnt << endl;
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}

Measured memory_bytes: 3612
import math

def is_prime(n):
  for i in range(2, int(math.sqrt(n)) + 1):
    if n % i == 0:
      return False
  return True

n = int(input())
a = [int(input()) for _ in range(n)]
print(sum([1 if is_prime(i) else 0 for i in a]))



Measured memory_bytes: 6092
//yashverma

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

#define rep(i,a,b) for(int i=a;i<b;i++)
#define F first
#define S second
#define pb push_back
#define Pi 3.141592653589793
#define MOD 1000000007
// For i/o
#define sd1(a) scanf("%d",&a)
#define sd2(a,b) scanf("%d %d",&a,&b)
#define sd3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define sf scanf
#define pf printf
// For debugging
#define deb(a) printf("deb%d\n",a)

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

int main()
{
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	int temp = 1;
	while(temp<<1 <= n)
	{
		temp = temp<<1;
	}
	cout << temp << "\n";
	return 0;
}

Measured memory_bytes: 256
while True:
	H, W = map(int, input().split())
	if H == 0 and W == 0:
		break
	for i in range(H):
		for j in range(W):
			if (i + j) % 2 == 0:
				print("#", end = '')
			else:
				print(".", end = '')
		print()
	print()


Measured memory_bytes: 7000
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;

struct Tag {
    string f;
    int w, s;
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    while(true) {
        int N;
        cin >> N;
        if(!N) break;
        vector<Tag> foods(N);
        for(int i = 0; i < N; ++i) {
            cin >> foods[i].f >> foods[i].w >> foods[i].s;
        }
        vector<int> order(N);
        for(int i = 0; i < N; ++i) {
            order[i] = i;
        }
        vector<int> best_ans;
        double best_G = 1e30;
        do {
            int sum_w = 0;
            int sum_gw = 0;
            bool ok = true;
            for(int i = N-1; i >= 0; --i) {
                if(sum_w > foods[order[i]].s) {
                    ok = false;
                    break;
                }
                sum_w += foods[order[i]].w;
                sum_gw += foods[order[i]].w * (i+1);
            }
            if(ok) {
                double G = static_cast<double>(sum_gw) / sum_w;
                if(G < best_G) {
                    best_ans = order;
                    best_G = G;
                }
            }
        } while(next_permutation(order.begin(), order.end()));
        for(int i = 0; i < N; ++i) {
            cout << foods[best_ans[i]].f << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1228
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2, log
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
from decimal import Decimal
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
from decimal import *

s = list(input())
K = INT()

def ctoi(c):
	return ord(c)-ord("a")

for i in range(len(s)):
	x = ctoi(s[i])
	if x == 0 or 26-x > K:
		continue
	K -= 26 - x
	s[i] = "a"

if K:
	s[-1] = ascii_lowercase[(ctoi(s[-1])+K)%26]

print("".join(s))

Measured memory_bytes: 6352
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    ll N, K;
    cin >> N >> K;

    ll a = N % K;
    ll b = K - a;

    if (a > b) cout << b << endl;
    else cout << a << endl;
    
}


Measured memory_bytes: 256
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <algorithm>
#include <array>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, a, n) for (int i = a; i < (n); i++)
#define all(in) in.begin(), in.end()
const int INF = 1e9;
const int MOD = 1e9 + 7;
int main() {
    int N, ans = 0;
    cin >> N;
    string A, B, C;
    cin >> A >> B >> C;
    rep(i, N) {
        if ((A[i] != B[i] && B[i] == C[i]) || (A[i] == B[i] && B[i] != C[i]) ||
            (A[i] == C[i] && B[i] != C[i])) {
            ans++;
        } else {
            if (A[i] == B[i] && B[i] == C[i]) {
            } else {
                ans += 2;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
 	int X,Y,Z;
  	int A=0;
  	scanf("%d %d %d",&X,&Y,&Z);
  	A=X;
  	X=Y;
  	Y=A;
  	A=X;
  	X=Z;
  	Z=A;
  	printf("%d %d %d",X,Y,Z);
  	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<map>
#include<numeric>
#include<set>
#include<sstream>
#include<string>
#include<utility>
#include<vector>

#define rep(i, a, n)  for(int i=a; i<n; i++)
#define per(i, a, n)  for(int i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define MAX 1000000000+7
using namespace std;
typedef long long ll;

ll F(ll a, ll b){
  if(b&1) return (b-a+1)/2&1;
  else return (b-a+1)/2&1 ^ b;
}

int main(){
  ll A, B; cin >> A >> B;
  ll ans = F(0, A-1) ^ F(0, B);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 768
X, K, D = map(int, input().split())

sho = abs(X)//D
amari = abs(X) % D

if abs(X) > K * D:
    print(abs(X) - K*D)
    exit(0)

if sho % 2 == K % 2:
    print(amari)
else:
    print(D - amari)

Measured memory_bytes: 8876
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
using namespace std;

template<typename A, typename B> bool chmin(A &a, const B &b){ return b < a && (a = b, true); }
template<typename A, typename B> bool chmax(A &a, const B &b){ return a < b && (a = b, true); }

int main(){
  int a,b;
  cin >> a >> b;
  for (int i = 0; i < 3; i++){
    if (a * b * i % 2 == 1){
      cout << "Yes\n";
      return 0;
    }
  }
  cout << "No\n";
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  int a,b,i;
  scanf("%d%d",&a,&b);
  if(a<=b){
    for(i=0;i<b;i++){
      printf("%d",a);
    }
    return 0;
  }
  else for(i=0;i<a;i++) printf("%d",b);
  return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<vector<P>> Graph;


int main(){

  int n,k;
  cin >> n >> k;
  
  int x[n];
  REP(i,n) cin >> x[i];
  
  int ans = 0;
  
  REP(i,n){
    ans += min(x[i],abs(x[i]-k))*2;
  }
  
  cout << ans << endl;

 return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double Double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

// chmax, chmin
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 solve(long long A, long long B) {
    for (int i = 0; i <= 1000000; i++) {
        if (abs(i * 8 / 100 - A) < 1e-9 && abs(i * 10 / 100 - B) < 1e-9) {
            cout << i << endl;
            return;
        }
    }
    cout << -1 << endl;
}

int main() {
    long long A;
    scanf("%lld", &A);
    long long B;
    scanf("%lld", &B);
    solve(A, B);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int x,y;
	while(1){
		cin>>x>>y;
		if(x==0&&y==0)return 0;
	else if(x>y){
		cout<<y<<" "<<x<<endl;
	}else cout<<x<<" "<<y<<endl;
	}
}



Measured memory_bytes: 3012
#include <iostream>
#include <iomanip>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <deque>
#include <queue>
#include <functional>
//#include <boost/multiprecision/cpp_int.hpp>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, m, n) for(int i = m; i < n; ++i)
#define rrep(i,n) for(int i = n; i >= 0; --i)
#define RREP(i, m, n) for(int i = n; i >= m; --i)
#define llrep(i, n) for(ll i = 0; i < n; ++i)
#define llREP(i, m, n) for(ll i = m; i < n; ++i)
#define llrrep(i,n) for(ll i = n; i >= 0; --i)
#define llRREP(i, m, n) for(ll i = n; i >= m; --i)

using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int, int>;
using pll = std::pair<long long, long long>;
using pil = std::pair<int, long long>;
using pli = std::pair<long long, int>;
using plpii = std::pair<long long, std::pair<int, int>>;
using pdd = std::pair<double, double>;

const long long INF = 1000000000000000001;
const long long _MOD = 1000000007;
const long long MOD = 998244353;
const int ALPHABET = 27;
const double pi = 3.14159265358979;

using namespace std;
//namespace mp = boost::multiprecision;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	char a;
	cin >> a;
	if (a >= 'a' && a <= 'z') {
		cout << 'a' << "\n";
	}
	else {
		cout << 'A' << "\n";
	}

	return 0;
}

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

const int N = 1e5 + 7;
int visit[N];

pair <int , pair <int, int> >  A[N], B[N];

int comparea(pair <int , pair <int, int> >  i, pair <int , pair <int, int> > j) {
        return i.first - j.second.first > j.first - i.second.first;
}


int32_t main() {
        int n; cin >> n;
        for(int i = 1; i <= n; i++) {
                int x, y;
                cin >> x >> y;
                A[i] = {x, {y, i}};
                B[i] = {y, {x, i}};
        }

        sort(A + 1, A + n + 1, comparea);
        sort(B + 1, B + n + 1, comparea);

        int diff = 0, j = 1, k = 1;
        for(int i = 1; i <= n; i++) {
                if(i & 1) {
                        while(visit[A[j].second.second]) j++;
                        visit[A[j].second.second] = 1;
                        diff += A[j].first;
                }else {
                        while(visit[B[k].second.second]) k++;
                        visit[B[k].second.second] = 1;
                        diff -= B[k].first;
                }
        }

        cout << diff << endl;
}


Measured memory_bytes: 5760
x = input()
#print(x)
y = [int(c) for c in x]
#print(y)
a = y[0]
b = y[1]
c = y[2]
d = y[3]
if a+b+c+d == 7:
  print(a,"+",b,"+",c,"+",d,"=",a+b+c+d, sep='')
  exit()
if a+b+c-d == 7:
  print(a,"+",b,"+",c,"-",d,"=",a+b+c-d, sep='')
  exit()
if a+b-c+d == 7:
  print(a,"+",b,"-",c,"+",d,"=",a+b-c+d, sep='')
  exit()
if a-b+c+d == 7:
  print(a,"-",b,"+",c,"+",d,"=",a-b+c+d, sep='')
  exit()
if a-b-c+d == 7:
  print(a,"-",b,"-",c,"+",d,"=",a-b-c+d, sep='')
  exit()
if a-b+c-d == 7:
  print(a,"-",b,"+",c,"-",d,"=",a-b+c-d, sep='')
  exit()
if a-b-c-d == 7:
  print(a,"-",b,"-",c,"-",d,"=",a-b-c-d, sep='')
  exit()
if a+b-c-d == 7:
  print(a,"+",b,"-",c,"-",d,"=",a+b-c-d, sep='')
  exit()

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<pair<string,int>> vpsi;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p,q)
#define pb(n) push_back(n)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define Sort(a) sort(a.begin(),a.end())
#define Rort(a) sort(a.rbegin(),a.rend())
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 P = 1000000007;
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;

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

int n;
cin >> n;
double x;
string u;
double ans=0;
rep(i,n){
    cin >> x >> u;
    if(u=="JPY")ans+=x;else ans+=x*380000.0;
}
printf("%.10lf",ans);

//////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 256
package main

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

const size = 1000000
var reader = bufio.NewReaderSize(os.Stdin,size)
func NextLine() string {
  var line,buffer []byte
  var isPrefix bool = true
  var err error
  for ;isPrefix; {
    line,isPrefix,err = reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer,line...)
  }
  return string(buffer)
}
func NextInt() int {
  var n int
  n,_ = strconv.Atoi(NextLine())
  return n
}
func NextIntArray() []int {
  var s []string = strings.Split(NextLine()," ")
  var a []int = make([]int,len(s))
  for i:=0;i<len(s);i++ {
    a[i],_ = strconv.Atoi(s[i])
  }
  return a
}

func main() {
  var n int = NextInt()
  var a []int = NextIntArray()
  var b []int = NextIntArray()
  var x int = 0
  for k:=28;k>-1;k-- {
    sort.Ints(b)
    var t int = 1<<uint(k)
    var l,r,y int
    for i:=0;i<n;i++ {
      l = bisect(b,t-a[i]%(2*t))
      r = bisect(b,2*t-a[i]%(2*t))
      y += r-l
      l = bisect(b,3*t-a[i]%(2*t))
      r = bisect(b,4*t-a[i]%(2*t))
      y += r-l
    }
    for i:=0;i<n;i++ {
      a[i] &= (1<<uint(k))-1
      b[i] &= (1<<uint(k))-1
    }
    x |= y%2 << uint(k)
  }
  fmt.Println(x)
}
func bisect(a []int,x int) int {
  var btm int = -1
  var top int = len(a)
  var mid int
  for top-btm > 1 {
    mid = (btm+top)/2
    if a[mid] < x {
      btm = mid
    } else {
      top = mid
    }
  }
  return btm
}

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

int main(){
  int a,b,c,d,e;
  cin >> a >> b >> c >> d >> e;
  int N=5;
  
  //注文してから届くまでの時間
  vector<int> Time = {a,b,c,d,e};
  //順番の並び替え
  vector<int> index = {0,1,2,3,4};
  
  int BestTime = (int)1e9;//←10^9(double)
  
  //indexの中身が
  //0,1,2,3,4
  //0,1,2,4,3
  //:
  //4,3,2,1,0
  //の全探索ができる。(当然DFSとかで全探索して求めてもok)
  do {
    int NowTime=0;
    for (int i=0;i<N;++i){
      //10で割り切れるようになるまで1を足し続ける
      while (NowTime%10!=0) NowTime++;
      NowTime+=Time[index[i]];
    }
    BestTime=min(BestTime,NowTime);
  }
  while (next_permutation(index.begin(),index.end()));
  cout << BestTime << endl;
}
//全探索による解法
    
  


Measured memory_bytes: 256
def examA():
    N, M = LI()
    ans = N*(N-1)//2 + M*(M-1)//2
    print(ans)
    return

def examB():
    def judge(A):
        #print(A)
        n = len(A)
        for i in range(n//2):
            if A[i]!=A[n-i-1]:
                return False
        return True
    S = SI()
    N = len(S)
    if not judge(S):
        print("No")
        return
    if judge(S[:(N-1)//2]) and judge(S[(N+1)//2:]):
        print("Yes")
    else:
        print("No")
    return

def examC():
    L = I()
    ans = (L/3)**3
    print(ans)
    return

def examD():
    N = I()
    A = LI()
    D = defaultdict(bool)
    C = Counter(A)
    M = 0
    for key,c in C.items():
        M += c*(c-1)//2
    #print(C)
    #print(M)
    ans = [0]*N
    for i in range(N):
        a = A[i]
        c = C[a]
        ans[i] = M -(c*(c-1)//2) + ((c-1)*(c-2)//2)
    for v in ans:
        print(v)
    return

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]

sys.setrecursionlimit(10**6)

if __name__ == '__main__':
    examD()

"""

"""

Measured memory_bytes: 84308
h, w = map(int, input().split())
n = int(input())
a = list(map(int, input().split()))

colors = [[0] * w for _ in range(h)]

i = j = 0
foward = True
for k in range(len(a)):
    num = a[k]
    while num > 0:
        colors[i][j] = k + 1
        if foward is True:
            j += 1
            if j == len(colors[0]):
                j -= 1
                i += 1
                foward = False
        else:
            j -= 1
            if j == -1:
                j += 1
                i += 1
                foward = True
        num -= 1

for i in range(len(colors)):
    for j in range(len(colors[0])):
        print(colors[i][j], end=' ')
    print()

Measured memory_bytes: 3920
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<climits>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<numeric>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i = m; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a)  (a).rbegin(),(a).rend()
#define PI 3.14159265359
#define MOD 1000000007
typedef long long LL;

template<class T> inline void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> inline void chmin(T& a, T b) { if (a > b) { a = b; } }
template<class T> void print_vector(vector<T> vec) {
	cout << "[ ";
	for (int i = 0; i < vec.size(); i++) {
		cout << vec[i] << " ";
	}
	cout << "]" << endl;
}
template<class T> void print_pair_vector(vector<pair<T, T> > vec) {
	cout << "[ ";
	for (int i = 0; i < vec.size(); i++) {
		cout << "(" << vec[i].first << "," << vec[i].second << ") ";
	}
	cout << "]" << endl;
}

const int INF = 1 << 30;

LL find_greatest_common_divisor(LL x, LL y) {
	if (y == 0) {
		return x;
	}
	return find_greatest_common_divisor(y, x % y);
}

int main(void) {
	LL N;
	cin >> N;

	vector<LL> A(N);
	rep(i, N) cin >> A[i];

	LL gcd = find_greatest_common_divisor(A[0], A[1]);
	for (int i = 2; i < N; i++) {
		gcd = find_greatest_common_divisor(gcd, A[i]);
	}

	cout << gcd << endl;
	return 0;
}

Measured memory_bytes: 1024
//#include "stdafx.h"
#include "iostream"
#include "fstream"
#include "algorithm"
#include "iomanip"
#include "stack"
#include "queue"
#include "string"
#include "vector"
#include "map"
#include "set"
#include "list"
#include "deque"
#include "complex"
#include "bitset"
#include "cmath"
#include "unordered_set"
#include "unordered_map"
#include "iterator"
#include <ctime>
#include <cassert>
#include "numeric"
#include <cstdio>
#include "random"
#include "chrono"
#include "cstring"

//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target_ans("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;

//#define f(i,n) for(int i=0; i<n;i++)
//#define rf(i, n) for(int i=n-1;i>=0;i--)
//#define forn(i, j, n) for(int i=j; i<n; i++)
//#define ff(i, j, n) f(i, n)f(j, n)
#define pb push_back
#define maxi(a,b) a = max(a, b);
#define mini(a,b) a = min(a, b);
#define endl '\n'

#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define sqr(x) ((x) * (x))
#define SZ(a) ((int)(a.size()))
#define watch(x) cout << (#x) << " = " << x << endl;
//typedef long long ll;
typedef long double ld;

#define int long long
//#define int unsigned int
#define double ld
typedef map<int, int> mii;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<pii> vpii;
typedef vector<char> vc;
typedef vector<vi> vvi;

template<class T>
void show(const vector<T> &a)
{
	for (T x : a)
		cout << x << " ";
	cout << endl;
}

vi xx = { 1, 0, -1, 0 };
vi yy = { 0, 1, 0, -1 };
string dir = "LRUD";

const int N = 5e5 + 50, oo = 3e18 + 500;
const int mod = 998244353;
//const int mod = 1e9 + 7;
//const int mod = 1e9 + 9;
const double eps = 1e-12, PI = 2 * acos(0.0);
int n, m, k;
long long cnt = 0;
int lg = 18;
vi g[N];
vi rg[N];
vi visit(N, 0);



signed main()
{
	ios::sync_with_stdio(0);
	cout.tie(0); cin.tie(0);
	/*freopen("abbreviation.in", "r", stdin);
	freopen("abbreviation.out", "w", stdout);*/
	//ПРОВЕРЯЙ ДЕФАЙНЫ ТУПОЙ!!!

	int h1, m1, h2, m2;
	cin >> h1 >> m1 >> h2 >> m2 >> k;

	cnt = h2 * 60 + m2 - h1 * 60 - m1;

	cout << cnt - k;
}




Measured memory_bytes: 30272
using System;
using System.Collections.Generic;
using System.Linq;
//全て投げ出して全探索してもいいんじゃない？ used to be O(N log N)?でeasy
namespace AtCoderTemplate
{
    public class App
    {
        public static void Main(string[] args)
        {
            var k = int.Parse(Console.ReadLine()); Console.WriteLine(Enumerable.Range(1,k/2).Select(v=>new {p=v,q=k-v}).Select(v=>v.p.ToString().ToCharArray().Sum(c=>c-'0')+v.q.ToString().ToCharArray().Sum(c=>c-'0')).Min());
        }
    }
}


Measured memory_bytes: 17480
A = int(input())
B = int(input())
C = int(input())
X = int(input())
answer = 0
for i in range(min(A, X // 500) + 1):
    for j in range(min(B, (X - i * 500) // 100) + 1):
        if X - 500 * i - 100 * j <= 50 * C:
            answer += 1
print(answer)


Measured memory_bytes: 9140
import numpy as np
N, M = map(int, input().split())
A = np.ones(N + 2, dtype='bool')
for _ in range(M):
    A[int(input())] = False
MOD = 1000000007

dp = np.zeros(N + 2, dtype='int')
dp[0] = 1
for now in range(N):
    for _next in range(now + 1, now + 3):
        if A[_next]:
            dp[_next] += dp[now]
            dp[_next] %= MOD
print(dp[N])


Measured memory_bytes: 14924
S = list(input())
N = len(S)
T = list(input())
n = len(T)
ans = n
for i in range(N - n + 1):
    s = S[i:i + n]
    a = 0
    for j in range(n):
        if T[j] != s[j]:
            a += 1
    if a < ans:
        ans = a
print(ans)


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

int main(){
	int n,i,ans=0,t=0;
	char s;
	
	cin>>n;
	
	for (i=1; i<=n; i++){
		cin>>s;
		if (s=='I') t++;
		else if (s=='D') t--;
		ans=max(ans,t);
	}
	
	cout<<ans<<endl;	
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream> 
#include<cstring> 
#include<limits.h> 
#include<algorithm>
#define inf 1000000007
using namespace std;
 
int dp[100005][3];
 
int main()
{
    memset(dp, 0, sizeof(dp));
    
    int n; cin >> n;
    int a[n],b[n],c[n];
    
    for(int i = 0; i < n; ++i) cin >> a[i] >> b[i] >> c[i];
    
        dp[0][0] = a[0];
        dp[0][1] = b[0];
        dp[0][2] = c[0];
    
    for(int i = 1; i < n; ++i)
    {
        dp[i][0] = a[i] + max(dp[i-1][1], dp[i-1][2]);
        dp[i][1] = b[i] + max(dp[i-1][2], dp[i-1][0]);
        dp[i][2] = c[i] + max(dp[i-1][1], dp[i-1][0]);
    }
    
    int ans = max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2]));
    cout << ans;
}

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

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

 rep(i,s.length()) cout<<"x";
 cout<<endl;

  return 0;
}


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

typedef long long int   ll;
#define cases           int t;cin>>t;while(t--)
#define FIO             ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define scan(n)         scanf("%d",&n)
#define pb              push_back
#define vi              vector<int>
#define ii              pair<int,int>

using namespace std;

int main(){
    ll a,b,n;cin>>a>>b>>n;
    if(n>=b)
        n=b-1;
    cout<<((a*n)/b)-a*(n/b)<<endl;
}


Measured memory_bytes: 3552
/************************************************************
	> File Name: c.cpp
	> Author: TSwiftie
	> Mail: 2224273204@qq.com 
	> Created Time: Fri 20 Dec 2019 02:39:23 AM CST
************************************************************/

#pragma GCC optimize(2)
#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <iomanip>
//#include <unordered_map>
#define lowbit(x) (x&-x)
#define lc (o<<1)
#define rc (o<<1|1)
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int INF = 0x3f3f3f3f;
const int MAXN = 20+5;
const int MAXM = 2e5+5;
const int MOD = 1e9+7;
const int dir[4][2] = {1,0,-1,0,0,1,0,-1};
const double PI = acos(-1.0);
const double EXP = 1e-8;
int n;
int a[MAXN];
int x[MAXN][MAXN],y[MAXN][MAXN];
int main(void){
	scanf("%d",&n);
	for(int i = 1;i <= n;i++){
		scanf("%d",a+i);
		for(int j = 1;j <= a[i];j++)
			scanf("%d%d",&x[i][j],&y[i][j]);
	}
	int ans = 0;
	for(int bit = 0;bit < 1<<n;bit++){
		bool mark = true;
		for(int i = 1;i <= n;i++){
			if(!(bit&(1<<(i-1))))
				continue;
			for(int j = 1;j <= a[i];j++){
				if((1<<(x[i][j]-1))&bit&&y[i][j])
					continue;
				else if(!((1<<(x[i][j]-1))&bit)&&!y[i][j])
					continue;
				else
					mark = false;
			}
		}
		if(mark)
			ans = max(ans,__builtin_popcount(bit));
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main
{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        if (sc.nextInt() * sc.nextInt() % 2 == 0) {
            System.out.println("Even");
        }
        else {
            System.out.println("Odd");
        }
    }
}


Measured memory_bytes: 22612
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

#define rep(i, x, n) for(int i = x; i < n; i++)
using namespace std;
const long long INF = 1LL << 60;

long long GCD(long long a, long long b) {
    if(b == 0)
        return a;
    else
        return GCD(b, a % b);
}
long long LCM(long long a, long long b) {
    long long g = GCD(a, b);
    return a / g * b;
}
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;
}
int main() {
    long long N, K;
    cin >> N >> K;
    if(K >= N) {
        cout << min(N, (K - N)) << endl;
    } else {
        long long x = N % K;
        cout << min(x, (K - x)) << endl;
    }
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

"""
参考：https://pitsbuffersolution.com/compro/atcoder/arc089d.php
　　　http://tutuz.hateblo.jp/entry/2018/06/20/212752
　　　https://paiza.hatenablog.com/entry/2014/05/28/%E3%82%82%E3%81%97%E5%A5%B3%E5%AD%90%E5%A4%A7%E7%94%9F%E3%83%97%E3%83%AD%E3%82%B0%E3%83%A9%E3%83%9E%E3%81%AB%E3%80%8E%E3%82%A2%E3%83%AB%E3%82%B4%E3%83%AA%E3%82%BA%E3%83%A0%E3%80%8F%E3%82%92%E5%9B%B3
　　　http://www.learning-algorithms.com/entry/2018/01/31/144519
　　　https://img.atcoder.jp/arc089/editorial.pdf
・2次元累積和
・0-indexedのまま行くか1-indexedにするか人によって色々で、
　それぞれに考慮する点があると思った。
・今度は0-indexedでループ減らした版。
"""

import sys
def input(): return sys.stdin.readline().strip()

N, K = map(int, input().split())

# ここは循環するK*2まで作る
B = [[0] * (K*2) for i in range(K*2)]
for i in range(N):
    x, y, c = input().split()
    x, y = int(x), int(y)
    # 白に塗る条件はxかyにKずらして黒の条件にする(これで2色考えなくていい)
    if c == 'W':
        y += K
    # 循環するのでmod K*2でやる
    B[x%(K*2)][y%(K*2)] += 1

# ここはK*2の正方形を右下まで動かすので、K*4まで作っておく
sm = [[0] * (K*4) for i in range(K*4)]
# 2次元累積和を取る
for i in range(K*4):
    for j in range(K*4):
        # K*2からはみ出る範囲も正しく累積和を出すため、K*2までの値を循環させる
        # 0-indexedなのでここはシンプル
        sm[i][j] = B[i%(K*2)][j%(K*2)]
        # 縦横の累積和を同時に集めていく
        # 0-indexedなので、i, jがマイナスになる場合を考慮
        if j > 0:
            sm[i][j] += sm[i][j-1]
        if i > 0:
            sm[i][j] += sm[i-1][j]
        if i > 0 and j > 0:
            sm[i][j] -= sm[i-1][j-1]

# 2次元累積和に必要な4点の加減を行う
def get_sum(x1, y1, x2, y2, sm):
    # 右下は必ず足す
    res = sm[x2][y2]
    # 左下を引く
    if x1 > 0:
        res -= sm[x1-1][y2]
    # 右上を引く
    if y1 > 0:
        res -= sm[x2][y1-1]
    # 左上を足す
    if x1 > 0 and y1 > 0:
        res += sm[x1-1][y1-1]
    return res

ans = 0
for i in range(K*2):
    for j in range(K*2):
        # 1つ目の正方形
        tmp = get_sum(i, j, i+K-1, j+K-1, sm)
        # 2つ目の正方形
        tmp += get_sum(i+K, j+K, i+K*2-1, j+K*2-1, sm)
        ans = max(tmp, ans)
print(ans)


Measured memory_bytes: 197852
#include <cstdio>
#include <iostream>
#include <cassert>
#include <algorithm>    
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <cstring>
#include <cmath>
#include <bitset>
#define pb push_back
#define mk make_pair
#define eb emplace_back
#define eps 1e-8
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
// #define int long long
using namespace std;

typedef long double ld;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef unsigned long long ull; 
typedef vector<int> vii;
typedef vector<long double> vd;
const int inf = 1e9;
const int M = 1e9 + 7;
//__int128


signed main()
{
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  int n;
  cin >> n;
  int a[100];
  for(int i = 1; i <= n; ++i) {
  	cin >> a[i];
  }
  int m = *min_element(a + 1, a + n + 1), M = *max_element(a + 1, a + n + 1);
  std::vector<pii> v;
  cout << 2 * n << endl;
  if(m + M < 0) {
  	int x = min_element(a + 1, a + n + 1) - a;
  	for(int i = 1; i <= n; ++i) {
  		cout << x << ' ' << i << endl;
  	}
  	cout << x << ' ' << n << endl;
  	for(int i = n - 1; i >= 1; --i) {
  		cout << i + 1 << ' ' << i << endl;
  	}
  } else {
  	int x = max_element(a + 1, a + n + 1) - a;
  	for(int i = 1; i <= n; ++i) {
  		cout << x << ' ' << i << endl;
  	}
  	cout << x << ' ' << 1 << endl;
  	for(int i = 2; i <= n; ++i) {
  		cout << i - 1 << ' ' << i << endl;
  	}
  }
	return 0;
}

Measured memory_bytes: 256
S = input()
fore = int(S[:2])
aft = int(S[2:])

if (fore == 0 or 13 <= fore <= 99) and 1 <= aft <= 12:
    print("YYMM")
elif 1 <= fore <= 12 and (aft == 0 or 13 <= aft <= 99):
    print("MMYY")
elif 1 <= fore <= 12 and 1 <= aft <= 12:
    print("AMBIGUOUS")
else:
    print("NA")

Measured memory_bytes: 3060
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
using namespace std;

int main()
{
    int n,h,i,sum=0;
    cin>>h>>n;
    while(n--)
    {
        cin>>i;
        sum+=i;
    }
    if(sum>=h) printf("Yes\n");
    else printf("No\n");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
  int N;
  cin >> N;
  double p[N];
  for(int i=0; i<N; i++) cin >> p[i];
  
  double dp[N+1][N+1];
  // dp[i][j]: i枚目まで投げて表がj枚
  // dp[i+1][j+1] = dp[i][j]*p[i],
  //              = dp[i][j+1]*(1-p[i]);
  for(int i=0; i<=N; i++) for(int j=0; j<=N; j++) dp[i][j] = 0;
  dp[0][0]=1;
  for(int i=1; i<=N; i++) dp[i][0] = dp[i-1][0]*(1-p[i-1]);

  
  for(int i=0; i<N+1; i++){
    for(int j=0; j<=i; j++){
      dp[i+1][j+1] = dp[i][j]*p[i];
//      if(i>=j+1) dp[i+1][j+1] += dp[i][j+1]*(1-p[i]);
      dp[i+1][j+1] += dp[i][j+1]*(1-p[i]);
    }
  }
  double ans = 0;
  /*
  for(int i=0; i<=N; i++) {
    for(int j=0; j<=N; j++){
      cout << dp[i][j] << " ";
    }
    cout << endl;
  }
  */
  for(int i=(N+2-1)/2; i<=N; i++) ans += dp[N][i];
  cout << setprecision(10) << ans << endl;
  return 0;
}

Measured memory_bytes: 70528
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
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;}
typedef long long ll;
typedef pair<int,int> pii;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;

// graph //
int V,E,r,from,to,weight;
ll dist[100][100];

int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    cin >> V >> E;
    REP(i,V) REP(j,V){
        dist[i][j] = INF;
        if(i==j) dist[i][j] = 0;
    }
    REP(i,E){
        cin >> from >> to >> weight;
        dist[from][to] = weight;
    }
    REP(k,V)
        REP(i,V)
            REP(j,V)
                chmin(dist[i][j],dist[i][k] + dist[k][j]);

    REP(i,V)
        if(dist[i][i] < 0){
            cout << "NEGATIVE CYCLE" << '\n';
            return 0;
        }
    REP(i,V) REP(j,V){
        if(dist[i][j] > 1e10) cout << "INF";
        else cout << dist[i][j];
        cout << (j==V-1 ? '\n' : ' ');
    }
    return 0;
}


Measured memory_bytes: 3248