akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#define N 36

typedef struct{
  char kind;
  int number;
}Trump;
  
int main(void){
  int n, i, j, s, min;
  Trump x[N], y[N], t;
  
  scanf("%d",&n);
  
  for(i = 0 ; i < n ; i++){
    scanf("%c%c%d",&x[i].kind, 
                 &x[i].kind,
                 &x[i].number);
    y[i] = x[i];
  }
    
  for(i = 0 ; i < n ; i++){
    for(j = n-1 ; j >= i+1 ; j--){
      if(x[j].number < x[j-1].number){
        t = x[j];
        x[j] = x[j-1];
        x[j-1] = t;
      }
    }
  }    
      
    
  for(i = 0 ; i < n ; i++){
    min = i;
    for(j = i ; j < n ;j++)
      if(y[j].number < y[min].number)
        min = j;
      t = y[i];
      y[i] = y[min];
      y[min] = t;     
  }
  
  
  
  
  for( i = 0; i < n-1; i++){
    printf("%c%d ", x[i].kind, x[i].number);
  }
  printf("%c%d\n", x[n-1].kind, x[n-1].number);
  printf("Stable\n");
   
  for( i = 0; i < n-1; i++){
    printf("%c%d ", y[i].kind, y[i].number);
  }
  printf("%c%d\n", y[n-1].kind, y[n-1].number);
  
  s = 1;
  
  for(i = 0; i < n; i++)
    if(x[i].kind != y[i].kind)
      s = 0;
  
  if(s == 1)
    printf("Stable\n");
  else
    printf("Not stable\n");
   
  return 0;
}

Measured memory_bytes: 1764
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<functional>
#include<map>
#include<unordered_set>
using namespace std;
/*int p = 998244353;*/
int p = 1000000007;
#define int long long
#define vel vector<long long>
#define vvel vector<vel>
#define rep(i,n) for(int i=0;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define mmax(a,b) a=max(a,b)
#define mmin(a,b) a=min(a,b)
#define mkp make_pair
#define pin pair<int,int>
#define qin pair<int,pin>
#define V vector
#define Endl endl
#define veb vector<bool>
#define rev(s) reverse(s.begin(),s.end())
#define end_pr(s) cout << s <<endl;return 0
signed main(){
	int a, b; cin >> a >> b;
	cout << (a + b) / 2 << endl;
}


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

int main(){
  char b;
  cin >> b;
  if(b == 'A'){
    cout << 'T' << endl;
  }
  if(b == 'T'){
    cout << 'A' << endl;
  }
  if(b == 'C'){
    cout << 'G' << endl;
  }
  if(b == 'G'){
    cout << 'C' << endl;
  }
}

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

int main()
{
  int n,x,sum;
  while(1){
    cin>>n>>x;
    if(n==0&&x==0)break;
    sum=0;
    for(int i=1;i<n+1;i++){
      for(int j=i+1;j<n+1;j++){
	for(int k=j+1;k<n+1;k++){
	  if((i+k+j)==x)sum++;
	}
      }
    }
    cout<<sum<<endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
int n,m,ans=0,a[110],num=0;

bool cmp(int a,int b)
{
    return a>b;
}

int main() 
{   cin>>n>>m;
    for(int i=1;i<=n;++i)
        cin>>a[i],ans+=a[i];
    sort(a+1,a+1+n,cmp);
    if(a[m]*4*m<ans)
        cout<<"No"<<endl;
    else
        cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e9+7;
int mod = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main() {
    int N;
    cin >> N;
    bool ok = false;
    for(int i = 0; i < N; i++) {
        int a;cin >> a;
        if(a%2 == 1) {
            ok = true;
        }
    }
    if(ok) {
        cout << "first" << endl;
    }
    else {
        cout << "second" << endl;
    }
}


Measured memory_bytes: 3584
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



ll N,P;
ll table[10005];
char buf[200005];

int main(){

	scanf("%lld %lld",&N,&P);
	scanf("%s",buf);

	ll ans = 0;

	if(P == 2 || P == 5){

		for(ll i = 0; i < N; i++){
			if((buf[i]-'0')%P == 0){

				ans += (i+1);
			}
		}
		printf("%lld\n",ans);

		return 0;
	}

	for(int i = 0; i < P; i++){

		table[i] = 0;
	}

	table[0] = 1;
	ll num = 0;
	ll mult = 1;

	for(int i = N-1; i >= 0; i--){

		num = num+mult*(buf[i]-'0');
		num %= P;
		table[num]++;

		mult *= 10;
		mult %= P;
	}

	for(int i = 0; i < P; i++){

		ans += (table[i]*(table[i]-1))/2;
	}

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

	return 0;
}


Measured memory_bytes: 512
H,W,N = $stdin.gets.chomp.split(" ").map(&:to_i)

painted = {}

N.times{
 i,j = $stdin.gets.chomp.split(" ").map(&:to_i)
 ([-1,0,1]).product([-1,0,1]).map{ |a,b| [i+a-1,j+b-1] }.select{ |i,j| 0 < i && i < H-1 && 0 < j && j < W-1 }.each{ |i,j|
   k = W*i+j
   painted[k] = (painted[k] || 0) + 1
 }
}

cnt = Hash[(0..9).map{ |n| [n,0] }]
cnt[0] = (H-2)*(W-2) - painted.size
painted.each{ |k,n| cnt[n] += 1 }
cnt.each{ |n,m| puts m }


Measured memory_bytes: 60156
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define repr(e,x) for(auto& e:x)
#define MOD 1'000'000'007
using namespace std;
typedef long long ll;
typedef long double ld;

ll mpow(ll x,ll n){
    if(n==0) return 1;
    else if(n%2) return x*mpow(x,n-1)%MOD;
    return mpow(x*x%MOD,n/2)%MOD;
}

ll mfrac(ll n){
    if(n==0) return 1;
    else return n*mfrac(n-1)%MOD;
}

ll mperm(ll n,ll r){
    ll res=1;
    for(ll i=0;i<r;i++) res=res*(n-i)%MOD;
    return res;
}

ll mcomb(ll n,ll r){
    if(r>n-r) r=n-r;
    ll res=mperm(n,r);
    return res*mpow(mfrac(r),MOD-2)%MOD;
}

ll N,M;

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

    ll ans=0;
    if(abs(N-M)==0){
        ans=mfrac(N)*mfrac(M)%MOD*2%MOD;
    }else if(abs(N-M)==1){
        ans=mfrac(N)*mfrac(M)%MOD;
    }

    cout<<ans<<endl;
}

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

using namespace std;

#define all(x) x.begin(), x.end()
#define sz(x) (int) x.size()
#define pb push_back
#define endl '\n'
#define snd second
#define fst first
#define fastio cin.tie(NULL),cout.sync_with_stdio(true)

typedef long long int ll;
typedef unsigned long long int ull;
typedef vector <int> vi;
typedef pair <ll,int> ii;
typedef pair <ii,int> iii;

const int mod = 1e9 + 7;
const int N = 200005;

ll v[N];

void solve(){
	int n;
	cin >> n;
	double ans = 0.0;
	bool zero = 0;
	for(int i = 0; i < n; i++){
		cin >> v[i];
		if(v[i] == 0)zero = 1;
		ans += log10(v[i]);
	}
	if(zero)cout << 0 << endl;
	else{
		if(ans > 18)cout << -1 << endl;
		else{
			ll res = 1;
			for(int i = 0; i < n; i++)
				res *= v[i];
			cout << (res<=1000000000000000000?res:-1) << '\n';
		}
	}
}

int main(){
	fastio;
	int t = 1;
	//cin >> t;
	while(t--)
		solve();
	return 0;
}


Measured memory_bytes: 4580
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>

using namespace std;


int main() {
	map<int, int> mp;
	long long int n, m=0,tmp=1,ax=0,k=0,t[500000],x,y,res=0,a,b,c,GCD,two=1,kisuu=0,p,q,r,type=0;
	string str, str2[5000];
	cin>>n;
	

	for (int i =0; i <n; i++) {
		cin >> t[i];
		if (t[i] % 2 == 1) { m++; }
		
	}
	if (m % 2 == 1) { cout << "NO"; }
	else { cout << "YES"; }
	
}

Measured memory_bytes: 2944
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main(){

	int n, m, p;
	
	while(cin>>n>>m>>p, n){
		
		int x[110], sum = 0;
		
		for(int i=1; i<=n; ++i){
			cin >> x[i];
			sum += x[i];
		}
		
		if(x[m])
			cout << sum*(100-p)/x[m] << endl;
		else
			cout << 0 << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1160
from string import ascii_lowercase


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


def solve(n):
    if n == 1:
        return [["a"]]

    tmp = solve(n - 1)

    lower = list(ascii_lowercase)
    ret = []
    for t in tmp:
        m_t = max(t)
        for i in range(lower.index(m_t) + 2):
            ret.append(t + [lower[i]])
    return ret


N = int(input())
ans = solve(N)
for a in ans:
    print("".join(a))


Measured memory_bytes: 25932
a, b, k = gets.chomp.split(" ").map(&:to_i)
ans=[]
for i in 0...k do
  if a+i<=b then
    ans.push(a+i)
  end
end
for i in 0...k do
  if ans.find { |n| n==b-i } == nil && b-i>=a then
    ans.push(b-i)
  end
end
ans.sort!
for i in 0...ans.length do
    p ans[i]
end


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

using namespace std;

int main() {

	int n;
	cin >> n;
	vector < vector<int>> G(n + 1);

	//グラフ隣接リスト読み込み
	int a, b, c;
	for (int i = 1; i <= n; i++) {
		cin >> a >> b;
		for (int j = 0; j < b; j++) {
			cin >> c;
			G[a].push_back(c);
		}
	}

	//幅優先探索処理
	vector<bool> seen(n + 1, false);	//発見したらtrue
	deque<int> todo;					//行く所のスタック

	int s=1;							//今いる場所
	vector<int> dist(n+1,0);			//1からの距離（この問題で使う変数）

	int j = 1; //この問題では１から到達できるところを調べる
//	for (int j = 1; j <= n; j++) {		//全ての頂点を調べる
		if (seen[j] == false) {			//訪れてなかったら処理すすめる
			seen[j] = true;
			todo.push_back(j);

			while (todo.empty() != true) {				//スタックが空になるまで処理	
				s = todo.front();						//処理番号を指定
				int tugiflg = false;					//次があったらtrueにするフラグ
				for (int i = 0; i < G[s].size(); i++) {
					if (seen[G[s][i]] != true) {
						seen[G[s][i]] = true;
						todo.push_back(G[s][i]);
						dist[G[s][i]] = dist[s]+1;		//この問題でのみ使う（1からの距離）
						tugiflg = true;
					}
				}
				todo.pop_front(); //次を全部探したので削除する
			}
		}
//	}

	for (int i = 1; i <= n; i++) {
		if (i != 1 && dist[i] == 0) { dist[i] = -1; }
		cout << i << " " << dist[i]  << endl;
	}

	return 0;

}


Measured memory_bytes: 3168
#include <iostream>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;

const string YES = "Yes";
const string NO = "No";

void solve(long long N){
    bool ans = false;
    REP(i, 26) REP(j, 16)
        if (4 * i + 7 * j == N) ans = true;
    if (ans) cout << "Yes" << '\n';
    else cout << "No" << '\n';
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


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

public class Main {
	public static void main(String[] args) {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    
		String x = "";
		try {
			while ((x = in.readLine()).equals("0 0") == false) {
				String[] data = x.split(" ");
				int n = Integer.parseInt(data[0]);
				int sum = (Integer.parseInt(data[1]) - 3);
				
				int num = 0;
				for (int i = 0; i < n; i++) {
					for (int j = (i + 1); (i + j) < sum; j++) {
						int k = sum - (i + j);
						if ((k > j) && (k < n)) num++;
					}
				}
				
				System.out.println(num);
			}
		} catch (NumberFormatException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}

Measured memory_bytes: 24276
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        // 整数の入力
        int N=sc.nextInt();
        int[] L=new int[N];
        for(int i=0;i<N;i++){
            L[i]=sc.nextInt();
        }
        int result=0;
        for(int a=0;a<N;a++){
            for(int b=a+1;b<N;b++){
                for(int c=b+1;c<N;c++){
                    if(L[a]!=L[b]&&L[b]!=L[c]&&L[c]!=L[a]){

                    if(L[a]+L[b]>L[c]&&L[b]+L[c]>L[a]&&L[c]+L[a]>L[b]){
                        result++;
                    }
                    }

                }
            }
        }

        System.out.println(result);

    }
}

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

typedef long long ll;
const int maxn=2*3e2+10,mod=1e9+7;
int n,k,a[maxn],sum[maxn];
ll fac[maxn],ans,powinv2[maxn],finv[maxn];

inline ll fpow(ll a,ll n){
	ll res=1;
	for(;n;n>>=1,a=a*a%mod)
		if(n&1ll)
			res=res*a%mod;
	return res;
}
inline void init(){
	fac[0]=1;
	for(int i=1;i<maxn;++i)
		fac[i]=fac[i-1]*i%mod;
	powinv2[0]=1;
	for(int i=1;i<maxn;++i)
		powinv2[i]=powinv2[i-1]*(mod+1>>1)%mod;
	for(int i=0;i<maxn;++i)
		finv[i]=fpow(fac[i],mod-2)%mod;
}

int main(){
	init();
	cin>>n>>k;
	for(int i=1,x,y;i<=k;++i){
		cin>>x>>y;
		a[x]=y;
		a[y]=x;
	}
	for(int i=1;i<=n<<1;++i)
		sum[i]=sum[i-1]+!a[i];
	for(int i=1;i<=n<<1;++i){
		static int dp[2][maxn];
		memset(dp,0,sizeof(dp));
		dp[i&1^1][0]=1;
		for(int j=i,most=0;j<=n<<1;++j){
			memset(dp[j&1],0,sizeof(dp[j&1]));
			if(a[j]&&a[j]<i)
				break;
			if(a[j])
				for(int k=0;k<=n<<1;++k)
					dp[j&1][k]=dp[j&1^1][k];
			else{
				for(int k=1;k<=n<<1;++k)
					dp[j&1][k-1]=(ll)k*dp[j&1^1][k]%mod;
				for(int k=0;k<=n<<1;++k)
					(dp[j&1][k+1]+=dp[j&1^1][k])%=mod;
			}
			if(a[j])
				most=max(most,a[j]);
			if(most<=j){
				int rest=sum[i-1]+sum[n<<1]-sum[j];
				(ans+=dp[j&1][0]*fac[rest]%mod*finv[rest/2]%mod*powinv2[rest/2])%=mod;
				dp[j&1][0]=0;
			}
		}
	}
	printf("%lld\n",ans);
	return 0;
}

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

#include <bits/stdc++.h>

using namespace std;

#define forn(i, n) for (long long i = 0; i < (long long) (n); ++i)
#define pb emplace_back
#define endl '\n'

template<typename T> void _dbg(const char*_s,T _h) { cerr<<_s<<" = "<<_h<<"\n"; }

template<typename T, typename... Ts> void _dbg(const char*_s,T _h,Ts... _t) {
    for(int _b=0;((_b+=*_s=='(')-=*_s==')')!=0||*_s!=',';)cerr<<*_s++;
    cerr<<" = "<<_h<<",";_dbg(_s+1,_t...);
}

#define int long long

#ifdef LOCAL
    #define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
    #define dbg(...)
#endif

const int N = 200 * 1000 + 17;
const int MOD = 1000 * 1000 * 1000 + 7;

int n, m;
string s;
int dp[N], p[N];

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

    return true;
}

void solve() {
    if (s[0] == '1' || s[n] == '1') {
        cout << "-1\n";
        return ;
    }

    dp[n] = 0;
    set< pair<int, int> > st;
    st.insert({0, n});

    for (int i = n - 1; i >= 0; --i) {
        if (i + m + 1 <= n)
            st.erase({dp[i + m + 1], i + m + 1});

        if (s[i] == '0') {
            dp[i] = st.begin()->first + 1;
            p[i] = st.begin()->second;
        } else {
            dp[i] = MOD;
        }

        st.insert({dp[i], i});
    }

    if (dp[0] >= MOD) {
        cout << "-1\n";
        return ;
    }

    for (int i = 0; i < n; i = p[i])
        cout << p[i] - i << ' ';

    cout << endl;
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    while (read())
        solve();

    return 0;
}



Measured memory_bytes: 7936
#include <bits/stdc++.h>
using namespace std;
#define sync ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define rep(i,n) for(int i=0; i<int(n); ++i)
#define repp(i,a,n) for(int i=a; i<int(n); ++i)
#define sz(x) (x).size()
#define pq priority_queue
#define pb push_back
#define mp make_pair

#define dbg(x) cerr << #x" = " << x << endl
#define debug(...) fprintf(stderr, __VA_ARGS__)

template<class T> std::ostream& operator<<(std::ostream& os, const std::vector<T> &input){for (auto const& i: input) {os << i << " ";}return os;}
template<class T1,class T2> std::ostream& operator<<(std::ostream& os, const std::pair<T1,T2> &input){os << "(" << input.first << ", " << input.second << ')';return os;}

typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<pi> vp;
typedef vector<ll> vl;
typedef vector<vi> vvi;


const int maxn = 50;

void pre(){
}

void solve(){
	int x,y;
	cin >> x >> y;
	cout << ((x*2<=y && x*4>=y && y%2==0) ? "Yes": "No") <<endl;
}


int main() {
    sync;
    int cas = 1;
    // cin >> cas;
    pre();
    rep(ca, cas) solve();
    return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
 
using namespace std;
 
int n, m, q, x[505][505];
int ta, tb;
 
int main() {
	scanf("%d%d%d", &n, &m, &q);
	while (m--) {
		scanf("%d%d", &ta, &tb);
		x[0][tb]++;
		x[ta + 1][tb]--;
	}
	for (int i = 0; i < 503; i++)
		for (int j = 0; j < 503; j++) {
			x[i + 1][j] += x[i][j];
			x[i][j + 1] += x[i][j];
			x[i + 1][j + 1] -= x[i][j];
		}
	while (q--) {
		scanf("%d%d", &ta, &tb);
		printf("%d\n", x[ta][tb]);
	}
	return 0;
}

Measured memory_bytes: 1920
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

n = INT()
p = LIST()

ans = 0
ma = 0
# for i in range(n):
#     flag = True
#     pi = p[i]
#     if ma > pi:
#         flag = False
#         ma = pi
#     # ma = pi
#     # for j in range(i, -1, -1):
#     #     if pi > p[j]:
#     #         flag = False
#     if flag ==True:
#         ans += 1
# print(ans)
ans = 1
m = p[0]
for i in range(1, n):
    if m > min(m, p[i-1]):
        m = min(m, p[i-1])
        # print(m)
    if m >=  p[i]:
        ans += 1
    # m = p[0:i]
    # print(m)

print(ans)




Measured memory_bytes: 27196
use itertools::Itertools;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let 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 $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")
    };
}

fn main() {
    input! {
        n: usize,
        ps: [usize; n],
        qs: [usize; n],
    }

    let perms = (1..n + 1).permutations(n);

    let mut s1i = 0;
    for item in perms {
        let mut flag = false;
        for (index, value) in item.iter().enumerate() {
            let a = ps[index];
            let v = *value as usize;
            if a != v {
                flag = true;
                break;
            }
        }

        s1i += 1;
        if !flag {
            break;
        }
    }

    let mut s2i = 0;
    for item in (1..n + 1).permutations(n) {
        let mut flag = false;
        for (index, value) in item.iter().enumerate() {
            let a = qs[index];
            let v = *value as usize;
            if a != v {
                flag = true;
                break;
            }
        }

        s2i += 1;
        if !flag {
            break;
        }
    }

    println!("{}", ((s1i - s2i) as i32).abs());
}


Measured memory_bytes: 2148
#include <stdio.h>
void swap_int(int* x, int* y) {
    int temp;
    temp = *x;
    *x = *y;
    *y = temp;
}
void swap_char(char* x, char* y) {
    char temp;
    temp = *x;
    *x = *y;
    *y = temp;
}

void sort(int* array, int n, int mode) {
    int i, j;
    if (mode) {  // 1 is ascending order
        for (i = 0; i < n - 1; i++) {
            for (j = i + 1; j < n; j++) {
                if (array[i] > array[j]) {
                    swap_int(&array[i], &array[j]);
                }
            }
        }
    } else {  // 0 is descending order
        for (i = 0; i < n - 1; i++) {
            for (j = i + 1; j < n; j++) {
                if (array[i] < array[j]) {
                    swap_int(&array[i], &array[j]);
                }
            }
        }
    }
}
int max(int x, int y) {
    if (x > y) {
        return x;
    } else {
        return y;
    }
}
int min(int x, int y) {
    if (x > y) {
        return y;
    } else {
        return x;
    }
}

int main(void) {
    int a, b;

    scanf("%d %d", &a, &b);
    if (13 <= a) {
        printf("%d\n", b);
    } else if (6 <= a && a <= 12) {
        printf("%d\n", b / 2);
    } else {
        printf("0\n");
    }
    return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)
#define eprintf(...) fprintf(stderr, __VA_ARGS__)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

char S[1011][1011];
bool F(int n, int m, int a, int b) {
    int g = (a+a%2)/2 + (b+b%2)/2;
    int h = n*m/4;
    if (g <= h) {
	for (int i=0; i<n; i+=2) for (int j=0; j<m; j+=2) {
	    if (a) {
		REP (t, 2) {
		    if (a) {
			S[i+t][j] = '<';
			S[i+t][j+1] = '>';
			a--;
		    }
		}
	    } else if (b) {
		REP (t, 2) {
		    if (b) {
			S[i][j+t] = '^';
			S[i+1][j+t] = 'v';
			b--;
		    }
		}
	    }
	}

	return true;
    } else {
	return false;
    }
}

int N, M;
int A, B;

void MAIN() {
    scanf("%d%d%d%d", &N, &M, &A, &B);
    bool yes;
    memset(S, '.', sizeof S);
    if ((N&1) && (M&1)) {
	int ga = min(A, M/2);
	int gb = min(B, N/2);
	yes = F(N-1, M-1, A-ga, B-gb);
	if (yes) {
	    REP (i, ga) {
		S[N-1][2*i] = '<';
		S[N-1][2*i+1] = '>';
	    }
	    REP (j, gb) {
		S[2*j][M-1] = '^';
		S[2*j+1][M-1] = 'v';
	    }
	} else if (N >= 3 && M >= 3) {
	    int a = A-ga, b = B-gb;
	    if (a && b) {
		a--; b--;
		int g = (a+a%2)/2 + (b+b%2)/2;
		int h = (N-1)*(M-1)/4;
		if (g <= h-1) {
		    yes = true;
		    F(N-1, M-1, A-ga-1, B-gb-1);
		    REP (i, ga-1) {
			S[N-1][2*i] = '<';
			S[N-1][2*i+1] = '>';
		    }
		    REP (j, gb-1) {
			S[2*j][M-1] = '^';
			S[2*j+1][M-1] = 'v';
		    }
		    const char z[4][4] = {
			"^<>",
			"v.^",
			"<>v",
		    };

		    REP (i, 3) REP (j, 3) S[N-3+i][M-3+j] = z[i][j];
		}
	    }
	}
    } else if (N&1) {
	int ga = min(A, M/2);
	yes = F(N-1, M, A-ga, B);
	if (yes) {
	    REP (i, ga) {
		S[N-1][2*i] = '<';
		S[N-1][2*i+1] = '>';
	    }
	}
    } else if (M&1) {
	int gb = min(B, N/2);
	yes = F(N, M-1, A, B-gb);
	if (yes) {
	    REP (j, gb) {
		S[2*j][M-1] = '^';
		S[2*j+1][M-1] = 'v';
	    }
	}
    } else {
	yes = F(N, M, A, B);
    }

    if (yes) {
	puts("YES");
	REP (i, N) {
	    S[i][M] = 0;
	    puts(S[i]);
	}
    } else {
	puts("NO");
    }
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



Measured memory_bytes: 2176
n, k = (int(x) for x in input().split())
c = 0
if k == 0:
    print(n*n)
else:
    for i in range(k+1, n+1):
        c += (i-k)*(n//i)
        m = n%i
        if m-k+1 >= 0:
            c += m-k+1
    print(c)


Measured memory_bytes: 2940
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
#define long long LL     
#define MAXN=1e4+10    


int main(){
	int x1,x2,y1,y2,a,w,h,s;
	int ans=1;
	int W,H,N,X,Y;
	int sq;
	int flag=1;
	cin>>W>>H>>N;
	w=W;
	h=H;
	x1=0;
	x2=W;
	y1=0;
	y2=H;
	while(N--){
	     cin>>X>>Y>>a;
     	if(a==1){
	 	    if(X>x1){
	 	    	x1=X;
			 }
	    }else if(a==2){
	 		if(x2>X){
	 			x2=X;
			 }
	    }else if(a==3){
	 		if(Y>y1){
	 			y1=Y;
			 }
	    }else if(a==4){
	 		if(Y<y2){
	 			y2=Y;
			 }
	    }

	}
	if((x2-x1)<0 ||(y2-y1)<0){
		flag=0;
	}
	if(flag==0){
		sq=0;
		cout<<sq<<endl;
	}else{
		sq=(x2-x1)*(y2-y1);
		cout<<sq<<endl;
	}
	
	/*
	sq=(x2-x1)*(y2-y1);
	if(sq>=0){
		cout<<sq<<endl;
	}else{
		cout<<0<<endl;
	} 
	/*
	cin>>a>>b>>x;
	if(a+b==c || a+c==b || b+c==a){
		ans=1;
	}
	if(ans==1){
		cout<<"Yes"<<endl;
	}else if(ans==0){
		cout<<"No"<<endl;
	}
	*/
	return 0;
}

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

using namespace std;

typedef long long ll;

#define FOR(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR1(i,n) for(int (i)=1;(i)<(n);(i)++)
#define eFOR(i,n) for(int (i)=0;(i)<=(n);(i)++)
#define eFOR1(i,n) for(int (i)=1;(i)<=(n);(i)++)
#define SORT(i) sort((i).begin(),(i).end())
#define INF 1000000000

int main() {

	int n;
	cin >> n;
	eFOR(i, 14) {
		eFOR(j, 25) {
			if (i * 7 + j * 4 == n) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 256
import numpy as np
N, M, Q = map(int, input().split()) # N個の都市、M本の列車、Q個のクエリ
grid = np.zeros((N+1, N+1), dtype=np.int64)
query = []
for _ in range(M):
    L, R = map(int, input().split())
    grid[L, R] += 1
cum_grid = grid.cumsum(axis=0).cumsum(axis=1)

ans_list = []
for _ in range(Q):
    p, q = map(int, input().split())
    ans = cum_grid[q, q] - cum_grid[p-1, q] - cum_grid[q, p-1] + cum_grid[p-1, p-1]
    ans_list.append(ans)

for ans in ans_list:
    print(ans)

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

int main() {
  int a, b, c = 1;
  cin >> a >> b;
  int s = a * b;
  for (int i = 0; i < 3; i++) {
    if (s*c%2 != 0) {
      cout << "Yes" << endl;
      break;
    }
    else {
      if (i < 2) {
        c++;
      }
      else {
        cout << "No" << endl;
        break;
      }
    }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF    	((ll)1ll<<60)
#define INF     	((int)1<<30)
#define EPS     	(1e-9)
#define MOD     	(1000000007ll)
#define fcout(a)	cout<<setprecision(a)<<fixed
#define fs 			first
#define sc			second
#define PI			3.1415926535897932384

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s; a=0;} return os;}
void OUT(bool b){cout<<(b?"YES":"NO")<<endl;}
void Out(bool b){cout<<(b?"Yes":"No")<<endl;}
void out(bool b){cout<<(b?"yes":"no")<<endl;}
int popcnt(int x) { return __builtin_popcount(x); }
int popcnt(ll x) { return __builtin_popcountll(x); }
int clz(int x) { return 31 - __builtin_clz(x); }
int clz(ll x) { return 63 - __builtin_clzll(x); }
int ctz(int x) { return __builtin_ctz(x); }
int ctz(ll x) { return __builtin_ctzll(x); }

class compare {
public:
	bool operator()(tuple<ll, ll> a, tuple<ll, ll> b) {
		return (get<1>(a) > get<1>(b));
	}
};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,m,t;
	cin>>n>>m;
	vl c(m),dp(n+1,LINF);
	rep(i,m)cin>>c[i];
	sort(all(c));
	dp[0]=0;
	rep(i,n+1){
		rep(j,m){
			t=i-c[j];
			if(t>=0)dp[i]=min(dp[i],dp[t]+1);
		}
	}
	cout<<dp[n]<<endl;
}



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

      

int main(){
 long long int a,b,c,d;
 cin>>a>>b>>c>>d;
long long int ret=b*c;
long long int ret1=b*d;
long long int ret2=a*c;
long long int ret3=a*d;
long long int ans1=max(ret,ret1);
long long int ans2=max(ret2,ret3);
cout<<max(ans1,ans2);
  return 0;
    
}

Measured memory_bytes: 3632
#include<iostream>
using namespace std;
int main(){
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	while(1){
		c=c-b;
		if(c<=0)
		{cout<<"Yes"<<endl;
		return 0;
		}
		a=a-d;
		if(a<=0)
		{cout<<"No"<<endl;
		return 0;
		}
	}
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
#define pb push_back
#define eb emplace_back
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
template <class T>
using V = vector<T>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll MOD = 1e9 + 7;
constexpr int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
template <class T>
void chmin(T &a, T b) { a = min(a, b); }
template <class T>
void chmax(T &a, T b) { a = max(a, b); }
void ok() { cerr << "ok" << endl; }
using D = double;
using Point = complex<D>;
const D eps = 1e-40;
inline int sgn(const D &a) { return (a < -eps) ? -1 : (a > eps) ? 1 : 0; }
inline D cross(const Point &a, const Point &b) {
    return a.real() * b.imag() - a.imag() * b.real();
}
inline D dot(const Point &a, const Point &b) {
    return a.real() * b.real() + a.imag() * b.imag();
}
istream &operator>>(istream &is, Point &p) {
    D a, b;
    is >> a >> b;
    p = Point(a, b);
    return is;
}
inline int ccw(const Point &a, const Point &b, const Point &c) {
    D d = cross(b - a, c - a);
    if (sgn(d) > 0) {
        return +1; //anti-clockwise
    } else if (sgn(d) < 0) {
        return -1; //clockwise
    } else {
        if (sgn(dot(b - a, c - a)) < 0) {
            return -2;
        } else if (sgn(dot(a - b, c - b)) < 0) {
            return +2;
        }
    }
    return 0;
}
inline Point projection(const Point &p, const Point &a, const Point &b) { //a to b
    return p + (dot(a - p, b - p) / norm(a - p)) * (a - p);
}
inline Point reflection(const Point &p, const Point &a, const Point &b) {
    return b + (projection(p, a, b) - b) * static_cast<D>(2.0);
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    Point p, a;
    cin >> p >> a;
    int q;
    cin >> q;
    while (q--) {
        Point b;
        cin >> b;
        Point to = reflection(p, a, b);
        cout << fixed << setprecision(20) << to.real() << " " << to.imag() << endl;
    }
}



Measured memory_bytes: 3376
#include "bits/stdc++.h"

#define INF 20000000
#define FER 0.0000000001

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;

int dp[1 << 15][15];
int dist[15][15];

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

	for (int i = 0; i < 15; i++)for (int j = 0; j < 15; j++)
	{
		dist[i][j] = INF;
	}

	int V, E;
	cin >> V >> E;
	for (int i = 0; i < E; i++)
	{
		int s, t, d;
		cin >> s >> t >> d;
		dist[s][t] = d;
	}

	for (int i = 0; i < 1 << V; i++)
	{
		fill(dp[i], dp[i] + V, INF);
	}
	dp[(1 << V) - 1][0] = 0;

	for (int S = (1 << V) - 2; S >= 0; S--)
	{
		for (int v = 0; v < V; v++)
		{
			for (int u = 0; u < V; u++)
			{
				if (!(S >> u & 1))
				{
					dp[S][v] = min(dp[S][v], dp[S | (1 << u)][u] + dist[v][u]);
				}
			}
		}
	}

	printf(dp[0][0] == INF ? "-1\n" : "%d\n", dp[0][0]);

	return 0;
}


Measured memory_bytes: 5108
def slove():
    import sys
    input = sys.stdin.readline
    n, k = list(map(int, input().rstrip('\n').split()))
    h = list(map(int, input().rstrip('\n').split()))
    dp = [0] * n
    for i in range(1, n):
        mc = 10 ** 10
        for j in range(i-1, max(-1, i - k - 1), -1):
            mc = min(mc, abs(h[i] - h[j]) + dp[j])
        dp[i] = mc
    print(dp[-1])


if __name__ == '__main__':
    slove()


Measured memory_bytes: 52448
#include <iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const int inf = 1000000007;

signed main() {
	int n, a, b;
	cin >> n >> a >> b;
	cout << min(a, b)<<' ';
	if (a + b < n)cout << 0 << endl;
	else cout << abs(a + b - n) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include<bits/stdc++.h>
#define ll long long
#define   ull unsigned long long 
#define mp make_pair
#define pb push_back
const int MAX=2e5+9;
const long long mod=1e9+7;
using namespace std;
vector<int>adj[MAX];
int main(){
	int n ,  m , a, b, c;
	cin>>a>>b;
	if((a+b)%2!=0)
		cout<<"IMPOSSIBLE";
	else
		cout<<(a+b)/2;

}

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

int par[10005], ranke[10005];

int root(int x) {
    if (par[x] == x) return x;
    else {
        return par[x] = root(par[x]);
    }
}

bool same(int x, int y) {
    x = root(x);
    y = root(y);

    return x == y;
}

void unite(int x, int y) {
    x = root(x);
    y = root(y);
    if (x == y) return;
    else {
        if (ranke[x] < ranke[y]) {
            par[x] = y;
        }
        else {
            par[y] = x;
            if (ranke[x] == ranke[y]) ranke[x]++;
        }
    }
}

int main() {
    int n, q, command, x, y;
    cin >> n >> q;
    for (int i = 0; i < n; i++) par[i] = i;
    for (int i = 0; i < n; i++) ranke[i] = 0;

    for (int i = 0; i < q; i++) {
        cin >> command >> x >> y;
        if (command == 0) {
            unite(x, y);
        }
        else {
            if (same(x, y)) cout << 1 << endl;
            else cout << 0 << endl;
        }
    }

    return 0;

}


Measured memory_bytes: 3156
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define mod 1000000007
#define infi 1900000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;




int main()
{

    ll N,K;
    cin >> N >> K;
    int ans = 1;
    ll a = 1;
    while (a*K-1 < N) {
        a *= K;
        ans++;
    }
    
    cout << ans << endl;
    
    
    

    return 0;
}


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

int main()
{
 int a;
 cin>>a;
 string b;
 cin>>b;
 for(int t=0;t<b.size();t++)
 {
   if(b[t]+a<='Z')
   b[t]=b[t]+a;
   else
   b[t]=b[t]+a-26;
 }
 cout<<b;
}


Measured memory_bytes: 256
number = int(input())
score = list(map(int,input().split()))
deny = 0
for i in range(number):
    if score[i] % 2 == 0:
        if score[i] % 3 != 0 and score[i] % 5 != 0:
            deny = 1
            break
if deny == 1:
    print('DENIED')
else:
    print('APPROVED')

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

int main()
{
    string s,s2;
    s2=" ";
    cin>>s;
    for(int i=0; i<s.length();i++){
        s[i]=tolower(s[i]);
    }
    s.replace(5,1,s2);
    s.replace(13,1,s2);
    cout<<s;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
typedef int long long ll;
using namespace std;

int main(){
    int n,m;
    cin>>n>>m;
    cout<<n*n-m<<endl;
 
return 0;
}

Measured memory_bytes: 256
import java.util.*;

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

		List<Integer> xlist = new ArrayList<Integer>();
		List<Integer> ylist = new ArrayList<Integer>();
		// x?????????????????????????´?
		for (int count = 0; count < n; count++) {
			xlist.add(scan.nextInt());
		}
		// y?????????????????????????´?
		for (int count2 = 0; count2 < n; count2++) {
			ylist.add(scan.nextInt());
		}

		// p1?????¨???????¨???? [???????????????????????¢]
		Double p1 = 0.0;
		for (int count3 = 0; count3 < n; count3++) {
			p1 += Math.abs(xlist.get(count3) - ylist.get(count3));
		}
		System.out.println(p1);

		// p2?????¨???????¨???? [???????????????????????¢]
		Double p2 = 0.0;
		for (int count4 = 0; count4 < n; count4++) {
			p2 += Math.pow(Math.abs(xlist.get(count4) - ylist.get(count4)), 2.0);
		}
		// ?????????Math.sqrt??§?±???????????????????Math.pow(n,(1.0/2.0))??§????±?????????????
		p2 = Math.pow(p2, (1.0 / 2.0));
		System.out.println(p2);

		// p3?????¨???????¨???? [???????????????????????¢]
		Double p3 = 0.0;
		for (int count5 = 0; count5 < n; count5++) {
			p3 += Math.pow(Math.abs(xlist.get(count5) - ylist.get(count5)), 3.0);
		}
		// ?????????Math.sqrt??§?±???????????????????Math.pow(n,(1.0/2.0))??§????±?????????????
		p3 = Math.pow(p3, (1.0 / 3.0));
		System.out.println(p3);

		// p=??? ?????¨??? [?????§????????§????????¢] ??¶??????(xi - yi)????????§???
		Double max = 0.0;
		for (int count6 = 0; count6 < n; count6++) {
			if (max <= Math.abs(xlist.get(count6) - ylist.get(count6))) {
				max = (double) Math.abs(xlist.get(count6) - ylist.get(count6));
			}
		}
		System.out.println(max);

	}
}

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

int main() {
  int a,b,c;
  int kyori;
  string kekka = "No";
  
  cin >> a >> b >> c >> kyori;
  
  if(abs(c - a) <= kyori) kekka = "Yes"; // 直接
  if(abs(c - b) <= kyori && abs(b - a) <= kyori) kekka = "Yes"; // 間接
  
  cout << kekka;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int k;
	scanf("%d", &k);
	if(k<=111)
	printf("%d", 111);
	if(k>111 && k<=222)
	printf("%d", 222);
	if(k>222 && k<=333)
	printf("%d", 333);
	if(k>333 && k<=444)
	printf("%d", 444);
	if(k>444 && k<=555)
	printf("%d", 555);
	if(k>555 && k<=666)
	printf("%d", 666);
	if(k>666 && k<=777)
	printf("%d", 777);
	if(k>777 && k<=888)
	printf("%d", 888);
	if(k>888 && k<=999)
	printf("%d", 999);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
typedef long long ll;
ll dp[35];
int main(void){
    dp[0]=1;
   for(int i=0;i<=30;i++){
       dp[i+1]+=dp[i];
       dp[i+2]+=dp[i];
       dp[i+3]+=dp[i];
       dp[i]=(dp[i]+9)/10;
   }
    while(1){
        int n;
        cin>>n;
        if(n==0)break;
        cout<<(dp[n]+364)/365<<endl;
    }
}



Measured memory_bytes: 3000
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

int main() {
	string t; cin >> t;
	for(char& c : t) {
		if(c == '?') {
			c = 'D';
		}
	}
	cout << t << '\n';
	return 0;
}

Measured memory_bytes: 3724
#include <bits/stdc++.h>
#include <limits>
#include <math.h>
#include <cmath>
#include <cctype>
#include <cstdio>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int> ;
using vs = vector<string>;
using vb = vector<bool>;
using vll = vector<long long>;
using vvll = vector<vector<long long >>;
#define PI 3.141592653
#define rep(i, k, n) for(ll i = k; i < n; i++)



int main(){
  ll k; cin >> k;
  string s; cin >> s;
  ll p = s.size();

  rep(i, 0, min(k, p)){
    cout << s[i];
  }

  if(s.size() > k){cout << "..." << endl;}
}


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

int main(void){
    int N;
    while(cin >> N){
        int t[N];
        for(int i = 0; i < N; i++) cin >> t[i];

        sort(t, t + sizeof(t) / sizeof(t[0]));
        int sum = 0;
        for(int i = 0; i < N; i++){
            sum = sum + t[i] * (N - i);
        }
        
        cout << sum << endl;
    }
    return 0;
}



Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf = 1e9;
const ll INF = 1e18;
const double pi = 3.14159265358979323846;
#define rep(i, n) for (int i = 0; i < (n); i++)
using pint = pair<int, int>;
using Graph = vector<vector<int>>;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dxx[8] = {1, 1, 1, 0, 0, -1, -1, -1}, dyy[8] = {-1, 0, 1, -1, 1, -1, 0, 1};

int n, m, q;
int a[55], b[55], c[55], d[55];
ll ans = 0;
void dfs (vector<int> &A) {
    if (A.size() == n) {
        ll sum = 0;
        rep (i, q) {
            if (A[b[i] - 1] - A[a[i] - 1] == c[i]) sum += (ll)d[i];
        }
        ans = max (ans, sum);
        return;
    }
    int prev = A.empty() ? 1 : A[A.size() - 1];
    for (int i = prev; i <= m; i++) {
        A.push_back (i);
        dfs (A);
        A.pop_back();
    }
}
int main() {
    cin >> n >> m >> q;
    rep (i, q) cin >> a[i] >> b[i] >> c[i] >> d[i];
    vector<int> A;
    dfs (A);
    cout << ans << "\n";
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i,a,b) for(auto i=(a);i<(b);i++)
#define per(i,a,b) for(auto i=(a);i>=(b);i--)
#define Min(a,b) ((a) < (b) ? (a) : (b))
#define Max(a,b) ((a) > (b) ? (a) : (b))
#define int_inf 0x3f3f3f3f
#define int_max 2147483647
#define ll_max 9223372036854775807
#define ull_max 18446744073709551615
#define ll_inf 0x7f7f7f7f7f7f7f7f
#define lowbit(x) (x)&(-x)
#define mp make_pair
#define fi first
#define se second
#define pb push_back
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
const ll mod=1e9+7;
template<class T>
inline T read()
{
	T x=0,f=1;char s=getchar();
	while(s<'0'||s>'9') {if(s=='-')f=-1;s=getchar();};
	while(s>='0'&&s<='9'){x=(x<<3)+(x<<1)+s-48;s=getchar();};
	return x*f;
}
template<typename T>
inline void wri(T x)
{
	if(x<0){x=-x;putchar('-');};
	if(x/10) wri(x/10);
	putchar(x%10+48);
}
template<typename T>
inline void print(T x,char s)
{
	wri(x);
	putchar(s);
}
template<typename T>
T gcd(T a,T b)
{
	return b==0?a:gcd(b,a%b);
}
//关闭流同步就不能手写读入优化啦
int h1,m1,h2,m2,k; 
int cnt1,cnt2,cnt;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);
    cin>>h1>>m1>>h2>>m2>>k;
	cnt1=h1*60+m1,cnt2=h2*60+m2;
	cout<<cnt2-k-cnt1;
    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rt "\n"
#define sp " "
#define test1 cout << "test1" << endl;
#define test2 cout << "test2" << endl;
#define fixprecision(n) fixed; cout << setprecision(n)
#define kyopro ios::sync_with_stdio(false);cin.tie(NULL);
#define MOD 1000000007
#define rep(i, s, N) for(ll i{s}; i < N; i++)
#define iikae auto&
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;

int main(){
  kyopro;
  string k;
  cin >> k;
  ll bad{};
  if(k.at(0) == k.at(1) || k.at(1) == k.at(2) || k.at(2) == k.at(3)) bad = 1;
  if(bad) cout << "Bad" << rt;
  else cout << "Good" << rt;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,t,i;
  long long ans=0;
  cin>>n;
  vector<int>a(n);
  for(i=0;i<n;i++)cin>>a[i];
  for(i=0;i<n;i++){
    if(a[i]<1)t++;
    a[i]=abs(a[i]);
    ans+=a[i];
  }
  sort(a.begin(),a.end());
  if(t%2!=0)ans-=2*a[0];
  cout<<ans<<endl;
}

Measured memory_bytes: 640
N, A, B, C, D = map(int, input().split())
S = input()
S = 'S' + S

if C < D:
    if '##' not in S[A:D + 1]:
        print('Yes')
    else:
        print('No')
else:
    if '...' in S[B - 1:D + 2]:
        if '##' not in S[A:C]:
            print('Yes')
        else:
            print('No')
    else:
        print('No')


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

# from time import time
# 
# start = time()


def six(n):
    n_str = str(n)
    while len(n_str) < 6:
        n_str = "0" + n_str

    return n_str


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

id_list = [None] * M
dic_P = {}
info = []
info_idx = 0

for i in range(M):
    P, Y = map(int, input().split())
    if P in dic_P.keys():
        info[dic_P[P]].append([i, P, Y])
    else:
        dic_P[P] = info_idx
        info_idx += 1
        info.append([[i, P, Y]])

for group in info:
    group.sort(key=lambda a_i: a_i[2], reverse=False)
    for i, pair in enumerate(group):
        id = six(pair[1]) + six(i+1)
        id_list[pair[0]] = id

for id in id_list:
    print(id)

# print(time() - start)


Measured memory_bytes: 50128
use std::io;

fn procon_read<T: std::str::FromStr>() ->  Vec<T> {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let iter = buf.split_whitespace();
	let mut v: Vec<T> = Vec::new();
	for i in iter {
		v.push(i.parse().ok().unwrap());
	}
	v
}

fn main() {
	let v:Vec<u64> = procon_read();
	let x = v[0];
	let a = v[1];
	let b = v[2];
	if b <= a {
		println!("delicious");
	}else if b <= a+x {
		println!("safe");
	}else{
		println!("dangerous");
	}
}

Measured memory_bytes: 4352
#include <stdio.h>

int main(void)
{
    
    char char_inputJoinData;
    int int_inputDisplayRatingData;

    scanf("%d %d", &char_inputJoinData, &int_inputDisplayRatingData);

    if (char_inputJoinData >= 10)
    {
        printf("%d", int_inputDisplayRatingData);
    }
    else
    {
        int int_innerRatingData;
        int_innerRatingData = int_inputDisplayRatingData + (10 - char_inputJoinData) * 100;
        printf("%d", int_innerRatingData);
    }

}

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

int n;
vector<int> v[210];
char c[210][210];
int color[210];

// bipartite graph check
bool dfs(int x, int c) {
    color[x] = c;
    for (int g : v[x]) {
        if (color[g] == c) return false;
        if (color[g] == 0 && !dfs(g, -c)) return false;
    }
    return true;
}

bool solve() {
    if (dfs(0, 1) == false) return false;
    return true;
}

int d[210][210];
int main() {
    cin >> n;
    rep(i, n) {
        rep(j, n) {
            cin >> c[i][j];
            if (i != j) d[i][j] = 1000000000;
            if (c[i][j] == '1') {
                v[i].push_back(j);
                d[i][j] = 1;
            }
        }
    }
    if (!solve()) {
        puts("-1");
        return 0;
    }
    rep(k, n) {
        rep(i, n) {
            rep(j, n) {
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }
    int ma = 0;
    rep(i, n) {
        rep(j, n) {
            ma = max(ma, d[i][j]);
        }
    }
    cout << ma + 1 << endl;
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
//const ull mod = 1e9 + 7;
const ll mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

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

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

// conversion number to bit
string num2bit(ll num, ll len){
  string bit = "";
  REP(i, len){
    bit += char('0'+(num>>i & 1));
  }
  return bit;
}

bool check(string t){
	ll N = t.size();
	bool ok = true;
	REP(i, N){
		if(t[i] != t[N-1-i]) ok = false;
	}
	return ok;
}

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

    string S;
    cin >> S;
    ll N = S.size();

    string p = S.substr(0, (N-1)/2);
    string q = S.substr((N+3)/2-1, (N-1)/2);

    bool ok = true;
    
    if(!check(S)) ok = false;
    if(!check(p)) ok = false;
    if(!check(q)) ok = false;


    cout << (ok?"Yes":"No") << endl;
    return 0;
}

Measured memory_bytes: 256