akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

ll n, k;
const ll maxn = 3000+5;
const ll maxk = 1e9+5;
ll MOD = 1e9+7;
ll a[maxn];
ll sum[maxn];
ll dp[maxn][maxn];

int main()
{
  cin >> n;
  a[0] = sum[0] = 0ll;
  for(int i = 1; i <= n; i++) cin >> a[i], sum[i] = sum[i-1] + a[i], dp[i][i] = a[i];

  for(int l = 1; l < n; l++) for(int s = 1; s+l <= n; s++) // 1 is length - 1
  {
    int r = s+l;
    dp[s][r] = max(sum[r]-sum[s-1]-dp[s+1][r], sum[r]-sum[s-1]-dp[s][r-1]);
    //cout << dp[s][r] << endl;
  }
  cout << (2*dp[1][n])-sum[n] << endl; //X-Y not X
  return 0;
}


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

const int N = 205;
int n, a[N];
vector<int> ans;

bool sorted(int n, int a[])
{
    for (int i = 0; i < n-1; i++)
        if (a[i] > a[i+1])
        return 0;
    return 1;
}
int main()
{
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> a[i];
    while(!sorted(n,a))
    {
        if (a[0] < a[n-1] && a[n-1] != n-1)
        {
            ans.push_back(n-1);
            swap(a[0],a[n-1]);
        }
        ans.push_back(1);
        for (int i = 0; i < n-1; i++)
        {
            swap(a[i],a[i+1]);
        }
    }
    cout << ans.size() << endl;
    for (auto x: ans)
        cout << x << endl;
}


Measured memory_bytes: 764
/* AtCoder Beginner Contest 127 - A */
#include<bits/stdc++.h>
using namespace std;
#define lint long long
#define ll long long
#define pq priority_queue
#define mp make_pair
#define vl vector<long long>
long long INF = 1e10;
#define pii pair<long long,long long>
#define all(x) (x).begin(),(x).end()
#define rep(x) for(int i = 0;i < (x);i++)
#define repj(x) for(int j = 0;j < (x);j++)
#define REP(i,x) for(int (i) = 0;(i) < (x);(i)++)
#define rrep(x) for(int i = (x);i >= 0;i--)
#define mod 1000000007
/******************************define**********************************/

/*****************************functions********************************/

/****************************main function*****************************/
int main(void){

    int a,b;cin >> a >> b;
    if(a>=13) cout << b << endl;
    else if(a >= 6) cout << b/2 << endl;
    else cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		long x = sc.nextLong();

		System.out.println(n+recur(x,n-x));
	}

	public static long recur(long a, long b) {
		if (b%a == 0) {
			return (2*b-a);
		} else {
			return (2*a*(b/a)+recur(b%a, a));
		}
	}

}


Measured memory_bytes: 23636
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto S = readln.chomp.to!(char[]);
    auto K = readln.chomp.to!long;

    if (S.length == 1) {
        writeln(K/2);
        return;
    }

    long[] ns;
    long cnt;
    char last;
    foreach (c; S) {
        if (cnt && last != c) {
            ns ~= cnt;
            cnt = 0;
        }
        ++cnt;
        last = c;
    }
    ns ~= cnt;

    if (ns.length == 1) {
        writeln(S.length * K / 2);
        return;
    }

    long r;
    foreach (n; ns[1..$-1]) r += n/2 * K;
    if (S[0] == S[$-1]) {
        r += ns[0]/2;
        r += ns[$-1]/2;
        r += (ns[0] + ns[$-1])/2 * (K-1);
    } else {
        r += ns[0]/2 * K;
        r += ns[$-1]/2 * K;
    }
    writeln(r);
}

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

int n;

void dfs(string s,char mx)
{
if(s.size()==n)
{
    cout<<s<<endl;
    return ;}
else 
{
for (char c='a';c<=mx+1;c++)
{string t;
t =s;
t+=c;
dfs(t,max(mx,c));

}

}


}

int main()
{
cin>>n;
dfs("",'a'-1);
return 0;

}

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

int main() {
	int a, b;
	cin >> a >> b;
	if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0) cout << "Possible" << endl;
	else cout << "Impossible" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n, ans;
int a[110], b[110];
inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
	return x * f;
}
int main()
{
	cin >> n;
	for(int i = 1; i <= n; i ++)
		a[i] = read(), ans += a[i];
	sort(a + 1, a + n + 1);
	if(ans % 10 != 0) {cout << ans; return 0;}

	for(int i = 1; i <= n; i ++)
		if(a[i] % 10 != 0) {ans -= a[i]; break;}
	if(ans % 10 == 0) cout << 0;
	else cout << ans;


	return 0;
}


Measured memory_bytes: 256
//__n1colai__
#include <bits/stdc++.h>
#include<stdint.h>
using namespace std;
#define vi vector<int>
#define pb emplace_back
#define w(t)   int t;cin>>t;while(t--)
#define show(ar) for(int i=0;i<ar.size();i++) cout<<ar[i]<<" "; cout<<endl;
#define mod 1e9+7
#define ff first
#define ss second
#define fio ios::sync_with_stdio(false); std::cin.tie(NULL); std::cout.tie(NULL);
#define all(x) (x.begin(),x.end())
#define inf 1e9+7
#define MAX 90000000
#define ll long long


vi inp(int n)
{
	vi v; int x;
	for(int i=0;i<n;i++) {
		cin>>x; v.pb(x);
	}
	return v;
}


int main()
{
	fio
	int n; cin>>n;
	vector<ll> ar;
	ll ans=0;
	while(n--){
		ll x; cin>>x;
		ar.pb(x);
		ans^=x;
	}
	vector<ll> res;
	for(int i=0;i<ar.size();i++){
		res.pb(ans^ar[i]);
	}
//	int um=17^24;
	//cout<<um<<endl;
	show(res);
	return 0;
}


Measured memory_bytes: 7948
#include <cstdio>
#include <iostream>
#include <cmath>
#include <map>
#include <algorithm>
#include <string.h>
using namespace std;
typedef long long ll;
ll n,a,b,c,d;
ll q[500005],w[500005];
int i;

int main() {
	cin >> n >> a >> b >> c >> d;
	int flag=0;
	for (i=1;i<=n;i++) {
		q[i]=a-(n-i)*d+(i-1)*c;
		w[i]=q[i]+(n-1)*(d-c);
		if (q[i]<=b&&b<=w[i]) flag=1;
	}
	if (flag) cout << "YES"; else cout << "NO";
	return 0;
}

Measured memory_bytes: 8064
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define all(in) in.begin(), in.end()
#define INF (sizeof(int) == 4 ? (int)1e9:(int)1e18)
#define EPS 0.0000000001
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
signed main(){
    string s; cin >> s;
    int ans = 0,ls = 0;
    for(int i = 0; i < s.size(); ++i){
        auto c = s[i];
        if(c == '<'){
            ans += ls + 1; ++ls;
        } else {
            int j = i;
            for(; j < s.size() and s[j] == '>'; ++j){};
            --j;
            int dif = j - i + 1;
            ans += (ls < dif ? (dif * (dif + 1)) / 2 - ls : (dif * (dif - 1)) / 2);
            ls = 0; i = j;
        }
    }
    cout << ans << endl;
}


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

int main() {
    int n;
    cin >> n;
    vector<int> p(n);
    for (int i = 0; i < n; i++) {
        cin >> p.at(i);
    }
    int cnt = 0;
    int min = p.at(0);
    for (int i = 0; i < n; i++) {
        if (min >= p.at(i)) {
            cnt++;
            min = p.at(i);
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,m;cin >> n >> m;
	int ans=(int)pow(2,m)*1900*m+(int)pow(2,m)*100*(n-m);
	cout << ans << endl;
}

Measured memory_bytes: 256
// C++(Clang 10.0.0)

//GCC用 ナゾです
//#pragma GCC target("avx")
//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")

#include <iostream>
#include <stdio.h>
#include <stdlib.h> //rand() 0~RAND_MAX2147483647
#include <math.h>
#include <time.h>   //srand((unsigned int)time(NULL));
#include <unistd.h> //sleep
#include <algorithm>
#include <cmath>
#include <vector>
#include <regex> //正規表現
#include <map>
#include <unordered_map>
#include <set>
#include <cassert> //assart(x>=0) -> x<0の時異常終了
#include <numeric>
#include <iterator>
#include <list>
#include <tuple>
#include <queue>

using namespace std;
#define ll long long int
#define FOR(i,min,max) for(ll i=(min);i<(max);i++)
#define FOReq(i,min,max) for(ll i=(min);i<=(max);i++)
#define FORREV(i,max,min) for(ll i=(max)-1;i>=(min);i--)
#define FORREVeq(i,max,min) for(ll i=(max);i>=(min);i--)

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

const int MOD=1e9+7;
const int MOD2=998244353;
const int not0=1;
const int INF=2000000001;
const ll INFll=2e18;
//const int MAX_V=10000;
const double  Micro=1e-5;

int UnUsedVariable(){
    if(INF || Micro || MOD || INFll || MOD2 || not0){;}
    return 0;
}

#define inarray(array,min,max) FOR(i,min,max){cin>>array[i];}
#define inarrayW(arrayA,arrayB,min,max) FOR(i,min,max){cin>>arrayA[i]>>arrayB[i];}
//#define br printf("\n");
#define br cout<<"\n";
#define OutputAndReturn0(x) {cout<<(x)<<endl;return 0;}
#define elif else if

#define issame(a,b,c,d) ((a)==(b) and (b)==(c) and (c)==(d))
#define isdiff3(a,b,c) ((a)!=(b) and (b)!=(c) and (c)!=(a))
#define isdiff4(a,b,c,d) ((a)!=(b) and (b)!=(c) and (c)!=(a) and (d)!=(a) and (d)!=(b) and (d)!=(c))
#define isdiff5(a,b,c,d,e) ((a)!=(b) and (b)!=(c) and (c)!=(a) and (d)!=(a) and (d)!=(b) and (d)!=(c) and (e)!=(a) and (e)!=(b) and (e)!=(c) and (e)!=(d))
#define Func3(f,a,b,c) (f)((f)((a),(b)),(c))
#define Func4(f,a,b,c,d) (f)((f)((f)((a),(b)),(c)),(d))

inline int isEven(int x){return x%2==0;}
inline int isOdd (int x){return x%2==1;}
inline ll samepair(ll x){return x*(x-1)/2;}
inline ll  gcd(ll a,ll b){ if(b==0)return a;else return gcd(b,a%b);}//最大公約数 なお一方が0なら答えは他方になるので番兵は０で良い また、負の数もOK -4%3=-1となるため
inline ll  lcm(ll a,ll b){return a*b/gcd(a,b);}//MODやオーバーフローには注意！
//inline ll  ceil(double a){return (ll)a+1;}
//ans = accumulate(A, A+N, 0, [](int a, int b) {return gcd(a,b);});
//auto count = std::count_if(v.begin(), v.end(), [](int x) { return x == 1 || x == 3; } );

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

//累積和　しゃくとり法　木構造　DP キュー　乱択アルゴリズム　嘘解法　ハッシュ　next_permulation

//課題：DP 木構造　Xor

ll probNow(){
    ll ans;ans=INF;
    ll N;
    cin>>N;
    
    ll X[N];
    inarray(X, 0, N);
    
    ll tAns=INF;
    FOReq(i, 1, 100){
        tAns=0;
        FOR(k, 0, N){
            tAns+= pow((i-X[k]),2);
        }
        //cout<<tAns<<"\n";
        ans=min(ans,tAns);
    }
    
    OutputAndReturn0(ans);
    return 0;
}

signed main(){
    cin.tie(0);    //cinとcoutの結び付き解除（cout時にcinの内容を吐き出さなくなる）
    ios::sync_with_stdio(false);  //coutとprintfの結び付き解除（coutとprintfを同時に使うな！）
    probNow();
    return 0;
}


Measured memory_bytes: 256
import sys
readline = sys.stdin.readline
def dfs(root):
    visited = [False] * n
    queue = [(0, root)]
    longest = (-1, -1)
    while queue:
        total_weight, node = queue.pop()
        if visited[node]:
            continue
        visited[node] = True
        longest = max(longest, (total_weight, node))
        for w, t in edges[node]:
            if not visited[t]:
                queue.append((total_weight + w, t))
    return longest
n = int(readline())
edges = [set() for _ in range(n)]
for _ in range(n - 1):
    s, t, w = map(int, readline().split())
    edges[s].add((w, t))
    edges[t].add((w, s))
_, ln = dfs(0)
ld, _ = dfs(ln)
print(ld)

Measured memory_bytes: 52972
//#include<bits/stdc++.h>
#include<iostream>
#include<memory>

using namespace std;

int map[55][55] = { 0 };
int  readed[55] = { 0 };
int q[51][51] = { 0 };

//当前遍历点为x,总共n个点；
int bianli(int x,int n)
{
	int e, sum = 0;
	for (e = 0; e <= n; e++)
	{
		if(map[x][e]&&readed[e]==0)
		{
			readed[e]++; 
			sum+=bianli(e, n);
		}
	}
	if(!sum)
	return 1;
	else return sum+1;
}
int main()
{
	int n, m, i, j, x, y, N = 0, Q = 0;
	cin >> n >> m;
	for (i = 0; i < m; i++)
	{
		cin >> x >> y;
		map[x][y] = 1;
		map[y][x] = 1;
	}
	for(i=1;i<=n;i++)
		for (j = 1; j <= n; j++)
		{
			if (map[i][j] == 1 && q[i][j] == 0) 
			{
				for(int e=0;e<55;e++)
                  readed[e]=0;
				map[i][j] = 0;
				map[j][i] = 0;
				readed[i] = 1;
				if (bianli(i, n) != n) { Q++; q[i][j] = 1; q[j][i] = 1; }
				//看map[i][j]边是不是桥；
				//是的话Q++；
				map[i][j] = 1;
				map[j][i] = 1;
				readed[i] = 0;
			}
		}
	cout << Q << endl;
	return 0;
}

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

using namespace std;
using namespace __gnu_pbds;

#define endl '\n'

typedef long long ll;
typedef pair<int, int> pii;
//typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

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

	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	
	string s;
	cin >> s;
	int n = s.size();
	
	for(int i = 0; i < n; i++)
		cout << "x";
	cout << endl;

	return 0;
}


Measured memory_bytes: 256
if __name__ == '__main__':

	n = int(input())
	
	d = {}
	for i in range(n):
		cmd = input()
		if cmd in d:
			d[cmd] += 1
		else:
			d[cmd] = 1

	mval = max(d.values())
	A = [kv[0] for kv in d.items() if kv[1] == mval]

	B = sorted(A)
	for b in B:
		print(b)


Measured memory_bytes: 35628
var obj = init();
Main();
function nextInt(){return myconv(next(),1);}
function nextStrArray(){return myconv(next(),2);}//半角スペース分割
function nextIntArray(){return myconv(next(),4);}//半角スペース + 数値化
function nextCharArray(){return myconv(next(),6);}//1文字分割
function next(){return obj.next();}
function hasNext(){return obj.hasNext();}
function myin(){return require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");}
function init(){
  var inputFile = myin();
  var returnObj = {
    "list" : inputFile, "index" : 0, "max" : inputFile.length,
    "hasNext" : function(){return (this.index < this.max);},
    "next" : function(){if(!this.hasNext()){return "";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(t){console.log(t);}//標準出力
function myerr(t){console.error(t);}//標準エラー出力
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す　1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
function Main(){
  var one = nextIntArray();
  var D = one[0];
  var N = one[1];
  if(N == 100){
    N++;
  }
  myout(Math.pow(100,D) * N);
}

Measured memory_bytes: 7372
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
#define rusha scanf("%d",&n);rep(i,1,n)scanf("%d",&a[i]);
#define rushb scanf("%d",&t);while(t--)
#define debug(x) cout<<" L-B-W-- "<<x<<" --N-B\n"
#define pb push_back
#define pii pair<int,int>
#define vii vector<int>
#define fi first
#define se second
#define mem(a,b) memset(a,b,sizeof a)
#define all(x) (x.begin(),x.end())
#define judgef printf("%s\n",f?"Yes":"No")
#define Judgef printf("%s\n",f?"YES":"NO")
#define sz(x) ((int)(x).size())
#define sf(x) (sizeof(x))
using namespace std;
typedef long long ll;
typedef double db;
const double pai = acos(-1.0);
const double eps = 1e-8;
const int mod=998244353;
//const int mod=1e9+7;
const int inf=1e9+7;
//const ll inf=0x7f7f7f7f1234abcd;
const int maxn=1e5+10;
inline ll ksm(ll x,ll y){ll res=1;while(y){if(y&1)res=res*x%mod;x=x*x%mod;y>>=1;}return res;}
inline ll inv(ll a,ll p){if(a==1)return 1;return (p-p/a)*inv(p%a,p)%p;}
inline ll lcm(ll a,ll b){return a * b / __gcd(a, b);}
int t,n,m,k;
vii ve[maxn];
int d[maxn];
bool ff[maxn];
void bfs(){
    queue<int>qu;
    qu.push(1);
    ff[1]=1;
    while(!qu.empty()){
        int g=qu.front();
        qu.pop();
        for(auto v:ve[g]){
            if(ff[v]==0){
                qu.push(v);
                ff[v]=1;
                d[v]=g;
            }
        }
    }
}
int main()
{
    int u,v;
    scanf("%d%d",&n,&m);
    rep(i,1,m){
        scanf("%d%d",&u,&v);
        ve[u].pb(v);
        ve[v].pb(u);
    }
    bfs();
    bool f=1;
    rep(i,2,n) if(d[i]==0) f=0;
    if(f==0) puts("No");
    else {
        puts("Yes");
        rep(i,2,n) printf("%d\n",d[i]);
    }
    return 0;
}


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

typedef long long ll;
typedef pair<int, int> P;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

#ifdef LOCAL
#include "../lib/dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

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

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  // freopen("temp.1", "r", stdin);
  int N;
  ll X;
  cin >> N >> X;
  N++;
  vector<ll> x(N);
  x[0] = X;
  for (int i = 1; i < N; i++) {
    cin >> x[i];
  }
  sort(x.begin(), x.end());
  vector<ll> d(N - 1);
  for (int i = 0; i < N - 1; i++) {
    d[i] = x[i + 1] - x[i];
  }
  if (N == 2) {
    cout << d[0] << endl;
    return 0;
  }
  ll ans = d[0];
  for (int i = 1; i < N - 1; i++) {
    ans = gcd(ans, d[i]);
  }
  dumpv(x);
  dumpv(d);
  dump(ans);
  cout << ans << endl;
  return 0;
}

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

int main() {
int N;
cin>>N;
vector<int> A(N);
for(int i=0;i<N;i++){
    cin>>A.at(i);
}
long long ans=0;
for(int i=1;i<N;i++){
    if(A.at(i-1)>A.at(i)){
        ans+=A.at(i-1)-A.at(i);
        A.at(i)=A.at(i-1);
    }
}
cout<<ans<<endl;
}

Measured memory_bytes: 4028
#[allow(unused_macros)]
macro_rules! parse_line {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            iter.next().unwrap().parse::<$t>().unwrap()
        }
    );

    ( $( $t:ty), +) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ( $(iter.next().unwrap().parse::<$t>().unwrap()),* )
        }
    );
}

#[allow(unused_macros)]
macro_rules! read_line {
    () => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            line.pop();
            line
        }
    )
}

#[allow(unused_macros)]
macro_rules! parse_vec {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let iter = line.split_whitespace();
            iter.map(|v| v.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    )
}

fn solve(a: u32, b: u32, k: u32) -> Vec<u32> {
    if  b-a+1 <= 2*k {
        return (a..b+1).collect()
    }

    let mut v1 = (a..a+k).collect::<Vec<u32>>();
    let v2 = (b-k+1..b+1).collect::<Vec<u32>>();
    v1.extend(v2.iter());
    v1
}

fn main() {
    let (a, b, k) = parse_line!(u32, u32, u32);
    for v in solve(a,b,k) {
        println!("{}", v);
    }
}

#[test]
fn solve_test() {
    assert_eq!(solve(3,8,2), vec![3,4,7,8]);
    assert_eq!(solve(4,8,3), vec![4,5,6,7,8]);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#include <atcoder/dsu>
using namespace atcoder;
using namespace std;
#define rep(i,n) for (int i = 0; i < n; ++i)
using ll = long long;
using P = pair<int,int>;
int main() {
   int n,m;cin>>n>>m;
   dsu d(n);
   rep(i,m){
      int a,b;cin>>a>>b;
      a--;b--;
      d.merge(a,b);
   }
   cout<<d.groups().size()-1<<endl;
}

Measured memory_bytes: 8812
#[allow(unused_imports)]
use std::collections::VecDeque;
#[allow(unused_imports)]
use std::cmp;
#[allow(unused_imports)]
use std::collections::HashMap;

#[allow(unused_macros)]
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()));
        #[allow(unused_variables)]
        #[allow(unused_mut)]
        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)*}
    };
}

#[allow(unused_macros)]
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)*}
    };
 
    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
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, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };
 
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
 
    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };
 
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };
 
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("parse error")
    };
}

fn main() {
    input!{
        n: usize,
        k: i64,
        arr: [usize1; n]
    }
    let mut dist = vec![-1; n];
    let mut queue = VecDeque::new();
    let mut to = 0;
    let mut loopstartindex = 0;
    let mut loopendindex = 0;
    dist[0] = 0;
    queue.push_back(0);
    for i in 1..n+1 {
        let to2 = arr[to];
        if dist[to2] != -1 {
            loopstartindex = dist[to2];
            break;
        }
        dist[to2] = i as i64;
        queue.push_back(to2);
        to = to2;
        loopendindex = i;
    }
    let loopsize = loopendindex as i64 + 1 - loopstartindex;
    let distsize_without_loop = if k > loopstartindex {(k - loopstartindex) % loopsize + loopstartindex} else {k};
    for _ in 0..distsize_without_loop {
        queue.pop_front();
    }

    println!("{}", queue[0] + 1);
}

Measured memory_bytes: 6672
#include<stdio.h>
#include<iostream>
#include<string>
#include<cstdlib>

using namespace std;

int main()
{
	int a, b, c500, c100, c50, c10, c5, c1, sum = 0;
	cin >> a;

	while (1)
	{
		if (a == 0)
		{
			break;
		}

		b = 1000 - a;
		c500 = b / 500;
		b = b % 500;
		c100 = b / 100;
		b = b % 100;
		c50 = b / 50;
		b = b % 50;
		c10 = b / 10;
		b = b % 10;
		c5 = b / 5;
		b = b % 5;
		c1 = b / 1;

		sum = c500 + c100 + c50 + c10 + c5 + c1;
		cout << sum<<endl;
		cin >> a;
	}
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pi 3.1415926535898
int32_t main()
{
   int k;
   cin>>k;
   string s;
   cin>>s;
   int n=s.size();
   if(n>k)
   {
      string w = s.substr(0,k);
      w+="...";
      cout<<w;
   }
   else
    cout<<s;

}

Measured memory_bytes: 3608
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

constexpr ll infl = 10000000000000007LL;
constexpr int inf = 1000000007;

int main() {
    string s;
    cin >> s;
    s += '.';
    int st = 0;
    int ans = 0;
    for (int i = 1; i < s.size(); ++i) {
        if (s[i] != s[i - 1]) {
            int l = i - st;
            ans += l / 3 * 2 + (l % 3 != 0);
            st = i;

            if (l % 3 == 2 && s[i] != '.') {
                ans += 1;
                st += 1;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstring>
#include<deque>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

using lint = long long;
using P = pair<int, int>;
using LLP = pair<long long, long long>;

#define REP(i, x, n) for(int i = (x), i##_len = int(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = int(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = int(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = int(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = int(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())
#define TWINS(x) cout << ((x) ? "Yay!" : ":(") << endl

const int IINF = (1 << 30) - 1;
const long long LLINF = 1LL << 61;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

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

    string s;
    cin >> s;

    map<char, int> mp;
    rep(i, s.size()){
        ++mp[s[i]];
    }

    bool flag = true;
    for(auto x : mp){
        flag &= x.second == 2;
    }

    if(flag){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

class Main
{
    public static void main(String[] args) throws Exception
    {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] s = br.readLine().split("\\s");
        int n = Integer.parseInt(s[0]);
        int m = Integer.parseInt(s[1]);
        int[][] mat = new int[n][m];
        for(int i = 0; i < n; i++)
        {
            String s1 = br.readLine();
            char[] ch = s1.toCharArray();
            for(int j = 0; j < m; j++)
            {
                if(ch[j] == '#')
                    mat[i][j] = -1;
                else
                    mat[i][j] = 0;
            }
        }
        double[][] dp = new double[n][m];
        dp[0][0] = 1;
        for(int i = 0; i < n; i++)
        {
            for(int j = 0; j < m; j++)
            {
                if(j + 1 < m && mat[i][j] == 0 && mat[i][j+1] == 0)
                    dp[i][j+1] = (dp[i][j] + dp[i][j+1])%mod;
                if(i + 1 < n && mat[i][j] == 0 && mat[i+1][j] == 0)
                    dp[i+1][j] = (dp[i+1][j] + dp[i][j])%mod;
            }
        }
        System.out.println((int)dp[n-1][m-1]);
    }
    static double mod = Math.pow(10, 9) + 7;
}

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

#define _p(...) (void)printf(__VA_ARGS__)
#define forr(x,arr) for(auto&& x:arr)
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) _rep3(i,0,n)
#define _rep3(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2,)(__VA_ARGS__)
#define _rrep2(i,n) _rrep3(i,0,n)
#define _rrep3(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2,)(__VA_ARGS__)
#define ALL(x) (x).begin(), (x).end()
#define BIT(n) (1LL<<(n))
#define SZ(x) ((int)(x).size())
#define fst first
#define snd second
using ll=long long;using pii=pair<int,int>;using vb=vector<bool>;
using vi=vector<int>;using vvi=vector<vi>;using vvvi=vector<vvi>;
using vl=vector<ll>;using vvl=vector<vl>;using vvvl=vector<vvl>;
using vd=vector<double>;using vvd=vector<vd>;using vvvd=vector<vvd>;
using vpii=vector<pii>;using vvpii=vector<vpii>;using vvvpii=vector<vvpii>;

void Main() {
  int N, D;
  scanf("%d%d", &N, &D);

  priority_queue<int, vector<int>, greater<int> > q;
  q.push(D);

  rep(i, N-1) {
    int x = q.top(); q.pop();
    int y = (~x & 127);
    int z = x | y;
    q.push(y);
    q.push(z);
  }

  int ans = 0;
  while (!q.empty()) {
    int x = q.top(); q.pop();
    ans += x;
  }

  _p("%d\n", ans);
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int T;
  scanf("%d", &T);
  while (T--) Main();
  return 0;
}


Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10000000)
import os
import math
import bisect
import collections
import itertools
import heapq
import re
import queue

# import fractions

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)
# lcm = lambda x, y: (x * y) // fractions.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    NUM = sorted(il(), reverse=True)
    K = ii()
    mx = max(NUM)
    sm = sum(NUM[1:])
    for i in range(K):
        mx *= 2
    print(sm+mx)


if __name__ == '__main__':
    main()


Measured memory_bytes: 4188
// E

#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll mod=1e9+7;

int main(){
  int N,A[100000];
  cin>>N;
  for (int i(0);i<N;i++) cin>>A[i];
  ll dp[100001][3] = {0};

  for (int i(1);i<=N;i++){
    bool flag = true;
    for (int j(0);j<3;j++){
      if (dp[i-1][j] == A[i-1] && flag == true){
        dp[i][j] = dp[i-1][j]+1;
        flag = false;
      } else {
        dp[i][j] = dp[i-1][j];
      }
    }
    sort(dp[i],dp[i]+3,greater<int>());
  }

  ll cnt(1);
  for (int i(0);i<N;i++){
    int cnti(0);
    for (int j(0);j<3;j++){
      if (A[i] == dp[i][j]) cnti++;
    }
    cnt*= cnti;
    cnt%=mod;
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 2944
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
 
#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<=n;i++)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define pb(x) push_back(x)
#define eb(x,y) emplace_back(x,y)
#define MOD 1000000007
#define MAX 1000000001
#define INF 1410065408
#define EPS 1e-9
 
using namespace std;
typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;
struct edge{int from, to; ll cost;};
 
signed main(){
    int N; ll A, B;
    cin >> N >> A >> B;
    vector<ll> hs;
    rep(N){
        ll h;
        cin >> h;
        hs.push_back(h);
    }
 
    ll max_h = *max_element(all(hs));
    //ll min_ans = (max_h+A-1) / A, max_ans = (max_h+B-1) / B;
    ll min_ans = 1, max_ans = (max_h+B-1) / B;
    ll ans;
    while(min_ans <= max_ans){
        ans = (max_ans + min_ans) / 2;
        ll check = 0;
        rep(N){
            if(hs[i] <= B*ans) continue;
            ll diff = A - B;
            check += (hs[i] - B*ans + diff - 1) / diff;
        }
        if(check <= ans){
            max_ans = ans-1;
        }else{
            min_ans = ans + 1;
        }
    }
    cout << min_ans;
}

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

typedef long long ll;
typedef pair<int, int> ii;

int main()
{
    int n, x, y;
    scanf("%d %d %d", &n, &x, &y);
    x--, y--;

    vector<int> g[n];
    for (int i = 0; i < n - 1; i++) {
        g[i + 1].push_back(i);
        g[i].push_back(i + 1);
    }
    g[x].push_back(y);
    g[y].push_back(x);

    int ans[n] = {0};
    for (int i = 0; i < n; i++) {
        // bfs
        queue<int> q;
        q.push(i);
        bool used[n] = {false};
        int dist[n] = {0};
        used[i] = true;
        dist[i] = 0;
        while (q.size() > 0) {
            int cur = q.front();
            q.pop();

            for (auto v : g[cur]) {
                if (used[v])
                    continue;
                q.push(v);
                used[v] = true;
                dist[v] = dist[cur] + 1;
            }
        }

        for (int j = 0; j < n; j++) {
            ans[dist[j]]++;
        }
    }

    for (int i = 1; i <= n - 1; i++)
        printf("%d\n", ans[i] / 2);

    return 0;
}


Measured memory_bytes: 384
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby
    #from itertools import product
    from bisect import bisect_left,bisect_right
    import heapq
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    n = int(input())
    a = [int(input()) for _ in range(5)]
    b = min(a)
    n -= 0.1
    print(int(n//b)+5)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define REP(i, a, n) for (long long i = (a); i < (long long)(n); ++i)
#define REPC(i, a, n) for (long long i = (a); i <= (long long)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init)                                          \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T> using VEC = std::vector<T>;
template <class T> using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail> void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T> ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec)
    os << v << ",";
  os << "}";
  return os;
}
template <typename T> ostream &operator<<(ostream &os, set<T> &s) {
  os << "{";
  for (auto p : s)
    os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m)
    os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  int A;
  cin>>A;
  cout<<A+A*A+A*A*A<<endl;

  return 0;
}


Measured memory_bytes: 3628
/* imports all std modules {{{*/
import
  std.algorithm,
  std.array,
  std.ascii,
  std.base64,
  std.bigint,
  std.bitmanip,
  std.compiler,
  std.complex,
  std.concurrency,
  std.container,
  std.conv,
  std.csv,
  std.datetime,
  std.demangle,
  std.encoding,
  std.exception,
  std.file,
  std.format,
  std.functional,
  std.getopt,
  std.json,
  std.math,
  std.mathspecial,
  std.meta,
  std.mmfile,
  std.net.curl,
  std.net.isemail,
  std.numeric,
  std.parallelism,
  std.path,
  std.process,
  std.random,
  std.range,
  std.regex,
  std.signals,
  std.socket,
  std.stdint,
  std.stdio,
  std.string,
  std.system,
  std.traits,
  std.typecons,
  std.uni,
  std.uri,
  std.utf,
  std.uuid,
  std.variant,
  std.zip,
  std.zlib;
/*}}}*/

/+---test
2
---+/
/+---test
4
---+/
/+---test
1000000000000
---+/

void main(string[] args) {
  const H = readln.chomp.to!long;

  long ans, cnt = 1;
  for (long h = H; h > 0; h/=2) {
    ans += cnt;
    cnt *= 2;
  }
  ans.writeln;
}


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

using namespace std;

int main() {
  double N;
  cin >> N;
  vector<double> v;
  double sum;
  for (int i = 0; i < N; ++i) {
    double tmp;
    cin >> tmp;
    sum += tmp;
    v.push_back(tmp);
  }
  double mean = sum / N;
  double diff = 10000;
  double ans;
  for (int i = 0; i < N; ++i) {
    double d = fabs(v[i] - mean);
    if (diff > d) {
      ans = i;
      diff = d;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <fstream>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int gcd(int a, int b) {
    while (b) {
        int c = a % b;
        a = b;
        b = c;
    }
    return a;
}

int main() {
    ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    int g = gcd(a, b);
    cout << 1ll * a * b / g;
}


Measured memory_bytes: 3656
#include<stdio.h>

int main(){
  int n, a, b, c, x, y[128];
  int i, j;

  while(scanf("%d%d%d%d%d", &n, &a, &b, &c, &x), n){
    for(i=0; i<n; i++){
      scanf("%d", &y[i]);
    }
    j=0;
    for(i=0; i<10002; i++){
      if(x==y[j]){
	if(j==n-1){
	  break;
	}else{
	  j++;
	}
      }
      x=(a*x+b)%c;
    }
    if(i>10000) i=-1;
    printf("%d\n", i);
  }
  
  return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, N) for (int i = 0; i < (int)N; ++i)
#define all(a) (a).begin(), (a).end()

template<typename T>
class FloydWarshall {
  bool _hasNegativeCycle;
  vector<vector<T>> distTo;

public:

  FloydWarshall(vector<vector<T>> G) {
    int V = G.size();
    T INF = numeric_limits<T>::max() / 2;
    distTo.resize(V, vector<T>(V, INF));

    for(int u = 0; u < V; ++u) {
      for(int v = 0; v < V; ++v) {
        if(u == v) {
          distTo[u][v] = 0;
          continue;
        }

        distTo[u][v] = G[u][v];
      }
    }

    for(int w = 0; w < V; ++w) {
      for(int u = 0; u < V; ++u) {
        for(int v = 0; v < V; ++v) {
          distTo[u][v] = min(distTo[u][v], distTo[u][w] + distTo[w][v]);
        }

        if(distTo[u][u] < 0) {
          _hasNegativeCycle = true;
          return;
        }
      }
    }
  }

  bool hasNegativeCycle() {
    return _hasNegativeCycle;
  }

  T dist(int s, int t) {
    return distTo[s][t];
  }
};

int N;
vector<vector<int>> A;

bool hasBypaass(int u, int v) {
  rep(w,N) {
    if(u == w || v == w) continue;
    if(A[u][v] == A[u][w] + A[w][v]) return true;
  }
  return false;
}

int main () {
  cin >> N;
  A.resize(N, vector<int>(N));
  rep(i,N)rep(j,N) cin >> A[i][j];

  FloydWarshall<int> fw(A);

  ll ans = 0;

  for(int u = 0; u < N; ++u) {
    for(int v = u + 1; v < N; ++v) {
      if(fw.dist(u, v) < A[u][v]) {
        cout << "-1" << endl;
        return 0;
      }

      if(!hasBypaass(u, v)) ans += A[u][v];
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
int main()
{
int a[3];
cin>>a[0]>>a[1]>>a[2];
if (a[0]==a[1]&&a[1]!=a[2]||a[0]==a[2]&&a[1]!=a[2]||a[2]==a[1]&&a[1]!=a[0])
cout<<"Yes"<<endl;
else
cout<<"No"<<endl;
return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include<stdio.h>
#include<string.h>
int main() {
	int d,n,t1,t2,i;
	while (~fscanf(stdin, "%d", &d), d != 0) {
		fscanf(stdin, "%d", &n);
		for (i = 0; i < n; i++) fscanf(stdin, "%d %d", &t1, &t2),d-=(t2-t1);
		if (d > 0) fprintf(stdout, "%d\n", d);
		else puts("OK");
	}
	return 0;
}

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

// macros
#define pb emplace_back
#define mk make_pair
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for(int i=((int)(n)-1);i>=0;i--)
#define irep(itr, st) for(auto itr = (st).begin(); itr != (st).end(); ++itr)
#define irrep(itr, st) for(auto itr = (st).rbegin(); itr != (st).rend(); ++itr)
#define whole(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define bit(n) (1LL<<(n))
// functions
template <typename T> void unique(T& c){c.erase(std::unique(c.begin(), c.end()), c.end());}
template <class T>bool chmax(T &a, const T &b){if(a < b){a = b; return 1;} return 0;}
template <class T>bool chmin(T &a, const T &b){if(a > b){a = b; return 1;} return 0;}
template <typename T> istream &operator>>(istream &is, vector<T> &vec){for(auto &v: vec)is >> v; return is;}
template <typename T> ostream &operator<<(ostream &os, const vector<T>& vec){for(int i = 0; i < vec.size(); i++){ os << vec[i]; if(i + 1 != vec.size())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const set<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const unordered_set<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const multiset<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const unordered_multiset<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p){os << "(" << p.first << ", " << p.second << ")"; return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const map<T1, T2> &mp){for(auto itr = mp.begin(); itr != mp.end(); ++itr){ os << "(" << itr->first << ", " << itr->second << ")"; auto titr = itr; if(++titr != mp.end())os << " "; } return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const unordered_map<T1, T2> &mp){for(auto itr = mp.begin(); itr != mp.end(); ++itr){ os << "(" << itr->first << ", " << itr->second << ")"; auto titr = itr; if(++titr != mp.end())os << " "; } return os;}
//  types
using ll = long long int;
using P = pair<int, int>;
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;
const int mod = 1000000007;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};
// io
struct fast_io{
  fast_io(){ios_base::sync_with_stdio(false); cin.tie(nullptr); cout << fixed << setprecision(20);}
} fast_io_;


int main(int argc, char const* argv[])
{
  ll n, m; cin >> n >> m;
  ll res = (n + m) * (n + m - 1) / 2 - n * m;
  cout << res << endl;
  return 0;
}


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

#ifdef LOCAL
#define debug(var) cerr << #var << " = " << var << endl;
#else
#define debug(var)
#endif

void init() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
}

void solve() {
	int x, a, b; cin >> x >> a >> b;
	cout << (x-a)%b;
}

int main() {
	init();
	int t = 1; //scanf("%d", &t);
	while (t--) {
		solve();
	}
	return 0;
}


Measured memory_bytes: 256
import java.util.*;



/**
 * Created by santa on 2016/10/16.
 */

public class Main {

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

        String s = scanner.next();

        for (int i = 0; i < s.length() / 2; i++) {
//            System.out.println(s.substring(0, s.length() / 2 - i - 1));
//            System.out.println(s.substring(s.length() / 2 - i - 1,s.length() - 2 * i - 2));
            if(s.substring(0, s.length() / 2 - i - 1).equals(s.substring(s.length() / 2 - i - 1,s.length() - 2 * i - 2))){
                System.out.println(s.length() - (i + 1) * 2);

                break;
            }
        }


    }






} // MainClass


Measured memory_bytes: 23636
import Control.Monad
import Control.Applicative

main :: IO ()
main = do
    [a, b, c] <- map read . words <$> getLine
    putStrLn $ solve a b c

solve :: Int -> Int -> Int -> String
solve a b c
    | a + b + c < 22 = "win"
    | otherwise      = "bust"


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

#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()

using namespace std;

typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;

const ll MOD = 1e9 + 7;
const ll INF = 1e18;
const ll N = 1e6 + 10;

str s;

ll adad(str x){
	ll res = 0;
	for (int i = 0; i < x.size(); i++){
		res = res * 10 + (x[i] - '0');
	}
	return res;
}

int main(){
	cin >> s;
	ll ans = 0;
	for (int mask = 0; mask < (1 << (s.size() - 1)); mask++){
		ll res = 0;
		str Now = "";
		Now += s[0];
		for (int i = 0; i < s.size() - 1; i++){
			if ((1 << i) & mask){
				res += adad(Now);
				Now = s[i + 1];
			}else{
				Now += s[i + 1];
			}
		}
		res += adad(Now);
		ans += res;
	}
	cout << ans;



	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main(void)
{
	int p[200][200], same[200], i, j, k = 0, min, dum, a_len;
	char str[200][100], dummy[200];
	
	while (scanf("%s %d", str[k], &p[k][0]) != EOF)k++;
	
	for (i = 0; i < k - 1; i++){
		min = i;
		for (j = i + 1; j < k; j++){
			if (strcmp(str[min], str[j]) > 0){
				min = j;
			}
			if (strcmp(str[min], str[j]) == 0 && p[min][0] > p[j][0]){
				min = j;
			}
			
		}
		strcpy(dummy, str[i]);
		strcpy(str[i], str[min]);
		strcpy(str[min], dummy);
		
		dum = p[i][0];
		p[i][0] = p[min][0];
		p[min][0] = dum;
		
	}
	for (i = 0; i < k; i++){
		j = i + 1;
		same[i] = 1;
		while (strcmp(str[i], str[j]) == 0){
			p[i][same[i]] = p[j][0];
			p[j][0] = -1;
			same[i]++;
			j++;
		}
		i = j - 1;
	}
	for (i = 0; i < k; i++){
		if (p[i][0] == -1)continue;
		else {
			printf("%s\n", str[i]);
			for (j = 0; j < same[i]; j++){
				printf("%d", p[i][j]);
				if (j != same[i] - 1)printf(" ");
				else printf("\n");
			}
		}
	}
	
	return (0);
}

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

int main() {
  string S, T, U;
  int A, B;
  cin >> S >> T;
  cin >> A >> B;
  cin >> U;
  if(U == S){
    --A;
  }
  else if(U == T){
    --B;
  }
  cout << A << " "<< B << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
using namespace std;
int myabs(int x) {return x>0?x:-x;}
int a[110000];
int main()
{
	int n;scanf("%d",&n);
	int sum=0;
	a[0]=a[n+1]=0;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		sum+=myabs(a[i-1]-a[i]);
	}
	sum+=myabs(a[n]-a[n+1]);
		
	for(int i=1;i<=n;i++)
	{
		int t=myabs(a[i-1]-a[i])+myabs(a[i]-a[i+1])-myabs(a[i-1]-a[i+1]);
		printf("%d\n",sum-t);
	}
}

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

int solve(vector<int> D, vector<int> imos, int i, int d){
  int n = D.size();
  if(i == n) return 0;
  d += imos[i];
  D[i] += 10 - d;
  D[i] %= 10;
  int ret = 1e9;
  if(D[i]){
    for(int j = i+1; j <= n; ++j){
      imos[j] -= D[i];
      ret = min(ret, 1 + solve(D,imos,i+1,(d+D[i])%10));
      imos[j] += D[i];
    }
  }else{
    ret = min(ret,solve(D,imos,i+1,d));
  }
  return ret;
}

int main(){
  int N;
  while(cin >> N, N){
    string S, T;
    cin >> S >> T;
    vector<int> D(N);
    for(int i = 0; i < N; ++i){
      D[i] = (T[i]-S[i]+10)%10;
    }
    cout << solve(D,vector<int>(N+1,0),0,0) << endl;
  }
  return 0;
}



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


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int k;
    cin>>k;
    ll sum=0;
    for(int i=1;i<=k;++i)
    {
        for(int j=1;j<=k;++j)
        {
            for(int l=1;l<=k;++l)
            {
                sum+=__gcd(__gcd(i,j),l);
            }
        }
    }
    cout<<sum<<"\n";

}


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


int main(){
	string w;
	cin >> w;
	int N = w.size();
	vector<int> alphabet(26);
	rep(i,N){
		++alphabet[w[i] - 'a'];
	}
	rep(i,26){
		if(alphabet[i]%2!=0){
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}












Measured memory_bytes: 3568