akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h> 
using namespace std; 
  
int MinimumNumIncreasingSubsequences(int arr[], int n) 
{ 
    multiset<int> last; 
  
    // last element in each  increasing subsequence  
    // found so far 
    for (int i = 0; i < n; i++) { 
  
        // here our current element is arr[i] 
        multiset<int>::iterator it = last.lower_bound(arr[i]); 
  
        // iterator to the first element larger  
        // than or equal to arr[i] 
        if (it == last.begin()) 
  
            // if all the elements in last larger 
            // than or to arr[i] then insert it into last 
            last.insert(arr[i]); 
  
        else { 
            it--; 
  
            // the largest element smaller than arr[i] is the number 
            // before *it which is it-- 
            last.erase(it); // erase the largest element smaller than arr[i] 
            last.insert(arr[i]); // and replace it with arr[i] 
        } 
    } 
    return last.size(); // our answer is the size of last 
} 
  
// Driver program 
int main() 
{ 
  	int n;
  	cin >> n;
  	int a[n];
  	for(int i=0;i<n;i++){
      cin >> a[i];
    }
  	cout << MinimumNumIncreasingSubsequences(a,n);
  
    return 0; 
} 

Measured memory_bytes: 5376
#!/usr/bin/env python3

import sys

DEBUG = False

def solve():
    return


def read_int_list(sep = " "):
    return [int(s) for s in sys.stdin.readline().rstrip().split(sep)]

def read_int():
    return int(sys.stdin.readline())

def dprint(*args, **kwargs):
    if DEBUG:
        print(*args, **kwargs)
    return


def main():
    a, b = read_int_list()
    for i in range(0, 1250):
        if int(i * 0.08) != a:
            continue
        if int(i * 0.1) != b:
            continue
        print(i)
        return
    print(-1)



if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using ii=pair<ll,ll>;
using vi=vector<ll>;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define INF (ll)1e18
#define all(x) (x).begin(),(x).end()
#define print(a); for(auto x:a)cout<<x<<" "; cout<<"\n";
#define mset(a); memset(a,0,sizeof(a));

ll n,cnt;
vector<queue<ll>>v(1005);
bool vst[1005];

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
    cin>>n;
    ll d;
    for(int i=1;i<=n;i++){
        for(int j=0;j<n-1;j++){
            cin>>d;v[i].push(d);
        }
    }
    ll cnt=0,ans=0;
    vi a;
    for(int i=1;i<=n;i++)a.pb(i);
    while(true){
        vi b;
        bool state=1;
        for(auto i:a){
            if(v[i].empty()||vst[i])continue;
            vst[i]=true;
            ll val=v[i].front();
            if(vst[val])continue;
            if(v[val].front()==i){
                state=0;vst[val]=true;v[val].pop();v[i].pop();cnt++;b.pb(i);b.pb(val);
            }
        }
        ans++;mset(vst);a=b;b.clear();
        if(state)break;
    }
    if(cnt<(n*(n-1))/2)cout<<"-1\n";
    else cout<<ans-1<<"\n";
}



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

int main() {
  set<string> S;
  int N;
  cin >> N;
  
  for(int i=0; i<N; ++i) {
    string Si;
    cin >> Si;
    S.insert(move(Si));
  }
  cout << S.size() << endl;
  return 0;
}

Measured memory_bytes: 15548
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "\n" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

lint gcd(lint a, lint b) { return b ? gcd(b, a%b) : a; }

int main() {

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

	lint N, K;
	cin >> N >> K;

	if (N %= K) {
		cout << min(K - N, N) << endl;
	}
	else cout << 0 << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define ep emplace_back
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(v) v.begin(), v.end()
#define revall(v) v.rbegin(), v.rend()
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
bool inside(int y,int x,int h,int w){ if(y<h && y>=0 && x<w && x>=0) return true; return false; }
template<class T> inline bool chmin(T& a, T b){ if(a > b){ a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b){ if(a < b){ a = b; return true; } return false; }






int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,a;cin >> n >> a;
	vector<int> x(n);
	rep(i,n) cin >> x.at(i);
	vector<vector<vector<ll>>> dp(n + 1, vector<vector<ll>>(n + 1, vector<ll>(n * 60)));
	dp[0][0][0] = 1;
	rep(i,n){
		rep(j,n){
			rep(k,n * 50 + 1){
				dp[i + 1][j][k] += dp[i][j][k];
				dp[i + 1][j + 1][k + x.at(i)] += dp[i][j][k];
			}
		}
	}
	ll ans = 0;
	for(int i = a; i <= a * n; i += a){
			ans += dp[n][i / a][i];
	}
	cout << ans << endl;
}


Measured memory_bytes: 62592
#include<iostream>
#include<algorithm>
#include<vector>
#include<bitset>
#include<map>

using namespace std;

typedef long long ll;

int N, M;
vector<vector<int>> E;

int color[100001];

void dfs(int pos, int bef, bool now_color, pair<int, int>& cnt) {
	color[pos] = now_color ? 1 : 2;
	if (now_color)cnt.first++;
	else cnt.second++;
	for (int i = 0; i < E[pos].size(); i++) {
		int nxt = E[pos][i];
		if (nxt == bef)continue;
		if (color[nxt] != 0 && color[nxt] + color[pos] != 3) {
			//二部グラフではない
			cnt.first -= 114514, cnt.second -= 114514;
			break;
		}
		if (color[nxt] == 0) {
			dfs(nxt, pos, !now_color, cnt);
		}
	}
}

int main() {

	cin >> N >> M;
	
	E.resize(N);
	for (int i = 0; i < M; i++) {
		int u, v;
		cin >> u >> v;
		u--, v--;
		E[u].push_back(v);
		E[v].push_back(u);
	}

	map<int, int> element_m;
	for (int i = 0; i < N; i++) {
		if (color[i] == 0) {
			pair<int, int> tmp;
			dfs(i, -1, true, tmp);
			if (tmp.first < 0 && tmp.second < 0) {
				cout << -1 << endl;
				return 0;
			}
			element_m[abs(tmp.first - tmp.second)]++;
		}
	}

	vector<pair<int, int>> element;
	for (auto it = element_m.begin(); it != element_m.end(); it++)element.push_back((*it));
	vector<int> dp(2 * N + 100, -1);

	int geta = 0;
	dp[0] = 0;
	for (int i = 0; i < element.size(); i++) {
		geta += element[i].second * element[i].first;
		for (int j = 0; j <= 2 * N; j++) {
			if (dp[j] >= 0)dp[j] = element[i].second;
			else if (j < 2 * element[i].first || dp[j - 2 * element[i].first] == -1)
				dp[j] = -1;//そのまま
			else dp[j] = dp[j - 2 * element[i].first] - 1;
		}
	}

	ll ans = 0;
	for (ll i = 0; i <= 2 * N; i++) {
		if (dp[i] >= 0) {
			ll diff = abs(i - geta);
			ans = max(ans, ((N - diff) / 2) * ((N - diff) / 2 + diff) - M);
		}
	}
	cout << ans << endl;
	return 0;
}


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

int main(){
    int cnt[26]={0};
    string w;
    cin >> w;
    rep(i,w.size()){
        int id = w[i]-'a';
        cnt[id]++;
    }
    rep(i,26){
        if (cnt[i]%2!=0){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    from itertools import product
    n=int(input())
    A=[list(map(int,list(input()))) for _ in range(n)]
    for i,j in product(range(n),repeat=2):
        if(i==j): continue
        if(A[i][j]==0): A[i][j]=INF
    B=[a[:] for a in A] # deep copy
    E=[[] for _ in range(n)]
    for i,j in product(range(n),repeat=2):
        if(i==j): continue
        if(A[i][j]==1): E[i].append(j)

    # bipartile check
    d=[-1]*n # -1: unvisited
    def dfs(v)->bool:
        # iterate
        res=True
        for nv in E[v]:
            if(d[nv]==-1):
                d[nv]=d[v]^1
                res=min(res,dfs(nv))
            else:
                res=min(res,d[nv]^d[v])
        return res

    for v in range(n):
        if(d[v]==-1):
            d[v]=0
            if(not dfs(v)):
                print(-1)
                return

    # Warshall-Floyd
    for k,i,j in product(range(n),repeat=3):
        B[i][j]=min(B[i][j],B[i][k]+B[k][j])

    # output
    diam=0
    for i,j in product(range(n),repeat=2):
        if(B[i][j]==INF): continue # connectedなので必要ない
        diam=max(diam,B[i][j])
    print(diam+1)
resolve()

Measured memory_bytes: 58332
n = map(int, input().split())
a = list(map(int, input().split()))
flag0 = False
flag1 = False
b = 1
for e in a:
    if e == 0:
        flag0 = True

    if b * e > 1000000000000000000:
        b = 0
        flag1 = True

    b *= e

if flag0 == True:
    print(0)
elif flag1 == True:
    print(-1)
else:
    print(b)


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

class Main {

	static int[][] dp;
	static int[] row;
	static int[] colmn;

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

		int n = Integer.parseInt(br.readLine());
		dp = new int[n][n];

		row = new int[n];
		colmn = new int[n];

		for (int i=0; i<n; i++) {
			String line = br.readLine();
			row[i] = Integer.parseInt(line.substring(0,line.indexOf(" ")));
			colmn[i] = Integer.parseInt(line.substring(line.indexOf(" ")+1));
		}

		System.out.println(rec(0,n-1));

		br.close();
	}

	static int rec(int i,int j){
		if (dp[i][j] != 0 || i==j)
			return dp[i][j];
		if (i-j == 1)
			return dp[i][j] = row[i] * colmn[i] * colmn[j];
		int min = Integer.MAX_VALUE;
		for (int k=i; k<j; k++){
			min = Math.min(min, rec(i,k) + rec(k+1,j) + row[i] * row[k+1] * colmn[j]);
		}
		return dp[i][j] = min;
	}
}

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

#define ll long long
#define L 100005
#define MX 1000000007
#define T int t; cin>>t; while(t--)


int main()
{
    int n, m, ans=0;
    cin>>n>>m;

    if(n>=2) ans+=(n*(n-1))/2;
    if(m>=2) ans+=(m*(m-1))/2;

    cout<<ans;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=3e5+5;
int n,tot,sum[N],a[N],b[N],ans[N];
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    sort(a+1,a+1+n);
    int t=1;
    for(int i=2;i<=n;i++)
    {
        if(a[i]==a[i-1]) t++;
        else b[++tot]=t,t=1;
    }
    b[++tot]=t;
    sort(b+1,b+1+tot);
    for(int i=1;i<=tot;i++) sum[i]=sum[i-1]+b[i];
    int p=0;
    for(int i=1,j=tot;i<=tot;i++,j--)
    {
        int l=ans[j+1],r=n/j,res;
        while(l<=r)
        {
            int m=l+r>>1;
            int pos=lower_bound(b+1,b+1+tot,m)-b-1;
            if(m*(pos-i+1)-sum[pos]+sum[i-1]<=p)
                res=m,l=m+1;
            else r=m-1;
        }
        ans[j]=res;
        p+=b[i];
    }
    for(int i=1;i<=n;i++) printf("%d\n",ans[i]);
}


Measured memory_bytes: 5504
#include<string>
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<functional>
using namespace std;
typedef long long int llint;
#define  pub push_back

//A
//BABA
int main(void){
	string st,iti;
	int i,j;
	int ia,ib,ic;
	cin>>st;
	for(j=0;j<5000;j++){
		if(st=="ABC"){ printf("Yes\n");break; }
		for(i=0;i<st.size();i++){
			iti.pub(st[i]);
			if(3<=iti.size()&&iti[iti.size()-3]=='A'&&iti[iti.size()-2]=='B'&&iti[iti.size()-1]=='C'){
				iti.pop_back();iti.pop_back();iti.pop_back();
				iti.push_back('X');
			}
		}
		ia=1;ib=1;ic=1;
		for(i=0;i<iti.size();i++){
			if(iti[i]=='A'){ia=0;}
			if(iti[i]=='B'){ib=0;}
			if(iti[i]=='C'){ic=0;}
		}
		if(ia+ib+ic!=1){printf("No\n");break;}
		st.clear();
		for(i=0;i<iti.size();i++){
			if(iti[i]!='X'){st.pub(iti[i]);}
			else if(ia==1){st.pub('A');}
			else if(ib==1){st.pub('B');}
			else if(ic==1){st.pub('C');}
		}
		iti.clear();
	}
	if(j==5000){printf("No\n");}
	return 0;
}

Measured memory_bytes: 3244
// A_B_Problem.cc
// ２つの整数 a と b を読み込んで、以下の値を計算するプログラムを作成して下さい
// ・a ÷ b ： d (整数)
// ・a ÷ b の余り ： r (整数)
// ・a ÷ b ： f (浮動小数点数)
// 【入力】
// 1行に２つの整数 a, b が与えられます。
// 【出力】
// d, r, f を１つの空白で区切って１行に出力して下さい。
// fについては、0.00001以下の誤差があってもよいものとします。
// 【制約】
// 1 ≤ a, b ≤ 10^9
// 【例】
// 入力：3 2、出力：1 1 1.50000
#include<cstdio>

int main( void) {
  int a, b;
  int d, r;
  double f;

  scanf( "%d %d", &a, &b);

  d = a / b;
  r = a % b;
  f = (double)a / b;

  printf( "%d %d %.8lf\n", d, r, f);

  return 0;
}



Measured memory_bytes: 2736
#include <iostream>
using namespace std;
int ans = 0;
void find(int n, long long sub, bool t, bool f, bool s)
{
    if(sub > n)
    {
        return;
    }
    if(t && s && f)
    {
        ans++;
    }
    find(n, sub * 10 + 3, true, f, s);
    find(n, sub * 10 + 5, t, true, s);
    find(n, sub * 10 + 7, t, f, true);
}
int main()
{
    int n;
    cin >> n;
    find(n, 0, false, false, false);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3608
import math
import sys
import os
from operator import mul
import numpy as np

sys.setrecursionlimit(10**7)

def _S(): return sys.stdin.readline().rstrip()
def I(): return int(_S())
def LS(): return list(_S().split())
def LI(): return list(map(int,LS()))

if os.getenv("LOCAL"):
    inputFile = basename_without_ext = os.path.splitext(os.path.basename(__file__))[0]+'.txt'
    sys.stdin = open(inputFile, "r")
INF = float("inf")


N = I()
A1 = LI()
A2 = LI()

if N == 1:
    print(A1[0]+A2[0])
    exit()

ans = 0
for i in range(N):
    ans = max(ans, sum(A1[:i])+sum(A2[i-1:]))


# A1n = np.zeros(N,dtype='int')
# A1n = np.array(A1)
# A2n = np.zeros(N,dtype='int')
# A2n = np.array(A2)

# A1_cum = np.zeros(N,dtype='int')
# A2_cum = np.zeros(N,dtype='int')
# A1_cum[1:] = A1n[1:].cumsum()
# A2_cum[1:] = A2n[:-1].cumsum()
# # print(A1_cum)
# # print(A2_cum)

# # 下に降りる最初の位置
# start = N - 2
# for i in range(N-1):
#     if A1_cum[N-1] - A1_cum[i] < A2_cum[N-1] - A2_cum[i]:
#         start = i
#         break

# ans = A1n[0] + A2n[-1] + A1_cum[start] + (A2_cum[-1] - A2_cum[start])

# # ans = sum(A1) + sum(A2) - min(A1[-1],A2[0]+A2[1])

print(ans)

Measured memory_bytes: 27140
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (ll i = m; i < n; ++i)
#define FORR(i, m, n) for (ll i = m; i >= n; --i)
#define ALL(v) (v).begin(),(v).end()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF=1LL<<60;
const int inf=(1<<30)-1;
const int mod=1e9+7;
int dx[8]={1,0,-1,0,-1,-1,1,1};
int dy[8]={0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m,t;cin >> n >> m >> t;
    vector<vector<int>> sum(n+1,vector<int>(n+1));
    REP(i,m){
        int l,r;cin >> l >> r;
        sum[l][r]++;
    }
    REP(i,n+1){
        REP(j,n){
            sum[i][j+1]+=sum[i][j];
        }
    }
    REP(j,n+1){
        REP(i,n){
            sum[i+1][j]+=sum[i][j];
        }
    }
    while(t--){
        int p,q;cin >> p >> q;
        cout << sum[q][q]-sum[p-1][q]-sum[q][p-1]+sum[p-1][p-1] << endl;
    }
}

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

int main(){
  int A,B,C;
  cin>>A>>B>>C;
  if(A==B){
    cout<<C<<endl;
  }
  else if (A==C){
    cout<<B<<endl;
  }
  else if(B==C){
    cout<<A<<endl;
  }
}


Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound

using namespace std;

int main() {
  int S, W;
  cin >> S >> W;
  if(S > W){
    cout << "safe" << endl;
  }
  if(W >= S){
    cout << "unsafe" << endl;
  }

  
  
}


Measured memory_bytes: 3132
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=19; 
inline int read()
{
	int x=0,ff=1;
	char ch=getchar();
	while(!isdigit(ch)) {if(ch=='-') ff=-1;ch=getchar();}
	while(isdigit(ch)) {x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}
	return x*ff;
}
int main()
{
//	freopen("1.in","r",stdin);
	double pai=3.1415926535;
	int n=read();
	double ans=2*n*pai;
	printf("%.2lf",ans);
	return 0;
}


Measured memory_bytes: 3764
#include<bits/stdc++.h>
using namespace std;
const int Mod = 1000000007;
long long dp[2000+10];
int main()
{
    int s;
    cin>>s;
    dp[0]=1;
    for(int i=3;i<=s;i++)
    {
        for(int j=3;j<=i;j++)
        {
            dp[i]+=dp[i-j];
            dp[i]%=Mod;
        }
    }
    cout<<dp[s];
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include <map>
#include <cmath>
#include <string>
using namespace std;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b)for(int i=(int)(a);(i)<(int)(b);i++)
typedef long long ll;


ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll c, ll d) { return c / gcd(c, d) * d; }

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

  vector<int> a(n);
  rep(i, n) {
      cin >> a[i];
  }

  sort(a.begin(), a.end());
  string ans = "YES";
  rep(i, n-1) {
      if (a[i] == a[i+1])
      {
          /* code */
          ans = "NO";
      }
  }
  cout << ans << endl;
}

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

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

  if ( N%2==0 ) {
    string A, B;
    rep( i, 0, N/2 ) {
      A += S[i];
    }
    rep( i, N/2, N ) {
      B += S[i];
    }
    if ( A==B ) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <typeinfo>
#include <cstring>
#include <utility>
#include <vector>
#include <bitset>
#include <cmath>
#include <algorithm>
#include <queue>

using namespace std;


int MAX = 1001;


int ceilInt(int x, int y) {
    return (x + y - 1) / y;
}


int minNumProblems(int bit, int D, long long G, vector<int>& p, vector<int>& c) {
    int result = 0;

    // count i'th bonus
    for (int i = 0; i < D; i++) {
        if (bit & (1<<i)) {  // i'th bonus
            G -= c[i];
            G -= p[i]*100*(i+1);
            result += p[i];
        }
    }

    if (G <= 0) return result;

    // Solve from the most difficult problems
    for (int i = D-1; i >= 0; i--) {
        if (!(bit & (1<<i))) {
            int numProblemsRequired = ceilInt(G, 100 * (i+1));
            if (numProblemsRequired <= p[i] - 1) {
                return result + numProblemsRequired;
            } else {
                // This should not be the answer.
                return MAX;
            }
        }
    }

    return MAX;
}


int main() {
    // inputs
    int D;
    long long G;
    cin >> D >> G;

    vector<int> p(D), c(D);
    for (int i = 0; i < D; i++) {
        cin >> p[i] >> c[i];
    }

    // all 2^D patterns in terms of bonus
    int ans = MAX;
    for (int bit = 0; bit < (1<<D); ++bit) {
        int hoge = minNumProblems(bit, D, G, p, c);
        // cout << bitset<10>(bit) << ": " << hoge << endl;
        ans = min(ans, hoge);
    }

    if (ans == MAX) cout << "What's wrong with you!" << endl;

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

// :!g++ -std=c++11 % && ./a.out
// :!tp %



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

signed main(){
  int N,ans=0;
  cin>>N;
  for(int i=1;i<=N;i++){
    ans+=i;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3568
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String s = sc.next();
		String t = sc.next();
		
		int dup = N;
		while(!s.substring(N-dup).equals(t.substring(0, dup))) {
			dup--;
		}
		
		System.out.println(N*2-dup);
		sc.close();
	}
}


Measured memory_bytes: 10320
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

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

typedef long long lint;

lint fact(lint n,lint p){
  lint r=1;
  REP(i,n){
    r*=i+1;
    r%=p;
  }
  return r;
}

lint pow_mod(lint a,lint b,lint p){
  if(b==0)return 1;
  if(b%2==0){
    lint d=pow_mod(a,b/2,p);
    return (d*d)%p;
  }else{
    return (a*pow_mod(a,b-1,p))%p;
  }
}

//x / a mod p=x * inv_mod(a,p) 
lint inv_mod(lint a,lint p){
  return pow_mod(a,p-2,p);//(a^(p-2))mod p
}

using namespace std;
lint p=1e9+7;
int main(){
  lint S;
  cin>>S;
  lint ans=0;
  REP(i,S){
    if(S-3-3*i<0)break;
    lint temp=fact(S-3-2*i,p);
    temp*=inv_mod(fact(S-3-3*i,p),p);
    temp%=p;
    temp*=inv_mod(fact(i,p),p);
    temp%=p;
    ans+=temp;
    ans%=p;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define X first
#define Y second
#define mkp make_pair
#define pb push_back
#define eb emplace_back
#define pob pop_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<", ";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

const ll MAXn=1e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=0x3f3f3f3f;

ll h[MAXn],dp[MAXn];
int main(){
  IOS();
  ll n,k;
  cin >> n >> k;
  REP (i,n) cin >> h[i], dp[i] = INF;
  dp[0] = 0;
  REP1 (i,n-1) {
    for (ll j=max(0LL,i-k);j<i;j++) {
      dp[i] = min(dp[i],dp[j]+abs(h[i]-h[j]));
    }
  }
  cout << dp[n-1] << endl;
}


Measured memory_bytes: 1792
package main

import "fmt"

func main() {
	var N, M, X, Y int
	fmt.Scanf("%d", &N)
	fmt.Scanf("%d", &M)
	fmt.Scanf("%d", &X)
	fmt.Scanf("%d", &Y)

	x := make([]int, N)
	y := make([]int, M)
	for i := 0; i < N; i++ {
		fmt.Scanf("%d", &x[i])
	}
	for i := 0; i < M; i++ {
		fmt.Scanf("%d", &y[i])
	}

	if X >= Y {
		fmt.Println("War")
		return
	}
	maxx := x[0]
	for _, xx := range x {
		if xx > maxx {
			maxx = xx
		}
	}

	miny := y[0]
	for _, yy := range y {
		if yy < miny {
			miny = yy
		}
	}

	if maxx >= Y {
		fmt.Println("War")
		return
	}

	if miny <= X {
		fmt.Println("War")
		return
	}
	if maxx >= miny {
		fmt.Println("War")
		return
	}
	fmt.Println("No War")
}


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

#define MAXN 100004

struct Day {
    int a, b, c;
};

vector<Day> vacation;
int dp[MAXN][4];

int main() {
  ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#ifdef _DEBUG
  freopen("/Users/huogenx/Desktop/__RUN__/input.txt", "r", stdin);
#endif
  int N; cin >> N;
  vacation.resize(N);
  for (int i = 0; i < N; i++) {
    cin >> vacation[i].a >> vacation[i].b >> vacation[i].c;
  }
  for (int i = 1; i <= N; i++) {
    dp[i][1] = max(dp[i-1][2], max(dp[i-1][3], dp[i][1]));
    dp[i][1] += vacation[i-1].a;

    dp[i][2] = max(dp[i-1][1], max(dp[i-1][3], dp[i][2]));
    dp[i][2] += vacation[i-1].b;

    dp[i][3] = max(dp[i-1][2], max(dp[i-1][1], dp[i][3]));
    dp[i][3] += vacation[i-1].c;
  }
  cout << max(dp[N][1], max(dp[N][2], dp[N][3]));
}

Measured memory_bytes: 2944
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <stack>
#include <vector>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define ll long long
#define inf 0x3f3f3f3f
using namespace std;

int main()
{
    int n; cin>>n;
    if(n & 1) printf("%.10lf\n",(n/2+1)/(n*1.0));
    else printf("%.10lf\n",(n/2)/(n*1.0));
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
vector<int> v;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long a=0,b,c,d=2,e=1,f=0,g=0;
  string s,u="CODEFESTIVAL2016";
  cin >>s;
  for(int n=0;n<16;n++){
    if(s[n]!=u[n]) a++;
  }
  cout<<a<<'\n';
  return (0);
}


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

int N;
vector<P> x, y;
vector<T> graph; //辺のコスト、行先の頂点

class UnionFind {
	public:
		vector<int> par, rank;
 		
		void init(int n) {
			par = vector<int>(n + 1);
			rank = vector<int>(n + 1);
			for (int i = 0; i < n; i++) par[i] = i, rank[i] = 0;
		}
		// 木の根を求める
		int root(int x) {
			return (par[x] == x) ? x : par[x] = root(par[x]);
		}
		// xとyの属する集合を併合
		void unite(int x, int y) {
			x = root(x), y = root(y);
			if (x == y)return;
 
			if (rank[x] < rank[y]) par[x] = y;
			else {
				par[y] = x;
				if (rank[x] == rank[y]) rank[x]++;
			}
		}
		// xとyが同じ集合に属するか否か
		bool same(int x, int y) {
			return root(x) == root(y);
		}
};

ll Kruscal(){
    
    UnionFind uf;
    uf.init(N);
    
    ll ans = 0;
    for(auto g : graph){
        ll x, y, c; tie(c, x, y) = g;
        
        if(uf.root(x) != uf.root(y)){
            uf.unite(x, y);
            ans += c;
        }
        
    }
    
    return ans;
}

int main(void){
	
	scanf("%d", &N);
	for(int i = 1; i <= N; ++i){
	    ll a, b; scanf("%lld %lld", &a, &b);
	    x.push_back(make_pair(a, i)), y.push_back(make_pair(b, i));
	}
	sort(x.begin(), x.end()), sort(y.begin(), y.end());
	
	for(int i = 0; i < N - 1; ++i){
	    graph.push_back(make_tuple(x[i + 1].first - x[i].first, x[i].second, x[i + 1].second));
	    graph.push_back(make_tuple(y[i + 1].first - y[i].first, y[i].second, y[i + 1].second));
	}
	sort(graph.begin(), graph.end());
	
	printf("%lld\n", Kruscal());
	
    return 0;
}


Measured memory_bytes: 13024
#include <string>
#include <algorithm>
#include <vector> 
#include <math.h>
#include <iostream>
#include <cmath>
#include <random>
using namespace std;
long long mod = 1000000000 + 7;

long long mp[10000];
int h, n;
vector<int> a;
vector<int> b;
void dp(int hit) {
	long long min = 99999999999;
	for (int i = 0; i < n; i++) {
		if (mp[max(0,hit - a[i])] + b[i] < min) {
			min = mp[max(0,hit - a[i])] + b[i];
		}
	}
	mp[hit] = min;
}

int main()
{


	
	int ain, bin;
	cin >> h >>n;

	for (int i = 0; i < n; i++) {
		cin >> ain >>bin;
		a.push_back(ain);
		b.push_back(bin);
	}
	mp[0] = 0;
	for (int i = 0; i < h; i++) {
		dp(i + 1);
	}
	cout << mp[h] << endl;

	
	return 0;

}



Measured memory_bytes: 384
N,K = map(int,input().split())
P = list(map(int,input().split()))
C = list(map(int,input().split()))

ans = -1*float('inf')

for i in range(N):
    k = i
    Cc = []
    Ct = 0
    while 1:
        k = P[k]-1
        Cc.append(C[k])
        if i == k:
            break
    l = len(Cc)
    Ct = sum(Cc)
    t = 0
    for j in range(l):
        t += Cc[j]
        if j >= K:break
        now = t
        if Ct > 0:
            e = (K-j-1)//l
            now +=  Ct*e
        ans = max(ans,now)
print(ans)

Measured memory_bytes: 80876
def main():
    n = int(input())
    s = list(input())

    ans = s.count("R")*s.count("G")*s.count("B")
    for i in range(n):
        for j in range(i+1, n):
            k = j + j - i
            if k < n and s[i] != s[j] and s[j] != s[k] and s[k] != s[i]:
                ans -= 1
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9104
#include <bits/stdc++.h>
#include <math.h>
#include <iostream>
#include <stdlib.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define MOD (1000000007)
using namespace std;
 
int main(){
  int a,b,c;
  cin >> a >> b >> c;
  if(c>(a-b)){
    c -= (a-b);
  }else{
    c = 0;
  }
  printf("%d\n",c);
  return 0;
}

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

struct Node{
  int im;
  Node *ri,*le,*pa;
};

Node *ne,*Ni;

Node * tmi(Node *A){
  while(A->le != Ni){
    A = A->le;
  }
  return A;
}

Node * mik(Node *x,int z){
  while( x != Ni && z != x->im){
    if(z<x->im){
      x=x->le;
    }
    else x = x->ri;
  }
  return x;
}

Node * ts(Node *A){
  if(A->ri != Ni){
    return tmi(A->ri);
  }
    Node *B = A->pa;
    while(B !=Ni && A == B->ri){
      A= B;
      B=B->pa;
    }
    return B;
  }

  void td(Node *K){
    Node *B;
    Node *A;

    if(K->le == Ni || K->ri ==Ni){
      B=K;
    }
    else B = ts(K);

    if(B->le != Ni){
      A = B->le;
    }
    else{
      A = B->ri;
    }

    if(A !=Ni){
      A ->pa = B->pa;
    }
    if(B->pa == Ni){
      ne = A;
    }
    else{
      if(B==B->pa->le){
	B->pa->le=A;
      }else{
	B->pa->ri=A;
      }
    }
    if(B!=K){
      K->im = B->im;
    }
    free(B);
  }

void na(int O){

  Node *B = Ni;
  Node *A = ne;
  Node *C;

  C = (Node *)malloc(sizeof(Node));
  C->im = O;
  C->le = Ni;
  C->ri = Ni;

  while(A!=Ni){
    B =A;
    if(C->im < A->im){
      A = A->le;
    }
    else{
      A= A->ri;
    }
  }
  C->pa = B;
  if(B==Ni){
    ne =C;
  }
  else{
    if(C->im < B->im){
      B->le =C;
    }
    else{
      B->ri = C;
    }
  }

}

void io(Node *A){
  if(A == Ni){
    return;
  }
  io(A->le);
  printf(" %d",A->im);
  io(A->ri);
}

void po(Node *A){
  if(A == Ni){
    return;
  }
  printf(" %d",A->im);
  po(A->le);
  po(A->ri);
}

int main(){
  int num,i,xi;
  string da;

  scanf("%d",&num);

  for(i=0;i<num;i++){
    cin >> da;
    if(da[0] == 'f'){
      scanf("%d",&xi);
      Node *k = mik(ne,xi);
      if(k != Ni){
	printf("yes\n");
      }
      else printf("no\n");
    }
    else if(da =="insert"){
      scanf("%d",&xi);
      na(xi);
    }
    else if(da == "print"){
    io(ne);
    printf("\n");
    po(ne);
    printf("\n");
  }
    else if(da == "delete"){
      scanf("%d",&xi);
      td(mik(ne,xi));
    }
  }

  return 0;
}



Measured memory_bytes: 21920
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

#include <functional>
#include <climits>

//SegmentTree<int> seg(N,[](int a,int b){return min(a,b);},INT_MAX);
template< typename T>
class SegmentTree{
public:

  using F = function<T(T,T)>;

  int n;
  vector<T> tree;
  const F operation;
  const T def;

  SegmentTree(int size,F _operation,T _def):operation(_operation),def(_def){
    n=1;
    while(n<size) n*=2;
    tree.resize(2*n-1,def);
  }

  void initialize(vector<T> v){
    int vSize=v.size();
    n=1;
    while(n<vSize) n*=2;
    tree.resize(2*n-1,def);

    for(int i=0;i<vSize;i++) tree[i+n-1]=v[i];
    for(int i=n-2;i>=0;i--) tree[i]=operation(tree[2*i+1],tree[2*i+2]);
  }

  void update(int index,T value){
    index+=n-1;

    tree[index]=value;
    while(index>0){
      index=(index-1)/2;
      tree[index]=operation(tree[2*index+1],tree[2*index+2]);
    }
  }

  T query(int a,int b,int k=0,int l=0,int r=-1){//[a,b),getMin(a,b,0,0,-1)
    if(r<0) r=n;

    if(r<=a||b<=l) return def;
    else if(a<=l&&r<=b) return tree[k];
    else{
      T lval=query(a,b,2*k+1,l,(l+r)/2);
      T rval=query(a,b,2*k+2,(l+r)/2,r);
      return operation(lval,rval);
    }
  }
};


int N;
vector<int> P;

int trans[100010];

int main(){
  cin>>N;
  P.resize(N);
  rep(i,N) cin>>P[i];

  for(int i=0;i<N;i++) trans[P[i]]=i;

  SegmentTree<int> seg(N+2,[](int a,int b){return min(a,b);},N+1);
  SegmentTree<int> msg(N+2,[](int a,int b){return max(a,b);},0);

  ll ans=0;
  for(int i=N;i>=1;i--){
    int now=trans[i];
    int rf=seg.query(now+1,N+1);
    int lf=msg.query(1,now+1);
    int rs=N+1,ls=0;

    //cout<<now+1<<" "<<rf<<" "<<lf<<endl;
    if(rf<N){
      rs=seg.query(rf+1,N+1);
    }
    if(lf>0){
      ls=msg.query(1,lf);
    }
    //cout<<ls<<" "<<rs<<endl;

    ll res=0;
    if(rf<=N) res+=(rs-rf)*(now+1-lf);
    if(lf>0) res+=(lf-ls)*(rf-(now+1));
    //cout<<res<<endl;
    ans+=res*i;

    seg.update(now+1,now+1);
    msg.update(now+1,now+1);
  }

  cout<<ans<<endl;


  return 0;
}


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

// iterator
#define REP(i,from, to) for(lli i=from;i<to;i++)
#define REPE(i,from, to) for(lli i=from;i<=to;i++)
#define REP_R(i,from, to) for(lli i=from;i>to;i--)
#define REPE_R(i,from, to) for(lli i=from;i>=to;i--)
#define REPIT(it,container) for(auto it = container.begin(); it != container.end(); it++)
#define REPIT_R(it,container) for(auto it = container.rbegin(); it != container.rend(); it++)

// input
#define cin1(x)             cin >> x
#define cin2(x, y)          cin >> x >> y
#define cin3(x, y, z)       cin >> x >> y >> z
#define ncin1(n, x)         REP(i, 0, n) {cin1(x[i]);}
#define ncin2(n, x, y)      REP(i, 0, n) {cin2(x[i], y[i]);}
#define ncin3(n, x, y, z)   REP(i, 0, n) {cin3(x[i], y[i], z[i]);}

// output
#define cout1(x)         cout << #x << ": " << x << endl;
#define cout2(x, y)      cout << #x << ": " << x << ", " << #y << ": " << y << endl;
#define cout3(x, y, z)   cout << #x << ": " << x << ", " << #y << ": " << y << ", " << #z << ": " << z << endl;;
#define ncout1(n, x)     REP(i, 0, n) {cout << #x << "[" << i << "]: "<< x[i] << endl;}

#define coutp(p)         cout << #p << ":" <<  " (" << p.first << ", " << p.second << ")" << endl;

// sort
#define sort_r(x, y)        sort(x, y, greater<lli>()); // 降順(5,4,3,,,)

#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

typedef long long int lli;
typedef pair<lli, lli> P;
typedef tuple<lli, lli, lli> tup;
typedef vector<lli> vlli;

int main() {
    lli n;
    cin1(n);
    REP(i,1,10) {
        REP(j,1,10) {
            if (i * j == n) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
                cout << "No" << endl;
}


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

using namespace std;
typedef long long ll;
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))
#define all(x) x.begin(),x.end()


int main()
{
	int n, m; cin >> n >> m;
	vector<int> l(m), r(m);
	int mn = 1, mx = n;
	rep(i, 0, m - 1)
	{
		int l, r; cin >> l >> r;
		mn = max(mn, l);
		mx = min(mx, r);
	}
	int res;
	res = max(0, mx - mn + 1);
	cout << res << endl;
}

Measured memory_bytes: 1024
//B
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 4e6+10;
int raw[maxn];
int main(){
	int n,k;
	cin >> n >> k;
	for(int i = 1;i <= n;i++)cin >> raw[i];
	sort(raw+1,raw+n+1);
	ll ans = 0;
	for(int i = 1;i <= k;i++)ans += raw[i];
	cout << ans;
	return 0;
}


Measured memory_bytes: 3600
N = int(input())

A = []
upsum = 0
dosum = 0

for i in range(2):
    newa = list(map(int,input().split()))
    A.append(newa)

    if i == 0:
        upsum = sum(newa)
    else:
        dosum = sum(newa)


maxi = 0
now = dosum

for i in range(N):

    now += A[0][i]

    if i != 0:
        now -= A[1][i-1]

    maxi = max(maxi,now)

print (maxi)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/algorithm_ext.hpp>
#include <boost/math/common_factor_rt.hpp>
using namespace std;
using namespace boost::range;
using boost::irange;
using boost::math::gcd;
using boost::math::lcm;

using ll = int64_t;
constexpr char LN = '\n';
template<class T> bool chmax(T& a, const T& b) {if(a<b){a=b;return true;}else{return false;}}
template<class T> bool chmin(T& a, const T& b) {if(b<a){a=b;return true;}else{return false;}}

#ifdef LOCAL
template<class H> void dump_(const char* s, H h) {cout<<s<<"="<<h<<LN; }
template<class H, class... T> void dump_(const char* s, H h, T... t) {for(;*s!=',';++s){cout<<*s;}cout<<"="<<h<<",";dump_(++s,t...);}
#define dump(...) dump_(#__VA_ARGS__, __VA_ARGS__)
#else
#define dump(...)
#endif

struct init_ {init_(){cin.tie(nullptr);ios::sync_with_stdio(false);}} init_;

template<class C> C scan(size_t n) {C c(n);for(auto& v:c){cin>>v;}return c;}
template<class C> C scan(size_t n, size_t m) {C vss(n);for(auto& vs:vss){vs.resize(m);for(auto& v:vs){cin>>v;}}return vss;}

template<class R> struct Joined { const R& r; const char* s; };
template<class R> Joined<R> joined(const R& r, const char* s = " ") {return{r,s};}
template<class R> ostream& operator<<(ostream& out, Joined<R> j) {bool f=true;for(const auto& v:j.r){if(f){f=false;}else{out<<j.s;}out<<v;}return out;}

template<class T> using matrix = vector<vector<T>>;
template<class T> matrix<T> make_matrix(size_t n, size_t m, const T& init = T()) {matrix<T> vss(n);for(auto& vs:vss){vs.resize(m,init);}return vss;}
template<class T> ostream& operator<<(ostream& out, Joined<matrix<T>> j) {bool a=true;for(const auto& vs:j.r){if(a){a=false;}else{out<<LN;}bool f=true;for(const auto& v:vs){if(f){f=false;}else{out<<j.s;}out << v;}}return out;}

template<class T> void show(const T& t) {cout<<t<<LN;}
template<class T> void show(const vector<T>& v) {cout<<joined(v)<<LN;}
void show(bool b) {cout<<(b?"Yes":"No")<<LN;}
void show(double d) {cout<<fixed<<setprecision(12)<<d<<LN;}

int main() {
    string S, T;
    cin >> S >> T;
    show(T + S);
}


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

int main(void){
    bool a[1001]={};
    int N,m,cnt=0;
    cin>>N>>m;
    while(m--){
        int c,d;
        cin>>c>>d;//d???c?????????????????????
        for(int i=c;i<d;++i)a[i]=true;//d??????c??????????????????
    }
    for(int i=0;i<=N;++i)if(a[i])cnt++;//?????£?????????????????°??????
    cout<<N+1+cnt*2<<endl;//N+1?????\?????£???????????£?????§????????¢???count*2???????????????

    return 0;
}

Measured memory_bytes: 1164
#include <stdio.h>
int main(void){
    int d,n;
    scanf("%d%d",&d,&n);
    if(n==100) n++;
    if(d==0) printf("%d",n);
    else if(d==1) printf("%d",100*n);
    else printf("%d",10000*n);
    return 0;
}

Measured memory_bytes: 1728
import sys
from collections import *
import heapq
import math
# from math import gcd
import bisect
import copy
from itertools import permutations,accumulate,combinations,product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n,c=map(int,input().split())
stc=[list(map(int,input().split())) for i in range(n)]
stc.sort()
lst=[0]*c
for i in range(n):
    s,t,ctmp=stc[i]
    for j in range(c):
        if lst[j]==0:
            lst[j]=stc[i]
            break
        else:
            if lst[j][2]==ctmp:
                lst[j]=stc[i]
                break
            elif lst[j][1]<s:
                lst[j]=stc[i]
                break
# print(lst)
ans=0
for i in range(c):
    if lst[i]!=0:
        ans+=1
print(ans)

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

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i < (ll)(n); i++)
#define INF 1000000000000
#define MOD 1000000007
using ll = long long;

int main(){
  int h,w;
  cin >> h >> w;
  ll a = INF, b = INF, c = INF, d = INF;
  if(w>=3)a = h*(w%3!=0);
  if(h>=3)b = w*(h%3!=0);
  if(h%3==2){
    c = max(abs((h/3+1)*w-w/2*(h-(h/3+1))),abs((h/3+1)*w-(w-w/2)*(h-(h/3+1))));
  }else{
    c = max(abs(h/3*w-w/2*(h-h/3)),abs(h/3*w-(w-w/2)*(h-h/3)));
  }
  if(w%3==2){
    d = max(abs((w/3+1)*h-h/2*(w-(w/3+1))),abs((w/3+1)*h-(h-h/2)*(w-(w/3+1))));
  }else{
    d = max(abs(w/3*h-h/2*(w-w/3)),abs(w/3*h-(h-h/2)*(w-w/3)));
  }
  
  cout<<min(a,min(b,min(c,d)))<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
////////////////////////////

ll hpow(ll x,ll y){
    ll ans=1;
    ll i=x;
    if(y==0)return 1;
    while(y>0){
        if(y%2==1){
            ans=(ans*i)%i_7;
        }
        i=(i*i)%i_7;
        y=y/2;
        
    }
    return ans;
}

ll memop[2000000];
ll mkai(ll i){
    if(i==0){
        return 1;
    }
    if(memop[i]!=0){
        return memop[i];
    }else{
        ll ans=(mkai(i-1)*hpow(i,i_7-2))%i_7;
        memop[i]=ans;
        return ans;
    }
}

ll memok[2000000];
ll kai(ll i){
    if(i==0){
        return 1;
    }
    if(memok[i]!=0){
        return memok[i];
    }else{
        ll ans=(kai(i-1)*i)%i_7;
        memok[i]=ans;
        return ans;
    }
}

ll comb(ll n,ll k){
    ll ans=(kai(n)*mkai(k))%i_7;
    ans=(ans*mkai(n-k))%i_7;
    return ans;
}
int main(){
    ll n;cin>>n;
    ll k;cin>>k;
    ll a[n];
    rep(i,0,n-1){
        cin>>a[i];
    }
    sort(a,a+n);
    ll ans=0;
    rep(i,k-1,n-1){
        ans=(ans+(comb(i,k-1)*(a[i]-a[n-1-i]))%i_7)%i_7;
    }
    cout<<ans<<endl;
    
    
    return 0;
}


Measured memory_bytes: 4608
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
using ld = long double;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);i++)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;i--)
#define lb lower_bound
#define ub upper_bound
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
const ll LINF = (ll)(1e18 +99);
vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
template<typename T,typename U> void chmin(T& t, const U& u){if(t>u)t=u;}
template<typename T,typename U> void chmax(T& t, const U& u){if(t<u)t=u;}
template<typename T>T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<typename T>T mpow(T a, T n) {
    T res = 1;
    for(;n;n>>=1) {
        if (n & 1) res = res * a;
        a = a * a;
    }
    return res;
}

//cin.tie(0);ios::sync_with_stdio(false);

double dp[310][310][310]={};

int cnt1,cnt2,cnt3,n;

double dfs(int i,int j,int k){
    if(!i && !j && !k)return 0;

    if(dp[i][j][k]!=0)return dp[i][j][k];

    double res=0;
    if(0<i)res+=(db)(dfs(i-1,j,k)+((db)n/(i+j+k))) * ((db)i/(i+j+k));
    if(0<j)res+=(db)(dfs(i+1,j-1,k)+((db)n/(i+j+k)))* ((db)j/(i+j+k));
    if(0<k)res+=(db)(dfs(i,j+1,k-1)+((db)n/(i+j+k)))* ((db)k/(i+j+k));
    //cout<<i<<" "<<j<<" "<<k<<" "<<res<<endl;

    dp[i][j][k]=res;
    return res;
}

signed main() {
    cin>>n;
    rep(i,0,n){
        int x;cin>>x;
        if(x==1)cnt1++;
        else if(x==2)cnt2++;
        else cnt3++;
    }

    cout<<fixed<<setprecision(20)<<dfs(cnt1,cnt2,cnt3)<<endl;
}


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

int N;
int a[15] = {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47};
int b[15] = {0,0,0,0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
 
int main() {
    cin >> N;
    int over_2 = 0, over_4 = 0, over_14 = 0, over_24 = 0, over_74 = 0;
    for (int i = 0; i < 15; ++i){
        int j = 1;
        while(pow(a[i],j) <= N){
            b[i] += N/pow(a[i],j++); 
        }
        if (b[i] >= 2) over_2++;
        if (b[i] >= 4) over_4++;
        if (b[i] >= 14) over_14++;
        if (b[i] >= 24) over_24++;
        if (b[i] >= 74) over_74++;
        // cout << a[i] << ":" << b[i] << endl;
    }
    cout << 
        over_4 * (over_4 - 1) / 2 * (over_2 - 2)
        + over_14 * (over_4-1)
        + over_24 * (over_2-1)
        + over_74
    << endl;
}

// (2**4) * (3**4) * (5**2)
// 5 * 5 * 3 

// (2**14) * (3**4)
// 15 * 5

// (2**24) * (3**2)
// 25 * 3


// (2**74)
// 75

Measured memory_bytes: 384
n=int(input())
a=[]
for i in range(n):
  x,l=map(int,input().split())
  a.append([x+l,max(0,x-l)])
a.sort()
r=0
c=0
for i in range(n):
  if a[i][1]>=r:
    r=a[i][0]
    c+=1
print(c)

Measured memory_bytes: 20104
////////////////////////// Author
////////////////////////// Nasim Hossain Rabbi
////////////////////////// JU-CSE28
////////////////////////// CF - imnasim3.1415
////////////////////////// UVA - imnasim3.1415
////////////////////////// Mail - imnasim3.1415@gmail.com

#include<bits/stdc++.h>
using namespace std;
#define sz size()
#define mk make_pair
#define clr clear()
#define B begin()
#define E end()
#define EM empty()
#define mem(a,b) memset(a,b,sizeof(a))
#define rep(i,n) for(i=0;i<n;i++)
#define Rep(i,n) for(i=1;i<=n;i++)
#define all(cont) cont.begin(),cont.end()
#define pb push_back
#define endl '\n'
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL)
#define pi 3.1415926535897932384626433832795
#define vi vector<int>
#define vs vector<string>
#define vp(vi,x) cin>>x; vi.pb(x);
typedef long long int LL;
typedef unsigned long long int ULL;
int main()
{
//    fast;
    int i,j,k,n,m,l,s=0,tc=1,c=0;
    while(cin>>n)
    {
        LL x,y;
        vector<long long int> a; bool f=1,ff=1;
        rep(i,n)
        {
            vp(a,x);
        }
        sort(all(a));
        for(i=n-1;i>0;i--)
        {
            if(a[i]==a[i-1] && f) x=a[i],i--,f=0;
            else if(a[i]==a[i-1])
            {
                y=a[i];
                ff=0;
                break;
            }
        }
        LL r=x*y;
        if(ff) cout<<"0"<<endl;
        else cout<<r<<endl;
    }
}


Measured memory_bytes: 1400