akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
    string s;
    cin >> s;
    int year = (s[0]-'0')*1000 + (s[1]-'0')*100 + (s[2]-'0')*10 + s[3]-'0';
    int month = (s[5]-'0')*10 + (s[6]-'0');
    int day = (s[8]-'0')*10 + s[9]-'0';
    if(year<=2019){
        if(month<=4){
            cout << "Heisei" << endl;
            return 0;
        }
    }
    cout << "TBD" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define P pair<int,int>
#define PI 3.141592653589793
const int INF = 1001001001;

int main() {
	ll n;
	cin >> n;
	if (n == 1) {
		cout << 0 << endl;
		return 0;
	}
	ll x = (ll)pow(n, 0.5)+1;
	vector<ll> a(x);
	
	for (ll i = 2; i * i <= n; i++) {
		if (n % i == 0) {
			while (n % i == 0) {
				a[i]++;
				n /= i;
			}
		}
	}
	ll ans = 0;
	if (n != 1) ans++;
	for (ll i = 2; i < x; i++) {
		if (a[i] != 0) {
			for (ll j = 1; j < INF;j++) {
				if (a[i] < j * (j + 1) / 2) {
					ans += j - 1;
					break;
				}
			}
		}
	}
	//cout << a[3] << endl;
	cout << ans << endl;
}

Measured memory_bytes: 11664
#include <bits/stdc++.h>
using namespace std;
bool b1[105][105]={0};
int main(){
	int a,b;
	char a1;
	cin >> a >> b;
	for (int i=1;i<=a;i++)
	for (int j=1;j<=b;j++){
		cin >> a1;
		if (a1=='#') b1[i][j]=1;
	}
	for (int i=1;i<=a;i++){
		for (int j=1;j<=b;j++){
			if (b1[i][j]==1) printf("#");
			else printf("%d",b1[i+1][j+1]+b1[i+1][j-1]+b1[i+1][j]+b1[i][j+1]+b1[i][j-1]+b1[i-1][j+1]+b1[i-1][j]+b1[i-1][j-1]);
		}
		cout << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include<algorithm>
#include<sstream>
#include<iomanip>
#include<deque>
#include<list>


using namespace std;

typedef long long ll;

typedef pair<int, int> pii;

const ll MOD_CONST = 1000000007;
const ll BIG_NUM = 1000000000000000000;
const int BIG_INT = 1000000000;



int main() {
	int n;
	cin >> n;
	vector<int> b(n);
	for (int i = 0; i < n; i++) {
		cin >> b[i];
	}
	bool canConsist;
	stack<int> procedure;
	for (int i = 0; i < n;i++) {
		canConsist = false;
		for (int j = n-1-i; j >=0; j--) {
			
			if (b[j] == j + 1) {
				
				canConsist = true;

				vector<int> tmp(n - i - 1);
				for (int k = 0;k < n - i;k++) {
					if (k < j) {
						tmp[k] = b[k];
						
					}
					if(k > j) {
						tmp[k-1] = b[k];
					}
					
				}

				b = tmp;
				procedure.push(j+1);
				break;
			}

		}
		if (!canConsist) {
			break;
		}
		//cout << i << endl;
	}

	if (canConsist) {
		while (!procedure.empty()) {
			cout << procedure.top() << endl;
			procedure.pop();
		}
	}
	else
	{
		cout << -1 << endl;
	}
	
}



Measured memory_bytes: 256
s=input()
n=len(s)
ans=0

la=[0]
lb=[0]

for i in s:
    if i=="0":
        la.append(la[-1]+1)
        lb.append(lb[-1])
    else:
        lb.append(lb[-1]+1)
        la.append(la[-1])

if n%2==0:
    for i in range(n//2+1):
        if la[n//2+i]-la[n//2-i]==0 or lb[n//2+i]-lb[n//2-i]==0:
            ans=n//2+i
else:
    for i in range(n//2+1):
        if la[n//2+i+1]-la[n//2-i]==0 or lb[n//2+i+1]-lb[n//2-i]==0:
            ans=n//2+i+1

print(ans)

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

int main(){
    int n, m;
    cin >> n >> m;
    vector<ll> x(m);
    rep(i,m) cin >> x[i];
    sort(x.begin(), x.end());
    vector<ll> d;
    for(int i = 1; i < x.size(); i++) d.push_back(x[i]-x[i-1]);
    sort(d.begin(), d.end(), greater<ll>());
    ll res = x.back() - x[0];
    rep(i,min((int)d.size(), n-1)) res -= d[i];
    cout << res << endl;
}

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

using namespace std;

bool czy[(int)1e5 + 5];
int n,m;
int dp[(int)1e5 + 5];
int suf[(int)3e5 + 5];

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	
	cin >> n >> m;
	string s;
	cin >> s;
	if(s[0] == '1' || s[n] == '1'){
		cout << -1;
		return 0;
	}
	for(int i = 0; i <= n; i++)
		if(s[i] == '1')
			czy[i] = 1;
	int last = 0;
	for(int i = 1; i <= n; i++){
		if(czy[i] == 0)
			last = i;
		suf[i] = last;
	}
	for(int i = n + 1; i <= n + m + 2; i++)
		suf[i] = last;
	dp[n] = 0;
	for(int i = n - 1; i >= 0; i--)
		dp[i] = dp[suf[i + m]] + 1;
	//~ for(int i = 0; i <= n; i++)
		//~ cout << "dp["<<i<<"] : "<< dp[i] << endl;
	int cnt = 0;
	int poz = 0;
	while(poz < n){
		if(suf[poz + m] <= poz){
			cout << -1;
			return 0;
		}
		cnt++;
		poz = suf[poz + m];
	}
	poz = 0;
	int zuzyte = 0;
	vector<int> ans;
	while(poz < n){
		//~ cout << " poz : "<< poz << endl;
		for(int i = poz + 1; i <= n; i++){
			if(dp[i] + zuzyte + 1 == cnt && czy[i] == 0){
				ans.push_back(i - poz);
				poz = i;
				zuzyte++;
				break;
			}
		} 
	}
	for(int i = 0; i < (int)ans.size(); i++)
		cout << ans[i] << ' ';
	
	
	
	return 0;
}


Measured memory_bytes: 1864
#include <cstdio>

int main()
{
  char s[11];
  scanf("%s", s);
  int max = 0;
  for (char *p = s; *p; ++p)
  {
    if (*p == 'A' || *p == 'T' || *p == 'C' || *p == 'G')
    {
      char *l = p;
      while (*p == 'A' || *p == 'T' || *p == 'C' || *p == 'G')
      {
        ++p;
      }
      if (max < p - l)
      {
        max = p - l;
      }
      --p;
    }
  }
  printf("%d\n", max);
  return 0;
}

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

int main(){
    int N;
    cin >> N;
    vector<int> L(N);
    rep(i,N) cin >> L[i];
    
    int ans=0;
    sort(L.begin(),L.end(),greater<int>());

    for(int i =0;i <N;i++){
        int f=0;
        for(int j = i+1;j<N;j++){
            for(int k= j+1;k<N;k++){
                if(L[i]<L[j]+L[k]) ans++;
                else break;
            }
        }
    }
    cout << ans;
}


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

int main()
{
	int A, B;
	char S[40];
	char T[40];
	char U[40];
	
	scanf("%s %s", &S, &T);
	scanf("%d %d", &A, &B);
	scanf("%s", &U);
	
	if(strcmp(S, U)==0)
{
	A--;
	printf("%d %d", A, B);
}
	else
{
	B--;
	printf("%d %d", A, B);
}
	return 0;
}

Measured memory_bytes: 3192
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <map>
#define ull unsigned long long
#define ll long long
using namespace std;

int v_find(vector<int> a, int num){
    auto x = find(a.begin(),a.end(),num);
    size_t index = distance(a.begin(),x);
    if(index != a.size()){return 1;}
    else{return 0;}
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m,d,t;
    vector<int> d_1,t_1;
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> d;
        d_1.push_back(d);
    }
    cin >> m;
    for(int i=0;i<m;i++){
        cin >> t;
        t_1.push_back(t);
    }
    map<int,int> w,e;
    for(int i=0;i<n;i++){
        w[d_1[i]]++;
    }
    for(int i=0;i<m;i++){
        e[t_1[i]]++;
    }
    int cmp;
    for(int i=0;i<m;i++){
        cmp=t_1[i];
        if(w[cmp]<e[cmp]){
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;

    return 0;
}


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



#define SIZE 200005
typedef pair<int,int> P;

enum Type{
	ROAD,
	TRAIN,
};

struct Info{

	int from,to;
};

int N,K,L;
int boss[2][SIZE],height[2][SIZE];
map<P,int> MAP;
Info info[100005];


int get_boss(int id,Type type){
	if(boss[type][id] == id)return id;
	else{
		return boss[type][id] = get_boss(boss[type][id],type);
	}
}

int isSame(int x,int y,Type type){
	return get_boss(x,type) == get_boss(y,type);
}

void unite(int x,int y,Type type){
	int boss_x = get_boss(x,type);
	int boss_y = get_boss(y,type);

	//既に同じグループなら何もしない
	if(boss_x == boss_y)return;

	//高さが高い方に吸収する
	if(height[type][boss_x] > height[type][boss_y]){

		boss[type][boss_y] = boss_x;


	}else if(height[type][boss_x] < height[type][boss_y]){

		boss[type][boss_x] = boss_y;

	}else{

		boss[type][boss_y] = boss_x;
		height[type][x]++;
	}
}

int main(){

	scanf("%d %d %d",&N,&K,&L);

	for(int i = 0; i < 2; i++){
		for(int k = 0; k < N; k++){
			boss[i][k] = k;
			height[i][k] = 0;
		}
	}

	//道路
	for(int i = 0; i < K; i++){

		scanf("%d %d",&info[i].from,&info[i].to);
		info[i].from--;
		info[i].to--;

		unite(info[i].from,info[i].to,ROAD);
	}

	int from,to;

	for(int loop = 0; loop < L; loop++){

		scanf("%d %d",&from,&to);
		from--;
		to--;

		unite(from,to,TRAIN);
	}

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

		MAP[make_pair(get_boss(i,ROAD),get_boss(i,TRAIN))]++;
	}

	printf("%d",MAP[make_pair(boss[ROAD][0],boss[TRAIN][0])]);
	for(int i = 1; i < N; i++){

		printf(" %d",MAP[make_pair(boss[ROAD][i],boss[TRAIN][i])]);
	}
	printf("\n");

	return 0;
}


Measured memory_bytes: 15872
#include <iostream>
#include <string>

using namespace std;

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

	string s, t;

	cin >> s >> t;

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

	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<map>
#include<queue>
#include<iostream>
#include<algorithm>
#define m(a,b) memset(a,b,sizeof(a));
using namespace std;
const int inf = 1 << 30;
const int maxn = 1e5;
typedef long long LL;
int main(){
	int n,t;
	cin >> n >> t;
	LL ans = t;
	int num,pos = 0;
	for(int i = 0;i<n;i++){
		cin >> num;
		if(num - pos< t) ans-=pos,ans += num;
		else ans += t;
		pos = num;
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

int main(){
  long long i,n,minv=LONG_LONG_MAX; 
  
  cin>>n;
  
  for(i=1;i*i<=n;i++)
    if(n%i==0 && i+n/i<minv)
       minv=i+n/i;
  
  cout<<minv-2;
  
  return 0;
  }

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
	int n, x;
	int l[101];

	cin >> n >> x;
	for (int i = 0; i < n; i++) cin >> l[i];

	int p = 0;
	int j = 0;

	for (j; j < n; j++)
	{
		p += l[j];
		if (p > x) break;
	}

	cout << j + 1 << endl;

	return 0;
}

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

int main() {
	string s, ans="";
	cin >> s;
	for(int i=0; i<s.size(); ++i){
		if(s[i]=='B'){
			if(ans.size()>0) ans.pop_back();
		}
		else ans += s[i];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;

const int MAXN = 200010;
int dp[MAXN + 10];
signed main() {
    int N; cin >> N;
    vector<int> last(MAXN + 10, -1);
    vector<int> past(MAXN + 10,  0);

    dp[0] = 1;
    for(int i=0; i<N; i++) {
        int c; cin >> c;
        c--;

        dp[i+1] = dp[i];
        {
            int val = past[c];
            if(!(last[c] >= 0 and i - last[c] <= 1)) {
                (dp[i+1] += val) %= MOD;
            }
        }
        if(last[c] < 0 or i - last[c] > 1) (past[c] += dp[i]) %= MOD;
        last[c] = i;

        // fprintf(stderr, "dp[%lld] = %lld\n", i+1, dp[i+1]);
    }
    cout << dp[N] << endl;
    return 0;
}


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

int main()
{
	int n; bool flag=false;
	cin >> n;
	for(int i=0; i<3; i++)
	{
		if(n%10==7)
		{
			cout << "Yes";
			flag = true; 
			break;
		}
		n=n/10;
	}
	if(flag == false)
	cout << "No";
	return 0;
}


Measured memory_bytes: 3596
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n,m = map(int, input().split())

lx = [None] * n
ly = [None] * m
sx = set([-10**10, 0, 10**10])
sy = set([-10**10, 0, 10**10])
ix = 0
iy = 0
for i in range(n):
    t = tuple(map(int, input().split()))
    lx[i] = t
    sx.add(t[0])
    sx.add(t[1])
    sy.add(t[2])
        
for i in range(m):
    t = tuple(map(int, input().split()))
    ly[i] = t
    sx.add(t[0])
    sy.add(t[1])
    sy.add(t[2])
        
xs = list(sx)
ys = list(sy)
xs.sort(); ys.sort()

wx = len(xs)*2
wy = len(ys)*2
bs = [[1]*wy for _ in range(wx)]
for i, (x0, x1, y) in enumerate(lx):
    ix0 = xs.index(x0)*2
    ix1 = xs.index(x1)*2
    iy = ys.index(y)*2
    for ii in range(ix0+1, ix1, 2):
        bs[ii][iy] = -1
for i, (x, y0, y1) in enumerate(ly):
    ix = xs.index(x)*2
    iy0 = ys.index(y0)*2
    iy1 = ys.index(y1)*2
    for ii in range(iy0+1, iy1, 2):
        bs[ix][ii] = -1

xx = xs.index(0)*2+1
yy = ys.index(0)*2+1
s = [(xx,yy)]
dx = [-1,0,1,0]
dy = [0,-1,0,1]
ans = 0
end = False
while s:
    ix,iy = s.pop()
    for x, y in zip(dx,dy):
        ixx = ix + x
        iyy = iy + y
        if bs[ixx][iyy]!=1:
            continue
        ixx += x
        iyy += y
        if bs[ixx][iyy]!=1:
            continue
        if ixx<0 or ixx>=wx-1 or iyy<0 or iyy>=wy-1:
            print("INF")
            s = []
            end = True
            break
        bs[ixx][iyy] = 2
        ans += (xs[ixx//2+1] - xs[ixx//2]) * (ys[iyy//2+1] - ys[iyy//2])
        s.append((ixx, iyy))
            
if not end:
    print(ans)


Measured memory_bytes: 639876
/* 163a.c */
#include <stdio.h>
#include <math.h>

int main(void){
    double r,s,l=0;
    scanf("%lf",&r);
    s = M_PI * r * r;
    l = 2 * M_PI * r;
    printf("%lf",l);
    return 0;
}

Measured memory_bytes: 1752
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, W;
	cin >> N >> W;
	vector<int> w(N), v(N); rep(i, 0, N) {
		cin >> w[i] >> v[i];
	}

	vector<int> a[4];

	rep(i, 0, N) {
		a[w[i] - w[0]].push_back(v[i]);
	}
	rep(i, 0, 4)sort(all(a[i]), greater<int>());

	vector<int> b[4];
	rep(i, 0, 4) {
		b[i].push_back(0);
		rep(j, 0, a[i].size()) {
			b[i].push_back(b[i].back() + a[i][j]);
		}
	}
	dump(b);
	int ans = 0;
	rep(i, 0, b[0].size())rep(j, 0, b[1].size())rep(k, 0, b[2].size())rep(l, 0, b[3].size()) {
		int tw = w[0] * (i + j + k + l) + j * 1 + k * 2 + l * 3;
		if (tw > W)continue;
		chmax(ans, b[0][i] + b[1][j] + b[2][k] + b[3][l]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
	int N, A[200],ans=0;
	cin >> N;
	for (int i = 0; i < N; i++)
		cin >> A[i];
	for (int cont = 1; cont;ans++)
	{
		for (int j = 0; j < N; j++)
		{
			if (A[j] & 1)
			{
				cont = 0;
				ans--;
				break;
			}
			else
				A[j] >>= 1;
			
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
var
  a,b:array[0..1000]of longint;
  n,m,i,j,max,min,x,y:longint;
begin
   readln(n,m,x,y);
   max:=x;min:=y;
   for i:=1 to n do
     begin
       read(a[i]);
       if a[i]>max then max:=a[i];
     end;
   readln;
   for i:=1 to m do
     begin
       read(b[i]);
       if b[i]<min then min:=b[i];
     end;

   if min<=max then write('War') else write('No War');
end.


Measured memory_bytes: 128
package main

import (
	"bufio"
	"fmt"
	"log"
	"os"
	"strconv"
)

func main() {
	log.SetFlags(log.Lshortfile)
	a := nextInt()
	b := nextInt()
	c := nextInt()
	fmt.Println(max(10*a+b+c, a+10*b+c, a+b+10*c))
}
func max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}
func min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}
func sum(a []int) (r int) {
	for i := range a {
		r += a[i]
	}
	return r
}
func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

type Pair struct {
	a, b int
}

type Pairs []Pair

func (p Pairs) Len() int {
	return len(p)
}
func (p Pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p Pairs) Less(i, j int) bool {
	return p[i].b < p[i].b
}

var nextReader func() string

func init() {
	nextReader = NewScanner()
}

func NewScanner() func() string {
	r := bufio.NewScanner(os.Stdin)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)
	return func() string {
		r.Scan()
		return r.Text()
	}
}
func nextString() string {
	return nextReader()
}
func nextInt64() int64 {
	v, _ := strconv.ParseInt(nextReader(), 10, 64)
	return v
}
func nextInt() int {
	v, _ := strconv.Atoi(nextReader())
	return v
}
func nextInts(n int) []int {
	r := make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}
func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(nextReader(), 64)
	return f
}


Measured memory_bytes: 640
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <numeric>
#include <functional>
#include <sstream>
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define VVVI vector<vector<vector<ll>>>
#define VVVVI vector<vector<vector<vector<ll>>>>
#define REP(i,n) for(ll i=0,_n=(n);(i)<(ll)_n;++i)
#define REPR(i,n) for(ll i=(ll)(n)-1;0<=(i);--i)
#define RANGE(i,a,b) for(ll i=(ll)a,_b=(ll)(b);(i)<_b;++i)
#define RANGER(i,a,b) for(ll i=(ll)(b)-1,_a=(ll)(a);(_a)<=i;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
#define FI first
#define SE second
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template<typename T>void maxUpdate(T& a, T b) {a = max(a, b);}
template<typename T>void minUpdate(T& a, T b) {a = min(a, b);}
string YN(bool v) { return v ? "Yes":"No"; }

#define INF (1LL<<60)
/*
1->5 -4
1->10 -9
5->10 -1
*/
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N,Y;
	while(cin>>N>>Y) {
		Y/=1000;
		ll done=0;
		REP(t, Y/10+1) REP(f, Y/5+1) if(!done){
			ll o=Y-(t*10+f*5);
//			DD(t);DD(f);DD(o);
			if(0<=o && t+f+o==N) {
				cout<<t<<" "<<f<<" "<<o<<endl;
				done=1;
			}
		}
		if(!done) cout<<"-1 -1 -1"<<endl;
	}
	
	return 0;
}


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

int main(void)
{
    unsigned long H;
    int flag = 1;
    unsigned long waru = 1;
    unsigned long hukasa = 0;
    unsigned long cnt = 0;

    scanf("%lu", &H);

    if (H == 1) {
        printf("1");
    }else {
        while(H > 1) {
            H = H / 2;
            cnt += pow(2, hukasa);
            hukasa++;
            if (H == 1) {
                flag = 0;
            }
        }
        cnt += pow(2, hukasa);
        printf("%lu", cnt);
    }

    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main(){
  int num[3];
  scanf("%d %d %d",&num[0],&num[1],&num[2]);
  int ans = 0;

  int max,mid,min;
  while(1){

    if(num[0] == num[1] && num[1] == num[2]){
      break;
    }

    if(num[0] < num[1]){
      max = 1;
      min = 0;
    }else{
      max = 0;
      min = 1;
    }
    if(num[max] < num[2]){
      mid = max;
      max = 2;
    }else if(num[min] > num[2]){
      mid = min;
      min = 2;
    }else{
      mid = 2;
    }

    if(num[max] - num[min] > 1){
      num[min] += 2;
    }else{
      num[min]++;
      num[mid]++;
    }
    ans++;
  }
  printf("%d\n",ans);
  return(0);
}

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

using namespace std;

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

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

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

int merge(VI& a, int s1, int s2, int t){
  int i, j, res = 0;
  VI tmp;
  for(i=s1,j=s2;i<s2&&j<t;){
	if(a[i] > a[j]){
	  tmp.PB(a[j++]);
	  res += s2-s1-(i-s1);
	}
	else{
	  tmp.PB(a[i++]);
	}
  }
  while(i<s2) tmp.PB(a[i++]);
  while(j<t) tmp.PB(a[j++]);

  for(i=s1;i<t;++i)
	a[i] = tmp[i-s1];
  return res;
}

int sort(VI& a, int s, int t){
  if(s+1 >= t) return 0;
  int m = (s + t) / 2, res = 0;
  res += sort(a, s, m);
  res += sort(a, m, t);
  res += merge(a, s, m, t);
  return res;
}


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

  int N; cin >> N;
  VI a(N); REP(i,N) cin >> a[i];
  int ans = sort(a, 0, N);

  cout << a[0];
  REP(i,N-1) cout << " " << a[i+1];
  cout << endl;

  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 1220
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
a = LI()
cnt = 0
for i in range(n):
    if a[i] < 0:
        cnt += 1

if cnt % 2:
    m = inf
    ans = 0
    for i in range(n):
        m = min(m, abs(a[i]))
        ans += abs(a[i])
    ans -= 2*m
    print(ans)
else:
    ans = 0
    for i in range(n):
        ans += abs(a[i])
    print(ans)

Measured memory_bytes: 87956
#include<bits/stdc++.h>
#define ll long long
#define MOD int(1e8)
#define mp make_pair
#define pb push_back
using namespace std;

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

    double h,w,n;
    cin>>h>>w>>n;

    if(w>h) swap(w,h);

    cout<<ceil(n/h);

    return 0;
}


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


template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const long long INF = 1LL<<60;

int N;
long long W, weight[110],value[110];

long long dp[110][100100]={};

int main() {
    cin>>N>>W;
    for(long long i=0; i<W; i++){
        cin>>weight[i]>>value[i];
    }

for(long long i=0; i<N; i++){
    for(long long wsum=0; wsum<=W; wsum++){
    if(wsum>=weight[i]) chmax(dp[i+1][wsum],dp[i][wsum-weight[i]]+value[i]);
     chmax(dp[i+1][wsum],dp[i][wsum]);
    }
}
    
cout<<dp[N][W]<<endl;
}


Measured memory_bytes: 79360
#include <bits/stdc++.h> 
using namespace std;
#define pb push_back
#define ll long long int
#define vi vector<int>
#define ii pair<int,int>
#define vli vector<ll>
#define graph vector<vector< int > >
#define vpi vector<pair<int ,int> >
#define vpli vector<pair<ll ,ll> >
#define mp make_pair
#define F first
#define S second
#define mod 163577857
#define INF (ll)1e10
#define wh(a) cout<<#a<<"  is  "<<a<<endl;
#define MIN(a,b) ((a) < (b) ? (a) : (b))
#define MAX(a,b) ((a) > (b) ? (a) : (b))
#define INI(a) memset(a,0,sizeof(a))
#define LIMIT 8008

void solve(){
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    if(k<=a){
        cout<<k;
        return;
    }
    if(k<=a+b){
        cout<<a;
        return;
    }
    k=k-a-b;
    cout<<a-k;
}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // #endif
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3652
import sys

if __name__ == "__main__":
    lines = sys.stdin.readlines()

    # Create n * n matrix
    dimension = int(lines[0])
    matrix = []
    for x in range(dimension):
        matrix.append([0] * dimension)

    # Set edge info
    for index, line in enumerate(lines[1:]):
        for edge in [int(x) for x in line.strip().split(" ")[2:]]:
            matrix[index][edge - 1] = 1

    # Print matrix
    for row in matrix:
        print(" ".join([str(x) for x in row]))

Measured memory_bytes: 7688
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<map>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<vector>
#include<algorithm>
#include<iostream>
#include<stack>
using namespace std;

#define GG {puts("No"); return 0;}
const int N=300010;
int n;
int a[N],b[N];
inline bool Check(int l,int r) {
    int lbd=0,rbd=0;
    for(int i=l;i<=r;i++) {
        if(b[i]<i) {
            // printf("%d\n",i);
            if(lbd>b[i] || (b[i]<l || b[i]>r)) return false;
            lbd=b[i];
        } else if(b[i]>i) {
            if(rbd>b[i] || (b[i]<l || b[i]>r)) return false;
            rbd=b[i];
        }
    }
    return true;
}
signed main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&b[i]);a[i]=(b[i]==i);
        if( (b[i]-i)%2 ) GG
    }

    for(int i=2;i<n;i++) if(!a[i-1] && !a[i] && !a[i+1]) GG
    for(int i=1;i<=n;i++) {
        if(a[i]==0) {
            int now=1;
            int l=i,r=i;
            while((a[r]^now) && r<=n) ++r,now^=1;
            --r;
            if(!Check(l,r)) GG
            i=r;
        }
    }
    puts("Yes");
    return 0;
}


Measured memory_bytes: 2560
using System;
using System.Collections.Generic;
using System.Linq;

namespace ABC126
{
    class Dist
    {
        public long nextvertex { get; set; }
        public long distance { get; set; }

        public Dist(long v, long d)
        {
            nextvertex = v;
            distance = d;
        }
    }

    class D
    {
        static long[] Res;
        static List<Dist>[] list;

        static void Main(string[] args)
        {
            long N = long.Parse(Console.ReadLine());
            Res = new long[N];
            list = new List<Dist>[N];

            long[] input;
            long u = 0;
            long v = 0;
            long w = 0;
            for (long i = 0; i < N - 1; i++)
            {
                input = Console.ReadLine().Split().Select(long.Parse).ToArray();
                u = input[0] - 1;
                v = input[1] - 1;
                if (input[2] % 2 == 0) w = 0;
                else if (input[2] % 2 == 1) w = 1;

                if (list[u] == null) list[u] = new List<Dist>();
                if (list[v] == null) list[v] = new List<Dist>();
                list[u].Add(new Dist(v, w));
                list[v].Add(new Dist(u, w));
            }

            DFS(0, 0, 0, 0);

            foreach (var item in Res)
            {
                Console.WriteLine(item);
            }
        }

        static void DFS(long now, long previous, long sumdist, long w)
        {
            sumdist += w;
            if (sumdist % 2 == 0) Res[now] = 0;
            if (sumdist % 2 == 1) Res[now] = 1;

            foreach (var item in list[now])
            {
                if (item.nextvertex != previous) DFS(item.nextvertex, now, sumdist, item.distance);
            }
        }
    }
}

Measured memory_bytes: 39332
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
typedef long long ll;

using ipair = pair<int, int>;

ll INF = 1e16+7;
ll mod = 1e9+7;

bool operator>(const ipair a,const ipair b){return a.first > b.first;}


const double PI=3.14159265358979323846;

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

  ll div = (ll)(sqrt(N)+1);

  ll found = -1LL;

  while(1){
    if(div == 1){
      found = 1LL;
      break;
    }
    if(N%div==0){
      found = div;
      break;
    }

    div--;
  }

  ll compliment = N / found;

  cout << (found-1) + (compliment-1) << endl;
  return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
#define _ ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);

#define sll(x) scanf("%I64d",&x)
#define sd(x)  scanf("%d",&x)
#define pll(x) printf("%I64d",x)
#define pd(x)  printf("%d",x)

#define clr(x) memset(x,0,sizeof x)
#define sf .second.first
#define ss .second.second
#define mid    ((l+r)>>1)
#define Pi acos(-1)
#define EPS 1e-12
#define MOD  1000000007
#define MOD1 1000000009
#define INF  1000000000

#define N 100005

int n,a[N],dp[N];


int main() {

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

    dp[0]=0;
    dp[1]=abs(a[0]-a[1]);
    for(int i=2;i<n;i++){
        int r1,r2;
        r1=abs(a[i-1]-a[i])+dp[i-1];
        r2=abs(a[i-2]-a[i])+dp[i-2];
        dp[i]=min(r1,r2);
    }


    cout<<dp[n-1]<<endl;
    return 0;
}


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

using namespace std;

typedef long long ll;

const int MOD = 1e9 + 7;

int N; ll K;

ll add(ll a, ll b) {
	ll res = a + b;
	if (res >= MOD) {
		return res - MOD;
	}
	return res;
}

ll mult(ll a, ll b) {
	ll res = a;
	res *= b;
	if(res >= MOD) {
		return res % MOD;
	}
	return res;
}

struct Matrix {
	ll mat[50][50];

	void reset() {
		memset(mat, 0, sizeof mat);
	}

	void makeIdentity() {
		reset();
		for (int i = 0; i < N; i++) {
			mat[i][i] = 1;
		}
	}

	Matrix operator + (const Matrix &o) const {
		Matrix res;
		for(int i = 0; i < N; i++) {
			for(int j = 0; j < N; j++) {
				res.mat[i][j] = add(mat[i][j], o.mat[i][j]);
			}
		}
		return res;
	}

	Matrix operator * (const Matrix &o) const {
		Matrix res;
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < N; j++) {
				res.mat[i][j] = 0;
				for (int k = 0; k < N; k++) {
					res.mat[i][j] = add(res.mat[i][j], mult(mat[i][k], o.mat[k][j]));
				}
			}
		}
		return res;
	}
};

Matrix bigMod(Matrix a, ll p) {
	Matrix res;
	res.makeIdentity();
	while (p) {
		if (p & 1) {
			res = res * a;
		}
		a = a * a;
		p >>= 1;
	}
	return res;
}

int main() {
  scanf("%d %lld", &N, &K);
  Matrix a;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      scanf("%d", &a.mat[i][j]);
    }
  }
  Matrix b = bigMod(a, K);
  ll ans = 0;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      //cout << b.mat[i][j] << " ";
      ans += b.mat[i][j];
    }
    //cout << '\n';
  }
  printf("%d\n", ans % MOD);
  return 0;
}



Measured memory_bytes: 384
/*http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_2_B&lang=jp*/
#include<iostream>

using namespace std;

void println(int *a,int n){
    for(int i=0;i<n;i++){
        cout<<a[i];
        if(i<n-1){
            cout<<" ";
        }
    }
    cout<<endl;
}

int main()
{
    int n;
    int a[100];
    int minj;
    int count=0;

    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=0;i<n;i++){
        minj=i;
        for(int j=i;j<n;j++){
            if(a[j]<a[minj]){
                minj=j;
            }
        }
        if(i!=minj) {
            swap(a[i], a[minj]);
            count++;
        }
    }
    println(a,n);
    cout<<count<<endl;
    return 0;
}

Measured memory_bytes: 1160
A = [[[0 for x in range(10)] for x in range(3)]for x in range(4)] 
n = int(input())
for k in range(n):
  b, f, r, v = map(int, raw_input().split())
  A[b-1][f-1][r-1] += v
 
for b in range(4):
  for f in range(3):
    print(" "+" ".join(map(str, A[b][f])))
  if b != 3:
    print("#"*20)

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

using namespace std;
using namespace std::chrono;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi; 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)    
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define print(x) cout << x << "\n";
#define REP(i,a,b) for(i=a;i<=b;i++)
#define RAP(i,a,b) for(i=a;i>=b;i--)
#define spa <<" "<<
#define all(x) (x).begin(), (x).end()
ll mod=1000000007;
const int MX=0x3f3f3f3f;

int n,m,x,tt;
int a[12][13],b[12];

int func(int t,int i){
    int flag=0,j;
    REP(j,0,m-1) 
        if(b[j]<x){
            flag=1;
            break;
        }
    if(!flag) return t;
    if(i==n) return MX;

    t+=a[i][0];
    REP(j,0,m-1) b[j]+=a[i][j+1];
    int temp1=func(t,i+1);
    REP(j,0,m-1) b[j]-=a[i][j+1];
    t-=a[i][0];
    int temp2=func(t,i+1);
    return min(temp1,temp2);
}

int main(){
    IOS;
    cin>>n>>m>>x;
    int i,j;
    REP(i,0,n-1){
        REP(j,0,m) cin>>a[i][j];
    }    
    int ans=func(0,0);
    if(ans==MX) cout<<-1;
    else cout<<ans;
	return 0;
} 

Measured memory_bytes: 3640
import java.util.*;
 //AtCoder problemsに反映されないため再提出
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int NN = N;
		int fx = 0;
		while (N > 0) {
			fx += N % 10;
			N /= 10;
		}
		System.out.println(NN % fx == 0 ? "Yes" : "No");
	}
}

Measured memory_bytes: 21844
from collections import Counter
n, m = map(int, input().split())
a = list(map(int, input().split()))
d = Counter(a)

for i in range(m):
    b, c = map(int, input().split())
    d[c] += b
key = list(d.keys())
key.sort(reverse = True)

ans = 0
for k in key:
    if n <= d[k]:
        ans += k*n
        break
    else:
        ans += k*d[k]
        n -= d[k]

print(ans)

Measured memory_bytes: 108876
// C++(GCC 9.2.1)
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
#define repex(i, a, b, c) for(int i = a; i < b; i += c)
#define repx(i, a, b) repex(i, a, b, 1)
#define rep(i, n) repx(i, 0, n)
#define repr(i, a, b) for(int i = a; i >= b; i--)
LL a[202020];

int main(){
    
    // 1. 入力情報.
    int N;
    // handmade13, handmade14 で, WAのため, ロジック修正(l = 1 でなく, l = 0 に修正).
    LL K, l = 0, h = 0, m;
    scanf("%d %lld", &N, &K);
    rep(i, N){
        scanf("%lld", &a[i]);
        h = max(h, a[i]);
    }
    
    // 2. 丸太の分割.
    auto f = [](LL aMax, LL k, int n) -> bool {
        // ex.
        // 18 を 2回分割すると, 長さ 6 の 丸太 が 3つ.
        // -> 18 ÷ (長さ 6) = 3 だが, 分割回数は, 2回 なので 注意.
        LL ok = 0;
        rep(i, n){
            ok += a[i] / aMax;
            if(a[i] % aMax == 0) ok--;
        }
        return (ok <= k);
    };
    // 二分探索で確認してみる.
    while(l + 1 < h){
        m = (h + l) >> 1;
        if(f(m, K, N)) h = m;
        else           l = m;
        // printf("h=%lld l=%lld m=%lld\n", h, l, m);
    }
    
    // 3. 出力.
    printf("%lld\n", h);
    return 0;
    
}

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


int main(){

  int af=0, bf=0, cf=0;
  string SA, SB, SC;
  cin >> SA >> SB >> SC;
  int la=SA.size(), lb=SB.size(), lc=SC.size();
  
  int  ix=af;
  char h ='a';
  
  while(true){
    
    if(h=='a'){
      if(af==la){
        cout<<'A'<<endl;
        return 0;
      }      
      h=SA[af];
      af++;
    }else if(h=='b'){
      if(bf==lb){
        cout<<'B'<<endl;
        return 0;
      }      
      h=SB[bf];
      bf++;      
    }else{
      if(cf==lc){
        cout<<'C'<<endl;
        return 0;
      }      
      h=SC[cf];
      cf++;      
    }
  }
  return 0;
}

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

int main(int argc, char const *argv[])
{
	string s; cin >> s;
	int cnt = 0;
	for (auto u : s) {
		cnt += (u == '+') ? 1 : -1;
	}
	printf("%d\n", cnt);
	return 0;
}

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

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int

int main(){
ll a,b;
cin>>a>>b;
int k;
cin>>k;
map<int,int> m;
for(int i=a;i<min(a+k,b+1);i++){
cout<<i<<endl;
m[i]++;
}
if(min(a+k,b)==a+k){
for(int i=b-k+1;i<=b;i++){
if(m[i]==0)
cout<<i<<endl;
}
}


  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
    int n,c,i,m;
    char b;
    scanf("%d",&n);
    int a[4][13]={0};
    for(i=0;i<n*2;i++){
        scanf("%c %d",&b,&c);
        switch(b){
            case 'S':
            a[0][c-1] =c;
            break;
            case 'H':
            a[1][c-1] =c;
            break;
            case 'C':
            a[2][c-1] =c;
            break;
            case 'D':
            a[3][c-1] =c;
            break;
        }
    }
    for(i=0;i<4;i++){
        for(m=0;m<13;m++){
            if(a[i][m]==0){
                switch(i){
                    case 0:
                    printf("S %d\n",m+1);
                    break;
                    case 1:
                    printf("H %d\n",m+1);
                    break;
                    case 2:
                    printf("C %d\n",m+1);
                    break;
                    case 3:
                    printf("D %d\n",m+1);
                    break;
                }
            }
        }
    }
    return 0;
}


Measured memory_bytes: 2060
import java.util.*;

class Main {
        public static void main(String args[]) {
                new Thread(null, () -> {
                        try(Scanner sc = new Scanner(System.in)){
                                boolean[] prime = new boolean[100000005];
                                prime[0] = true; prime[1] = true;
                                for (int i = 2; i <= Math.sqrt(100000005); i++) {
                                        if (!prime[i]) {
                                                int j = 2;
                                                while (i * j < 100000005) {
                                                        prime[i*j] = true;
                                                        j++;
                                                }
                                        }
                                }
                                int N = sc.nextInt();
                                int ans = 0;
                                for (int i = 0; i < N; i++) {
                                        if (!prime[sc.nextInt()]) {
                                                ans++;
                                        }
                                }
                                System.out.println(ans);
                        }
                }, "", 1<<24).start();
        }
}

Measured memory_bytes: 143888
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

// 与えられた位置に最寄りのスポットを探索：O(log(Size))
const vector<LLONG> FindNearestSpots(const vector<LLONG> &v, const LLONG p)
{
    auto itr = lower_bound(v.begin(), v.end(), p); // O(log(N))
    if (itr == v.begin()) return { v.front() };
    else if (itr == v.end()) return{ v.back() };
    int index = static_cast<int>(distance(v.begin(), itr));
    return{ v[index - 1], v[index] };
}

int main()
{
    int A, B, Q; cin >> A >> B >> Q;
    vector<LLONG> ss(A), ts(B), xs(Q);
    for (auto &si : ss) cin >> si;
    for (auto &ti : ts) cin >> ti;
    for (auto &xi : xs) cin >> xi;
    for (const LLONG xi : xs)
    {
        LLONG ans = 10e11;
        for (const LLONG si : FindNearestSpots(ss, xi))
        {
            for (const LLONG ti : FindNearestSpots(ts, xi))
            {
                ans = min(ans, abs(si - xi) + abs(ti - si));    // xi -> si -> ti
                ans = min(ans, abs(ti - xi) + abs(si - ti));    // xi -> ti -> si
            }
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 3712
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];
        int[] b = new int[n];
        for(int i=0; i<n; i++) {
            a[i] = sc.nextInt();
        }
        int gcd = a[0];
        for(int i=1; i<n; i++) {
            gcd = gcd(gcd, a[i]);
        }
        boolean setwise = gcd == 1;

        if(!setwise) {
            System.out.println("not coprime");
            return;
        }

        int[] div = new int[1000001];
        for(int i=1; i<=1000000; i++) {
            div[i] = i;
        }
        for(int i=2; i<=1000; i++) {
            if(div[i] != i) continue;
            for(int j=2; i*j<=1000000; j++) {
                div[i*j] = i;
            }
        }

        boolean pc = true;

        boolean[] used = new boolean[1000001];
        OUTER: for(int i=0; i<n; i++) {
            while(a[i] > 1) {
                int d = div[a[i]];
                if(used[d]) {
                    pc = false;
                    break OUTER;
                }
                while(a[i] % d == 0) {
                    a[i] /= d;
                }
                used[d] = true;
            }
        }


        if(pc) {
            System.out.println("pairwise coprime");
        } else {
            System.out.println("setwise coprime");

        }


    }
    static int gcd(int m, int n) {
        if(m < n) return gcd(n, m);
        if(n == 0) return m;
        return gcd(n, m % n);
    }

}

Measured memory_bytes: 68776
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define endl "\n"
#define ll long long
#define sz(s) (int)(s.size())
#define INF 0x3f3f3f3f3f3f3f3fLL
#define all(v) v.begin(),v.end()
#define watch(x) cout<<(#x)<<" = "<<x<<endl
const int dr[] { -1, -1, 0, 1, 1, 1, 0, -1 };
const int dc[] { 0, 1, 1, 1, 0, -1, -1, -1 };
#if __cplusplus >= 201402L
template<typename T>
vector<T> create(size_t n) {
	return vector<T>(n);
}
template<typename T, typename ... Args>
auto create(size_t n, Args ... args) {
	return vector<decltype(create<T>(args...))>(n, create<T>(args...));
}
#endif
void run() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifdef EZZAT
	freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
#else
#endif
}

int main() {
	run();
	int n, m, x;
	cin >> n >> m >> x;
	vector<int> c(n);
	vector<vector<int>> v = create<int>(n, m);
	for (int i = 0; i < n; i++) {
		cin >> c[i];
		for (int j = 0; j < m; j++)
			cin >> v[i][j];
	}
	int sum = -1;
	for (int i = 1; i < (1 << n); i++) {
		int sumSoFar = 0;
		vector<int> tmp(m);
		for (int j = 0; j < n; j++)
			if (i & (1 << j)) {
				sumSoFar += c[j];
				for (int k = 0; k < m; k++)
					tmp[k] += v[j][k];
			}
		bool valid = true;
		for (auto &it : tmp)
			valid &= (it >= x);
		if (valid) {
			if (~sum)
				sum = min(sum, sumSoFar);
			else
				sum = sumSoFar;
		}
	}
	cout << sum << endl;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
const int mod = (int)1e9 + 7;
string s;
int cnt[30];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    //freopen("input.txt", "r", stdin);
    int n;
    cin >> n;
    cin >> s;
    for (int i = 0; i < s.size(); i++) {
        cnt[s[i] - 'a']++;
    }
    int ans = 1;
    for (int i = 0; i < 26; i++) {
        ans = 1LL * ans * (cnt[i] + 1) % mod;
    }
    cout << (ans + mod - 1) % mod;
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
#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 ALL(v) (v).begin(), (v).end()
#define PUTS(x) cout << (x) << endl;
#define SZ(x) ((int)(x).size())
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MOD 1000000007
vector<Int> IntsIn(int n) {
    auto v = vector<Int>(0);
    for (int i = 0; i < n; i++) {
        Int a;
        cin >> a;
        v.push_back(a);
    }
    return v;
}

Int gcd(Int a, Int b) {
    Int M = max(a, b);
    Int m = min(a, b);
    while (true) {
        Int r = M % m;
        if (r == 0) break;
        M = m;
        m = r;
    }
    return m;
}

int main() {
    Int k;
    cin >> k;
    Int s = 0;
    reps(a, k) {
        reps(b, k) {
            reps(c, k) {
                s += gcd(gcd(a, b), c);
            }
        }
    }
    PUTS(s)
}


Measured memory_bytes: 3632