akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int f[2001] = {0};

int main(){
	for(int i = 0; i <= 1000; i++){
		for(int j = 0; j <= 1000; j++){
			f[i + j]++;
		}
	}
	int n;
	while( cin >> n ){
		int ans = 0;
		for(int i = 0; i <= 1000; i++){
			if( n < i ) break;
			for(int j = 0; j <= 1000; j++){
				if( n < i + j ) break;
				int x = n - i - j;
				if( 0 <= x && x <= 2000 ) ans += f[x];
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 1172
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int main()
{
	int n;
	deque<int> b;
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		int a;
		scanf("%d",&a);
		if(i%2)
			b.push_back(a);
		else
			b.push_front(a);
	}
	while(!b.empty())
	{
		if(b.size()!=n)printf(" ");
		if(n%2)
		{
			printf("%d",b.front());
			b.pop_front();
		}
		else
		{
			printf("%d",b.back());
			b.pop_back();
		}
	}
	puts("");
}


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

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

    int64_t A;
    double B;
    cin >> A >> B;
    B *= 100;
    __int128 BB = (int64_t)round(B);
    A *= 100;

    // cout << A << " " << BB << endl;

    __int128 r = (__int128)A*BB;

    cout << (int64_t)(r/10000) << endl;

}

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

using namespace std;

int W,a,b,FV,SV,zero;

int main() {
    cin>>W>>a>>b;
    zero=0;
    FV=b-(W+a);
    SV=a-(W+b);
    {if(FV>zero)
     cout<<FV<<endl;
     else if(SV>zero)
     cout<<SV<<endl;
     else
     cout<<zero<<endl;
    }
           }


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep3(i, l, n) for (int i = l; i < n; ++i)
#define max(a, b) (a > b ? a : b)
#define min(a, b) (a < b ? a : b)
#define chmax(a, b) a = (a >= b ? a : b)
#define chmin(a, b) a = (a <= b ? a : b)
#define out(a) cout << a << endl
#define outa(a, n) { rep(_, n) cout << a[_] << " "; cout << endl; }
#define outp(a, n) { cout << endl; rep(_, n) cout << a[_].F << " " << a[_].S << endl; }
#define SZ(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
#define FIX(a) fixed << setprecision(a)
#define LB(v, n) (int)(lower_bound(all(v), n) - v.begin())
#define UB(v, n) (int)(upper_bound(all(v), n) - v.begin())

int main() {
    int n;
    cin >> n;
    ll a[n], b[n];
    rep(i, n) cin >> a[i] >> b[i];
    
    ll sum = 0;
    for (int i = n - 1; i >= 0; --i) {
        a[i] += sum;
        // cout << endl; outa(a, n);
        ll tmp = 0;
        if (a[i] % b[i] != 0) tmp = b[i] - a[i] % b[i];
        sum += tmp;
        a[i] += tmp;
        // outa(a, n);
    }
    
    out(sum);
}


Measured memory_bytes: 1920
#include <iostream>
using namespace std;
int main(void){
    
    int counter[26];
    for(int i=0;i<26;i++){
        counter[i]=0;
    }
    
    char ch;
    while(cin>>ch){
        int num = tolower(ch) - 'a';
        counter[num]++;
    }
    
    for(int i=0;i<26;i++){
        ch = i + 'a';
        cout << ch << " : " << counter[i] << endl;
    }

}

Measured memory_bytes: 1140
#include <stdio.h>

int main(void)
{
	int r, c, data[101][101] = {0};
	int i, j;

	scanf("%d %d", &r, &c);
	for(i=0;i<r;i++){
		for(j=0;j<c;j++){
			scanf("%d", &data[i][j]);
			data[i][c] += data[i][j];

			data[r][j] += data[i][j];
		}
		data[r][c] += data[i][j];

	}

	for(i=0;i<=r;i++){
		for(j=0;j<c;j++)
			printf("%d ", data[i][j]);
		printf("%d\n", data[i][j]);
	}
	return 0;
}

Measured memory_bytes: 648
/*町xi 最大の利益　yi
yi,y2...最大値だけを全部少なくとも１引いたら1円は減る*/
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>

// ===============================================================

using namespace std;
using ll = long long;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using vs = vector<string>;
using vc = vector<char>;
using vcc = vector<vector<char>>;
using vm = vector<short>;
using vmm = vector<vector<short>>;
using pii = pair<int, int>;
using psi = pair<string, int>;
using ld = long double;
using ull = unsigned long long;
using ld = long double;

// ========================================================================



ll gcd(ll a, ll b)
{
	if (a % b == 0)
	{
		return(b);
	}
	else
	{
		return(gcd(b, a % b));
	}
}
//最大公約数
ll lcm(ll a, ll b)
{
	return a * b / gcd(a, b);
}
//最小公倍数
ll box(double a)
{
	ll b = a;
	return b;
}
//切り捨て
ll fff(double a)
{
	ll b = a + 0.5;
	return b;
}
//四捨五入
ll sum(ll n) {
	return (1 + n) * n / 2;
}
//1から整数nまでの合計を出す
ll mch(ll n) {
	if (n == 1) return 1;
	else return n * mch(n - 1);
}
//1から整数nまでの階乗を出す(INFで割っていない)
bool prime(ll a)//素数判定、primeならtrue,違うならfalse
{
	if (a < 2) return false;
	else if (a == 2) return true;
	else if (a % 2 == 0) return false;
	double m = sqrt(a);
	for (int i = 3; i <= m; i += 2)
	{
		if (a % i == 0)
		{
			return false;
		}
	}

	// 素数である
	return true;
}
//素数判定
ll modpow(ll a, ll n, ll mod) {
	ll hi = 1;
	while (n > 0) {
		if (n & 1) hi = hi * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return hi;
}
//いろいろやります（ただの前座）
ll mg(ll a, ll mod) {
	return modpow(a, mod - 2, mod);
}
//割り算の10^9+7等対策で逆元を出します 
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;
}
ll cnt = 0;
//#define int long long;


// ========================================================================


/*signed*/int main() {
	ll n, t; cin >> n >> t;
	vl a(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	vl b(n);
	b[0] = a[0];
	for (int i = 0; i < n; i++) {
		if (i != 0) {
			b[i] = min(b[i - 1], a[i]);
		}
	}
	vl c(n);
	for (int i = 0; i < n; i++) {
		c[i] = a[i] - b[i];
	}
	sort(c.begin(), c.end());
	ll ans = 1;
	for (int i = n - 1; i >= 0; i--) {
		if (c[i] == c[i - 1]) ans++;
		else break;
	}
	cout << ans << endl;
	
	return 0;
}

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

int x, y, ans;

int main() {
    cin >> x >> y;
    ans = abs(abs(x) - abs(y));
    if (x > 0 && y > 0) {
        if (x > y) ans += 2;
    } else if (x > 0 && y < 0) {
        ans++;
    } else if (x < 0 && y > 0) {
        ans++;
    } else if (x < 0 && y < 0) {
        if (x > y) ans += 2;
    } else if (x == 0 && y < 0) {
        ans++;
    } else if (x > 0 && y == 0) {
        ans++;
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
n = int(input())
A = list(map(int, input().split()))

print(' '.join(list(map(str, A))))
for i in range(1,n):
    key = A[i]
    j = i - 1
    while j >= 0 and A[j] > key:
        A[j+1] = A[j]
        j -= 1
    A[j+1] = key
    print(' '.join(list(map(str, A))))

Measured memory_bytes: 7708
//g++ -std=c++14 test.cpp -o test.out
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <utility>
#include <limits.h>
using namespace std;

int N;
long A[200000];

string ans = "YES";

void solve(){
	sort(A,A+N);
	for(int i=0;i<N-1;i++){
		if(A[i]==A[i+1]){
			ans = "NO";
			return;
		}
	}
}
 
int main(){
	cin >> N;
	for(int i=0;i<N;i++) cin >> A[i];
 
	solve();

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


Measured memory_bytes: 1792
from sys import stdout
printn = lambda x: stdout.write(x)
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
DBG = True # and False
BIG = 999999999
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

a = inn()
b = inn()
if a in [1,2] and b in [1,2]:
    print(3)
    exit()
if a in [1,3] and b in [1,3]:
    print(2)
    exit()
print(1)


Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		
		if(X == 7 || X == 5 || X == 3) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}

	}

}

Measured memory_bytes: 23124
#exec({'RUBY_THREAD_VM_STACK_SIZE'=>'100000000'},'/usr/bin/ruby', $0) if !ENV['RUBY_THREAD_VM_STACK_SIZE']

def inpf() a=gets.chomp.split(" ").map(&:to_f)end

def inps() a=gets.chomp.split(" ")end

def copy(a) Marshal.load(Marshal.dump(a)) end

def kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r} end

def na(n,d=0) Array.new(n,d)end

def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end

def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end

def inp() a=gets.chomp.split(" ").map(&:to_i)end

def r_up(a, b) (a+b-1)/b end

def sum(a) a.inject(:+) end

a,b = inp
oa,ob = a,b
as,bs, = a.to_s(2),b.to_s(2)
if(a.odd?)
  as[-1] = (a/2).odd?? "1" : "0"
  a = as[-1].to_i(2)
else
  as[-1] = (a/2).even?? "1" : "0"
  a = as.to_i(2)
end
if(b.odd?)
  bs[-1] = (b/2).odd?? "1" : "0"
  b = bs[-1].to_i(2)
else
  bs[-1] = (b/2).even?? "1" : "0"
  b = bs.to_i(2)
end

p a^b^oa


Measured memory_bytes: 3836
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        List<Integer> l = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            l.add(sc.nextInt());
        }
        sc.close();

        Collections.sort(l);

        int sum = 0;
        for (int i = 0; i < n - 1; i++) {
            sum += l.get(i);
        }

        if (sum > l.get(n - 1)) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }

    }

}


Measured memory_bytes: 23252
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// AISing_A
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int L = sc.nextInt();
		int R = sc.nextInt();
		int d = sc.nextInt();

		int res = 0;

		for(int i = L; i <= R; i++) {
			if(i%d == 0) {
				res++;
			}
		}
		// 出力
		System.out.println(res);
	    // Scannerクラスのインスタンスをクローズ
		sc.close();
	}
}


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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
	for(auto &e:u) fill_v<T>(e,v...);
}

int64 N;
vector<int64> G[2123];

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> N;
	int64 X, Y;
	cin >> X >> Y; X--; Y--;

	vector<int64> res(N-1, 0);
	REP(i, N) {
	  FOR(j, i+1, N) {
	    int64 dis = abs(i-j);
	    chmin(dis, abs(i-X)+abs(j-Y)+1);
	    res[dis-1]++;
	  }
	}
	REP(i, N-1) {
	  cout << res[i] << endl;
	}
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
typedef long long ll;
int main()
{
  ll h,w;cin >> h >> w;
  if(h==1||w==1) cout << 1 << "\n";
  else {
    ll res = (h*w+(ll)1)/2;
    cout << res << "\n";
  }
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>

using namespace std;

int main() {
  int i;
  int N;
  long long a[100010];
  scanf("%d", &N);
  for (i = 0; i < N; i++) {
    scanf("%lld", &a[i]);
  }
  int p = 0;
  int ans = 0;
  while (p < N) {
    if (p >= N-2) {
      ans += 1;
      break;
    }
    long long diff;
    for (i = p; i < N; i++) {
      if (a[i+1] - a[i] != 0) {
	diff = a[i+1] - a[i];
	break;
      }
    }
    for (i = p+2; i < N; i++) {
      if ((a[i] - a[i-1])*diff < 0) {
	p = i;
	ans += 1;
	//printf("cut at %d\n", p); 
	break;
      }
      p = i;
    }
  }
  printf("%d", ans);
  return 0;
}


Measured memory_bytes: 896
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <tuple>
#include <bitset>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>

int main() {
	int n; std::cin >> n;
	std::vector<std::vector<int>> shop(n, std::vector<int>(10));
	for (auto& line : shop) for (auto& f : line) std::cin >> f;
	std::vector<std::vector<int>> gain(n, std::vector<int>(11));
	for (auto& line : gain) for (auto& p : line) std::cin >> p;
	int max = INT_MIN;
	for (auto i = 1; i < 1024; ++i) {
		int sum = 0;
		for (auto j = 0; j < n; ++j) {
			int count = 0;
			for (auto k = 0; k < 10; ++k) {
				if ((i & (1 << k)) != 0) count += shop[j][k];
			}
			sum += gain[j][count];
		}
		max = std::max(max, sum);
	}
	std::cout << max << std::endl;
}

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

int main(){
    int h, w;
    cin >> h >> w;

    vector<vector<char>> a(h, vector<char>(w));
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            cin >> a[i][j];
        }
    }

    vector<int> b(w,0);
    for(int j=0; j<w; j++){
        for(int i=0; i<h; i++){
            if(a[i][j] == '#'){
                b[j] = 1;
                break;
            }
        }
    }

    vector<int> c(h,0);
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            if(a[i][j] == '#'){
                c[i] = 1;
                break;
            }
        }
    }    
    for(int i=0; i<h; i++){
        if(c[i] == 0) continue;

        for(int j=0; j<w; j++){
            if(b[j] == 1) cout << a[i][j];
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 256
// All Heil Fire Lord Zuko

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

#define all(x) x.begin(), x.end()

const int N = 100 * 1000 + 19;

int n, m, a[N];
vector<int> adj[N];
vector <long long> v, vec;
bool mark[N];

void dfs(int v);

int main() {
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    cin >> n >> m;
    for (int i = 0; i < n; i ++)
        cin >> a[i];
    for (int i = 0; i < m; i ++) {
        int u, v;
        cin >> u >> v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    long long ans = 0, cnt = 0;
    if (m == n - 1)
        return cout << 0, 0;
    if (n < 2 * (n - m - 1))
        return cout << "Impossible", 0;
    for (int i = 0; i < n; i ++)
        if (!mark[i]) {
            vec.clear();
            dfs(i);
            sort(all(vec));
            ans += vec[0], cnt ++;
            for (int j = 1; j < (int)vec.size(); j ++)
                v.push_back(vec[j]);
        }
    sort(all(v));
    int i = 0;
    while (i < (int)v.size() && cnt < 2 * (n - m - 1)) {
        ans += v[i];
        cnt ++;
        i ++;
    }
    cout << ans;
    return 0;
}

void dfs(int v) {
    mark[v] = true;
    vec.push_back(a[v]);
    for (auto u : adj[v])
        if (!mark[u])
            dfs(u);
}

/* THINGS TO CHECK !! */

// Runtime ->
// Overflows ->
// Order is ->

/* READ PROBLEM STATEMENT CAREFULLY */

Measured memory_bytes: 8564
# -*- coding: utf-8 -*-
#
# N = int(input())
#
# a = []
#
# for i in range(N):
#     a.append(input().split())
#
# Y = 0
#
# for figure, kind in a:
#
#     if kind == 'JPY':
#         Y += int(figure)
#     else:
#         figure = float(figure) * 380000.00000000
#         Y += figure
# print(Y)
#

import sys

N = int(input())

a = [i.strip().split() for i in sys.stdin.readlines()]

ans = 0

for b, c in a:
    if c == 'JPY':
        ans += int(b)
    else:
        ans += float(b) * 380000

print(ans)












Measured memory_bytes: 2940
#include <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <ctime>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <memory.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <unordered_map>
#include <unordered_set>
using namespace std;
typedef long double LD;
typedef long long LL;
typedef pair<LL, LL> pll;
typedef pair<int, int> pii;
typedef vector<int> vi;
#ifdef LOCAL
    #define DEBUG(x) { cerr << "# " << #x << ": " << x << endl;}
#else
    #define DEBUG(x)
#endif
mt19937_64 mt(time(0));
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/
const int MAXN = 2e5 + 10;
LL nums[MAXN];

LL solve(int n, LL x, int k) {
    int i = n-1;
    LL ret = 0, cnt = 1;
    while (i >= 0) {
        for (int j = 0; j < k && i >= 0; j++, i--) {
            if (cnt == 1) ret += nums[i];
            ret += x;
            int tmp = i - k;
            if (tmp >= 0) {
                ret += (nums[i]-nums[tmp]) * (cnt+1) * (cnt+1);
            } else {
                ret += nums[i] * (cnt+1) * (cnt+1) + x;
            }
        }
        cnt++;
    }
    return ret;

}



int main() {
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cout.precision(10); cout << fixed;
#ifdef LOCAL
    freopen("../test.txt", "r", stdin);
    // freopen("../output.txt", "w", stdout);
#endif
    LL n, x; cin >> n >> x;
    for (int i = 0; i < n; i++) {
        cin >> nums[i];
    }
    LL ra = solve(n, x, 1), rb = solve(n, x, n);
    LL a = 1, b = n;
    while (b-a > 20) {
        LL c = a + (b-a)/3;
        LL d = a + (b-a)/3*2;
        LL rc = solve(n, x, c);
        LL rd = solve(n, x, d);
        if (rc >= rd && rb >= rd) {
            a = c;
            ra = rc;
        }
        else if (ra >= rc && rd >= rc) {
            b = d;
            rb = rd;
        }
        else if (ra <= rc) {
            b = c;
            rb = rc;
        }
        else {
            a = d;
            ra = rd;
        }
    }
    LL ret = ra;
    for (int i = a+1; i <= b; i++) {
        ret = min(ret, solve(n, x, i));
    }
    cout << ret << endl;





/*---------------------------------------Coding Space End------------------------------------------*/
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s." << endl;
#endif
    return 0;
}
/* author:  txingml */
/* picture is from hamayanhamayan(CF handle) */


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

int main(){
    string x;
    while(true){
        cin>>x;
        if(x[0]=='0') break;
        int sum=0;
        for(int i=0;i<x.size();i++){
            sum+=x[i]-'0';
        }
        cout<<sum<<'\n';
    }
}


Measured memory_bytes: 3160
#include <stdio.h>
int main(){
  long a,b,c;
  scanf("%ld%ld%ld",&a,&b,&c);
  if(a%2&&b%2&&c%2){
    if(a>=b&&a>=c)a=1;
    else if(b>=a&&b>=c)b=1;
    else if(c>=a&&c>=b)c=1;
  }else a=0;
  printf("%ld",a*b*c);
  return 0;
}

Measured memory_bytes: 128
N=int(input())
F=[[0]*10 for _ in range(N)]
P=[[0]*11 for _ in range(N)]
for i in range(N):
    F[i]=list(map(int,input().split()))
for i in range(N):
    P[i]=list(map(int,input().split()))
i=1
ans=int(-10e15)
cnt=0
while i<=int('1111111111',2):
    tmp_ans=0
    bin_str=format(i,'10b')
    for j in range(N):
        cnt=0
        for k in range(10):
            if bin_str[k]=='1' and F[j][k]==1:
                cnt+=1
        tmp_ans+=P[j][cnt]
    if tmp_ans>ans:
        ans=tmp_ans
    i+=1
print(ans)

Measured memory_bytes: 3064
DBG = !true
n = gets.to_i
a = []
for i in 0...n
  a << gets.to_i
end
if DBG
  puts "n #{n} a: #{a}"
end

def lossev(x)
  return (x==0 ? 2 : x%2 == 0 ? 0 : 1)
end

def lossod(x)
  return (x%2 == 1 ? 0 : 1)
end

lz = Array.new(n,0)
le = Array.new(n,0)
od = Array.new(n,0)
re = Array.new(n,0)
rz = Array.new(n,0)
lz[0] = a[0]
le[0] = lossev(a[0])
od[0] = lossod(a[0])
re[0] = lossev(a[0])
rz[0] = a[0]
for i in 1...n
  lz[i] = lz[i-1] + a[i]
  le[i] = [lz[i-1], le[i-1]].min + lossev(a[i])
  od[i] = [lz[i-1], le[i-1], od[i-1]].min + lossod(a[i])
  re[i] = [lz[i-1], le[i-1], od[i-1], re[i-1]].min +
            lossev(a[i])
  rz[i] = [lz[i-1], le[i-1], od[i-1], re[i-1],
             rz[i-1]].min + a[i]
end

if DBG
  print lz ; puts ""
  print le ; puts ""
  print od ; puts ""
  print re ; puts ""
  print rz ; puts ""
end

ans = [lz[n-1], le[n-1], od[n-1], re[n-1],
           rz[n-1]].min
puts "#{ans}"


Measured memory_bytes: 13692
from functools import reduce
import math

def main():
    # 文字列の2進数を数値にする
    # '101' → '5'
    # 文字列の頭に'0b'をつけてint()にわたす
    # binary = int('0b'+'101',0)

    # 2進数で立っているbitを数える
    # 101(0x5) → 2
    # cnt_bit = bin(5).count('1')
    
    # N! を求める
    # f = math.factorial(N)

    # N の逆元
    # N_inv = pow(N,MOD-2,MOD)

    # nCr
    # Nの階乗 * rの階乗の逆元 * n-rの階乗の逆元
    
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    INF = float("inf")

    # 大きな素数
    MOD = 10**9+7
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    
    a, b, c, d = (int(_) for _ in input().split())
    ab = [0]*101
    cd = [0]*101
    for i in range(a,b+1):
        ab[i] = 1
    for i in range(c,d+1):
        cd[i] = 1
    ans = 0
    for i in range(0,101):
        if(ab[i] == 1 and cd[i] ==1):
            ans +=1
    print(max(ans-1,0))
if __name__ == '__main__':
    main()


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

typedef pair<int, int> pii;
typedef long long ll;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

#ifdef LOCAL
#define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl
#else 
#define dump(x) true
#endif

constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

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

template<class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
	os<<"{";
	rep(i, v.size()) {
		if (i) os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}

int main() {
	int A, B, M; cin >> A >> B >> M;
	V<int> a(A), b(B);
	rep(i, A) cin >> a[i];
	rep(i, B) cin >> b[i];
	int ans = *min_element(ALL(a)) + *min_element(ALL(b));

	rep(i, M) {
		int x, y, c;
		cin >> x >> y >> c;
		--x; --y;
		chmin(ans, a[x] + b[y] - c);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define f first
#define s second
#define MOD 1000000007
#define PMOD 998244353
#define pb(x) push_back(x)
using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> plii;
typedef pair<int, pii> piii;
const int INF = 1e9+10;
const ll LINF = 1LL*INF*INF;
const int MAXN = 2e5+10;
const int MAXM = 5e3+10;

priority_queue<int> pq;
vector<vector<int> > graph;
queue<int> que;

int A[MAXN];
char S[MAXN];
bool dp[MAXM];

int main()
{
    int n,m,k,a,b,c,x,y;
    int sum = 0;
    int cnt = 0;
    int mx = 0;
    int mn = INF;
    int cur = 0, idx = -1;

    cin>>a>>b>>c;

    if(a+b>=c)cout<<"Yes\n";
    else cout<<"No\n";

    return 0;
}


Measured memory_bytes: 256
{-# LANGUAGE CPP #-}
module Main where

import qualified Data.Vector as V 
import qualified Data.Map.Strict as M
import Control.Monad
import qualified Data.ByteString.Char8 as BS
import Data.Maybe

dump :: (Show a) => a -> IO()
#if __GLASGOW_HASKELL__ >= 800
dump x = print x
#else
dump _ = pure ()
#endif

-- "101010" -> [1,0,1,0,1,0]
readToList :: String -> [Int]
readToList [] = []
readToList (x:xs) = read [x] : readToList xs

-- "10 10 10" -> [10, 10, 10]
readvec :: IO [Int]
readvec = (fmap (read . BS.unpack) . BS.words) <$> BS.getLine

readmat :: Int -> IO [[Int]]
readmat rows = replicateM rows readvec

newtype UF a = UF (M.Map a a) deriving (Show) -- Map node parent

makeuf :: Int -> UF Int
makeuf n = let m = M.fromList $ zip [0..n] [0..n]
                in UF m

union :: (Eq a, Ord a) => a -> a -> UF a -> UF a
union l r uf@(UF m) = let lp = find l uf
                          rp = find r uf
                      in if lp == rp
                         then uf
                         else if size l uf < size r uf
                              then UF $ M.update (const $ Just rp) lp m
                              else UF $ M.update (const $ Just lp) rp m

find :: (Eq a, Ord a) => a -> UF a -> a
find x uf@(UF m) = let px = m M.! x
                in if px == x
                   then px
                   else find px uf -- TODO 貼り直し

size :: (Eq a, Ord a) => a -> UF a -> Int
size x (UF m) = M.size $ M.filter (\par -> par==x) m

genbit :: Int -> [[Int]]
genbit 0 = []
genbit 1 = [[0],[1]]
genbit len = do
  x <- [0,1]
  map (x:) $ genbit (len-1)

forn :: (Num a, Enum a, Monad m) => a -> (a -> m b) -> m [b]
forn x = forM [0..(x-1)]

count :: (Eq a) => a -> [a] -> Int
count y = length . filter (== y)

main :: IO()
main = do
  [n] <- readvec
  xss <- forM [1..n] $ \_ -> do
            [a] <- readvec
            forM [1..a] $ \_ -> do
              [x,y] <- readvec 
              pure (x-1, y)
  dump xss
  -- [[(1,1)],[(0,1)],[(1,0)]]
  rs <- forM (genbit n) $ \bits -> do
          ress <- fmap concat <$> forn (length xss) $ \x -> do
                    forn (length $ xss !! x) $ \y -> do
                            return $ if (bits !! x) == 1 && (snd $ xss !! x !! y) /= (bits !! (fst $ xss !! x !! y))
                                       then False
                                       else True
          dump bits
          if null $ filter (== False) ress
                   then do 
                     --dump $ bits
                     dump $ count 1 bits
                     pure $ count 1 bits
                   else pure 0
  print $ maximum rs


      


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

#define ll long long
#define Fi first
#define Se second
#define Pb push_back
#define vi vector<int>
#define vp vector<pair<int,int>>
#define vvi vector<vector<int>>
#define vvp vector<vector<pair<int,int>>>

const int INF = 1e9;
const int MOD = 1e9+7;
using Graph = vector<vector<int>>; //Caution!! Segmentation Fault!! Don't forget to add +1!

#define all(v) v.begin(),v.end()
#define output_s(a) printf("%s\n",(a).c_str())

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,n,m) for(int i=(int)(n);i<(int)(m);i++)
#define RepS(i,n,m) for(int i=(int)(n);i<=(int)(m);i++)
#define RRepS(i,n,m) for(int i=(int)(n);i>=(int)(m);i--)
#define RepA(x) for(auto &item:(x))

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}    
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

template<typename TypeInt> //最大公約数
TypeInt GCD(TypeInt a,TypeInt b){
    if(a%b==0) return b;
    else return GCD(b,a%b);
}
template<typename TypeInt> //最小公倍数
TypeInt LCM(TypeInt a,TypeInt b){
    return a*b/GCD(a,b);
}

int IN_int(){
    int x;
    scanf("%d",&x);
    return x;
}

//library----------------------------------------------

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

const int NMAX = 25;
bool flag;


int main(){
    SCIN(s);
    int ans=s.length();
    rep(i,s.size()-1){
        if(s[i]==s[i+1]){
            ans--;
            i+=2;
        }
    }
    printf("%d\n",ans);

    return 0;
}

Measured memory_bytes: 640
#include<cstring>
#include<bits/stdc++.h>
#define mod 1000000007
#define INF 1000000007
using namespace std;
typedef long long ll;
int main()
{
    //freopen("input.txt","r",stdin);
    int n,T,x,t;
    cin>>n>>T;
    int ans=INF;
    for(int i=1;i<=n;++i)
    {
        cin>>x>>t;
        if(t<=T)
            ans=min(ans,x);
    }
    if(ans==INF)
        puts("TLE");
    else cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
struct Edge {
  ll to;
  ll cost;
};
int main() {
  int N;
  cin >> N;
  string S;
  cin >> S;
  int mx = 0;
  int num = 0;
  REP(i,S.size()){
    if(S[i]=='I'){
      num++;
    }else{
      num--;
    }
    mx = max(mx, num);
  }
  cout << mx << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

void solve() {
  int n;
  cin >> n;
  vector<int> v(n);
  rep(i,n) cin >> v[i];
  sort(v.begin(), v.end());
  if (v[n/2-1] == v[n/2]) cout << 0 << endl;
  else cout << v[n/2] - v[n/2-1] << endl;
}

int main() {
  solve();
  return 0;
}

Measured memory_bytes: 3752
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    int a,b,k;
    cin>>a>>b>>k;
    int cnt=0;
    for(int i=100;i>=1;i--){
        if(a%i==0&&b%i==0) cnt++;
        if(cnt==k){
            cout<<i; return 0;
        }
    }
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define mp make_pair
#define mt make_tuple
#define lb lower_bound
#define ub upper_bound
#define fi first
#define sc second
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

const int MAXN = 1e7;
int ct_div[MAXN + 5];

int main()
{
	ll ans = 0;
	int n; scanf("%d", &n);
	
	for(int i = 1; i <= n; i++){
		for(int j = 1; i * j <= n; j++){
			ct_div[i * j]++;
		}
	}
	for(int i = 1; i <= n; i++){
		ans += 1LL * i * ct_div[i];
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 42848
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;


int main()
{
	unsigned long long int n;
	cin>>n;
	n = n - 1;
	cout<< n*(n+1)/2<<endl;
	return 0;
}



Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int A,B,C,D,E;
	cin>>A>>B>>C>>D>>E;
	int answer;
    if(A<0){
		 answer=-A*C+D+B*E;
	}
	if(A>0){
		 answer=(B-A)*E;
	}
	cout<<answer<<endl;

	return 0;
}


Measured memory_bytes: 3080
import numpy as np
n=int(input())
x=[list(map(int, input().split())) for _ in range(n)]

now=0
nplace=[0,0]
noflag=False
for y in x:
    dis=sum(map(abs, (np.array(y[1:]) - np.array(nplace))))
    # print(dis)
    if not ((dis<=(y[0]-now)) & ((y[0]-now-dis)%2==0)):
        noflag=True

    now=y[0]
    nplace=y[1:]
print('Yes') if noflag==False else print('No')

Measured memory_bytes: 45076
n = int(input())
max_num = 1
max_counter =0
for i in range(1, n+1):
    if not i%2 == 0:
        continue
    else:
        num = i
        counter = 0
        while num%2 == 0:
            num //= 2
            counter += 1
        if max_counter < counter:
            max_counter = counter
            max_num = i
print(max_num)


Measured memory_bytes: 2940
n, X = list(map(int, input().split()))
x = list(map(int, input().split()))

d = [abs(e - X) for e in x]

import fractions
from functools import reduce
# g=0
# for e in d:
#   g=fractions.gcd(e,g)
# print(g)

print(reduce(fractions.gcd, d))


Measured memory_bytes: 14252
import collections
s = input()
c = collections.Counter(s)

if c["a"] == c["b"] == c["c"]:
  print("YES")
  exit()
if c["a"]+1 == c["b"] == c["c"]:
  print("YES")
  exit()
if c["a"]-1 == c["b"] == c["c"]:
  print("YES")
  exit()
if c["a"] == c["b"]+1 == c["c"]:
  print("YES")
  exit()
if c["a"] == c["b"]-1 == c["c"]:
  print("YES")
  exit()
if c["a"] == c["b"] == c["c"]+1:
  print("YES")
  exit()
if c["a"] == c["b"] == c["c"]-1:
  print("YES")
  exit()
else:
  print("NO")

Measured memory_bytes: 3572
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
  int a,b,c,d,e,f,cnt;
  for(int i=0; i<3; i++) {
      cin >> a >> b >> c >> d >> e >> f;
      cnt=3600*(d-a)+60*(e-b)+(f-c);
      cout << cnt/3600 << " " << (cnt%3600)/60 << " " << cnt%60 << endl;
  }
}


Measured memory_bytes: 3116
D,N = map(int,input().split())
if D == 0:
    if N != 100:
        print(N)
    else:
        print(101)
    exit()
if D == 1:
    if N != 100:
        print(N*100)
    else:
        print(10100)
    exit()
if N != 100:
    print(N*10000)
else:
    print(1010000)

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

ll N,A,B,C,D;

bool check(ll s,ll t){
  ll d=abs(s-t);
  if( C<=d && d<=D )return true;
  return false;
}

bool f(ll l,ll r,ll x){
  return (l<=x&&x<=r);
}

int main(){

  cin>>N>>A>>B>>C>>D;
  N-=2;
  
  for(ll i=0;i<=N;i++){
    
    ll x=C*i;
    ll dx=(D-C)*i;
    
    ll y=C*(N-i);
    ll dy=(D-C)*(N-i);

    ll L=A+(x-y)-dy;
    ll R=A+(x-y)+dx;
    
    if( f(L,R,B+C) || f(L,R,B-C) || check(L,B) || check(R,B) ){
      //      cout<<i<<' '<<L<<' '<<R<<endl;
      cout<<"YES"<<endl;
      return 0;
    }
  }

  cout<<"NO"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <tuple>

using namespace std;

typedef long double ld;

const ld EPS = 1e-9;

ld p, q;
int a, n;
ld t;



int dfs(int m, ld s,int w,int c){

	if (abs(s - t) < EPS){
		return 1;
	}
	if (m == n)return 0;

	int ret = 0;
	for (int i = min(a/w,c); i >= 1; i--){
		if (w * i <= a){
			ld j = s + (ld(1.0) / ld(i));
			if (j <= t + EPS){
				ret += dfs(m + 1, j, w * i, i);
			}
		}
	}
	return ret;
}

int main(){

	while (cin >> p >> q >> a >> n && (p || q || a || n)){
		t = p / q;
		cout << dfs(0,0,1,a) << endl;
	}

	return 0;
}

Measured memory_bytes: 1228
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define ld long double
#define F first
#define S second
#define P pair<int,int>
#define V vector
#define pb push_back
#define mkp make_pair
#define pi pair<int,int>//struct pi {int fi,se;};
#define all(v) (v).begin(), (v).end()
#define rep(i, l, r) for(int i=(int)(l);i<(int)(r);i++)
#define repd(i, l, r) for (int i=(int)(l);i>=(int)(r);i--)
#define ln length()
#define sz size()
const int N=100005;
///////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////

int32_t main()
{
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    
    // int t;cin>>t;while(t--)
    {
        int i,j,k,n,m,ans=0,cnt=0,sum=0;
        string s;
        cin>>n>>s;
        //int a[n];
        for(i=0;i<n;i++){
            if(s[i] == 'R'){
                sum++;
            }else{
                cnt++;
            }
        }
        i = 0;
        j = n-1;
        while(i < j){
            if(s[i] == 'R'){
                i++;
            }
            else if(s[j] == 'W'){
                j--;
            }
            else if(s[i] == 'W' && s[j] == 'R'){
                ans++;
                swap(s[i],s[j]);
            }
        }
        cout << ans<<endl;

    }
}

Measured memory_bytes: 3772
def main():
  S = [s for s in input()]
  T = [s for s in input()]
  R1 = [-1 for i in range(26)]
  R2 = [-1 for i in range(26)]
  for i in range(len(S)):
    a = ord(S[i]) % 26
    b = ord(T[i]) % 26
    if(R1[a] != -1 or R2[b] != -1):
      if(R1[a] != b or R2[b] != a):
        print("No")
        return
    else:
      R1[a]=b
      R2[b]=a
  print("Yes")
  return

main()

Measured memory_bytes: 7076
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Codeforces
{
	internal class Template
	{
		private void Solve()
		{
			var n = cin.NextInt();
			var m = cin.NextInt();
			if (Math.Abs(n - m) > 1)
			{
				Console.WriteLine(0);
				return;
			}
			if (m > n)
			{
				var temp = n;
				n = m;
				m = temp;
			}
			var mod = (int) 1e9 + 7;
			var res = 1L;
			if (m == n)
			{
				res = 2L;
			}
			while (n > 0)
			{
				res *= n;
				res %= mod;
				n--;
				if (m > 0)
				{
					res *= m;
					res %= mod;
					m--;
				}
			}
			Console.WriteLine(res);
		}

		private static readonly Scanner cin = new Scanner();

		private static void Main()
		{
			new Template().Solve();
			Console.ReadLine();
		}
	}

	internal class Scanner
	{
		private string[] s = new string[0];
		private int i;
		private readonly char[] cs = { ' ' };

		public string NextString()
		{
			if (i < s.Length) return s[i++];
			var line = Console.ReadLine() ?? string.Empty;
			s = line.Split(cs, StringSplitOptions.RemoveEmptyEntries);
			i = 1;
			return s.First();
		}

		public double NextDouble()
		{
			return double.Parse(NextString());
		}

		public int NextInt()
		{
			return int.Parse(NextString());
		}

		public long NextLong()
		{
			return long.Parse(NextString());
		}
	}
}

Measured memory_bytes: 13268
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <string>
#include <iomanip>

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

using namespace std;

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

  if(N<1000) cout << "ABC" << endl;
  else if(N>=1000) cout << "ABD" << endl;

  return 0;
}

Measured memory_bytes: 256
def show(nums):
    for i in range(len(nums)):
        if i!=len(nums)-1:
            print(nums[i],end=' ')
        else:
            print(nums[i])


n=int(input())
nums=list(map(int,input().split()))
show(nums)
for i in range(1,n):
    v=nums[i]
    j=i-1
    while(j>=0 and nums[j]>v):
        nums[j+1]=nums[j]
        j-=1
    nums[j+1]=v
    show(nums)


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

int main() {
    int A, B, C;
    cin >> A >> B >> C;
    if ((A == B && B != C)
    || (A == C && A != B)
    || (B == C && B != A)) {
        cout << "Yes";
    } else {
        cout << "No";
    }
}


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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  int l[n];
  for(int i=0;i<n;i++)
    cin >> l[i];
  int ans = 0;

  for(int i = 0; i < n; i++)
    for(int j = i+1; j < n; j++)
      for(int k = j+1; k < n; k++)
        if(l[i] < l[j] + l[k] && l[j] < l[k]+l[i] && l[k] < l[i]+l[j])
          ans++;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
const double pi = 3.141592653589793238462643383279;
using namespace std;

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
 
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
 
//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007
 
 
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
 
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
 
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
const long double EPS = 1e-6, PI = acos((long double)-1);

//ここから編集
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(4);

  int N; cin >> N;
  vector<int> L(N);
  REP(i,N) cin >> L[i];

  int ans = 0;
  for(int i=0; i<N; i++){
    for(int j=i+1; j<N; j++){
      for(int k=j+1; k<N; k++){
        if(L[i] != L[j] && L[i] != L[k] && L[j] != L[k]){
          if(L[i] + L[j] > L[k] && L[i] + L[k] >  L[j] && L[j] + L[k] > L[i]) ans++;
        }
      }
    }
  }
  cout << ans << endl;


  return 0;
}

Measured memory_bytes: 3628
#include <iostream>

int main(){

    int A,B,X;
    std::cin >> A >> B >> X;

    if(A == X){
        std::cout << "YES" << std::endl;
    }
    else if(A > X){
        std::cout << "NO" << std::endl;
    }
    else if(A < X){
        if(A+B < X){
            std::cout << "NO" << std::endl;
        }
        else{
            std::cout << "YES" << std::endl;
        }
    }

    return 0;
}

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

int k,x;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin>>k>>x;
	int i = x-k+1;
	while(i < x+k){
		cout<<i<<' ';
		i++;
	}
	return 0;
}

Measured memory_bytes: 256
s = int(input())
a = {s}
pre_a = s
i = 2
while True:
    if pre_a&1:
        pre_a = 3*pre_a + 1
        if pre_a in a:
            print(i)
            break
        a.add(pre_a)
    else:
        pre_a = pre_a // 2
        if pre_a in a:
            print(i)
            break
        a.add(pre_a)
    i += 1

Measured memory_bytes: 38256
from math import sqrt

n,m=map(int,input().split())
#print(n,m)
l=[]
for i in range(1,int(sqrt(m))+1):
    if m%i == 0:
        l.append(i)
        l.append(m//i)
l.sort(reverse=True)
for i in l:
    if i*n<=m:
        print(i)
        break

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

char s[1000];

int main(){
    int i,l,x=0,max=0,n;

    scanf("%d",&n);
    scanf(" %s",s);
    l=strlen(s);

    for(i=0;i<l;i++){
        if(s[i]=='I'){
            x++;
        }
        else
            x--;
        if(x>max)
            max=x;
    }

    printf("%d\n",max);



    return 0;
}



Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define hell  1000000007
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb   push_back


int main()
{
	ios;
	string s;
	cin>>s;
	if(s=="ABC")
		cout<<"ARC";
	else
		cout<<"ABC";
}

Measured memory_bytes: 3652
import difflib
S=input()
T=input()
lenT=len(T)
ans=len(T)

for i in range(len(S)-lenT+1):
  check = 0
  for j in range(lenT):
    if S[i+j] != T[j]:
      check = check + 1
  if check<ans:
    ans = check
print(ans)

Measured memory_bytes: 9904
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int main(){
  while(1){
    int n,ans=0;
    scanf("%d\n",&n);
    if(n==0){
      return 0;
    }
    int i,j,k,a[300][300],b[300][300];
    char s;
    for(i=0;i<=n+1;i++){
      for(j=0;j<=n+1;j++){
        b[i][j]=0;
      }
    }
    for(i=1;i<=n;i++){
      for(j=1;j<=n;j++){
        scanf("%c",&s);
        a[i][j]=s-'0';
      }
      scanf("\n");
    }
    for(i=1;i<=n;i++){
      for(j=1;j<=n;j++){
        if(a[i][j]==1){
          b[i][j+1]=b[i][j]+1;
        }
      }
    }
    for(i=0;i<=n+1;i++){
      for(j=0;j<=n+1;j++){
        ans=max(ans,b[i][j]);
      }
    }
    for(i=0;i<=n+1;i++){
      for(j=0;j<=n+1;j++){
        b[i][j]=0;
      }
    }
    for(i=1;i<=n;i++){
      for(j=1;j<=n;j++){
        if(a[j][i]==1){
          b[j+1][i]=b[j][i]+1;
        }
      }
    }
    for(i=0;i<=n+1;i++){
      for(j=0;j<=n+1;j++){
        ans=max(ans,b[i][j]);
      }
    }
    for(i=0;i<=n+1;i++){
      for(j=0;j<=n+1;j++){
        b[i][j]=0;
      }
    }
    for(i=1;i<=n;i=k){
      k=i+1;
      for(j=1;j<=n && i>0;i--,j++){
        if(a[i][j]==1){
          b[i-1][j+1]=b[i][j]+1;
        }
      }
    }
    for(i=0;i<=n+1;i++){
      for(j=0;j<=n+1;j++){
        ans=max(ans,b[i][j]);
      }
    }
    for(i=0;i<=n+1;i++){
      for(j=0;j<=n+1;j++){
        b[i][j]=0;
      }
    }
    for(i=1;i<=n;i=k){
      k=i+1;
      for(j=1;j<=n && i<=n;i++,j++){
        if(a[i][j]==1){
          b[i+1][j+1]=b[i][j]+1;
        }
      }
    }
    for(i=0;i<=n+1;i++){
      for(j=0;j<=n+1;j++){
        ans=max(ans,b[i][j]);
      }
    }
    for(i=0;i<=n+1;i++){
      for(j=0;j<=n+1;j++){
        b[i][j]=0;
      }
    }
    for(i=1;i<=n;i=k){
      k=i+1;
      for(j=n;j>0 && i<=n;i++,j--){
        if(a[i][j]==1){
          b[i+1][j-1]=b[i][j]+1;
        }
      }
    }
    for(i=0;i<=n+1;i++){
      for(j=0;j<=n+1;j++){
        ans=max(ans,b[i][j]);
      }
    }
    for(i=0;i<=n+1;i++){
      for(j=0;j<=n+1;j++){
        b[i][j]=0;
      }
    }
    for(i=1;i<=n;i=k){
      k=i+1;
      for(j=n;j>0 && i>0;i--,j--){
        if(a[i][j]==1){
          b[i-1][j-1]=b[i][j]+1;
        }
      }
    }
    for(i=0;i<=n+1;i++){
      for(j=0;j<=n+1;j++){
        ans=max(ans,b[i][j]);
      }
    }
    cout << ans << endl;
  }
}


Measured memory_bytes: 3732
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9+7;
const ll mod=1e9+7;
int main(){
    ll n,k;cin>>n>>k;
    n%=k;
    n=min(k-n,n);
    cout<<n<<endl;
}

Measured memory_bytes: 256