akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <stdlib.h>
#include <time.h> 
 
using namespace std;
long long mod = 1e9 + 7;
long long INF = 1e7;
double EPS = 1e-12;
typedef long long int lld;
long double tick(){static clock_t oldt; clock_t newt=clock();
    long double diff=1.0L*(newt-oldt)/CLOCKS_PER_SEC; oldt = newt; return diff; }
#define rep(i,a,n) for(long long int i = (a); i <= (n); ++i)
#define repI(i,a,n) for(int i = (a); i <= (n); ++i)
#define repD(i,a,n) for(long long int i = (a); i >= (n); --i)
#define repDI(i,a,n) for(int i = (a); i >= (n); --i)
inline lld sc() { lld a; scanf("%lld", &a); return a; }
inline int scd() { int a; scanf("%d", &a); return a; }
inline double scf() { double a; scanf("%lf",&a); return a; }
#define prL(a) printf("%lld\n",a)
#define prS(a) printf("%lld ",a)
#define prdL(a) printf("%d\n",a)
#define prdS(a) printf("%d ",a)
#define all(c) (c).begin(), (c).end()
#define sz(a) ((int)a.size())
#define Error(x...) { cout << "(" << #x << ")" << " = ( "; printIt(x); }
template <typename T1> void printIt(T1 t1) { cout << t1 << " )" << endl; }
template <typename T1, typename... T2>
void printIt(T1 t1, T2... t2) { cout << t1 << " , "; printIt(t2...); }
#define errorpair(a) cout<<#a<<" = ( "<<((a).first)<<" , "<<((a).second)<<" )\n";
#define mset(a, v) memset(a, v, sizeof(a))
#define popcount __builtin_popcountll

typedef pair<lld,lld> PA;

lld powP(lld x, lld y) {
    lld ans = 1, po = x % mod;
    while(y > 0) {
        if(y & 1) ans = ans * po % mod;
        y >>= 1; po = po * po % mod;
    }
    return ans;
}
 
bool bitSet(lld n, lld bit){
    if((n & (1LL << bit)) != 0) return true;
    else return false;
}
 
lld findGcd(lld a, lld b){
    while(a != 0) { lld temp = b % a; b = a; a = temp; }
    return b;
}

#define lim 300010
#define lim2 200010
#define qqqqqq 210
// Ab :)
// inline lld sqr(lld x) { return x * x; }
// unordered_map<lld,lld>::iterator it;
// std::ios::sync_with_stdio(false);
// priority_queue<PA> Q;
// lld dp[1<<18];

// vector<lld> G[lim];
// string S[lim];
// lld A[lim];

int main(){
    lld n = sc();
    map<string,lld> M;
    while(n--) {
        string S;
        cin >> S;
        M[S]++;
    }
    printf("AC x %lld\n", M["AC"]);
    printf("WA x %lld\n", M["WA"]);
    printf("TLE x %lld\n", M["TLE"]);
    printf("RE x %lld\n", M["RE"]);
    return 0;
}


Measured memory_bytes: 3792
#ifndef _WIN32
#include<iostream>
#endif // !_WIN32

#include<algorithm>
#include<vector>
#include<string>
#include<iomanip>
#include<map>
using namespace std;
#define FOR(i,bg,ed) for(int i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
int main() {
	int N;
	while (cin >> N, N) {
		vector<string> s;
		REP(i,N){
			string t;
			cin >> t;
			s.push_back(t + "1");
			cin >> t;
			s.push_back(t + "0");
		}
		sort(ALL(s));
		int lb = 0;
		int ub = N;
		auto f = [&](int cnt) {
			for (auto &it : s) {
				if (it.back() == '1')cnt--; else cnt++;
				if (cnt < 0)return false;
			}
			return true;

		};
		while (ub - lb > 1) {
			const int mid = (lb + ub) / 2;
			if (f(mid))ub = mid;
			else lb = mid;
		}
		cout << ub << endl;
	}

}

Measured memory_bytes: 4204
/*  ex9_1
    kento_titech*/
#include <stdio.h>
#include <stdlib.h>
#include<string.h>
#define SIZE 11
typedef struct {//配列におけるスタックを構造体として定義
    int count;
    char data[SIZE];
    char *tail;//配列の要素の末尾部分のポインタ
    char *head;//先頭部分のポインタ
} stack;

void initialize_stack(stack *stk);
void print_stack(stack *stk);
void push(stack *stk, char x);
void pop(stack *stk);

stack stk;

int main(void){
    initialize_stack(&stk);
    char input[SIZE];
    int i;
    scanf("%s",input);
    for(i=0;i<strlen(input);i++){
        if(input[i]=='1'||input[i]=='0'){//'1','0'であればpush
            push(&stk,input[i]);
        }
        else//'B'のときpop
            pop(&stk);
    }
    print_stack(&stk);
    printf("\n");
    return 0;
}

void initialize_stack(stack *stk){//スタックの初期化
    stk->count = 0;
    stk->head=&(stk->data[0]);
    stk->tail=&(stk->data[0]);
}

void push(stack *stk,  char x){  //pushの定義  
    *(stk->tail) = x;
    stk->tail++;//末尾を一つ後ろに
    stk->count++;
}

void pop(stack *stk){//popの定義
    if(stk->count > 0){
        stk->tail--;//末尾を一つ前に
        stk->count--;
    }
}

void print_stack(stack *stk){//配列の中身を出力
    char *p;
    int i;    
    p = stk->head;
    for(i=0;i< stk->count;i++)//先頭からすべての要素を出力
        printf("%c",*p++);
}

Measured memory_bytes: 1656
#include<bits/stdc++.h>
#define del(a,i) memset(a,i,sizeof(a))
#define ll long long
#define inl inline
#define il inl void
#define it inl int
#define ill inl ll
#define re register
#define ri re int
#define rl re ll
#define mid ((l+r)>>1)
#define lowbit(x) (x&(-x))
#define INF 0x3f3f3f3f
using namespace std;
template<class T>il read(T &x){
	int f=1;char k=getchar();x=0;
	for(;k>'9'||k<'0';k=getchar()) if(k=='-') f=-1;
	for(;k>='0'&&k<='9';k=getchar()) x=(x<<3)+(x<<1)+k-'0';
	x*=f;
}
template<class T>il _print(T x){
	if(x/10) _print(x/10);
	putchar(x%10+'0');
}
template<class T>il print(T x){
	if(x<0) putchar('-'),x=-x;
	_print(x);
}
ll mul(ll a,ll b,ll mod){long double c=1.;return (a*b-(ll)(c*a*b/mod)*mod)%mod;}
it qpow(int x,int m,int mod){
	int res=1,bas=x;
	while(m){
		if(m&1) res=(1ll*res*bas)%mod;
		bas=(1ll*bas*bas)%mod,m>>=1;
	}
	return res;
}
const int N = 2e5+5;
int n,f[N][60];
ll k;
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	read(n),read(k);
	for(ri i=1;i<=n;++i) read(f[i][0]);
	for(ri i=1;i<=59;++i) for(ri j=1;j<=n;++j) f[j][i]=f[f[j][i-1]][i-1];
	int now=1;
	for(ri i=59;i>=0;--i) if(k&(1ll<<i)) now=f[now][i];
	print(now);
	return 0;
}

Measured memory_bytes: 50508
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//int→string
//string→int
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//sqrt
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//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 SZ(a) int((a).size())
#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())
#define RSORT(c) sort((c).rbegin(),(c).rend())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int func(LL n){
    string str = toString(n);
    return str.length();
}

int main() {

    LL N;
    cin >> N;

    int ans = (1<<20);

    for(LL i = 1; i*i <= N; i++){
        if(N % i == 0){
            ans = min(ans, func(N/i));
        }
    }

    printf("%d", ans);

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <cmath>
#define rep(i,n) for(int i=0; i<n; i++)
#define loop(i, j, n) for(int i=j; i<n; i++)
using namespace std;
int main()
{
	int N, ans=0, cnt=0;
	int i, j;
	cin >>N;

	for(i=1; i<=N; i++){
		if(i%2 != 0){
			cnt = 0;
			for(j=1; j<=i; j++){
				if(i%j == 0) cnt++;
			}
			if(cnt == 8) ans++;
		}
	}
	cout << ans <<endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= (int)end; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return 0;}
template<typename T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return 0;}

const ll INF = 1LL << 50;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, M, X;
    cin >> N >> M >> X;
    vector<ll> C(N);
    vector<vector<ll>> A(N, vector<ll>(M));
    rep(i, 0, N) {
        cin >> C[i];
        rep(j, 0, M) {
            cin >> A[i][j];
        }
    }
    ll ans = INF;
    rep(mask, 0, 1 << N) {
        vector<ll> val(M, 0);
        ll cost = 0;
        rep(i, 0, N) {
            if (!((mask >> i) & 1)) {
                continue;
            }
            cost += C[i];
            rep(j, 0, M) {
                val[j] += A[i][j];
            }
        }
        bool is_ok = true;
        rep(i, 0, M) {
            if (val[i] < X) {
                is_ok = false;
                break;
            }
        }
        if (is_ok) {
            chmin(ans, cost);
        }
    }
    if (ans == INF) {
        cout << -1 << endl;
    } else {
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3592
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

// use std::io::{stdout, Write, BufWriter};
use std::cmp::{max};

fn main() {
    input! {
        a: usize,
        b: i32,
        s: String,
    }
    let s = s.as_bytes();
    for (i, t) in s.iter().cloned().enumerate() {
        if i == a { if t != b'-' {
            println!("No");
            return;
            }
        } else if !(b'0' <= t && t<= b'9') {
            println!("No");
            return;
        }
    }
    println!("Yes");
}


Measured memory_bytes: 4476
N = int(input())
S = [input() for i in range(N)]
cnt_ab_from_S = sum([s.count('AB') for s in S])
start_from_b_and_end_at_a = sum([(s[0] == 'B') and (s[-1] == 'A') for s in S])
not_start_from_b_and_end_at_a = sum([(s[0] != 'B') and (s[-1] == 'A') for s in S])
start_from_b_and_not_end_at_a = sum([(s[0] == 'B') and (s[-1] != 'A') for s in S])
ans = cnt_ab_from_S
if (start_from_b_and_end_at_a == 0):
    ans += min(not_start_from_b_and_end_at_a, start_from_b_and_not_end_at_a)
elif (not_start_from_b_and_end_at_a + start_from_b_and_not_end_at_a == 0):
    ans += (start_from_b_and_end_at_a - 1)
else:
    ans += (start_from_b_and_end_at_a + min(not_start_from_b_and_end_at_a, start_from_b_and_not_end_at_a))
print(ans)

Measured memory_bytes: 3700
import sys
# input処理を高速化する
input = sys.stdin.readline
def chmax(a, b):
    if a >= b:
        return a
    return b
def chmin(a, b):
    if a <= b:
        return a
    return b
def main():
    N = int(input())
    a = list(map(int, input().split()))
    # aiからajのX−Yの最大値
    # [左端,右端)=[l,r)からの遷移    
    # 左をとる[l+1,r)、右をとる[l,r−1)の2通り
    dp = [[0] * (N+1)  for _ in range(N+1)]
    for len in range(1, N + 1):
        for i in range(N + 1 - len):
            j = i + len
            if (N - len) % 2 == 0:
                dp[i][j] = chmax(dp[i + 1][j] + a[i], dp[i][j - 1] + a[j - 1])
            else:
                dp[i][j] = chmin(dp[i + 1][j] - a[i], dp[i][j - 1] - a[j - 1])
    print(dp[0][N])
main()

Measured memory_bytes: 113628
/* */
#include <cstdio>
#include <cstring>
#include <cassert>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <bitset>
#include <map>
#include <set>
const int MAX_LEN = 1010;
#define GETLINE(x) fgets(x,MAX_LEN,stdin);
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<ll, ll> pll;
typedef pair<double, double> dd;
typedef tuple<int, int, int> iii;
typedef vector<ii> vii;
typedef vector<ll> vll;
#ifdef XVENOM
	#define errp(...) fprintf(stderr, __VA_ARGS__)
	#define dbg(...) errp("[%s]: ", #__VA_ARGS__), dbg_str(__VA_ARGS__)
#else
	#define errp(...)
	#define dbg(...)
#endif
template <typename U, typename V> string to_string (pair<U, V>);
string to_string (const string& e_) { return "\"" + e_ + "\""; }
string to_string (char e_) { return "\'" + string(1, e_) + "\'"; }
string to_string (bool e_) { return e_ ? "true" : "false"; }
template <typename T> string to_string (T e_) {
	string s_ = "[ ";
	for (const auto& x_ : e_) s_ += to_string(x_) + " ";
	return s_ + "]";
}
template <typename U, typename V> string to_string (pair<U, V> e_) {
	return "(" + to_string(e_.first) + ", " + to_string(e_.second) + ")";
}
void dbg_str () { errp(" \n"); }
template <typename U, typename... V> void dbg_str (U u, V... v) {
 	errp(" %s", to_string(u).c_str()); dbg_str(v...);
}
/* --- */
const int INF=5000;
int n,ma,mb,x,y,z;
int a[44],b[44],c[44];
int f[44][444][444];
int main () { 
	scanf("%d %d %d",&n,&ma,&mb);
	for(int i=0;i<n;i++)
		for(int j=0;j<402;j++)
			for(int k=0;k<402;k++)
				f[i][j][k]=INF;
	for(int i=0;i<n;i++)
		scanf("%d %d %d",&a[i],&b[i],&c[i]);
	f[0][0][0]=0;
	f[0][a[0]][b[0]]=c[0];
	for(int i=0;i<n-1;i++)
		for(int j=0;j<=10*(i+1);j++)
			for(int k=0;k<=10*(i+1);k++){
				f[i+1][j][k]=min(f[i+1][j][k],f[i][j][k]);
				f[i+1][j+a[i+1]][k+b[i+1]]=min(f[i+1][j+a[i+1]][k+b[i+1]],f[i][j][k]+c[i+1]);
			}
	int ans=INF;
	for(int i=1;i<402;i++)
		for(int j=1;j<402;j++){
			if(ma*j==mb*i)ans=min(ans,f[n-1][i][j]);
		}
	printf("%d\n",(ans==INF)?-1:ans);
}

Measured memory_bytes: 32896
N, X = map(int, input().split())
L = [int(x) for x in input().split()]

D = [0] * 2
for i in range(2, N+2):
    D.append( D[i-1] + L[i-2] )
    if D[i] > X:
        ans = i-1
        break
if D[-1] <= X:
    ans = N+1

print(ans)

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

int main(){
    int N;
    cin >> N;
    long long  ans = 0;
    vector<vector<int>> cnt(10, vector<int>(10));
    for(int i=1;i<=N;i++){
        string s = to_string(i);
        int goa = s.back() - '0';
        int sta = s[0] - '0';
        cnt[sta][goa]++;
    }
    for(int i=1;i<=N;i++){
        string s = to_string(i);
        int sta = s.back() - '0';
        int goa = s[0] - '0';
        if(sta == 0) continue;
        ans += cnt[sta][goa];
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#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;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const ll INF=1e18;
const ll MOD=1e9+7;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);  
  
  int a,b,c,d,e,f;
  cin >> a >> b >> c >> d >> e >> f;
  
  cout << a+b+c+d-min({a,b,c,d})+max(e,f) << endl;
}



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

int main() {
	int a, b;
	char op;

	while(1) {
		cin >> a >> op >> b;
		if (op == '?') break;
		if (op == '+') cout << a+b << endl;
		else if (op == '-') cout << a-b << endl;
		else if (op == '*') cout << a*b << endl;
		else if (op == '/') cout << a/b << endl;
		else break;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>

using namespace std;

int main()
{
    int n, m, c;
    cin >> n >> m >> c;

    int b[m];
    for (int i = 0; i < m; i++)
    {
        cin >> b[i];
    }

    int tmp[n][m];
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++)
        {
            cin >> tmp[i][j];
        }
    }

    int count = 0;
    for (int i = 0; i < n; i++)
    {
        int sum = 0;
        for (int j = 0; j < m; j++)
        {
            sum += (tmp[i][j] * b[j]);
        }

        if (sum + c > 0)
        {
            count++;
        }
    }

    cout << count << endl;
    return 0;
}

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

using namespace std;

int main ()
{
	int S, N;
	scanf("%d %d",&S,&N);
	static pair<int, int> a[MAXN];
	int i;
	int odd = 0;
	for (i = 0; i < N; i++)
	{
		scanf("%d",&a[i].second);
		if (a[i].second % 2)
		{
			a[i].first = 0;
			odd++;
		}
		else a[i].first = 1;
	}
	sort(a, a+N);
	if (S % 2)
	{
		if (odd == 1)
		{
			if (a[0].second == 1)
			{
				char first;
				first = 1;
				for (i = 0; i < N; i++)
				{
					if (first) first = 0;
					else printf(" ");
					printf("%d",a[i].second);
				}
				printf("\n");
				if ((N == 1) && (S > 1))
				{
					printf("%d\n",N+1);
					printf("%d %d\n",S-1,1);
				}
				else
				{
					printf("%d\n",N);
					first = 1;
					for (i = 1; i < N; i++)
					{
						if (first) first = 0;
						else printf(" ");
						printf("%d",a[i].second);
					}
					if (first) first = 0;
					else printf(" ");
					printf("%d",a[0].second);
					printf("\n");
				}
			}
			else
			{
				char first;
				first = 1;
				for (i = 0; i < N; i++)
				{
					if (first) first = 0;
					else printf(" ");
					printf("%d",a[i].second);
				}
				printf("\n");
				printf("%d\n",N+1);
				printf("%d",a[0].second - 1);
				for (i = 1; i < N; i++)
				{
					printf(" %d",a[i].second);
				}
				printf(" 1\n");
			}
		}
		else printf("Impossible\n");
	}
	else
	{
		if (odd == 0)
		{
			char first;
			first = 1;
			for (i = 0; i < N; i++)
			{
				if (first) first = 0;
				else printf(" ");
				printf("%d",a[i].second);
			}
			printf("\n");
			printf("%d\n",N+1);
			printf("%d",a[0].second - 1);
			for (i = 1; i < N; i++)
			{
				printf(" %d",a[i].second);
			}
			printf(" 1\n");
		}
		else if (odd == 2)
		{
			pair<int, int> temp;
			temp = a[1]; a[1] = a[N-1]; a[N-1] = temp;
			char first;
			first = 1;
			for (i = 0; i < N; i++)
			{
				if (first) first = 0;
				else printf(" ");
				printf("%d",a[i].second);
			}
			printf("\n");
			if (a[N-1].second > 1) printf("%d\n",N);
			else printf("%d\n",N-1);
			printf("%d",a[0].second + 1);
			for (i = 1; i < N-1; i++)
			{
				printf(" %d",a[i].second);
			}
			if (a[N-1].second > 1) printf(" %d",a[N-1].second - 1);
			printf("\n");
		}
		else printf("Impossible\n");
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n;
long long a[1001];
long long b[1001];
char ans[1001][50];
long long dy[4]={1,0,-1,0};
long long dx[4]={0,1,0,-1};
char c[5]="DLUR";
int q;
long long abs2(long long k){
    return k>0 ? k:-k;
}
int isok(long long x,long long y,int lev){
    if(abs2(x)+abs2(y)<=((long long)1<<lev) )return 1;
    return 0;
}
void f(int lev,long long x,long long y,int k){

   /// cout<<lev<<" "<<x<<" "<<y<<endl;
    if(lev==-1){
        for(int i=0 ; i<4 ; i++){
            int xx=x+dx[i];
            int yy=y+dy[i];
            if(xx==0 && yy==0){
                ans[k][lev+1]=c[i];
                return;
            }
        }
        return;
    }
    long long l=1;
    long long t=(l<<lev);
    for(int i=0 ; i<4 ; i++){
        long long xx=x+t*dx[i];
        long long yy=y+t*dy[i];
        if(isok(xx,yy,lev)){
            ans[k][lev+1-q]=c[i];
            f(lev-1,xx,yy,k);
            return;
        }
    }
}
int main(){
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(0);
    int i;
    cin>>n;
    for(i=1 ; i<=n ; i++){
        cin>>a[i]>>b[i];
        if(abs2(a[i]+b[i])%2!=abs2(a[1]+b[1])%2){
            cout<<-1;
            return 0;
        }
        q=abs2(a[i]+b[i])%2;
        f(30,a[i],b[i],i);
    }
    cout<<(32-q)<<endl;
    if(q){
        for(i=0 ; i<=30 ; i++){
            cout<<(1<<i)<<" ";
        }
    }
    else{
        cout<<1<<" ";
        for(i=0 ; i<=30 ; i++){
            cout<<(1<<i)<<" ";
        }
    }
    cout<<"\n";
    for(i=1 ; i<=n ; i++){
        cout<<(ans[i])<<"\n";
    }
    return 0;

}


Measured memory_bytes: 384
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    if len(x) == 0:
        return []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans

"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""

n = onem()

a = input()[:-1]


if len(a) > n:
    print(a[:n]+"...")
else:
    print(a)















Measured memory_bytes: 65164
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
#define FOR(i,k,n) for(int i=(k);i<(n);++i)

int main(){
    ll n,k;cin>>n>>k;
    ll res=0;
    if(k==0){cout<<n*n<<endl;return 0;}
    for(ll b=k+1;b<=n;b++){
        res+=(n/b)*(b-k)+max(0LL,n-(n/b)*b-k+1);
    }
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 384
#include<iostream>

using namespace std;

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

int dp[394];

int main() {
  int n, m, s, l, p, w[400];
  cin >> n;
  rep (i, 393) dp[i + 1] = -1;
  rep (i, n) {
    cin >> s >> l >> p;
    rep (j, 394) {
      for (int k = max(0, j - l); k <= j - s; ++k) if (dp[k] != -1) {
	  dp[j] = max(dp[j], dp[k] + p);
	}
    }
  }
  cin >> m;
  rep (i, m) {
    cin >> w[i];
    if (dp[w[i]] == -1) {
      cout << -1 << endl;
      return 0;
    }
  }
  rep (i, m) cout << dp[w[i]] << endl;
  return 0;
}

Measured memory_bytes: 1160
import Data.List

swapTwoNumbers :: IO ()
swapTwoNumbers = do
  input <- getLine
  let xs = map read $ words input
  if (head xs == 0) && (head (tail xs) == 0)
    then do return ()
    else do putStrLn $ unwords $ map show $ sort xs
            swapTwoNumbers

main :: IO ()
main = swapTwoNumbers

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

int main(){
  int H, W, K; cin >> H >> W >> K;
  vector<string> mp(H);
  for(int i = 0; i < H; i++) cin >> mp[i];
  
  int ans = 1001001001;
  for(int bit = 0; bit < (1<<(H-1)); bit++){
    vector<int> gp(H,0); 
    int gpn = 0; 
    //横に切る
    for(int i = 0; i < H-1; i++){
      if(!(bit & (1<<i))) gp[i+1] = gp[i];
      else{
        gp[i+1] = gp[i]+1;
        gpn++;
      }
    }
    int add = 0; //縦に切る回数
    vector<int> num(gpn+1,0);//各列の1の数を左からギリギリまで足していく
    bool ok = true; //縦1列の1がK個以下か 
    for(int w = 0; w < W; w++){
      vector<int> ones(gpn+1,0); //縦1列に含まれる1の個数をカウント
      bool cut = false; //縦に切るか
      for(int h = 0; h < H; h++){
        ones[gp[h]] += mp[h][w] - '0';
        num[gp[h]] += mp[h][w] - '0';
        if(ones[gp[h]] > K) ok = false;
        if(num[gp[h]] > K) cut = true; //この時、今カウントした列と前の列の間できる
      }
      if(cut){
        add++;
        num = ones; //numにさっきカウントした物を入れる
      }
    }
    if(ok) ans = min(ans, gpn + add);
  }
  cout << ans << endl;
}
          
      

Measured memory_bytes: 3632
import std.algorithm;
import std.bigint;
import std.concurrency;
import std.container;
import std.conv;
import std.functional;
import std.format;
import std.math;
import std.meta;
import std.numeric;
import std.random;
import std.range;
import std.stdio;
import std.string;
import std.traits;
import std.typecons;


auto solve(long N, long[] B) {
    auto A = new long[](cast(size_t) N);
    A.fill(-1);
    foreach (t; B.enumerate.array.sort!"a[1] < b[1]"()) {
        auto i = t[0];
        if (A[i] == -1)
            A[i] = B[i];
        if (A[i + 1] == -1)
            A[i + 1] = B[i];
    }
    return sum(A);
}


void main() {
    auto input = stdin.byLine.map!split.joiner;

    long N;
    N = input.front.to!long;
    input.popFront;

    long[] B = new long[](cast(size_t) (N-1));
    foreach (i; 0 .. cast(size_t) (N-1)) {
        B[i] = input.front.to!long;
        input.popFront;
    }

    static if (is(ReturnType!solve == void))
        solve(N, B);
    else
        solve(N, B).writeln;
}


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

int main()
{
    int sum = 0;
    int a = 0;
    char ch;
    stack< int > total;
    stack< pair< int , int > > subs;

    for( int i = 0; cin >> ch; i++)
    {
        if( ch == '\\' )
        {
            total.push( i );
        }
        else if( ch == '/' && total.size() > 0 )
        {
            
            int j = total.top();
            total.pop();
            sum += i - j;
	    a = i - j;
            while( subs.size() > 0 && subs.top().first > j )
	    {
                a += subs.top().second;
		subs.pop();
	    }
	    subs.push( make_pair( j, a ) );
        }
    }
    
    vector< int > ans;
    cout << sum << endl;
    cout << subs.size();
    while( !subs.empty() )
    {
        ans.push_back( subs.top().second );
	subs.pop();
    }
    reverse( ans.begin(), ans.end() );
    for( int i = 0; i < ans.size(); i++)
    {
        cout << ' ' << ans[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3232
#include<iostream>
using namespace std;
int main( )
{
	int n;
	cin>>n;
	int p=n % 10;
	if(p == 3) cout<<"bon"<<"\n";
	else if(p == 0 || p == 1 || p == 6 || p == 8 ) cout<<"pon"<<"\n";
	else cout<<"hon"<<"\n";
	
}

Measured memory_bytes: 3100
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define ld long double
#define pll pair<ll, ll>
#define pii pair<int, int>
#define f first
#define se second
#define pb push_back
#define ft fflush(stdout)
 
 
using namespace std;
 
 
const int N = 2e5 + 123;
const int PLS = 3e5 + 123;
const int mod = 1e9 + 7;
const ll inf = 1e16;


ll n, a[N], dp[N], k;


int main() {
    ios_base::sync_with_stdio(NULL);
    cin.tie(NULL); cout.tie(NULL);
    cin >> n >> k;
    for (int i = 1; i <= n; i++)
        cin >> a[i];
    dp[1] = 0;
    for (ll i = 2; i <= n; i++) {
        dp[i] = inf;
        for (ll j = i - 1; j >= max(1ll, i - k); j--)
            dp[i] = min(dp[i], dp[j] + abs(a[i] - a[j]));
    }
    cout << dp[n];
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <vector>

using namespace std; using ll=long long; const int INF=1e9;
typedef pair<int,int> P;
const int mx = 200000;

vector<int> v[mx]; int an[mx], a[mx]; int n; int pp[mx];

void dfs(int from, int now, int pc) {
  //cout<<from<<" "<<now<<" "<<pc<<" ";
  auto it = lower_bound(pp, pp+mx, a[now]);
  int pc2 = max(pc, (int)(it-pp));
  //cout<<pc2<<" ";
  int bf = *it;
  //cout<<bf<<endl;
  *it = a[now];
  an[now] = pc2;
  
  for(int x:v[now]) {
    if (x == from) continue;
    dfs(now, x, pc2);
  }

  *it = bf;
}

int main() {
  cin>>n;
  for(int i=0;i<n;i++) cin>>a[i];

  for(int i=0;i<n-1;i++) {
    int s,b; cin>>s>>b; s--; b--;
    v[s].push_back(b); v[b].push_back(s);
  }

  fill(pp, pp+mx, INF);

  dfs(-1, 0, 0);

  for(int i=0;i<n;i++) {
    cout<<an[i]+1<<endl;
  } 
}

Measured memory_bytes: 31244
#include<iostream>
#include<string>
#include<vector>
using namespace std;
#define N 100
vector<string> field;
int main() {
	int H, W;
	cin >> H >> W;
    cin.ignore();
	for (int i = 0; i < H; ++i) {
		string str;
		getline(cin, str);
		field.push_back(str);
	}
    
	for (int i = 0; i < H; ++i) {
        cout << field[i] << endl;
        cout << field[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;
class Z { static void Main() => new K(); }
class K
{
	int F => int.Parse(Str);
	long FL => long.Parse(Str);
	int[] G => Strs.Select(int.Parse).ToArray();
	long[] GL => Strs.Select(long.Parse).ToArray();
	string Str => ReadLine();
	string[] Strs => Str.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
	const int MOD = 1000000007;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		WriteLine(Str.Replace("2017", "2018"));
	}
}


Measured memory_bytes: 13140
#B問題
N = int(input())
S = []
for i in range(N):
    s = list(input().split())
    s.append(i+1)
    S.append(s)
    
for i in range(N):
    S[i][1] = int(S[i][1])

S.sort(key=lambda x:(x[0], -x[1]))

for i in range(N):
    print(S[i][2])
    

Measured memory_bytes: 3060
fun main(args: Array<String>){
    val N = readLine()!!.toInt()
    val P = readLine()!!.split(" ").map { it.toInt() }.map { it - 1 }.toIntArray()

    var count = 0
    for(i in 0 until N - 1){
        if(P[i] == i){
            P.swap(i, i + 1)
            count++
        }
    }
    if(P[N - 1] == N - 1){
        P.swap(N - 2, N - 1)
        count++
    }
    println(count)
}

fun IntArray.swap(i: Int, j: Int) {
    val tmp = this[i]
    this[i] = this[j]
    this[j] = tmp
}

Measured memory_bytes: 53724
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
using namespace std;
#define arep(i,x,n) for(int i=int(x);i<(int)(n);i++)
#define rep(i,n) for(long long i = 0;i < n;++i)
#define pi 3.141592653589793
#define eps 0.00000001
#define INF 1e9+7  
using ll = long long; 
using P=pair<int,int>;
using lP=pair<ll,ll>;
using fP=pair<double,double>;


int main(){
    int s,w;
    cin>>s>>w;
    if(w>=s)cout<<"unsafe"<<endl;
    else cout<<"safe"<<endl;
    
    return 0;
}

Measured memory_bytes: 3624
// Aizu Vol-5 0511: Who Are The Student Yet To Submit
// 2017.8.30 bal4u@uu

#include <stdio.h>

int main()
{
	int i, a;
	char c[31];

	for (i = 1; i <= 30; i++) c[i] = 0;
	for (i = 0; i < 28; i++) scanf("%d", &a), c[a] = 1;
	for (i = 1; i <= 30; i++) if (!c[i]) printf("%d\n", i);
	return 0;
}

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

using namespace std;


int main()
{
	int c = 0, ans = 0;
	char x;
	for (int i = 0; i < 3; ++i)
	{
		cin >> x;
		if (x == 'S')
			c = 0;
		else
			c++;
		ans = max(ans, c);
	}
	cout << ans << endl;
}


Measured memory_bytes: 3628
# -*- coding: utf-8 -*-
"""
Created on Sat Aug 31 13:18:21 2019

@author: arute
"""

from sys import stdin
import itertools



############################################

# read data for n sequences.
temp = stdin.readline().split()
W = int(temp[0])
H = int(temp[1])
x = int(temp[2])
y = int(temp[3])

area = W*H/2

if W/2 == x and H/2 == y:
    ans = 1
else:
    ans = 0

print(area, ans)

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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	Int n, m; cin >> n >> m;
	vector<vector<Int>> g(n, vector<Int>());
	for(Int i=0; i<m; ++i){
		Int a, b; cin >> a >> b; --a; --b;
		g[a].push_back(b); g[b].push_back(a);
	}
	queue<Int> q; q.push(0);
	bool f = true;
	vector<Int> v(n, -1); v[0] = 0;
	while(!q.empty()){
		Int p = q.front(); q.pop();
		for(size_t i=0; i<g[p].size(); ++i){
			Int t = g[p][i];
			if(v[t] == v[p]){
				f = false;
				break;
			}
			if(v[t] == -1){
				v[t] = 1 - v[p];
				q.push(t);
			}
		}
		if(!f) break;
	}
	if(!f){
		cout << n * (n-1) / 2 - m << "\n";
	}else{
		Int b = count(v.begin(), v.end(), 0);
		Int w = count(v.begin(), v.end(), 1);
		cerr << b << " " << w << "\n";
		for(size_t i=0; i<v.size(); ++i) cerr << i << " " << v[i] << "\n";
		cout << b * w - m << "\n";
	}
}

Measured memory_bytes: 7168
parseInt(x) = parse(Int, x)
parseBigInt(x) = parse(BigInt, x)
parseFloat(x) = parse(Float64, x)
parseBigFloat(x) = parse(BigFloat, x)
何故踊る(x::Array{SubString{String},1}) = map(parseInt, x)
母親の心がわかって(x) = split(x)
おそろしいのか() = readline()

function ドグラ_マグラ(arr)
    sx,sy,tx,ty=arr
    ans=""
    if ty>sy
        ans*="U"^(ty-sy)
    else
        ans*="D"^(sy-ty)
    end
    if tx>sx
        ans*="R"^(tx-sx)
    else
        ans*="L"^(sx-tx)
    end
    if ty>sy
        ans*="D"^(ty-sy)
    else
        ans*="U"^(sy-ty)
    end
    if tx>sx
        ans*="L"^(tx-sx+1)
    else
        ans*="R"^(sx-tx+1)
    end
    if ty>sy
        ans*="U"^(ty-sy+1)
    else
        ans*="D"^(sy-ty+1)
    end
    if tx>sx
        ans*="R"^(tx-sx+1)
    else
        ans*="L"^(sx-tx+1)
    end
    if ty>sy
        ans*="D"
    else
        ans*="U"
    end
    if tx>sx
        ans*="R"
    else
        ans*="L"
    end
    if ty>sy
        ans*="D"^(ty-sy+1)
    else
        ans*="U"^(sy-ty+1)
    end
    if tx>sx
        ans*="L"^(tx-sx+1)
    else
        ans*="R"^(sx-tx+1)
    end
    if ty>sy
        ans*="U"
    else
        ans*="D"
    end
    println(ans)
end

function main()
    胎児よ胎児よ = 何故踊る(母親の心がわかって(おそろしいのか()))
    ドグラ_マグラ(胎児よ胎児よ)
end
main()

Measured memory_bytes: 167276
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <chrono>

    #pragma GCC optimize("O3")
    #pragma GCC optimize("Ofast")
    #pragma GCC optimize("unroll-loops")
    /*#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
    #pragma GCC target ("avx2")*/

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;

ll MAX = 1e15;
double PI = 3.141592653589793238463;
//double PI = acos(-1);
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

ll gcd(ll a, ll b){
    return b==0 ? abs(a) : gcd(b, a%b);
}

ll md = 1000000007;

ll pows(ll a, ll n){
    if(n==0){
        return 1;
    }
    if(n%2==0){
        ll b = pows(a, n/2);
        return (b*b)%md;
    }
    return (pows(a, n-1)*a)%md;
}

void solve(){
    ll n;
    cin >> n;
    map<pair<ll,ll>, ll> mp;
    ll zeros=0;
    for(ll i=0; i<n; i++){
        ll a,b;
        cin >> a >> b;
        if(b<0){
            a*=-1;
            b*=-1;
        }
        ll d = gcd(a,b);
        if(d==0){
            zeros++;
            continue;
        }
        a/=d; b/=d;
        mp[{a,b}]++;
    }
    ll ans=1;
    for(auto smth : mp){
        pair<ll,ll> x = smth.first;
        ll amount = smth.second;
        ll a =x.first, b=x.second;
        ll tomult=pows(2, amount);
        mp[{a,b}]=0;
        swap(a,b);
        /*if(b<0){
            a*=-1;
            b*=-1;
        }*/
        b*=-1;
        if(mp.count({a,b})>0){
            tomult+=pows(2, mp[{a,b}]);
            tomult+=md-1;
            tomult%=md;
            mp[{a,b}]=0;
        }
        ans*=tomult;
        ans%=md;
    }
    ans+=md-1+zeros;
    ans%=md;
    cout << ans;
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif


    ll t=1;
    //cin >> t;
    while(t--){
        solve();
    }


    return 0;
}


Measured memory_bytes: 16068
#coding: utf-8

import sys

X = int(input())

powers = {}
def powered(i):
    if i in powers:
        return powers[i]
    powered = pow(i, 5)
    powers[i] = powered
    return powered

for a in range(1000, 0, -1):
    for b in range(0, 1000):
        poweredA = powered(a)
        poweredB = powered(b)
        if poweredA - poweredB == X:
            print(a, b)
            sys.exit()
        elif poweredA + poweredB == X:
            print(a, -b)
            sys.exit()

Measured memory_bytes: 9136
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
static const ll mod = 1e9 + 7;
static const ll INF = 1LL << 50;
using namespace std;

int imos(vector<int> &num){
	vector<int>cnt(num.size()+5);
	int maxv=0;
	cnt[0]=num[0];
	if(cnt[0]<0)cnt[0]=0;
	for(int i=1;i<num.size();++i){
		cnt[i]=cnt[i-1]+num[i];
		maxv=max(maxv,cnt[i]);
	}
	return maxv;
}


signed main(){
	std::ios::sync_with_stdio(false);
    std::cin.tie(0);
	ll n,k,q;
	cin>>n>>k>>q;
	vector<ll>num(n,k-q);
	rep(i,q){
		ll a;
		cin>>a;
		a--;
		num[a]++;
	}
	rep(i,n){
		if(num[i]>0)cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}
	return 0;
}


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

int main(){
	int N;
	cin >> N;
	int A[N], B[N];
	rep(i,N){
		cin >> A[i];
		B[i] = A[i];
	}
	sort(B,B+N);
	rep(i,N) {
		if (A[i] == B[N-1]) cout << B[N-2] << endl;
		else cout << B[N-1] << endl;
	}

	return 0;
}


Measured memory_bytes: 5108
N = int(input())
As = [int(i) for i in input().split()]

d = {}
for a in As:
    if a not in d:
        d[a] = 1
    else:
        d[a] += 1

# 全ての組み合わせの総数をcntに入れる
cnt = 0
for i in d.values():
    cnt += (i * (i-1)) // 2

# cntから自分を抜いて組み合わせの総数をprintする
for a in As:
    print(cnt-(d[a]-1))


Measured memory_bytes: 24748
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

typedef boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>> cpp_dec_float_1000;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }

void solve(void)
{
  int N, A; cin >> N >> A;
  auto ans = (N % 500) <= A;
  cout << (ans ? "Yes" : "No") << CRLF;
  return;
}

int main(void)
{
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(0);

  solve();

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
inline void chmin(int& a, int b) { a = min(a, b); }
    
const int INF = INT_MAX;
const int MAX_N  = 1000000;
const int BACKET = 500;
    
     
int main()
{
  int N, Q;
  int A[MAX_N];
  int small[MAX_N / BACKET + 1];
  char s[32];
    
  fill_n(A, MAX_N, INF);
  fill_n(small, MAX_N / BACKET + 1, INF);
    
  fgets(s, sizeof(s), stdin);
  sscanf(s, "%d %d", &N, &Q);
      
  while(Q--) {
    int t, a, b;
    fgets(s, sizeof(s), stdin);
    sscanf(s, "%d %d %d", &t, &a, &b);
    if(t == 0) {
      int curr = a / BACKET;
      bool update = small[curr] == A[a];
      A[a] = b;
      if(small[curr] >= b) {
        small[curr] = b;
      } else if(update) {
        small[curr] = INF;
        for(int i = 0; i < BACKET; i++) chmin(small[curr], A[curr * BACKET + i]);
      }
    } else {
      int begin = (a + BACKET - 1) / BACKET;
      int end   = b / BACKET;
      int ret = INF;
      if(begin >= end) {
        for(int i = a; i <= b; i++) chmin(ret, A[i]);
      } else {
        for(int i = begin; i < end; i++) chmin(ret, small[i]);
        if(ret > small[begin - 1]) for(int i = begin * BACKET - 1; i >= a; i--) chmin(ret, A[i]);
        if(ret > small[end]) for(int i = end * BACKET; i <= b; i++) chmin(ret, A[i]); 
      }
      printf("%d\n", ret);
    }
  }
}



Measured memory_bytes: 7128
parseInt(x) = parse(BigInt, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
	k = readline() |> parseInt
	a = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
	println(a[k])
end

main()

Measured memory_bytes: 114820
#include <bits/stdc++.h>
using namespace std;
#define idfc ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
#define ll long long
#define pb push_back
#define mp make_pair
#define nt _int128
#define ld long double
long double PI =3.14159265358979323846;
 
 
const ll modo=1e9+7;
const ll inf=2e14;
const ll ms=(1e5) +5;
 
int x,y;
int ar[30][30];
int vis[30][30];
int dis[30][30];
 
bool check(int i,int j)
{
    if(i>=1&&i<=x&&j>=1&&j<=y&&!vis[i][j]&&ar[i][j])return true;
    return false;
}
 
int func(int i,int j,int a,int b)
{
    vis[i][j]=1;
    dis[i][j]=dis[a][b]+1;
    return dis[i][j];
}
 
int callme(int i,int j)
{
  vis[i][j]=1;
   queue<pair<int,int>> qq;
   qq.push({i,j});
   int a,b;
   int mx=0;
   while(!qq.empty())
   {
       auto it=qq.front();
       qq.pop();
       a=it.first;
       b=it.second;
       if(check(a-1,b))
       {
           mx=max(func(a-1,b,a,b),mx);
           qq.push({a-1,b});
       }
       if(check(a+1,b))
       {
           mx=max(mx,func(a+1,b,a,b));
           qq.push({a+1,b});
       }
       if(check(a,b-1))
       {
           mx=max(mx,func(a,b-1,a,b));
           qq.push({a,b-1});
       }
       if(check(a,b+1))
       {
           mx=max(mx,func(a,b+1,a,b));
           qq.push({a,b+1});
       }
   }
   return mx;
}
 
 
 
int main()
{
    idfc;
    cin>>x>>y;
    int i;int j;
    char e;
    for(i=1;i<=x;i++)
    {
        for(j=1;j<=y;j++)
        {
           cin>>e;
           if(e=='.')ar[i][j]=1;
           else ar[i][j]=0;
        }
    }
    int ans=0;
    for(i=1;i<=x;i++)
    {
        for(j=1;j<=y;j++)
        {
            if(ar[i][j])
            {
                memset(vis,0, sizeof(vis));
                memset(dis,0, sizeof(dis));
                ans=max(ans,callme(i,j));
            }
        }
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>

using namespace std;

long long d=0;
bool flag=0;

long long gcd(long long a,long long b){
	if(a%b==0)return b;
	return gcd(b,a%b);
}

long long judge(long long x,long long y){
	return abs(x)+abs(y);
}

pair<long long,long long> calc(long long a,long long b,long long x,long long y){
	if(a*x+b*y==d)return pair<long long,long long>(x,y);
	if(a*x+b*y==-d)return pair<long long,long long>(-x,-y);
	flag^=1;
	long long n=a*x+b*y,tmp=0;
	if(b%n==0)return calc(b,a,y,x);
	tmp=b/n;
	x*=tmp;
	y=y*tmp-1;
	long long k=(x+y)/(b-a);
	x-=b*k;
	y+=a*k;
	return calc(b,a,y,x);
}
 
int main(){
	long long a=0,b=0;
	cin>>a>>b;
	if(a==b){cout<<"0 1"<<endl;return 0;}
	d=gcd(a,b);
	pair<long long,long long> ans=calc(a,b,1,0);
	if(flag){long long tmp=ans.first;ans.first=ans.second;ans.second=tmp;}
	long long k=(ans.first+ans.second)/(b-a);
	ans.first-=b*k;
	ans.second+=a*k;

	while(judge(ans.first-b/d,ans.second+a/d)<judge(ans.first,ans.second)){ans.first-=b/d;ans.second+=a/d;}
	while(judge(ans.first+b/d,ans.second-a/d)<judge(ans.first,ans.second)){ans.first+=b/d;ans.second-=a/d;}

	cout<<ans.first<<" "<<ans.second<<endl;
	return 0;
}

Measured memory_bytes: 1164
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
 
struct node{
    unsigned int key;
    struct node *next;
    struct node *prev;
};
 
typedef struct node * NodePointer;
 
NodePointer nil;
 
NodePointer listSearch(int key){
    NodePointer cur = nil->next;
    while(1){
        if ( cur == nil ) break;
        if (cur->key == key) return cur;
        cur = cur->next;
    }
    return nil;
}
 
void init(){
    nil = (NodePointer) malloc(sizeof(struct node));
    nil->next = nil;
    nil->prev = nil;
}
 
void printList(){
    NodePointer cur = nil->next;
    int isf = 1;
    while(1){
        if ( cur == nil ) break;
        if ( isf == 0)  printf(" ");
        printf("%d", cur->key);
        cur = cur->next;
        isf = 0;
    }
    printf("\n");
}
 
void deleteNode(NodePointer t){
    if (t == nil) return;
    t->prev->next = t->next;
    t->next->prev = t->prev;
    free(t);
}
 
void deleteFirst(){
    NodePointer t = nil->next;
    if ( t == nil ) return;
    deleteNode(t);
}
 
void deleteLast(){
    NodePointer t = nil->prev;
    if ( t == nil ) return;
    deleteNode(t);
}
 
void delete(int key){
    NodePointer t = listSearch(key);
    deleteNode(t);
}
 
 
void insert(int key){
    NodePointer x;
    x = malloc(sizeof(struct node));
    x->key = key;
    x->next = nil->next;
    x->prev = nil;
    if (nil->prev == nil) {
        nil->prev = x;
    }
 
    nil->next->prev = x;
    nil->next = x;
}
 
int main(){
    int key, n, i;
    int size = 0;
    char com[20];
    int np = 0, nd = 0;
    scanf("%d", &n);
    init();
    for ( i = 0; i < n; i++ ){
        scanf("%s%d", com, &key);
        if ( com[0] == 'i' ) {insert(key); np++; size++;}
        else if ( com[0] == 'd' ) {
            if (strlen(com) > 6){
                if ( com[6] == 'F' ) deleteFirst();
                else if ( com[6] == 'L' ) deleteLast();
            } else {
                delete(key); nd++; 
            }
            size--;
        }
    }
    printList();
    return 0;
}


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

using namespace std;

void CheckCard(char mark,int number,vector<vector<int>>& v)
{
  switch(mark)
  {
    case 'S':
      v[0][number-1]=1;
      break;
    case 'H':
      v[1][number-1]=1;
      break;
    case 'C':
      v[2][number-1]=1;
      break;
    case 'D':
      v[3][number-1]=1;
      break;
  }
}

void PrintCard(vector<vector<int>>& v)
{
  for(int i=0;i<4;i++)
  {
    for(int j=0;j<13;j++)
    {
      if(v[i][j]==0)
      {
        switch (i)
        {
          case 0:
            cout << "S " << j+1 << endl;
            break;
          case 1:
            cout << "H " << j+1 << endl;
            break;
          case 2:
            cout << "C " << j+1 << endl;
            break;
          case 3:
            cout << "D " << j+1 << endl;
            break;
        }
      }
    }
  }
}

int main(int argc, char* argv[])
{
  int total,number;
  char mark;
  vector<vector<int>> trump(4,vector<int>(13,0));
  cin >> total;
  for(int i=0;i<total;i++)
  {
    cin >> mark >> number;
    CheckCard(mark,number,trump);
  }
  PrintCard(trump);
}

Measured memory_bytes: 3120