akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;
int main(){
int i,j,h,w;
while(1){
cin>>h>>w;
i=0;
j=0;

if(h==0 && w==0)break;

for(j=0;j<=w-1;j++){
    cout<<"#";
}
cout<<endl;
j=0;

for(i=0;i<=h-3;i++){
    cout<<"#";
    for(j=0;j<=w-3;j++){
    cout<<".";
    }
    cout<<"#"<<endl;
}
j=0;

for(j=0;j<=w-1;j++){
    cout<<"#";
}
cout<<endl;
cout<<endl;
}
return 0;
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF 2 << 29
#define MOD 1000000007
#define Yes(f) puts((f)? "Yes" : "No")
#define YES(f) puts((f)? "YES" : "NO")
int gcd(int a, int b) {
	if (b != 0)return gcd(b, a % b);
	return a;
}
int lcm(int a, int b) {
	return a / gcd(a, b) * b;
}
using Graph = vector<vector<int>>;

int main(){
	string s; cin >> s;
	bool f = true;
	rep(i, s.size()){
		if(i % 2 == 0){
			if(s[i] != 'R' && s[i] != 'U' && s[i] != 'D') f = false;
		}
		else {
			if(s[i] != 'L' && s[i] != 'U' && s[i] != 'D') f = false;
		}
	}
	Yes(f);
}

Measured memory_bytes: 256
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {n: usize, a:[usize; n]};
    let a: Vec<usize> = a;

    let mut two_count = 0;
    let mut four_count = 0;

    for a_i in a.iter() {
        if a_i % 4 == 0 {
            four_count += 1;
        } else if a_i % 2 == 0 {
            two_count += 1;
        }
    }

    let x = a.len() - four_count - two_count + two_count % 2;

    if x > four_count+1 {
        println!("No")
    } else {
        println!("Yes")
    }
}


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

#ifdef _LOCAL_DEBUG
#include "templates/debug.h"
#else
#define debug(...)
#endif

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll x, d, k;
    cin >> x >> k >> d;
    ll y = abs(x);
    ll m = y / d;
    ll ans = 0;
    if (m > k) {
        ans = y - k * d;
    } else if (m == k) {
        ans = y - (m * d);
    } else {
        ll a = y - m * d;
        ll b = y - (m + 1) * d;
        ll n = k - m;
        ans = n % 2 ? b : a;
    }
    cout << abs(ans);
    return 0;
}

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

typedef long long  LL;
struct edge{int s,t,n;}e[205];
int n,S,T,h[105],f[105],dep[105],ans1;
LL ans2;
vector <int> V[105];

void dfs(int x,int fa)
{
	f[x]=fa,dep[x]=dep[fa]+1;
	for (int i=h[x],y; y=e[i].t,i; i=e[i].n)
		if (y!=fa)  dfs(y,x);
}

LL calc()
{
	int md=0;  LL res=1;
	for (int i=1; i<=n; i++)  md=max(md,dep[i]);
	for (int i=1; i<=md; i++)  V[i].clear();
	for (int i=1; i<=n; i++)  V[dep[i]].push_back(i);
	for (int i=md-1,mx,cnt; i; i--)
		{
			mx=0;
			for (auto x:V[i])
				{
					cnt=0;
					for (int j=h[x],y; y=e[j].t,j; j=e[j].n)
						if (dep[y]==dep[x]+1)  cnt++;
					mx=max(mx,cnt);
				}
			res*=mx;
		}
	return res;
}

LL calc(int x)
{
	dfs(x,0);
	return calc();
}

LL calc(int x,int y)
{
	dep[x]=0,dfs(y,x),dep[y]=0,dfs(x,y),dep[y]=1;
	return calc()*2;
}

void work()
{
	scanf("%d",&n);
	for (int i=1,u,v,tot=0; i<n; i++)
		{
			scanf("%d %d",&u,&v);
			e[++tot]=(edge){u,v,h[u]},h[u]=tot;
			e[++tot]=(edge){v,u,h[v]},h[v]=tot;
		}
	dfs(1,0),S=1;
	for (int i=1; i<=n; i++)  if (dep[i]>dep[S])  S=i;
	dfs(S,0),T=S;
	for (int i=1; i<=n; i++)  if (dep[i]>dep[T])  T=i;
	ans1=(dep[T]+1)/2;
	if (dep[T]&1)
		{
			int x=T;
			while (dep[x]!=ans1)  x=f[x];
			ans2=calc(x);
			for (int i=h[x],y; y=e[i].t,i; i=e[i].n)  ans2=min(ans2,calc(x,y));
		}else
		{
			int x,y=T;
			while (dep[y]!=ans1+1)  y=f[y];
			x=f[y];
			ans2=calc(x,y);
		}
	printf("%d %lld",ans1,ans2);
}

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


Measured memory_bytes: 256
T = list(input())
 
for i in range(len(T)):
  if T[i] == "?":
    if 1 <= i and T[i-1] == "P":
      T[i] = "D"
    elif i < len(T)-1 and T[i+1] == "?":
      T[i] = "P"
      T[i+1] = "D"
    elif i < len(T)-1 and T[i+1] == "D":
      T[i] = "P"
    else:
      T[i] = "D"
      
print("".join(T))

Measured memory_bytes: 10944
// V solo
#include <bits/stdc++.h>

#define forn(i, a, b) for (int i = a; i <= b; ++i)

using namespace std;

const int N = (int)2e5 + 1;
const long long INF = 1e9 + 7;

typedef long long ll;
typedef long double ld;

typedef pair < int, int > pii;
typedef pair < ll, ll > pll;

int n;
int main (){
  scanf ("%d", &n);
  if (n % 2 == 0){
    printf ("%d\n", n);
  } else {
    printf ("%d\n", n * 2);
  }
  return 0;
}


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

const int N = 3005;
const int md = 1e9 + 7;

int n, m;
string s;
int r[N], cnt[N], mx[N];
int f[N][N];

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	cin >> n >> m >> s; s = ' ' + s;
	for (int i = 1; i <= n; ++i) cnt[i] = cnt[i-1] + (s[i] == '1');
	for (int i = 1; i <= m; ++i) {
		int L, R; cin >> L >> R; r[L] = max(r[L], R);
	}
	for (int i = 1; i <= n; ++i) mx[i] = max(mx[i-1], r[i]), mx[i] = max(mx[i], i);

	f[0][0] = 1;
	for (int i = 1; i <= n; ++i) {
		for (int j = 0; j <= n; ++j) if (f[i-1][j]) {
			int nj = j + max(0, cnt[mx[i]] - cnt[mx[i-1]]);
			int w = mx[i] - i + 1;
			if (w - nj > 0) f[i][nj] = (f[i][nj] + f[i-1][j]) % md;
			if (nj > 0) f[i][nj - 1] = (f[i][nj - 1] + f[i-1][j]) % md;
		}
	}

	cout << f[n][0] << endl;
}

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

const int INF = (1LL<<31)-1;

int V, E;

int main(){
    cin >> V >> E;
    vector<vector<int>> D(V, vector<int>(V, INF));
    for(int i=0; i<V; i++)
        D[i][i] = 0;
    
    for(int i=0; i<E; i++){
        int s, t, d;
        cin >> s >> t >> d;
        D[s][t] = d;
    }
    
    for(int k=0; k<V; k++){
        for(int i=0; i<V; i++){
            for(int j=0; j<V; j++){
                if(D[i][k] != INF && D[k][j] != INF)
                    D[i][j] = min(D[i][j], D[i][k] + D[k][j]);
            }
        }
    }
    
    bool is_negative = false;
    for(int i=0; i<V; i++)
        is_negative |= D[i][i] < 0;
    
    if(is_negative)
        cout << "NEGATIVE CYCLE" << endl;
    else
        for(int i=0; i<V; i++){
            for(int j=0; j<V; j++){
                if(D[i][j] == INF)
                    cout << "INF";
                else
                    cout << D[i][j];
                if(j < V-1)
                    cout << " ";
            }
            cout << endl;
        }
    
    return 0;
}

Measured memory_bytes: 3152
#include <bits/stdc++.h>
using namespace std;
int n, k, lc[2];
string s[2020], z;
bitset<10001> f[2020];
pair<int, int> l[2][2020];
int main() {
	ios::sync_with_stdio(0);
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		cin >> s[i];
	}
	f[n][k] = 1;
	for (int i = n - 1; i >= 0; i--) {
		f[i] = f[i + 1] | (f[i + 1] >> s[i].size());
		if (f[i + 1][s[i].size()]) {
			l[0][lc[0]++] = make_pair(i, 0);
		}
	}
	for (int i = 0, ii = 0; i < k; i++, ii ^= 1) {
		char c = '~';
		for (int jj = 0; jj < lc[ii]; jj++) {
			pair<int, int> j = l[ii][jj];
			c = min(c, s[j.first][j.second]);
		}
		z += c;
		int t = n + 1;
		for (int jj = 0; jj < lc[ii]; jj++) {
			pair<int, int> j = l[ii][jj];
			if (s[j.first][j.second] == c) {
				if (j.second + 1 == s[j.first].size()) {
					t = min(t, j.first);
				} else {
					l[ii ^ 1][lc[ii ^ 1]++] = make_pair(j.first, j.second + 1);
				}
			}
		}
		for (int j = t + 1; j < n; j++) {
			if (i + 1 + s[j].size() <= k && f[j + 1][i + 1 + s[j].size()]) {
				l[ii ^ 1][lc[ii ^ 1]++] = make_pair(j, 0);
			}
		}
		lc[ii] = 0;
	}
	cout << z << endl;
	return 0;
}

Measured memory_bytes: 3840
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define INF 100000000
#define rep(i,s,n) for (int i = (int)(s); i < (int)(n); i++)
ll mod = 1000000007;

int main(){
    ll n;cin>>n;
    ll ans = 1;
    for (ll i= 2;i*i<=n;i++){
        if ((n-1)%i==0&&((n-1)/i>sqrt(n))) ans++;
        ll m = n;
        while (m%i==0){
            m/=i;
        }
        if (m%i==1) ans++;
    }
    if (n>2) ans++;
    cout << ans << endl;
}

Measured memory_bytes: 3688
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
#include <cassert>
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;
typedef pair<int,int> PI;
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mp make_pair
#define pb push_back


map<string,char> dic;

string encode(char c){
  if(isalpha(c))c-='A';
  else{
    switch(c){
    case ' ':c=26;break;
    case '.':c=27;break;
    case ',':c=28;break;
    case '-':c=29;break;
    case '\'':c=30;break;
    case '?':c=31;break;
    }
  }
  
  string ret;
  while(c){
    ret+='0'+c%2;
    c/=2;
  }
  while(ret.size()<5)ret+='0';
  reverse(ret.begin(),ret.end());
  return ret;
}

main(){
  dic["101"]=' ';
  dic["000000"]='\'';
  dic["000011"]=',';
  dic["10010001"]='-';
  dic["010001"]='.';
  dic["000001"]='?';
  dic["100101"]='A';
  dic["10011010"]='B';
	
  dic["0101"]='C';
  dic["0001"]='D';
  dic["110"]='E';
  dic["01001"]='F';
  dic["10011011"]='G';
  dic["010000"]='H';
  dic["0111"]='I';
  dic["10011000"]='J';
	
  dic["0110"]='K';
  dic["00100"]='L';
  dic["10011001"]='M';
  dic["10011110"]='N';
  dic["00101"]='O';
  dic["111"]='P';
  dic["10011111"]='Q';
  dic["1000"]='R';
	
  dic["00110"]='S';
  dic["00111"]='T';
  dic["10011100"]='U';
  dic["10011101"]='V';
  dic["000010"]='W';
  dic["10010010"]='X';
  dic["10010011"]='Y';
  dic["10010000"]='Z';
  string str;

  while(getline(cin,str)){
    string code;
    rep(i,str.size()){
      if(str[i]=='\n' || str[i]=='\r')continue;
      code+=encode(str[i]);
      //cout<<code<<endl;
    }
    int i=0;
    string dec;
    while(i<code.size()){
      dec+=code[i];
      ++i;
      if(dic.count(dec)){
        cout<<dic[dec];
        dec="";
      }
    }
    cout<<endl;
  }
}

Measured memory_bytes: 0
fn getline() -> String {
    let mut __ret = String::new();
    std::io::stdin().read_line(&mut __ret).ok();
    return __ret;
}

fn solve(n: i64) -> i64 {
    let mut ans = 1;
    for i in 1..(n + 1) {
        ans = (ans * i) % 1000000007;
    }
    return ans;
}

fn main() {
    let s = getline();
    let n: i64 = s.trim().parse().unwrap();
    let ans = solve(n);
    println!("{}", ans);
}


Measured memory_bytes: 4352
import java.util.*;

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

	int n = sc.nextInt();

	while(n!=0){
	    int sum = 0;
	    int max = 0;
	    int min = 1000;
	    for(int i=0; i<n; i++){
		int score = sc.nextInt();
		sum += score;
		if(score>max){max = score;}
		if(score<min){min = score;}
	    }

	    int ans = (sum-max-min)/(n-2);
	    System.out.println(ans);

	    n = sc.nextInt();
	}
    }
}

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

using ll = long long;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define ALL(c) (c).begin(), (c).end()
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
const int MOD = 1000000007;
const int INF = 1000000001;
const char EOL = '\n';

void solve();

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

void solve() {
    int ans = 0;
    int n;
    cin >> n;
    vector<int> d(n);
    REP(i, n) cin >> d[i];
    REP(i, n) FOR(j, i + 1, n) {
        ans += d[i] * d[j];
    }
    cout << ans << EOL;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ft first
#define sc second
#define pt(sth) cout << sth << "\n"
#define moca(a, s, b) a=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
template<class T>bool chmax(T &a, const T &b) {if(a<b) {a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) {if(b<a) {a=b; return 1;} return 0;}
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;

//for(i=0; i<N; i++) cin >> a[i];

class unionFind {
public:
  vector<ll> data;
  
  unionFind(ll size) {
    data.assign(size, -1);
  }
  
  bool same(ll x, ll y) {
    return find(x)==find(y);
  }
  
  void unite(ll x, ll y) {
    x=find(x);
    y=find(y);
    if(x==y) return;
    if(data[x]>data[y]) swap(x, y);
    data[x]+=data[y];
    data[y]=x;
  }
  
  ll find(ll k) {
    if(data[k]<0) return k;
    return data[k]=find(data[k]);
  }
  
  ll size(ll k) {
    return -data[find(k)];
  }
  
};


int main(void) {
  ll i, j, k;
  
  ll N, K;
  cin >> N >> K;
  ll P[5555], C[5555];
  for(i=0; i<N; i++) {
    cin >> P[i];
    P[i]--;
  }
  for(i=0; i<N; i++) cin >> C[i];
  
  unionFind uf=unionFind(N);
  map<ll, set<ll>> mp;
  
  for(i=0; i<N; i++) uf.unite(i, P[i]);
  
  for(i=0; i<N; i++) {
    ll u=uf.find(i);
    if(mp[u].empty()) mp[u]=set<ll>();
    mp[u].insert(i);
  }
  
  ll ans=-INF;
  for(auto it=mp.begin(); it!=mp.end(); it++) {
    set<ll> st=it->sc;
    ll n=st.size();
    ll c=0;
    for(auto ptr=st.begin(); ptr!=st.end(); ptr++) c+=C[*ptr];
    
    ll tK=K;
    ll t=0;
    if(c>0) {
      t=max(0LL, (tK/n-1)*c);
      tK-=max(0LL, (tK/n-1)*n);
    }else {
      chmin(tK, n);
    }
    
    vector<ll> v;
    ll now=*st.begin();
    v.push_back(now);
    for(i=1; i<n; i++) {
      now=P[now];
      v.push_back(now);
    }
    for(i=0; i<n; i++) v.push_back(v[i]);
    for(i=0; i<n; i++) v.push_back(v[i]);
    
    ll sum[v.size()+10];
    for(i=0; i<v.size(); i++) sum[i+1]=sum[i]+C[v[i]];
    
    ll S=-INF;
    for(k=1; k<=tK; k++) for(i=1; i<=(ll)v.size()-k+1; i++) chmax(S, sum[i+k-1]-sum[i-1]);
    
    t+=S;
    chmax(ans, t);
    
  }
  
  pt(ans);
  
}
 
 




Measured memory_bytes: 4452
import sys
import math
from itertools import accumulate as acc

input=sys.stdin.readline

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


a=[[0 for i in range(10**5+1)] for i in range(C+1)]

rec=[0 for i in range(10**5+1)]

for i in range(N):
    s,t,c=map(int,input().split())
    recs,rect=a[c][s],a[c][t]
    if recs==0 and rect==0:
        rec[s-1]+=1
        rec[t]-=1
    elif recs==0 and rect==1:
        rec[s-1]+=1
        rec[t-1]-=1
    elif recs==1 and rect==0:
        rec[s]+=1
        rec[t]-=1
    elif recs==1 and rect==1:
        rec[s]+=1
        rec[t-1]-=1

    a[c][s],a[c][t]=1,1

tmp=0
ans=0
for i in range(10**5):
    tmp+=rec[i]
    ans=max(tmp,ans)
print(ans)

Measured memory_bytes: 28360
#include<bits/stdc++.h>
#define MOD 1000000007
#define MAX 10005
#define int long long
#define f(i,a,n) for(int i=a;i<n;i+=1)
#define T int t;cin>>t;while(t--)
#define set_dp(dp) memset(dp,-1,sizeof(dp))
using namespace std;

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int a,b;
    cin>>a>>b;
    if((a%2==0 && b%2==1) || (a%2==1 && b%2==0)) {
        cout<<"IMPOSSIBLE\n";
        return 0;
    }
    int ans = abs(a+b)/2;
    cout<<ans;

    return 0;
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

fn main() {
    input!{
        n: usize,
        m: usize,
        x: i64,
        y: i64,
        xs: [i64; n],
        ys: [i64; m]
    }
    let xmax = xs.iter().fold(x, |ac,&p| std::cmp::max(ac,p));
    let ymin = ys.iter().fold(y, |ac,&p| std::cmp::min(ac,p));
    println!("{}", if xmax < ymin {"No War"} else {"War"});
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, s, n) for (int i = (s); i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
  int n;
  cin >> n;
  int result[4] = {};
  rep(i, n) {
    string s;
    cin >> s;
    if (s == "AC") result[0]++;
    if (s == "WA") result[1]++;
    if (s == "TLE") result[2]++;
    if (s == "RE") result[3]++;
  }
  printf("AC x %d\n", result[0]);
  printf("WA x %d\n", result[1]);
  printf("TLE x %d\n", result[2]);
  printf("RE x %d\n", result[3]);

  return 0;
}

Measured memory_bytes: 3716
#include <iostream>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <functional>
#include <iterator>
#include <bitset>
#include <string>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>

typedef   signed long long int slli;
typedef unsigned long long int ulli;
const slli MAX_SLLI = 0x7FFFFFFFFFFFFFFF;
const slli MIN_SLLI = 0x8000000000000000;
const ulli MAX_ULLI = 0xFFFFFFFFFFFFFFFF;
const ulli MIN_ULLI = 0x0000000000000000;

#define N_TIMES(i, n)     for (ulli i = 0;     i <  n; ++i)
#define N_TIMES_REV(i, n) for (slli i = n - 1; i >= 0; --i)

#ifdef __DEBUG__
template<typename T>
std::ostream& operator<<(std::ostream &os, const std::list<T> &list)
{
  const std::string delim = ", ";
  typename std::list<T>::const_iterator itr = list.begin();
  while (itr != list.end()) {
    os << *itr;
    ++itr;
    if(itr != list.end()) os << delim;
  }
  return os;
}

template<typename T>
std::ostream& operator<<(std::ostream &os, const std::vector<T> &v)
{
  const std::string delim = ", ";
  for (unsigned n = 0; n < v.size(); ++n) {
    os << v[n];
    if((n + 1) < v.size()) os << delim;
  }
  return os;
}
#endif /* __DEBUG__ */

int main(int argc, char **argv)
{
  long A, B, K;
  std::cin >> A >> B >> K;
  
  std::set<long> s;
  for (long k = 0; k < K; ++k) {
    if (A + k <= B) s.insert(A + k);
    if (A <= B - k) s.insert(B - k);
  }
  
  for (long d : s) {
    std::cout << d << std::endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));

            return;
        }

        public void Solve(ConsoleInput cin)
        {

            var A = cin.ReadLine;
            var B = cin.ReadLine;

            int ALen = A.Length;
            int BLen = B.Length;
            char[] AChrAry = A.ToCharArray();
            char[] BChrAry = B.ToCharArray();

            if (ALen > BLen){
                WriteLine("GREATER");
                return;
            }
            else if (ALen < BLen){
                WriteLine("LESS");
                return;
            }
            else if (ALen == BLen){
                for (int i = 0; i < ALen; i++){
                    if(AChrAry[i] - '0' > BChrAry[i] - '0'){
                        WriteLine("GREATER");
                        return;
                    }else if (AChrAry[i] - '0' < BChrAry[i] - '0'){
                        WriteLine("LESS");
                        return;
                    }else if (AChrAry[i] - '0' == BChrAry[i] - '0'){
                        continue;
                    }
                }


                WriteLine("EQUAL");
                return;
            }
        }
    }

    public static class Extensions
    {
        public static string Reverse(this string sourse)
        {
            char[] chrAry = sourse.ToCharArray();
            Array.Reverse(chrAry);
            return new string(chrAry);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}


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

int main()
{
    int k , a,b;
    cin >> k;
    cin >> a >> b;
    string ans = "NG";
    for(int i=a ; i<=b; i++){
        if(i%k==0)
        ans="OK";
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define rep_(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) rep_(i, 0, n)
#define rev_(i, m, n) for(int i=(int)(m-1);i>=(int)(n);i--)
#define rev(i, n) rev_(i, n, 0)
#define each(i, n) for(auto&& i: n)
#define pb push_back
#define mp make_pair
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin() , (v).rend()
#define dump(x) cerr << #x << "=" << x <<endl
#define gcd __gcd
int lcm(int a, int b){return a / gcd(a, b) * b;}
const int INF = 1e18;
const int MOD = 1e9 + 7;
const double EPS = 1e-15;
const double PI = acos(-1);

void solve()
{
	/*--------------------------*/

	int N, A, B;
	cin >> N >> A >> B;
	cout << A * (int)(N / (A + B)) + min(N % (A + B), A) << endl;

	/*--------------------------*/
}

signed main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);
	solve();
}

Measured memory_bytes: 256
import Control.Arrow
import Control.Monad
import Data.Bits
import qualified Data.ByteString.Char8 as BC
import Data.Char
import Data.List
import Data.Maybe

main :: IO ()
main = do
  [n, m] <- getInts
  [xs, ys, zs] <- transpose <$> replicateM n getInts
  print . maximum $ do
    f <- [negate, id]
    g <- [negate, id]
    h <- [negate, id]
    return . sum . take m . reverse . sort . map sum . transpose $ [map f xs, map g ys, map h zs]

getInts :: IO [Int]
getInts = unfoldr (BC.readInt . BC.dropWhile (== ' ')) <$> BC.getLine


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

int main() {
    int N, K, Q;
	cin >> N >> K >> Q;
    vector<int> A(Q), cnt(N);
    rep(i, Q) {
        cin >> A[i];
        cnt[A[i]-1]++;
    }
    rep(i, N) {
        if (K-Q+cnt[i] > 0) cout << "Yes" << endl;
        else                cout << "No" << endl;
    }

	return 0;
}


Measured memory_bytes: 1408
import java.util.Scanner;

public class Main {
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();
        if(Math.abs(a - c) <= d){
            System.out.println("Yes");
        }else{
            if(Math.abs(b - a) <= d && Math.abs(c - b) <= d){
                System.out.println("Yes");
            }else{
                System.out.println("No");
            }
        }
    }
}


Measured memory_bytes: 23892
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size1,init=nil,size2=1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

a,b,c,x,y=get_i
ans=0
if a+b>=c*2
    min=x>y ? y : x
    ans+=2*c*min
    x-=min
    y-=min
    if x>0
        if a>c*2
            ans+=x*c*2
        else
            ans+=x*a
        end
    elsif y>0
        if b>c*2
            ans+=y*c*2
        else
            ans+=y*b
        end
    end
else
    ans+=a*x+b*y
end
puts ans

Measured memory_bytes: 1788
#include <iostream>
#include <cstdio>
#include <vector>
#include <list>
#include <complex>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <stack>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <cassert>
#include <numeric>
using namespace std;
typedef long long ll;
typedef pair<int,int> PI;
#define EPS (1e-6)
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define REP(i, n) rep (i, n)
#define F first
#define S second
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define min3(a,b,c) min((a),min((b),(c)))
#define min4(a,b,c,d) min((a),min3((b),(c),(d)))
#define SZ(a) (int)((a).size())
#define ALL(a) a.begin(),a.end()
#define FLL(a,b) memset((a),b,sizeof(a))
#define CLR(a) memset((a),0,sizeof(a))
#define FOR(it,a) for(__typeof(a.begin())it=a.begin();it!=a.end();++it)
template<typename T,typename U> ostream& operator<< (ostream& out, const pair<T,U>& val){return out << "(" << val.F << ", " << val.S << ")";}
template<class T> ostream& operator<< (ostream& out, const vector<T>& val){out << "{";rep(i,SZ(val)) out << (i?", ":"") << val[i];return out << "}";}
typedef double FP;
typedef complex<FP> pt;
typedef pt P;
typedef pair<pt,pt> line;
FP dot(P a,P b){return real(conj(a)*b);}
FP crs(P a,P b){return imag(conj(a)*b);}
P ortho(P a){return conj(P(imag(a),real(a)));}
P ortho(line a){return ortho(a.S-a.F);}
P crspt(P a,P b,P c,P d){b-=a,d-=c;return a+b*crs(d,c-a)/crs(d,b);}
P crspt(line a,line b){return crspt(a.F,a.S,b.F,b.S);}
bool onl(P a1,P a2,P b){return abs(b-a1)+abs(b-a2)<abs(a1-a2)+EPS;}
bool onl(line a,P b){return onl(a.F,a.S,b);}
bool iscrs(line a,line b){P c=crspt(a,b);return onl(a,c)&&onl(b,c);}
void pkuassert(bool t){t=1/t;};
int dx[]={0,1,0,-1,1,1,-1,-1};
int dy[]={1,0,-1,0,-1,1,1,-1};
enum{TOP,BTM,LFT,RGT,FRT,BCK};
int dxdy2ce[]={RGT,FRT,LFT,BCK};
template<class T> T shift(T a,int b,int c,int d,int e){
 __typeof(a[0])t=a[b];a[b]=a[c];a[c]=a[d];a[d]=a[e];a[e]=t;
 return a;}
template<class T> T rgt(T a){return shift(a,TOP,LFT,BTM,RGT);}
template<class T> T lft(T a){return shift(a,TOP,RGT,BTM,LFT);}
template<class T> T frt(T a){return shift(a,TOP,BCK,BTM,FRT);}
template<class T> T bck(T a){return shift(a,TOP,FRT,BTM,BCK);}
line mkl(P a,P v){return line(a,a+v);}
FP lpdist(line a,P b){return abs(b-crspt(a,mkl(b,ortho(a))));}
FP spdist(line a,P b){
  P c(crspt(a,mkl(b,ortho(a))));
  return onl(a,c)?abs(b-c):min(abs(a.F-b),abs(a.S-b));
}
FP ssdist(line a,line b){
 return
  iscrs(a,b)?0.:
   min4(spdist(a,b.F),spdist(a,b.S),
        spdist(b,a.F),spdist(b,a.S));
}
namespace std{
  bool operator<(const P&a,const P&b){
    return mp(real(a),imag(a))<mp(real(b),imag(b));
  }
}

int n,m,k;
ll allsum;
void dfs(int sum,int depth){
  if(depth==n){
    allsum+=max(sum-k,1);
    return;
  }
  for(int i=1;i<=m;++i)
    dfs(sum+i,depth+1);
}

void solve(){
  allsum=0;
  dfs(0,0);
  printf("%.8f\n",allsum/pow(m,n));
}

int main(int argc, char *argv[])
{
  while(cin >> n >> m >> k && n) solve();
  return 0;
}

Measured memory_bytes: 1252
#include "bits/stdc++.h"
using namespace std;
const auto start_time = std::chrono::high_resolution_clock::now();
void timecalculater(){
    #ifndef ONLINE_JUDGE
    auto end_time = std::chrono::high_resolution_clock::now();
    std::chrono::duration<double> diff = end_time-start_time;
    cerr<<"Time Taken : "<<diff.count()<<"\n";
    #endif
}//continue break
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
void __print(int x) {cout << x;}
void __print(long x) {cout << x;}
void __print(long long x) {cout << x;}
void __print(unsigned x) {cout << x;}
void __print(unsigned long x) {cout << x;}
void __print(unsigned long long x) {cout << x;}
void __print(float x) {cout << x;}
void __print(double x) {cout << x;}
void __print(long double x) {cout << x;}
void __print(char x) {cout << '\'' << x << '\'';}
void __print(const char *x) {cout << '\"' << x << '\"';}
void __print(const string &x) {cout << '\"' << x << '\"';}
void __print(bool x) {cout << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
void _print() {cout << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define dbg(x...) cout << "[" << #x << "] = ["; _print(x)
#else
#define dbg(x...)
#endif
#define fastio  cin.sync_with_stdio(0); cin.tie(0);cin.exceptions(cin.failbit);
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repA(i, a, n) for(int  i = a; i <= (n); ++i)
#define all(x) x.begin(), x.end()
#define sz(x) (int) (x).size()
#define fill(a,v) memset(a, v, sizeof(a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define endl '\n'
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef vector<int> vi;
typedef vector<long long int> vll;
typedef vector<pii> vpii;
ll p=1e9+7;
const int N=2e5+5;
int main() {
   
    fastio;
    int T=1;
    // cin>>T;
    while(T--){
        int x;cin>>x;
        x=x-400;
        int ans=x/200;
        ans=8-ans;
        cout<<ans;
    }   
    timecalculater();
    return 0;   
} 

Measured memory_bytes: 3656
import java.util.*;

public class Main {
    public static void main(String[] args) {
        int total;

        Scanner inp = new Scanner(System.in);
        total = inp.nextInt();

        String[] b = new String[total];
        String[] c = new String[total];

        for (int k = 0; k < total; k++) {
            String a = inp.next();

            b[k] = a;
            c[k] = a;
        }

        for (int i = 0; i < total; i++) {
            for (int j = total - 1; j > i; j--) {
                if (b[j].charAt(1) < b[j - 1].charAt(1)) {
                    String temp = b[j];
                    b[j] = b[j - 1];
                    b[j - 1] = temp;
                }
            }
        }

        for (int l = 0; l < total; l++) {
            if (l == 0) {
                System.out.printf("%s", b[l]);
            } else {
                System.out.printf(" %s", b[l]);
            }
        }

        System.out.println("\n" + "Stable");


        for (int i = 0; i < total; i++) {
            int mini = i;
            for (int j = i + 1; j < total; j++) {
                if (c[j].charAt(1) < c[mini].charAt(1)) {
                    mini = j;
                }
            }

            if (i != mini) {
                String temp = c[i];
                c[i] = c[mini];
                c[mini] = temp;
            }
        }


        for (int l = 0; l < total; l++) {
            if (l == 0) {
                System.out.printf("%s", c[l]);
            } else {
                System.out.printf(" %s", c[l]);
            }
        }

        int counter = 0;

        for (int l = 0; l < total; l++) {
            if (b[l] == c[l]) {
                {
                    counter++;
                }
            }
        }

        if (counter == total) {
            System.out.println("\n" + "Stable");
        } else {
            System.out.println("\n" + "Not stable" );
        }
    }
}



Measured memory_bytes: 26616
#include <iostream>
#include <set>
#include <vector>

int min;
std::string res;

void dfs(int depth, std::string s,
           const std::set<std::string> &st)
{
    if (depth == 4) {
        if (s.empty() || st.count(s)) {
            return;
        }
        
        int size = s.size();
        if (size < min) {
            min = size;
            res = s;
        } else if (size == min) {
            res = std::min(res, s);
        }
        return;
    }

    dfs(depth + 1, s, st);    
    for (char c = 'a'; c <= 'z'; c++) {
        dfs(depth + 1, s + c, st);
    }    
}

int main()
{
    int N;   
    std::cin >> N;    
    
    std::set<std::string> st; 
    for (int i = 0; i < N; i++) {
        std::string S;
        std::cin >> S;
        int size = S.size();
        for (int j = 0; j < size; j++) {
            for (int k = 1; k <= 4; k++) {
                if (j + k > size) break;
                st.insert(S.substr(j, k));
            }
        }
    }

    min = 5;    
    std::string s;
    dfs(0, s, st);
    std::cout << res << std::endl;
    
    return 0;
}

Measured memory_bytes: 42436
# あなたは、正の整数をいくつか選び、それらの総和を求めます。
# 選ぶ数の上限や、選ぶ整数の個数に制限はありません。
# どんなに大きな整数を選んでもよいですし、整数を 5000 兆個選んでもよいです。
# ただし、選ぶ数はすべて A の倍数でなくてはいけません。
# また、少なくとも 1 つは整数を選ばなくてはいけません。
# そして総和を B で割ったあまりが C となるようにしたいです。
# こうなるように整数を選ぶことが出来るか判定してください。
# 出来るならば YES、そうでないならば NO を出力してください。

# 情報を取得
input = gets.chomp.split
a = input[0].to_i
b = input[1].to_i
c = input[2].to_i

# 出力する結果を格納する変数を宣言
result = "NO"

# 総和を代入する変数を宣言
sum = 0

# 上限を1万回として検証を行う
10000.times do
  sum += a
  
  if sum % b == c
    result = "YES"
    break
  end
end

# 結果を出力
puts result

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

int digitsSum(int n)
{
	int sum = 0;
	while(n>0){
		sum += n%10;
		n /= 10;
	}
	
	return sum;
}

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

	int ans = 1 + digitsSum(n-1);
	for(int i = 2; i < n / 2 + 1; i++){
		ans = min(ans, digitsSum(i) + digitsSum(n-i));
	}

	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.TreeSet;
 
// ALDS1_10_A

public class Main {
  public static void main(String[] args) {
    InputReader sc = new InputReader(System.in);

    int nownum = 1;
    int nextnum = 1;
    int count = sc.nextInt();
    for(int i = 0; i < count; i++){
      int keepnum = nownum + nextnum;
      nownum = nextnum;
      nextnum = keepnum;
    }
    System.out.println(nownum);
  }
 
//nextChar ?????????????????????

//System.out.printf("? %d %d\n", i, j);

  
// LinkedList<Integer>[] setsu = new LinkedList[n];
// for(int i = 0; i < n; i++){
//   setsu[i] = new LinkedList<Integer>();
// } 

 //???????????????????????¬
  static class InputReader {
      private InputStream stream;
      private byte[] buf = new byte[1024];
      private int curChar;
      private int numChars;
      private SpaceCharFilter filter;

      public InputReader(InputStream stream) {
          this.stream = stream;
      }
 
      public int next() {
          if (numChars == -1)
              throw new InputMismatchException();
          if (curChar >= numChars) {
              curChar = 0;
              try {
                  numChars = stream.read(buf);
              } catch (IOException e) {
                  throw new InputMismatchException();
              }
              if (numChars <= 0)
                  return -1;
          }
          return buf[curChar++];
      }
 
      public String nextStr() {
        int c = next();
        while(isSpaceChar(c)){c = next();}
        StringBuffer str = new StringBuffer();
        do{
          str.append((char)c);
          c = next();
        }while(!isSpaceChar(c));
        return str.toString();
      }

      public char nextChar() {
        int c = next();
        while(isSpaceChar(c)){c = next();}
        char ret;
        do{
          ret = (char)c;
          c = next();
        }while(!isSpaceChar(c));
        return ret;
      }

      public int nextInt() {
          int c = next();
          while (isSpaceChar(c))
              c = next();
          int sgn = 1;
          if (c == '-') {
              sgn = -1;
              c = next();
          }
          int res = 0;
          do {
              if (c < '0' || c > '9')
                  throw new InputMismatchException();
              res *= 10;
              res += c - '0';
              c = next();
          } while (!isSpaceChar(c));
          return res * sgn;
      }
 
      public boolean isSpaceChar(int c) {
          if (filter != null)
              return filter.isSpaceChar(c);
          return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
      }
 
      public interface SpaceCharFilter {
          public boolean isSpaceChar(int ch);
      }
  }
}

Measured memory_bytes: 16992
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			int a = scanner.nextInt();
			int b = scanner.nextInt();
			int c = scanner.nextInt();
			scanner.nextLine();
			int[] l = new int[n];
			for (int i = 0; i < n; i++) {
				l[i] = scanner.nextInt();
				scanner.nextLine();
			}
			System.out.println(dfs(0, 0, 0, 0, n, a, b, c, l));
		}
	}

	private static long dfs(int cur, int d, int e, int f, int n, int a, int b, int c, int[] l) {
		if (cur == n) {
			if (min(d, e, f) > 0) {
				return Math.abs(d - a) + Math.abs(e - b) + Math.abs(f - c) - 30;
			} else {
				return Integer.MAX_VALUE;
			}
		}
		long ret0 = dfs(cur + 1, d, e, f, n, a, b, c, l);
		long ret1 = dfs(cur + 1, d + l[cur], e, f, n, a, b, c, l) + 10;
		long ret2 = dfs(cur + 1, d, e + l[cur], f, n, a, b, c, l) + 10;
		long ret3 = dfs(cur + 1, d, e, f + l[cur], n, a, b, c, l) + 10;
		return min(ret0, ret1, ret2, ret3);
	}

	private static int min(int... x) {
		int min = Integer.MAX_VALUE;
		for (int number : x) {
			min = Math.min(min, number);
		}
		return min;
	}

	private static long min(long... x) {
		long min = Long.MAX_VALUE;
		for (long number : x) {
			min = Math.min(min, number);
		}
		return min;
	}
}

Measured memory_bytes: 28056
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 2e5 + 10;
const int INF = 0x3f3f3f3f;
int n, k, c;
char s[N];
int f[N], g[N], fr[N], bk[N];
int main() {
	scanf("%d%d%d", &n, &k, &c);
	scanf("%s", s + 1);
	for (int i = 1; i <= n; i++) {
		bk[i] = bk[i - 1];
		f[i] = f[i - 1];
		if (i >= bk[i] && s[i] == 'o') {
			f[i]++;
			bk[i] = i + c + 1;
		}
	}
	fr[n + 1] = n + 1;
	for (int i = n; i >= 1; i--) {
		fr[i] = fr[i + 1];
		g[i] = g[i + 1];
		if (i <= fr[i] && s[i] == 'o') {
			g[i]++;
			fr[i] = i - c - 1;
		}
	}
	for (int i = 1; i <= n; i++) {
		if (s[i] == 'x')continue;
		if (f[i - 1] + g[max(i + 1, bk[i - 1])] < k)printf("%d\n", i);
	}
	return 0;
}

Measured memory_bytes: 4864
#![allow(clippy::needless_range_loop)]
#![allow(unused_macros)]
#![allow(dead_code)]
#![allow(unused_imports)]

use proconio::input;
use proconio::marker::*;
use itertools::Itertools;

fn main() {
    input! {
        x: isize,
        k: isize,
        d: isize,
    }
    let x = x.abs();
    let nk = std::cmp::max(k - x / d, 0) % 2;
    let nx = x - std::cmp::min(x / d, k) * d;
    let ans = if nk == 0 {
        nx
    } else {
        d - nx
    };

    println!("{}", ans);
}


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

using namespace std;

int main(void) {
	int N;
	vector<long long> a, b;
	long long positive_total = 0;
	long long negative_capacity = 0;
	cin >> N;
	for(int i = 0; i < N; ++i) {
		long long t;
		cin >> t;
		a.push_back(t);
	}
	for(int i = 0; i < N; ++i) {
		long long t;
		cin >> t;
		b.push_back(t);
	}
	for(int i = 0; i < N; ++i) {
		if(a[i] > b[i]) {
			positive_total += a[i] - b[i];
		} else {
			const long long diff = b[i] - a[i];
			if(diff % 2 == 0) {
				negative_capacity += b[i] - a[i];
			} else {
				negative_capacity += b[i] - a[i] - 1;
			}
		}
	}
	if(2 * positive_total <= negative_capacity) {
		cout << "Yes\n";
	} else {
		cout << "No\n";
	}
	return 0;
}



Measured memory_bytes: 512
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>


using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;

#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i,a,b) for(int i = (a); i < (int)(b); ++i)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(v) ((int)v.size())

#define pb push_back
#define mp make_pair
#define mt make_tuple

int main(void)
{
    cin.sync_with_stdio(false);
    int N, M, Q;
    cin >> N >> M >> Q;

    vector<vector<int>> Ls(N + 1);
    REP(m, M) {
        int l, r;
        cin >> l >> r;
        Ls[l].pb(r);
    }
    FOR(n, 1, N + 1) sort(ALL(Ls[n]));
    
    REP(dummy, Q) {
        int p, q;
        cin >> p >> q;
        int ans = 0;
        FOR(l, p, q + 1) {
            auto it = lower_bound(ALL(Ls[l]), q + 1);
            ans += it - Ls[l].begin();
        }
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 2176
/* Author: $%U%$
 * Time: $%Y%$-$%M%$-$%D%$ $%h%$:$%m%$:$%s%$
**/
#include <bits/stdc++.h>
using namespace std;
#define fore(i, a, b) for (int i = a, to = b; i < to; i++)
#define all(v) v.begin(), v.end()
#define SZ(v) (int)v.size()
#define pb push_back
typedef long long Long;
typedef pair<int, int> Pair;
const Long INF = (1e18);
vector<Long> v;
void init() {
  v.push_back(100LL);
  while (true) {
    Long cur = v.back();
    if (v.back() >= INF) break;
    Long extra = cur / 100;
    v.pb(cur + extra);
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(NULL);
  init();
  Long x;
  cin >> x;
  cout << lower_bound(all(v), x) - v.begin() << '\n';

  return 0;
}

Measured memory_bytes: 3728
import java.io.*;
class Main{
  public static void main(String[] args) {
    try{
      BufferedReader br =
        new BufferedReader(new InputStreamReader(System.in));
      int i = Integer.parseInt(br.readLine());
      for(int f=0;f<i;f++){
        String[] str = br.readLine().split("\\s");
        int a = Integer.parseInt(str[0]);
        a*=a;
        int b = Integer.parseInt(str[1]);
        b*=b;
        int c = Integer.parseInt(str[2]);
        c*=c;
        if(a+b==c||b+c==a||c+a==b) System.out.println("YES");
        else System.out.println("NO");
      }
    }catch(IOException e){}
  }
}

Measured memory_bytes: 27212
#include<bits/stdc++.h>
#define ll long long 
#define MAXN 100010
using namespace std;

int n;
ll X[MAXN];
ll m[MAXN];


int main(){
	scanf("%d",&n);
	
	int x=1;
	ll ans=0;
	for(int i=1;i<=n;i++){
		scanf("%lld",&m[i]);
		ans+=m[i]*x;
		x=-x; 
	}
	X[1]=ans/2;
	for(int i=2;i<=n;i++){
		X[i]=m[i-1]-X[i-1];
	}
	for(int i=1;i<=n;i++)printf("%lld ",2*X[i]);	
}

Measured memory_bytes: 5352
#include<stdio.h>
main(void){
    
  char egara;
  int n,i,j,maisuu;
  int a[4][13]={};
  scanf("%d",&maisuu);
  
     for(i=0;i<maisuu;i++){
         
        scanf("%s%d",&egara,&n);
         if(egara=='S') a[0][n-1]=1;
         if(egara=='H') a[1][n-1]=1;
            if(egara=='C') a[2][n-1]=1;
            if(egara=='D') a[3][n-1]=1;
  }
  for(i=0;i<4;i++){
      
    for(j=0;j<13;j++){
        
      if(a[i][j]==0){
          
        if(i==0) printf("S %d\n",j+1);
        if(i==1) printf("H %d\n",j+1);
        if(i==2) printf("C %d\n",j+1);
        if(i==3) printf("D %d\n",j+1);
      }
    }
  }
  return 0;
}



Measured memory_bytes: 2112
#include<set>
#include<vector>
#include<iostream>
#define F(A, B) for(int A=0; A<B; A++)
using namespace std;

int main(){
	long num;
	int d;

	cin >> num >> d;
	while( !(num == 0 && d == 0) ){
		vector<long> arr;
		arr.push_back(num);
		int cnt=1;
		int I=-1, J=-1;
		while(1){
			multiset<int> nset;
			F(i, d){
				int dig=1;
				F(j, i){
					dig *= 10;
				}
				nset.insert( (num/dig)%10 );
			}

			int di=d-1;
			long mir=0;
			for(multiset<int>::iterator it=nset.begin(); it!=nset.end(); it++){
				int dig=1;
				F(j, di){
					dig *= 10;
				}
				mir += (*it)*dig;
				di--;
			}
			int max=0;
			di = d-1;
			for(multiset<int>::iterator it=nset.end(); it!=nset.begin(); ){
				it--;
				int dig=1;
				F(j, di){
					dig *= 10;
				}
				max += (*it)*dig;
				di--;
			}
			//cout << max << '|' << mir << '|' << max-mir << endl;
			num = max-mir;
			F(i, cnt){
				if(arr[i] == num){
					I = i;
					J = cnt-i;
					break;
				}
			}
			if(I>=0 && J>=0){
				cout << I << ' ' << num << ' ' << J << endl;
				break;
			}
			cnt++;
			arr.push_back(num);
		}
		cin >> num >> d;
	}
}

Measured memory_bytes: 1220
#include<iostream>
#include<algorithm>
using namespace std;
#define N 131072
int tree[N*2];
int getsum(int a,int b,int k,int l,int r){
  if(r<=a||b<=l)return 0;
  if(a<=l&&r<=b)return tree[k];
  int m=(l+r)/2;
  return getsum(a,b,k*2+1,l,m)+getsum(a,b,k*2+2,m,r);
}
void add(int a,int b){
  a+=N-1;
  tree[a]+=b;
  while(a){
    a=(a-1)/2;
    tree[a]+=b;
  }
}
int main(){
int n,q;
int c,a,b;
  cin>>n>>q;
  for(int i=0;i<q;i++){
    cin>>c>>a>>b;
    a--;
    if(c==1) cout<<getsum(a,b,0,0,N)<<endl;
    else add(a,b);
  }
  return 0;
} 


Measured memory_bytes: 3860
#include<bits/stdc++.h>
#define llt long long  int
#define ullt unsigned long long int
using namespace std;
void fast(){
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
    }
int main()
{
    fast();
    char a;
    cin>>a;
    cout<<(char)(a+1);
}

Measured memory_bytes: 256
#include <stdio.h>
#include <vector> 
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
using namespace std;

int main(){
    long A,B,C,K;
    cin>>A>>B>>C>>K;
    long ans=0;
    if(K-A>0){
        ans+=A;
        if(K-A-B>0){
            ans-=K-A-B;
        }else{

        }

    }else{
        ans=K;
    }
    cout<<ans;


}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define ll long long

const ll mod = 1000000007 ;

bool isInteger(double n)
{
	if(floor(n)==ceil(n))
		return true ;
	return false ;
}

using namespace std ;

int main()
{
	int k;
	cin>>k;
	string s;
	cin>>s;
	string s1="" ;
	if(s.length()<=k)
		cout<<s;
	else
	{
		for(int i=0 ;i<s.length() ;i++)
		{
			if(i<k)
				s1+=s[i];
		}
		s1+="...";
		cout<<s1;
	}

}


Measured memory_bytes: 3652
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    int[] num = new int[26];
    for(int i=0;i<s.length();i++){
      int a = s.charAt(i)-'a';
      num[a]++;
    }
    for(int i=0;i<26;i++){
      if(num[i]==0){
        
        System.out.println((char)('a'+i));
        return ;
      }
    }
    System.out.println("None");
  }
}

Measured memory_bytes: 24548