akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <fstream>
#include <sstream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <string.h>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
typedef long long ll;

int main() {

    ll N; cin >> N;

    for (ll h = 1; h <= 3500; h++) {
        for (ll n = 1; n <= 3500; n++) {
            ll t = 4LL * n * h - N * (h + n);
            if (t <= 0) continue;
            ll w = (n * h * N) / t;
            if ((n * h * N) % t == 0) {
                ll a = 4LL * n * w * h;
                ll b = (n * w + w * h + h * n) * N;
                //cout << a << " " << b << endl;
                cout << w << " " << n << " " << h << endl;
                return 0;
            }
        }
    }

    return 0;
}


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

using namespace std;

struct Triangle {
    int a, b, x;
    bool operator <(const Triangle &other) const {
        return a < other.a;
    }
};

bool update(int &a, int v) {
    if(a > v) return false;
    a = v;
    return true;
}

int dp[2][5000];
int main() {
    int N, M;
    cin >> N >> M;
    vector<Triangle> triangles(M);
    for(int i = 0; i < M; ++i) {
        Triangle &t = triangles[i];
        cin >> t.a >> t.b >> t.x;
    }
    sort(triangles.begin(), triangles.end());

    int ans = 0;
    int ptr = 0;
    vector<Triangle>::iterator it = triangles.begin();
    dp[ptr][0] = -1;
    for(int i = 0; i < N; ++i) {
        int np = 1-ptr;
        while(it != triangles.end() && it->a-1 == i) {
            update(dp[ptr][it->b-1], it->x);
            ++it;
        }
        for(int j = 0; j < N; ++j) {
            dp[np][j] = -1;
        }
        for(int j = 0; j <= i; ++j) {
            if(dp[ptr][j] != -1) {
                ++ans;
                update(dp[np][j], dp[ptr][j]-1);
                if(j+1 < N) update(dp[np][j+1], dp[ptr][j]-1);
            }
        }
        ptr = np;
    }
    cout << ans << endl;
    return 0;
}

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

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

Measured memory_bytes: 256
from collections import Counter

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

L=[]
for i in range(N):
    A=list(map(int,input().split()))
    L.append(A)
    
OUTD=dict()
S=[0 for i in range(N)]

ANS=1000
for i in range(M):
    B=[0 for _ in range(N)]
    for j in range(N):
        for k in range(S[j],M):
            if L[j][k] in OUTD:
                S[j]+=1
            else:
                B[j]=L[j][k]
                break
    X=Counter(B).most_common()[0]
    if X[1]<ANS:
        ANS=X[1]
    OUTD[X[0]]=1
    #print(ANS,B,OUTD)
print(ANS)

Measured memory_bytes: 46172
<?php
$ans = 0;
fscanf(STDIN,"%d %d",$n,$d);
for($i = 0;$i < $n;++$i) {
    fscanf(STDIN,"%d %d",$x,$y);
    if (sqrt($x ** 2 + $y ** 2) <= $d) {
        ++$ans;
    }
}
echo $ans.PHP_EOL;

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

int main() {
  int64_t N, M;
  cin >> N >> M;
  vector<int> issafe(N+1, 1);
  vector<int> a(N+1);
  rep(i, M){
    cin >> a[i];
    issafe[a[i]]=0;
  }
  
  int64_t mod=1000000007;
  
  vector<int64_t> dp(N+1);
  dp[0]=1;
  
  if(issafe[1]==0) dp[1]=0;
  else dp[1]=1;
  
  for(int i=2; i<N+1; i++){
    if(issafe[i]==0) dp[i]=0;
    else dp[i]=dp[i-2]%mod +dp[i-1]%mod;
  }
  
  cout << (int64_t)dp[N]%mod;

}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <cstdlib>
#include <cmath>

using namespace std;
typedef long long ll;

const int gr1[] = {1,3,5,7,8,10,12 };
const int gr2[] = {4,6,9,11};

int func(int x) {
	for (int i = 0; i < 7;i++) {
		if (gr1[i] == x)return 1;
	}
	for (int i = 0; i < 4; i++) {
		if (gr2[i] == x)return 2;
	}
	return 3;
}
int main() {
	int x, y;
	bool ans=false;
	cin >> x >> y;
	if (func(x) == func(y))ans = true;
	cout << (ans ? "Yes" : "No") << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int t = 2*n;
  int arr[t];
  for(int i=0;i<t;i++)
		cin>>arr[i];
  sort(arr,arr+t);
  int sum=0;
  int i=0;
  while(i<t)
  {
    sum+=arr[i];
    i = i+2;
  }
  cout<<sum;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
using ll = long long;
using P = pair<int,int>;
void Yes() {
    cout << "Yes" << endl;
}
void No() {
    cout << "No" << endl;
}
int main(void) {
    int x, a, b; cin >> x >> a >> b;
    cout << (x-a)%b;
}


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

using namespace std;
using llong = long long;
using ldbl = long double;
using P = pair<llong, llong>;

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

const llong inf = 1100100100100100ll;
const llong mod = 1e9+7;

llong N, K;
vector<vector<llong> > dp;

llong solve(llong now, llong bunkatsu) {
	if (now == 0) return dp[now][bunkatsu] = bunkatsu == 0;
	if (bunkatsu == 0) return 0;
	if (dp[now][bunkatsu] != -1) return dp[now][bunkatsu];

	return dp[now][bunkatsu] = (solve(now-1, bunkatsu) + solve(now-1, bunkatsu-1)) % mod;
}

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

	dp.resize(N+1, vector<llong>(K+2, -1));
	for (int i = 0; i <= K+1; ++i) {
		solve(N, i);
		solve(N-K, i);
	}

	for (int i = 1; i <= K; ++i) {
		// llong b = dp[K][i];
		// llong r = (dp[N-K][i-1] + dp[N-K][i]*2 + dp[N-K][i+1]) % mod;
		// cout << b*r%mod << endl;
		// cerr << dp[K][i] << " " << dp[N-K][i-1] << " " << dp[N-K][i] << " " << dp[N-K][i+1] << endl;
		cout << dp[K][i] * (max(0ll, dp[N-K][i-1]) + max(0ll, dp[N-K][i])*2ll + max(0ll, dp[N-K][i+1])) % mod << endl;
	}

	return 0;
}

/*

Kをi分割して整列する場合の数
N-Kをi-1, i, i+1分割して整列する場合の数

dp i個まででj分割

*/


// #include <bits/stdc++.h>

// using namespace std;
// using llong = long long;
// using ldbl = long double;
// using lpair = pair<llong, llong>;

// #define ALL(x) x.begin(), x.end()

// const llong inf = 1100100100100100ll;
// const llong mod = 1e9+7;

// llong N, K;
// vector<vector<llong> > memo;

// llong dp(llong now, llong sep) {
// 	if (now == 0) return memo[now][sep] = sep == 0;
// 	if (sep == 0) return memo[now][sep] = 0;
// 	if (memo[now][sep] != -1) return memo[now][sep];

// 	return memo[now][sep] = (dp(now-1, sep) + dp(now-1, sep-1)) % mod;
// }

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

// 	memo.resize(N+1, vector<llong>(K+2, -1));
// 	for (int i = 0; i <= K+1; ++i)
// 		dp(N, i);

// 	for (int i = 1; i <= K; ++i) {
// 		llong b = memo[K][i];
// 		llong r = (memo[N-K][i-1] + memo[N-K][i]*2 + memo[N-K][i+1]) % mod;

// 		cout << b*r << endl;
// 	}

// 	return 0;
// }

Measured memory_bytes: 31744
import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);

    int N = sc.nextInt();
    int[] a = new int[N + 1];

    for (int i = 1; i < N + 1; i++) {
      a[i] = sc.nextInt();
    }

    sc.close();

    int count = 0;

    boolean valid = true;
    int current = 1;

    while (valid) {

      count++;
      
      current = a[current];

      if (current == 2) {
        valid = false;
      }

      if (count == N) {
        count = 0;
        valid = false;
      }

    }

    if (count == 0) {
      System.out.println(-1);
    } else {
      System.out.println(count);
    }

  }

}

Measured memory_bytes: 51092
#include<bits/stdc++.h>
using namespace std;
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define pa pair<int,int>
#define mod 998244353
#define ll long long
#define mk make_pair
#define pb push_back
#define fi first
#define se second
#define cl(x) memset(x,0,sizeof x)
#ifdef Devil_Gary
#define bug(x) cout<<(#x)<<" "<<(x)<<endl
#define debug(...) fprintf(stderr, __VA_ARGS__)
#else
#define bug(x)
#define debug(...)
#endif

const int INF = 0x7fffffff;
const int N=2e5+5;
/*
char *TT,*mo,but[(1<<15)+2];
#define getchar() ((TT==mo&&(mo=(TT=but)+fread(but,1,1<<15,stdin),TT==mo))?-1:*TT++)//*/
inline int read(){
    int x=0,rev=0,ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')rev=1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+ch-'0';ch=getchar();}
    return rev?-x:x;
}
int n,k,a[N];
int main(){
#ifdef Devil_Gary
    freopen("in.txt","r",stdin);
//  freopen("out.txt","w",stdout);
#endif
	n=read(),k=read();
	for(int i=1;i<=n;i++) a[i]=read();
	for(int i=k+1;i<=n;i++) if(a[i]>a[i-k]) printf("Yes\n");else printf("No\n") ;
	return 0;
}


Measured memory_bytes: 4400
#include<stdio.h>
#define MAX 100000

struct Node{
	int parent;
	int left;
	int right;
};

struct Node T[MAX];
int n, D[MAX], H[MAX];

int setDepth(int u, int d){
	if ( u==-1 ){ return; }
	D[u] = d;
	setDepth(T[u].left, d+1);
	setDepth(T[u].right, d+1);
}

int setHeight(int u){
	int h1=0, h2=0;
	if( T[u].left != -1 ){ h1 = setHeight(T[u].left) + 1; }
	if( T[u].right != -1 ){ h2 = setHeight(T[u].right) + 1; }
	return H[u] = ( h1 > h2 ? h1 : h2 );
}

int getSibling(int u){
	if( T[u].parent == -1 ){ return -1; }
	if( T[T[u].parent].left != u && T[T[u].parent].left != -1 ){
		return T[T[u].parent].left; 
	}
	if( T[T[u].parent].right != u && T[T[u].parent].right != -1 ){
		return T[T[u].parent].right; 
	}
	return -1;
}

void print(int u){
	printf("node %d: parent = %d, sibling = %d, ", u, T[u].parent, getSibling(u));
	
	int deg = 0;
	if( T[u].left != -1 ){ deg++; }
	if( T[u].right != -1 ){ deg++; }
	
	printf("degree = %d, depth = %d, height = %d, ", deg, D[u], H[u]);
	
	if( T[u].parent == -1 ){ printf("root\n"); }
	else if( T[u].left == -1 && T[u].right == -1 ){ printf("leaf\n"); }
	else { printf("internal node\n"); }
}


int main(void){
	int n, i, j;
	int num, left, right, root = 0;
	scanf("%d", &n);
	
	for(i=0; i<n; i++){		//初期化
		T[i].parent = -1;
		T[i].left = -1;
		T[i].right = -1;
	}
	for(i=0; i<n; i++){
		scanf("%d %d %d", &num, &left, &right);
		T[num].left = left;
		T[num].right = right;
		if( left != -1 ){ T[left].parent = num; }
		if( right != -1 ){ T[right].parent = num; }
	}
	for(i=0; i<n; i++){
		if( T[i].parent == -1 ){ root = i; }
	}	
	setDepth(root, 0);
	setHeight(root);
	
	for(i=0; i<n; i++){
		print(i);
	}
	return 0;
}



Measured memory_bytes: 2048
import java.util.Scanner;

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

			while (true) {
				int a = sc.nextInt(); //第一入力
				int b = sc.nextInt(); //第二入力
				char output[][] = new char[a][b];
				if(a == 0 && b == 0) {
					break; //00のときループを抜ける
				}
				for(int i = 0; i < a; i++) {
					for(int j = 0; j < b; j++) {
						if(((1 <= i) && (i < a - 1)) && ((1 <= j) && (j < b - 1))){
							output[i][j] = '.';
						}else {
							output[i][j] = '#';
						}
						System.out.print(output[i][j]);
					}
					System.out.println(); //改行
				}
				System.out.println(); //改行
			}
		}
	}
}



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

int main(){
string s;
cin >> s;
int a = s.size();
long long b=0;

for(int i=0;i<a;i++){
  b = b + s[i]-48;
}

if(b%9==0) cout << "Yes" <<endl;
else cout << "No" <<endl;


}


Measured memory_bytes: 3716
#include <bits/stdc++.h>
 
using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;
 
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
 
template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
 
template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) { 
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }
 
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
  for(T& x: vec) {is >> x;} return is;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'['; for(T i: a) {out<<i<<',';} out<<']'; return out;
}
 
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const int MOD = 1000000007;

ll h, w;
string s[405];
bool used[405][405];
ll black, white;
void dfs(ll x, ll y) {
  if(s[y][x] == '#') black++;
  else white++;
  used[y][x] = true;
  REP(i, 4) {
    ll nx = x + dx[i], ny = y + dy[i];
    if(!IN(0LL,h,ny) || !IN(0LL,w,nx) || s[y][x] == s[ny][nx] || used[ny][nx]) continue;
    dfs(nx, ny);
  }
}

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

  cin >> h >> w;
  REP(i, h) cin >> s[i];

  ll ret = 0;
  REP(i, h) REP(j, w) {
    black = white = 0;
    dfs(j, i);
    ret += black * white;
  }
  cout << ret << endl;

  return 0;
}


Measured memory_bytes: 13056
n, k = gets.chomp.split(' ').map(&:to_i)
ary = gets.chomp.split(' ').map(&:to_i)

n -= k
ans = 1

while n >= (k-1)
  ans += 1
  n -= (k-1)
end

if n > 0
  ans += 1
end

p ans


Measured memory_bytes: 8708
a, b = map(int, input().split())
n = 24
unit = [
    '####',
    '#.#.',
    '#.#.',
    '....'
]
row = [
    '.' + unit[0]*n + '#',
    '.' + unit[1]*n + '#',
    '.' + unit[2]*n + '#',
    '.' + unit[3]*n + '#'
]
grid = []
for i in range(n):
    grid.append(list(row[0]))
    grid.append(list(row[1]))
    grid.append(list(row[2]))
    grid.append(list(row[3]))
"""
# 黒
for i in range(n):
    grid[0][4*(i+1)] = 'x'
for i in range(n):
    grid[4*i][4] = 'y'
# 白
for i in range(n):
    grid[2][4*(i+1)-2] = 'w'
for i in range(n):
    grid[4*(i+1)-2][2] = 'v'
"""
# 白
for i in range(a//n+1):
    for j in range(n):
        if i * n + j < a-1:
            #print('#',4*(j+1)-2,4*(i+1)-2)
            grid[4*(i+1)-2][4*(j+1)-2] = '#'

# 黒
for i in range(b//n+1):
    for j in range(n):
        if i * n + j < b-1:
            #print('.',4*j,4*(i+1))
            grid[4*i][4*(j+1)] = '.'

print(len(grid), len(grid[0]))
for i in grid:
    print(''.join(i))



Measured memory_bytes: 3700
import java.util.Scanner;

public class Main {
	private static Scanner stdIn;
	
	public static void main(String[] args) {
		stdIn = new Scanner(System.in);
		int a = stdIn.nextInt();
		int b = stdIn.nextInt();
		
		if(a > 0) 
			System.out.println("Positive");
		else if(a == 0 || b >= 0)
			System.out.println("Zero");
		else {
			if((b - a) % 2 == 1)
				System.out.println("Positive");
			else
				System.out.println("Negative");
		}
	}
}


Measured memory_bytes: 23508
#include <bits/stdc++.h>
typedef long long LL;
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;
LL p = 1000000007ll;

int main(void)
{
  LL n;
  cin >> n;
  vector<LL> s(n);
  for(auto &x:s) cin >> x;
  LL answer = 0;
  FOR(a,1,n) {
    LL tmp = 0;
    for(LL pos = 0; pos <= n-a; pos += a) {
      if(pos == n-pos-1) break;
      if(pos - a == n-pos-1) break;
      tmp += s[pos];
      tmp += s[n-pos-1];
      answer = max(answer, tmp);
    }
  }
  cout << answer << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define index(xs, x) (int)(lower_bound(all(xs), x) - xs.begin())
#define _1 first
#define _2 second
#define pb push_back
#define INF (1LL<<60)
#define MOD 1000000007
#define MAX_N (1<<18)
typedef pair<long long, long long> Node;
Node seg[MAX_N*2-1];
Node op(Node a, Node b) {
  return Node(max(a._1+b._1, a._2+b._2), max(a._1+b._2, a._2+b._1));
}
void update(int k, int v) {
  k += MAX_N-1;
  seg[k] = Node(0, v);
  while (k > 0) {
    k = (k-1)/2;
    seg[k] = op(seg[k*2+1], seg[k*2+2]);
  }
}
Node query(int a, int b, int k=0, int l=0, int r=MAX_N) {
  if (b <= l || r <= a) return Node(0, -INF);
  if (a <= l && b <= r) return seg[k];
  return op(query(a, b, k*2+1, l, (l+r)/2), query(a, b, k*2+2, (l+r)/2, r));
}

int N, Q;
int A[200000], B[200000];

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  rep(i, MAX_N*2-1) seg[i] = Node(0, -INF);

  cin >> N >> Q;
  N *= 2;
  rep(i, N) cin >> A[i];
  rep(i, N) cin >> B[i];
  long long base = 0;
  rep(i, N) {
    if (i > 0 && i < N-1) update(i-1, B[i]-A[i]);
    base += A[i];
  }
  rep(i, Q) {
    int p, a, b;
    cin >> p >> a >> b;
    p--;
    base -= A[p];
    A[p] = a, B[p] = b;
    base += A[p];
    if (p > 0 && p < N-1) update(p-1, B[p]-A[p]);
    cout << base+query(0, MAX_N)._1 << "\n";
  }
  return 0;
}


Measured memory_bytes: 11520
#include <iostream>
#include <math.h>
using namespace std;

int main(){
  int M,K;
  cin >> M >> K;
  if(K >= pow(2,M)){
    cout << -1 << endl;
    return 0;
  }
  if(M == 0){
    cout << "0 0" << endl;
    return 0;
  }
  if(K == 0){
    for(int i = 0;i < pow(2,M);i++)cout << i << " ";
    for(int i = pow(2,M)-1;i >= 1;i--)cout << i << " ";
    cout << 0 << endl;
    return 0;
  }
  if(M == 1){
    if(K == 0)cout << "0 0 1 1" << endl;
    else cout << -1 << endl;
    return 0;
  }
  for(int i = 0;i < pow(2,M);i++){
    if(i == K)continue;
    cout << i << " ";
  }
  cout << K << " ";
  for(int i = pow(2,M)-1;i >= 0;i--){
    if(i == K)continue;
    cout << i << " ";
  }
  cout << K << endl;
  return 0;
}

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


int main() {
  int n;
  cin >> n;
  int ans = 1000 - (n%1000);
  if (ans == 1000) {
    cout << 0;
  } else {
    cout << ans;
  }
}

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

using namespace std;
typedef long long ll;
typedef pair<int,ll>pa;

const int N=2e5+100;
const int mod=1e9+7;
const int inf=0x3f3f3f3f;

int n,k;
priority_queue<int,vector<int>,greater<int>>q;
int  head[100],to[100];
int a[100];
int ans=0;
void work(int l,int r)
{
    int kk=k-l-r;
    int sum=0;
    while(q.size()) q.pop();
    for(int i=1;i<=l;i++){
        q.push(a[i]);
    }
    for(int i=n;i>=n-r+1&&i>l;i--){
        q.push(a[i]);
    }
    int ll=n-r+1;
    if(ll<=l)
        sum=head[n];
    else
    sum=head[l]+to[ll];
   // cout<<sum<<endl;
    while(q.size()&&kk--){
        int p=q.top();
        if(p>0) break;
        else {
            q.pop();
            sum-=p;
        }
    }
   // cout<<sum<<"**"<<endl;
    ans=max(sum,ans);
}
int main()
{
   ios::sync_with_stdio(0);cin.tie(0);
   cin>>n>>k;
   for(int i=1;i<=n;i++){
     cin>>a[i];
   }
   for(int i=1;i<=n;i++){
     head[i]=head[i-1]+a[i];
   }
   for(int i=n;i>=1;i--){
     to[i]=to[i+1]+a[i];
   }
   for(int i=0;i<=n;i++)
     if(i<=k){
      for(int j=0;j+i<=k;j++){
          work(i,j);
       }
     }
    cout<<ans<<endl;
   return 0;
}



Measured memory_bytes: 3672
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <algorithm>
#include <vector>
#include <cstring>
#include <stack>
#include <cctype>
#include <utility>
#include <map>
#include <string>
#include <climits>
#include <set>
#include <sstream>
#include <utility>
#include <ctime>
#include <cassert>
#include <fstream>
using namespace std;
typedef long long LL;
#define MS(A) memset(A, 0, sizeof(A))
#define MSV(A,a) memset(A, a, sizeof(A))
#define MP make_pair
#define PB push_back
#define getcx getchar_unlocked
#define INF (int(1e9))
#define INFL (LL(1e18))
#define EPS 1e-12
#define chkbit(s, b) (s & (1<<b))
#define setbit(s, b) (s |= (1<<b))
#define chk(a) cerr << endl << #a << " : " << a << endl
#define chk2(a,b) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << endl
#define chk3(a,b,c) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << endl
#define chk4(a,b,c,d) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << "\t" << #d << " : " << d << endl
#define rep(i, a, n) for(i=a;i<n;i++)
#define rev(i, a, n) for(i=a;i>=n;i--)
#define rep_itr(itr, c) for(itr = (c).begin(); itr != (c).end(); itr++)
#define MOD 1000000007
#define MAX 100005

int main() {

	int n, d, l ,r , i, ans = 0;

	cin>>l>>r>>d;

	int lq = l / d;
	int uq = r / d;

	ans += (uq - lq);

	if(l % d == 0) ans++;

	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 3584
#include <iostream>
#include <vector>
#include <queue>
using namespace std;

const int INF = 1e+9;
vector<int> e[100000];
int d1[100000], d2[100000];

int main()
{
  int n;

  cin >> n;
  for(int i = 0; i < n-1; i++){
    int a, b;
    cin >> a >> b;

    a--; b--;
    e[a].push_back(b);
    e[b].push_back(a);
  }

  for(int i = 0; i < n; i++){
    d1[i] = d2[i] = INF;
  }

  d1[0] = d2[n-1] = 0;

  queue<int> q;

  q.push(0);
  while(!q.empty()){
    int v = q.front();
    q.pop();

    for(auto u :e[v]){
      if(d1[u] > d1[v] + 1){
        d1[u] = d1[v] + 1;
        q.push(u);
      }
    }
  }

  q.push(n-1);
  while(!q.empty()){
    int v = q.front();
    q.pop();

    for(auto u :e[v]){
      if(d2[u] > d2[v] + 1){
        d2[u] = d2[v] + 1;
        q.push(u);
      }
    }
  }

  int s = 0, f = 0;
  for(int i = 0; i < n; i++){
    if(d1[i] <= d2[i]) s++;
    else f++;
  }

  if(f >= s) cout << "Snuke" << endl;
  else cout << "Fennec" << endl;

  return 0;
}


Measured memory_bytes: 6656
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iomanip>
#include <float.h>
#include <math.h>
using namespace std;
using ll = long long;


unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

class UnionFind {
public:
    vector <ll> par;
    vector <ll> siz;
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}


int main() {
    ll n;
    cin >> n;
    vector<ll> ans(26,1341398495);
    for (int i = 0; i < n; i++) {
        string a;
        vector<ll> zans(26);
        cin >> a;
        for (int j = 0; j < a.size(); j++) {
            zans[a[j] - 'a']++;
        }
        for (int j = 0; j < 26; j++) {
            ans[j] = min(ans[j], zans[j]);
        }
    }
    for (int i = 0; i < 26; i++) {
        for (int j = 0; j < ans[i]; j++) {
            cout << (char)('a' + i);
        }
    }
    cout << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define ed cout<<"\n";
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define All(obj) (obj).begin(),(obj).end()

using namespace std;


int main() {
	speed;
	int a, b;
	cin >> a >> b;
	if (a % 2 == 0 || b % 2 == 0)cout << "No";
	else { cout << "Yes"; }
	ed;
	return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<queue>
#include<vector>
#include<algorithm>
#include<stack>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<string>


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

typedef long long ll;
#define INF 1e9

using namespace std;

int main()
{
	int n,m;
	scanf("%d %d",&n,&m);
	int road[n+1][n+1];
	REP(i,n+1)REP(j,n+1){ road[i][j] = INF;if(i == j)road[i][j] = 0;}
	
	
	REP(i,m)
	{
		int a,b,c,d;
		scanf("%d, %d, %d, %d",&a,&b,&c,&d);
		road[a][b] = c;road[b][a] = d;
	}
	
	int x1,x2,y1,y2;
	scanf("%d, %d, %d, %d",&x1,&x2,&y1,&y2);
	REP(k,n+1)REP(i,n+1)REP(j,n+1)
	road[i][j] = min(road[i][j] ,road[i][k] + road[k][j]);
	
	cout << y1 - y2 - road[x1][x2] - road[x2][x1] << endl;
	
	
	return 0;
}

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

using namespace std;

int main() {
	int X, N;
	cin >> X >> N;
	set<int >S;
	int nAns = 0;
	for (int n = 0; n<N; ++n) {
		int m;
		cin >> m;
		S.insert(m);
	}
	int nCount = 0;
	bool bend = true;
	while (bend) {
		{
			auto itr = S.find(X - nCount);
			if (itr == S.end()) { // 見つかった
				cout << X - nCount << endl;
				return 0;
			}
		}
		{
			auto itr = S.find(X + nCount);
			if (itr == S.end()) { // 見つかった
				cout << X + nCount << endl;
				return 0;
			}
		} 
		nCount++;
	}

	return 0;
}

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

using ll=long long;
const ll z=0;

ll GCD(ll n,ll m){
  if(n==1||m==1){
    return 1;
  }
  if(m==0){
    return n;
  }
  return GCD(m,n%m);
}
  
int main() {
  ll A,B,C,D;
  cin >> A >> B >> C >> D;
  ll k=-(A-1)+B+(A-1)/C-B/C-B/D+(A-1)/D+B/(C*D/GCD(C,D))-(A-1)/(C*D/GCD(C,D));
  cout << k << endl;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"log"
)

func main() {
	var n int
	if _, err := fmt.Scanf("%d", &n); err != nil {
		log.Fatalln(err)
	}
	s := make([]int, n)
	for i := 0; i < n; i++ {
		if _, err := fmt.Scanf("%d", &s[i]); err != nil {
			log.Fatalln(err)
		}
	}

	var q int
	if _, err := fmt.Scanf("%d", &q); err != nil {
		log.Fatalln(err)
	}
	t := make([]int, q)
	for i := 0; i < q; i++ {
		if _, err := fmt.Scanf("%d", &t[i]); err != nil {
			log.Fatalln(err)
		}
	}

	var sum int
	for _, n := range t {
		sum += binarySearch(s, n)
	}
	fmt.Println(sum)
}

func binarySearch(array []int, n int) int {
	left := 0
	right := len(array) - 1

	for left <= right {
		mid := (left + right) / 2
		if array[mid] == n {
			return 1
		} else if array[mid] > n {
			right = mid - 1
		} else {
			left = mid + 1
		}
	}

	return 0
}



Measured memory_bytes: 6000
import sys

def input(): return sys.stdin.readline()[:-1]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def MATINT(h): return [list(map(int, input().split())) for _ in range(h)]
def MATSTR(h): return [input() for _ in range(h)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
inf = float('inf')
mod = 10 ** 9 + 7

def main():
    N = INT()
    A = LIST()

    all = A[0]
    for a in range(len(A) - 1):
        all = all ^ A[a + 1]

    for a in A:
        if a ^ all != a:
            No()
            exit()
    Yes()

if __name__ == '__main__':
    main()


Measured memory_bytes: 60784
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<list>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<map>
#include<functional>
#include<set>

using namespace std;

#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
#define INF 9223372036854775807
#define MOD 1000000007
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef pair<ll, ll> pll;

ll n = 0, m = 0, ans = 0, sum = 0, cnt = 0, temp = 0;
string s;
bool flag;

//-------------------------------------------------------------------------------

#define MAX 1000


int main(void) {
  cin >> s;

  map<char,ll> mp;

  FOR(i, 0, 3) {
	mp[s[i]]++;
  }

  if (mp.count('a') > 0 && mp.count('b') > 0 && mp.count('c') > 0) {
	cout << "Yes" << endl;
  }
  else {
	cout << "No" << endl;
  }

  return 0;
}

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

using namespace std;

const int MOD = 1000000007;
const int MAX32 = 2147483647;
const double PI = 3.14159265358979323846;

int main() {
  int k;
  cin >> k;
  cout << (k / 2) * (k / 2 + k % 2) << endl;
}


Measured memory_bytes: 3524
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int A, B;
cin >> A >> B;
for(int i = 1; i < 4; i++){ 
       if((A * B * i) % 2 == 1) {
             cout << "Yes" << endl;
             return 0;
       } 
}

cout << "No" << endl; 
}

Measured memory_bytes: 256
#include <stdio.h>

int min(int a,int b){
	if(a>b) return b;
	else return a;
}

int abs(int a){
	if(a>0) return a;
	else return -1*a;
}

int main(void) {
	
	int n;
	int k;
	int x=0;
	int tmp = 0;
	scanf("%d%d",&n,&k);
	int dp[n];
	int cost[n];
	for(int i=0;i<n;i++){
		scanf("%d",&cost[i]);
	}
	dp[0] = 0;
	dp[1] = abs(cost[0]-cost[1]);
	
	for(int i=2;i<n;i++){
		//dp[i] = min(dp[i-2]+abs(cost[i-2]-cost[i]),dp[i-1]+abs(cost[i-1]-cost[i]));
		if(i-k<0) x = i;
		else x = k;
		for(int j=i-x;j<i;j++){
			if(j==i-x) tmp = dp[j]+abs(cost[i]-cost[j]);
			if(tmp>dp[j]+abs(cost[i]-cost[j])) tmp = dp[j]+abs(cost[i]-cost[j]);
		}
		dp[i] = tmp;
	}
	
	printf("%d",dp[n-1]);
	/*for(int i=0;i<n;i++){
		printf("%d\n",dp[i]);
	}*/
	return 0;
}

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

int main(){
  int n,x,X;
  cin>>n>>x;
  vector<long> k(n);
  for(int i=0;i<n;i++){
    cin>>X;
    if (X-x<0){
      k[i] = -(X-x);
    }else{
      k[i] = X-x;
    }
  }
  long f=k[0];
  for(int i=0;i<n-1;i++){
    f = __gcd(f,k[i+1]);
  }
  cout<<f<<endl;
  return 0;
}

Measured memory_bytes: 1024
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


INF = float('inf')


x = I()
if x >= 30:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 9184
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    while(1){
        cin >> n >> m;
        if(n + m == 0) break;
        vector<int> a(n);
        rep(i, 0, n){
            cin >> a[i];
        }
        int ans = -1;
        rep(i, 0, n){
            rep(j, i + 1, n){
                int tmp = a[i] + a[j];
                if(tmp <= m){
                    chmax(ans, tmp);
                }
            }   
        }
        if(ans == -1) cout << "NONE" << endl;
        else cout << ans << endl;
    }
}


Measured memory_bytes: 3124
// {{{ Template
// Author:  wenxing
// Date:    2017-12-30 20:43 +0800
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;
#define rep(i, l, r) for (int i = l; i < r; ++i)
#define per(i, r, l) for (int i = r; i >= l; --i)
#define repv(ele, vec) for (auto &ele : vec)
#define zero(mem) memset(mem, 0, sizeof(mem))
#define sd(_) scanf("%d", &_)
#define sdd(_, __) scanf("%d%d", &_, &__)
#define sddd(_, __, ___) scanf("%d%d%d", &_, &__, &___)
#define sdddd(_, __, ___, ____) scanf("%d%d%d%d", &_, &__, &___, &____)
#define sl(_) scanf("%ld", &_)
#define sll(_, __) scanf("%ld%ld", &_, &__)
#define slll(_, __, ___) scanf("%ld%ld%ld", &_, &__, &___)
#define sc(_) scanf("%c", &_)
#define ss(_) scanf("%s", _)
#define mid(a, b) (((a) + (b)) >> 1)
#define lft(x) x << 1
#define rht(x) x << 1 | 1
#define inf 0x3f3f3f3f
#define mp make_pair
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
// }}}

// - Pseudocode -

// {{{ Global Variables
// }}}

int main() {
    int m;
    sd(m);
    cout << 48 - m << endl;
    return 0;
}


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

int main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	int N;
	cin >> N;
	vi a(N);
	for (int i = 0; i < N; i++) {
		cin >> a[i]; --a[i];
	}
	vi b = a;
	sort(b.begin(), b.end());
	if (a == b) {
		puts("0");
		return 0;
	}
	queue<vi> q[2];
	map<vi, int> d[2];
	q[0].push(a);
	d[0][a] = 0;
	q[1].push(b);
	d[1][b] = 0;
	int dist = 0;
	while (++dist) {
		for (int i = 0; i < 2; i++) {
			while (!q[i].empty() && d[i][q[i].front()] < dist) {
				auto v = q[i].front(); q[i].pop();
				for (int x = 0; x < N; x++) {
					for (int y = x + 2; y <= N; y++) {
						auto tmp = v;
						reverse(tmp.begin() + x, tmp.begin() + y);
						if (d[i].count(tmp) == 0) {
							q[i].push(tmp);
							d[i][tmp] = d[i][v] + 1;
							if (d[!i].count(tmp)) {
								cout << d[0][tmp] + d[1][tmp] << endl;
								return 0;
							}
						}
					}
				}
			}
		}
	}
	assert(false);
	return 0;
}



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

using namespace std;

typedef long long int64;

int main()
{
  int N, M, A[300][300];

  cin >> N >> M;
  for(int i = 0; i < N; i++) {
    for(int j = 0; j < M; j++) {
      cin >> A[i][j];
      --A[i][j];
    }
  }

  auto check = [&](int v)
  {
    vector< int > tail(N, 0);
    vector< int > size[300], kill(M, 0);
    for(int i = 0; i < N; i++) {
      size[A[i][0]].push_back(i);
    }
    bool update = true;
    while(update) {
      update = false;
      for(int i = 0; i < M; i++) {
        if(kill[i] == 1) continue;

        if(size[i].size() > v) {
          kill[i] = 1;

          for(auto &s : size[i]) {
            while(tail[s] < M && kill[A[s][tail[s]]] == 1) {
              ++tail[s];
            }
            if(tail[s] == M) return (false);
            size[A[s][tail[s]]].push_back(s);
          }

          size[i].clear();
          update = true;
        }
      }
    }
    return (true);
  };

  for(int i = 1; i <= N; i++) {
    if(check(i)) {
      cout << i << endl;
      return (0);
    }
  }
}

Measured memory_bytes: 1264
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll N=1e6+5,inf=1e18,mod=1e9+7;
#define test ll testcases;cin>>testcases; while(testcases--)
#define lp(var,start,end) for (ll var = start; var <end ; ++var)
#define rlp(var,start,end) for(ll var = start; var>=end ; var--)
#define pb push_back
#define mp make_pair
#define pf push_front
#define ff first
#define ss second
#define vll vector<ll>
#define vld vector<ld>
#define pll pair<ll,ll> 
#define pld pair<ld,ld> 
#define vpll vector<pll>
#define vpld vector<pld>
#define all(X) X.begin(),X.end()
#define sz(x) ((ll)((x).size()))
const ld pi=3.141592653589793238;

bool check_prime(ll n)
{
	ll flag=0,i;
	for(i=2;i*i<=n;i++)
	{
		if(n%i==0)
		{
			flag=1;
			break;
		}
	}
	if(n==1)
	{
		return false;
	}
	else if(flag==0 || n==2 || n==3)
	{
		return true;
	}
	else
	{
		return false;
	}
}

ll fastexpo(ll a,ll b,ll MOD) 
{
	ll result=1;
	while(b>0)
	{
		if(b%2==1)
		{
			result=(result*a)%MOD;
		}
		a=(a*a)%MOD;
		b=b/2;
	}
	return result;
}

ld dp[3005][3005];
ld p[3005];

ld fxn(ll r,ll k)
{
	ld s;
	ll i;
	if(dp[r][k]!=-1.0)
	{
		return dp[r][k];
	}
	if(r==0 && k==0)
	{
		return 1.0;
	}
	else if(r==0)
	{
		return 0.0;
	}
	else if(k==0)
	{
		s=1.0;
		for(i=1;i<=r;i++)
		{
			s*=(1-p[i]);
		}
		return s;
	}
	else
	{
		dp[r][k]=p[r]*fxn(r-1,k-1)+(1-p[r])*fxn(r-1,k);
		return dp[r][k];
	}
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,i,t,j;
    ld ans;
    cin>>n;
    for(i=1;i<=n;i++)
    {
    	cin>>p[i];
    }
    for(i=0;i<3005;i++)
    {
    	for(j=0;j<3005;j++)
    	{
    		dp[i][j]=-1.0;
    	}
    }
 	for(i=n;i>=0;i--)
 	{
 		for(j=n;j>=0;j--)
 		{
 			t=fxn(i,j);
 		}
 	}
 	ans=0.0;
 	for(i=(n+1)/2;i<=n;i++)
 	{
 		ans+=dp[n][i];
 	}
 	printf("%0.10Lf\n",ans);
	return 0;
}

Measured memory_bytes: 145168
import java.util.Scanner;

// AOJ problem

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int w, h;
		for(;;) {
			h = sc.nextInt();
			w = sc.nextInt();
			
			if(h == 0 && w == 0) {
				break;
			}
			for(int j = 0; j < h; j++) {
				for(int i = 0; i < w; i++) {
					if(j % 2 == 1) {
						if(i % 2 == 1) {
							System.out.print("#");
						} else {
							 System.out.print(".");
						}
					} else {
						if(i % 2 == 1) {
							System.out.print(".");
						} else {
							System.out.print("#");
						}
					}
				}
				System.out.print("\n");
			}
			System.out.print("\n");
		}
		sc.close();
	}
}


Measured memory_bytes: 38260
use std::io::{stdout, BufWriter, Write};

macro_rules! debug {
    ($($a:expr),*) => {
       // eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

macro_rules! get {
      ($t:ty) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              line.trim().parse::<$t>().unwrap()
          }
      };
      ($($t:ty),*) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              let mut iter = line.split_whitespace();
              (
                  $(iter.next().unwrap().parse::<$t>().unwrap(),)*
              )
          }
      };
      ($t:ty; $n:expr) => {
          (0..$n).map(|_|
              get!($t)
          ).collect::<Vec<_>>()
      };
      ($($t:ty),*; $n:expr) => {
          (0..$n).map(|_|
              get!($($t),*)
          ).collect::<Vec<_>>()
      };
      ($t:ty ;;) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              line.split_whitespace()
                  .map(|t| t.parse::<$t>().unwrap())
                  .collect::<Vec<_>>()
          }
      };
      ($t:ty ;; $n:expr) => {
          (0..$n).map(|_| get!($t ;;)).collect::<Vec<_>>()
      };
}


fn exam_a(){
    let s = get!(String);
    if s.contains("a") && s.contains("b") && s.contains("c") {
        println!("Yes");
    } else {
        println!("No");
    }
}

fn exam_b(){
    let out = stdout();
    let mut out = BufWriter::new(out.lock());

    let (A, B, K) = get!(u64, u64, u64);
    if B - A >= K*2 {
        for n in A..A+K {
            writeln!(out, "{}", n).unwrap();
        } 

        if B-K >= A+K {
            for n in B-K..B {
                writeln!(out, "{}", n+1).unwrap();
            }
        } else {
          //  for n in A+K-1..B {
              for n in A+K..B {
                writeln!(out, "{}", n+1).unwrap();
            }
        }
    } else {
        for n in A..B+1 {
            writeln!(out, "{}", n).unwrap();
        }
    }
}

fn exam_c(){
}

fn main() {
    exam_b();
}


Measured memory_bytes: 4352
#include <iostream>
#include <climits>
#include <vector>
#include <queue>
 
#define MAX_V 1024
using namespace std;
 
void get_map();
void check();
struct edge
{
  int to;
  int weight;
};
 
 
const int INF = INT_MAX/4;
vector<edge> g[2000];
int graph[MAX_V][MAX_V];
int dist[MAX_V];
int numofedge;
int vertex;
int start;
int flag=0;
 
int main()
{
  get_map();
  check();
  //for(int i=0;i<vertex;i++)
    {
      for(int j=0;j<vertex;j++)
    {
      //if(i==j)
        {
          if(graph[start][j]<INF/2 && graph[j][j]<0)
        {
          cout << "NEGATIVE CYCLE" <<endl;
          return 0;
        }
        }
    }
    }
   
    for(int i=0;i<vertex;i++)
      {
    if(graph[start][i]>=INF/2)
      {
        cout << "INF" << endl;
      }
    else
      {
    cout << graph[start][i] << endl;
      }
      }
  return 0;
}
 
int fastmin(int a, int b)
{
    int c = a-b;
  return (((c)>>31)&(c))+b;
}
 
void check()
{
  //  int next;
  //int here = start;
  //for(int i=0;i<vertex;i++)
   
  for(int k=0;k<vertex;k++)//v=4
    {
      for(int i=0;i<vertex;i++)
    {
      int gik= graph[i][k];
      for(int j=0;j<1000;j++)
        {

          //if(graph[i][k] !=INF && graph[k][j]!=INF)
        {
          graph[i][j]= min(gik+graph[k][j], graph[i][j]);
        }
        }
    }
    }
   
}
 
void get_map()
{
  int edge, from ,to;
  cin >> vertex >> numofedge >> start;
   
  fill(graph[0], graph[vertex], INF);
   
  for(int i=0;i<vertex;i++)
    {
      for(int j=0;j<vertex;j++)
      {
    if(i==j)
      {
        graph[i][j]=0;
      }
    /*else
      {
        graph[i][j]=INF;
        }*/
      }
    }
 
  /*for(int i=0;i<vertex;i++)
    {
      dist[i]=INF;
    }
  */
  for(int i=0;i<numofedge;i++)
    {
      cin>>from>>to;
      cin >> graph[from][to];
    }
 
  /*  for(int i=0;i<numofedge;i++)
    {
      int from, to, weight; 
      cin >> from >> to >> weight;
      g[from].push_back({to , weight});
   }
  */ 
 
  /*  for(int i=0;i<vertex;i++)
    {
      for(int j=0;j<vertex;j++)
    {
      cout << graph[i][j] << " ";
    }
      cout << endl;
      }*/
  // dist[start]=0;
   
  /*  cout << vertex << endl;
  for(int i=0;i<vertex;i++)
    {
      for(int j=0;j<vertex;j++)
    {
      cout << graph[i][j] << " ";
    }  
      cout << endl;    
      }*/
   
 
}

Measured memory_bytes: 5300
#include <iostream>
#include <vector>
#include <queue>
using namespace std;

int main(void){

    int N, M;
    priority_queue<int> PTJ_queue;
    vector<vector<int>> PTJ_raw(100000);
    int Abuf, Bbuf;

    cin >> N >> M;

    for(int i=0; i<N; i++){
        cin >> Abuf >> Bbuf;
        PTJ_raw[Abuf].push_back(Bbuf);
    }

    int reward = 0;

    for(int i=1; i<=M; i++){
        for(int j: PTJ_raw[i]){
            PTJ_queue.push(j);
        }
        if(!PTJ_queue.empty()){
            reward += PTJ_queue.top();
            PTJ_queue.pop();
        }
    }

    cout << reward << endl;

    return 0;
}

Measured memory_bytes: 5632
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define size_of_array(array) (sizeof(array)/sizeof(array[0]))
#define MAX 100005
#define DEBUG 0 
using ll =long long;
using namespace std;
using Graph=vector<vector<int>>;

ll counter(ll num){
    return (num*(num-1))/2;
}
int main(){
    int a,b;
    cin>>a>>b;
    for(int i=1;i<1010;i++){
        int x=i*8/100;
        int y=i*10/100;
        if(a==x&&b==y){
            cout<<i<<endl;
            return 0;
        }
    }
    cout<<-1<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    char a[3];
    cin>>a;
    for(int i=0; i<3; i++){
        if(a[i]=='1')
            a[i]='9';
        else
        if(a[i]=='9')
            a[i]='1';
    }
    cout<<a;

    return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> vec(101);
  int a;
  for (int i = 0; i < N; i++) {
    cin >> a;
    vec.at(i) = a;
  }
  sort(vec.begin(), vec.end(), greater<int>());
  int A = 0, B = 0;
  for (int i = 0; i < 50; i++) {
    A += vec.at(2*i);
    B += vec.at(2*i+1);
  }
  cout << A-B << endl;
}


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

using namespace std;

class Bridge {
public:
	int u, v, cost;
};

Bridge MapData[500];
int Point[100];
int Height[100];


int find(int root) {

	while (root != Point[root]) {
		root = Point[root];
	}

	return root;
}

bool judge(int x, int y) {
	x = find(x);
	y = find(y);
	if (x == y) {
		return false;
	}

	if (Height[x] < Height[y]) {
		Point[x] = y;
	}
	else {
		Point[y] = x;
		if (Height[x] == Height[y]) {
			Height[x]++;
		}	
	}

	return true;
}

bool cmp(Bridge &b1, Bridge &b2) {
	return b1.cost < b2.cost;
}

int solve(int n, int m) {
	int cnt, sum;

	sort(MapData, MapData + m, cmp);
	for (int i = 0; i < n; i++) {
		Point[i] = i;
		Height[i] = 1;
	}

	cnt = sum = 0;
	for (int i = 0; i < m; i++) {
		if (cnt == n - 1) {
			return sum;
		}

		if (judge(MapData[i].u, MapData[i].v)) {
			cnt++;
			sum += MapData[i].cost;
		}
	}

	return sum;
}

int main() {
	int n, m;

	while (1) {
		cin >> n >> m;
		if (n == 0 && m == 0) {
			break;
		}

		for (int i = 0; i < m; i++) {
			cin >> MapData[i].u >> MapData[i].v >> MapData[i].cost;
		}

		cout << solve(n, m) << endl;
	}
	

	return 0;
}


Measured memory_bytes: 3160
def distance(a, b, d):
    res = 0
    for i in range(d):
        res += (a[i] - b[i]) ** 2
    res **= 0.5
    return res

n, d = [int(i) for i in input().split()]
dot = []
for i in range(n):
    dot.append([int(i) for i in input().split()])
ans = 0
for i in range(n):
    for j in range(i + 1, n):
        di = distance(dot[i], dot[j], d)
        if abs(int(di) - di) < 0.0001:
            ans += 1
print(ans)


Measured memory_bytes: 3064
#include<stdio.h>
char s[10000];
int main()
{
	scanf("%s", s);
	int i, w = 0;
	for (i = 0; s[i] != '\0'; i++)
	{
		if (s[i] == '-')
			w--;
		if (s[i] == '+')
			w++;
	}
	printf("%d", w);
	return 0;
}

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

int main(){
  int n,k,x,y; cin >> n >> k >> x >> y;
  int charge = 0;
  if (k >= n){
    charge = x * n;
  }
  else{
    int charge1 = x * k;
    int charge2 = (n - k) * y;
    charge = charge1 + charge2;
  }
  cout << charge;
}

Measured memory_bytes: 256