akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
using namespace std;
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 (b<a) {a=b; return 1;} return 0;}

int main(){
    ll a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;
    ll c_max = max(x, y) * 2;
    ll ans = 1LL<<60;
    rep(i, c_max+1) {
        ll price = max(a * (x - i/2), 0LL) + max(b * (y - i/2), 0LL) + c * i;
        chmin(ans, price);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include<vector>
#include<iostream>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<iomanip>
#include<assert.h>
#include<unordered_map>
#include<unordered_set>
#include<string>
#include<stack>
#include<complex>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;
	
#define WHATS(var)//cout<<__LINE__<<' '<<#var<<"="<<var<<endl;
	
template<class S, class T> ostream& operator <<(ostream &os, const pair<S, T> v){
	os << "( " << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator <<(ostream &os, const vector<T> &v){
	for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator <<(ostream &os, const vector<vector<T>> &v){
	for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
template<class T> ostream& operator <<(ostream &os, const vector<set<T>> &v){
	for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
template<class T> ostream& operator <<(ostream &os, const set<T> &v){
	int i=0;
	for(auto it:v){
		if(i > 0){os << ' ';}
		os << it;
		i++;
	} 
	return os;
}

using ll =long long ;
ll mod;

void solve(vector<vector<int>>&cango){
	int tt=cango.size();
	for(int i=0;i<tt;++i){
		for(int j=0;j<tt;++j){
			for(int k=0;k<tt;++k){
				cango[j][k]|=cango[j][i]&cango[i][k];
			}
		}
	}
}
int main() {
	ios::sync_with_stdio(false);
	int N;cin>>N;
	vector<int>v(N);
	for(int i=0;i<N;++i){
		char ch;cin>>ch;
		v[i]=ch=='T';
	}
	int now=((!v[0])||v[1]);
	for(int i=2;i<N;++i){
		now=((!now)||v[i]);
	}
	if(now)cout<<'T'<<endl;
	else cout<<'F'<<endl;
	return 0;	
}


Measured memory_bytes: 3356
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i < n; ++i)
#define repe(i, n) for(int i=0; i <= n; ++i)
#define repr(i, n) for(int i=n-1; i > 0; --i)
#define all(x) (x).begin(), (x).end()
#define pb(x) push_back(x)
using namespace std;
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 <class T> using V=vector<T>;
typedef long long ll;
const int INF = 1e9;
const ll MOD = 1000000007;
const ll MAX = 510000;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    int n,l,v;
    cin >> n >> l;
    vector<int> V;
    for(int i=1; i<=n; ++i) {
        V.pb(l+i-1);
    }
    int risou = 0;
    rep(i,n) {
        risou += V[i];
    }
    int act = 0;
    int res  =0;
    int diff = INF;
    rep(i,n) {
        act = risou-V[i];
        if (abs(act-risou) < diff) {
            diff = abs(act-risou);
            res = act;
        }
    }
    cout << res << "\n";
}


Measured memory_bytes: 256
while True:
    h,w = map(int,input().split())
    if h == 0 and w == 0:
        break
    else:
        for i in range(h):
            for j in range(w):
                if (i+j) % 2 == 0:
                    print("#",end="")
                else:
                    print(".",end="")
            print()
        print()


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

    dif = [0 for i in range(n)]
    for i in range(n):
        dif[i] = a[i] - i - 1

    dif.sort()
    if n % 2 == 0:
        med = (dif[n//2-1]+dif[n//2]) // 2
        med2 = med + 1
    else:
        med = med2 = dif[n//2]

    dm1, dm2 = 0, 0
    for i in range(n):
        dm1 += abs(dif[i]-med)
        dm2 += abs(dif[i]-med2)

    print(min(dm1, dm2))


if __name__ == '__main__':
    main()


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

int main() {
  int n,x=0,ans=0;
  string s;
  cin >> n >> s;
  for (int i = 0; i < n; i++) {
    s[i] == 'I' ? x++ : x--;
    ans = max(ans, x);
  }
  cout << ans << endl;
}

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

using namespace std;
typedef long long ll;

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

	for(int i = 1; i <= 9; i++){
		for(int j = 1; j <= 9; j++){
			if(i * j == n){
				cout << "Yes" << endl;
				return 0; 
			}
		}
	}

	cout << "No" << endl;	
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
 
#define N 3
#define LIM 32
#define HN 362897
 
struct dep{
    int depth,key;
};
 
int ans[N][N]={
    {1,2,3},
    {4,5,6},
    {7,8,0}
    };
 
int min = LIM;
struct dep h[HN];
 
int hash1(int k)
{
    return k % HN;
}
int hash2(int k)
{
    return 1 + k%(HN-1);
}
int hash(int k, int i)
{
    return (hash1(k) + i*hash2(k))%HN;
}
 
 
void dfs(int p[N][N], int n)
{
    int i,j,i0,j0,a=0,b=1;
    int f=0;
    int tmp[N][N];
    for(i=0;i<N;i++)
    {
        for(j=0;j<N;j++)
        {
            if(ans[i][j]!=p[i][j])f++;
            if(p[i][j]==0)
            {
                i0=i;
                j0=j;
            }
            a+=p[i][j]*b;
            b*=10;
        }
    }
     
    if(f==0)
    {
        if(min>=n)
        {
            min=n;
        }
        return;
    }
    if(n>min) return;
    i=0;
    while(1)
    {
        b=hash(a, i);
        if(h[b].key == 0)
        {
            h[b].key=a;
            h[b].depth=n;
            break;
        }
        else if(h[b].key == a)
        {
            if(h[b].depth>n)
            {
                h[b].depth=n;
                break;
            }
            else return;
        }
        i++;
    }
     
    if(i0>0 && i0<N)
    {
        memcpy(tmp,p,sizeof(int)*N*N);
        f=tmp[i0][j0];
        tmp[i0][j0]=tmp[i0-1][j0];
        tmp[i0-1][j0]=f;
        dfs(tmp, n+1);
    }
    if(j0>0 && j0<N)
    {
        memcpy(tmp,p,sizeof(int)*N*N);
        f=tmp[i0][j0];
        tmp[i0][j0]=tmp[i0][j0-1];
        tmp[i0][j0-1]=f;
        dfs(tmp, n+1);
    }
     
    if(i0>=0 && i0<N-1)
    {
        memcpy(tmp,p,sizeof(int)*N*N);
        f=tmp[i0][j0];
        tmp[i0][j0]=tmp[i0+1][j0];
        tmp[i0+1][j0]=f;
        dfs(tmp, n+1);
    }
    if(j0>=0 && j0<N-1)
    {
        memcpy(tmp,p,sizeof(int)*N*N);
        f=tmp[i0][j0];
        tmp[i0][j0]=tmp[i0][j0+1];
        tmp[i0][j0+1]=f;
        dfs(tmp, n+1);
    }
     
}
 
int main()
{
    int i,j;
    int p[N][N];
     
    for(i=0;i<N;i++)
    {
        for(j=0;j<N;j++)
        {
            scanf("%d",&p[i][j]);
        }
    }
    dfs(p,0);
     
    printf("%d\n",min);
     
    return 0;
}


Measured memory_bytes: 4696
#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--) //逆ループ

//型名省略
typedef long long ll;
//値
static const ll MX = 100005;
static const ll MX_ll = 1e18;

using namespace std;

//#include "./lib/generic/search.h"

int main(){
    ll n, ans=0;
    cin >> n;
    vector<int> cnt(n+1);
    for(int i=1; i<=n; i++){
        for(int p=i; p<=n; p=p+i){
            cnt[p]++;
        }
    }
    for(int i=1; i<=n; i++){
        ans+=ll(i)*cnt[i];
    }
    cout << ans << endl;
    return 0;
}

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

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define replrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) replrev(i,0,n)
#define repi(itr,ds) for(auto itr = ds.begin(); itr != ds.end(); ++itr)
#define mp make_pair
#define INF 2000000000
#define MOD 1000000007
#define PI 3.1415926536
typedef long long ll;
typedef pair<int, int> P;

int main() {
	int N, A, B;
	cin >> N >> A >> B;
	vector<int>x(N);
	rep(i, N)cin >> x[i];
	double th = B / (double)A;
	ll ans = 0;
	rep(i, N - 1) {
		if (x[i + 1] - x[i] < th) {
			ans += (ll)(x[i + 1] - x[i])*A;
		}
		else {
			ans += B;
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 768
//** aman**/
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define dl          double
#define hell        1000000007
#define endl        '\n'
#define rep(i,a,b) for(int i=a;i<b;i++)
#define lb lower_bound
#define ub upper_bound
#define bs          binary_search
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
int main(){
	ll a,b;cin>>a>>b;
	ll g=__gcd(a,b);
	ll cnt=1;
	for(ll i=2;i<=sqrt(g);i++){
		if(g%i==0)cnt++;
		while(g%i==0){
			g=g/i;
		}
	}
	if(g>1)cnt++;
	cout<<cnt<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

            int Cx = -1;
            int Cy = -1;
            int Ch = -1;
            for (int X = 0; X <= 100; X++) {
                YLoop: for (int Y = 0; Y <= 100; Y++) {
                    int H = -1;
                    for (int i = 0; i < N; i++) {
                        if (h[i] <= 0) {
                            continue;
                        }
                        H = h[i] + Math.abs(x[i] - X) + Math.abs(y[i] - Y);
                        if (H > 0) {
                            break;
                        }
                    }
                    for (int i = 0; i < N; i++) {
                        if (h[i] != h(X, Y, H, x[i], y[i])) {
                            continue YLoop;
                        }
                    }
                    Cx = X;
                    Cy = Y;
                    Ch = H;
                }
            }

            System.out.println(Cx + " " + Cy + " " + Ch);

        }
    }

    private static int h(int X, int Y, int H, int x, int y) {
        return Math.max(H - Math.abs(x - X) - Math.abs(y - Y), 0);
    }

}


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

// mod（素数だけ）の処理を忘れさせてくれるライブラリ
// https://github.com/atcoder-live/library/blob/master/mint.cpp
const int mod = 1000000007;
struct mint {
  long long x;
  mint(long long x = 0):x((x % mod + mod) % mod) {}
  mint operator-() const {return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(long long t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res /= a;
  }
};

// n_C_kを求めるライブラリ
// mint.cppが必要
// https://github.com/atcoder-live/library/blob/master/combination.cpp
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; i++) {
      fact[i] = fact[i-1] * i;
    }
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; i--) {
      ifact[i-1] = ifact[i] * i;
    }
  }
  mint operator()(int n, int k){
    if (k < 0 || k > n) {
      return 0; 
    } else {
      return fact[n] * ifact[k] * ifact[n-k];
    }
  }
};

int main() {

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

  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }

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

  // combinationの初期化
  // n を N よりちょっと多めに
  combination c(N+5);

  // 最大値の総和
  mint answer = 0;

  for (int i = 0; i < N; i++) {
    mint count = c(i, K-1);
    answer += count * A[i];
  }

  // 最小値の総和
  reverse(A.begin(), A.end());

  for (int i = 0; i < N; i++) {
    mint count = c(i, K-1);
    answer -= count * A[i];
  }

  cout << answer.x << endl;

}

Measured memory_bytes: 2176
#include <bitset>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
#include <queue>
#include <stdio.h>
#include <math.h>

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

typedef pair<int, int> pii;


#define rep(i, n) for(int i=0; i<(n); ++i)
#define repp(i, a, b) for(int i = (a); i <= (b); i++)
#define repm(i, a, b) for(int i = (a); i >= (b); i--)

#define all(v) v.begin(), v.end()
//sort( all(v) )　などと使える

int n;
ll m;
vector<ll> a;
vector<ll> s;
map<ll, ll> mod_map;

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

    a.resize(n);
    rep(i, n){

        int a_i; cin >> a_i;
        a[i] = a_i % m;

    }
    
    s.resize(n+1);

    s[0] = 0; mod_map[s[0]]++;
    rep(i, n){

        s[i+1] = (s[i] + a[i]);
        mod_map[ s[i+1] % m ]++;

    }


   
    ll ans = 0;
    
    for(auto k: mod_map){
        ans += k.second * (k.second-1) / 2;
    }

    cout << ans << endl;
}

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

int main() {
    int A,B;
    cin >> A >> B;
    int temp=A+B;
    if(A-B > temp){
        temp=A-B;
    }
    if (A*B > temp){
        temp=A*B;
    }
    cout << temp;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll=long long;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;

int main(){
    int n;
    cin >> n;
    bool yes=false;
    rep(i,n){
        int a;
        cin >> a;
        if(a%2==0 && (a%3==0 || a%5==0)) continue;
        else if(a%2==1) continue;
        else{
            yes = true;
            break;
        }
    }

    if(yes) cout << "DENIED" << endl;
    else cout << "APPROVED" << endl;
}

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

#define int long long
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rept(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(int)(n);(i)++)
#define repst(i,s,n) for(int (i)=(s);(i)<=(int)(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>=0;(i)--)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define dbg(x) cout<<#x" = "<<(x)<<ln

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int> > mat;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const int mod = (int)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

int q, a, b, c, d, k, s, x, y, z;

void getCenter() {
	int l = 0, r = a + 1;
	while (r-l>1) {
		// 境目まででAをm個使うと仮定
		int m = (r+l)/2;
		// その時残るAとBの個数 m%k==0の場合はBはm/k-1個しか使わないことに注意
		int na = a - m;
		int nb = b - max(0ll, (m-1)/k);
		// 残ってるA,BでまだAAAAB...の続きを作れる場合
		if (nb <= (na+1)*k) l = m;
		else r = m;
	}
	// で求まったlが境目までのAの個数
	// つまりs = (l-1)/kとすると
	s = (l-1)/k;
	// 境目の左側は
	// [0, x = s*(k+1)) の範囲ではAAAABをs回繰り返す
	x = s*(k+1);
	// [x, y = l+s) の範囲では余ったAのみを繰り返す
	y = l+s;
	// でBはl = b-s個残るので、ABBBBはs = (l-1)/k個作れる それらが末尾に続く
	l = b-s;
	s = (l-1)/k;
	// [y, z) の範囲は余ったBのみを繰り返す
	z = a+b - s*(k+1);
}

signed main() {
	cin >> q;
	while (q--) {
		cin >> a >> b >> c >> d;
		c--, d--;
		// ABAB..とかBABA..って交互に置くだけの場合
		if (a==b || a==b+1) {
			repst(i,c,d) cout << (i%2==0 ? 'A' : 'B');
			cout << ln;
		}
		else if (b==a+1) {
			repst(i,c,d) cout << (i%2==0 ? 'B' : 'A');
			cout << ln;
		}
		else {
			// 同じ文字のみからなる部分文字列の最長の長さ
			k = (max(a,b) + min(a,b)) / (min(a,b) + 1);
			// f(A,B)は「'A'*k + 'B'」がいくつか繋がった前半と「'A' + 'B'*k」がいくつか繋がった後半に分けられる
			// 前半と後半の境目は二分探索で求める
			getCenter();
			repst(i,c,d) {
				if (i<x) cout << (i%(k+1)==k ? 'B' : 'A');
				else if (i<y) cout << 'A';
				else if (i<z) cout << 'B';
				else cout << ((i-z)%(k+1)==0 ? 'A' : 'B');
			}
			cout << ln;
		}
	}
}

Measured memory_bytes: 384
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

namespace MyProgram{
    public class Program
    {	
        static char[,] A;
        static char[,] B;
        static int N;
        static int M;
        
        public static void Main(string[] args)
    	{
            string[] s = Console.ReadLine().Split(' ');
            N = int.Parse(s[0]);
            M = int.Parse(s[1]);
            
            A = new char[N,N];
            B = new char[M,M];
            bool ok = false;
            
            
            string ss;
            for(int i = 0 ; i < N ; i++)
            {
                ss = Console.ReadLine();
                for(int j = 0 ; j < N ; j++) A[i,j] = ss[j];
            }
            for(int i = 0 ; i < M ; i++)
            {
                ss = Console.ReadLine();
                for(int j = 0 ; j < M ; j++) B[i,j] = ss[j];
            }
            
            for(int i = 0 ; i < N - M+1 ; i++)
            {
                for(int j = 0 ; j < N - M+1 ; j++)
                {
                    if(check(i,j))ok = true;
                }
            }
            
            if(ok) Console.WriteLine("Yes");
            else Console.WriteLine("No");
    	}
    	public static bool check(int x , int y)
    	{
    	    char[,] c = new char[M,M];
    	    for(int i = 0 ; i < M ; i++)
    	    {
    	        for(int j = 0 ; j < M ; j++)
    	        {
    	            c[i,j] = A[i+x,j+y];
    	            if(B[i,j] != c[i,j]) return false; 
    	        }
    	    }
    	    
    	    return true;
    	}
    }
}

Measured memory_bytes: 11092
num = gets.to_i
blocks = gets.chomp.split(" ").map(&:to_i)

target = 1
breaking = 0
breaking_count = 0

num.times do |i|
  if blocks[breaking] == target
    target += 1
  else
    breaking_count += 1
  end
  breaking += 1
end

puts "-1" if num == breaking_count
puts breaking_count if num != breaking_count

Measured memory_bytes: 16772
#include<iostream>
#include<vector>
using namespace std;
int main(){
  int n,m;
  cin>>n>>m;
  string s[n];
  for(int i=0;i<n;i++)
    cin>>s[i];
  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
      if(s[i][j]=='#')
        continue;
      else{
        int cnt=0;
        for(int dx=-1;dx<=1;dx++){
          for(int dy=-1;dy<=1;dy++){
            int y=i+dy,x=j+dx;
            if(0<=x&&x<m&&0<=y&&y<n){
              if(s[y][x]=='#')
                cnt++;
              }
            }
          }
        s[i][j]=cnt+'0';
        }
      }
    }
  for(int i=0;i<n;i++)
    cout<<s[i]<<endl;
  return 0;
  }


Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define ll long long int
#define pb push_back
void solve(){
    int n;
    cin>>n;
    int y=n/1000;
    if(n%1000==0){
        cout<<"0\n";
        return;
    }
    int u=(y+1)*1000;
    cout<<u-n<<"\n";
}
int main() {
	int t=1;
	//cin>>t;
	while(t--){
	    solve();
	}
	return 0;
}


Measured memory_bytes: 3592
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define jizz ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define ll long long
#define pb push_back
#define MEM(i,j) memset(i,j,sizeof i)
#define F first
#define S second
#define MP make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ET cout << "\n"
#define DB(a,s,e) {for(int i=s;i<e;++i) cout << a[i] << " ";ET;}
using namespace std;

const ll MOD=998244353;

ll dp[2001][2001],dp2[2001][2001];

ll solve(ll x,ll t,ll n)
{
	ll ans=dp[t-x][n];
	for(int i=1;i<=n;++i)
		ans=(ans+dp2[x][i]*dp[t-x][n-i])%MOD;
	return ans;
}

int main()
{jizz
	ll n,k,ans,t,x;
	cin >> k >> n;
	dp[0][0]=dp[1][0]=1;
	for(int i=1;i<=k;++i,dp[i][0]=1)
		for(int j=1;j<=n;++j)
			dp[i][j]=(dp[i][j-1]+dp[i-1][j])%MOD;
	dp2[0][0]=1,dp2[1][0]=1;
	for(int i=1;i<=k;++i,dp2[i][0]=1)
		for(int j=1;j<=n;++j)
			dp2[i][j]=(dp2[i-1][j]+dp2[i-1][j-1]+dp2[i][j-1])%MOD;
	for(int i=2;i<=2*k;++i)
	{
		t=k,x=0;
		for(int j=1;j<(i+1)/2;++j)
			if(i-j<=k) --t,++x;
		if(i&1) cout << solve(x,t,n) << "\n";
		else cout << (solve(x,t-1,n)+solve(x,t-1,n-1))%MOD << "\n"; 
	}
} 

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

int main(void){
	int N,M;
	cin >> N >> M;
	vector<int> L(M),R(M);
	for(int i=0;i<M;i++){
		cin >> L[i] >> R[i];
	}
	sort(L.begin(),L.end());
	sort(R.begin(),R.end());
	long long ans = min(N,R[0] - L[M-1]  + 1);
	if(ans<0)ans=0;
		cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define itn int
#define REP(i, n) for (int i = 0; i < n; i++)
#define IREP(i, n) for (int i = n - 1; i >= 0; i--)
#define REPEACH(i,k) for(auto&& i:k)
#define all(a) a.begin(),a.end()
#define MOD 1000000007
#define int long long
using namespace std;
typedef long long ll;

const ll INF = 1LL << 60;

signed main() {
	int n;
	cin >> n;
	vector<int> a(n);
	map<int,int> m;
	REP(i,n){
		cin >> a[i];
		if(n%2==a[i]%2){
			cout << 0 << endl;
			return 0;
		}
		m[a[i]]++;
	}
	int ans=1;
	REPEACH(i,m){
		if(i.first==0){
			if(i.second!=1){
				cout <<0 << endl;
				return 0;
			}
		}
		else{
			if(i.second==2){
				ans*=2;
				ans%=MOD;
			}
			else{
				cout << 0 << endl;
				return 0;
			}
		}
	}
	cout << ans << endl;
}		

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

using ll = long long;

ll a[510][510] = {};
    
int colum[510] = {};

int main(void){
    // Here your code !
    
    ll n;
    cin >> n;
    bool flag = true;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            char c;
            cin >> c;
            
            if(c == '#'){
                a[i][j] = 1;
                flag = false;
            }
            
        }
    }
    
    if(flag){
        cout << -1 << endl;
        return 0;
    }
    
    int t = 0;
    //すべての列を見る
    for(int i = 0; i < n; i++){
        
        bool f1 = true;
        bool f2 = true;
        
        for(int j = 0; j < n; j++){
            if(a[j][i]){
                f1 = false;
            }else{
                f2 = false;
            }
        }
        
        if(f2){
            colum[i] = 1;
            t++;
        }else if(f1){
            colum[i] = 2;
        }
    }
    
    ll Min = 1000000;
    
    for(int i = 0; i < n; i++){
        int tmp = 0;
        for(int j = 0; j < n; j++){
            if(!a[i][j])tmp++;
        }
        //cout << colum[i] << " " << n-t << " " << tmp << endl;
        Min = min(Min,((colum[i]==2)?1:0)+(n-t)+tmp);
    }
    
    cout << Min << endl;
    
    
    
}


Measured memory_bytes: 2304
#include <stdio.h>

int n;
int a[100000];

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

long long int count(int sf) {
	int i;
	long long int sum = 0, count = 0;
	
	for (i = 0; i < n; i++) {
		sum += a[i];
		if (!sf) {
			if (sum >= 0) {
				count += sum + 1;
				sum = -1;
			}
		}
		else {
			if (sum <= 0) {
				count += -sum + 1;
				sum = 1;
			}
		}
		sf = !sf;
	}
	return count;
}

int main(void) {
	int i;
	scanf("%d", &n);
	for (i = 0; i < n; i++)
		scanf("%d", &a[i]);

	printf("%lld\n", min(count(0), count(1)));
	return 0;
}

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

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


Measured memory_bytes: 3596
#include<iostream>
#include<string>
#include<utility>
#include<algorithm>
using namespace std;
bool cmp(pair<int,int> a,pair<int,int> b)
{
	if(a.second!=b.second)
	return a.second<b.second;
	return a.first<b.first;
}
int main()
{
	int n,m;
	cin>>n>>m;
	pair<int,int> arr[m];
	for(int i=0;i<m;i++)
		cin>>arr[i].first>>arr[i].second;
	sort(arr,arr+m,cmp);
	if(m==1)
	{
		cout<<1<<"\n";
		return 0;
	}
	int ans=0;
	int i=0;
	int end=arr[0].second;
	i=1;
	while(i<m)
	{
		while(i<m&&arr[i].first<end)
		i++;
		ans++;
		if(i!=m)
			end=arr[i].second;
	}
	cout<<ans;
	
}

Measured memory_bytes: 1152
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <bitset>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;

const ll MOD = 1000000007;
const long double EPS = 1e-10;
const int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

int main() {
    std::ios::sync_with_stdio(0); cin.tie(0);
    ll n,k;
    cin >> n >> k;

    long double ans = 0;
    for(ll i=1;i<=n;++i) {
        ll tmp = i, inv_p = 1;
        while(tmp < k) {
            tmp *= 2;
            inv_p <<= 1;
        }
        ans += (inv_p?(long double)1.0/inv_p:1.0);
    }
    ans /= n;
    cout << fixed << setprecision(12) << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h> 
#include<stdlib.h> 
#include <math.h>
int i,j;
#define N 5
#define rep(i,l,r) for(i=(l);i<(r);i++)
#define per(i,r,l) for(i=(r);i>(l);i--)
int main(){
	int n,a,b,c,sum=0;
	scanf("%d",&n);
	for(a=1;a<=n;a++){
		for(b=1;b<=n;b++){
			for(c=1;c<=n;c++){
				sum+=gcd(a,gcd(b,c));
			}
		}
	}
	printf("%d",sum);
	return 0;
}
int gcd(int a,int b){
	if(b==0)return a;
	return gcd(b,a%b);
}

Measured memory_bytes: 1696
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<sstream>
#include<complex>
#include<functional>
#include<vector>
#include<map>
#include<queue>
#include<deque>
#include<stack>
#include<set>

const int MOD = 1000000007;

using namespace std;

int main(){
    int i,n;
    cin >> n;
    float a[n],sum;
    for(i=0;i<n;i++){
        cin >> a[i];
        sum += 1.00000000000/a[i];
    } 


    sum = 1.0000000/sum;
    printf("%.10f\n",sum);

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
   int a,b,c;
   cin>>a>>b>>c;
   if(a+b>=c)
cout<<"Yes"<<endl;
else
    cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n, i;
	double arr[50];
	scanf("%d", &n);
	for(int i=0; i<n; i++){
		cin >> arr[i];
	}
	sort(arr, arr+n);
	double ans=arr[0];
	for(i=1; i<n; i++){
		ans=(ans+arr[i])/2;
	}
	cout << ans << "\n";
}


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


int main(void){
  int n,m,i,j,l[27][100005]={};
  string s,t;
  
  cin >> s >> t;
  n=s.size();
  m=t.size();
  
  for (i=0;i<n;i++) l[s[i]-'a'][i+1]++;
  for (i=0;i<26;i++) for (j=1;j<=n;j++){
    l[i][j]+=l[i][j-1];
  }
  
  for (i=0;i<m;i++){
    if (l[t[i]-'a'][n]==0){
      cout << -1 << endl;
      return 0;
    }
  }
  
  int p=0,lk,rou=0;
  int *sp;
  for (i=0;i<m;i++){
    lk=t[i]-'a';
    sp=lower_bound(l[lk]+p,l[lk]+n+1,l[lk][p]+1);
    if (p==n || sp==l[lk]+n+1){
      p=0;
      sp=lower_bound(l[lk],l[lk]+n+1,1);
      rou++;
    }
    p=sp-l[lk];
  }
  
  cout << (ll)n*rou+p << endl;
  
  return 0;
}

Measured memory_bytes: 11136
/**
 * Stack
 * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_3_A&lang=ja
 */

#include<iostream>
#include<vector>
#include <algorithm>
using namespace std;

int main() {
  // int N;
  // cin >> N;

  // 計算途中の値を入れておく
  vector <int>stack(100);

  while (1) {
    string s;
    cin >> s;
    // 入力が終了したら完了とする
    if (cin.eof()) {
      break;
    }
    if (s == "+" || s == "-" || s == "*") {
      // 演算対象の数値を2つ取り出す
      int b = stack.back();
      stack.pop_back();
      int a = stack.back();
      stack.pop_back();

      if (s == "+") {
        stack.push_back(a + b);
      }
      if (s == "-") {
        stack.push_back(a - b);
      }
      if (s == "*") {
        stack.push_back(a * b);
      }
    } else {
      stack.push_back(stoi(s));
    }
  }

  cout << stack.back() << endl;
  return 0;
}




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

#define vi vector<int>
#define vl vector<long>
#define vvi vector<vector<int>>
#define vvl vector<vector<long>>
#define pint pair<int, int>
#define plong pair<long, long>

int main() {
    string S;
    cin>>S;
    int ans = 0;
    REP(i, 0, S.size()){
        if(S[i] == '+') ans++;
        else ans--;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>
#include <iomanip>

using namespace std;

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

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class T>
void print_container(T &container, string delim=" ") {
    bool first = true;
    for(auto &t: container){
        if(!first){
            cout << delim;
        }
        first = false;
        cout << t;
    }
    cout << endl;
}

int main() {
    int n;
    cin >> n;
    cout << (n/2+n%2) / (double)n << endl;
    return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll n;
string s;
int main()
{
    cin >> s;
    n = s.size();
    ll i = 0,j = n - 1;
    while(i < j)
    {
        if(s[i] != s[j])
        {
            cout << "No";
            return 0;
        }
        i ++;
        j --;
    }
    i = 0,j = (n - 1) / 2 - 1;
    while(i < j)
    {
        if(s[i] != s[j])
        {
            cout << "No";
            return 0;
        }
        i ++;
        j --;
    }
    i = ((n + 3) / 2) - 1;j = n - 1;
    while(i < j)
    {
        if(s[i] != s[j])
        {
            cout << "No";
            break;
        }
        i ++;
        j --;
    }
    /*for(ll i = (n + 3) / 2 - 1;i < (n + (n + 3) / 2) / 2;i ++)
    {
        if(s[i] != s[n + (n + 3) / 2 - i])
        {
            cout << "No";
            return 0;
        }
    }*/
    cout << "Yes";
    return 0;
}
/*
akasaka
*/


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<unordered_map>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=2e18;
const ll MOD=1e9+7;

ll N,A,B;
int main(){
    cin>>N>>A>>B;
    if(A%2==B%2){
        cout<<(B-A)/2<<endl;
    }else{
        ll a=A + (B-A)/2;
        ll b=N-B+1 + (N-(A+(N-B+1)) )/2;
        cout<<min(a,b)<<endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define inrange(x,y,z) (((x)>=(y))&&((x)<=(z)))
using namespace std;
int n,m,nx,ny;
char grid[22][22];
int dist[22][22],dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
queue<pair<int,int> > q;
int Bfs(int x,int y){
	int ret=0;
	memset(dist,63,sizeof(dist));
	dist[x][y]=0;
	q.push(make_pair(x,y));
	while(q.size()){
		x=q.front().first;
		y=q.front().second;
		q.pop();
		ret=max(ret,dist[x][y]);
		for(int i=0;i<4;i++){
			nx=x+dx[i];ny=y+dy[i];
			if(grid[nx][ny]=='.'&&inrange(nx,1,n)&&inrange(ny,1,m)&&dist[nx][ny]>=1e9){
				dist[nx][ny]=dist[x][y]+1;
				q.push(make_pair(nx,ny));
			}
		}
	} 
	return ret; 
}
int main(){
	#ifdef FILIN
		#ifndef LOCAL
			freopen(FILIN,"r",stdin);
			freopen(FILOUT,"w",stdout);
		#endif
	#endif
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n>>m;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			cin>>grid[i][j];
		}
	}
	int res=0;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			if(grid[i][j]=='#') continue;
			res=max(res,Bfs(i,j));
		}
	}
	cout<<res<<endl;
	return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>

int bignumber(int a, int b){
    if(a>b){
        return(a);
    } else {
        return(b);
    }
}

int main(void){
    int a1,a2,a3;
    scanf("%d%d%d",&a1,&a2,&a3);
    int b1=abs(a1-a2),b2=abs(a2-a3),b3=abs(a3-a1);
    int ans=b1+b2+b3-bignumber(bignumber(b1,b2),b3);
    printf("%d\n",ans);
	return 0 ;
}

Measured memory_bytes: 128
//Bismillahir Rahmanir Rahim
// AtCoder-Battle
 
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int th,ts,ah,as;
  cin>>th>>ts>>ah>>as;
  int ahts = ceil((double) ah/ts);
  int thas = ceil((double) th/as);
  
  if(thas >= ahts) 
  cout<<"Yes\n";
  else cout<<"No\n";
  return 0;
}

Measured memory_bytes: 3640
#include <iostream>

using namespace std;

int main()
{
	string s;

	while(1){
		cin >> s;
		if (s == "0")
			break;
		int len = s.length();
		int sum = 0;
		for (int i = 0; i < len; i++){
			sum += (int)(s[i] - '0');
		}

		cout << sum << endl;
	}

	return 0;
}



Measured memory_bytes: 3140
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define repA(i,a,n) for(int i=a;i<n;i++)
#define trav(a,x)for(auto &a: x)
#define fll(a) memset(a,0,sizeof(a));
#define mp make_pair
#define pb push_back
#define all(x) x.begin(),x.end()
#define F first
#define S second
#define itr(it,x) for(auto it=x.begin();it!=x.end();it++)
typedef long long ll;
typedef long double ld;
typedef pair<int,int>pii;
typedef vector<int>vi;
typedef map<int,int>ma;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
# define PI    3.14159265358979323846  
void solve()
{
  ld r;
  cin>>r;
  cout<<2*PI*r;
 
}
int main()
{
  fastio;
 // fopen();
 // int t;
//  cin>>t;
  rep(i,1)
  { 
   // cout<<"Case #"<<i+1<<": ";
    solve();
    cout<<endl;
  }
  
}

Measured memory_bytes: 3796
def main():
    [width, height, cord_x, cord_y, radius] = list(map(int, input().split()))
    (circle_top,
     circle_left,
     circle_right,
     circle_bottom) = (cord_y + radius,
                       cord_x - radius,
                       cord_x + radius,
                       cord_y - radius)
    if circle_top <= height and circle_left >= 0 and circle_right <= width and circle_bottom >= 0:
        print('Yes')
    else:
        print('No')


main()

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

ll f(ll n) { return n*(n+1)/2;}

int main() {
  int n;
  cin >> n;
  ll ans = 0;
  vector<int> d(n+1);
  for (int i = 1; i <= n; i++) {
    for (int j = i; j <= n; j += i) d[j]++;
    // ll r = n/i;
    // ans += f(r)*i;
  }
  for (int i = 1; i <= n; i++) ans += ll(i)*d[i];
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 42292
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using loop = int;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(loop (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(loop (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(loop (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(loop (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause") //comment out this on AOJ.
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    int n; cin >> n;
    int ans = 0;
    FOR(i, 0, n) {
        int l, r; cin >> l >> r;
        ans += r - l + 1;
    }
    cout << ans << "\n";
}

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

using namespace std;
 
int main(){
    long long t,i,p=0;
    string s;
    cin>>s;
    t=s.size();
    for(i=0;i<t;i++){
        if(s[i]=='o')
        p++;
    }p=p+15-t;
    if(p>=8)
    cout<<"YES";
    else
    cout<<"NO";
    return 0;
    }
 


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


int main(void)
{
	//変数の宣言
	int h,w;
	static int a[510][510];
	static int map[510][510];
	int i,j;
	int flag=0;
	int ans;
	int count=0;
	//データの読み込み
	scanf("%d %d",&h,&w);
	
	for(i=0;i<h;i++){
		for(j=0;j<w;j++){
			scanf("%d",&a[i][j]);
		}
	}
		
//	printf("nは%dです\n", n);
//	printf("データの読み込み終了\n");
	//実際の処理
	
	for(i=0;i<h;i++){
		for(j=0;j<w-1;j++){
			if(a[i][j]%2==1){
				map[i][j]=1;
				a[i][j]--;
				a[i][j+1]++;
				count++;
			}
		}
		
		if(i!=h-1&&a[i][w-1]%2==1){
			map[i][w-1]=1;
			a[i][w-1]--;
			a[i+1][w-1]++;
			count++;
		}
	}
	
	
	
//	printf("計算部分終了\n");
	//出力
	
	printf("%d\n",count);
	for(i=0;i<h;i++){
		for(j=0;j<w-1;j++){
			if(map[i][j]==1){
				printf("%d %d %d %d\n",i+1,j+1,i+1,j+2);
			}
		}
		if(map[i][w-1]==1){
			printf("%d %d %d %d\n",i+1,w,i+2,w);
		}
	}
	
//	printf("結果の出力終了\n");
	
}



Measured memory_bytes: 3968
#include <stdio.h>
int main(void)
{
    int dice[7],i,tmp;
    char dir;
    
    for(i=1;i<=6;i++)
    {
        scanf("%d",&dice[i]);
    }
    while(scanf("%c",&dir)!=EOF)
    {
        if(dir=='E')
        {
            tmp=dice[1];
            dice[1]=dice[4];
            dice[4]=dice[6];
            dice[6]=dice[3];
            dice[3]=tmp;
        }
        else if(dir=='N')
        {
            tmp=dice[1];
            dice[1]=dice[2];
            dice[2]=dice[6];
            dice[6]=dice[5];
            dice[5]=tmp;
        }
        else if(dir=='S')
        {
            tmp=dice[1];
            dice[1]=dice[5];
            dice[5]=dice[6];
            dice[6]=dice[2];
            dice[2]=tmp;
        }
        else if(dir=='W')
        {
            tmp=dice[1];
            dice[1]=dice[3];
            dice[3]=dice[6];
            dice[6]=dice[4];
            dice[4]=tmp;
        }
    }
    printf("%d\n",dice[1]);
    
    return 0;
}



Measured memory_bytes: 2104
use std::io;
use std::cmp;
use std::collections::BinaryHeap;
use std::collections::HashMap;
use std::collections::HashSet;
use std::f64::consts::PI;

fn read_line() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).ok();
    buf
}


const EPS: f64 = 1e-9;

fn dfs(x: usize, i: usize, memo: &Vec<Vec<u64>>, vs: &Vec<u64>, memo2: &mut Vec<Vec<Option<usize>>>) -> usize {
    if i==0 {
        return 1;
    }
    if x==0 {
        return 0;
    }
    if memo2[x][i].is_some() {
        return memo2[x][i].unwrap();
    }
    let tar = memo[x][i];
    let mut ans = 0;
    if memo[x-1][i] == tar {
        ans += dfs(x-1, i, memo, vs, memo2);
    }
    if memo[x-1][i-1] + vs[x-1] == tar {
        ans += dfs(x-1, i-1, memo, vs, memo2);
    }
    memo2[x][i] = Some(ans);
    ans
}

fn main() {
    let line: Vec<usize> = read_line().split_whitespace().map(|s| s.parse().unwrap()).collect();
    let n = line[0];
    let a = line[1];
    let b = line[2];

    let vs: Vec<u64> = read_line().split_whitespace().map(|s| s.parse().unwrap()).collect();

    let mut memo = vec![vec![0; n+1]; n+1];
    for i in 0..n {
        for j in 0..i+1 {
            memo[i+1][j+1] = cmp::max(memo[i][j+1], memo[i][j] + vs[i]);

        }
    }
    let mut val = 0;
    let mut x = 1;
    for i in a..b+1 {
        let tmp = memo[n][i];
        if tmp * (x as u64) > val * (i as u64) {
            val = tmp;
            x = i;
        }
   }
   let mut ans = 0;
   let mut memo2 = vec![vec![None; n+1]; n+1];
   for i in a..b+1 {
       let tmp = memo[n][i];
        if tmp * (x as u64) == val * (i as u64) {
            ans += dfs(n, i, &memo, &vs, &mut memo2);
       }
   }
   println!("{:.9}", (val as f64)/(x as f64));
   println!("{}", ans);
}


Measured memory_bytes: 2244
#include <iostream>
#include <algorithm>
#include <string>
#include <sstream>
#include <map>
using namespace std;

int main() {
  map<string,int> m;
  m["A"] = m.size()-1;
  m["B"] = m.size()-1;
  m["AB"] = m.size()-1;
  m["O"] = m.size()-1;
  string s;
  int num[m.size()];
  fill(num, num+m.size(), 0);
  while(cin >> s) {
    replace(s.begin(), s.end(), ',', ' ');
    stringstream ss(s);
    int id;
    string kind;
    ss >> id >> kind;
    ++num[m[kind]];
  }
  for(int i = 0; i < m.size(); ++i) cout << num[i] << endl;

  return 0;
}

Measured memory_bytes: 1228
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Comparator;
import java.util.SortedSet;
import java.util.StringTokenizer;
import java.util.TreeSet;

import static java.lang.Integer.parseInt;

/**
 * Best Matched Pair
 */
public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;
		String[] words;

		int N = parseInt(br.readLine());
		int[] a = new int[N];

		StringTokenizer st = new StringTokenizer(br.readLine());

		for (int i = 0; i < N; i++) {
			a[i] = parseInt(st.nextToken());
		}

		SortedSet<Integer> pairs = new TreeSet<>(Comparator.reverseOrder());

		for (int i = 0; i < N; i++) {
			for (int j = i + 1; j < N; j++) {
				pairs.add(a[i] * a[j]);
			}
		}

		int ans = -1;
		for (int p : pairs) {
			if (check(p)) {
				ans = p;
				break;
			}
		}

		System.out.println(ans);

	} //end main

	static boolean check(int p) {

		String s = String.valueOf(p);
		boolean ret = true;

		char t = s.charAt(0);
		for (int i = 1; i < s.length(); i++) {
			if (t + 1 != s.charAt(i)) {
				ret = false;
				break;
			}
			t = s.charAt(i);
		}

		return ret;
	}
}

Measured memory_bytes: 88608
#include <iostream>
#include <cmath>
#include <cstdio>
#include <bits/stdc++.h>
using namespace std;

int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    int k=a*b/2;
    double l=c*1.0/k;
    if(l<=a)
    {
        double tanx=b/l;
        double x=atan(tanx);
        double ll=180.0/3.141592653589793;
        printf("%.10lf",x*ll);
    }
    else
    {
        double shen=a*a*b-c;
        shen/=a*a;
        shen*=2;
        double tanx=shen/(a*1.0);
        double x=atan(tanx);
        double ll=180.0/3.141592653589793;
        printf("%.10lf",x*ll);
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <chrono>
#include <complex>
#define fill(a,val) memset(a,val,sizeof(a))
#define endl "\n"
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define f first

#define M 315
using namespace std;
 

int main()
{
    std::ios::sync_with_stdio(false);
    int T = 1;
    //cin>>T;
    while(T--)
    {
       int temp = 0;
       int sum = 0;
       for(int  i = 0;i<5;i++)
       {
            cin>>temp;
            sum+=temp;
       }
       cout<<15-sum;

    }   
    
    return 0;
}


Measured memory_bytes: 3544
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <iostream>
#include <queue>
#include <string>
#include <unordered_set>
using namespace std;
#define max(a,b) (a>b?a:b)
#define min(a,b) (a>b?b:a)
int good_one;
int len;
long T;
struct infor{
	long sum;
	int length;
	bool is_good;
};
bool enough(long a){
	unordered_set<int> check;
	while(a!=0){
		check.insert(a%10);
		a/=10;
	}
	return check.size()==3;
}
void bfs(){
	queue<infor> Q;
	Q.push({0,0,false});
	infor cur;
	long temp;
	while(!Q.empty()){
		cur=Q.front();
		Q.pop();
		cur.length++;
		bool ori=cur.is_good;
		for(int i=3;i<=7;i+=2){
			temp=cur.sum;
			cur.sum=cur.sum*10+i;
			//cout<<cur.sum<<endl;
			if(!ori){
				cur.is_good=enough(cur.sum);
			}
			if(cur.is_good && cur.sum<=T) good_one++;
			
			if(cur.length<len && cur.sum<T) Q.push(cur);
			cur.sum=temp;
		}
	}
}
int get_len(long a){
	int sum=0;
	while(a!=0){
		sum++;
		a/=10;
	}
	return sum;
}
int main(){
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	cin>>T;
	len=get_len(T);
	good_one=0;
	bfs();
	cout<<good_one<<endl;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main(){
    int k, a[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    cin >> k;
    cout << a[k-1] << '\n';
    return 0;
}


Measured memory_bytes: 256