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

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}


typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0, -1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
//#define mp make_pair

int w, h;

int dfs(int si, int sj, vii &a, int d) {
  if (d == 10) return inf;
  int res = inf;
  rep (i, 4) {
    int ni = si + dx[i], nj = sj + dy[i];
    if (!in(ni, 0, h) || !in(nj, 0, w)) continue;
    if (a[ni][nj] == 1) continue;
    bool fall = false;
    while (a[ni][nj] != 1) {
      if (a[ni][nj] == 3) return d + 1;
      ni += dx[i]; nj += dy[i];
      if (!in(ni, 0, h) || !in(nj, 0, w)) {
        fall = true;
        break;
      }
    }
    if (fall) continue;
    a[ni][nj] = 0;
    chmin(res, dfs(ni - dx[i], nj - dy[i], a, d + 1));
    a[ni][nj] = 1;
  }
  return res;
}

int main() {
  while (true) {
    cin >> w >> h;
    if (w == 0 && h == 0) return 0;
    vii a(h, vi(w));
    int si, sj;
    rep (i, h) {
      rep (j, w) {
        cin >> a[i][j];
        if (a[i][j] == 2) {
          si = i;
          sj = j;
        }
      }
    }

    int ans = dfs(si, sj, a, 0);
    if (ans >= 1000000) {
      cout << -1 << endl;
    }
    else {
      cout << ans << endl;
    }
  }
}



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

main(){
  int N,M;
  cin >> N >> M;
  int X[M];
  for(int ii=0;ii<M;ii++){
    cin >> X[ii];
  }
  sort(X,X+M);
  int sa[M];
  for(int ii=0;ii<M;ii++){
    if(ii==0)sa[ii]=0;
    else sa[ii]=X[ii]-X[ii-1];
  }
  sort(sa,sa+M);
  /*  for(int ii=0;ii<M;ii++){
    cout << sa[ii] << endl;
    }*/
  int ans=0;
  for(int ii=0;ii<M-N+1;ii++){
    ans+=sa[ii];
  }
  cout << ans << endl;
}


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

int main(){
  char c; //入力
  cin >> c;
  string boinList; //文字列変数
  boinList = "aiueo";
  bool boin;
  
  for(int i=0;i<boinList.size();i++){
    if(boinList.at(i) == c){
      boin = true;
      break;
    } else {
      boin = false;
    }
  }
  
  if(boin){
      cout << "vowel";
  } else {
      cout << "consonant";
  }
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define sort(a)         sort((a).begin(), (a).end())
#define uniq(a)         SORT(a);(a).erase(unique((a).begin(), (a).end()), (a).end())
#define reverse(a)      reverse((a).begin(), (a).end())
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define Yes()           printf("Yes\n")
#define No()            printf("No\n")
#define YES()           printf("YES\n")
#define NO()            printf("NO\n")
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }

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

const ll MOD = 1000000007; // 10^9 + 7

void solve() {
  int a, b; cin >> a >> b;
  outl((b - a) * (b - a - 1) / 2 - a);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


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

using namespace std;

int main() {
	string s;
	cin >> s;
	int num;
	cin >> num;
	
	vector<string> subs;
	subs.reserve(1000000);
	int size = s.size();
	for (int i = 0; i < size; ++i) {
		for (int j = 1; i + j <= size && j <= 5; ++j) {
			string sub = s.substr(i, j);
			for(int k = 0; k < num; ++k) {
				int subsSize = subs.size();
				if (subsSize <= k) {
					subs.push_back(sub);
					break;
				}
				
				if (subs[k] == sub) {
					break;
				}
				
				if (subs[k] > sub) {
					subs.insert(subs.begin() + k, sub);
					break;
				}
			}
		}
	}
	
	cout << subs[num - 1] << endl;
	
	return 0;
}

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

using namespace std;

const long long int MOD = 1e9+7;

long long modpow(long long a, long long n, long long mod)
{
    long long res = 1;
    while(n>0)
    {
        if(n&1) res = res * a % mod; // 1が立っていたら，計算に算入する．
        a *= a % mod ; // ダブリング
        n >>= 1; // bit演算で，右シフトさせる.
    }
    return res;
}

int main()
{
    int N;
    cin >> N ;
    // vector<int> A;
    vector<int> cnt(N,0);

    for (int i=0; i<N; ++i)
    {
        int tmp;
        cin >> tmp;
        // A.push_back(tmp);
        cnt[tmp] += 1;
    }

    bool can = true;
    if(N%2 != 0)
    {
        if(cnt[0] != 1) can = false;

        for(int i=1; i<N; ++i)
        {
            if(i%2 != 0) continue;

            if(cnt[i] != 2)
            {
                can = false;
                break;
            }
        }
    }
    else
    {
        if(cnt[0] != 0) can = false;

        for(int i=1; i<N; ++i)
        {
            if(i%2 == 0) continue;
            
            if(cnt[i] != 2)
            {
                can = false;
                break;
            }
        }

    }

    // long long ans = modpow(2,(int)N/2,MOD);
	long long ans = 1;
	for (int i = 0; i < N/2; ++i)
    {
		ans *= 2;
		ans %= MOD;
	}


    if(can) cout << ans << endl;
    else cout << 0 << endl;

    return 0;
}

Measured memory_bytes: 640
#include<iostream>
using namespace std;
int main(void)
{
int x;
while(cin>>x)
{
int a[10]={1,2,4,8,16,32,64,128,256,512};
int b[10]={0};

int j=0;
for(int i=9;i>=0;i--)
{
	if(x>=a[i])
	{
	x-=a[i];
	b[j]=a[i];
	j++;
	if(x==0)break;
	}
}
for(int i=9;i>=0;i--)
{
if(b[i]!=0)cout<<b[i]<<(i==0?"\n":" ");
}
}
return 0;
}

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

using namespace std ;

const int MAX = 1e5 + 10 ;
int par[MAX] , sz[MAX] ;
int n ;

void init()
{
	for(int i = 0 ; i < MAX ; ++i)
		par[i] = i , sz[i] = 1; 
}

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

void Union(int x , int y)
{
	int a = root(x) ; 
	int b = root(y) ;
	par[a] = b ;
	sz[b] += sz[a] ;
}

bool cmp(pair<int , pair<int , int> >&a , pair<int , pair<int , int> >&b)
{
	return a.second.first < b.second.first;
}

int main()
{
	init() ;
	ios_base::sync_with_stdio(0) ;
	cin.tie(0) ;
	cin>>n ;
	vector< pair<int , pair<int , int> > >vp ;
	for(int i = 0 ; i < n ; ++i)
	{
		int x , y ;
		cin>>x>>y ;
		vp.push_back({x , {y , i}}) ;
	}
	sort(vp.begin() , vp.end()) ;
	vector< pair<int , pair<int , int> > >edges ;
	for(int i = 0 ; i < n-1 ; ++i)
		edges.push_back({vp[i+1].first - vp[i].first , {vp[i].second.second , vp[i+1].second.second}}) ;
	sort(vp.begin() , vp.end() , cmp) ;
	for(int i = 0 ; i < n-1 ; ++i)
		edges.push_back({vp[i+1].second.first - vp[i].second.first , {vp[i].second.second , vp[i+1].second.second}}) ;
	sort(edges.begin() , edges.end()) ;
	long long ans = 0ll ;
	for(auto &i : edges)
	{
		if(root(i.second.first) == root(i.second.second))
			continue ;
		Union(i.second.first , i.second.second) ;
		ans += (i.first * 1ll) ;
	}
	return cout<<ans<<"\n" , 0 ;
}

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

int main() {
	int n;cin>>n;
	long long a[n];
	long long ans=0;
	for(int i=0;i<n;i++){
		cin>>a[i];
		ans+=a[i]-1;
	}
	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 256
x,k,d=map(int,input().split())

x=abs(x)

cnt=abs(x)//d


if cnt>=k:
    print(x-d*k)
else:
    k-=cnt

    if k%2==0:
        print(abs(x-d*cnt))
    else:
        print(abs(x-d*(cnt+1)))



Measured memory_bytes: 8956
#include<bits/stdc++.h>
using namespace std;int f,Q,T,F,x,y;char S[1<<20];main(){for(x=3e5,cin>>S+x>>Q,y=strlen(S+x)+x;Q--&&cin>>T;)if(T&1)f^=1;else cin>>F,cin>>S[F-1^f?y++:--x];if(f)reverse(S+x,S+y);cout<<S+x;}

Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
cin>>n;
string s;
cin>>s;
long long ans=0;
for(int i=0;i<s.size()-2;i++){
    if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C'){
        ans++;
    }
}
cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
A = [int(input()) for _ in range(N)]
A.sort()
cnt = 1
ans = 0
if len(A) == 1:
    print(1)
    exit()
for i in range(1,N):
    if A[i-1] == A[i]:
        cnt += 1
    else:
        ans += cnt%2
        cnt = 1
if cnt >= 1:
    ans += cnt%2
print(ans)

Measured memory_bytes: 7388
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007

int main() {
  
  int N,M;
  cin >> N >> M;

  long long d = 0;
  for(int i = 0;i < M;i++) {
    int a;
    cin >> a;
    d += a;
  }

  if(d <= N) cout << N-d << endl;
  else cout << -1 << endl;


}


Measured memory_bytes: 3632
S=input()
N=len(S)
flag=0
for i in range((N-1)//4):
	if S[i]!=S[(N-1)//2 -i-1]:
		flag=1
		break
	if S[(N+3)//2 +i-1]!=S[N-1-i]:
		flag=1
		break
for j in range((N-1)//2):
	if S[j]!=S[N-1-j]:
		flag=1
		break
if flag==0:
	print("Yes")
else:
	print("No")

Measured memory_bytes: 3064
import java.util.*;
 
public class Main{
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        int a = in.nextInt();
        int b = in.nextInt();
        String sa = "", sb = "";
        for (int i = 0; i < a; i++) sa += b;
        for (int i = 0; i < b; i++) sb += a;
        if (sa.compareTo(sb) < 0) System.out.println(sa);
        else System.out.println(sb);
        in.close();
    }
}


Measured memory_bytes: 21844
package main

import "fmt"

func main() {
	var N, sum, q int
	fmt.Scan(&N)
	q = N
	for {
		sum += q % 10
		q /= 10
		if q == 0 {
			break
		}
	}
	if N%sum == 0 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 512
#include<stdio.h>

int main() {
	int n, a[100], max, min, i;
	if (scanf("%d", &n) == 0) return 1;
	for (i = 0; i < n; i++) if (scanf("%d", &a[i]) == 0) return 1;
	max = 0; min = 1000000000;
	for (i = 0; i < n; i++) {
		if (max < a[i]) max = a[i];
		if (min > a[i]) min = a[i];
	}
	printf("%d", max - min);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    ll n,i,num,sum=0;
    cin>>n;
    num=n;
    while(num>0){
        sum+=(num%10);
        num/=10;
    }
    if(n%sum==0)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}


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

vector<int> to[100005];
vector<bool> visited;
void dfs(int i){
    visited[i] = true;
    for(int k : to[i]){
        if(visited[k])continue;
        dfs(k);
    }
}

int main()
{
    // input
    int n,m;
    cin >> n >> m;
    rep(i,m){
        int x,y,z;
        cin >> x >> y >> z;
        x--;y--;
        to[x].emplace_back(y);
        to[y].emplace_back(x);
    }

    // solve
    visited.resize(n);
    int ans=0;
    rep(i,n){
        if(visited[i])continue;
        dfs(i);
        ans++;
    }


    // output
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 8832
n,a,b = map(int,input().split())
s= input()
count_a=0
count_b=0

for i in range(n) :
    if s[i] == 'a' :
        if count_a + count_b < a+b :
            count_a += 1
            print('Yes')

        else :
            print('No')
        
    if s[i] == 'b' :
        if count_a + count_b < a+b and count_b < b :
            count_b += 1
            print('Yes')

        else :
            print('No')
    
    if s[i] =='c' :
        print('No')

Measured memory_bytes: 4244
#include "stdio.h"
#include "string.h"

void sort_up(char* str)
{
	int i, j;
	char temp;
	int len = strlen(str);

	for(i=0;i<len+1;i++){
		for(j=0;j<len+1-i;j++){
			if(str[j]<str[j+1]) {
				temp = str[j];
				str[j] = str[j+1];
				str[j+1] = temp;
			}
		}
	}
}

void sort_down(char* str)
{
	int i, j;
	char temp;
	int len = strlen(str);

	for(i=0;i<len-1;i++){
		for(j=0;j<len-1-i;j++){
			if(str[j]>str[j+1]) {
				temp = str[j];
				str[j] = str[j+1];
				str[j+1] = temp;
			}
		}
	}
}


int main(void){
	char str1[100];
	char str2[100];
	int i;

	memset(str1, NULL, 100);
	memset(str2, NULL, 100);

	scanf("%s%s", str1, str2);

	sort_down(str1);
	sort_up(str2);

	for(i=0;i<100;i++){
		if(str1[i]<str2[i]){
			printf("Yes\n");
			return 0;
		}
		if(str1[i]>str2[i]){
			printf("No\n");
			return 0;
		}
	}

	printf("No\n");
	return 0;
}

Measured memory_bytes: 128
package main

import (
        "bufio"
        "fmt"
        "os"
        "strings"
)

func solution(s string) string {
        var memo [26]bool

        for _, r := range s {
                memo[r-'a'] = true
        }
        for i := range memo {
                if !memo[i] {
                        return string(i + 'a')
                }
        }
        return "None"
}

func main() {
        reader := bufio.NewReaderSize(os.Stdin, 10240*10240)
        str, _, _ := reader.ReadLine()
        fmt.Println(solution(strings.TrimRight(string(str), "\r\n")))
}

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

typedef long long ll;

ll A, B;

vector<ll> divisors(ll n) {
    vector<ll> res;
    for(ll i = 1; i*i <= n; ++i) {
        if(n % i != 0) continue;
        res.push_back(i);
        if(n/i == i) continue; // 上の行で追加済み。
        res.push_back(n/i);
    }
    return res;
}

bool is_prime(ll n) {
    if(n == 1) return true; // 問題の都合上 
    for(ll i = 2; i*i <= n; ++i) { // 2 <= i <= sqrt(n) に約数があれば、
        if(n % i == 0) return false; // n は素数ではない
    }
    return true;
}

int main() {
    cin >> A >> B;
    map<ll, ll> mp;

    vector<ll> a1 = divisors(A);
    vector<ll> a2 = divisors(B);

    for (ll i = 0; i < a1.size(); i++) {
        mp[a1[i]]++;
    }

    for (ll i = 0; i < a2.size(); i++) {
        mp[a2[i]]++;
    }

    // for (auto i = mp.begin(); i != mp.end(); i++) {
    //     cout << i->first << " " << i->second << endl;
    // }

    vector<ll> target;
    for (auto i = mp.begin(); i != mp.end(); i++) {
        // 2かどうか 
        if (i->second != 2) continue;
        // 素数かどうか
        if (!is_prime(i->first)) continue;

        target.push_back(i->first);
    }

    ll n = target.size();
    cout << n << endl;
    // if (n == 0) {
    //     cout << 1 << endl;
    // } else {
    //     ll ans = 0;
    //     ans = 1 * n;
    //     ans += n * (n - 1) / 2;
    // }

    // for (ll i = 0; i < target.size(); i++) {
    //     cout << target[i] << endl;
    // }
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define for0(n) for(i=0; i<(n); i++)
#define for1(n) for(i=1; i<=(n); i++)
#define M 1000000007


int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll _,i,j,n,a,b,e,k,u,t,x=1,m,y,q,f=1,c=0,d=0,l,p,z,o,r,g;
    string ss,s;
    cin>>s;
    if(s[s.size()-1]=='s')cout<<s+"es"<<endl;
    else cout<<s+"s"<<endl;
}



Measured memory_bytes: 3628
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int n,a,b,c;
  cin>>n;
  int dp[n][3]={};
  for(int i=0;i<n;i++){
    cin>>a>>b>>c;
    if(!i){dp[i][0]=a;dp[i][1]=b,dp[i][2]=c;}
    else {
      dp[i][0]=a+max(dp[i-1][1],dp[i-1][2]);
      dp[i][1]=b+max(dp[i-1][0],dp[i-1][2]);
      dp[i][2]=c+max(dp[i-1][0],dp[i-1][1]);
    }
  }
  cout<<max({dp[n-1][0],dp[n-1][1],dp[n-1][2]})<<endl;
  return 0;
}

Measured memory_bytes: 1408
#include <stdio.h>

int main(void){
    int H,W;
    int i,j;

    while(1){
        scanf("%d %d", &H,&W);
        if (H == 0 &&  W == 0){
            break;
        }
        else{
            for (i = 0; i < H; i ++){
                for (j = 0; j < W; j++){
                    if(i == 0 || i == H-1){
                        printf("#");
                    }
                    else if (j == 0 || j == W-1){
                        printf("#");
                    }
                    else{
                        printf(".");
                    }
                }
                printf("\n");
            }
            printf("\n");
        }
    }
    return(0);
}

Measured memory_bytes: 572
#include<stdio.h>

double factorial(double a){
  double b;
  if(a==1){
    b=1;
  }else{
    b=a*factorial(a-1);
  }
  return b;
}

int main(void){
  double n,f;
  scanf("%lf",&n);
  f=factorial(n);
  printf("%.0f\n",f);
  return 0;
}

Measured memory_bytes: 648
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-15
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int N;
	int a[200001];
	int maxmod;
	vint plusindex[2],minusindex[2];
	ll ans[2]={0},ansmax;
	int minusmax=-INF,maxindex;
	queue<int> tejun;
	int hajimekesu=0;
	scan(N);
	rep(i,N){
		scan(a[i]);
		if(a[i]>0){
			ans[i%2]+=a[i];
			plusindex[i%2].push_back(i);
		}
		else{
			minusindex[i%2].push_back(i);
		}
		if(a[i]>minusmax){
			minusmax=a[i];
			maxindex=i;
		}
	}
	if(minusmax<=0){
		ansmax=minusmax;
		for(int i=N;i>maxindex+1;i--){
			tejun.push(i);
		}
		for(int i=1;i<=maxindex;i++){
			tejun.push(1);
		}
	}
	else{
		if(ans[0]>ans[1]){
			maxmod=0;
			ansmax=ans[0];
		}
		else{
			maxmod=1;
			ansmax=ans[1];
		}
		if(N%2==maxmod){
			tejun.push(N);
			N--;
		}
		for(int i=minusindex[maxmod].size()-1;i>=0;i--){
			tejun.push(minusindex[maxmod].back()+1-hajimekesu);
			if(minusindex[maxmod].back()+1==N||minusindex[maxmod].back()+1==1){
				if(minusindex[maxmod].back()+1==1){
					tejun.push(1);
					N--;
				}
				N--;
			}
			else N-=2;
			minusindex[maxmod].pop_back();
		}
		if(N%2==maxmod){
			tejun.push(N);
			N--;
		}
		for(int i=N-1;i>0;i-=2){
			tejun.push(i);
		}
	}
	prin(ansmax);prin(tejun.size());
	while(!tejun.empty()){
		prin(tejun.front());
		tejun.pop();
	}
	return 0;
}


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


int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    char c;
    cin >> c;
    if (c >= 'A' && c <= 'Z') cout << 'A';
    else cout << 'a';
    cout << endl;
    return 0;
}



Measured memory_bytes: 3612
#include <iostream>
#include <string>
#include <cstdint>
#include <algorithm>
#include <cmath>

int main()
{
	std::string S;
	int Q;

	std::cin >> S;
	std::cin >> Q;

	std::string str[2];
	int head_index = 0;
	int op, f;
	char c;
	for (int i = 0; i < Q; ++i)
	{
		std::cin >> op;
		if (op == 1)
		{
			head_index = 1 - head_index;
		}
		else if (op == 2)
		{
			std::cin >> f >> c;
			if (f == 1)
			{
				str[head_index].push_back(c);
			}
			else
			{
				str[1 - head_index].push_back(c);
			}
		}
	}

	std::reverse(str[head_index].begin(), str[head_index].end());
	if(head_index != 0)
	{
		std::reverse(S.begin(), S.end());
	}
	std::cout << str[head_index] + S << str[1 - head_index] << std::endl;

	return 0;
}

Measured memory_bytes: 1308
#[allow(unused_imports)]
use std::cmp::{Ordering};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};

#[allow(unused_imports)]
use std::iter::FromIterator;

#[allow(unused_macros)]
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::min($x, min!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::max($x, max!($($z),*))
    }}
}

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

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

const BIG_STACK_SIZE: bool = true;

#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

fn solve() {
    let k = get!(usize);
    let vec = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51];
    println!("{}", vec[k-1]);
}


Measured memory_bytes: 8572
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

#define rep(i, n)       rep2 (i, 0, n)
#define rep2(i, m, n)   for  (int i = (int)(m); i < (int)(n); ++i)

typedef pair<int, int> pi;

int main()
{
    int n, h, m, s;
    while (scanf("%d", &n), n) {
        vector<pi> v;
        rep (i, n) {
            scanf("%d:%d:%d", &h, &m, &s);
            v.push_back((pi){ h * 3600 + m * 60 + s, 1 });
            scanf("%d:%d:%d", &h, &m, &s);
            v.push_back((pi){ h * 3600 + m * 60 + s, -1 });
        }
        sort(v.begin(), v.end());
        
        int ans = 0, cur = 0;
        rep (i, v.size()) {
            cur += v[i].second;
            ans = max(ans, cur);
        }
        
        printf("%d\n", ans);
    }
}

Measured memory_bytes: 1284
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define mp make_pair
#define pb push_back
#define pll pair<ll,ll>
ll INF = 1000000007;


//-----------------//
  #define amin main
//-----------------//


int amin()
{
	
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll t,i,j;
	ll n;
	cin>>n;
	ll k;
	cin>>k;
	ll arr[n];
	for(i=0;i<n;i++)
		cin>>arr[i];
	ll low  = 1;
	ll high = 1e9+2;
	ll mid= 0;
	while(low<=high)
	{
		mid = (low+high)/2;
		//bin(mid);

		ll sum =0;
		for(i=0;i<n;i++)
		{
			sum += (arr[i]-1)/mid;
		}
		if(sum<=k)
		{
			high=  mid-1;
		}
		else if(sum>k)
		{
			low = mid+1;
		}
		
		//cout<<mid<<" "<<sum<<endl;


	}
	//cout<<mid<<endl;
	 ll sum = 0;
	 ll sum2= 0;
	 for(i=0;i<n;i++)
	{
		if(mid-1>0)
		sum2 += (arr[i]-1)/(mid-1);	
		else
			sum2 = INF;
	}
	ll sum1 = 0;

	for(i=0;i<n;i++)
	{
		sum += (arr[i]-1)/mid;	
	}
	//ll sum1 = 0;
	//ll sum = 0;
	for(i=0;i<n;i++)
	{
		sum1 += (arr[i]-1)/(mid+1);	
	}
	if(sum2<=k)
	{
		cout<<mid-1<<endl;
	}
	else if(sum<=k)
		cout<<mid<<endl;
	else
		cout<<mid+1<<endl;
	
	


	
	return 0;
}

Measured memory_bytes: 5148
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define mod 1000000007
#include<string.h>
#define inf 9000000000000000000
#define maxn 200006
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
#define endl '\n'
#define mapint_iterator map<int,int> :: iterator
#define mapll_iterator map<ll,ll> :: iterator
#define setint_iterator set<int> :: iterator
#define setll_iterator set<ll> :: iterator
#define setpint_iterator set<pint> :: iterator
#define setpll_iterator set<pll> :: iterator
#define trace(x) cout<<#x<<": "<<x<<" "<<endl
#define trace2(x,y) cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x,y,z) cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a,b,c,d) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define cout1(a) cout<<a<<endl
#define cout2(a,b) cout<<a<<' '<<b<<endl
#define cout3(a,b,c) cout<<a<<" "<<b<<" "<<c<<endl
#define cout4(a,b,c,d) cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl
#define vcout(v,i) cout<<v[i].fi<<" "<<v[i].se<<endl
typedef priority_queue<ll,vector<ll>,greater<ll> > pqset;
typedef priority_queue<pint,vector<pint>,greater<pint> > pqset_ll;
#define pb push_back
#define fi first
#define se second
#include<ext/pb_ds/assoc_container.hpp>
ll dxk[]={0,0,1,-1,1,1,-1,-1};
ll dyk[]={1,-1,0,0,1,-1,1,-1};
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> os;
typedef tree<pll,null_type,less<pll>,rb_tree_tag,tree_order_statistics_node_update> os_pair;
#define acc (ios::sync_with_stdio(false),cin.tie(0))
#define rep(i,n) for(ll i=0;i<n;i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define per1(i,n) for(ll i=n;i>0;i--)
#define repeat(i,start,n) for(ll i=start;i<n;i++)
#define print(a,n) for(ll i=0;i<n;i++){ cout<<a[i]<<" ";}
ll ll_max(ll a,ll b,ll c){return max(a,max(b,c));}
int int_max(int a,int b,int c){return max(a,max(b,c));}
ll ll_min(ll a,ll b,ll c){return min(a,min(b,c));}
int int_min(int a,int b,int c){return min(a,min(b,c));}
ll max(int a,ll b){ return max((ll)a,b);}
ll min(int a,ll b){ return min((ll)a,b);} 
ll min(ll a,int b){ return min(a,(ll)b);}
ll max(ll a,int b){ return max(a,(ll)b);}
ll dx[]={0,0,1,-1};
ll dy[]={1,-1,0,0};
//ifstream cin("b_read_on.txt"); ofstream cout("output3.txt");
//Chronology: Binary Search,Greedy,dp,dfs and similar
//Use (<<) for multiplication
//Use (>>) for division
// In dp, first try top-down,then bottom-up
//ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);cout<<fixed;cerr.tie(NULL);cout.precision(10);
// find_by_order -> value at index
// order_of_key -> index of value
void solve(int countu){
	double r;
	cin>>r;
	r*=(double)6.28318530717958623200;
	cout.precision(10);
	cout1(r);
}
int main(){
    int t=1;
	//scanf("%d",&t);
	int countu=1;
    while(t--){
    	solve(countu);
    	countu++;
    }
}

Measured memory_bytes: 3792
#include<bits/stdc++.h>
using namespace std;
int a[3005];
int main(){
	int r,d,x;
	scanf("%d%d%d",&r,&d,&x);
	for(int i=1;i<=10;i++){
		printf("%d\n",r*x-d);
		x=r*x-d;
	}
		
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
	int i,j, d, n;
	int divide,ans;

	scanf("%d%d", &d, &n);

	if (d == 0)
		divide = 1;
	if (d == 1)
		divide = 100;
	if (d == 2)
		divide = 10000;

	ans = divide*n;
	if (n == 100)
		ans += divide;

	printf("%d\n",ans);

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  ll l, r;
  cin >> l >> r;
  ll m = 2019;
  if (r-l >= 2018) {
    cout << 0 << endl;
    return 0;
  }
  
  ll ans = 2019;
  for (ll i = l; i < r; i++) {
    for (ll j = i+1; j <= r; j++) {
      ans = min(ans, i*j%m);
    }
  }

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

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


int main(){

    int D;
    cin >> D;
    
    if( D == 22 ) cout << "Christmas Eve Eve Eve" << endl;
    else if( D == 23 ) cout << "Christmas Eve Eve" << endl;
    else if( D == 24 ) cout << "Christmas Eve" << endl;
    else cout << "Christmas" << endl;

    return 0;

}

Measured memory_bytes: 256
#include <iostream>
 
void show_ret(int home[][10], bool use_partition) {
    for(int i= 0; i < 3; i++) {
        for(int j = 0; j < 10; j++) {
            std::cout << " " << home[i][j];
        }
        std::cout << std::endl;
    }
    if(use_partition) std::cout << "####################" << std::endl;
}

int main(int argc, char *argv[]) {
    int home1[3][10] = {{0}};
    int home2[3][10] = {{0}};
    int home3[3][10] = {{0}};
    int home4[3][10] = {{0}};
    int n, b, f, r, v = 0;
 
    std::cin >> n;      
    for(int i = 0; i < n; i++) {
        std::cin >> b >> f >> r >> v;
        switch(b) {     
            case 1:     
                home1[f-1][r-1] += v;
                break;  
            case 2:     
                home2[f-1][r-1] += v;
                break;  
            case 3:     
                home3[f-1][r-1] += v;
                break;  
            case 4:     
                home4[f-1][r-1] += v;
                break;  
        }
    }
    show_ret(home1, true);
    show_ret(home2, true);
    show_ret(home3, true);
    show_ret(home4, false);
    return 0;
}

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

typedef long long int ll;
typedef vector<long long>lve;
typedef vector<pair<ll,ll> > lvp;

#define sp         ' '
#define endl       '\n'
#define F          first
#define S          second
#define pp         pop_back`
#define pb         push_back
#define mp         make_pair 
#define GCD(x,y)   __gcd(x,y)
#define lb         lower_bound
#define up         upper_bound
#define bs         binary_search
#define all(x)     x.begin(),x.end()
#define LCM(x,y)   ((x*y)/__gcd(x,y))
#define spc(x)     cout<<fixed<<setprecision(x)

const   long long  inf = 1e18;
const   long long  cs =  200005;
const   long long  mod = 1000000007;
const   double     PI =  2 * acos(0.0);
void solve()
{
    ll t,n,m,a,b,c,d,e,i,j,k,x,y,z,cnt=0,cnt1=0;
    bool flag = false;   
    
    string s,s1;
    cin>>s>>s1;
    for(i=0;i<3;i++)
    {
        if(s[i]==s1[i]) cnt++;
    }
    cout<<cnt<<endl;
    
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);    cout.tie(NULL);

    // freopen ("input.txt","r",stdin);
    // freopen ("output.txt","w",stdout);

    // int32_t tc;
    // cin>>tc;
    // while(tc--)
    solve();

    return 0;
}


Measured memory_bytes: 3612
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;

int main() {
	int a, b, c;
	while(~scanf("%d %d %d", &a, &b, &c)) {
		printf("%d\n", (a - c) / (b + c));
	}
	return 0;
}

Measured memory_bytes: 128
import math

a,b = map(str,input().split())
a = int(a)

b1 = int(b[0]) * 100
b2 = int(b[2]) * 10
b3 = int(b[3])

ans = a * b1 + a * b2 + a * b3
ans = str(ans)

if len(ans) >= 3:
	print(ans[:-2])
else:
	print(0)


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

using namespace std;

string C(long long a, long long b, long long c) {
	if (a + b >= c)
		return "No";
	return (4 * a * b < (c - a - b) * (c - a - b)) ? "Yes" : "No";
}

int main() {
	double a, b, c;
	cin >> a >> b >> c;
	cout << C(a, b, c);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
ll knapSack(ll W, ll wt[], ll val[], ll n) 
{ 
   ll i, w; 
   ll K[n+1][W+1]; 
  
   // Build table K[][] in bottom up manner 
   for (i = 0; i <= n; i++) 
   { 
       for (w = 0; w <= W; w++) 
       { 
           if (i==0 || w==0) 
               K[i][w] = 0; 
           else if (wt[i-1] <= w) 
                 K[i][w] = max(val[i-1] + K[i-1][w-wt[i-1]],  K[i-1][w]); 
           else
                 K[i][w] = K[i-1][w]; 
       } 
   } 
  
   return K[n][W]; 
} 
int main(){
 	ll n , w;
 	cin >> n >> w;
  	ll wt[n];
	ll val[n];
  	for(int i=0;i<n;i++){
  		cin >> wt[i] >> val[i];
	}
	cout << knapSack(w,wt,val,n) << "\n";
	
	
}

Measured memory_bytes: 79104
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		int m = sc.nextInt();
		int l = sc.nextInt();
		int[][] dist = new int[n+1][n+1];
		for(int i = 0; i < m; i++){
		    int a = sc.nextInt();
		    int b = sc.nextInt();
		    int c = sc.nextInt();
		    dist[a][b] = c;
		    dist[b][a] = c;
		}
		int q = sc.nextInt();
		int[][] st = new int[q][2];
		for(int i = 0; i < q; i++){
		    st[i][0] = sc.nextInt();
		    st[i][1] = sc.nextInt();
		}

		// 計算
	    wf(dist);
	    int[][] dist2 = new int[n+1][n+1];
	    for(int i = 0; i < n+1; i++){
	        for(int j = 0; j < n+1; j++){
	            if(dist[i][j] <= l){
	                dist2[i][j] = 1;
	            }
	        }
	    }
	    wf(dist2);

		// 出力
		for(int i = 0; i < q; i++){
		    int result = -1;
		    if(dist2[st[i][0]][st[i][1]] != 1001001001) result = dist2[st[i][0]][st[i][1]] - 1;
		    System.out.println(result);
		}
        
	}
	
	static void wf(int[][] dist) {
		int n = dist[0].length;
		int INF = 1001001001;
		for(int i = 0; i < n; i++){
			for(int j = 0; j < n; j++){
				if(dist[i][j] == 0) dist[i][j] = INF;
				if(i == j) dist[i][j] = 0;
			}
		}

		for(int k = 0; k < n; k++){
			for(int i = 0; i < n; i++){
				for(int j = 0; j < n; j++){
					dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
				}
			}
		}
	}
}


Measured memory_bytes: 95280
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

int main()
{
    int N; cin >> N;
    vector<pair<int, int>> red(N), blue(N);
    vector<int> ans_red(N), ans_blue(N);
    rep (i, 0, N) {
        int a, b; cin >> a >> b;
        red[i] = make_pair(a, b);
    }
    rep (i, 0, N) {
        int c, d; cin >> c >> d;
        blue[i] = make_pair(c, d);
    }

    sort(blue.begin(), blue.end());
    sort(red.begin(), red.end(), [&red](pair<int, int> i, pair<int, int> j) {
        if (i.second != j.second) return i.second < j.second;
        else return i.first < j.first;
    });
    reverse(red.begin(), red.end());

    int ans = 0;
    rep (i, 0, blue.size()) {
        rep (j, 0, red.size()) {
            if (blue[i].first > red[j].first and blue[i].second > red[j].second) {
                ++ans;
                red.erase(red.begin()+j);
                break;
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
a, b = map(int, input().split())
if a <= 0 and b >= 0:
	ans = "Zero"
elif a > 0:
	ans = "Positive"
elif b < 0:
	if (b-a)%2 == 1:
		ans = "Positive"
	else:
		ans = "Negative"
print(ans)

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>  // Including tree_order_statistics_node_update

using namespace __gnu_pbds;
using namespace std;

#define sz(a) int((a).size())
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(), (c).end()
#define tr(c, i) for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define present(c, x) ((c).find(x) != (c).end())
#define cpresent(c, x) (find(all(c), x) != (c).end())
#define minei(x) min_element(x.begin(), x.end()) - (x).begin()
#define maxei(x) max_element(x.begin(), x.end()) - (x).begin()
#define LSOne(S) (S & (-S))

#define uns(v) sort((v).begin(), (v).end()), v.erase(unique(v.begin(), v.end()), v.end())
#define acusum(x) accumulate(x.begin(), x.end(), 0)
#define acumul(x) accumulate(x.begin(), x.end(), 1, multiplies<int>());
#define bits(x) __builtin_popcount(x)
#define oo INT_MAX
#define inf 1000000000
#define MAXN 1000007
#define MOD 1000000007

const double pi = acos(-1.0);
const double eps = 1e-11;

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

int main() {
    std::ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, m, s, c;
    cin >> n >> m;
    vector<int> nm(n, -1);
    bool found = true;
    for (int i = 0; i < m; i++) {
        cin >> s >> c;
        s--;
        if (nm[s] != -1 && (nm[s] != c)) {
            found = false;
        }
        nm[s] = c;
    }
    if (!found) {
        cout << "-1\n";
        return 0;
    }
    if (n == 1) {
        cout << (nm[0] == -1 ? 0 : nm[0]) << "\n";
    }
    if (n == 2) {
        if (nm[0] == 0) {
            cout << "-1\n";
            return 0;
        }
        if (nm[0] == -1) nm[0] = 1;
        if (nm[1] == -1) nm[1] = 0;
        cout << nm[0] * 10 + nm[1] << "\n";
    }
    if (n == 3) {
        if (nm[0] == 0) {
            cout << "-1\n";
            return 0;
        }
        if (nm[0] == -1) nm[0] = 1;
        if (nm[1] == -1) nm[1] = 0;
        if (nm[2] == -1) nm[2] = 0;
        cout << nm[0] * 100 + nm[1] * 10 + nm[2] << "\n";
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T> &p){ cout << "[" << p.first << ", " << p.second << "]"; return os; }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) vc<vc<T>> xs(n, vc<T>(m)); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << " "; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define Return(expr) { Cout(expr); return 0; }
#define vc vector
#define Mini(a, x) a = min(a, x)
#define Maxi(a, x) a = max(a, x)

// constexpr int MOD = 1e9+7;

int main(void){
    Cin(int, n);
    Cins(int, n, p);
    Cins(int, n, q);
    auto r = p;
    Sort(r);
    int i = 0, a = 0, b = 0;
    do{
       if(p == r) a = i;
       if(q == r) b = i;
       i ++;
    }
    while(next_permutation(Range(r)));
    Cout(abs(a-b));
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<typeinfo>
#include<vector>
#include<algorithm>
#include<map>
using namespace std;
typedef long long int ll;
int main()
{
	ll Q,H,S,D,N;
	cin >> Q >> H >> S >> D >> N;

	ll min_1=min({4*Q, 2*H, S});
	ll price=0;
	if(N%2){
		price=min_1;
		N--;
	}

	price += min({8*Q, 4*H, 2*S, D})*N/2;
	cout << price << 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 rrep(i, k, n) for (int i = k; i < (int)(n); i++)
#define repd(i, n) for (int i = n-1; i >= 0; i--)
#define rrepd(i, k, n) for (int i = n-1; i >= (int)(k); i--)
#define all(x) (x).begin(),(x).end()
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
//V,Pは大文字i,l,bは小文字
using ll = long long;
using Vi = vector<int>;
using VVi = vector<Vi>;
using Vl = vector<ll>;
using VVl = vector<Vl>;
using Vb = vector<bool>;
using VVb = vector<Vb>;
using P = pair<int,int>;
using Pll = pair<ll, ll>;
const ll mod = 1000000007;
const ll inf = 1000000000000;//10の12乗

int main() {
  string s;
  cin >> s;
  int a=0,b=0,c=0;
  rep(i,s.length()){
    char cc=s[i];
    if(cc=='a') a++;
    else if(cc=='b') b++;
    else c++;
  }
  int x=max(a,max(b,c));
  int y=min(a,min(b,c));

  if(x-y<=1) cout << "YES" << endl;
  else cout << "NO" << endl;
}


Measured memory_bytes: 3724
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using pll = pair<ll, ll>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(i) begin(i), end(i)

const int INF = 0x3fffffff;
const ll MINF = 0x7fffffffffff;
const ld DINF = numeric_limits<ld>::infinity();
const int MOD = 1000000007;
const int MODD = 998244353;
const ld EPS = 1e-9;
const ld PI = 3.1415926535897932;

template<class T> bool chmin(T &a, const T &b){ if(a > b){ a = b; return 1; } else return 0; }
template<class T> bool chmax(T &a, const T &b){ if(a < b){ a = b; return 1; } else return 0; }
template<class T> auto min(const T& a){ return *min_element(all(a)); }
template<class T> auto max(const T& a){ return *max_element(all(a)); }

ll gcd(ll a, ll b){ while(b){ ll c = b; b = a % b; a = c; } return a; }
ll lcm(ll a, ll b){ if(!a || !b) return 0; return a * b / gcd(a, b); }
ll pow_mod(ll n,ll k,ll m){ll r = 1;for(; k > 0;k >>= 1) {if (k & 1) r = (r * n) % m; n = (n * n) % m;}return r;}

//ここから。
int main(){
    ll n,k;
    cin >> n >> k;
    ll a[n];
    rep(i,n) cin >> a[i];

    ll ok = 1e9; //解が存在する値
    ll ng = 0; //解が存在しない値

    while(abs(ok - ng) > 1){
        ll mid = (ok + ng)/2;
        ll cnt = 0;
        rep(i,n){
            cnt += (a[i] + mid -1) / mid - 1;
        }
        if(cnt <= k){
            ok = mid;
        }else{
            ng = mid;
        }
    }
    cout << ok << endl;
}

Measured memory_bytes: 5060
#include <bits/stdc++.h>
using namespace std;
#define jaldi ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define kuch(a,n) for(ll i=0;i<n;i++) cin>>a[i]
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define pb push_back
#define bs(v,x)	binary_search(v.begin(),v.end(),x)
#define mci(b)	cout<<b<<"\n"
#define bvb(n)	long long n;cin>>n;

typedef long long ll;
typedef vector<long long> vll ;
typedef long double ld;
const ll maxn = 1e9, mod = 1e9 + 7;


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

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

int main()
{
	jaldi;
	bvb(n)
	ll arr[n];kuch(arr,n);
	vll dp(n,maxn);
	dp[0]=0;
	for(ll i=0;i<n;i++)
	{
		for(ll j=i+1;j<=i+2;j++)
		{
			if(j<n)
				dp[j]=min(dp[j],dp[i]+abs(arr[i]-arr[j]));
		}
	}
	cout<<dp[n-1]<<"\n";
	return 0;
}

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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1)
    printEoln();
  if (suc == 2)
    printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

template <class T, class U> void chmax(T &a, U b) {
  if (a < b)
    a = b;
}

template <class T, class U> void chmin(T &a, U b) {
  if (b < a)
    a = b;
}

template <class T> T Sq(const T &t) { return t * t; }

const int mod = 1e9 + 7;

const int limit = 50;
int n, m;
int a[limit], b[limit];
bool grapgh[limit][limit];
bool visited[limit];

void dfs(int v) {
  visited[v] = true;
  for (int v2 = 0; v2 < n; ++v2) {
    if (grapgh[v][v2] == false)
      continue;
    if (visited[v2] == true)
      continue;
    dfs(v2);
  }
}

signed main() {
  std::cin >> n >> m;
  REP(i, m) {
    std::cin >> a[i] >> b[i];
    a[i]--, b[i]--;
    grapgh[a[i]][b[i]] = grapgh[b[i]][a[i]] = true;
  }
  int ans = 0;
  REP(i, m) {
    grapgh[a[i]][b[i]] = grapgh[b[i]][a[i]] = false;
    REP(j, n) visited[j] = false;
    dfs(0);
    bool isBridge = false;
    REP(j, n) {
      if (!visited[j]) {
        isBridge = true;
        break;
      }
    }
    if (isBridge)
      ans++;
    grapgh[a[i]][b[i]] = grapgh[b[i]][a[i]] = true;
  }
  print(ans);
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<cstring>
using namespace std;
int s=5000;
int p,q,r;

void check(int a,int b,int c,int d){
	int e=abs(a-p)+abs(b-q)+abs(c-r)+d*10;
	if(e<s)s=e;
}

void check_all(int a,int b,int c,int d){
	if(a==0 || b==0 || c==0)return;
	check(a,b,c,d);
	check(a,c,b,d);
	check(b,a,c,d);
	check(b,c,a,d);
	check(c,a,b,d);
	check(c,b,a,d);
}

int main(){
	int n;
	int i,j,k,l;
	int t[10];
	int d[5];
	int a,b,c;
	cin>>n>>p>>q>>r;
	for(i=0;i<n;i++){
		cin>>t[i];
	}
	for(i=0;i<(1<<(2*n));i++){
		memset(d,0,sizeof(d));
		for(a=0,j=0;j<n;j++){
			k=0;
			if(i&(1<<(2*j+1)))k+=2;
			if(i&(1<<(2*j)))k++;
			if(k==0)continue;
			a++,d[k]+=t[j];
		}
		//cout<<d[1]<<" "<<d[2]<<" "<<d[3]<<" "<<a<<endl;
		check_all(d[1],d[2],d[3],a-3);
	}
	cout<<s<<endl;
	return 0;
}


Measured memory_bytes: 256