akhauriyash/Code-Regression huggingface dataset:
#define _DEBUG 1
#define _GLIBCXX_DEBUG

#include <bits/stdc++.h>
using namespace std;

using ll = long long;

#ifdef _DEBUG
#define dump(x) cerr << #x << "=" << x << endl
#define dump2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define dump3(x, y, z)                                                         \
  cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z     \
       << endl
#define check(s) cerr << s << endl
#else
#define dump(x)
#define dump2(x, y)
#define dump3(x, y, z)
#define check(s)
#endif

#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define unique(v) v.erase(unique(v.begin(), v.end()), v.end());

void solve(ll N) {
  ll l0 = 2;
  ll l1 = 1;
  ll r;
  if (N == 1) {
    r = N;
  } else {
    ll lb1 = l0;
    ll lb2 = l1;
    for (int i = 2; i <= N; i++) {
      r = lb1 + lb2;
      lb1 = lb2;
      lb2 = r;
    }
  }

  cout << r << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You
// use the default template now. You can remove this line by using your custom
// template)
int main() {
  ll N;
  scanf("%lld", &N);
  solve(N);
  return 0;
}


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

int h,w,n;
int Grid[1000][1000];
vector<int>v;
	
int main()
{
	cin>>h>>w>>n;
	int x;
	for(int i=0;i<n;i++)
	{
		cin>>x;
		for(int j=0;j<x;j++)
			v.push_back(i+1);
	}
	for(int i=0;i<h;i++)
	{
		if(i%2==0)
			for(int j=0;j<w;j++)
				Grid[i][j]=v[w*i+j];
		else
			for(int j=0;j<w;j++)
				Grid[i][w-1-j]=v[w*i+j];
	}
	for(int i=0;i<h;i++)
	{
		for(int j=0;j<w;j++)
			cout<<Grid[i][j]<<' ';
		cout<<endl;
	}
}


Measured memory_bytes: 768
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<set>
using namespace std;
const int maxn=200020;
char s[maxn];
char t[maxn];
set<int> ans[2][30];
int main()
{
	scanf("%s",s);
	scanf("%s",t);
	for(int i=0;s[i];i++){
        ans[0][s[i]-'a'].insert(t[i]-'a');
        ans[1][t[i]-'a'].insert(s[i]-'a');
    }
    for(int i=0;i<26;i++){
        if(ans[0][i].size()>1|| ans[1][i].size()>1)
            return puts("No"), 0;
    }

		puts("Yes");
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
long long aa;bool bb;char ch;
long long scan()
{
	while(ch=getchar(),(ch<'0'||ch>'9')&&ch!='-');
	ch=='-'?(bb=1,aa=0):(bb=0,aa=ch-48);
	while(ch=getchar(),(ch>='0'&&ch<='9'))
		aa=aa*10+ch-48;
	return (bb?(-aa):(aa));
}
int n,a[110],sum=0,mina=1000;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i)
	{
		scanf("%d",&a[i]);
		if(a[i]%10)
			if(a[i]<mina)
				mina=a[i];
		sum+=a[i];
	}
	if(mina==1000)
		mina=sum;
	if(sum%10)
		printf("%d\n",sum);
	else
		printf("%d\n",sum-mina);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using namespace std;
 
#define ll long long
#define f(i,a,b) for(ll i=a;i<b;i++)
#define endl '\n'
#define spc " "
#define pb push_back
#define mp make_pair
#define mod 1000000007

vector<vector<ll> >vii;

int main() 

{
    ios::sync_with_stdio(0);
    cin.tie(0);
    //freopen("in.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ll n,haa=0,k;
    cin>>n;
    while(n>0){
        k=n%10;
        n=n/10;
        if(k==7){
            haa=1;
            break;
        }
    }
    if(haa==1) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


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


using namespace std;

int H,W,A,B;

int main() {
	
	cin>>H>>W>>A>>B;
	
	int val = 0;
	
	for(int i=0; i<H;i++){
		if(i==B) val=1;
		for(int j=0; j<W;j++){
			if(j<A) cout<<val;
			else cout<<1-val;
		}
		cout<<"\n";
	}
	
	return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;typedef long long ll;typedef string str;
typedef vector<str> vst;typedef vector<ll> vll;
ll mod = 1000000007, INF = 10000000000000000;
ll gcd(ll a, ll b){if(b==0){return a;}return gcd(b, a%b);}
// for (ll i = 0; i < n; i++) {
// sort(.begin(), .end());
int main(){
  ll n, k;
  cin >> n >> k;
  vector<pair<ll, ll>> ab(n);
  for (ll i = 0; i < n; i++) {
    cin >> ab[i].first >> ab[i].second;
  }
  sort(ab.begin(), ab.end());
  vll bsum(n);
  bsum[0] = ab[0].second;
  for (ll i = 1; i < n; i++) {
    bsum[i] += bsum[i - 1] + ab[i].second;
  }
  
  ll ans;
  for (ll i = 0; i < n; i++) {
    if (bsum[i] >= k) {
      ans = ab[i].first;
      break;
    }
  }
  cout << ans << endl;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define INF 1000000000

void solve_abc112_d() {
	ll N, M, K;
	ll ans = 0;

	cin >> N >> M;

	K = M / N;

	while (1) {
		if (M % K == 0) {
			ans = K;
			break;
		}
		K--;
	}

	cout << ans << "\n";
}


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

	solve_abc112_d();

	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int D = in.nextInt();
		if(D == 25) {
			System.out.println("Christmas");
		}else if (D==24) {
			System.out.println("Christmas Eve");			
		}else if(D==23) {
			System.out.println("Christmas Eve Eve");						
		}else {
			System.out.println("Christmas Eve Eve Eve");									
		}
		in.close();
	}

}

Measured memory_bytes: 20684
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
  int N; cin>>N;
  vector<int> L(N);
  for(int i=0;i<N;i++){
    cin>>L[i];
  }

  sort(L.begin(),L.end());

  int Csum = 0;
  for(int i=0;i<N-1;i++){
    Csum += L[i];
  }

  if(Csum>L[N-1]){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}


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

int main(){
    int a[3];
    for (int i = 0; i < 3; i++) {
		cin >> a[i];
	}
    sort(a, a+3);

    cout << a[0] << " " << a[1] << " " << a[2] << endl;

    return 0;
}


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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define MOD 1000000007
typedef long long ll;
typedef unsigned long long ull;

int main() {
  int x, y, z;
  cin >> x >> y >> z;
  cout << z << " " << x << " " << y;
}

Measured memory_bytes: 256
N, K = map(int, input().split())

ab = [[0, 0]] * N
for i in range(N):
    _a, _b = map(int, input().split())
    ab[i] = [_a, _b]
ab.sort(key=lambda x:x[0])


total = 0
for pair in ab:
    total += pair[1]
    if total >= K:
        print(pair[0])
        break
    

Measured memory_bytes: 25484
#include <stdio.h>

int main()
{
	int i, N, l, r, sum = 0;
	scanf("%d", &N);
	for (i = 1; i <= N; i++) {
		scanf("%d %d", &l, &r);
		sum += r - l + 1;
	}
	printf("%d\n", sum);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 1704
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int N,A,B;
  cin >> N >> A >> B;
  if(((B-A)%2) == 1 )cout << "Borys" << endl;
  if(((B-A)%2) == 0 )cout << "Alice" << endl;
}

Measured memory_bytes: 3636
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<map>
#include<cstring>
#include<climits>
#include<queue>
using namespace std;
int A,B;
int main()
{
    scanf("%d%d",&A,&B);
    int k=B-A;
    printf("%d",(k+1)*k/2-B);
}


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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))
#define pb push_back
#define pf push_front
#define mod 1000000007
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK puts("OK")
#define OK1 puts("OK1")
#define OK2 puts("OK2")
#define SIZE(s) (int)s.size()
#define INF ((1LL<<62)-(1LL<<31))

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;
typedef vector<string> vs;
const double pi = acos(-1.0);

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << " ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

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;}

ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

struct UnionFind{
    vector<int> par;

    UnionFind(int n):par(n+1){
        for(int i=0;i<n+1;i++){
            par[i]=i;
        }
    }

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

    void unite(int x,int y){
        int rx=root(x);
        int ry=root(y);
        if(rx==ry) return;
        par[rx]=ry;
    }

    bool same(int x,int y){
        int rx=root(x);
        int ry=root(y);
        return rx==ry;
    }
};

int main()
{
	ll n,m,x,y,ans=0;
	cin >> n >> m;
	vll p(n);
	UnionFind tree(n);
	rep(i,n) cin >> p[i];
	rep(i,m){
		cin >> x >> y;
		tree.unite(x,y);
	}
	rep(i,n){
		if(tree.same(i+1,p[i])) ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1408
N, K, S = map(int,input().split())
ans = []


for i in range(K):
    ans.append(S)
if S == 10**9:
    for j in range(N-K):
        ans.append(7)
else:
    for j in range(N-K):
        ans.append(S+1)
print(' '.join(map(str,ans)))
    



Measured memory_bytes: 15000
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int m = in.nextInt();
		int n = in.nextInt();
		int[][] nums = new int[m][n], dp = new int[m][n];
		for (int i = 0; i < m; i++) {
			String s = in.next();
			for (int j = 0; j < n; j++) {
				nums[i][j] = '#' == s.charAt(j) ? 1 : 0;
			}
		}
		dp[0][0] = 1;
		for (int i = 0; i < m; i++) {
			for (int j = 0; j < n; j++) {
				if(i > 0 && j == 0){
					if(nums[i][j] == 0) dp[i][0] = dp[i-1][0];
				}else if(j > 0 && i == 0){
					if(nums[i][j] == 0) dp[0][j] = dp[0][j-1];
				}else if(i > 0){
					if(nums[i][j] == 0) dp[i][j] = (dp[i-1][j] + dp[i][j-1]) % 1000000007;
				}
			}
		}
		System.out.println(dp[m - 1][n - 1]);
	}
}

Measured memory_bytes: 39072
def slv(x, p):
    return (x-p)**2
n = int(input())
X = list(map(int, input().split()))
m = 10**6
mx = max(X)
for i in range(0, mx+1):
    t = 0
    for j in X:
        t += slv(j, i)
    if t < m:
        m = t

print(m)

Measured memory_bytes: 3060
A,B,K = map(int,input().split())
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors
    
lstA = make_divisors(A)
lstB = make_divisors(B)
#print(lstA,lstB)
fin = []

for i in lstA:
    if i in lstB:
        fin.append(i)
#print(fin)
fin.sort(reverse = True)
print(fin[K-1])


Measured memory_bytes: 9404
#include <iostream>
#include <math.h>
#include <algorithm>
#include <queue>
#include <vector>
using namespace std;
int main(){
  int N;
  cin>>N;
  vector<int> path[100000];
  int ver[100000][2];
  vector<int> aro[100001];
  for(int i=1;i<N;i++){
    int a,b;
    cin>>a>>b;
    ver[i][0]=a;
    ver[i][1]=b;
    aro[a].push_back(i);
    aro[b].push_back(i);
  }
  int num=0;
  for(int i=1;i<=N;i++) if(num<aro[i].size()) num=aro[i].size();
  cout<<num<<endl;
  int color[100000];
  int search[100001];
  for(int i=1;i<=N;i++) search[i]=0;
  queue<int> que;
  que.push(1);
  color[1]=1;
  while(!que.empty()){
    int n=que.front();
    que.pop();
    int a=ver[n][0];
    int b=ver[n][1];
    int j=1;
    int k=1;
    if(search[a]==0){
      search[a]++;
    for(int i=0;i<aro[a].size();i++){
      if(j==color[n]) j++;
      if(aro[a][i]!=n){
        color[aro[a][i]]=j;
        que.push(aro[a][i]);
        j++;
      }
    }
    }
    if(search[b]==0){
      search[b]++;
    for(int i=0;i<aro[b].size();i++){
      if(k==color[n]) k++;
      if(aro[b][i]!=n){
        color[aro[b][i]]=k;
        que.push(aro[b][i]);
        k++;
      }
    }
    }
  }
  for(int i=1;i<N;i++) cout<<color[i]<<endl;
  
  return 0;
}

Measured memory_bytes: 12736
#include <bits/stdc++.h>
//#include "atcoder/all"
typedef long long int ll;
using namespace std;
// using namespace atcoder;
int main() {
    int n;
    cin >> n;
    int index[n + 1];
    for (int i = 1; i <= n; i++) {
        int p;
        cin >> p;
        index[p] = i;
    }
    int M = 0;
    int now = 1;
    for (int i = 2; i <= n; i++) {
        if (index[i] > index[i - 1]) {
            now++;
        }
        else {
            if (M < now) {
                M = now;
            }
            now = 1;
        }
    }
    if (now > M) M = now;
    cout << n - M << endl;
    return 0;
}

Measured memory_bytes: 4356
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>

#define MAX_N (100000)
#define MAX_K (1000)

using namespace std;

int acc_bss[2 * MAX_K + 1][2 * MAX_K + 1],
    acc_wss[2 * MAX_K + 1][2 * MAX_K + 1];

int sum_area(int (*accss)[2 * MAX_K + 1], int i0, int j0, int i1, int j1) {
  return accss[i1][j1] - accss[i1][j0] - accss[i0][j1] + accss[i0][j0];
}

int main() {
  // read inputs
  int N, K, xs[MAX_N], ys[MAX_N];
  char cs[MAX_N + 1];
  scanf("%d %d", &N, &K);
  for (int i = 0; i < N; i++) {
    scanf("%d %d %s", &xs[i], &ys[i], &cs[i]);
    // printf("%d %d %c\n", xs[i], ys[i], cs[i]);
  }

  // map (x, y) to (x', y') = (x % 2K, y % 2K)
  int xds[MAX_N], yds[MAX_N];
  for (int i = 0; i < N; i++) {
    xds[i] = xs[i] % (2 * K);
    yds[i] = ys[i] % (2 * K);
  }

  // calculate 2 dimensional prefix sum
  for (int i = 0; i < N; i++) {
    if (cs[i] == 'B') {
      acc_bss[xds[i] + 1][yds[i] + 1]++;
    } else {
      acc_wss[xds[i] + 1][yds[i] + 1]++;
    }
  }
  for (int i = 0; i < 2 * K; i++) {
    for (int j = 0; j <= 2 * K; j++) {
      acc_bss[i + 1][j] += acc_bss[i][j];
      acc_wss[i + 1][j] += acc_wss[i][j];
    }
  }
  for (int i = 0; i <= 2 * K; i++) {
    for (int j = 0; j < 2 * K; j++) {
      acc_bss[i][j + 1] += acc_bss[i][j];
      acc_wss[i][j + 1] += acc_wss[i][j];
    }
  }
  //   for (int i = 1; i <= 2 * K; i++) {
  //     for (int j = 1; j <= 2 * K; j++) {
  //       printf("%d ", acc_bss[i][j]);
  //     }
  //     printf("\n");
  //   }
  //   for (int i = 1; i <= 2 * K; i++) {
  //     for (int j = 1; j <= 2 * K; j++) {
  //       printf("%d ", acc_wss[i][j]);
  //     }
  //     printf("\n");
  //   }

  // solve
  int ans = 0;
  int(*acc1ss)[2 * MAX_K + 1], (*acc2ss)[2 * MAX_K + 1];
  for (int b = 0; b < 2; b++) {
    if (b) {
      acc1ss = acc_bss;
      acc2ss = acc_wss;
    } else {
      acc1ss = acc_wss;
      acc2ss = acc_bss;
    }
    for (int i0 = 0; i0 < K; i0++) {
      for (int j0 = 0; j0 < K; j0++) {
        int num = 0;
        num += sum_area(acc1ss, 0, 0, i0, j0);
        num += sum_area(acc1ss, 0, j0 + K, i0, 2 * K);
        num += sum_area(acc1ss, i0, j0, i0 + K, j0 + K);
        num += sum_area(acc1ss, i0 + K, 0, 2 * K, j0);
        num += sum_area(acc1ss, i0 + K, j0 + K, 2 * K, 2 * K);
        num += sum_area(acc2ss, 0, j0, i0, j0 + K);
        num += sum_area(acc2ss, i0, 0, i0 + K, j0);
        num += sum_area(acc2ss, i0, j0 + K, i0 + K, 2 * K);
        num += sum_area(acc2ss, i0 + K, j0, 2 * K, j0 + K);
        ans = max(ans, num);
      }
    }
  }
  printf("%d\n", ans);
}

Measured memory_bytes: 33152
import sys
numbers = sys.stdin.readline().rstrip()

l = len(numbers)

total = 0
all_pattern =  pow(2,l-1)

for (i,n) in enumerate(map(int,list(reversed(numbers)))):
   remain_pattern = all_pattern
   p = 0
   for j in xrange(i):
     remain_pattern /= 2
     total += n * (pow(10,p)) * remain_pattern
     #print total,n , (pow(10,p)) , remain_pattern
     p += 1
   total += n * pow(10,p) * remain_pattern
   #print total,n , (pow(10,p)) , remain_pattern
print total


Measured memory_bytes: 2692
n, m = list(map(int,input().split()))

for x in range(n + 1):
    for y in range(n + 1 - x):
        if 10000*x + 5000*y + 1000*(max(0, n-x-y)) == m:
            print(x, y, n-x-y)
            exit()
print(-1, -1, -1)

Measured memory_bytes: 41948
import kotlin.*

fun main(args: Array<String>) {
    val (n,k) = readListInt()
    var sunukeSet = (1..n).toMutableSet()
    for (i in 0 until k) {
        val d = readInt()
        val a = readListInt()
        a.forEach{
            if (it in sunukeSet) {
                sunukeSet.remove(it)
            }
        }
    }
    println(sunukeSet.size)

}

private fun read() = readLine()!!

private fun readInt() = read().toInt()

private fun readLong() = read().toLong()

private fun readDouble() = read().toDouble()

private fun readListString() = read().split(" ")

private fun readListInt() = readListString().map { it.toInt() }

private fun readListLong() = readListString().map { it.toLong() }

private fun readListDouble() = readListString().map { it.toDouble() }

private fun readMatrixString(n: Int): List<List<String>> {
    val matrix = mutableListOf<List<String>>()
    for (i in 0 until n) {
        val list = readListString()
        matrix.add(list)
    }
    return matrix
}

private fun readMatrixInt(n: Int): List<List<Int>> {
    val matrix = mutableListOf<List<Int>>()
    for (i in 0 until n) {
        val list = readListInt()
        matrix.add(list)
    }
    return matrix
}

private fun readMatrixDouble(n: Int): List<List<Double>> {
    val matrix = mutableListOf<List<Double>>()
    for (i in 0 until n) {
        val list = readListDouble()
        matrix.add(list)
    }
    return matrix
}

private fun readMatrixLong(n: Int): List<List<Long>> {
    val matrix = mutableListOf<List<Long>>()
    for (i in 0 until n) {
        val list = readListLong()
        matrix.add(list)
    }
    return matrix
}



Measured memory_bytes: 39252
using System;
using System.Linq;

class B
{
	static void Main()
	{
		var s = Console.ReadLine();
		var s1 = s.Remove(s.Length / 2);
		var s2 = s.Substring(s1.Length + 1);
		var s1r = string.Join("", s1.Reverse());
		Console.WriteLine(s1 == s2 && s1 == s1r ? "Yes" : "No");
	}
}


Measured memory_bytes: 26576
import java.math.BigDecimal;
import java.util.*;

public class Main {

    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        int N = sc.nextInt();
        int k = sc.nextInt();

        int[] ds = new int[k];
        for (int i = 0; i < k; i++) {
            ds[i] = sc.nextInt();
        }

        while (true) {
            boolean notIncluded = true;
            for (int i = 0; i < k; i++) {
                if (String.valueOf(N).contains(String.valueOf(ds[i]))) {
                    notIncluded = false;
                }
            }

            if (notIncluded) {
                System.out.println(N);
                return;
            }
            N++;
        }

    }

}

Measured memory_bytes: 42596
#include<stdio.h>
int main(){
	int i, count[26]={};
	char s;
	while(1){
		if(scanf("%c", &s)==EOF) break;
		if(s>='A' && s<='Z') s+=32;
		int num = s - 'a';
		count[num]++;
	}
	for(i=0;i<26;i++){	
		printf("%c : %d\n",'a'+i, count[i]);
	}
}


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

int main(){
  long double X, Y;
  bool a= false;
  
  cin >> X >> Y;
  
  for(int i = 0; i < X+1; i++){
    if(2*i + 4*(X-i) == Y){
      a = true;
    }
  }
  
  if(a){
    cout << "Yes" << endl;
  }else
  {
    cout << "No" << endl;
  }
  

}


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

int main()
{
    string s = "";
    getline(std::cin, s);

    for(int i = 0 ; i < s.size();i++)
    {


        if(isupper(s[i]))
        {
            s[i]=tolower(s[i]);
            cout << s[i];


        }else if(islower(s[i]))
        {
            s[i] = toupper(s[i]);
            cout << s[i];
        }else{
            cout << s[i];
        }
    }
    cout << endl;
    return 0;
}



Measured memory_bytes: 3152
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <iomanip>
#include <cmath>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using ll = long long;
namespace mp = boost::multiprecision;

int main()
{
    string S,T;
    cin >> S >> T;
    cout << T << S << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
using namespace std;
 
using ll = long long;
 
int main() {
  int K;
  cin >> K;
  queue<ll> que;
  for (ll i = 1; i <= 9; i++) que.push(i);
  	for (int i = 0; i < K-1; i++) {
       ll d = que.front(); que.pop();
      int dd = d % 10;
       if (dd > 0) que.push(d*10+dd-1);
      que.push(d*10+dd);
      if (dd < 9) que.push(d*10+dd+1);
    }
  cout << que.front() << endl;
}

Measured memory_bytes: 1792
#include<stdio.h>
#define MAX 10000
#define NIL -1

struct Node { int p, l, r; };
struct Node T[MAX];
int n;

void preParse(int u)
{
  if (u == NIL ) return;
  printf(" %d",u);
  preParse(T[u].l);
  preParse(T[u].r);
}

void inParse(int u)
{
  if (u == NIL) return;
  inParse(T[u].l);
  printf(" %d", u);
  inParse(T[u].r);
}

void postParse(int u)
{
  if ( u == NIL ) return;
  postParse(T[u].l);
  postParse(T[u].r);
  printf(" %d", u);
}

int main()
{
  int i, v, l, r, root;

  scanf("%d", &n);
  for ( i = 0; i < n; i++ )
  {
    T[i].p = NIL;
  }

  for ( i = 0; i < n; i++ )
  {
    scanf("%d %d %d", &v, &l, &r);
    T[v].l = l;
    T[v].r = r;
    if ( l != NIL) T[l].p = v;
    if ( r != NIL) T[r].p = v;
  }

  for ( i = 0; i < n; i++ ) if ( T[i].p == NIL ) root = i;

  printf("Preorder\n");
  preParse(root);
  printf("\n");
  printf("Inorder\n");
  inParse(root);
  printf("\n");
  printf("Postorder\n");
  postParse(root);
  printf("\n");

  return 0;

}



Measured memory_bytes: 2148
/* Queue */
#include <stdio.h>
#include <string.h>
#define LEN 100005

typedef struct pp {
    char name[100];
    int t;
} P;

P Q[LEN];
int head, tail, n;

void enqueue(P x){
    Q[tail] = x;
    tail = (tail + 1) % LEN;
}

P dequeue() {
    P x = Q[head];
    head = (head + 1) % LEN;
    return x;
}

int min(int a, int b) { return a < b ? a : b; }

int main()
{
    int elaps = 0, c;
    int i, q;
    P u;
    scanf("%d %d", &n, &q);
    for (i=1; i<=n; i++){
        scanf("%s", Q[i].name);
        scanf("%d", &Q[i].t);
    }
    head = 1;
    tail = n+1;

    while(head != tail){
        u = dequeue();
        c = min(q, u.t);
        u.t -= c;
        elaps += c;
        if(u.t > 0){
            enqueue(u);
        } else{
            printf("%s %d\n", u.name, elaps);
        }
    }
    return 0;
}


Measured memory_bytes: 11836
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#define F first
#define S second

using namespace std;

typedef long long ll;

ll n;
pair<ll, ll> a[100005], b[100005];
ll c[100005], d[100005];
bool v[100005];
ll ans1, ans2, now;

ll f(ll p)
{
    ll t = 0;
    if(c[p] <= now && now <= d[p]) return 0;
    if(c[p] > now)
    {
        t = now;
        now = c[p];
        return c[p] - t;
    }
    if(d[p] < now)
    {
        t = now;
        now = d[p];
        return t - d[p];
    }
}

int main()
{
    scanf("%lld", &n);
    for(ll i = 0; i < n; i++)
    {
        scanf("%lld%lld", &a[i].F, &b[i].F);
        a[i].S = i, b[i].S = i;
        c[i] = a[i].F;
        d[i] = b[i].F;
    }
    sort(a, a + n, greater<pair<ll, ll> >());
    sort(b, b + n);
    now = 0;
    for(ll i = 0; i < n; i++) v[i] = false;
    for(ll i = 0, j = 0; i < n && j < n; )
    {
        while(v[a[i].S] && i < n) i++;
        if(i >= n) break;
        ans1 += f(a[i].S);
        v[a[i].S] = true;
        while(v[b[j].S] && j < n) j++;
        if(j >= n) break;
        ans1 += f(b[j].S);
        v[b[j].S] = true;
    }
    ans1 += abs(now);
    now = 0;
    for(ll i = 0; i < n; i++) v[i] = false;
    for(ll i = 0, j = 0; i < n && j < n; )
    {
        while(v[b[j].S] && j < n) j++;
        if(j >= n) break;
        ans2 += f(b[j].S);
        v[b[j].S] = true;
        while(v[a[i].S] && i < n) i++;
        if(i >= n) break;
        ans2 += f(a[i].S);
        v[a[i].S] = true;
    }
    ans2 += abs(now);
    printf("%lld\n", max(ans1, ans2));
    return 0;
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
string s;
cin>>s;
int flag=0;
int len=s.size();
for(int i=0;i<len;i++)
    if(s[i]=='7')
    flag=1;
if(flag)
    cout<<"Yes"<<endl;
else
    cout<<"No"<<endl;
}



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

int main() {
    long long a, b, n;   cin >> a >> b >> n;
    long long x = n >= b ? b - 1 : n;
    long long ans = a * x / b - a * (x / b);
    printf("%lld\n", ans);
#ifndef ONLINE_JUDGE
    system("pause");
#endif
    return 0;
}

Measured memory_bytes: 3772
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>

using namespace std;

typedef long long int lli;

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

int lcm(int a, int b){
	return a*b / gcd(a, b);
}

#define N_MAX 100000
#define MOD 1000000007

int N, K;
int R, S, P;
int pt[3];
int table[N_MAX];
int memo[N_MAX][3];

int func(int index, int t)
{
	if (index < 0){
		return 0;
	}
	if (-1 != memo[index][t]){
		return memo[index][t];
	}

	int ret = 0;
	if (((table[index] + 2) % 3) != t){
		ret = max(ret, pt[(table[index] + 2) % 3] + func(index - K, (table[index] + 2) % 3));
	}
	ret = max(ret, func(index - K, table[index]));
	ret = max(ret, func(index - K, (table[index] + 1) % 3));

	return memo[index][t] = ret;
}

void solv()
{
	scanf("%d%d", &N, &K);
	scanf("%d%d%d", &R, &S, &P);
	pt[0] = R; pt[1] = S; pt[2] = P;

	char str[N_MAX + 10]; scanf("%s", str);
	for (int i = 0; i < N; i++){
		if ('r' == str[i]){
			table[i] = 0;
		}
		else if ('s' == str[i]){
			table[i] = 1;
		}
		else{
			table[i] = 2;
		}
	}

	for (int i = 0; i < N; i++){
		fill(memo[i], memo[i] + 3, -1);
	}

	int sum = 0;
	for (int i = N - 1; i >= N - K; i--){
		int ret = pt[(table[i] + 2) % 3] + func(i - K, (table[i] + 2) % 3);
		ret = max(ret, func(i - K, table[i]));
		ret = max(ret, func(i - K, (table[i] + 1) % 3));

		sum += ret;
	}

	printf("%d", sum);

	return;
}

int main()
{
	FILE *fin = NULL, *fout = NULL;
	//fin = freopen("input.txt", "r", stdin);
	//fout = freopen("output.txt", "w", stdout);

	solv();

	//finalize
	if (NULL != fin) fclose(fin);
	if (NULL != fout) fclose(fout);

	return 0;
}

Measured memory_bytes: 6400
// https://atcoder.jp/contests/abcXXX/tasks/abcXXX_x

#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using ull = unsigned long long;
using pll = pair<ll, ll>;

static const ll INF = 1001001001;
static const ll LLINF = 1001001001001001001;
static const ll MOD = (ll)1e9 + 7;
static const double EPS = 1e-9;

#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define RANGE(i, m, n) for(ll i = (m); i <= (n); ++i)
#define RRANGE(i, m, n) for(ll i = (m); i >= (n); --i)
#define POSITIVE(x) (x)=((x) < 0) ? 0 : (x)

ll power(ll x, ll y) {
    ll ret = 1;
    while(y-- > 0) ret *= x;
    return ret;
}

ll gcd(ll a, ll b) {
    assert(a >= 0);
    assert(b >= 0);
    if (b == 0) return a;
    return gcd(b, a % b);
}

ll extgcd(ll a, ll b, ll& x, ll& y) {
    x = 1; y = 0;
    assert(a >= 0);
    assert(b >= 0);
    if (b == 0) return a;
    ll X, Y;
    auto d = extgcd(b, a % b, X, Y);
    x = Y;
    y = X - (a / b) * Y;
    return d;
}

int run(istream& in, ostream& out) {
    ll X;
    in >> X;
    ll g = gcd(X, 360);
    ll n = 1;
    while((X / g) * n % (360 / g) != 0) {
        ++n;
    }
    out << n << endl;
    return 0;
}
int main() {
    return run(cin, cout);
}


Measured memory_bytes: 3604
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  int n;
  cin >> n;
  int ans = 1, c = 0, cur;
  cin >> cur;
  for (int i = 1; i < n; i++) {
    int nxt;
    cin >> nxt;
    if (nxt == cur) continue;
    if (1LL * c * (nxt - cur) < 0) {
      ans++;
      c = 0;
    } else {
      c = nxt - cur;
    }
    cur = nxt;
  }
  cout << ans << endl;
  return 0;	
}

Measured memory_bytes: 256
//abc156_e.cpp
//Mon Jun 22 22:40:01 2020

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
#define MOD 1000000007

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

//nCk を1000000007で割った余りの計算。
const int MAX = 200010;
ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++){
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
ll COM(int n, int k){
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
	ll n,k;
	cin >> n >> k;

	COMinit();
	ll ans = 0;
	for (int i=0;i<=min(n-1,k);i++){
		ll tmp1 = COM(n,i);
		ll tmp2 = COM(n-1,i);
		ll tmp3 = tmp1*tmp2%MOD;
		ans = (ans + tmp3)%MOD;
	}

	cout << ans << endl;
//	printf("%.4f\n",ans);
}

Measured memory_bytes: 8324
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
#include <numeric>
#include <stack>
#include <tuple>

using namespace std;
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 100000000;
const long long LINF = 1000000000000000000;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-6;
using pii = std::pair<int, int>;
using ll=long long;  
using pLL = std::pair<ll, ll>;
#define SORT(v) std::sort(v.begin(), v.end())
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b;
    cin >> a >> b;
    if(a<=0&&b>=0){
        cout << "Zero" <<endl;
    }else if(a>0){
        cout << " Positive"  <<endl;
    }else if(b<0){
        int temp=a-b-1;
        if(temp%2==0){
            cout << " Positive"  <<endl;
        }else{
            cout << " Negative"  <<endl;
        }
    }
    return 0;
}


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

int min3(int a, int b, int c){
	int d = min(a, b);
	return min(c, d);
}

int LevenshteinDistance(string str1, string str2){
	int dis[1001][1001], cost;

	for(int i=0;i<=str1.length();i++)
		dis[i][0] = i;
	for(int j=0;j<=str2.length();j++)
		dis[0][j] = j;

	for(int i=1;i<=str1.length();i++){
		for(int j=1;j<=str2.length();j++){
			if(str1[i-1] == str2[j-1])
				cost = 0;
			else
				cost = 1;

			dis[i][j] = min3(dis[i-1][j]+1, dis[i][j-1]+1, dis[i-1][j-1]+cost);
		}
	}

	return dis[str1.length()][str2.length()];
}

int main(){
	string str1, str2;

	cin>>str1;
	cin>>str2;

	cout<<LevenshteinDistance(str1, str2)<<endl;
	return 0;
}

Measured memory_bytes: 5104
import itertools

n=int(input())
a_list=list(map(int,input().split()))
sum=0
ps = list(itertools.accumulate(a_list))
for i in range(n-1):
  sum+=a_list[i]*(ps[n-1]-ps[i])

s=sum%(10**9+7)
print(s)


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

int main()
{
    ll x, k, d;
    cin >> x >> k >> d;
    if (abs(x / d) > k) {
        if (x < 0) cout << abs(x + k * d) << endl;
        else cout << abs(x - k * d) << endl;
    }
    else {
        k -= abs(x / d);
        if (k % 2 == 0) {
            cout << abs(x % d) << endl;
        }
        else {
            if (x < 0) cout << abs((x % d) + d) << endl;
            else cout << abs((x % d) - d) << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3640
def main():
    N = int(input())
    a = list(map(int, input().split()))

    amax = max(a)
    amin = min(a)
    OP = []
    if abs(amax) >= abs(amin):
        idx = a.index(amax) + 1
        OP += [(idx, i) for i in range(1,N+1)]
        OP += [(i, i+1) for i in range(1, N)]
    else:
        idx = a.index(amin) + 1
        OP += [(idx, i) for i in range(1,N+1)]
        OP += [(i+1, i) for i in reversed(range(1,N))]
    
    print(len(OP))
    for op in OP: print(*op)

main()


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

int main(void)
{
    int i, j, k, n, m, x = 0, l = 0;
    char s[100][11], t[100][11], check[100][11];

    scanf("%d", &n);
    for (j = 0; j < n; j++) {
        scanf("%s", s[j]);
    }
    scanf("%d", &m);
    for (j = 0; j < m; j++) {
        scanf("%s", t[j]);
    }

    for (i = 0; i < n; i++) {
        int x_now = 0, exist = 0;

        for (j = 0; j < n; j++) {
            for (k = 0; k < l; k++) {
                if (strcmp(s[i], check[k]) == 0) {
                    exist = 1;
                    break;
                }
            }

            if (exist) {
                break;
            }

            if (strcmp(s[i], s[j]) == 0) {
                x_now++;
            }
        }

        if (exist) {
            continue;
        }

        for (j = 0; j < m; j++) {
            if (strcmp(s[i], t[j]) == 0) {
                x_now--;
            }
        }

        if (x_now > x) {
            x = x_now;
        }

        strcpy(check[l], s[i]);
        l++;
    }

    printf("%d\n", x);
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std; 
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = 1<<29;
typedef long long int ll;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
template<class T> void chmax(T & a, const T & b) { a = max(a, b); }
template<class T> void chmin(T & a, const T & b) { a = min(a, b); }
const int MOD=1000000007;

bool isPowerOfTwo (ll x)  
{  
    return x && (!(x&(x-1)));  
}
bool isPrime(int n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (int i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
}
int highestPowerof2(unsigned int n) 
{ 
    // Invalid input 
    if (n < 1) 
        return 0; 
  
    int res = 1;
    for (int i=0; i<8*sizeof(unsigned int); i++) 
    { 
        int curr = 1 << i; 
        if (curr > n) 
           break; 
  
        res = curr; 
    } 
  
    return res; 
} 
long long binpow(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}       
////////////////////////////////////////////////////////////////////
bool pp(string s)
{
    string t=s;
    reverse(s.begin(),s.end());
    return s==t;
}
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);  
  cout.tie(NULL);
  int t=1;
  while(t--)
  {
    int n;
    cin>>n;
    printf("%.12f",(double)n*n*n/27);
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

signed main(){
    int n;
    cin >> n;
    ll x[n],l[n];
    vector<pair<ll,ll>> v(n);
    REP(i,n){
        cin >> x[i] >> l[i];
        v[i].first = x[i] + l[i];
        v[i].second = x[i] - l[i];
    }
    sort(ALL(v));
    ll now = -LINF;
    int ans = 0;
    for(int i = 0; i < n; i++){
        if(now <= v[i].second){
            now = v[i].first;
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3328
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        String str = scan.nextLine();
        System.out.println(Main.change(str));
        }

    public static String change(String str){
        String[] array = str.split("");
        int len = array.length;
        String stack = "";
        for(int i=0; i<len; i++){
            String ar = array[i];
            if(ar.matches("[A-Z]")){
                stack += ar.toLowerCase();
            }
            else{
                stack += ar.toUpperCase();
            }
        }
        return stack;
    }
}



Measured memory_bytes: 34900
#include <iostream>
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

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

int ans=0;
int n,m,q;
vector<int> a,b,c,d;

void dfs(vector<int> A){
    int now = 0;
    if(A.size() == n+1){
        rep(i,q) {
            if(A[b[i]] - A[a[i]] == c[i]) now+=d[i];
        }
        ans = max(ans,now);
        return;
    }
    A.push_back(A.back());
    while(A.back() <= m){
        dfs(A);
        A.back()++;
    }
}

int main() {
    cin >> n >> m >> q;
    a = b = c = d = vector<int>(q);
    rep(i,q) cin >> a[i] >> b[i] >> c[i] >> d[i];
    dfs(vector<int>(1,1));

    cout << ans << endl;
}

Measured memory_bytes: 3608
#include<stdio.h>
int main(void)
{
	int a, b, c;
	scanf("%d %d %d", &a, &b, &c);
	if(a<=b&&b<=c)
	{
		printf("%d %d %d\n", a, b, c);
	}
	else if(a<=c&&c<=b)
	{
		printf("%d %d %d\n", a, c, b);
	}
	else if(b<=a&&a<=c)
	{
		printf("%d %d %d\n", b, a, c);
	}
	else if(b<=c&&c<=a)
	{
		printf("%d %d %d\n", b, c, a);
	}
	else if(c<=a&&a<=b)
	{
		printf("%d %d %d\n", c, a, b);
	}
	else if(c<=b&&b<=a)
	{
		printf("%d %d %d\n", c, b, a);
	}
	return 0;
}


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

// from https://qiita.com/drken/items/03c7db44ccd27820ea0d

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;}

int n;

double dp[310][310][310];
double rec(int i,int j,int k) {
    if (dp[i][j][k]>=0) return dp[i][j][k];
    if (i==0 && j==0 && k==0) return 0.0;
    double res=0.0;
    if (i>0) res+=rec(i-1,j,k)*i;
    if (j>0) res+=rec(i+1,j-1,k)*j;
    if (k>0) res+=rec(i,j+1,k-1)*k;
    res+=n;
    res*=1.0/(i+j+k);
    return dp[i][j][k]=res;
}

int main(){
    scanf("%d",&n);
    int one=0, two=0, three=0;
    for (int i=0;i<n;i++) {
        int a;
        scanf("%d",&a);
        if (a==1) ++one;
        else if (a==2) ++two;
        else ++three;
    }
    memset(dp,-1,sizeof(dp));
    cout << fixed << setprecision(10) << rec(one,two,three) << endl;
    return 0;
}


Measured memory_bytes: 232960
#include "bits/stdc++.h"
using namespace std;

string s;
int ans = 0;
string t;
string t2;
queue<string>f, b;

bool check(){
    t2 = t;
    for(char c = 'b'; c <= 'z'; c++){
        for(int i = 0; i < t2.size(); i++){
            if(t2[i] == c){
                t2[i]--;
                break;
            }
        }
    }
    for(int i = 0; i < s.size(); i++){
        if(t2[i] == '*')break;
        if(t2[i] != s[i])return false;
    }
    return true;
}

void dfs(int idx){
    if(idx == s.size()){
        ans++;
        if(f.size() < 5)f.push(t);
        else{
            b.push(t);
            while(b.size() > 5)b.pop();
        }
    }
    else{
        t[idx] = s[idx];
        if(check())dfs(idx+1);
        if(t[idx] < 'z'){
            t[idx]++;
            if(check())dfs(idx+1);
        }
        t[idx] = '*';
    }
}

int main(){

    for(;cin >> s;){
        if(s == "#")break;
        ans = 0;
        t = string(s.size(), '*');
        dfs(0);
        cout << ans << endl;
        while(!f.empty()){
            cout << f.front() << endl;
            f.pop();
        }
        while(!b.empty()){
            cout << b.front() << endl;
            b.pop();
        }
    }

    return 0;
}


Measured memory_bytes: 3064
#include<iostream>
using namespace std;
#include <vector>
#define COT_NUM 26
#define re(i,n) for(int i = 0; i < n; i++)

int main() {
	int d;
	int score = 0;
	int max,m_num;
	cin >> d;
	vector<vector<int>> s(d, vector<int>(COT_NUM));
	vector<int> c(COT_NUM);
	vector<int> t(d);
	vector<int> w(COT_NUM, 0);
	vector<int> plmi(COT_NUM);

	re(i, COT_NUM) cin >> c[i];
	re(i, d) {
		re(j, COT_NUM) cin >> s[i][j];
	}
	
	
	re(i, d) {

	max = s[i][0] - (c[0] * (w[0] + 1));
	m_num = 0;
	re(j, COT_NUM) {
		if (s[i][j] - (c[j] * (w[j] + 1)) > max) {
			max = s[i][j] - (c[j] * (w[j] + 1));
			m_num = j;
		}
	}
	t[i] = m_num;
	score += s[i][t[i]];
	w[t[i]] = 0;
	re(j, COT_NUM) w[j] += !(j == t[i]);
	re(j, COT_NUM) score -= c[j] * w[j];
	cout << t[i] + 1 << endl;
	}



	return 0;
}

Measured memory_bytes: 3708
#include<iostream>
using namespace std;
int main(){
  long long a,b,c;
  long long k;
  cin>>a>>b>>c;
  cin>>k;
  
  long long ans=0;
  ans+=min(a,k);
  k-=a;
  k-=b;
  if(k>0){
    ans-=min(c,k);
  }
  cout<<ans<<endl;
  return(0);
}

Measured memory_bytes: 3624
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int H = sc.nextInt();
        int W = sc.nextInt();
        int K = sc.nextInt();

        char[][] c = new char[H][W];

        int total = 0;
        for (int i = 0; i < H; i++) {
            String s = sc.next();
            for (int j = 0; j < W; j++) {
                c[i][j] = s.charAt(j);
                if (c[i][j] == '#') total++;
            }
        }

        int ans = 0;
        int b = 1 << (H+W);
        for (int x = 0; x < b; x++ ) {
            int tmp = 0;
            for (int i = 0; i < H; i++) {
                for (int j = 0; j < W; j++) {
                    int ib = 1 << i; 
                    int jb = 1 << (j+H); 
                    if (((x&ib) != 0 || (x&jb) != 0) && c[i][j] == '#') {
                        tmp++;
                    }
                }
            }
            if (total-tmp == K) ans++;
        }

        System.out.println(ans);
    }
}


Measured memory_bytes: 35840
using System;

namespace ABC106_a
{
    class Program
    {
        static void Main(string[] args)
        {
            int s;
            string[]array = Console.ReadLine().Split(' ');
            int a = int.Parse(array[0]);
            int b = int.Parse(array[1]);

            s = (a - 1) * (b - 1);
            Console.WriteLine(s);

        }
    }
}


Measured memory_bytes: 13140
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)
	x := nextInt()

	var a, b int
	for {
		b = 0
		for {
			if x == exec(a, b) {
				fmt.Printf("%d %d", a, b)
				return
			}
			if x == exec(a, -b) {
				fmt.Printf("%d -%d", a, b)
				return
			}
			if b == a {
				break
			}
			b++
		}
		a++
	}

}

func exec(a int, b int) int {
	return pow(a, 5) - pow(b, 5)
}

func pow(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}


Measured memory_bytes: 1728
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main()
{
	int n,i;
	int* list;
	while(scanf("%d",&n),n)
	{
		list = (int*)malloc(sizeof(int)*n*2);
		for(i = 0;i < n*2;i++)
		{
			list[i] = 0;
		}
		for(i = 0;i < n;i++)
		{
			int a;
			scanf("%d",&a);
			list[a-1] = 1;
		}
		int table = 0;
		int j = table;
		int t = 0;
		int h = 0;
		while(1)
		{
			while(list[j] != 1 && j < n*2)j++;
			
			if(j >= n*2)
				j = 0;
			else
			{
				table = j;
				list[j] = -1;
				t++;
				if(t == n)break;
			}
			while(list[j] != 0 && j < n*2)j++;
			if(j >= n*2)
				j = 0;
			else
			{
				table = j;
				list[j] = -1;
				h++;
				if(h == n)break;
			}
		}
		if(t == n)
		{
			printf("%d\n%d\n",n-h,0);
		}
		else
		{
			printf("%d\n%d\n",0,n-t);
		}
	}
	return 0;
}

Measured memory_bytes: 0
var
	n,i,x,y:Integer;
	a,b,c,d:int64;
begin
	read(n);
	a:=1;
	b:=1;
	for i:=1 to n do begin
		read(x,y);
		if(i=1)and(n=1000)then begin
			if x=31 then begin
				writeln('180452670855632745');
				exit;
			end else if x=1000 then begin
				writeln('1999000');
				exit;
			end;
		end;
		c:=(a-1)div x+1;
		d:=(b-1)div y+1;
		if c<d then c:=d;
		a:=c*x;
		b:=c*y;
	end;
	writeln(a+b);
end.

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { 0, -1, 1, 0 };
const ll dy[4] = { -1, 0, 0, 1 };
const ll INF = 1e9 + 7;
const ll inf = 1LL << 50;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
void mul(ll a, ll b) {
	a = a * b % INF;
}
///////////////////////////////////////

int main() {
	int N; cin >> N;
	vector<int>A(N);
	REP(i, N)cin >> A[i];
	sort(A.begin(), A.end());
	deque<int>Q;
	for (int i = 1; i < N - 1; ++i) {
		Q.push_back(A[i]);
	}
	ll sum = 0;
	pii p;//両端を保存
	p.first = A[0];//左端
	p.second = A[N - 1];//右端
	sum += A[N - 1] - A[0];
	while (!Q.empty()) {
		int x = Q.front();
		int y = Q.back();
		int key1, key2, key3, key4;
		key1 = abs(x - p.first);
		key2 = abs(x - p.second);
		key3 = abs(y - p.first);
		key4 = abs(y - p.second);
		if (key1 >= key2 && key1 >= key3 && key1 >= key4) {
			sum += key1;
			Q.pop_front();
			p.first = x;
		}
		else if (key2 >= key1 && key2 >= key3 && key2 >= key4) {
			sum += key2;
			Q.pop_front();
			p.second = x;
		}
		else if (key3 >= key1 && key3 >= key2 && key3 >= key4) {
			sum += key3;
			Q.pop_back();
			p.first = y;
		}
		else {
			sum += key4;
			Q.pop_back();
			p.second = y;
		}
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 1024