akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
const double EPS = 1e-9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
int main() {
	int n; cin >> n;
	string s, t; cin >> s >> t;
	ll dp[54] = {};
	dp[0] = 1;
	int bef;
	rep(i, n) {
		if (i == 0) {
			if (s[i] == t[i]) {
				dp[1] = 3; bef = 0;
			}
			else {
				dp[2] = 6; bef = 1; i++;
			}
		}
		else {
			if (s[i] == t[i]) {
				if (bef)dp[i + 1] = dp[i];
				else dp[i + 1] = dp[i] * (ll)2 % MOD;
				bef = 0;
			}
			else {
				if (bef)dp[i + 2] = dp[i] * (ll)3 % MOD;
				else dp[i + 2] = dp[i] * (ll)2 % MOD;
				i++;
				bef = 1;
			}
		}
	}
	cout << dp[n] << endl;
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC optimize("no-stack-protector,fast-math")
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define IO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
const int N = 1e2 + 5;

char s[8];

int main(){
    scanf("%s", s);
    puts(s[2] == s[3] && s[4] == s[5] ? "Yes" : "No");
}


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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

typedef long long ll;
typedef long double R;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};

// Problem Specific Parameter:

int main() {
  int a, b, c; cin >> a >> b >> c;
  if(a * c <= b) cout << c << endl;
  else cout << b / a << endl;

  return 0;
}


Measured memory_bytes: 256
import scala.io.StdIn._
object Main extends App {

  val menus = Array.tabulate(5){_ ⇒ readInt()}.sortBy{it ⇒ (10 - (it % 10)) % 10}

  var time = 0
  for (menu ← menus) {
    time = (time + 9) / 10 * 10 + menu
  }
  println(time)
}

Measured memory_bytes: 25540
#include<iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
using namespace std;
#define rep(i,ra,re) for((i)=ra;(i)<(re);(i)++)
#define rep_(i,ra,re) for((i)=ra;(i)<=(re);(i)++)
#define pu(n) cout << n; 
#define put(n) cout << n << " "; 
#define puts(n) cout << n << endl;
int main(void){
	int a,b,c;
	cin >> a >> b >> c;
	int maxs=max(a,b);
	maxs=max(maxs,c);
	puts(a+b+c-maxs);
	return 0;
	}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define DBG_N(hoge) cerr<<" "<<(hoge)<<endl;
#define DBG cerr<<"!"<<endl;
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;cin>>n;
  vector<double>vd(n);
  for(auto &a:vd)cin>>a;
  sort(ALL(vd));
  double now;
  for(int i=0;i<n;i++){
    if(i==0){
      now=vd[i];
    }else{
      now=(now+vd[i])/2;
    }
  }
  printf("%.10f\n",now);
  return 0;
}


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

int main(){
  string S;
  cin >> S;
  vector<string> ABC(200000,"0");
  int64_t j=0;
  for(int64_t i=0;i<S.size();i++){
    while(S.at(i)!='A'){
      i++;
      if(i>=S.size()){
        break;
      }
    }
    ABC.at(j)="A";
    while(true){
      if(i>=S.size()-2||S.size()==1){
        i+=2;
        break;
      }else if(S.at(i+1)=='A'){
        ABC.at(j)+="A";
        i++;
      }else if(S.at(i+1)=='B'){
        if(S.at(i+2)=='C'){
          ABC.at(j)+="BC";
          i+=2;
        }else{
          j++;
          break;
        }
      }else{
        j++;
        break;
      }
    }
  }
  j=0;
  int64_t ans=0;
  while(ABC.at(j)!="0"){
    int64_t bc=0;
    for(int i=ABC.at(j).size()-1;i>=0;i--){
      if(ABC.at(j).at(i)=='A'){
        ans+=bc;
      }else{
        bc++;
        i--;
      }
    }
    j++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3972
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<set>
#include<climits>
#include<map>
#define ll long long
using namespace std;
int main() {
	ll n;
	cin >> n;
	vector<ll>t(n);
	vector<ll>t2(n);
	for (ll i = 0; i < n; i++) {
		cin >> t[i];
		t2[i] = t[i];
	}
	ll m;
	cin >> m;
	vector<ll>p(m);
	vector<ll>x(m);
	for (ll i = 0; i < m; i++) {
		cin >> p[i] >> x[i];
	}
	for (ll j = 0; j < m; j++) {
		ll sum = 0;
		t = t2;
		for (ll i = 0; i < n; i++) {
			if (p[j] == i + 1) {
				t[i] = x[j];
			}
			sum += t[i];
			//cout << t[i] << endl;
		}
		cout << sum << endl;
	}

}



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

public class Main {

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

		List<Integer> vals = new ArrayList<>();
		for (int i = 0; i < 3; ++i) {
			vals.add(in.nextInt());
		}
		Collections.sort(vals);
		if (vals.get(0) == vals.get(2)) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

	}

}

Measured memory_bytes: 21332
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <assert.h>
#include <fstream>

using namespace std;

int A,B,C;
int ans;

int main()
{
	cin >> A >> B >> C;
	ans += min(B,C);
	B -= ans;
	C -= ans;
	ans <<= 1;
	if (!B)
		ans += min(A + 1,C);
	else
		ans += B;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
//Sani buyuk Osman Pasa Plevneden cikmam diyor.
//FatihSultanMehmedHan
//Abdulhamid Han
//Bismillahirrahmanirrahim
//█▀█─█──█──█▀█─█─█
//█▄█─█──█──█▄█─█▄█
//█─█─█▄─█▄─█─█─█─█

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

typedef long long lo;
typedef pair< lo,lo > PII;
typedef pair< lo,PII > PIII;

#define fi first
#define se second
#define mp make_pair
#define int long long
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(int i=1;i<=n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)

const lo MAX = -1000000000000000000;
const lo MIN = 1000000000000000000;
const lo inf = 1000000000;
const lo KOK = 100000;
const lo LOG = 30;
const lo li = 500005;
const lo mod = 1000000007;

int n,m,b[li],a[li],k,flag,t,mx,vis[25][25];
int cev;
char s[25][25];
vector<int> v;

inline void bfs(int bas,int basy){
	queue<PIII> q;
	//~ cout<<bas<<" "<<basy<<endl;
	while(q.size())q.pop();
	q.push(mp(bas,mp(basy,0)));
	while(q.size()){
		int satir=q.front().fi;
		int sutun=q.front().se.fi;
		int der=q.front().se.se;
		q.pop();
		if(satir<1 || sutun<1 || satir>n || sutun>m)continue;
		if(s[satir][sutun]=='#')continue;
		if(vis[satir][sutun]==1)continue;
		vis[satir][sutun]=1;
		mx=max(mx,der);
		q.push(mp(satir+1,mp(sutun,der+1)));
		q.push(mp(satir-1,mp(sutun,der+1)));
		q.push(mp(satir,mp(sutun+1,der+1)));
		q.push(mp(satir,mp(sutun-1,der+1)));
	}
}

main(void){
	scanf("%lld %lld",&n,&m);
	FOR{
		for(int j=1;j<=m;j++){
			scanf(" %c",&s[i][j]);
		}
	}
	FOR{
		for(int j=1;j<=m;j++){
			if(s[i][j]=='#')continue;
			memset(vis,0,sizeof(vis));
			bfs(i,j);
		}
	}
	printf("%lld\n",mx);
	return 0;
}



Measured memory_bytes: 256
N = int(input())
R = []
B = []
for i in range(2 * N):
    a, b = map(int, input().split())
    if i < N:
        R.append((a, b))
    else:
        B.append((a, b))
B = sorted(B)

ans = 0
checked = set()
p = []
for b in B:
    x1, y1 = b
    tR = [(x2, y2) for x2, y2 in R if x2 < x1]
    tR = sorted(tR, key=lambda p: p[1], reverse=True)
    for x2, y2 in tR:
        if (x2, y2) in checked:
            continue
        if x1 > x2 and y1 > y2:
            ans += 1
            checked.add((x2, y2))
            p.append((b, (x2, y2)))
            break
print(ans)


Measured memory_bytes: 8960
#include <iostream>
#include <vector>
using namespace std;
int main() {
  int n; cin >> n;
  int var; vector<int> count(n+1, 0);
  for (int i = 1; i < n; i++) {
    cin >> var;
    count[var]++;
  }
  for (int i = 1; i < count.size(); i++) {
    cout << count[i] << "\n";
  }
}

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

int main(void){
	int N;
	string s,t;
	cin>>N>>s>>t;
	int res = N*2;
	rep(i,N){
		if(s.substr(i,N-i)==t.substr(0,N-i)){
			res-=N-i;
			break;
		}
	}
	cout<<res<<endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#define M 10000
using namespace std;

struct P{
  int ts,te,n;
};

int main(){
  int n,m, r,q, te,ts, t,nn,mm,s;
  vector<P> v[M+1];
  P p;

  while( cin >> n >>m && (n||m) ){
    cin >> r;
    for( int i=1;i<=m;i++ ) v[i].clear();

    for( int i=0;i<r;i++ ){
      cin >> t >> nn >> mm >> s;

      if( s==1 ){
	p.ts=t; p.te=-1; p.n=nn; v[mm].push_back( p );
      }else{
	for( int j=v[mm].size()-1;j>=0;j-- ){
	  if( v[mm][j].n==nn && v[mm][j].te==-1 ){
	    v[mm][j].te=t; break;
	  }
	}
      }
    }
    /*
    for( int i=1;i<=m;i++ ){
      for( unsigned int j=0;j<v[i].size();j++ )
	cout << "("<<v[i][j].ts << "-"<< v[i][j].te <<"),"
	     << v[i][j].n <<" " ;
      if( v[i].size()>0 )
	cout << endl;
    }
    cout << "CNV"<<endl;
    */
    // ツつゥツづ板づ?づ?つ「ツづゥツ篠楪甘板づーツ鳴ウツつュツつキ
    for( int i=1;i<=m;i++ ){
      for( unsigned int j=1;j<v[i].size();j++ ){
	int k=j-1;
	if( v[i][k].te >= v[i][j].ts ){
	  v[i][k].te = max( v[i][k].te, v[i][j].te );
	  v[i].erase( v[i].begin()+j );
	  j--;
	}
      }

    }
    /*
    for( int i=1;i<=m;i++ ){
      for( unsigned int j=0;j<v[i].size();j++ )
	cout << "("<<v[i][j].ts << "-"<< v[i][j].te <<"),"
	     << v[i][j].n <<" " ;
      if( v[i].size()>0 )
	cout << endl;
    }
    */
    cin >> q;
    for( int lp=0;lp<q;lp++ ){
      cin >> ts>>te >> m;
      int ans=0;
      //      cout << ts << "->" << te << " m="<<m<<endl;

      for( unsigned int i=0;i<v[m].size();i++ ){
	if( v[m][i].te<=ts ) continue;
	if( v[m][i].ts>=te ) continue;
	ans += ( min( te,v[m][i].te )- max(v[m][i].ts,ts) );
	//	cout << " "<< ans << endl;
      }

      cout << ans << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <sstream>
#include <stdio.h>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
#include <exception>
#include <numeric>
using namespace std;
typedef long long ll;
typedef string str;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<Pll> vp;
typedef vector<bool> vb;
#define rep(i, a, n) for (ll i = (a); i < (n); ++i)
#define rrep(i, a, n) for (ll i = (a); i > (n); --i)
#define erep(i, a, n) for (ll i = (a); i <= (n); ++i)
#define rerep(i, a, n) for (ll i = (a); i >= (n); --i)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define mp make_pair
#define sz(x) ((int)x.size())
#define vec_max(V) *max_element(all(V))
#define vec_min(V) *min_element(all(V))
#define vec_sum(V) accumulate(all(V), 0LL)
#define print(X) cout << (X) << "\n"
#define _ << " " <<
#define Yes print("Yes")
#define No print("No")
static const int INF = 1e+9+7;

int main(){
  ll N;
  vll A(5);
  cin >> N;
  rep(i,0,5) cin >> A[i];

  ll min = vec_min(A);

  if(min < N){
    if(N%min == 0) print(5 + N/min -1);
    else print(5 + ll(N/min));
  }

  else print(5);

 return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;
public class Main {

	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int N=sc.nextInt();
		int x=sc.nextInt();
		int[] a = new int[N];
		for(int i=0; i<N; i++){
			a[i] = sc.nextInt();
		}

		Arrays.sort(a);

		int i=0;
		
//		for(int j=0; j<N; j++){
//			x-=a[i];
//			k++;
//			if(x<0){
//				k--;
//				break;
//			}
//		}
		while(i<N){
			x-=a[i];
			i++;
			if(x<0 || (i==N && x>0)){
				i--;
				break;
			}
		}
//		if(i==N && x>0) k--;

		System.out.println(i);
	}
}


Measured memory_bytes: 22996
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define ll long long
#define M 1000000007
#define sz(a) (ll)a.size()
#define pll pair<ll,ll>
#define rep(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define sep(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
#define mll map<ll,ll>
#define vl vector<ll>
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(a) a.begin(),a.end()
#define F first
#define S second
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n,k;
    cin>>n>>k;
    ll h[n+1],dp[n+1];
    rep(i,1,n+1)
    cin>>h[i];
    dp[n]=0;
    sep(i,n-1,1)
    {
    	dp[i]=LLONG_MAX;
    	rep(j,i+1,min(i+k,n)+1)
    		dp[i]=min(dp[i],abs(h[i]-h[j])+dp[j]);
    }
    cout<<dp[1];
}


Measured memory_bytes: 1792
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        
        if(a<b){
            System.out.println("a < b");
        }else if(a>b){
            System.out.println("a > b");
        }else{
            System.out.println("a == b");
        }
    }
}


Measured memory_bytes: 25912
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REPR(i,n) for (int i=(int)(n)-1;i>=0;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define valid(y,x,h,w) (0<=y&&y<h&&0<=x&&x<w)
#define tpl(...) make_tuple(__VA_ARGS__)
const int INF = 0x3f3f3f3f;
const double EPS = 1e-8;
const double PI = acos(-1);
const int dy[] = {-1,0,1,0};
const int dx[] = {0,1,0,-1};
typedef long long ll;
typedef pair<int,int> pii;
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 (b<a) { a=b; return 1; } return 0; }
template<typename Ch,typename Tr,typename C,typename=decltype(begin(C()))>basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>&os,
const C& c){os<<'[';for(auto i=begin(c);i!=end(c);++i)os<<(i==begin(c)?"":" ")<<*i;return os<<']';}
template<class S,class T>ostream&operator<<(ostream &o,const pair<S,T>&t){return o<<'('<<t.first<<','<<t.second<<')';}
template<int N,class Tp>void output(ostream&,const Tp&){}
template<int N,class Tp,class,class ...Ts>void output(ostream &o,const Tp&t){if(N)o<<',';o<<get<N>(t);output<N+1,Tp,Ts...>(o,t);}
template<class ...Ts>ostream&operator<<(ostream&o,const tuple<Ts...>&t){o<<'(';output<0,tuple<Ts...>,Ts...>(o,t);return o<<')';}
template<class T>void output(T t,char z=10){if(t<0)t=-t,putchar(45);int c[20];
int k=0;while(t)c[k++]=t%10,t/=10;for(k||(c[k++]=0);k;)putchar(c[--k]^48);putchar(z);}
template<class T>void outputs(T t){output(t);}
template<class S,class ...T>void outputs(S a,T...t){output(a,32);outputs(t...);}
template<class T>void output(T *a,int n){REP(i,n)cout<<a[i]<<(i!=n-1?',':'\n');}
template<class T>void output(T *a,int n,int m){REP(i,n)output(a[i],m);}
template<class T>bool input(T &t){int n=1,c;for(t=0;!isdigit(c=getchar())&&~c&&c-45;);
if(!~c)return 0;for(c-45&&(n=0,t=c^48);isdigit(c=getchar());)t=10*t+c-48;t=n?-t:t;return 1;}
template<class S,class ...T>bool input(S&a,T&...t){input(a);return input(t...);}
template<class T>bool inputs(T *a, int n) { REP(i,n) if(!input(a[i])) return 0; return 1;}

typedef tuple<int,int,int> P;

int main() {
  int n;
  while(cin>>n) {
    vector<pii> v;
    REP(i,n) {
      int x,l;
      input(x,l);
      v.push_back(pii(x+l,x-l));
    }
    sort(ALL(v));
    int cur = -2000000000;
    int ans = 0;
    REP(i,n) {
      if (v[i].second >= cur) {
        cur = v[i].first;
        ans++;
      }
    }
    cout << ans << endl;
  }
}


Measured memory_bytes: 1528
S = input()
T = input()
ls = len(S)
lt = len(T)
ans = lt
for i in range(0,ls-lt+1):
  m = 0
  for j in range(lt):
    if S[i:i+lt][j]!=T[j]:
      m += 1
  ans = min(ans,m)
print(ans)

Measured memory_bytes: 9096
import java.util.*;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
 
   int a = sc.nextInt();
   int b = sc.nextInt();
   int c = sc.nextInt();
 
   if(a<=c&&c<=a+b) System.out.println("YES");
   else System.out.println("NO");
 }
}

Measured memory_bytes: 21972
#include <iostream>
#include <algorithm>
 
inline void fastin(int &num) {
    bool neg = false;
    int c;
    num = 0;
    c = getchar_unlocked();
    if (c == '-') {
        neg = true;
        c = getchar_unlocked();
    }
    for (; (c > 47 && c < 58); c = getchar_unlocked()) num = (num<<3) + (num<<1) + c - 48;
    if (neg) num *= -1;
}

inline void fastout(int n) {
    int N = n, rev, count = 0;
    rev = N;
    if (N == 0) { putchar_unlocked('0'); putchar_unlocked('\n'); return ;}
    while ((rev % 10) == 0) { ++count; rev /= 10;}
    rev = 0;
    while (N != 0) { rev = (rev<<3) + (rev<<1) + N % 10; N /= 10;}
    while (rev != 0) { putchar_unlocked(rev % 10 + '0'); rev /= 10;}
    while (count--) putchar_unlocked('0');
}
 
inline int divide(int x, int y){
    if (x % y == 0) return x / y;
    else return x / y + 1;
}
 
int main(){    
    int N, H; fastin(N); fastin(H);
  	int a = 0;
	int b[N];
    for (int i = 0; i < N; ++i) {
      	int ta, tb; fastin(ta); fastin(tb);
    	a = std::max(a, ta); b[i] = tb;
    }
 
    std::sort(b, b + N);
    auto it = std::lower_bound(b, b + N, a);
 
    int temp = 0, cnt = 0;
 
    for (int i = N - 1; i >= (int) (it - b); --i){
        temp += b[i]; ++cnt;
        if (temp >= H){
            fastout(cnt); return 0;
        }
    }
    fastout(cnt + divide((H - temp), a));
    
    return 0;
}


Measured memory_bytes: 640
import java.util.Scanner;


public class Main {

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

		int n = sc.nextInt();

		call(n);

		sc.close();
	}

	private static void call(int n) {
		for (int i = 1; i <= n; i++) {
			int x = i;
			if (x % 3 == 0) {
				System.out.print(" " + i);
			} else {
				while (x != 0) {
					if (x % 10 == 3) {
						System.out.print(" " + i);
						x = 0;
					}
					x /= 10;
				}					
			}
		}

		System.out.println("");
	}

}

Measured memory_bytes: 24236
from collections import Counter

N = int(input())
inputs = [int(i) for i in input().split()]

ans = 0
ruisekiwa = [0] * (N+1)

for i in range(N):
    ruisekiwa[i+1] = ruisekiwa[i] + inputs[i]

ruisekiwa = ruisekiwa[1:]
ruisekiwa.sort()
counter_ruiseki = Counter(ruisekiwa)

for key, value in counter_ruiseki.items():
    if key == 0 and value == 1:
        ans += value
        continue
    elif key == 0 and value > 1:
        ans += value
    if value > 1:
        ans += sum(list(range(value)))

print(ans)


Measured memory_bytes: 41880
#include <stdio.h>

int main()
{
	int n;
	int a,b,c,d;
	int s=0;
	while(scanf("%d",&n)!=EOF){
	s=0;
	for(a=0;a<=9;a++){
	for(b=0;b<=9;b++){
	for(c=0;c<=9;c++){
	for(d=0;d<=9;d++){
		if(a+b+c+d==n) s++;
	}	
	}	
	}	
	}
	
	printf("%d\n",s);
	
	}
	
	return 0;
}

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

int main()
{
  int n;
  cin >> n;
  
  int arr[n];
  for(int i = 0; i < n; i++)
  {
    cin >> arr[i];
  }
  
  sort(arr, arr+n);
  double a = arr[0];
  for(int i = 1; i < n; i++)
  {
    a = (a + arr[i])/2;
  }
  
  cout << a << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i,N); for (int64_t i = 0; i<N; i++)
#define in(N); cin >> N
#define out(ans); cout << ans << endl;

int64_t kou_min (int64_t a, int64_t b) {

  // a1>=b1とする
  int64_t a1, b1, r;
  a1 = max(a, b);
  b1 = min(a, b);


  // ユークリッドの互除法を用いる, b1が最大公約数として返される。
  while (true) {
    r = a1%b1;
    if (r == 0) {
      break;
    }
    a1 = b1;
    b1 = r;
  }
  return b1;
}

int main() {
  int64_t K, ans=0, ans1;
  cin >> K;
  for (int64_t i = 1; i <= K; i++) {
    for (int64_t j = 1; j <= K; j++) {
      ans1 = kou_min (i, j);
      for (int64_t l = 1; l <= K; l++) {
        ans += kou_min (ans1, l);
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3620
N, K = map(int, input().split())
A = list(map(int, input().split()))
F = list(map(int, input().split()))
A.sort()
F.sort(reverse=True)

start = -1
end = A[-1] * F[0]

def check(now):
    cnt = 0
    for a, f in zip(A, F):
        eatable = now//f
        if eatable < a:
            cnt += a - eatable
    if cnt > K:
        return False
    return True

while end > start + 1:
    now = (start + end) // 2
    if check(now):
        end = now
    else:
        start = now

print(end)


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

int top,S[10000];

void push(int x){
  S[++top]=x;
}

int pop(){
 return S[top--];
}

int main(){
  int a,b;
  char s[1000];
  top=0;
  
  while(scanf("%s",s)!=EOF){
    if(s[0]=='+'){
      b=pop();
      a=pop();
      push(a+b);
    }else if(s[0]=='-'){
      b=pop();
      a=pop();
      push(a-b);
    }else if(s[0]=='*'){
      b=pop();
      a=pop();
      push(a*b);
    }else{
      push(atoi(s));
    }
  }
  printf("%d\n",pop());
  return 0;
}

Measured memory_bytes: 548
// Problem : D - Friends
// Contest : AtCoder - AtCoder Beginner Contest 177
// URL : https://atcoder.jp/contests/abc177/tasks/abc177_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#pragma GCC optimize("O2")
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define mod 1000000007
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
ll cnt;
void dfs(ll u,vector<ll> *adj,vector<bool> &vis)
{
	vis[u] = true;
	cnt++;
	for(auto v:adj[u])
		if(!vis[v])
			dfs(v,adj,vis);
}
int main()
{
	fast;
	ll t = 1;
	// cin >> t;
	while (t--)
	{
		ll n,m;
		cin >> n >> m;
		vector<ll> adj[n+1];
		for(ll i=0;i<m;i++)
		{
			ll u,v;
			cin>>u>>v;
			adj[u].push_back(v);
			adj[v].push_back(u);
		}
		 ll res=0;
		 vector<bool> vis(n+1,false);
		for(ll i=1;i<=n;i++)
		{
			if(!vis[i])
			{
				cnt=0;
				dfs(i,adj,vis);
				res = max(res,cnt);
			}
		}
		cout<<res<<"\n";
	}
	return 0;
}


Measured memory_bytes: 23880
import bisect
def main():

    N, M, K = map(int, input().split())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    prefixA = [0]
    for j in range(N):
        prefixA.append(prefixA[-1] + A[j])
    prefixB = [0]
    for j in range(M):
        prefixB.append(prefixB[-1] + B[j])

    ans = 0
    for i in range(N+1):
        v = prefixA[i]
        j = bisect.bisect_left(prefixB, K-v)
        if j< len(prefixB) and prefixB[j] + v <= K:
            ans = max(ans, i + j)
        if j-1 >=0 and prefixB[j-1] + v <= K:
            ans = max(ans, i + j-1)
    return ans


if __name__ == '__main__':
    print(main())


Measured memory_bytes: 127236
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define sz size
#define se second
#define fe first
#define mper make_pair
#define all(x) x.begin(), x.end()
#define mal ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL);
#define vl vector<ll>
#define vi vector<int>
#define vli vector <pair <ll, int> >
#define vll vector <pair <ll, ll> >
#define vii vector <pair <int, int> >
using namespace std;

const ll MAXN = 2e5 + 100;
string s;

map <char, ll> mp;

void solve() {

    vector < pair <char, int> > g;

    cin >> s;
//    n = s.sz();

    reverse(all(s));

    ll ans = 0;

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

        ll l = s.sz() - i - 1;

        ans += s.sz() - l - 1;

        if(mp[s[i]]) {

            ans -= mp[s[i]];

        }

        mp[s[i]]++;

    }

    cout << ans + 1;

}

int main(){

mal
//freopen("ladder.in", "r", stdin);
//freopen("ladder.out", "w", stdout);

ll tt = 1;


while(tt--) {

    solve();

}

return 0;
}



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

long dp[2001];

long find(int n){

    if(n < 3){
        return 0;
    }
    if(n == 3){
        return 1;
    }
    int ans = 0;
    for(int i=3;i<n-1;i++){
        
        if((n-i) > 2){
            if(dp[(n-i)] != -1){
                ans = (ans%mod + dp[(n-i)]%mod)%mod;
                continue;
            }
            ans = (ans%mod + find(n-i)%mod)%mod;
        }
    }
    dp[n] = ans+1;
    return (ans%mod+1%mod)%mod;
}

int main(){
    int n;
    cin >> n;
    for(int i=0;i<=2000;i++) dp[i] = -1;
    int ans = find(n)%mod;
    cout << ans;

}

Measured memory_bytes: 3600
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<math.h>
#include<limits>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0;i < (n); ++i)

int main() {
	int a, b, c, d, e;
	cin >> a >> b >> c >> d >> e;
	if (a == 0)cout << 1 << endl;
	else if (b == 0)cout << 2 << endl;
	else if (c == 0)cout << 3 << endl;
	else if (d == 0)cout << 4 << endl;
	else if (e == 0)cout << 5 << endl;

	return 0;
}

Measured memory_bytes: 3588
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc=new Scanner(System.in);
		int a=sc.nextInt();
		int b=sc.nextInt();
		int t=sc.nextInt();
		int ans=0;
		ans=(int) ((t+0.5)/a);
		ans=ans*b;
		System.out.println(ans);
	}
}

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

int main() {
	int n, m;
	cin >> n >> m;
	vector<vector<pair<int, int64_t>>> v(n);
	for (int i = 0; i < m; i++) {
		int64_t l, r, d;
		cin >> l >> r >> d;
		l--;
		r--;
		v[l].emplace_back(make_pair(r, d));
		v[r].emplace_back(make_pair(l, -d));
	}
	vector<int64_t> dist(n, numeric_limits<int64_t>::max());
	for (int i = 0; i < n; i++) {
		if (dist[i] == numeric_limits<int64_t>::max()) {
			queue<int> q;
			dist[i] = 0;
			q.emplace(i);
			while (!q.empty()) {
				int j = q.front();
				q.pop();
				for (auto &p : v[j]) {
					if (dist[p.first] == numeric_limits<int64_t>::max()) {
						dist[p.first] = dist[j] + p.second;
						q.emplace(p.first);
					} else if(dist[p.first] != dist[j] + p.second) {
						cout << "No" << endl;
						return 0;
					}
				}
			}
		}
	}
	cout << "Yes" << endl;
	return 0;
}

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

using namespace std;

int a[200010];

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

    for (int i = 2; i <= n; ++i) {
        int x;
        cin >> x;
        a[x]++;
    }
    for (int i = 1; i <= n; ++i)
        cout << a[i] << "\n";
    return 0;
}

Measured memory_bytes: 4360
n, y = map(int, input().split())
for i in range(n + 1):
    for j in range(n + 1 - i):
        if i * 10000 + j * 5000 + (n - i - j) * 1000 == y:
            print(i, j, n - i - j)
            exit()
print('-1 -1 -1')

Measured memory_bytes: 9116
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <stdio.h>
#include <vector>

using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

int main() {

    string S;
    cin >> S;
    ll N = S.length();
    ll a = 0;
    ll b = 0;
    rep(i,N){
        if(i%2==0){
            if(S[i]=='1') a++;
            else b++;
        }
        else{
            if(S[i]=='0') a++;
            else b++;
        }
    }
    cout << min(a,b) << endl;
    return 0;
}


Measured memory_bytes: 512
#両者に、同じ位置，同じ文字があれば変換可能
s = input()
t = input()

s_inf = [[] for _ in range(97+26+1)]
t_inf = [[] for _ in range(97+26+1)]

for i in range(len(s)):
    s_inf[ord(s[i])].append(i)
    t_inf[ord(t[i])].append(i)
s_inf.sort()
t_inf.sort()
if s_inf==t_inf:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 14640
#include <stdio.h>
 
int main(){
  int A,B,C;
  int X;
  int a,b,c;
  int cnt = 0;
  
  scanf("%d\n%d\n%d",&A,&B,&C);
  scanf("%d",&X);
  
  for(a = 0;a <= A;a++){
    for(b = 0;b <= B;b++){
      for(c = 0;c <= C;c++){
        if(X == (500 * a) + (100 * b) + (50 * c)){
          cnt++;
        }
      }
    }
  }
  
  printf("%d",cnt);
  
  return 0;
  
}

Measured memory_bytes: 128
#include <stdio.h>
int max(int n,int m){
    if(n>m) return n;
    else return m;
}
int main(void){
    int a,b;
    scanf("%d%d",&a,&b);
    printf("%d",max(max(a+b,a-b),a*b));
    return 0;
}

Measured memory_bytes: 128
#
import sys
import math
import numpy as np
import itertools


# いくつか入力
n,m = (int(i) for i in input().split())

# 空白区切りの数列をリストに代入
a = [int(i) for i in input().split()] 

a=sorted(a,reverse=True)
total=0
for i in range(n):
    total += a[i]
for i in range(m):
    if a[i]<(total/4/m):
        print("No")
        exit()
print("Yes")



Measured memory_bytes: 21540
from functools import reduce
import math

def main():
    # 文字列の2進数を数値にする
    # '101' → '5'
    # 文字列の頭に'0b'をつけてint()にわたす
    # binary = int('0b'+'101',0)

    # 2進数で立っているbitを数える
    # 101(0x5) → 2
    # cnt_bit = bin(5).count('1')
    
    # N! を求める
    # f = math.factorial(N)

    # N の逆元
    # N_inv = pow(N,MOD-2,MOD)

    # nCr
    # Nの階乗 * rの階乗の逆元 * n-rの階乗の逆元
    
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    INF = float("inf")

    # 大きな素数
    MOD = 10**9+7
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    
    N = int(input())
    p = list(int(_)-1 for _ in input().split())
    ans = 0
    for i in range(N):
        if p[i] == i and i<N-1:
            tmp = p[i]
            p[i] = p[i+1]
            p[i+1] = tmp
            ans +=1
        elif p[i] == i and i == N-1:
            ans +=1
    print(ans)
    
if __name__ == '__main__':
    main()


Measured memory_bytes: 14504
N, X = [int(x) for x in input().split()]


def solution(N, X):
  if N<X:
    N, X = X, N
  if not N % X:
    return (2*(N//X) -1) * X
  else:
    return 2*(N//X)*X + solution(X, N%X)
      
answer = solution(N-X, X) + N
print(answer)
    


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

int main() {
  int n;
  cin >> n;
  string s, t, ans;
  cin >> s >> t;
  rep(i,n) {
    ans += s[i];
    ans += t[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 3596
/* ALDS1_9_A: Binary search trees */
/* 20181126 AOJ */

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef struct BinaryTreeNode_ {
	int key;
	struct BinaryTreeNode_ *left;
	struct BinaryTreeNode_ *right;
} BinaryTreeNode;

void insert(BinaryTreeNode *node, int value);
void print(BinaryTreeNode *node);
void Inorder(BinaryTreeNode *node);
void Preorder(BinaryTreeNode *node);

int main(void) {
	int i, n, value;
	char cmd[7];

	BinaryTreeNode *root = NULL;
	
	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%s", cmd);
		if(cmd[0] == 'i') { /* strcmp(cmd, "insert") == 0 */
			scanf("%d", &value);
			if(root == NULL) {
				root = (BinaryTreeNode *)malloc(sizeof(BinaryTreeNode));
				root->key = value;
				root->left = NULL;
				root->right = NULL;
			}else {
				insert(root, value);
			}
		}else { /* else if(strcmp(cmd, "print") == 0)  */
			print(root);
		}
	}

	return 0;
}


void insert(BinaryTreeNode *node, int value) {
	if(value < node->key) {
		if(node->left == NULL) {
			node->left = (BinaryTreeNode *)malloc(sizeof(BinaryTreeNode));
			node->left->key = value;
			node->left->left = NULL;
			node->left->right = NULL;
		}else {
			insert(node->left, value);
		}
	}else {
		if(node->right == NULL) {
			node->right = (BinaryTreeNode *)malloc(sizeof(BinaryTreeNode));
			node->right->key = value;
			node->right->left = NULL;
			node->right->right = NULL;
		}else {
			insert(node->right, value);
		}
	}
}

void print(BinaryTreeNode *node) {
	Inorder(node);
	printf("\n");
	Preorder(node);
	printf("\n");
}

void Inorder(BinaryTreeNode *node) {
	if(node == NULL) return ;
	Inorder(node->left);
	printf(" %d", node->key);
	Inorder(node->right);
}

void Preorder(BinaryTreeNode *node) {
	if(node == NULL) return;
	printf(" %d", node->key);
	Preorder(node->left);
	Preorder(node->right);
}



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

int main() {
    int A,B,X;
    cin >> A>>B>>X;
    int sum = A + B;
    if (X <= sum&& A<=X) {
        cout << "YES" << endl;
    }
    else cout << "NO" << endl;
}


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

const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const int MOD =   1000000007;

// Lib
//

using type = pair<int, long long>; // 1: query, 0; delete, -1: insert
using event = pair<long long, type>;

int main(){
#ifdef MYLOCAL
    ifstream in("input.txt");
    cin.rdbuf(in.rdbuf());
#endif
    int N, Q; cin >> N >> Q;
    vector<event> v;
    for (int i = 0; i < N; ++i) {
        int s, t, x; cin >> s >> t >> x;
        v.push_back({s-x, type(-1, x)});
        v.push_back({t-x, type(0, x)});
    }
    for (int i = 0; i < Q; ++i) {
        int d; cin >> d;
        v.push_back({d, type(1, i)});
    }
    sort(v.begin(), v.end());

    vector<long long> res(Q);
    multiset<long long> se;
    for (auto p : v) {
        long long x = p.first;
        int type = p.second.first;
        long long val = p.second.second;
        if (type == -1) se.insert(val);
        else if (type == 0) se.erase(se.lower_bound(val));
        else res[val] = (se.empty() ? -1 : *(se.begin()));
    }
    for (auto v : res) cout << v << endl;
    return 0;
}


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

namespace AtCoderMake.EX_HITACHI2020
{
    class H20B
    {
        static void Main(string[] args)
        {
            int min = 0;
            int tmp = 0;
            Console.ReadLine();
            var a = Console.ReadLine().Split().Select((x)=>int.Parse(x)).ToArray();
            var b = Console.ReadLine().Split().Select((x) => int.Parse(x)).ToArray();
            min = a.Min() + b.Min();
            string c = Console.ReadLine();
            while (c != null)
            {
                var d = c.Split().Select((x) => int.Parse(x)).ToArray();
                tmp = a[d[0] - 1] + b[d[1] - 1] - d[2];
                if (tmp < min)
                {
                    min = tmp;
                }
                c = Console.ReadLine();
            }
            Console.WriteLine(min);

        }
    }
}

Measured memory_bytes: 36444
N=int(input())
A=[list(map(int,input().split()))for i in range(2)]
ans=0
for i in range(N):
    l=sum(A[0][:i])
    c=A[0][i]+A[1][i]
    r=sum(A[1][i+1:])
    ans=max(ans,l+c+r)
print(ans)

Measured memory_bytes: 9216
n,m=map(int,input().split())
l=[0]*n
d=[0]*n
for i in range(m):
    s=input().split()
    x=int(s[0])
    if(s[1]=='AC'):
        l[x-1]=1
    else:
        if(l[x-1]==1):
            continue
        else:
            d[x-1]+=1
p=0
for i in range(n):
    if(l[i]==1):
        p+=d[i]
print(sum(l),p)


Measured memory_bytes: 75832
import java.util.Scanner;
    public class Main{
    	public static void main(String[] args) {
    		Scanner sc = new Scanner(System.in);
    		 int x =sc.nextInt();
    		 int y =sc.nextInt();
    		 
    		 for(int i=1; i<=100000; i++) {
    		 if((int)(i*0.08)==x && (int)(i*0.1)==y) {
    			 System.out.println(i);
    			 return;
    		 	}
    		 }	
    			 System.out.println("-1");
        }
    }

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

int main(){
  pair<int,int> p;
  while(1){
    int h,w,di,ndi,min=1000000,f=0;
  cin>>h>>w;
  di=h*h+w*w;
  if(h+w==0) break;
   for(int i=1;i<=150;i++){
    for(int j=1;j<=150;j++){
      ndi=i*i+j*j;
      if(ndi==di && i>h && i<j &&f==0){
	p.first=i;
	p.second=j;
	min=ndi;
	f=1;
      }else if(ndi>di && i<j && ndi<min){
	p.first=i;
	p.second=j;
	min=ndi;
      }
    }
  }

  cout<<p.first<<" "<<p.second<<endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <cmath>
#include <list>
#include <chrono>
#include <thread>

using namespace std;

const bool debug = false;

#ifndef M_PI
    const double M_PI = acos(-1.0);
#endif // M_PI

#define y1 roman_kaban
#define rank oryshych_konb
#define ull unsigned long long
//#define ll long long
//const int mod = int(1e9) + 7;
//const int inf = 1e9;
//const long long infLL = 1e16;
//const int MX2 = 10100500; //  e7
//const long long INF = 1e18 + 0.5;
const int MX = 300500; //       e5
//const int SZ = 2100;
//const int delta = 1 << 19;


long long minn(long long x, long long y){
    if(x < y) return x;
    return y;
    return y;
}

long long go(long long x, long long y, long long z){
    if(x > y) swap(x, y);
    if(x > z) swap(x, z);
    if(y > z) swap(y, z);
    return z - x;
}

long long solve(int h, int w){
    long long res = h; res *= w;
    //cout << w << ' ' <<h << endl;
    for(int i = 1; i < h; i++){
        long long s1 = w; s1 *= i;

        long long x = (h - i) / 2;
        long long y = h - i - x;
        if(x > 0 && y > 0){
            x *= w;
            y *= w;
            res = minn(res, go(s1, x, y));
        }

        x = w / 2;
        y = w - x;
        x *= h - i;
        y *= h - i;
        //if(i == 2)  cout << x <<  ' ' << y <<  ' ' << s1 <<  ' ' << w << ' ' << h << endl;
        res = minn(res, go(s1, x, y));
    }
    return res;
}

int main()
{
    ios_base::sync_with_stdio(false);
    //if(debug)
//freopen("/Users/ozzy/Documents/in.txt","r", stdin);
//    freopen("/Users/ozzy/Documents/C-small-attempt1.in.txt","r", stdin);
//freopen("/Users/ozzy/Documents/out.txt","w", stdout);
    int h, w;
    cin >> h >> w;
    cout << minn(solve(h, w), solve(w, h));
    return 0;
}


Measured memory_bytes: 256
// Monsters Battle Royale

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

int n, ar[100005], ans;

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

int main(){
  scanf("%d", &n);
  for(int i = 0; i < n; i++){
    scanf("%d", &ar[i]);
  }
  
  ans = gcd(ar[0],ar[1]);
  for(int i = 2; i < n; i++){
    ans = gcd(ans, ar[i]);
  }

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

  return 0;
}

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

int main(){
	int m, f, r;
		
	while(1){
		cin >> m >> f >> r;
		if(m == -1 && f == -1 && r == -1){
			break;
		}
		
		if(m == -1 || f == -1){
			cout << 'F' << endl;
		}else if(m + f >= 80){
			cout << 'A' << endl;
		}else if(m + f >= 65){
			cout << 'B' << endl;
		}else if(m + f >= 50){
			cout << 'C' << endl;
		}else if(m + f >= 30){
			if(r >= 50){
				cout << 'C' << endl;
			}else{
				cout << 'D' << endl;
			}
		}else{
			cout << 'F' << endl;
		}
	}

 	return 0;
}

Measured memory_bytes: 3072
#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 FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const ll INF = 1e18;
const long double EPS = 1e-10;

int main() {
  int n, l;
  cin >> n >> l;
  vector<string> s(n);
  rep(i, n) cin >> s[i];
  
  sort(s.begin(), s.end());
  rep(i, n) cout << s[i];
  cout << endl;


  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#define initdp(a, b)  for (int i = 0; i <= a; i++)   for (int j = 0; j <= b; j++) dp[i][j] = -1;
#define fi first
#define se second
#define pb push_back
#define pii pair<int, int>
#define ll long long
#define pll pair<ll, ll>
#define all(arr) arr.begin(), arr.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repd(i, n) for (int i = n - 1; i >= 0; i--)
#define fo(i, l, r) for (int i = l; i <= r; i++)
#define inf 1000000001
#define inf1 1000000000000000001
#define mod 1000000007
#define pie 3.14159265358979323846
#define N 1000005
#define mid(l, r) l + (r - l) / 2
#define vec vector<int>
#define vecl vector<ll>
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
#define umapi unordered_map<ll, ll>
#define umapc unordered_map<char, int>
#define endl "\n"
#define pui pair<int, pair<int,int> >
using namespace std;



/*
            ॐ
    || Jai Shree Ram ||  
 
 */

void solve(){
    
    int x, n;
    cin>>x>>n;

    set<int> st;
    for(int i=0; i<n; i++) {
        int z;
        cin>>z;
        st.insert(z);
    }

    bool found = false;
    int l= x;
    int r = x;

    while(!found) {
        if(st.find(l) == st.end() ) {
            cout<<l<<endl;
            return;
        }
        l--;
        if(st.find(r) == st.end()) {
            cout<<r<<endl;
            return;
        }
        r++;
    }



}

 
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout<<fixed<<setprecision(25);
    int t = 1;
    // //cin >> t;
    while (t--)
    {
        solve();
    }
}



Measured memory_bytes: 3564
s=input()
s0=s[0]
s1=s[1]
if s0==s1:
    if s[2]==s[3] and s[2]!=s0:
        print("Yes")
    else:
        print("No")
else:
    if (s[2]==s0 and s[3]==s1) or (s[2]==s1 and s[3]==s0):
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 3060
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
// #include<C:\Users\J\Desktop\AC\athead.h>
#define showa(v) for(int iii = 0; iii < v.size(); iii++){ cout << v[iii] << " ";} cout << endl;
#define show(iiii) cout << iiii << endl; 
#define shows(iiiii) cout << iiiii << " ";
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include <cmath>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <set>
#include <deque>
#include <numeric>
#include<tuple>
#include <utility>
#include <map>
using namespace std;

 
int main(){
    int x;
    cin >> x;
    if(x%100==0){
        cout << 1 << endl;
    }
    else{
        int target = x%100;
        int n = x/100;
        if(target > n*5){
            cout << 0;
        }
        else{
            cout << 1;
        }

    }

}

Measured memory_bytes: 256
#include<iostream>
#include<set>
#include<map>
#include<string>
using namespace std;
typedef pair<int,int> p;
typedef pair<int,p> P;
int main(){
	int n,h;
	set<int> box;
	string s;
	int x,y;
	while(cin>>n>>h,n||h){
		for(int j=0;j<h;j++){
			cin>>s>>x>>y;
			if(s=="xy"){
				for(int i=1;i<=n;i++)
				box.insert((x-1)*n*n+(y-1)*n+(i-1));
			}else if(s=="xz"){
				for(int i=1;i<=n;i++)
				box.insert((x-1)*n*n+(i-1)*n+(y-1));
			}else if(s=="yz"){
				for(int i=1;i<=n;i++)
				box.insert((i-1)*n*n+(x-1)*n+(y-1));
			}
		}
		cout<<n*n*n-box.size()<<endl;
		box.clear();
	}
	return 0;
}

Measured memory_bytes: 1980
n,k=map(int,input().split())
p=list(map(int,input().split()))

res=[]
for i in range(n):
    tmp=((p[i]*(p[i]+1))//2)/p[i]
    res.append(tmp)

ans=sum(res[:k])
ret=ans
for i in range(n-k):
    ret+=res[i+k]-res[i]
    ans=max(ret,ans)

print(ans)

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

const int mod = 1e9 + 7;
const long long INF = 1LL<<60;
using ll = long long;
using P = pair<int,int>;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

// https://www.hamayanhamayan.com/entry/2017/06/03/231142
// dp[i][j] : i個目までの問題を使って, 合計得点をj点にできるか？
// 作れる得点のうち, 10の倍数でない最大の数が答えとなる

int A[101010];
int dp[101][10101];

int main(){
    int N;
    cin >> N;
    
    rep(i, N) cin >> A[i];
    
    dp[0][0] = 1;
    
    rep(i, N) rep(j, 10001){
        if (dp[i][j]){
            dp[i+1][j] = 1;
            dp[i+1][j + A[i]] = 1;
        }
    }
    
    int ans = 0;
    
    rep(j, 10001){
        if (j % 10 && dp[N][j]) ans = max(ans, j);
    }
    
    cout << ans << endl;
}

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

//--------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX/3

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

//--------------------------------------------

int color[] = {0, 400, 800, 1200, 1600, 2000, 2400, 2800, 3200, 4801};
int coder[11] = {0};

int main(){
  int n;
  int a;

  scanf("%d",&n);

  REP (i, n) {
    scanf("%d",&a);
    REP (i, 9) {
      if (color[i] <= a && a < color[i + 1]) {
        coder[i] += 1;
        break;
      }
    }
  }

  int min = 0;
  int max = 0;
  if (coder[8] == 0) {
    REP (i, 8) if (coder[i] != 0) min += 1;
    max = min;
  } else {
    REP (i, 8) if (coder[i] != 0) min += 1;
    max = min + coder[8];
    if (min == 0) min = 1;
  }

  printf("%d %d\n",min, max);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<iostream>
using namespace std;
int main()
{
    int N;
    cin >> N;
    vector<int> vec(200);
    for (int i = 0; i < N; i++) {
        cin >> vec.at(i);
    }

    int arice_score = 0;
    int bob_score = 0;
    std::sort(vec.begin(),vec.end(),std::greater<int>());
    for (int i = 0; i < N; i ++) {
	    int val = vec[i];
	    if ((i + 1) % 2 != 0) {
		    arice_score += val;
	    } else {
		    bob_score += val;
	    }
    }

    cout << arice_score - bob_score << endl;


    return 0;
}


Measured memory_bytes: 256