akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.*;
import java.lang.*;

class Main {

	public static void main(String[] args) {
		final FastScanner sc = new FastScanner(System.in);
		int n = sc.nextInt();
		long a = 0;
		for (int i = 1; i <= n; i++) {
			if (i % 3 == 0 && i % 5 == 0) {
				continue;
			} else if (i % 3 == 0) {
				continue;
			} else if (i % 5 == 0) {
				continue;
			}

			a += i;
		}

		System.out.println(a);

	}

	static class FastScanner {
		private final InputStream in;
		private final byte[] buffer = new byte[1024];
		private int ptr = 0;
		private int buflen = 0;

		public FastScanner(InputStream source) {
			in = source;
		}

		private boolean hasNextByte() {
			if (ptr < buflen) {
				return true;
			} else {
				ptr = 0;
				try {
					buflen = in.read(buffer);
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (buflen <= 0) {
					return false;
				}
			}
			return true;
		}

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

		private static boolean isPrintableChar(int c) {
			return 33 <= c && c <= 126;
		}

		public boolean hasNext() {
			while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;
			return hasNextByte();
		}

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

		public long nextLong() {
			if (!hasNext()) throw new NoSuchElementException();
			long n = 0;
			boolean minus = false;
			int b = readByte();
			if (b == '-') {
				minus = true;
				b = readByte();
			}
			if (b < '0' || '9' < b) {
				throw new NumberFormatException();
			}
			while (true) {
				if ('0' <= b && b <= '9') {
					n *= 10;
					n += b - '0';
				} else if (b == -1 || !isPrintableChar(b)) {
					return minus ? -n : n;
				} else {
					throw new NumberFormatException();
				}
				b = readByte();
			}
		}

		public int nextInt() {
			long nl = nextLong();
			if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
				throw new NumberFormatException();
			return (int) nl;
		}

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


Measured memory_bytes: 32532
from itertools import groupby

s = input()
k = int(input())

cont = [sum(1 for _ in it) for k, it in groupby(s)]

if len(cont) == 1:
    res = len(s) * k // 2
else:
    res = k-1 if s[0] == s[-1] and cont[0] % 2 == 1 and cont[-1] % 2 == 1 else 0
    for c in cont:
        if c != 1:
            res += c // 2 * k

print(res)


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

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

const int INF = 1 << 28;
int sum;
string num;

int main() {
    while (cin >> sum >> num, sum || num != "0") {
        map<int,vec> m;
        int target = -1;
        for (int i = 0; i < 1 << (num.size() - 1); i++) {
            int tmp = 0;
            int pre = 0;
            for (int j = 0; j < num.size() - 1; j++) {
                if (i & (1 << j)) {
                    string s = string(num.begin() + pre, num.begin() + j + 1);
                    // if (s[0] == '0' && s.size() > 1) continue;
                    stringstream ss; ss << s;
                    int n; ss >> n;
                    tmp += n;
                    pre = j + 1;
                }
            }

            string s = string(num.begin() + pre, num.end());
            stringstream ss; ss << s;
            int n; ss >> n;
            tmp += n;

            if (tmp <= sum) {
                m[tmp].push_back(i);
                target = max(target, tmp);
            }
        }

        if (m.size() == 0) {
            cout << "error" << endl;
        } else if (m[target].size() == 1) {
            cout << target << " ";
            int tmp = m[target][0];
            for (int i = 0; i < num.size(); i++) {
                cout << num[i];
                if (tmp & (1 << i)) cout << " ";
            }
            cout << endl;
        } else {
            cout << "rejected" << endl;
        }
    }
}

Measured memory_bytes: 3164
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int n = Integer.parseInt(br.readLine());
		String[] str = br.readLine().split(" ");

		int max = -1000000;
		int min = 1000000;
		long sum = 0;
		for (int i = 0; i < n; i++) {
			int an = Integer.parseInt(str[i]);
			if (max < an) {
				max = an;
			}
			if (min > an) {
				min = an;
			}
			sum += an;
		}

		System.out.println(min + " " + max + " " + sum);
	}

}

Measured memory_bytes: 28552
#include<bits/stdc++.h>
using namespace std;
char st[2000100];
int a[2000100];
int main()
{
	scanf("%s",st+1);int len=strlen(st+1),ans=2100000000;
	for (int ch='a';ch<='z';ch++)
	{
		for (int i=1;i<=len;i++) a[i]=(st[i]==ch);
		int ths=0,l=len;
		while (1)
		{
			bool err=false;
			for (int i=1;i<=l;i++) if (a[i]==0) err=true;
			if (!err) break;
			for (int i=1;i<l;i++) a[i]=a[i]||a[i+1];l--;
			ths++;
		}
		ans=min(ans,ths);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 2304
N = gets.to_i
A = gets.split.map(&:to_i)

min = 10**5 + 1
sum = 0
negatives = 0
A.each do |a|
  sum += a.abs
  if a < 0
    negatives += 1
  end
  if min > a.abs
    min = a.abs
  end
end

# p min, sum, negatives

if negatives % 2 == 0
  p sum
else
  p sum - 2*min
end


Measured memory_bytes: 8580
#include <bits/stdc++.h>
using namespace std;
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20);} } fast;

long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return t / 2;
    } else {
        return modpow(m, n - 1) * m;
    }
}

int main() {
    long long n, p, a = 1, s, ans = 1;
    cin >> n >> p;
    s = p;
    map<long long, long long> cnt; 
    for (int i = 2; 1LL * i * i <= p; i++) {  
        while (p % i == 0) {  
            cnt[i]++;  
            p = p / i;  
        }  
    } 
    if (p >= 2) { 
        cnt[p]++;
    }
    for (auto& p : cnt) {
        for (int i = 0; i < p.second / n; i++) ans *= p.first;
    }
    cout << ans << endl;
} 

Measured memory_bytes: 384
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#A
def A():
    return

#B
def B():
    return

#C
def C():
    n = I()
    f = LIR(n)
    po = [1]*11
    for i in range(n):
        k = 0
        p = 1
        for j in range(10):
            k += p*f[i][j]
            p *= 2
            po[j+1] = p
        f[i] = k
    p = LIR(n)
    ans = -float("inf")
    for i in range(1,1024):
        k = 0
        for j in range(n):
            c = i&f[j]
            s = 0
            for l in po:
                if c&l:s += 1
            k += p[j][s]
        ans = max(ans,k)
    print(ans)
#D
def D():
    n,C = LI()
    T = [[0 for i in range(100002)] for j in range(C)]
    for i in range(n):
        s,t,c = LI()
        c -= 1
        T[c][s] += 1
        T[c][t+1] -= 1
    for c in range(C):
        for i in range(100000):
            T[c][i+1] += T[c][i]
    ans = 0
    for i in range(100000):
        k = 0
        for c in range(C):
            if T[c][i]:k += 1
        ans = max(ans, k)
    print(ans)
#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == "__main__":
    D()


Measured memory_bytes: 118216
#include <bits/stdc++.h> 
#define rep(i,n) for(long long i = 0; i < (long long)(n); i++)
#define per(i,n) for(long long i = (long long)(n-1);i >= 0;--i)
#define REP(i,s,t) for(long long i=s;i<t;i++)
#define PER(i,s,t) for(long long i=s;i>t;--i)
#define all(x) x.begin(),x.end()
#define sp(n) setprecision(n)
typedef long long ll;
using namespace std;
int main(){
  int n,m;
  cin>>n>>m;
  if(n==m){
    rep(i,n){
      cout<<n;
    }
    cout<<endl;
  }
  else if(n>m){
    rep(i,n){
      cout<<m;
    }
    cout<<endl;
  }
  else{
    rep(i,m){
      cout<<n;
    }
    cout<<endl;
  }
}

Measured memory_bytes: 256
#include <cstdio>

using namespace std;

void Get_Val(int &Ret)
{
	Ret = 0;
	char ch;
	while (ch = getchar(), ch > '9' || ch < '0')
		;
	do
	{
		(Ret *= 10) += ch - '0'; 
	}
	while (ch = getchar(), ch >= '0' && ch <= '9');
}

const int Max_N(100050);

int N, Total, Head[Max_N], To[Max_N << 1], Next[Max_N << 1];

inline void Add_Edge(const int &s, const int &t)
{
	++Total, To[Total] = t, Next[Total] = Head[s], Head[s] = Total;
}

void init()
{
	Get_Val(N);
	for (int i = 1, u, v;i != N;++i)
		Get_Val(u), Get_Val(v), Add_Edge(u, v), Add_Edge(v, u);
}

int SG[Max_N];
void dp(const int &u, const int &fa)
{
	for (int i = Head[u], v;i;i = Next[i])
		if ((v = To[i]) != fa)
			dp(v, u), SG[u] ^= (SG[v] + 1);
}

int main()
{

	init();
	dp(1, -1);
	if (SG[1])
		printf("Alice");
	else
		printf("Bob");
	return 0;
}

Measured memory_bytes: 7168
#include "bits/stdc++.h"
using namespace std;

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

int main() {
	int N;
	cin >> N;
	vector<vector<int> > Dist(N, vector<int>(N, 0));
	vector<vector<bool> > Use(N, vector<bool>(N, true));
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			Dist[i][j] = min({ i, j, N - 1 - i, N - 1 - j });
		}
	}
	int ANS = 0;
	for (int i = 0; i < N * N; i++) {
		int P;
		cin >> P;
		P--;
		int X = P / N, Y = P % N;
		ANS += Dist[X][Y];
		Use[X][Y] = false;
		queue<int> Q;
		Q.push(P);
		while (!Q.empty()) {
			int A = Q.front() / N, B = Q.front() % N;
			Q.pop();
			for (int j = 0; j < 4; j++) {
				int NX = A + dx[j], NY = B + dy[j];
				if (0 <= NX && NX < N && 0 <= NY && NY < N) {
					if (Dist[NX][NY] > Dist[A][B] + Use[A][B]) {
						Dist[NX][NY] = Dist[A][B] + Use[A][B];
						Q.push(NX * N + NY);
					}
				}
			}
		}
	}
	cout << ANS << endl;
}

Measured memory_bytes: 4648
#include <bits/stdc++.h>
#define MP make_pair
using namespace std;
typedef long long ll;
const int N = 1e5 + 5;

int n, k;
char s[N];

int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    cin >> n >> k;
    cin >> s + 1;
    int ans = 0;
    for(int i = 1; i <= n; i++) {
        if(s[i] == s[i - 1] && s[i] == 'L') ++ans;
    }
    for(int i = n; i >= 1; i--) {
        if(s[i] == s[i + 1] && s[i] == 'R') ++ans;
    }
    ans = min(n - 1, ans + 2 * k);
    cout << ans;
}


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

int main() {
	int a, b , c, x;
	cin >> a >> b >> c >> x;
	int cnt = 0;
	for(int i = 0; i <= a; i++) {
		for(int j = 0; j <= b; j++) {
			for (int k = 0; k <= c; k++) {
				int total = 500 * i + 100 * j + 50 * k;
				if (total == x) cnt++;
			}
		}
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
    int a, b;
    char op;

    while(1){
        scanf("%d %c %d", &a, &op, &b);
        if(op == '?') break;

        if(op == '+') printf("%d\n", a+b);
        else if(op == '-') printf("%d\n", a-b);
        else if(op == '*') printf("%d\n", a*b);
        else printf("%d\n", a/b);
    }

    return 0;
}


Measured memory_bytes: 2120
N = gets.to_i
S = gets.chomp.chars.take(N)
left = 0
stack = []
S.each do |s|
  top = stack.last
  if s == '('
    stack.push(s)
  else # ')'
    if top == '('
      stack.pop
    else
      stack.push(s)
    end
  end
end
left_count = stack.count(')')
right_count = stack.count('(')
ans = ('(' * left_count) + S.join('') + (')' * right_count)
puts ans


Measured memory_bytes: 1916
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(I, a, b) for (int i = (a); i < (b); ++i)
using namespace std;
using ll = long long;

int main() {
  int n;
  string s;
  cin >> n >> s;
  
  int cnt = 0;
  REP(i,n-2){
    if(s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C'){
      cnt++;
    }
  }
  
  cout << cnt << endl;

  
}

Measured memory_bytes: 3552
//#include "pch.h"
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;

#define FOR(i, s, e) for(int i=s; i<e; i++)
#define REF(i, s, e) for(int i=s; i>e; i--)
typedef long long ll;

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
    int a,b;
    cin >> a >> b;
    
    int ans = 0;
    
    FOR(i,0,2){
        if (a > b){
            ans += a;
            a--;
        }
        else{
            ans += b;
            b--;
        }
    }
    cout << ans << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

template<class T>
inline bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

istream& operator>>(istream& is, P& p){
    is >> p.first >> p.second;
    return is;
}

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

    int n, m;
    cin >> n >> m;
    vector<P> table(m);
    for(int i = 0; i < m; ++i)  cin >> table[i];
    sort(table.begin(), table.end(), [](const P& p1, const P& p2){
        if(p1.first == p2.first){
            return p1.second > p2.second;
        }
        return p1.first < p2.first;
    });
    int ans = 0;
    int lb = n + 1, ub = 0;
    for(auto p : table){
        int l = p.first, r = p.second;
        if(r <= lb || l >= ub){
            ++ans;
            lb = l, ub = r;
        }
        else{
            chmax(lb, l);
            chmin(ub, r);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3992
use proconio::{input, fastout};
use std::time::{Duration, Instant};
use rand::prelude::*;

const TYPE_COUNT: usize = 26;

#[fastout]
fn main() {
    input! {
        d: usize,
        cc: [usize; TYPE_COUNT],
        ss: [[usize; TYPE_COUNT]; d],
    }
    let start = Instant::now();

    let mut last = vec![0; TYPE_COUNT];

    let mut ans = vec![];

    for s in ss.iter() {
        let mut max = 0;
        let mut index = 0;
        for (i, &x) in s.iter().enumerate() {
            let x = x + cc[i] * last[i] * 5;
            if max < x {
                max = x;
                index = i;
            }
        }
        for l in last.iter_mut() {
            *l += 1;
        }
        last[index] = 0;
        ans.push(index);
    }

    let mut score = calc_score(&cc, &ss, &ans);
    let mut rng = thread_rng();

    while Instant::now().duration_since(start) < Duration::from_millis(1900) {
        let mut dts = vec![];
        let mut olds = vec![];

        for _ in 0..(d/11)+1 {
            let day = rng.gen_range(0, d);
            let ty = rng.gen_range(0, 26);
            dts.push((day, ty));
            let old = ans[day];
            ans[day] = ty;
            olds.push((day, old));
        }

        let new_score = calc_score(&cc, &ss, &ans);
        if new_score < score {
            for (day, old) in olds.into_iter().rev() {
                ans[day] = old;
            }
        } else {
            score = new_score;
        }
    }

    for x in ans {
        println!("{}", x+1);
    }
    
}

fn calc_score(cc: &Vec<usize>, ss: &Vec<Vec<usize>>, tt: &Vec<usize>) -> isize {
    let mut last = vec![0; TYPE_COUNT];

    let mut v = 0;
    for (s, &t) in ss.iter().zip(tt.iter()) {
        v += s[t] as isize;
        for l in last.iter_mut() {
            *l += 1;
        }
        last[t] = 0;
        v -= last.iter().zip(cc.iter()).map(|(&l, &c)| (l * c) as isize).sum::<isize>();
    }
    v
}

Measured memory_bytes: 2780
#include<bits/stdc++.h>
using namespace std;
#define inf 1e9
#define ll long long
#define ull unsigned long long
#define M 1000000007
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define RFOR(i,m,n) for(int i=m;i>=n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265

int n;
int a[1000000];
int x=0;

int main(){
  cin>>n;
  rep(i,n){
    cin>>a[i];
    x = x^a[i];
  }

  int ans=0;
  for (int k=30; k>=1; k--) {
    if (x == 0) break;
    if (!(x>>(k-1) & 1)) continue;
 
    for (size_t i=0; i<n; ++i) {
      if ((a[i]^(a[i]-1)) == (1<<k)-1) {
        x ^= (1<<k)-1;
        ans++;
        a[i] = 0;  
        break;
      }
    }
  }


  if(x!=0){
    cout<<-1<<endl;
  }
  else{
    cout<<ans<<endl;
  }

  return 0;
}

Measured memory_bytes: 640
#include <algorithm>
#include <cstdio>
const int MAXN = 305;
int A[MAXN][MAXN];
int G[MAXN][MAXN];
int L, M, N, Q;

void build_graph() {
    for (int i = 1; i <= N; ++i) {
        for (int j = 1; j <= N; ++j) {
            if (G[i][j] <= L) {
                A[i][j] = 1;
            } else {
                A[i][j] = MAXN;
            }
        }
    }
}

void init() {
    for (int i = 1; i <= N; ++i) {
        for (int j = 1; j <= N; ++j) {
            if (i == j) {
                G[i][j] = 0;
            } else {
                G[i][j] = L + 1;
            }
        }
    }
}

void floyd_warshall(int (&E)[MAXN][MAXN]) {
    for (int k = 1; k <= N; ++k) {
        for (int i = 1; i <= N; ++i) {
            for (int j = 1; j <= N; ++j) {
                E[i][j] = std::min(E[i][k] + E[k][j], E[i][j]);
            }
        }
    }
}

int main() {
    scanf(" %d%d%d", &N, &M, &L);
    init();
    for (int i = 0; i < M; ++i) {
        int a, b, c;
        scanf(" %d%d%d", &a, &b, &c);
        G[a][b] = G[b][a] = c;
    }
    floyd_warshall(G);
    build_graph();
    floyd_warshall(A);
    scanf("%d", &Q);
    for (int q = 0; q < Q; ++q) {
        int s, t;
        scanf(" %d%d", &s, &t);
        if (A[s][t] < MAXN) {
            printf("%d\n", A[s][t] - 1);
        } else {
            puts("-1");
        }
    }
    return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define pi 3.14159
using namespace std;

int main()
 {
 	long long int  x;
	cin >> x;
	int c = 0;
	long long int  a = 100;
	while(a<x) {
		a += a/100;
		c++;
	}
	cout << c << endl;	
 		
 	return 0;
 }

Measured memory_bytes: 3512
#include <bits/stdc++.h>
using namespace std;
vector<vector<int>> G;
vector<int> edge_origin, passed_order;
int order(0);

void solve(int node, int parent){
	if(passed_order[node]) return ;
	passed_order[node] = ++order;
	for(int neighbor : G[node]){
		if(neighbor == parent) continue;
		if(passed_order[neighbor]){
			if(passed_order[node] > passed_order[neighbor]){
				edge_origin[node]++;
				cout<<node<<" "<<neighbor<<endl;
			}
		} else {
			solve(neighbor , node);
		}
	}
	if(parent == -1) return;
	if(edge_origin[node]%2){
		cout << node << " " << parent << endl;
		edge_origin[node]++;
	} else {
		cout<<parent<<" "<<node<<endl;
		edge_origin[parent]++;
	}
}
int main(){	
	int N, M;
	cin >> N >> M;
    if(M%2 != 0){
		cout<< -1 <<endl;
		return 0;
	}
    G.resize(N+1);
    edge_origin.resize(N+1);
	passed_order.resize(N+1);
	int a, b;
	for(int i(0); i < M; ++i){
		cin >> a >> b;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	solve(1,-1);
	return 0;
}

Measured memory_bytes: 15488
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<functional>
#include<math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pf(n) printf("%d\n",n)
#define pff(a,b) printf("%d  %d\n",a,b);
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1001001001;
const double PI = acos(-1);

int main() {
	ll l, r;
	cin >> l >> r;

	ll ans = 1001001;
	if (r - l >= 2019) {
		ans = 0;
	}
	else {
		for (ll i = l; i < r; i++) {
			for (ll j = i + 1; j <= r; j++) {
				ans = min(ans, (i*j) % 2019);
			}
		}
	}
	cout << ans << endl;

	return 0;
}

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

using namespace std;
using ll = long long;

//container util
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)


int main(void){

	int A1, A2, A3; cin >> A1 >> A2 >> A3;
	
	if(A1+A2+A3 <= 21) cout << "win" << endl;
	else cout << "bust" << endl;


	return 0;

}


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

int solve(vector<string> &s) {

    int larb = 0;
    int la = 0;
    int rb = 0;
    int ab = 0;

    for (string si: s) {
        if (si.front() == 'B' and si.back() == 'A') {
            larb++;  // c1
        }

        if (si.front() == 'B' and si.back() != 'A') la++; // c2
        if (si.front() != 'B' and si.back() == 'A') rb++; // c3

        for (int j=0; j<si.size()-1; j++) {
            if (si[j] == 'A' and si[j+1] == 'B') ab++;
        }
    }


    int ans = ab;
    if (larb == 0) {
        ans += min(la, rb);
    }
    else {
        if (la + rb > 0) {
            ans += larb + min(la, rb);
        }
        else {
            ans += larb - 1;
        }
    }

    return ans;
}

int main() {
    int n; cin >> n;
    vector<string> s(n); for(int i=0; i<n; i++) cin >> s[i];
    cout << solve(s) << endl;
    return 0;
}


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

using namespace std;
 
int N;
char ans[20];
int num;
 
int main() {
    cin >> N;
    while (N != 0) {
        if (N % 3 == 0) {
            ans[num++] = '0';
        }
        else if (N % 3 == 1) {
            ans[num++] = '+';
            N--;
        }
        else {
            ans[num++] = '-';
            N++;
        }
        N /= 3;
    }
    for (int i = num-1; i >= 0; i--) {
        cout << ans[i];
    }
    cout << "\n";
    return 0;
}

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

def main():
    N = int(input())
    x = list(map(int, input().split()))
    y = list(map(int, input().split()))
    x_y = [abs(i - j) for i, j in zip(x, y)]
    
    for p in range(1, 4):
        tmp = 0
        for i in range(N):
            tmp += pow(x_y[i], p)
        print(pow(tmp, 1/p))
    print(max(x_y))




if __name__ == "__main__":
    main()


Measured memory_bytes: 5652
import math
 
 
def insertionsort(A, n, g):
    cnt = 0
    for i in range(g, n):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j + g] = A[j]
            j = j - g
            cnt += 1
        A[j + g] = v
    return cnt
 
 
def shellsort(A, n):
    G = []         
    gap = 1
    while gap <= math.ceil(n / 3):
        G.append(gap)
        gap = gap * 3 + 1
    G = G[::-1]
    m = len(G)
    print(m)
    print(*G)
    cnt = 0
    for i in range(m):
        cnt += insertionsort(A, n, G[i])
    print(cnt)
 
 
n = int(input())
A = []
for i in range(n):
    A.append(int(input()))
shellsort(A, n)
for i in range(n):
    print(A[i])

Measured memory_bytes: 47524
#include <bits/stdc++.h>
#define rep(i,N) for(int i=0;i<N;i++)
using namespace std;
long long  INF=1000000000000000000;
long long mod=1000000007;
using namespace std;


int main(){

long long  N;
cin>>N;

for(double x=1;x<=N;x++){
    if(N==floor(x*1.08)){
        cout<<x<<endl;
        return 0;
    }
}
cout<<":("<<endl;


 return 0;
}
/*
432

400

1079

:(


1001

927

*/

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

YES = "Yes"  # type: str
NO = "No"  # type: str

def solve(S: str):
    print(YES if len(set(S)) == 3 else NO)


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()


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

int main() {
  int N, K, sum = 1;
  cin >> N >> K;
  
  for (int i = 0; i < N; i++){
    if (sum*2 < (sum+K)){
      sum *= 2;
    }
    else{
      sum += K;
    }
  }
  
  cout << sum << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
        String[] inputs = input.readLine().split(" ");


        int a = Integer.parseInt(inputs[0]);
        int b = Integer.parseInt(inputs[1]);
        int c = Integer.parseInt(inputs[2]);

        if (a==b) {
            if (b==c) {
                System.out.println(1);
            } else {
                System.out.println(2);
            }
        } else {
            if (b==c) {
                System.out.println(2);
            } else if (a==c){
                System.out.println(2);
            } else {
                System.out.println(3);
            }
        }
    }
}


Measured memory_bytes: 22996
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) ((int)(x).size())
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

const int mod=1e9+7;
int dp[101][5][5][5];

signed main()
{
    int N; cin>>N;

    dp[0][4][4][4]=1;
    for(int i=0;i<N;i++){ 
        REP(x,5) REP(y,5) REP(z,5) REP(j,4){
            if(y==0 and z==1 and j==2) continue;
            if(y==0 and z==2 and j==1) continue;
            if(y==1 and z==0 and j==2) continue;

            if(x==0 and y==1 and j==2) continue;
            if(x==0 and z==1 and j==2) continue;

            dp[i+1][y][z][j]+=dp[i][x][y][z];
            dp[i+1][y][z][j]%=mod;
        }
    }
    int ans=0;
    REP(x,4) REP(y,4) REP(z,4) ans=(ans+dp[N][x][y][z])%mod;
    cout<<ans<<endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
long long inf=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
long long gcd(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd(b,a%b);
  }
}
 
long long lcm(long long x, long long y){
  return (x/gcd(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};
 
int main(){
  string o,e;
  cin>>o;
  cin>>e;
  int n;
  n=o.size()+e.size();
  string s="";
  REP(i,n){
    if(i%2==0){
      s += o[i/2];
    }else{
      s += e[(i-1)/2];
    }
  }
  cout<<s<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define REP(i, d, n) for(int i=(d); i<(n); ++i)
#define all(v) v.begin(), v.end()
using ll = long long;
using P = pair<int, int>;

int main() {

	int n;
	string s;
	cin >> n >> s;

	if(count(s.begin(), s.end(), 'R') > count(s.begin(), s.end(), 'B')){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>


long gcd(long a,long b)
{
        if(a%b==0)
                return b;
        else
                return gcd(b,a%b);
}
int main(void)
{
        long a,b;

        scanf("%ld%ld",&a,&b);

        printf("%ld",a*b/gcd(a,b));
        return 0;
}


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

int main()
{
    int sq[1005],i;
    for(i=0;i<1005;i++) sq[i]=i*i;
    string a,b;
    cin>>a>>b;
    int x=a.size()+b.size()-1;
    int n=0;
    for(i=0;i<a.size();i++)
    {
        int p=a[i]-'0';
        n=n+(p*pow(10,x))+.5;
        x--;
        //cout<<n<<"\n";
    }
    for(i=0;i<b.size();i++)
    {
        int p=b[i]-'0';
        //cout<<p<<" ";
        n=n+(p*pow(10,x))+.5;
        x--;
        //cout<<n<<"\n";
    }
    //cout<<n<<"\n";
    //cout<<a<<" "<<b<<"\n";
    //cout<<x;
    bool ch=0;
    for(i=0;i<1005;i++)
    {
        if(sq[i]==n)
        {
            printf("Yes\n");
            ch=1;
            break;
        }
    }
    if(ch==0) cout<<"No\n";
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define endl '\n'
#define int long long
#define eps 1e-9
#define oo 1e7+5

using namespace std;

typedef unsigned long long ull;
typedef vector<pair<int,pair<int,int>>> dirgraph;
typedef vector<vector<int>> graph;

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

	int n,w;
	cin>>n>>w;
	vector<int> weights(w+1);
	
	for (int i = 0; i < n; i++)
	{
		int value,weight;
		cin>>weight>>value;
		
		for (int old_weight = w-weight;old_weight>=0;old_weight--)
		{
			weights[old_weight+weight]=max(weights[old_weight+weight],
			weights[old_weight]+value);
		}
		
		
	}

	int ans=0;
	for (int i = 0; i < w+1; i++)
	{
		ans=max(ans,weights[i]);
	}
	cout<<ans<<endl;

	return 0;
}



Measured memory_bytes: 1024
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,j,n) for(int i = j; i < n; i++)
#define rrep(i,j,n) for(int i = j-1; i >= n; i--)
#define prec(n) fixed << setprecision(n)
#define print_array(v) rep(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define fi first
#define se second
#define endl "\n"
using namespace std;

constexpr int inf = 2147483647;
constexpr int64_t inf64 = 9223372036854775807;
constexpr int mod = 1e9+7;
double pi = acos(-1);

double PiDegree(double h, double m) {
  h *= 30;
  h += m/2;
  m *= 6;
  return abs(h-m) * pi / 180;
}

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

  double a, b, h, w;
  cin >> a >> b >> h >> w;

  double A = PiDegree(h, w);
  double res = a*a + b*b - 2*a*b*cos(A);
  cout << prec(20) << sqrt(res) << endl;
  return 0;
}

Measured memory_bytes: 4192
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define endl '\n'
#define pb push_back
#define mod 1000000007
#define all(v) v.begin(),v.end()
#define mm memset
#define PI 3.14159265358979323846264338327950288419716939937510
#define M 998244353 
#define MAXN   20000001 
#define ll long long int

void solve(){

  ll n;
  cin>>n;
  string s="";
  while(n>=1){
    ll rem=(n-1)/26;
    s+=(((n-1)%26)+'a');
    n=rem;
  }
  reverse(all(s));
  cout<<s<<endl;
}

int main() {

  #ifndef ONLINE_JUDGE
    freopen("./input.txt", "r", stdin  );
  #endif   
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll t=1;
   // cin>>t;
    for(ll i=0;i<t;i++){
      solve();
    }
    return 0;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
  long a,b,k,memo; cin>>a>>b>>k; memo=0;
  long a1,a2;
  a1=a; a2=a;
  a=a-k; if(a<0) a=0;
  memo=k-a1; if(memo<0) memo=0;
  b=b-memo; if(b<0) b=0;
  cout<<a<<" "<<b<<endl;
}


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

int dp[1001][1001][3];
int M, N, K;
int a, b, c, d;

int solve(int a, int b, int c, int d, int t){
  int ret = 0;
  for(int i = a; i <= c; i++){
    ret += dp[i][d][t] - dp[i][b-1][t];
  }
  return ret;
}

int main(void){
  cin >> M >> N;
  cin >> K;
  for(int i = 1; i <= M; i++){
    for(int j = 1; j <= N; j++){
      char c;
      cin >> c;
      if(c == 'J') dp[i][j][0]++;
      if(c == 'O') dp[i][j][1]++;
      if(c == 'I') dp[i][j][2]++;
      for(int k = 0; k < 3; k++){
        dp[i][j][k] += dp[i][j-1][k];
      }
    }
  }

  for(int k = 0; k < K; k++){
    int j, o, i;
    cin >> a >> b >> c >> d;
    j = solve(a, b, c, d, 0);
    o = solve(a, b, c, d, 1);
    i = solve(a, b, c, d, 2);
    cout << j << " " << o << " " << i << endl;
  }
  return 0;
}

Measured memory_bytes: 12772
#include<cstdio>
#include<cstring>
#include<algorithm>
#define ll long long
using namespace std;
const int N=2000100,mod=1e8;
inline int read(){
    int x=0,c=getchar(),f=0;
    for(;c>'9'||c<'0';f=c=='-',c=getchar());
    for(;c>='0'&&c<='9';c=getchar())
    x=(x<<1)+(x<<3)+c-'0';return f?-x:x;
}
void write(ll x){
    if(x>9)write(x/10);
    putchar(x%10+'0');
}
int i,a,b,ans;
int main(){
	for(i=1;i<=2;i++){
		a=read();b=read();
		ans=max(ans,a*b);
	}printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;

P StoP(string a){
  int top=0,first=0;
  for(int i=0;i<a.size();i++){
    if(a[i]=='(') top++;
    else if(top) top--;
    else first++;
  }
  return P(first,top);
}

int main(){
  int n;
  cin>>n;
  
  P p[101];
  int cnt=0;
  for(int i=0;i<n;i++){
    string tmp;
    cin>>tmp;
    p[i]=StoP(tmp);
    if(!p[i].second) cnt+=p[i].first,i--,n--;
  }


  bool ans=1,used[101]={};
  int top=0;
  for(int i=0;i<n&&ans;i++){
    int idx=-1,mx=-110;
    for(int j=0;j<n;j++){
      if(used[j]||top-p[j].first<0)continue;
      int k=p[j].second-p[j].first;
      if(mx<k) mx=k,idx=j;
    }
    if(idx==-1) ans=0;
    top+=mx;
    used[idx]=1;
  }
  cout<<(ans&&!(top-cnt)? "Yes":"No")<<endl;
	
  
  return 0;
}


Measured memory_bytes: 3196
// Author : Chi
// created :
//header files
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

//macros
#define ll 		    long long
#define ss          second
#define ff          first
#define vi          vector<int>
#define vll         vector<long long>
#define pb          push_back
#define TEST  	    int TesT;cin>>TesT;while(TesT--)solve();
#define TEST1       solve();
#define mod         1000000007
#define r0n(i,n)    for(ll i = 0; i < n; ++i)
#define r1n(i,n)    for(ll i = 1; i <= n; ++i)
#define pdp(d,i)    fixed<<setprecision(i)<<d
#define CHI         ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
//namespaces
using    namespace __gnu_pbds;
using    namespace std;
typedef tree <int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update > ordered_set;
typedef struct item{
   int v,w;
}I;
void solve(){
    int n,w;
    cin>>n>>w;
    I it[n+1];
    for(int i=1;i<=n;i++)
        cin>>it[i].w>>it[i].v;
    int maxval= 100000;
    int dp[n+1][maxval+1];
    dp[0][0]=0;
    for(int i=1;i<=maxval;i++)
        dp[0][i]=1e9+1;
    for(int i=1;i<=n;i++){
        for(int j=0;j<=maxval;j++){
            dp[i][j]=dp[i-1][j];
            if(it[i].v <= j){
                dp[i][j]=min(dp[i][j],dp[i-1][j-it[i].v]+it[i].w);
            }
            }
    }
    int ans=0;
    for(int i=0;i<=maxval;i++){
        if(dp[n][i] <= w)
            ans=i;
    }
    cout<<ans;
}

// Driver Code
int main(){
    TEST1
    return 0;
}


Measured memory_bytes: 39680
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())

template <class T>
void cout_vec(const vector<T> &vec1){
  rep(i,len(vec1)){
    cout<<vec1[i]<<' ';
  }
  cout<<'\n';
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,t;
    cin>>n>>t;
    vector<ll> a(n),ma(n+1,0);
    rep(i,n) cin>>a[i];
    for(ll i=n-1;i>=0;i--){
      ma[i]=max(ma[i+1],a[i]);
    }
    ll ans=0,cnt=0;
    rep(i,n){
      if(ans<ma[i+1]-a[i]) ans=ma[i+1]-a[i];
    }
    rep(i,n){
      if(ans==ma[i+1]-a[i]) cnt++;
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>

template <int MOD>
struct ModInt {
    using lint = long long;
    int val;

    // constructor
    ModInt(lint v = 0) : val(v % MOD) {
        if (val < 0) val += MOD;
    };

    // unary operator
    ModInt operator+() const { return ModInt(val); }
    ModInt operator-() const { return ModInt(MOD - val); }
    ModInt inv() const { return this->pow(MOD - 2); }

    // arithmetic
    ModInt operator+(const ModInt& x) const { return ModInt(*this) += x; }
    ModInt operator-(const ModInt& x) const { return ModInt(*this) -= x; }
    ModInt operator*(const ModInt& x) const { return ModInt(*this) *= x; }
    ModInt operator/(const ModInt& x) const { return ModInt(*this) /= x; }
    ModInt pow(lint n) const {
        auto x = ModInt(1);
        auto b = *this;
        while (n > 0) {
            if (n & 1) x *= b;
            n >>= 1;
            b *= b;
        }
        return x;
    }

    // compound assignment
    ModInt& operator+=(const ModInt& x) {
        if ((val += x.val) >= MOD) val -= MOD;
        return *this;
    }
    ModInt& operator-=(const ModInt& x) {
        if ((val -= x.val) < 0) val += MOD;
        return *this;
    }
    ModInt& operator*=(const ModInt& x) {
        val = lint(val) * x.val % MOD;
        return *this;
    }
    ModInt& operator/=(const ModInt& x) { return *this *= x.inv(); }

    // compare
    bool operator==(const ModInt& b) const { return val == b.val; }
    bool operator!=(const ModInt& b) const { return val != b.val; }

    // I/O
    friend std::istream& operator>>(std::istream& is, ModInt& x) noexcept { return is >> x.val; }
    friend std::ostream& operator<<(std::ostream& os, const ModInt& x) noexcept { return os << x.val; }
};

constexpr int MOD = 998244353;
using mint = ModInt<MOD>;

template <class T>
struct Combination {
    int max_n;
    std::vector<T> f, invf;

    explicit Combination(int n)
        : max_n(n), f(n + 1), invf(n + 1) {
        f[0] = 1;
        for (int i = 1; i <= n; ++i) {
            f[i] = f[i - 1] * i;
        }

        invf[max_n] = f[max_n].inv();
        for (int i = max_n - 1; i >= 0; --i) {
            invf[i] = invf[i + 1] * (i + 1);
        }
    }

    T fact(int n) const { return f[n]; }
    T invfact(int n) const { return invf[n]; }
    T perm(int a, int b) const {
        return a < b || b < 0 ? T(0) : f[a] * invf[a - b];
    }
    T comb(int a, int b) const {
        return a < b || b < 0 ? T(0) : f[a] * invf[a - b] * invf[b];
    }
};

const Combination<mint> C(1000000);

void solve() {
    int n, m, k;
    std::cin >> n >> m >> k;

    mint ans = 0;
    for (int i = n; n - i <= k; --i) {
        ans += C.comb(n - 1, i - 1) * m * mint(m - 1).pow(i - 1);
    }
    std::cout << ans << std::endl;
}

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

    solve();

    return 0;
}


Measured memory_bytes: 10988
#include<stdio.h>
#include<ctype.h>
int main(){
  int i,x;
  int count[26]={0};
  char c,ch;
  while(scanf("%c",&c)!=EOF){
    ch=tolower(c);
    x=ch-'a';
    count[x]=count[x]+1;
    }
  for(i=0;i<26;i++){
    printf("%c : %d\n",'a'+i,count[i]);}
  return 0;}

Measured memory_bytes: 544
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
const ll INF=1e18;
const int MOD=1e9+7;
const double pi=acos(-1);

int main(){
  int d,n;
  cin >> d >> n;
  if(d==0){
    if(n==100)cout << 101 << endl;
    else cout << n << endl;
  }
  if(d==1){
    if(n==100)cout << 10100 << endl;
    else cout << n*100 << endl;
  }
  if(d==2){
    if(n==100)cout << 1010000 << endl;
    else cout << n*10000 << endl;
  }
  
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<bitset>

using namespace std;

const int MAXR = 15, MAXC = 10000+100;
int mapp[MAXR][MAXC];
int r, c;


int main()
{
    while(scanf("%d%d", &r, &c) == 2 && r && c)
    {
        for(int i=0; i<r; ++i)
        {
            for(int j=0; j<c; ++j)
            {
                scanf("%d", &mapp[i][j]);
            }
        }
        int ans = 0;
        bitset<32> bs;
        for(int i=0; i<r; i++) bs[i] = 1;
        int m = bs.to_ulong();
        for(unsigned int i=0; i<=m; i++)
        {
            bs = i;
            int cnt = 0;
            for(int j=0; j<c; j++)
            {
                int cnt1 = 0, cnt0 = 0;
                for(int k=0; k<r; k++)
                {
                    if(mapp[k][j] && bs[k]==0) cnt1++;
                    else if(!mapp[k][j] && bs[k]) cnt1++;
                    else cnt0++;
                }
                cnt+= max(cnt1, cnt0);
            }
            ans = max(ans, cnt);
        }
        cout << ans << endl;
    }


    return 0;
}

Measured memory_bytes: 3516
import sys

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inm = lambda: map(int, sys.stdin.readline().split())
inl = lambda: list(inm())
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))

N = ini()


def solve():
    n = N
    d = 0
    while n:
        d += n % 10
        n //= 10
    return N % d == 0


print("Yes" if solve() else "No")


Measured memory_bytes: 9088
#include <stdio.h>
#include <iostream>
#include <vector>
#include <assert.h>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <stack>
#include <bitset>
#include <string>
#include <sstream>
#include <memory.h>
#include <time.h>
#include <string.h>
#include <stdlib.h>
#include <functional>
#include <algorithm>
using namespace std;
typedef long long ll;
int main()
{
	int n;
	scanf("%d",&n);
	map<int,int> f;
	for(int i=0;i<n;++i){
		int x;
		scanf("%d",&x);
		++f[x];
	}
	pair<int,int> last(0,0);
	int res=0;
	for(auto it=f.rbegin();it!=f.rend();++it){
		auto cur=*it;
		cur.second+=last.second;
		if(last.first && (last.first - cur.first-1)%2==1)
			res^=last.second;
		res^=cur.second;
		last=cur;
	}
	if(last.first%2==0)
		res^=last.second;
	if(res)
		puts("first");
	else
		puts("second");
	return 0;
}

Measured memory_bytes: 4992
#include <stdio.h>
#include <stdlib.h>
typedef long long ll;

ll n, m;
ll a[100005];

ll ans;

int cmp(const ll *x, const ll *y);

int main()
{
	scanf("%lld %lld", &n, &m);
	for (ll i = 1; i <= n; i++) {
		scanf("%lld", &a[i]);
	}

	for (ll i = 1; i <= n; i++) {
		a[i] += a[i - 1];
		a[i] %= m;
	}

	qsort(a + 1, n, sizeof(ll), (int (*)(const void *, const void *))cmp);

	a[n + 1] = -1;
	ll i = 0;
	while (i <= n) {
		ll cnt = 1;

		while (a[i] == a[i + 1]) {
			i++;
			cnt++;
		}

		ans += cnt * (cnt - 1) / 2;
		i++;
	}

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

	return 0;
}

int cmp(const ll *x, const ll *y)
{
	if (*x > *y) {
		return 1;
	} else if (*x == *y) {
		return 0;
	} else {
		return -1;
	}
}


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



int main(){
    int N;
    cin >> N;
    std::vector<string> words(N);

    for(int i=0; i < N; i++){
        cin >> words.at(i);
    }
    std::map<std::string, int> counter;
    string tmp_str;
    long long cnt = 0LL;
    for(int i=0; i < N; i++){
        tmp_str = words.at(i);
        sort(tmp_str.begin(), tmp_str.end());
        if(counter[tmp_str]>=0){
            cnt += counter[tmp_str];
            counter[tmp_str] ++;

        }
    }
    // for (auto word : counter){
    //     cnt += word.second*(word.second-1)/2;
    // }
    cout << cnt << endl;
}


Measured memory_bytes: 18176
#include<bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define lli long long int
#define f(i,a,b) for(i=a;i<b;i++)
#define ff first
#define sc second
#define pb push_back
#define full(v) v.begin(),v.end()
#define ms(a) memset(a,0,sizeof(a))
#define mod 1000000007
#define mod2 998244353
#define msb(b) memset(b,true,sizeof(b))
#define msf(b) memset(b,false,sizeof(b))
#define MAXN 100005
// bool prime[1000000]; // 10**6
// lli pri[100000],x=0;
/*void sieve()
{
  msb(prime);
  prime[0]=prime[1]=false;
  for(int p=2;p*p<=1000000;p++)
  {
    if(prime[p])
    {
      for(int i=p*2;i<=1000000;i+=p)
        prime[i]=false;
      // a[x++]=p;
    }
  }
} */

int main()
{
    fio;
    int t,n,i;
    cin >> n;
    cout << 1000*(ceil((float)n/1000)) - n << endl;
}


Measured memory_bytes: 3744
N = int(input())
A = list(map(int, input().split()))

n, r = max(A), None
A.pop(A.index(n))
target, best_score = n / 2, float('inf')
for a in A:
    score = abs(a - target)
    if score < best_score:
        best_score = score
        r = a

print(n, r)


Measured memory_bytes: 14428
#include "bits/stdc++.h"
using namespace std;

int main() {
   int k, n, inp;
   cin >> k >> n;
   vector <int> a;
   cin >> inp;
   a.push_back(inp);
   int mx = -1, mxi = -1, last;
   for(int i = 1;i < n; i++)  {
       cin >> inp;
       if(i == n-1) last = inp;
       a.push_back(inp);
       if(mx < inp-a[i-1]) {
           mx = inp-a[i-1];
       }
   }
   int out  = k - last + a[0];
//    cout << mx << " " << out << endl;
   if(mx > out) {
       cout << k - mx;
   } else {
       cout << k - out;
   }
}

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

int main(){
  int a = 0;
  int b = 0;
  cin >> a >> b;
  if(a < 9 && b < 9){
    cout << "Yay!" << endl;
  }else{
    cout << ":(" << endl;
  }
}           

Measured memory_bytes: 256