akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using lint = long long int;
using ulint = unsigned long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T, class U> void assign(V<T>& v, int n, const U& a) { v.assign(n, a); }
template<class T, class... Args> void assign(V<T>& v, int n, const Args&... args) { v.resize(n); for (auto&& e : v) assign(e, args...); }


int main() {
  cin.tie(nullptr); ios_base::sync_with_stdio(false);
  string s;
  map<int, int> mp;
  set<int> st;
  int mx = 0;
  while (getline(cin, s)) {
    int a = stoi(s);
    mp[a]++;
    if (mp[a] == mx) {
      st.insert(a);
    } else if (mp[a] > mx) {
      mx = mp[a];
      set<int>().swap(st);
      st.insert(a);
    }
  }
  for (int e : st) {
    cout << e << '\n';
  }
}


Measured memory_bytes: 3224
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<cstring>
#include<functional>
#include<stack>
#include<queue>
#include <iomanip>
#include<map>
#include<limits>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<deque>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

using namespace std;

#define DBG cerr << '!' << endl;
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(ll (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(ll (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(10)

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

int main()
{
	int n,a,b;cin >> n >> a >> b;
	
	int cou = 0;
	while(b-a>1)
	{
		if(cou == 0)
		{
			a++;
		}
		else
		{
			b--;
		}
		cou = 1-cou;
	}
	
	if(cou == 1)
	{
		cout << "Alice" << endl;
	}
	else
	{
		cout << "Borys" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
import bisect
n=int(input())
l=list(map(int,input().split()))
l.sort()
ans=0
for i in range(n-2):
  for j in range(i+1,n-1):
    res=l[i]+l[j]
    ans+=bisect.bisect_left(l,res)-1-j
print(ans)

Measured memory_bytes: 68272
#include<bits/stdc++.h>
using namespace std;
int main(void){
    int n,x;
    int i;
    string s;
    cin>>n>>s;
    for(i=0;i<s.size();i++){
        x=n;
        while(x--){
            s[i]++;
            if(s[i]=='Z'+1)     s[i]='A';
        }
    }
    cout<<s<<endl;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();

		int ans = 0;
		for(int i = 1 ; i <= n ; i++) {
			String str = String.valueOf(i);
			int sum = 0;
			for(int j = 0 ; j < str.length() ; j++) {
				sum += Integer.parseInt(str.substring(j, j + 1));
			}
			if(sum >= a && sum <= b) {
				ans += i;
			}
		}
		System.out.println(ans);

		sc.close();

	}

}


Measured memory_bytes: 24404
//https://qiita.com/DaikiSuyama/items/9dba963ba74396b9b7fd
//インクルード(アルファベット順)
#include <algorithm>     //sort,二分探索,など
#include <bitset>        //固定長bit集合
#include <cmath>         //pow,logなど
#include <complex>       //複素数
#include <deque>         //両端アクセスのキュー
#include <functional>    //sortのgreater
#include <iomanip>       //setprecision(浮動小数点の出力の誤差)
#include <iostream>      //入出力
#include <iterator>      //集合演算(積集合,和集合,差集合など)
#include <map>           //map(辞書)
#include <numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include <queue>         //キュー
#include <set>           //集合
#include <stack>         //スタック
#include <string>        //文字列
#include <unordered_map> //イテレータあるけど順序保持しないmap
#include <unordered_set> //イテレータあるけど順序保持しないset
#include <utility>       //pair
#include <vector>        //可変長配列
using namespace std;
typedef long long ll;
//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (ll)(b); i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(), (x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())      //sizeをsize_tからllに直しておく
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007    //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first      //pairの一つ目の要素
#define S second     //pairの二つ目の要素
signed main()
{
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    //文字列入力
    string s;
    cin >> s;

    ll ans = 0;
    REP(i, 4)
    {
        if (s[i] == '+')
        {
            ans++;
        }
        else
        {
            ans--;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3644
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[][] lr = new int[n][2];
        for (int i = 0; i < n; i++) {
            lr[i][0] = sc.nextInt();
            lr[i][1] = sc.nextInt();
        }

        int pep = 0;
        for (int i = 0; i < n; i++) {
            pep += lr[i][1] - lr[i][0] + 1;
        }

        System.out.println(pep);
    }

}

Measured memory_bytes: 26032
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int main()
{
	int N, A, B;
	cin >> N >> A >> B;
	cout << min(N * A, B) << endl;
}


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

int main(void) {
	std::string s;

	std::cin >> s;

	if (s.length() == 3) {
		std::cout << s[2] << s[1] << s[0] << std::endl;
	}
	else {
		std::cout << s << std::endl;
	}

	return 0;
}

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

using namespace std;

using ll = long long;
const ll mod = 1e9 + 7;

#define mem(a, b) memset(a, b, sizeof(a))
#define REP(i, a) for (int i = 0; i < a; ++i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define ALL(a) a.begin(), a.end()

inline void quickread() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout << fixed << setprecision(10);
}

inline void print_vector(vector<int> &A){
    for (auto&& x : A){
        cout << x << " ";
    }
    cout << endl;
}

inline void print_array(const int A[], int n) {
    REP(i, n) {
        if (i < n - 1) {
            cout << A[i] << " ";
        } else {
            cout << A[i] << endl;
        }
    }
}

ll a[2001];

inline void solve() {
    int n;
    cin >> n;

    a[0] = 0;
    a[1] = 0;
    a[2] = 0;

    for (int i = 3; i <= n; ++i) {
        ll cur = 0;
        for (int j = 3; j < i; ++j) {
            cur += 1 * a[i - j];
            cur %= mod;
        }
        cur += 1;
        cur %= mod;
        a[i] = cur;
        // cout << i << " " << cur << endl;
    }

    cout << a[n] << endl;
}

int main() {
    // freopen("input.txt", "r", stdin);
    quickread();
    int t = 1;

    for (int _ = 0; _ < t; _++) {
        solve();
    }

    return 0;
}


Measured memory_bytes: 3592
#include<algorithm>
#include<iomanip>
#include<iostream>
#include<map>
#include<map>
#include<set>
#include<stack>
#include<string>
#include<vector>
#include<bitset>
#include<cmath>
using namespace std;
#define FOR(i,a,b) for(int i=(a); i<int(b); ++i)
#define RFOR(i,a,b) for(int i=(b)-1; i>=int(a); --i)
#define rep(i,n) FOR(i,0,n)
#define rep1(i,n) FOR(i,1,int(n)+1)
#define rrep(i, n) RFOR(i, 0, n)
#define rrep1(i, n) RFOR(i, 1, int(n) + 1)
#define all(c) begin(c), end(c)
#define al(d) d.begin(),d.end()
using namespace std;
template <typename T>
void putv(vector<T>& V){
	// cout << "The elements in the vector are: " << endl;
	for(auto x: V)
		cout << x << " ";
	cout << endl;
}
template <class T>
vector<T> getv(int n){
	vector<T> vec;
	rep(i,n){
		T input;
		cin >> input;
		vec.emplace_back(input);
	}
	return vec;
}
using AdjList = vector<vector<int>>;
using Weight = int;
using Flow = int;
struct Edge {
	int src, dst;
	Weight weight;
	Flow cap;
	Edge() : src(0), dst(0), weight(0) {}
	Edge(int s, int d, Weight w) : src(s), dst(d), weight(w) {}
};
using Edges = std::vector<Edge>;
using Graph = std::vector<Edges>;
using Array = std::vector<Weight>;
using Matrix = std::vector<Array>;

void add_edge(Graph &g, int a, int b, Weight w = 1) {
	g[a].emplace_back(a, b, w);
	g[b].emplace_back(b, a, w);
}
void add_arc(Graph &g, int a, int b, Weight w = 1) { g[a].emplace_back(a, b, w); }

// Recieve edge(=(int,int)) as an adj list.
AdjList getadj(int N, int M){
	// Initialize all lists of the graph as a empty vector.
	vector<int> init;
	vector<vector<int>> graph(N,init);

	rep(i,M){
		int a, b;
		cin >> a >> b;
		graph[a-1].emplace_back(b-1);
		graph[b-1].emplace_back(a-1);
	}
// rep(i,N)
// 	putv(graph[i]);
	return graph;
}

long long Manhattan_dist(long long x1, long long y1, long long x2, long long y2){return abs(x1-x2) + abs(y1-y2);}

void out(bool ans){
	if(ans == true) cout << "yes" << endl;
	else cout << "no" << endl;
}
void Out(bool ans){
	if(ans == true) cout << "Yes" << endl;
	else cout << "No" << endl;
}
void OUT(bool ans){
	if(ans == true) cout << "YES" << endl;
	else cout << "NO" << endl;
}
unsigned long long gcd(const unsigned long long a, const unsigned long long b){
	return (b==0) ? a : gcd(b,a%b);
}
int main(){
	string s;
	cin >> s;
	int len = s.length();
	cout << s[0] << len-2 << s[len-1] << endl;
}



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

using namespace std;

typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = (ll)1e9 + 7;

int main()
{
  int W, a, b; scanf("%d %d %d", &W, &a, &b);
  if (a > b) { swap(a, b); }
  int ans = max(0, b - (a + W));
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<map>
using namespace std;
int main()
{
	int N,M,X,Y;
	int i,j,mx=-200,mn=0x3f3f3f;
	int a;
	cin>>N>>M>>X>>Y;
	for(i=1;i<=N;i++)
	{
		cin>>a;
		mx=max(mx,a);
	}
	for(i=1;i<=M;i++)
	{
		cin>>a;
		mn=min(mn,a);
	}
	int k=0;
	for(i=X+1;i<=Y;i++)
		if(mn>mx&&i>mx&&i<=mn)
		{
			cout<<"No War";k=1;break;
		}
	if(k==0)
	cout<<"War";
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef long double ld; 
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<ll>::iterator sit;
typedef map<ll,ll>::iterator mit;

int a[111111];
ll diff[111111];
ll ans[111111];
int n, m;

ll dist(int l, int r)
{
	if(l<r) return r-l;
	else return (r+m-l);
}

void adddiff(int l, int r, int V)
{
	diff[l]+=V;
	diff[r+1]-=V;
}

void addrange(int l, int r, int V) //ans[l] += V, ..., a[r] += V + whatever
{
	//ans[l] += V
	//ans[r] += V + (r - l)
	if(l>r) return ;
	adddiff(l,l,V);
	adddiff(r+1,r+1,-(V+(r-l)));
	adddiff(l+1,r,1);
}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin>>n>>m;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		a[i]--;
	}
	ll tmp=0;
	for(int i=1;i<n;i++)
	{
		tmp+=dist(a[i-1],a[i]);
	}
	for(int i = 1; i < n; i++)
	{
		int l = a[i-1]; int r = a[i];
		if(l<r)
		{
			addrange(l+1,r,0);
			//cerr<<l+1<<' '<<r<<' '<<0<<'\n';
		}
		else
		{
			addrange(l+1,m-1,0);
			addrange(0,r,m-(l+1));
			//cerr<<l+1<<' '<<m-1<<' '<<0<<'\n';
			//cerr<<0<<' '<<r<<' '<<m-(l+1)<<'\n';
		}
	}
	for(int i=1;i<m;i++)
	{
		diff[i]+=diff[i-1];
	}
	ans[0] = diff[0];
	for(int i=1;i<m;i++)
	{
		ans[i]=ans[i-1]+diff[i];
	}
	ll res=0;
	for(int i=0;i<m;i++)
	{
		//cerr<<i<<' '<<tmp-ans[i]<<'\n';
		res=max(res,ans[i]);
	}
	cout<<tmp-res<<'\n';
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long;


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

    if (n >= 10) {
        cout << r << endl;
    } else {
        cout << r + 100 * (10 - n) << endl;
    }
}


Measured memory_bytes: 256
import collections
n = int(input())
a = list(map(int,input().split()))
count_delete = 0
count_dict = collections.Counter(a)
for k, v in count_dict.items():
    if k != v:
        if k > v:
            count_delete += v
        else:
            count_delete += min(v-k, v)
print(count_delete)

Measured memory_bytes: 18676
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <map>　　　　　　
#include <iostream>
#include <queue>
#include <set>　　　　　　
#include <string>　　　　　
#include <vector>
using namespace std;
int n,a[210],ans=0;
int main(){
    scanf("%d",&n);
    for (int i=1; i<=2*n; i++)
        scanf("%d",&a[i]);
    sort(a+1,a+2*n+1);
    for (int i=1; i<=n; i++)
        ans+=a[i*2-1];
    printf("%d\n",ans);
}

Measured memory_bytes: 3080
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
using namespace std;
int main()
{
	int n,ans=0;
	bool x;
	string s,a;
	cin >> n >> s;
	for(int i=0;i<n;i++){
		x=false;
		cin >> a;
		for(int start=0;start<a.length();start++){
			for(int skip=1;skip<a.length()+1;skip++){
				for(int k=0;k<s.length();k++){
					if(start+skip*k>=a.length()||s[k]!=a[start+skip*k])goto next;
				}
				x=true;
				next:;
			}
		}
		if(x)ans++;
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 1212
X, Y, Z, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

A.sort(reverse = True)
B.sort(reverse = True)
C.sort(reverse = True)

bi_comb = []
for i in range(min(X, K)):
    for j in range(min(Y, K)):
        if (i+1)*(j+1) <= K:
            bi_comb += [A[i]+B[j]]
bi_comb.sort(reverse = True)

tri_comb = []
for k in range(min(len(bi_comb), K)):
    for l in range(min(Z, K)):
        if (k+1)*(l+1) <= K:
            tri_comb += [bi_comb[k]+C[l]]
tri_comb.sort(reverse = True)

print (*tri_comb[:K], sep='\n')


Measured memory_bytes: 5484
use std::io::*;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: f64 = itr.next().unwrap().parse().unwrap();
    println!("{:.10}", 1f64.atan() * 8.0 * n);
}


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

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

    ll ans = 0;
    for(int h=1;h<=k;h++){
        for(int i=1;i<=k;i++){
            for(int j=1;j<=k;j++){
                ans += gcd(gcd(h,i), j);
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3632
def insertionSort( nums, n, g ):
    cnt = 0
    for i in range( g, n ):
        v = nums[i]
        j = i - g
        while j >= 0 and nums[j] > v:
            nums[ j+g ] = nums[j]
            j -= g
            cnt += 1
         
        nums[ j+g ] = v
    return cnt
         
def shellSort( nums, n ):
    g = []
    v = 1
    while v <= n:
        g.append( v )
        v = 3*v+1     
    g.reverse( )
    m = len( g )
    print( m )
    print( " ".join( map( str, g ) ) )  
    cnt = 0
    for i in range( m ):
        cnt += insertionSort( nums, n, g[i] )
    print( cnt )
 
 
n = int( input( ) )
nums = [ int( input( ) ) for i in range( n ) ]
nums.append( 0 )
shellSort( nums, n )
nums.pop( )
for v in nums:
    print( v )

Measured memory_bytes: 47248
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>

using namespace std;
#define MOD 1000000007
#define ll long long
#define rint register int
#define gc() getchar()
inline ll read(ll ans = 0, rint sgn = ' ', rint ch = gc())
{
	for(; ch < '0' || ch > '9'; sgn = ch, ch = gc());
	for(; ch >='0' && ch <='9';(ans*=10)+=ch-'0', ch = gc());
	return sgn-'-'?ans:-ans;
}
int H, W, a, b, c, row, col; char s[1005][1005]; ll K;
inline int fastpow(int s, ll n){int a = 1; for(; n; n&1 ? a = 1ll*a*s%MOD : 0, s = 1ll*s*s%MOD, n >>= 1); return a;}
struct Matrix{int c[2][2]; Matrix(){} Matrix(int c00, int c01, int c10, int c11){c[0][0]=c00,c[0][1]=c01,c[1][0]=c10,c[1][1]=c11;}}U,S,A,I(1,0,0,1),F;
inline Matrix operator * (Matrix &A, Matrix &B)
{
	return Matrix((1ll*A.c[0][0]*B.c[0][0]+1ll*A.c[0][1]*B.c[1][0])%MOD,
				  (1ll*A.c[0][0]*B.c[0][1]+1ll*A.c[0][1]*B.c[1][1])%MOD,
				  (1ll*A.c[1][0]*B.c[0][0]+1ll*A.c[1][1]*B.c[1][0])%MOD,
				  (1ll*A.c[1][0]*B.c[0][1]+1ll*A.c[1][1]*B.c[1][1])%MOD);
}
inline Matrix operator ^ (Matrix S, ll n){for(A = I; n; S = S*S, n >>= 1) if(n&1) A = A*S; return A;}
int main()
{
	H = read(), W = read(), K = read(); if(!K){puts("1"); return 0;}
	for(rint i = 1; i <= H; scanf("%s",s[i]+1), c += s[i][1]=='#'&&s[i][W]=='#', i++); row = c;
	for(rint j = 1; j <= W; c += s[1][j]=='#'&&s[H][j]=='#', j++); col = c-row;
	for(rint i = 1, j; i <= H; i++)
		for(j = 1; j <= W; s[i][j]=='#' ? ++a, b += row?j<W&&s[i][j+1]=='#':i<H&&s[i+1][j]=='#' : 0, j++);
	if(row&&col){puts("1"); return 0;} if(!row&&!col){printf("%d\n",fastpow(a,~-K)); return 0;}
	U = Matrix(a,MOD-b,0,c), F = Matrix(1,0,1,0), S = U^~-K, F = S*F, printf("%d\n",F.c[0][0]); return 0;
}

Measured memory_bytes: 1280
#include <stdio.h>
 
int main(){
	int k;
	int x;
    int total;
	scanf("%d", &k);
	scanf("%d", &x);
	total = k * 500;
	if(x <= total){
		printf("Yes""\n");
	}
  	else{
      	printf("No""\n");
    }
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long LL;
typedef vector<ll>VI;
typedef vector<bool>VB;
typedef pair<ll,ll>P;
typedef pair<double,double>P_D;
#define VV(T) vector<vector<T>>
#define PI 3.1415926535897932384626433832795
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define reprev(i, n) for (ll i = (ll)n - 1; i >= 0; i--)
#define bitrep(bit,A) for(int bit=A; ;bit=(bit-1)&A)
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) (ll)((a).size())
#define c_max(a, b) (((ll)a)>((ll)b)?(a):(b))
#define c_min(a,b) (((ll)a)<((ll)b)?(a):(b))
#define chmax(x,a) x=max(x,a)
#define chmin(x,a) x=min(x,a)
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define SORT(c) stable_sort(ALL(c))
#define $(x) {cout<<#x<<" = " <<(x)<<endl;}
#define fi first
#define se second
#define MAX 100100//5
#define MAX2 200100
#define MAX_6 1001001//6
#define MAX_7 10010010//7
#define SENTINEL 2000000000//9
#define NIL -1
const int MOD = 1000000007;
#define INF 1<<30
#define INFTY 1LL<<61
#define MAX_INT INT_MAX
#define Endl '\n'
#define greater greater<int>()
inline ll GCD(ll a,ll b){return b?GCD(b,a%b):a;}
inline ll lcm(ll a,ll b){return a*b/GCD(a,b);}
using Edge=pair<int,ll>;
using Graph=vector<vector<bool> >;//ll or Edge
using Edge=pair<int,ll>;
const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
// g++ -o a a.cpp -Wall -lm -std=c++17

int main(){
    int n;cin>>n;
    VI a(n);
    rep(i,n)cin>>a[i],--a[i];
    VI res;
    rep(i,n){
        int pivot=-1;
        for(ll j=(int)a.size()-1;j>=0;--j){
            if(a[j]==j){
                pivot=j;
                break;
            }
        }
        if(pivot==-1){
            cout<<-1<<endl;
            return 0;
        }
        res.push_back(pivot);
        a.erase(a.begin()+pivot);
    }
    reverse(ALL(res));
    for(auto v:res)cout<<v+1<<endl;
    return 0;
}

Measured memory_bytes: 3624
def main():
    import heapq
    X, Y, A, B, C = map(int, input().split())
    p = list(map(int, input().split()))
    q = list(map(int, input().split()))
    r = list(map(int, input().split()))
    hq = [None]*(A+B+C)
    for i, x in enumerate(p):
        hq[i] = (-x, 0)
    for i, x in enumerate(q):
        hq[A+i] = (-x, 1)
    for i, x in enumerate(r):
        hq[A+B+i] = (-x, 2)

    heapq.heapify(hq)

    hq2 = []

    x = 0
    y = 0
    ans = 0
    while(len(hq2) < X+Y - (x+y)):
        a, b = heapq.heappop(hq)
        a = -a
        if b == 0:
            if x < X:
                x += 1
                ans += a
            else:
                continue
        elif b == 1:
            if y < Y:
                y += 1
                ans += a
            else:
                continue
        else:
            hq2.append(a)
        if x == X and y == Y:
            break

    if x < X or y < Y:
        ans += sum(hq2)
    print(ans)


main()


Measured memory_bytes: 125264
package main

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

const (
	SCANNER_BUF_SIZE = 2 << 20

	INF = int64(math.MaxInt64)
	MOD = 1e9 + 7
)

var (
	writer  *bufio.Writer
	scanner *bufio.Scanner
)

func init() {
	writer = bufio.NewWriter(os.Stdout)
	scanner = bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, SCANNER_BUF_SIZE), SCANNER_BUF_SIZE)
}

func printf(f string, a ...interface{}) {
	fmt.Fprintf(writer, f, a...)
}

func sint64() int64 {
	scanner.Scan()
	bb := scanner.Bytes()
	i := int64(0)
	if bb[0] == '-' {
		for _, b := range bb[1:] {
			i *= 10
			i -= int64(b - '0')
		}
		return i
	}
	for _, b := range bb {
		i *= 10
		i += int64(b - '0')
	}
	return i
}

func suint64() uint64 {
	scanner.Scan()
	bb := scanner.Bytes()
	i := uint64(0)
	for _, b := range bb {
		i *= 10
		i += uint64(b - '0')
	}
	return i
}

func sstring() string {
	scanner.Scan()
	return scanner.Text()
}

func gcd(a, b int64) int64 {
	for b != 0 {
		a, b = b, a%b
	}
	return a
}

func lcm(a, b int64) int64 {
	return a * b / gcd(a, b)
}

func abs(a int64) int64 {
	if a < 0 {
		return a * -1
	}
	return a
}

func min(a int64, rest ...int64) int64 {
	for _, r := range rest {
		if r < a {
			a = r
		}
	}
	return a
}

func max(a int64, rest ...int64) int64 {
	for _, r := range rest {
		if r > a {
			a = r
		}
	}
	return a
}

func main() {
	defer writer.Flush()
	s := sstring()
	t := sstring()
	ans := 0
	for i := 0; i < len(s); i++ {
		if s[i] != t[i] {
			ans++
		}
	}
	printf("%d\n", ans)
}


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

int main () {
    int n;
    cin >> n;
    map<int, int> m; 
    for (int i = 0; i < n - 1; i++) {
        int x;
        cin >> x;
        x--;
        m[x]++;
    }

    for (int i = 0; i < n; i++) cout << m[i] << "\n";
}



Measured memory_bytes: 13004
#include<stdio.h>
int main(void){
	int S;
	scanf("%d",&S);
	int h,m,s;
	h=S/3600;
	S=S%3600;
	m=S/60;
	s=S%60;
	printf("%d:%d:%d\n",h,m,s);
	return 0;
}

Measured memory_bytes: 592
#include "bits/stdc++.h"
#include "sstream"
#define quick ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
const int N=2e4+1;
map<long long,int>mp;
long long  gcd(long long a, long long b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
int main() {
    quick
long long a,b,c,t; scanf("%lld",&a); scanf("%lld",&b);
c=gcd(a,b);
t=c; int ans=1;
for(long long i=2;i*i<=t;i++){
    if(c%i==0){ans++;}
    while(c%i==0){c/=i;}
}
if(c!=1) ans++;
printf("%d",ans);
}

Measured memory_bytes: 256
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import bisect

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

def LI(): return list(map(int, sys.stdin.readline().split()))
M1,D1 = LI()
M2, D2 = LI()
if M1 != M2:
    print("1")
else:
    print("0")


Measured memory_bytes: 6848
// Problem : 
// 			C - Five Transportations
// 			Editorial
// 		
// Contest : AtCoder - AtCoder Beginner Contest 123
// URL : https://atcoder.jp/contests/abc123/tasks/abc123_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;

/* DEBUGGING */
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif

/* MACROS */ 
typedef unsigned long long int ll;
 
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
 
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

typedef map<int,int> mii;

#define  ff          first
#define  ss          second
#define  pb          push_back
#define  IOS         ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define  lb          lower_bound
#define  ub          upper_bound
#define  all(x)      (x).begin(), (x).end()
#define  ps(x,y)     fixed<<setprecision(y)<<x
#define  setbit(x)   __builtin_popcountll(x)
#define  rep(i,a,b)  for(int i=a ; i<b ; ++i)
#define  repr(i,a,b) for(int i=a ; i>=b ; --i)

/* CONSTANTS */ 
#define PI 3.141592653589793
const ll MOD = 1e9 + 7;
const ll INF = 1000000000;
const ll MAX_N = 2e5 + 2;

// #define cerr if(false)cerr
/* CODE STARTS HERE */

void solve(){
	ll n; cin >> n;
	vll v(5);
	rep(i,0,5) cin >> v[i];
	ll mn = v[0] , ans;
	rep(i,0,5) mn = min(mn , v[i]);
	ans = (n/mn) + 5;
	ans = ans - (mn==1);
	cout << ans;
}

int main(){
    IOS;
    solve();
}


Measured memory_bytes: 3604
from collections import deque
while True:
    n=int(input())
    if n==0:
        exit()
    data = []
    for i in range(n):
        tmp = list(map(int,input().split()))
        tmp = [tmp[:4],tmp[4:8],tmp[8:12],tmp[12:]]
        d = [ [0 for i in range(3)]for i in range(3)]
        for i in range(3):
            for j in range(3):
                for k in range(2):
                    for l in range(2):
                        d[i][j] += tmp[i+k][j+l]
        data.append(d)
    
    q = deque()
    memo = set()
    if data[0][1][1]:
        print(0)
        continue
    q.append((0,1,1,(0,0,0,0)))
    while len(q):
        z,y,x,h = q.popleft()
        if (y,x) == (0,0):
            h = (0,h[1]+1,h[2]+1,h[3]+1)
        elif (y,x) == (0,2):
            h = (h[0]+1,0,h[2]+1,h[3]+1)
        elif (y,x) == (2,0):
            h = (h[0]+1,h[1]+1,0,h[3]+1)
        elif (y,x) == (2,2):
            h = (h[0]+1,h[1]+1,h[2]+1,0)
        else:
            h = (h[0]+1,h[1]+1,h[2]+1,h[3]+1)
        if max(h)>6:
            continue
        if (z,y,x,h) in memo:
            continue
        memo.add((z,y,x,h))
        if z==n-1:
            print(1)
            break
        for i in range(3):
            if not data[z+1][i][x]:
                q.append((z+1,i,x,h))
            if not data[z+1][y][i]:
                q.append((z+1,y,i,h))
    else:
        print(0)

        




Measured memory_bytes: 18480
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<limits>
using namespace std;
using uint = unsigned int;
using ll = long long;

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

uint N;
ll A[200001];
uint l, c, r;

ll getVal() {
  ll prev_diff, curr_diff;
  ll cval = A[c], eval = A[N];

  // left side
  prev_diff = numeric_limits<ll>::max();
  while (1) {
    curr_diff = abs((cval - A[l]) - (A[l] - 0));
    if (curr_diff > prev_diff) {
      --l;
      break;
    }

    prev_diff = curr_diff;
    ++l;
    if (l >= c) {
      --l;
      break;
    }
  }

  // right side
  prev_diff = numeric_limits<ll>::max();
  while(1) {
    curr_diff = abs((eval - A[r]) - (A[r] - cval));
    if (curr_diff > prev_diff) {
      --r;
      break;
    }

    prev_diff = curr_diff;
    ++r;
    if (r >= N) {
      --r;
      break;
    }
  }

  // calc val
  ll sum[4];
  sum[0] = A[l] - 0;
  sum[1] = cval - A[l];
  sum[2] = A[r] - cval;
  sum[3] = eval - A[r];
  ll maxval = *max_element(sum, sum+4);
  ll minval = *min_element(sum, sum+4);
  return maxval - minval;
}

int main() {
  scanf("%u", &N);

  A[0] = 0;
  REP(i,N) {
    scanf("%llu", &A[i+1]);
    A[i+1] += A[i];
  }

  ll minval = numeric_limits<ll>::max();
  for (l = 1, c = 2, r = 3; c <= N - 2; ++c) {
    if (r <= c) r = c + 1;   
    ll val = getVal();
    if (val < minval) minval = val;
  }

  printf("%llu\n", minval);
  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;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 NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;
#define out(a) cout<<fixed<<setprecision((a))


int main(){
	ll N,K;
	cin >> N >> K;
	if((N-1)*(N-2)<2*K){
		cout << -1 << endl;
		return 0;
	}
	vector<ll> u,v;
	FOR(i,2,N+1){
		u.push_back(1);
		v.push_back(i);
	}
	ll k = (N-1)*(N-2)/2;

	ll i = 2;
	ll j = 3;
	while(k>K){
		k--;
		u.push_back(i);
		v.push_back(j);
		j++;
		if(j==(N+1)){
			i++;
			j = i+1;
		}
	}
	if(i>N){
		cout << -1 << endl;
		return 0;
	}
	ll M = u.size();
	cout << M << endl;
	FOR(i,0,M){
		cout << u[i] << " " << v[i] << endl;
	}
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define FAST ios_base:: sync_with_stdio(false),cin.tie(0),cout.tie(0);
typedef long long ll;

int main(){
	FAST;
	int i;
	ll ans = 0;
	ll a[5];
	for( i=0; i<5; i++){
		cin >> a[i];
		ans += a[i] - a[i]%10;
		a[i] = a[i]%10;
	}
	sort(a,a+5);
	for( i=0 ; i<5 ; i++){
		if(a[i]!=0)
			break;
	}
	if(i!=5)
	ans += 10*(5-i-1);
	ans += a[i];
	cout << ans;
}




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


vector<int> colors;
int a[105][105];


int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    int p;
    scanf("%d",&p);
    for(int i=1;i<=p;i++){
        int x;
        scanf("%d",&x);
        for(int j=1;j<=x;j++)
            colors.push_back(i);
    }
    int k=0;
    for(int i=1;i<=n;i++){
        if(i&1){
            for(int j=1;j<=m;j++){
                a[i][j]=colors[k++];
            }
        }
        else {
            for(int j=m;j>=1;j--)
                a[i][j]=colors[k++];
        }
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++)

            if(j!=m) printf("%d ",a[i][j]);
            else printf("%d\n",a[i][j]);
    }
    return 0;
}



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

int main(){
    string s;
    cin >> s;
    sort(s.begin(), s.end());
    char charcmp = 'a';
    int i = 0;
    if(s[i] != charcmp){
        cout << charcmp << endl;
        return 0;
    }
    while (charcmp != 'z')
    {
        while (s[i] == charcmp){
            i++;
        }
        charcmp++;
        if (s[i] != charcmp){
            cout << charcmp << endl;
            return 0;
        }
    }
    cout << "None" << endl;
    return 0;
}

Measured memory_bytes: 512
#include<stdio.h>
int main(){
int c=0,d=0,a=0,num,x,n,m,z,f,s;
while(1){
x=getchar();
if(x=='0')
break;
else
num=x-'0';
while(1){
	n=getchar();
	if(n=='\n'){
		printf("%d\n",num);
		num=0;
		break;
	}
	num+=n-'0';
}
}

return 0;
}

Measured memory_bytes: 524
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <list>
#include <string>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <iomanip> // setprecisionを使用するのに必要 cout << fixed << setprecision(15) << p でpを小数点以下15桁表示
using namespace std;
#define REPD(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) REPD(i, 0, n)
#define DIV0 1000000007
typedef long long ll;
#define fin(ans) cout << (ans) << '\n'
/*

*/
int main()
{
    int X,N;
    cin >> X >> N;
    int p[150] = {0};
    REP(i,N){
        p[i] = 0;
    }
    int temp;
    REP(i,N){
        cin >> temp;
        p[temp]++;
        //cout << "p[" << temp << "]="<< p[temp] << endl;
    }
    int ans;
    int mindiff = 100000;
    REP(i,150){
        if(p[i] == 0){
            if(abs(X-i) < mindiff){
                ans = i;
                mindiff = abs(X-i);
            }
        }
    }
    fin(ans);
    return 0;
}

Measured memory_bytes: 3200
#include<stdio.h>

int main()
{
  char ans[20];
  char str[20];

  scanf("%s", str);

  int i;
  for (i = 0; i < 19; i++) {
    if(str[i] == ',') {
      ans[i] = ' ';
      continue;
    }
    ans[i] = str[i];
  }
  ans[i] = '\0';
  printf("%s\n", ans);
  return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
int main(void){
    // Your code here!
    int a,b,n;
    scanf("%d%d%d",&a,&b,&n);
    
    for(int i=0;i<n;i++){
        if(i%2==0){
            a=a/2;
            b=b+a;
        }
        else{
            b=b/2;
            a=a+b;
        }
        //printf("%d %d %d \n",i,a,b);
    }
    printf("%d %d\n",a,b);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

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

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int n;
    cin >> n;
    vector<pair<int,int>> r(n);
    rep(i,n){
        int x,l;
        cin >> x >> l;
        r[i].first = x+l;
        r[i].second= x-l;
    }
    sort(ALL(r));
    int ans = 0;
    int s = -1e9;
    rep(i,n){
        if(s<=r[i].second){
            s = r[i].first;
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <stack> 
using namespace std;
static const int N = 100;
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n,M[N][N];
int color[N],d[N],f[N],tt;
int nt[N]; 

int next(int u){
	for(int v=nt[u];v<n;v++){
		nt[u]=v+1;
		if(M[u][v]) return v;
	}
	return -1;
}

void dfs_visit(int r){
	for(int i=0;i<n;i++) nt[i]=0;
	
	stack<int> S;
	S.push(r);
	color[r]=GRAY;
	d[r]=++tt;
	
	while(!S.empty()){
		int u=S.top();
		int v=next(u);
		if(v!=-1){
			if(color[v] == WHITE){
				color[v] = GRAY;
				d[v] = ++tt;
				S.push(v);
			}
		}else{
			S.pop();
			color[u]=BLACK;
			f[u]=++tt;
		}
	}
	 
}


void dfs(){
	for(int i=0;i<n;i++){
		color[i]=WHITE;
		nt[i]=0;
	}
	
	tt=0;
	
	for(int u=0;u<n;u++){
		if(color[u]==WHITE) dfs_visit(u);
	}
	
	for(int i=0;i<n;i++){
		cout<<i+1<<" "<<d[i]<<" "<<f[i]<<endl;
	}
}


int main() {
	int u,k,v;
	
	cin>>n;
	
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			M[i][j]=0;
		}
	}
	
	for(int i=0;i<n;i++){
		cin>>u>>k;
		u--;
		for(int j=0;j<k;j++){
			cin>>v;
			v--;
			M[u][v]=1;
		}
	}
	
	dfs();
	
	return 0;
}

Measured memory_bytes: 3100
#include <bits/stdc++.h>
#include <vector>
 
using namespace std;
const double PI=3.14159265358979323846;
 
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
#define rep(i, n) for (int i = 0; i < (n); ++i)

int main() {

	string s;
	cin >> s;

	string ans = "No";
	if (s[2] == s[3] && s[4] == s[5]) ans = "Yes";

	cout << ans << endl;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		String[] s  = line.split(" ");
		int height =Integer.parseInt(s[0]);
		int width=Integer.parseInt(s[1]);
		System.out.print(menseki(height,width));
		System.out.print(" ");
		System.out.println(shuu(height,width));
	}

	private static int menseki(int height, int width) {
		return height * width;
	}

	private static int shuu(int height, int width) {
		return (height + width) * 2;
	}
}

Measured memory_bytes: 26036
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<climits>
#include<set>
#include<utility>
#include<typeinfo>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef set<int> S;
#define rep(i, n) for(int i=0; i<n; i++)
const ll MOD=1e9+7;

int main(){

	ll k, a, b, ans=1;
	cin >> k >> a >> b;
	if(b-a<=2){
		cout << k+1 << endl;
		return 0;
	} else {
		k=k-a+1;
		ans+=a-1;
		if(k<=0){
			cout << k+1 << endl;
			return 0;
		} else {
			ans+=k/2*(b-a);
			ll tmp=k/2;
			k-=tmp*2;
			ans+=k;
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define llu unsigned long long int
#define sa(a,n,t) for(int ii=0;ii<n;ii++) scanf("%"#t"",&(a)[ii])
#define rep(i,n) for(int i=0;i<n;i++) 
#define reps(i,a,n) for(int i=a;i<n;i++) 
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rreps(i,a,n) for(int i=n-1;i>=a;i--)
#define validl(i,a,b) ((i>=a)&&(i<=b))?1:0
#define validmat(x,y,a,b,c,d) (validl(x,a,b) && validl(y,a,b))?1:0
#define validmn(x,y,m,n) validmat(x,y,0,m,0,n)
#define valid(i,n) validl(i,0,n)
#define v(t) vector<t>
#define vv(t) vector<vector<t> >
#define mk make_pair
#define pb push_back
#define pa(a,n,t)  for(int i=0;i<n;i++) printf("%"#t"",a[i])
#define p2 pair<int,int>
#define p3 pair<p2,int>
#define fi first
#define se second
#define sd(a) scanf("%d",&a)
#define sl(a) scanf("%lld",&a)
#define pl(a) printf("%lld",a)
#define pd(a) printf("%d",a)
#define sf(a) scanf("%lf",&a)
#define pf(a) printf("%lf",a)
#define nline printf("\n")
#define ss(a) scanf("%s",a)
#define ps(a) printf("%s",a)
#define sc(a) scanf("%c",&a)
#define pc(a) printf("%c",&a)
#define mf(m,f) m.find(f)!=m.end()
#define pp3(m) cout<<m.fi.fi<<" "<<m.fi.se<<" "<<m.se<<" "
#define pp2(m) cout<<m.fi<<" "<<m.se<<" "
#define debug 0
/*v(int) adj[200001];
void dfs(int i,int p){
    rep(j,adj[i].size()){
        if(p!=adj[i][j])
            dfs(adj[i][j],i);
    }
}*/
int main()
{
  int x,n;
  int arr[301]={0},a;
  cin>>x>>n;
  rep(i,n) cin>>a,arr[a]=1;
  int ans;
  reps(i,x,x+101) if(arr[i]!=1) {ans=i;break;}
  for(int i=x;i>=0;i--)if(arr[i]!=1 && ans-x>=x-i) {ans=i;break;}
  cout<<ans;
  nline;
  return 0;
}


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

int n, m, p;

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	while(1){
		cin >> n >> m >> p;
		if(n == 0 && m == 0 && p == 0) return 0;
		int s = 0, t = 0;
		for(int i=0; i<n; ++i){
			int tmp;
			cin >> tmp;
			s += tmp;
			if(i == m-1) t = tmp;
		}
//		cout << s << " " << t << "\n";
		s *= 100;
		s = s * (100 - p) / 100;
		if(t == 0) cout << 0 << "\n";
		else{
			s /= t;
			cout << s << "\n";
		}
	}
}


Measured memory_bytes: 3036
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N =sc.nextInt();
		double sumJ=0;
		double sumB=0;
		
		for(int i=0;i<N;i++) {
			double x = sc.nextDouble();
			String y =sc.next();
			if(y.equals("JPY")) {
				sumJ+=x;
			}
			else {
				sumB+=x;
			}
		}
		
		sumJ+=(sumB*380000);
		System.out.println(sumJ);
		
		sc.close();
	}
}


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

//#define DEBUG
#ifdef DEBUG
#define debug_printf printf
#else
#define debug_printf 1 ? 0 : printf
#endif

using namespace std;
typedef long long int ll;
typedef vector<ll> Vl;
typedef vector<int> Vi;
typedef pair<int, int> Pi;

#define INF   (1e9 + 7)
#define MAX_N (5000)
#define MAX_K (5000)

int N, K;
int A[MAX_N];
bool DP[MAX_K];

void solve() {
  sort(A, A + N);
  ll sum = 0;
  for (int i = 0; i < N; i++) sum += A[i];
  for (int j = 0; j < K; j++) DP[j] = false;
  DP[0] = true;

  int ans = 0;
  for (int i = N - 1; i >= 0; i--) {
    bool no_need = true;
    for (int j = 0; j < K; j++) {
      if (DP[j] && j + sum >= K) {
        no_need = false;
        break;
      }
    }
    if (no_need) ans++;
    debug_printf("sum = %lld, a = %d\n", sum, A[i]);
    for (int j = 0; j < K; j++) debug_printf("%s ", DP[j]? "o": "x");
    debug_printf("\n");

    for (int j = K - A[i] - 1; j >= 0; j--) DP[j + A[i]] |= DP[j];

    sum -= A[i];
  }
  printf("%d\n", ans);
}

int main() {
  scanf("%d %d", &N, &K);
  for (int i = 0; i < N; i++) scanf("%d", &A[i]);

  solve();

  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main(){
  int r, g;
  cin >> r >> g;
  cout << 2*g-r << endl;
  //if(abs(x,a)<abs(x,b)){cout<<'A'<<endl;}
  //else{cout<<'B'<<endl;}
 
  return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
OKlist = [0]*(10**6+100)
A.sort()
for i in range(len(A)-1):
    if A[i] == A[i+1]:
        OKlist[A[i]] += 1
    else:
        for j in range(10**6+10):
            if A[i]*j > 10**6:
                break
            else:
                OKlist[A[i]*j] += 1
OKlist[max(A)] += 1
cnt = 0
for i in A:
    if OKlist[i] == 1:
        cnt += 1
        
print(cnt)


Measured memory_bytes: 96928
#include<bits/stdc++.h>
using namespace std;
int main(){
  char s[200];
  cin >> s;
  int n,m=999;
  for(int i=0;i<strlen(s)-2;i++){
    n=abs(((s[i]-'0')*100+(s[i+1]-'0')*10+(s[i+2]-'0'))-753);
    if(m>n)m=n;
  }
  cout << m;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<stack>
#include<queue>
#include<string>
#include<set>
#include<map>
using namespace std;
#define rep(i,n) for(int i=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int i=(m);(i)<(n);(i)++)
typedef long long ll;

bool check(ll m){
    int a=0,b=0,c=0;
    while(m>0){
        if(m%10==3)a=1;
        if(m%10==5)b=1;
        if(m%10==7)c=1;
        m/=10;
    }
    if(a+b+c==3)return true;
    else return false;
}

int main(){
    int n;
    cin >> n;
    queue<ll> s;
    s.push(0);
    int ans = 0;
    while(!s.empty()){
        if(s.front()>n){
            s.pop();
            continue;
        }
        ll a = s.front();
        s.pop();
        s.push(10*a+3);
        s.push(10*a+5);
        s.push(10*a+7);
        if(check(a))ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 768
// AOJ 2618: Trip to Kyoto
// 2018.1.25 bal4u@uu

#include <stdio.h>

#define ABS(a)    ((a)>=0?(a):-(a))
#define MIN(a,b)  ((a)<=(b)?(a):(b))

int x1[10002], y1[10002], x2[10002], y2[10002];
char *msg[2] = { "%d.0\n", "%d.5\n" };

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0;
	int c = getchar_unlocked();
	if (c == '-') {
		c = getchar_unlocked();
		do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
		while (c >= '0');
		return -n;
	}
	do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

int calc(int x1, int y1, int x2, int y2)
{
	x1 += 200000000, y1 += 200000000;
	x2 += 200000000, y2 += 200000000;
	if (x1%20 == 0 && x2%20 == 0) {
		if      (x1 == x2) return ABS(y1-y2);
		else if (y1/20 == y2/20) return ABS(x1-x2) + MIN(y1%20+y2%20, 40-y1%20-y2%20);
	} else if (y1%20 == 0 && y2%20 == 0) {
		if      (y1 == y2) return ABS(x1-x2);
		else if (x1/20 == x2/20) return ABS(y1-y2) + MIN(x1%20+x2%20, 40-x1%20-x2%20);
	}
	return ABS(x1-x2) + ABS(y1-y2);
}

int main()
{
	int n, x, y, i, j, k, s, t, ans;
	int xmin, xmax, ymin, ymax;
	int x0, y0;

	n = in();
	x = in() << 1, y = in() << 1;
	x1[0] = x, y1[0] = y, xmin = xmax = x2[0] = x+y, ymin = ymax = y2[0] = x-y;
	for (i = 1; i < n; i++) {
		x = in() << 1, y = in() << 1;
		x1[i] = x,   y1[i] = y;
		x2[i] = x+y, y2[i] = x-y;
		if      (x2[i] < xmin) xmin = x2[i];
		else if (x2[i] > xmax) xmax = x2[i];
		if      (y2[i] < ymin) ymin = y2[i];
		else if (y2[i] > ymax) ymax = y2[i];
	}
 
	x = (xmin + xmax) >> 1, y = (ymin + ymax) >> 1;
	x0 = (x + y) >> 1, y0 = (x - y) >> 1;

	ans = 0x7fffffff;
	for (i = x0-40; i <= x0+40; i++) {
		for (j = y0-40; j <= y0+40; j++) {
			if (i%20 && j%20) continue;
			t = 0; for (k = 0; k < n; k++) if (t < (s = calc(i, j, x1[k], y1[k]))) t = s;
			if (ans > t) ans = t;
		}
	}
	printf(msg[ans & 1], ans >> 1);
	return 0;
}


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

class dice{
public:
	int a[6];
	int b;
	void moveN(){
		b = a[0];
		a[0] = a[1];
		a[1] = a[5];
		a[5] = a[4];
		a[4] = b;
	}
	void moveS(){
		b = a[0];
		a[0] = a[4];
		a[4] = a[5];
		a[5] = a[1];
		a[1] = b;
	}
	void moveE(){
		b = a[0];
		a[0] = a[3];
		a[3] = a[5];
		a[5] = a[2];
		a[2] = b;
		
	}
	void moveW(){
		b = a[0];
		a[0] = a[2];
		a[2] = a[5];
		a[5] = a[3];
		a[3] = b;
	}
};

int main(){
	dice c;
	string d;
	for (int i = 0; i < 6; i++){
		cin >> c.a[i];
	}
	cin >> d;
	for (int i = 0; i < d.size(); i++){
		if (d[i] == 'N'){
			c.moveN();
		}
		if (d[i] == 'S'){
			c.moveS();
		}
		if (d[i] == 'E'){
			c.moveE();
		}
		if (d[i] == 'W'){
			c.moveW();
		}
	}

	cout << c.a[0] << endl;

	return 0;
}


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

using namespace std;

typedef long long int lli;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n, i, j, size, l, r;
    cin >> n;
    lli a[n];
    lli prefsum[n];
    
    for(i = 0; i < n; ++i)
    {
        cin >> a[i];
    }
    
    lli dp[n][n];
    prefsum[0] = a[0];
    dp[0][0] = 0;
    for(i = 1; i < n; ++i)
    {
        dp[i][i] = 0;
        prefsum[i] = prefsum[i - 1] + a[i];
    }
    lli base;
    for(size = 2; size <= n; ++size)
    {
        for (l = 0; l < n - size + 1; ++l)
        {
            r = l + size - 1;
            dp[l][r] = prefsum[r];
            if (l > 0)
            {
                dp[l][r] -= prefsum[l - 1];
            }
            
            base = dp[l][r];
            
            dp[l][r] += dp[l][l];
            dp[l][r] += dp[l + 1][r];
            
            for(i = l + 1; i < r; ++i)
            {
                dp[l][r] = min(dp[l][r], base + dp[l][i] + dp[i + 1][r]);
            }
        }
    }
    
    
    cout << dp[0][n - 1];
    
    return 0;
}


Measured memory_bytes: 1536