akhauriyash/Code-Regression huggingface dataset:
// finish date: 2018/08/19
#include <bits/stdc++.h>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>>
        vvvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<double> vd;
typedef vector<vector<double>> vvd;
typedef vector<vector<vector<double>>>
        vvvd;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, pair<int, int>> plii;
const int bigmod = 1000000007;
const int INF = 1050000000;
const long long INFll = 100000000000000000;


int main() {
    string S;
    ll K;
    cin >> S >> K;
    K--;
    rep(i, S.length()) {
        if (i == K) {
            cout << S[i] << endl;
            return 0;
        }
        if (S[i] != '1') {
            cout << S[i] << endl;
            return 0;
        }
    }


    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
	int num,i,j,temp,flag=1,count=0;
	scanf("%d",&num);
	int *p=(int *)malloc(sizeof(int)*num);
	for(i=0;i<num;i++)
	scanf("%d",&p[i]);
	i=num-1;
	while(i>0&&flag==1)
	{
		flag=0;
		for(j=0;j<i;j++)
		if(p[j]>p[j+1])
		{
			temp=p[j];
			p[j]=p[j+1];
			p[j+1]=temp;
			count++;
			flag=1;		
		}			
	}
	for(i=0;i<num;i++)
	{
		printf("%d",p[i]);
		if(i+1!=num)
		printf(" ");
	}
	printf("\n%d\n",count);
	return 0;
}

Measured memory_bytes: 1816
#include<iostream>
using namespace std;
int main(){
	int n; cin>>n;
	int a[2][100];
	for(int i=0;i<2;i++)
		for(int j=0;j<n;j++) cin>>a[i][j];
	int ans=0;
	for(int i=0;i<n;i++){
		int k=0;
		int temp=0;
		for(int j=0;j<n;j++){
			temp+=a[k][j];
			if(j==i){
				k=1;
				temp+=a[k][j];
			}
		}
		ans=max(temp,ans);
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define FORR(I,A,B) for(ll I=(B-1);I>=(A);I--)
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //ai>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //ai>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
#define TO(x,t,f) ((x)?(t):(f))
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define FILV(x,a) fill(x.begin(),x.end(),a)
#define FILA(ar,N,a) fill(ar,ar+N,a)
#define NEXTP(x) next_permutation(x.begin(),x.end())
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;else return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define pb push_back
#define pri(aa) cout<<(aa)<<endl
#define mp(x,y) make_pair(x,y)
#define fi first
#define se second
const ll INF=1e18+7;
const ll MOD=1e9+7;
const ll N = 2003;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n,x;
	cin>>n>>x;
	vector<ll> a(n);
	ll mina=INF;
	FOR(i,0,n){
		cin>>a[i];
		mina=min(mina,a[i]);
	}
	ll cost[n][n];
	FOR(i,0,n)cost[i][0]=a[i];
	FOR(i,0,n){
		FOR(m,1,n){
			ll l = i-m;
			if(l<0)l+=n;
			cost[i][m] = min(cost[i][m-1],a[l]);
		}
	}
	ll ans = mina*n+(n-1)*x;
	FOR(m,0,n){
		ll w=m*x;
		FOR(i,0,n){
			w+=cost[i][m];
		}
		ans = min(ans,w);
	}
	pri(ans);
}

Measured memory_bytes: 31488
#include<stdio.h>
#include<stdlib.h>

#define NEW(p,n){p=malloc((n)*sizeof(p[0]));if(p==NULL){printf("not enough memory\n");exit(1);};}
//pの型の変数n個の要素分のメモリを確保し、そのアドレスをpに代入するマクロ

#define INFTY 999999

typedef int* vector;
typedef vector* matrix;
typedef matrix* tmatrix;

//0-c-1の添字のものを作る(初期値0)
vector create_vector(int c){
    vector v;
    NEW(v,c);
    for(int i=0;i<c;i++){
        v[i]=0;
    }
    return v;
}

//0-b-1,0-c-1の添字のものを作る
matrix create_matrix(int b, int c){
    matrix M;
    NEW(M,b);
    for(int i=0;i<b;i++){
        M[i]=create_vector(c);
    }
    return M;
}

//0-a-1,0-b-1,0-c-1の添字のものを作る
tmatrix create_tmatrix(int a, int b, int c){
    tmatrix T;
    NEW(T,a);
    for(int i=0;i<a;i++){
        T[i]=create_matrix(b,c);
    }
    return T;
}

//サイズcのベクトルのメモリ解法
void free_vector(vector v, int c){
    free(v);
    return;
}

//サイズb,cのmatrixのメモリ解法
void free_matrix(matrix M, int b, int c){
    for(int i=0;i<b;i++){
        free_vector(M[i],c);
    }
    free(M);
    return;
}



int main(void){
    int N,M;
    scanf("%d %d",&N, &M);

    int* K;
    NEW(K,N+1); //K[i]を入れる

    matrix A;
    A=create_matrix(N+1,M+1); //A[i][j]

    for(int i=1;i<=N;i++){
        scanf("%d",&K[i]);
        for(int j=1;j<=K[i];j++){
            int c;
            scanf("%d",&c);
            A[i][c]=c;
        }
    }

    int ans=0;
    for(int i=1;i<=M;i++){
        int cari=0;
        for(int j=1;j<=N;j++){
            if(A[j][i]==0){
                cari=1;
                break;
            }
        }
        if(cari==0){
            ans++;
        }
    }

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

    return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int a = sc.nextInt();
		String ans = "";
		for(int i = 0 ;; i += a) {
			ans += s.charAt(i);
			if(i + a >= s.length()) break;
		}
		System.out.println(ans);
	}
}


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


void solve(long long N){
	if (N % 2 == 0) cout << N/2 << endl; 
	else cout << (N/2)+1 << 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(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef ENABLE_DEBUG_OUTPUT
#define DEBUG_LOG(s) cout << s << endl;
#else
#define DEBUG_LOG(s) void();
#endif

int main(){
    int m, n, x;
    cin >> n >> m >> x;

    vector<int> c(n);
    vector<vector<int>> a(n, vector<int>(m, 0));
    for (auto i = 0; i < n; i++) {
        cin >> c[i];
        for (auto j = 0; j < m; j++) {
            cin >> a[i][j];
        }
    }

    int64_t ans = INT64_MAX;
    for (auto i = 0; i < (1 << n); i++) {
        int64_t price = 0;
        bool flg = true;
        vector<int64_t> r(m);
        for (auto j = 0; j < n; j++) {
            if(i & (1 << j)) {
                price += c[j];
                for (auto k = 0; k < m; k++) {
                    r[k] += a[j][k];
                }
            }
        }
        for (auto j = 0; j < m; j++) {
            if(r[j] < x) {
                flg = false;
                break;
            }
        }
        if(flg) ans = min(ans, price);
    }

    cout << ((ans == INT64_MAX) ? -1 : ans) << endl;
    return 0;
}

Measured memory_bytes: 3640
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();

		ArrayList<Integer> list = new ArrayList<>();

		for (int i = 0; i < N; i++) {
			list.add(sc.nextInt());
		}

		Collections.sort(list);

		int num[] = new int[100010];
		for (int i = 0; i < N; i++) {
			num[list.get(i)]++;
		}

		int ans = 1;
		int cnt = 1;
		for (int j = 1; j < N-1; j++) {
			ans = Math.max(ans,num[j-1]+num[j]+num[j+1]);
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 48524
// Hail god Yato
 
#include <bits/stdc++.h> 
using namespace std;
 
#define hs ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
const ll mod = 1000000007;
const ll INF = 1e18;
const ll MAX = 100001;
//
//
void solve(){
    ll n;
    cin>>n;
    vector<ll> vec(n);
    set<ll> s;
    for(int i = 0; i < n; i++){
        cin>>vec[i];
        // s.insert(vec[i]);
    }
    // n = s.size();
    // // cout<<n;
    // vec.clear();
    // for(ll k : s)
    //     vec.push_back(k);

    ll ans = 0;
    for(int i = 0; i <n ; i++)
        for(int j = i+1; j < n; j++)
            for(int k = j+1; k < n; k++){
                ll sm = vec[i]+vec[j]+vec[k];
                if(vec[i]!=vec[j] && vec[i]!=vec[k] && vec[j]!=vec[k] && 2*vec[i] < sm &&  2*vec[j] < sm && 2*vec[k] < sm )
                    ++ans;
            }

    cout<<ans;
}
int main(){ 
        hs;
        ll t;
        t=1;
        // cin>>t;
        for (int i=1; i<=t; i++){
                //cout<<"Case #"<<i<<": ";
                solve();
         }
        return 0; 
}

Measured memory_bytes: 3568
#include<iostream>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<numeric>
#include<cmath>
#include<queue>
#include<set>
#include<map>
using namespace std;
using ulong = unsigned long;
using ll = long long;
const int M = 1e9 + 7;
#pragma unused(M)

int main(){
	int k, t;
	cin >> k >> t;
	priority_queue<int> pq;
	for(int i=0;i<t;i++){
		int a;
		cin >> a;
		pq.push(a);
	}

	int prev = pq.top(), next;
	pq.pop();
	prev--;
	while(!pq.empty()){
		next = pq.top();
		pq.pop();
		next--;
		if(prev){
			pq.push(prev);
		}
		prev = next;
	}
	cout << prev << endl;
	return 0;
}



Measured memory_bytes: 384
($n,$q)=glob<>;
$R=0;
@A=(0)x$n;$A[0]=1;$A[1]=1;
# print @A;
for(1..$q){
    <>=~$";
    ($A[$`-1],$A[$'-1])=($A[$'-1],$A[$`-1]);
    $R=($R==$`-1)?$'-1:$`-1 if($R==$`-1or$R==$'-1);
    # print $/,$R,$/;
    $A[$R]=1;
    $A[$R-1]=1 if($R>0);
    $A[$R+1]=1 if($R<$n);
    # print @A;
}
print$k=grep{$_}@A;

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

using namespace std;

typedef long long int lli;

int n,t,sol;
vector<int> all(3);

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    for(int i=0;i<3;i++)cin>>all[i];
    int a,b,c,d,e,f;
    a=(abs(all[2]-all[0])+abs(all[1]-all[2]));
    b=(abs(all[1]-all[0])+abs(all[2]-all[1]));
    c=(abs(all[1]-all[0])+abs(all[2]-all[0]));
    d=(abs(all[2]-all[1])+abs(all[0]-all[2]));
    e=(abs(all[2]-all[0])+abs(all[1]-all[0]));
    f=(abs(all[1]-all[2])+abs(all[0]-all[1]));
    a=min(a,b);b=min(c,d);c=min(e,f);
    cout<<min(a,min(b,c));
     return 0;
}


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

#define ED return 0;
#define SORT(vec) sort(vec.begin(),vec.end());
#define DOUBLECHANGE(count) cout << setprecision(count);
#define REV(vec) reverse(vec.begin(),vec.end());
#define ipow(x,y) int(pow(x,y))
const long mod = 1000000007;

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

void infect(int H,int W,int h, int w, vector<vector<bool>> &vec, bool infected){
    if(h != 0 && vec.at(h-1).at(w)){
        vec.at(h).at(w) = false;
        infect(H,W,h-1,w,vec,true);
    }
    if(w != 0 && vec.at(h).at(w-1)){
        vec.at(h).at(w) = false;
        infect(H,W,h,w-1,vec,true);
    }
    if(h != H-1 && vec.at(h+1).at(w)){
        vec.at(h).at(w) = false;
        infect(H,W,h+1,w,vec,true);
    }
    if(w != W-1 && vec.at(h).at(w+1)){
        vec.at(h).at(w) = false;
        infect(H,W,h,w+1,vec,true);
    }

    if(infected){
        vec.at(h).at(w) = false;
    }

    if(vec.at(h).at(w)){
        cout << "No" << endl;
        exit(0);
    }
}

int main() {
    int H, W;
    cin >> H >> W;
    vector<vector<bool>> vec;
    vec = vector<vector<bool>>(H, vector<bool>(W, false));
    for(int i = 0;i < H;i++){
        string test_s;
        cin >> test_s;
        for(int j = 0;j < W;j++){
            if(test_s.at(j) == '#'){
                vec.at(i).at(j) = true;
            }
        }
    }
    for(int h = 0;h < H;h++){
        for(int w = 0;w < W;w++){
            if(vec.at(h).at(w))
            infect(H,W,h,w,vec,false);
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
        #define endl '\n'
        #define modulo 1000000007
        #define int long long
        //#define __int128 long long
        #pragma GCC optimize("-Ofast")
        #define float double
        #define PI 3.141592653589793238462643383279502884
        #define sinDegrees(x) sin((x) * PI / 180.0)
        #define tanDegrees(x) tan((x) * PI / 180.0)
        #define atanDegrees(x) atan(x)* 180.0 / PI
        #define f first
       // #define s second
        using namespace std;
        int power(int x,int y,int m)
        {
        int temp;
        if(y == 0)
        return 1;
        temp = (power(x, y/2,m))%m;
        if (y%2 == 0)
        return ((temp%m)*temp);
        else
        return ((x*temp%m)*temp%m)%m;
        }
        int inv(int x)
        {
        return (power(x,modulo-2,modulo))%modulo;
        }
        bool comp(int a,int b)
        {
            return a>b;
        }
        ///Solution created by:Ahmadsm2005
        int32_t main()
        {
            //freopen("output.txt","w", stdout);
            //freopen("input0.txt","r", stdin);
            iostream::sync_with_stdio(0);
            cin.tie(0);
            cout.tie(0);
            int n,m;
            cin>>n>>m;
            m=(m*(m-1))/2;
            n=(n*(n-1))/2;
            cout<<m+n;
            return 0;
        }


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

#define fastIO                      \
  ios_base::sync_with_stdio(false); \
  cin.tie(NULL)
#define here cout << "here\n" // debug
#define int long long int
#define pb push_back
#define mp make_pair
#define pi pair<int, int>
#define sl(x) scanf("%lld", &x)
#define pfl(x) printf("%lld\n", x)
#define pf printf //debug
#define mod 1000000007
#define modu(x) x % 1000000007
#define isEqualf(a, b) (abs(a - b) < 1e-9) // comapre 2 float nums
#define inputVec(v, n)        \
  for (int i = 0; i < n; i++) \
  {                           \
    int d;                    \
    sl(d);                    \
    v[i] = d;                 \
  }

int32_t main()
{
  fastIO;

  int a;
  cin >> a;
  string s;
  cin >> s;
  if (a < 3200)
    pf("red\n");
  else
    pf("%s\n", s.c_str());
  return 0;
}

Measured memory_bytes: 256
#encoding=utf-8
import sys

def inp():
    fe, fe1 = [], []
    for line in sys.stdin:
        fe += line.split()
        
    i,j = 0,8
    while True:
        fe1 = fe[i:j]
        if a(fe1):
            if b(fe1):
                if c(fe1):
                    if d(fe1):
                        if e(fe1):
                            if f(fe1):
                                if g(fe1):
                                    pass

        i, j =i + 8,j + 8
        if j > len(fe): break

def a(fe1):
    for i in xrange(8):
        for j in xrange(8):
            if fe1[i][j] == "1":
                try:
                    if fe1[i][j+1]==fe1[i+1][j]==fe1[i+1][j+1]=="1":
                        print "A"
                        return False
                except:
                    pass
    return True

def b(fe1):
    for i in xrange(8):
        for j in xrange(8):
            if fe1[i][j] == "1":
                try:
                    if fe1[i+1][j]==fe1[i+2][j]==fe1[i+3][j]=="1":
                        print "B"
                        return False
                except:
                    pass
    return True

def c(fe1):
    for i in xrange(8):
        for j in xrange(8):
            if fe1[i][j] == "1":
                try:
                    if fe1[i][j+1]==fe1[i][j+2]==fe1[i][j+3]=="1":
                        print "C"
                        return False
                except:
                    pass
    return True

def d(fe1):
    for i in xrange(8):
        for j in xrange(8):
            if fe1[i][j] == "1":
                try:
                    if fe1[i+1][j-1]==fe1[i+1][j]==fe1[i+2][j-1]=="1":
                        print "D"
                        return False
                except:
                    pass
    return True

def e(fe1):
    for i in xrange(8):
        for j in xrange(8):
            if fe1[i][j] == "1":
                try:
                    if fe1[i][j+1]==fe1[i+1][j+1]==fe1[i+1][j+2]=="1":
                        print "E"
                        return False
                except:
                    pass
    return True

def f(fe1):
    for i in xrange(8):
        for j in xrange(8):
            if fe1[i][j] == "1":
                try:
                    if fe1[i+1][j]==fe1[i+1][j+1]==fe1[i+2][j+1]=="1":
                        print "F"
                        return False
                except:
                    pass
    return True

def g(fe1):
    for i in xrange(8):
        for j in xrange(8):
            if fe1[i][j] == "1":
                try:
                    if fe1[i][j+1]==fe1[i+1][j-1]==fe1[i+1][j]=="1":
                        print "G"
                        return False
                except:
                    pass
    return True

if __name__ == "__main__":
    inp()

Measured memory_bytes: 6444
n = int(input())
g = [[] * n for i in range(n)]
for i in range(n-1):
  u, v = map(int, input().split())
  u -= 1
  v -= 1
  g[u].append(v)
  g[v].append(u)
  
d = list(map(int,input().split()))
d.sort(reverse=True)

from collections import deque
 
que = deque()
que.append(0)
chk = [False]*n
chk[0] = True
ans = [0]*n
ans[0] = d[0]
cnt = 1
while que:
  now = que.popleft()
  if cnt == n:
    break
  for i in g[now]:
    if not chk[i]:
      chk[i] = True
      ans[i] = d[cnt]
      cnt += 1
      que.append(i)
      
print(sum(d[1:]) if n > 1 else 0)
print(*ans)

Measured memory_bytes: 11944
#include<iostream>
#include<vector>
#include<string>
#include<math.h>
#include<stdio.h>
#include<queue>
using namespace std;

int main()
{
	int a, b;
	cin >> a >> b;
	vector<string>name(a);

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

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

	string x = "";

	for (int i = 0; i < a; i++)
	{
		x = x + name[i];
	}

	cout << x << endl;

}



Measured memory_bytes: 3132
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111; 
using namespace std;
typedef long long lint;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	string s;
	cin >> s;
	lint Acnt = 0, ans = 0;
	s += 'X';//番兵

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

		if (i > 0 && s[i - 1] == 'B' && s[i] == 'A') Acnt = 0;
		if (s[i] == 'A') Acnt++;
		else if (i > 0 && s[i - 1] == 'B' && s[i] == 'C') ans += Acnt;
		else if (i > 0 && ((s[i - 1] == 'B' && s[i] == 'B') || (s[i - 1] == 'C' && s[i] == 'C') || (s[i - 1] == 'A' && s[i] == 'C'))) Acnt = 0;
	}

	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 720
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
const int INF = 1001001001;
int main(){
  int N;
  cin>>N;
  int64_t ans=1;
  for(int i=1;i<=N;i++){
   ans=ans*i%(1000000007);

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

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

class Main {
	public static void main(String[] args){
		Main.exec3();
	}
	
	static void exec1(){
		// http://abc064.contest.atcoder.jp/tasks/abc064_a
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String s;
		try {
			s = new String(in.readLine());
			s = s.replaceAll(" ", "");
			int i = Integer.parseInt(s);
			String opt;
			if(i%4 == 0) opt = "YES";
			else opt = "NO";
			System.out.println(opt);
		} catch (IOException e) {
			// TODO 自動生成された catch ブロック
			e.printStackTrace();
		}
	}
	
	static void exec2(){
		// http://abc064.contest.atcoder.jp/tasks/abc064_b
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String n_str, a_str;
		try {
			n_str = new String(in.readLine());
			a_str = new String(in.readLine());
			int n = Integer.parseInt(n_str);
			if(n<1 || n>100) throw new Exception();
			String[] a_str_arr = a_str.split(" ", 0);
			if(n != a_str_arr.length) throw new Exception();
			int max=0;
			int min=1000;
			for(int i=0; i<a_str_arr.length; i++){
				int a = Integer.parseInt(a_str_arr[i]);
				if(a<0 || a>1000) throw new Exception();
				if(max<a) max = a;
				if(min>a) min = a;
			}
			System.out.println(max-min);
			
		} catch (IOException e) {
			// TODO 自動生成された catch ブロック
			e.printStackTrace();
		} catch (Exception e) {
			// TODO 自動生成された catch ブロック
			e.printStackTrace();
		}
	}
	
	static void exec3(){
		// http://abc064.contest.atcoder.jp/tasks/abc064_c
		int[] color_rate = {400, 800, 1200, 1600, 2000, 2400, 2800, 3200, 4800};
		Boolean[] is_choosen_arr = new Boolean[8];
		Arrays.fill(is_choosen_arr, false);
		
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String n_str, a_str;
		try {
			n_str = new String(in.readLine());
			a_str = new String(in.readLine());
			int n = Integer.parseInt(n_str);
			if(n<1 || n>100) throw new Exception();
			String[] a_str_arr = a_str.split(" ", 0);
			if(n != a_str_arr.length) throw new Exception();
			
			int free_count = 0;
			for(int i=0; i<a_str_arr.length; i++){
				int a = Integer.parseInt(a_str_arr[i]);
				if(a<1 || a>4800) throw new Exception();
				for(int k=0; k<is_choosen_arr.length; k++){
					if(a < color_rate[k]){
						is_choosen_arr[k] = true;
						break;
					}
				}
				if(a >= color_rate[7]) free_count++;
			}
			int chosen_count = 0;
			for(int i=0; i<is_choosen_arr.length; i++){
				if(is_choosen_arr[i]) chosen_count++;
			}
			
			int min = chosen_count!=0 ? chosen_count: 1;
			int max = chosen_count+free_count;
			
			System.out.println(min + " " + max);
			
		} catch (IOException e) {
			e.printStackTrace();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}


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

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

const ll INF = 1LL<<60;
const ll MOD = 1000000007;

//cout << fixed << setprecision(10);

ll dp[50][500][500];


int main() {
    ll N,Ma,Mb;
    cin >> N >> Ma >> Mb;

    vector<ll> A(N),B(N),C(N);

    for(int i=0;i<N;i++) cin >> A[i] >> B[i] >> C[i];
    
    

    
    for(int i=0;i<N+5;i++){
        for(int j=0;j<500;j++){
            for(int l=0;l<500;l++){
                dp[i][j][l]=INF;
            }
        }
    }

    dp[0][0][0]=0;
    for(int i=0;i<N;i++){
        for(int j=0;j<500;j++){
            for(int k=0;k<500;k++){
                if(j-A[i]>=0 && k-B[i]>=0){
                    dp[i+1][j][k]=min(dp[i][j-A[i]][k-B[i]]+C[i],dp[i][j][k]);
                }
                else dp[i+1][j][k]=dp[i][j][k];
            }
        }
    }

    ll res=INF;

    for(int i=1;i<=N;i++){
        for(int j=0;j<500;j++){
            for(int k=0;k<500;k++){
                if(dp[i][j][k]!=INF && dp[i][j][k]!=0 && j%Ma==0 && k%Mb==0 && j/Ma==k/Mb){
                    res=min(res,dp[i][j][k]);
                }
            }
        }
    }

    cout << (res==INF?-1:res) << endl;



    return 0;
}

Measured memory_bytes: 88320
#include<cstdio>
#include<iostream>
using namespace std;
int n,h,w,a,b,x,y,z;
int main()
{
	cin>>n>>a>>b;
	for(int i=0;i<n;i++)
	{
		int k;
		cin>>k;
		if(k<=a) x++;
		else if(k>b) z++;
		else y++;
	}
	cout<<min(min(x,y),z);
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <numeric>

using namespace std;


int main(){
   int k,s;
   cin>>k>>s;
   int ans=0;
   for(int i=0;i<=k;i++){
       for(int j=0;j<=k;j++){
           if(s-i-j>=0 && s-i-j<=k)ans++;
       }
   }
   cout<<ans<<endl;
}
   


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

int main() {
  string s; 
  cin >> s;
  
  int count=0;
  for(int i=0;i<=2;i++)
  {
    if (s[i]=='1')
    {
      count++;
    }
  }
  
  cout << count << endl;
  
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;

int N;
int main(){
    cin >> N;
    vector<ll> A(N),X(N);
    for(int i=0;i<N;i++){
        cin >> A[i];
        if(i%2==0) X[0] += A[i];
        else X[0] -= A[i];
    }
    ll x = X[0]/2;
    for(int i=N-1;i>=0;i--){
        x = A[i]-x;
        X[i] = 2*x;
    }
//    X[] -= X[0];
    for(auto a:X) cout << a << " ";
    cout << endl;
}

Measured memory_bytes: 2944
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

int a,b,c;
void solve(){
  for(int i = 1; i*i <= abs(a); i++){
    if(a%i!=0)
      continue;
    for(int p = 0; p < 2; p++){
      vector<int> prv;
      prv.push_back(i);
      prv.push_back(a/i);
      if(p==1){
	prv[0]=-prv[0];
	prv[1]=-prv[1];
      }
      for(int j = 1; j*j <= abs(b); j++){
	if(b%j!=0)
	  continue;
	for(int m=0;m<2;m++){
	  vector<int> nxt;
	  nxt.push_back(j);
	  nxt.push_back(b/j);
	  if(m==1){
	    nxt[0]=-nxt[0];
	    nxt[1]=-nxt[1];
	  }
	  //ツ組ツ和ツつケツづ計ツ算
	  for(int k = 0; k < 2; k++){
	    for(int l = 0; l < 2; l++){
	      int sum=prv[0]*nxt[1]+prv[1]*nxt[0];
	      if(sum==c){
		vector<pair<int,int> > vpii;
		vpii.push_back(make_pair(prv[0],nxt[0]));
		vpii.push_back(make_pair(prv[1],nxt[1]));
		sort(vpii.begin(),vpii.end(),greater<pair<int,int> >());
		cout<<vpii[0].first<<" ";
		cout<<vpii[0].second<<" ";
		cout<<vpii[1].first<<" ";
		cout<<vpii[1].second<<endl;
		return;
	      }
	      swap(nxt[0],nxt[1]);
	    }
	    swap(prv[0],prv[1]);
	  }
	}
      }
    }
  }
  cout<<"Impossible"<<endl;
}

int main(){
  while(cin>>a>>c>>b&&!(a==0&&b==0&&c==0)){
    if(b==0){
      vector<pair<int,int> > vpii;
      vpii.push_back(make_pair(a,c));
      vpii.push_back(make_pair(1,0));
      sort(vpii.begin(),vpii.end(),greater<pair<int,int> >());
      cout<<vpii[0].first<<" ";
      cout<<vpii[0].second<<" ";
      cout<<vpii[1].first<<" ";
      cout<<vpii[1].second<<endl;
    }
    else
      solve();
  }
  return 0;
}

Measured memory_bytes: 0
N, Y = map(int, input().split())
res10 = -1
res5 = -1
res1 = -1
for i in range(N+1):
    for j in range(N+1):
        l = N-i-j
        if 10000*i + 5000*j + 1000*l == Y and i+j+l==N and l>=0:
            res10 = i
            res5 = j
            res1 = l
            break
print(res10, " ", res5, " ", res1)


Measured memory_bytes: 3316
# a, b, cで大きいサイズのものから数えていき、あるa, bのパーツに関してその下のパーツの組み合わせがいくつあるか数える。O(N)
def input():
    import sys
    return sys.stdin.readline().rstrip()


def main():
    import math
    import collections
    import itertools

    n = int(input())
    # 番兵
    as_ = [0] + sorted(list(map(int, input().split())))
    bs_ = [0] + sorted(list(map(int, input().split())))
    cs_ = [0] + sorted(list(map(int, input().split())))

    # その時点で成り立つ組み合わせの数
    n_combs = [0] * 3
    is_ = [n] * 3
    while is_[0] >= 1:
        # print((as_[is_[0]], 0), (bs_[is_[1]], 1), (cs_[is_[2]], 2))
        # 同じ数字の時、上のパーツが選ばれて欲しいため2つめに以下のような数字を入れている
        max_value = max((as_[is_[0]], 0, 0), (bs_[is_[1]], -1, 1), (cs_[is_[2]], -2, 2))
        posi = max_value[2]
        if posi == 2:
            n_combs[2] += 1
        else:
            n_combs[posi] += n_combs[posi + 1]
        is_[posi] -= 1
        
    print(n_combs[0])


if __name__ == '__main__':
    main()

Measured memory_bytes: 23480
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "iomanip"
#include "cmath"

using namespace std;

const long long int MOD = 1000000007;

long long int N, M, K, H, W, L, R;


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

	cin >> N >> M;
	vector<vector<int>>cha(M + 1, vector<int>(100002));
	vector<int>sum(100002);
	for (int i = 0; i < N; i++) {
		int a, b, c;
		cin >> a >> b >> c;
		cha[c][a - 1]++;
		cha[c][b]--;
	}
	for (int i = 1; i <= M; i++) {
		for (int j = 1; j < 100002; j++) {
			cha[i][j] += cha[i][j - 1];
		}
	}
	for (int i = 1; i <= M; i++) {
		L = -1;
		for (int j = 0; j < 100002; j++) {
			if (cha[i][j]) {
				if (L == -1) {
					L = j;
				}
			}
			else {
				if (L != -1) {
					sum[L]++;
					sum[j]--;
					L = -1;
				}
			}
		}
	}
	int ans = sum[0];
	for (int i = 1; i < 100002; i++) {
		sum[i] += sum[i - 1];
		ans = max(ans, sum[i]);
	}
	cout << ans << endl;
	return 0;
}


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

struct Prime {
  vector<bool> ch;
  vector<long long> ary;
  Prime(long long N = 20000000) {
    ch.resize(N + 1);
    ch[0] = ch[1] = 1;
    for(int i = 2; i <= N; ++i)
      if(!ch[i]) {
        ary.push_back(i);
        for(int j = 2; (long long)i * j <= N; ++j)
          ch[i * j] = 1;
      }
  }
  inline const bool isprime(int n) { return !ch[n]; }
  inline const long long &operator[](int k) const {
    return (ary[k]);
  }
};

int n;
long long cnt = 0;
Prime p;

int main() {
  int i;
  cin >> n;
  for(i = 2; i <= n; ++i)
    if(p.isprime(i) && p.isprime(2 + i)) cnt += 2;
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 21652
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<map>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
signed main(){
  ll n,p,ans=1,cnt;
  map<ll,ll> mp;
  cin >> n >> p;
  for(ll i=2;i*i<=p;i++){
    if(p%i==0){
      cnt = 0;
      while(p%i==0){
        p/=i;
        cnt++;
      }
      mp[i] = cnt;
    }
  }
  if(p!=1){
    mp[p] = 1;
  }
  for(auto i:mp){
    for(ll j=0;j<i.second/n;j++){
      ans *= i.first;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

// auto mod int
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {if ((x += a.x) >= mod) x -= mod; return *this;}
  mint& operator-=(const mint a) {if ((x += mod-a.x) >= mod) x -= mod; return *this;}
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

// combination mod prime
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

int main() {
  int x,y;
  cin >> x >> y;
  if((x+y)%3!=0){
    cout << 0 << endl;
    return 0;
  }
  int n = (x+y)/3;
  x -= n; y -= n;
  if(x<0||y<0){
    cout << 0 << endl;
    return 0;
  }
  combination c(n);
  cout << c(n,x) << endl;
}


Measured memory_bytes: 10624
#include<iostream>
#include<cmath>

using namespace std;

int main(void){
  int n;
  int a,b,c;

  cin >> n;
  for(int i = 0;i < n;i++){
    cin >> a >> b >> c;
    if(hypot(a,b) == c || hypot(b,c) == a || hypot(c,a) == b){
      cout << "YES" << endl;
    }
    else{
      cout << "NO" << endl;
    }
  } 
  return 0;
}

Measured memory_bytes: 0
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <string>
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>

#define mem(a, b) memset(a, (b), sizeof(a))
 
using namespace std;
typedef long long ll;

const int N = 2e5 + 10;
const int Max = 1e9 + 10;

int main(){
	int a, b ,c, d;
	cin >> a >> b >> c >> d;
	int aa = abs(a - b), bb = abs(b - c), cc = abs(a - c);
	if(cc <= d) printf("Yes\n");
	else if(aa <= d && bb <= d) printf("Yes\n");
	else printf("No\n");
}

Measured memory_bytes: 256
#include <limits>
#include <initializer_list>
#include <utility>
#include <bitset>
#include <tuple>
#include <type_traits>
#include <functional>
#include <string>
#include <array>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iterator>
#include <algorithm>
#include <complex>
#include <random>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <regex>
#include <cassert>
#include <cstddef>
#include <variant>

// Yay!!
#define endl codeforces

// macros for iterator
#define ALL(v) std::begin(v), std::end(v)
#define ALLR(v) std::rbegin(v), std::rend(v)

// alias
using ll = std::int64_t;
using ull = std::uint64_t;
using pii = std::pair<int, int>;
using tii = std::tuple<int, int, int>;
using pll = std::pair<ll, ll>;
using tll = std::tuple<ll, ll, ll>;
template <typename T> using vec = std::vector<T>;
template <typename T> using vvec = vec<vec<T>>;

// variadic min/max
template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return std::min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return std::max(t, var_max(tail...)); }

// variadic chmin/chmax
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }

// multi demension array
template <typename T, std::size_t Head, std::size_t... Tail> struct multi_dim_array { using type = std::array<typename multi_dim_array<T, Tail...>::type, Head>; };
template <typename T, std::size_t Head> struct multi_dim_array<T, Head> { using type = std::array<T, Head>; };
template <typename T, std::size_t... Args> using mdarray = typename multi_dim_array<T, Args...>::type;

// fill container
template <typename T, typename F, typename... Args> 
void fill_seq(T &t, F f, Args... args) { if constexpr (std::is_invocable<F, Args...>::value) { t = f(args...); } else { for (ssize_t i = 0; i < t.size(); i++) fill_seq(t[i], f, args..., i); } }

// make multi dimension vector
template <typename T> vec<T> make_v(ssize_t sz) { return vec<T>(sz); }
template <typename T, typename... Tail> auto make_v(ssize_t hs, Tail&&... ts) { auto v = std::move(make_v<T>(std::forward<Tail>(ts)...)); return vec<decltype(v)>(hs, v); }

// init
namespace init__ { 
struct InitIO { InitIO() { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); std::cout << std::fixed << std::setprecision(30); } } init_io; 
}


int main() {
    std::string s;
    std::cin >> s;
    ll n = s.back() - '0';
    if (n == 2 || n == 4 || n == 5 || n == 7 || n == 9) std::cout << "hon";
    else if (n == 0 || n == 1 || n == 6 || n == 8) std::cout << "pon";
    else std::cout << "bon";
    std::cout << "\n";
    return 0;
}


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


int main() {
    string S;
    cin >> S;

    ll sum = 0;
    string e;
    
    for (int tmp = 0; tmp < pow(2,(S.size()-1)); tmp++) {
        e = S[0];

        for (int i=0;i<S.size()-1;i++) {
            if ((tmp>>i)&1) {
                sum += stoll(e);
                e = S[i+1];
            }
            else {
                e += S[i+1];
            }
        }
        sum += stoll(e);
    }

    cout << sum << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{

	ios_base::sync_with_stdio(0);
	cout.tie(0);
	cin.tie(0);

// #ifndef ONLINE_JUDGE
// 	freopen("input.txt" , "r" , stdin);
// 	freopen("output.txt" , "w" , stdout);
// #endif

	int k, a, b;
	cin >> k >> a >> b;
	int z = b / k;
	z = z * k;
	if (z >= a && z <= b)
		cout << "OK";
	else
		cout << "NG";



}


Measured memory_bytes: 3612
//#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
//#include <queue>
//#include <stack>
#include <cstring>
#include <cassert>

using namespace std;

#ifdef LOCAL_DEBUG
#include <local_debug.h>
#define DEBUG(x...) cerr << #x << " = "; DBG::_print(x)
#else
#define DEBUG(x...)
#endif

#define SZ(a) int((a).size())
#define REP(i,n) for(int i=0,_n=(n);i<_n;++i)
#define FOR(i,a,b) for(int i=(a),_b=(b);i<=_b;++i)

typedef long long llong;
typedef vector<int> VI;
typedef vector<VI> VVI;

const int MOD = 1e9 + 7;

int powmod(llong x, int n, int m) {
   llong res = 1 % m;
   x %= m;
   for (; n > 0; n >>= 1) {
      if (n & 1) {
         res = (res * x) % m;
      // n--;
      }
      x = (x * x) % m;
   }
   return (int) res;
}

int main(int argc, char* argv[]) {
   ios_base::sync_with_stdio(false); 
   cin.tie(nullptr);

   int N, K;
   cin >> N >> K;

   vector<llong> DP(K+1);
   for (int d = K; d >= 1; --d) {
      DP[d] = powmod(K/d, N, MOD);
      for (int m = 2*d; m <= K; m += d) {
         DP[d] -= DP[m];
         if (DP[d] < 0)
            DP[d] += MOD;
      }
   }

   llong res = 0;
   FOR(d, 1, K) {
      res = (res + d*1LL*DP[d]) % MOD;
   }
   cout << res << '\n';

   return 0;
}


Measured memory_bytes: 3960
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Program
{
    static void Main()
    {
        Scanner cin = new Scanner();

        int h = cin.Int();
        int w = cin.Int();
        string[] s = new string[h + 2];

        for(int i = 1; i <= w + 2; i++)
        {
            s[0] += ".";
            s[h + 1] += ".";
        }
        for (int i = 1; i <= h; i++)
        {
            s[i] = "." + Console.ReadLine() + ".";
        }

        for(int i = 1; i <= h; i++)
        {
            for(int j = 1; j <= w; j++)
            {
                if(s[i][j] == '.')
                {
                    int cnt = 0;
                    for(int k = i - 1; k <= i + 1; k++)
                    {
                        for(int l = j - 1; l <= j + 1; l++)
                        {
                            if (s[k][l] == '#') cnt++;
                        }
                    }
                    s[i] = s[i].Substring(0, j) + cnt.ToString() + s[i].Substring(j + 1);
                }
            }
        }

        for(int i = 1; i <= h; i++)
        {
            s[i] = s[i].Substring(1, w);
            Console.WriteLine(s[i]);
        }
        Console.ReadLine();
    }

}

class Scanner //標準入力
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int Int()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = Int() + add;
        }
        return Array;
    }

    public long Long()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = Long() + add;
        }
        return Array;
    }

    public double Double()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = Double() + add;
        }
        return Array;
    }
}


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

int main () {
  int N;
  cin >> N;
  vector<string> W(N);
  for(int i = 0; i < N; i++) {
    cin >> W.at(i);
  }
  bool ans = true;
  for (int i = 0; i < N-1; i++) {
    if (W.at(i).back() != W.at(i+1).at(0)) {
      ans = false;
      break;
    }
  }
  if (ans) {
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        if (i != j && W.at(i) == W.at(j)) {
          ans = false;
          break;
        }
      }
      if (ans == false) break;
    }
  }
  if (ans) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

int main(){
    int A,B,C,K; cin>>A>>B>>C>>K;

    if(K<=A){
        cout<<K<<endl;
    }else if(K<=A+B){
        cout<<A<<endl;
    }else{
        cout<<A-(K-A-B)<<endl;
    }
}


Measured memory_bytes: 3572
N,M,X,Y=map(int,input().split())
x=list(map(int,input().split()))
y=list(map(int,input().split()))
if min(y)-max(x)<=0:
  print('War')
  exit()
z=max(x)+1
n=min(y)-max(x)
for i in range(n):
  if X<z and z<=Y:
    print('No War')
    exit()
  else:
    z+=1
print('War')

Measured memory_bytes: 3064
/*


                 """Bismillahir Rahmanur Rahim"""

*/
#include<bits/stdc++.h>
using namespace std;
#define pi 2*acos(0.0)
#define ll long long int
#define inf 922337203470075000
#define pb push_back
#define pf push_front
const ll sz = 1000001;
#define ek(x) __builtin_popcount(x)
#define ses '\n'
#define in(x) scanf("%lld",&x);
#define out(x) printf("%lld\n",x);
#define stm istringstream
#define all(x) x.begin(),x.end()
#define ghora ios_base::sync_with_stdio(0);cin.tie(0);
#define gcd __gcd
ll lcm(ll x,ll y){return (x*y)/gcd(x,y);}
#define tin ll T;cin>>T; for(ll o=1;o<=T;o++)
#define tout cout<<"Case "<<o<<": ";
#define spc printf(" ");
std::vector<ll> v[100050];
ll n,k;
ll dp[100020][3];
ll f(ll i,ll j)
{
    if(i==n-1)
     {
        if(j==-1)
           return   max(max(v[i][1],v[i][2]),v[i][0]);
        if(j==0)
            return max(v[i][1],v[i][2]);
        if(j==1)
             return max(v[i][0],v[i][2]);

         else  return max(v[i][1],v[i][0]);
     }
    if(dp[i][j]>0) 
    {
        return dp[i][j];
        
    }
   
    ll x=-1,y=-1,z=-1;
   if(j!=0)
      x=v[i][0]+f(i+1,0);
  if(j!=1)
      y=v[i][1]+f(i+1,1);
  if(j!=2)
      z=v[i][2]+f(i+1,2);
   return dp[i][j]=max(z,max(x,y));
}
int main()
{
     ll p,a,b,c;
     memset(dp,-1,sizeof(dp));
     cin>>n;
     for(ll i=0;i<n;i++)
     {
        cin>>a>>b>>c;
        v[i].pb(a);
         v[i].pb(b);
          v[i].pb(c);
     }
     ll x=f(0,-1);
     cout<<x<<ses;
    return 0;
}
/*   --------------------
    |      ~SOHAN~       |
    |   ~Chandler68~     |
     --------------------
    || VALAR MORGULIS||==|| ALL MEN MUST DIE ||
    \\ Power Is Power//
    || I Can Do This All day ||
    // We are on a Break \\ // How you doin'? \\
    || Say My Name || ~~ || I Am The Who Knocks ||
    // I Am Ted Mosby Architect \\
    || It Is Legen --wait for it -- dary ,Legendary ||
    \\ Penny - Penny - Penny // -- Bazinga

*/

Measured memory_bytes: 15872
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <queue>
#include <map>
#include <set>
using namespace std;
#define ll long long
#define rep(i, s, n) for(int i = s; i < n; i++)

int main() {
    int n, r;
    cin >> n >> r;
    if(n >= 10) {
        cout << r << endl;
    }
    else {
        cout << r+100*(10-n) << endl;
    }
    return 0;
}

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

import static java.util.Arrays.*;
import static java.util.Collections.*;
import static java.lang.Math.*;

public class Main {

	int INF = 1 << 28;
	//long INF = 1L << 62;
	double EPS = 1e-10;

	void run() {
		Scanner sc = new Scanner(System.in);
		for(;;) {
			int n = sc.nextInt();
			if(n == 0) break;
			BigInteger[] d = new BigInteger[n], v = new BigInteger[n];
			d[0] = new BigInteger(sc.next()); v[0] = new BigInteger(sc.next());
			
			BigInteger div = gcd(d[0], v[0]);
			d[0] = d[0].divide(div); v[0] = v[0].divide(div);
			
			BigInteger nume = new BigInteger("" + d[0]), deno = new BigInteger("" + v[0]);
			for(int i=1;i<n;i++) {
				d[i] = new BigInteger(sc.next()); v[i] = new BigInteger(sc.next());
				div = gcd(d[i], v[i]);
				d[i] = d[i].divide(div); v[i] = v[i].divide(div);
				nume = lcm(nume, d[i]);
				deno = gcd(deno, v[i]);
			}
			for(int i=0;i<n;i++) {
				System.out.println(nume.divide(d[i]).multiply(v[i]).divide(deno) );				
			}
		}
	}
	
	BigInteger lcm(BigInteger x, BigInteger y) {
		return x.divide(gcd(x, y)).multiply(y);
	}
	
	BigInteger gcd(BigInteger x, BigInteger y) {
		if(y.equals(new BigInteger("0"))) return x;
		return gcd(y, x.divideAndRemainder(y)[1]);
	}

	void debug(Object... os) {
		System.err.println(Arrays.deepToString(os));
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

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


ll calc(ll X){
    if(X == 1){
        return 1;
    }else{
        return 1 + 2 * calc(X / 2);
    }
}

void solve(long long H){
    cout << calc(H) << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
int main(){
    long long H;
    scanf("%lld",&H);
    solve(H);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <set>
using namespace std;
int main(){
  int a;
  cin >> a;
  set<int> s;
  for(int i=1;;i++){
    if(s.find(a)!=s.end()){
      cout << i << endl;
      return 0;
    }
    s.insert(a);
    if(a&1)a=a*3+1;
    else a=a/2;
  }
  return 0;
}

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

int main() {
  int i;
  cin >> i;
  
  int s1, s2, s3;
  s1 = i / 100;
  i %= 100;
  s2 = i / 10;
  i %= 10;
  s3 = i;
  cout << s1 + s2 + s3 << endl;
}


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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007

struct edge{
  int to,we;
};
vector<vector<edge>> v(100);
vector<vector<int>> d(100,vector<int>(100,1e8));
set<P> st;

void dfs(int pos,int pre,int S,int G){
  if(pos == G)return ;
  for(auto nv : v[pos]){
    if(nv.to == pre)continue;
    if(d[S][G] == d[S][pos]+d[nv.to][G]+nv.we){
      int a = pos,b = nv.to;
      if(a > b)swap(a,b);
      st.insert({make_pair(a,b)});
      dfs(nv.to,pos,S,G);
    }
  }
}

int main(){
  
  int n,m;
  cin >> n >> m;
  rep(i,n)d[i][i] = 0;
  rep(i,m){
    int a,b,c;cin >> a >> b >> c;
    a--,b--;
    v[a].push_back({b,c});
    v[b].push_back({a,c});
    d[a][b] = d[b][a] = c;
  }
  rep(k,n)rep(i,n)rep(j,n)d[i][j] = min(d[i][j],d[i][k]+d[k][j]);
  rep(i,n)for(int j = i+1;j < n;j++)dfs(i,i,i,j);
  int k = st.size();
  cout << m-k << endl;


  
  return 0;
}

Measured memory_bytes: 3668
import math
a,b,c = ((float(x) for x in input().split()))

S = a*b*math.sin(math.radians(c))/2
x = math.sqrt(a**2 + b**2 - 2*a*b*math.cos(math.radians(c)))
L = a + b + x
h = b*math.sin(math.radians(c))
print(S)
print(L)
print(h)



Measured memory_bytes: 5700