akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
# define ll int64_t
# define str string
# define rep(i,n) for(ll i=0;i<n;i++)
# define rrep(i,n) for(ll i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define mod 1000000007
# define PI 3.141592653589793
# define vec vector
#define dump(x) cerr<<#x<<"="<<x<<endl
using namespace std;



#define INF 2000000000
#define MAX_V 10



bool compare_by_b(pair<string,ll> a,pair<string,ll> b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

bool my_compare(pair<ll,ll> a,pair<ll,ll> b){
    if(a.first != b.first) return a.first<b.first;
    if(a.second != b.second) return a.second>b.second;
    else return true;
}

ll modpow(ll a,ll n,ll mod1) {
    ll res=1;
    while(n>0){
        if(n&1) res=res*a%mod1;
        a = a*a%mod1;
        n >>= 1;
    }
    return res;
}

ll factorial(ll n){
    ll x=1;
    rrep(i,n) x*=i;
    return x;
}

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

ll func(ll a,ll b,ll& ans_x,ll& ans_y){
    if(b == 0){
        ans_x = 1;
        ans_y = 0;
        return a;
    }else{
        ll ret = func(b,(a%b),ans_y,ans_x);
        ans_y -= (a/b)*ans_x;
        return ret;
    }
}

ll lcm(ll a,ll b){
   return a/gcd(a,b)*b;
}
const ll MAX = 5100000;
const ll MOD = 1000000007;
 
ll fac[MAX], finv[MAX], inv[MAX];
 
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll 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;
    }
}

// 二項係数計算
ll COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

using graph = vector<vector<ll>>;
pair<pair<ll,ll>,ll> p[100010];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll X, N; cin >> X >> N;
    vector<bool> vec(102);
    for (ll i = 0; i < N; i++) {
      ll p; cin >> p;
      vec.at(p) = true;
    }
    ll i = X;
    for (i=X ; vec.at(i); i++);
    ll j = X;
    for (j=X ; vec.at(j); j--);
    if (X - j <= i - X) {
      cout << j << endl;
    }else {
      cout << i << endl;
    }
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int>A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  bool check = true;
  for (int i = 0; i < N; i++) {
    if (A.at(i) % 2 == 0) {
      if (A.at(i) % 3 != 0 && A.at(i) % 5 != 0) {
        check = false;
      }
    }
  }
  if (check) {
    cout << "APPROVED";
  }
  else {
    cout << "DENIED";
  }
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int gcd(int,int);

int main()
{
    int n,k,Max=0,Gcd=0;

    cin >> n >> k;

    while(n--)
    {
        int x;

        cin >> x;

        Max = max(Max,x);

        Gcd = gcd(Gcd,x);
    }

    if(k>Max || k%Gcd)
        cout << "IMPOSSIBLE" << endl;
    else
        cout << "POSSIBLE" << endl;

    return 0;
}

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


Measured memory_bytes: 384
n = int(input())

a = 3*3*3*5
b = 3*3*3*7

m = 0

l = [3, 5, 7, 11, 13]

for f in range(5):
    for g in range(f+1, 5):
        for h in range(g+1, 5):
            if l[f]*l[g]*l[h] <= n:
                m += 1
        
if n>=a:
    m += 1
    if n>=b:
        m+= 1
        
print(m)

Measured memory_bytes: 3060
import java.util.*;

class Main{
public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	String s = sc.next();
	String a = "yes";
	for(int i=0; i<s.length()-1; i++) {
		for(int j=i+1; j<s.length(); j++) {
			if(s.charAt(i) == s.charAt(j)) {
				a = "no";
				break;
			}

		}
	}
	System.out.println(a);
}
}


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

vector<vector<int>> G;
vector<int> dp;

int dfs(int cur) {
  if (dp.at(cur) != -1) return dp.at(cur);
  int res = 0;
  for (int nx : G.at(cur)) {
    res = max(res, dfs(nx) + 1);
  }
  return dp.at(cur) = res;
}

int main() {
  int N, M; cin >> N >> M;
  G.resize(N);
  dp.assign(N, -1);
  for (int i = 0; i < M; i++) {
    int x, y; cin >> x >> y; x--; y--;
    G.at(x).push_back(y);
  }
  int ans = 0;
  for (int i = 0; i < N; i++) {
    ans = max(ans, dfs(i));
  }
  cout << ans << endl;
}

Measured memory_bytes: 8192
//Date and time of submission: 
 
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll N=1e5+5;
ll a,b,c;
int main() {
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL);
	cin>>a>>b>>c;
	if(c>=a&&c<=b)
	cout<<"Yes";
	else
	cout<<"No";
	return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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; }

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

int main() {
  int n,k;
  cin>>n>>k;
  
  vector<int> vec(n);
  rep(i,n) cin>>vec[i];
  
  double sum=0,max;
  rep(i,k) sum+=vec[i];
  max=sum;
  
  for(int i=k;i<n;i++){
    sum-=vec[i-k];
    sum+=vec[i];
    chmax(max,sum);
  }
  
  printf("%.10f\n", (max+k)/2);
  
  return 0;
}

Measured memory_bytes: 4040
#include<iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>

typedef long long ll;
using namespace std;
int n,x[955],y[955],ans; 
map<int,map<int,int> >mp;
int main(){
	scanf("%d",&n);
	for(int i=0;i<n;++i){
		scanf("%d%d",x+i,y+i);
		for(int j=0;j<i;++j){
			if(ans<++mp[x[j]-x[i]][y[j]-y[i]]){
				ans=mp[x[j]-x[i]][y[j]-y[i]];
			}
			if(ans<++mp[x[i]-x[j]][y[i]-y[j]]){
				ans=mp[x[i]-x[j]][y[i]-y[j]];
			}
		}
	}
	cout<<n-ans<<endl;
	return 0;
} 

Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
vector<int>adj[100009];
bool vis[100009];
int dis[100009];
int dfs(int node)
{
    vis[node]=true;
    int ans=0;
    if(dis[node]!=-1)
     return dis[node];
    for(int x:adj[node])
     ans=max(ans,1+dfs(x));
    return dis[node]=ans;
}
int main(){
    int n,m,u,v;
    cin>>n>>m;
    for(int i=0;i<m;i++)
    {
      cin>>u>>v;
      adj[u].push_back(v);
    }
    int ans=0;
    memset(dis,-1,sizeof(dis));
    for(int i=1;i<=n;i++)
    {
        if(vis[i]==false)
        {
            ans=max(ans,dfs(i));
        }

    }
    cout<<ans<<endl;
}

Measured memory_bytes: 11544
import sys
n, m = map(int,input().split())
mod = 1000000007
a = [True] * (n + 1)
for i in range(m):
    a[int(sys.stdin.readline())] = False
dp = [0] * (n + 1)
dp[0] = 1

dp[1] = dp[0] if a[1] else 0

for i in range(2, n + 1):
    if a[i]:
        dp[i] = (dp[i - 1] + dp[i - 2]) % mod

print(dp[n])


Measured memory_bytes: 7668
#pragma GCC optimize("Ofast")
	#pragma GCC target("avx,avx2,fma")
	#pragma GCC optimization ("unroll-loops")
	
    #include<bits/stdc++.h>
    using namespace std;
	
    #define ll long long
    #define ull unsigned long long
    #define ld long double
    #define ff first
    #define ss second
    #define null NULL
    #define MAX 1000000000  // 1x10^9
    #define all(c) (c).begin(),(c).end()
    #define eb emplace_back
    #define pb push_back
    #define pf push_front
    #define lb lower_bound   //used for sortted 
    #define ub upper_bound 
    #define m_p make_pair      
    #define mod 1000000007
    #define For(i,n) for(int i=(0);i<(n);++i)
    #define FOR(i,a,b) for(int i=(a);i<=(b);++i)
	#define ROF(i,a,b) for(int i=(a);i>=(b);--i)
    #define in(s3) inserter((s3), (s3).begin())  //	set_union(all(s1),all(s2),in(s3));
    typedef vector<ll> vl;
    typedef vector< vl > vvl;
    typedef pair< ll,ll> pll;
    typedef map< ll,ll> mll;
    
    //  A-65 Z-90 a-97 z-122   A-a = 32   Z-A = z-a = 35
    //	v.push_back(make_pair(min(2 * k[i], l[i]) - min(k[i], l[i]), i));      //int pos = v[i].second;
    //	floor(log10(no) + 1);                   //	to_string(no).length();             ----- length of a number
	//  llabs - long long of abs
	//  labs -long of abs
	//  sqrtf - sq root of float
	//  sqrtl - sq of long double    ( cout << fixed << setprecision(12) << sqrtl(val2) << endl; )
	//  it = find (all(vec), e);     if(it != vec.end());       it - vec.begin();
   	//	size_t found = str.find(str1);    if(found != string::npos); 	 cout<<found;
    	 
	/*	
		1. ^ is XOR and is used to to check odd occurance of number as a number XORed with itself results in zero so all even	occurrances result in zero.
		2.   & is used to check even or odd. (x & 1) ? printf("Odd") : printf("Even"); 
		3.   left shift(<<) - *         right shift(>>) - /
		4.   int a[] = { 1, 7, 2, 4, 8, 3 }; 
    		 int l = sizeof(a) / sizeof(a[0]); 
    		 sort(a, a + l);  reverse(a, a + l); accumulate(a, a + l, 0); *max_element(a, a + l);
	*/
	
	string to_string(char& x) {      
		string s(1,x);
		return s;    
	} 
	struct obj {
		ull val1;
		ull val2;
		ull pos;
	};
	bool cmp(const pair<int,int>&a,const pair<int,int>&b) {
		if(a.first==b.first)
		return a.second<b.second;
		return a.first<b.first;
	}

	int main() {
		string s;
		cin>>s;
		ull sum=0;
		for(ull i=0;i<s.length();i++)
		{
			sum+=s[i]-'0';
		}
		if(sum%9==0)
		cout<<"Yes";
		else
		cout<<"No";
		return 0;
	}





Measured memory_bytes: 3724
#include<bits/stdc++.h>
using namespace std;
int temp[500004],a[500004];
int belong[500004],block,n,m;
int res[500004];
struct Ds{
    int l,r,sit;
    bool operator<(const Ds &b){
        return (belong[l]^belong[b.l])?belong[l]<belong[b.l]:((belong[l]&1)?r<b.r:r>b.r);
    }
}q[500004];
int main(){
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++)scanf("%d",&a[i]);
    block=sqrt(n);
    for(int i=1;i<=n;i++)belong[i]=(i-1)/block+1;
    for(int i=1;i<=m;i++){
        scanf("%d%d",&q[i].l,&q[i].r);
        q[i].sit=i;
    }
    sort(q+1,q+m+1);
    int l=1,r=0,ans=0;
     for(int i=1;i<=m;i++){
        while(l < q[i].l) ans -= (!--temp[a[l++]]);
        while(l > q[i].l) ans += (!temp[a[--l]]++);
        while(r < q[i].r) ans += (!temp[a[++r]]++);
        while(r > q[i].r) ans -= (!--temp[a[r--]]);
        res[q[i].sit] = ans;
     }
    for(int i=1;i<=m;i++)printf("%d\n",res[i]);
    return 0;
}


Measured memory_bytes: 17408
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
	ll n,k1;
	cin>>n>>k1;
	ll x[n];
	ll y[n];
	ll sx[n];
	ll sy[n];
	for(ll i=0;i<n;i++)
	{
		cin>>x[i]>>y[i];
		sx[i]=x[i];
		sy[i]=y[i];
	}
	sort(sx,sx+n);
	sort(sy,sy+n);
	ll x1=sx[0],x2=sx[n-1];
	ll y1=sy[0],y2=sy[n-1];
	ll minar = 1LL*(x2-x1)*(y2-y1);
	//cout<<minar<<" ";
	for(ll i=0;i<n;i++)
	{
		for(ll j=i+1;j<n;j++)
		{
			for(ll k=0;k<n;k++)
			{
				for(ll l=k+1;l<n;l++)
				{
					ll tx1 = sx[i],tx2=sx[j],ty1=sy[k],ty2=sy[l];
					ll area= (1LL*(tx2-tx1)*(ty2-ty1));
					ll count=0;
					for(ll m=0;m<n;m++)
					{
						if(x[m]>=tx1 && x[m]<=tx2 && y[m]>=ty1 && y[m]<=ty2)
							count++;
					}
					if(count>=k1 && area<minar){
						minar=area;
						//cout<<tx1<<" "<<tx2<<" "<<ty1<<" "<<ty2<<" "<<count;
					}
					//count=0;
				}
			}
		}
	}
	cout<<minar<<"\n";
}


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

ll num_layers(int n){
  if(n==0){return 1;}
  else{return 2*num_layers(n-1)+3;}
}

ll num_patties(int n){
  if(n==0){return 1;}
  else{return 2*num_patties(n-1)+1;}
}

ll solve(int n, ll x){
  if(n==0){return x<=0 ? 0:1;}
  if(x<=num_layers(n-1)+1){return solve(n-1, x-1);}
  if(x==num_layers(n-1)+2){return num_patties(n-1)+1;}
  if(x<=num_layers(n)-1){return num_patties(n-1)+1+solve(n-1,x-num_layers(n-1)-2);}
  else{return num_patties(n);}
}

int main(){
  int N; ll X;cin>>N>>X;
  ll ans=solve(N, X);
  cout << ans << endl;
  return 0; 
}

Measured memory_bytes: 256
/*
    Author - Param Kothari
    Ah shit, here we go again
*/
 
/* Ordered Set Implementaton:

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

using namespace __gnu_pbds;

typedef tree<
    int,
    null_type,
    less<int>,
    rb_tree_tag,
    tree_order_statistics_node_update>
ordered_set;
*/

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

#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
#define mk make_pair 
 
typedef long long ll;
typedef long double ld;

void solve(){
    ll n, m;
    cin >> n >> m;
    vector<ll> a(n);
    ll suma = 0;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        suma += a[i];
    }
    sort(a.rbegin(), a.rend());
    int c = 0;
    for(int i = 0; i < n; i++){
        if((a[i] * 4 * m) >= suma){
            c++;
        }
        else break;
    }
    if(c >= m) cout <<"Yes\n";
    else cout << "No\n";
    return;
}
 
int main(){
    IOS;
    int t = 1;
    //cin >> t;
    for(int i = 1; i <= t; i++){
        //cout << "Case #" << i << ": ";
        solve();
    }
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;
typedef long long LL;

int n, a[110000], b[110000], c[110000];
LL s[310000];

int lowbit(int x) {return x & -x;}
void change(int x, int c) {
	for(int i = x; i <= 2 * n + 1; i += lowbit(i)) s[i] += c;
}
LL getsum(int x) {
	LL sum = 0;
	for(int i = x; i; i -= lowbit(i)) sum += s[i];
	return sum;
}

bool check(int mid) {
	for(int i = 1; i <= n; i++) {
		if(a[i] <= b[mid]) c[i] = -1;
		else c[i] = 1;
		c[i] += c[i - 1];
	}
	LL ans = 0, tot = (LL)(n + 1) * n / 2;
	tot = tot / 2 + 1;
	memset(s, 0, sizeof(s));
	int q = 2 * n + 1;
	change(q - (n + 1), 1);
	for(int i = 1; i <= n; i++) {
		int hh = c[i] + n + 1;
		ans += getsum(q - hh - 1);
		if(i < n) change(q - hh, 1);
	} return ans >= tot;
}

int main() {
	scanf("%d", &n);
	for(int i = 1; i <= n; i++) scanf("%d", &a[i]), b[i] = a[i];
	sort(b + 1, b + n + 1);
	int l = 1, r = n, ans;
	while(l <= r) {
		int mid = (l + r) / 2;
		if(check(mid)) r = mid - 1, ans = mid;
		else l = mid + 1;
	} printf("%d\n", b[ans]);
	return 0;
}

Measured memory_bytes: 3712
while 1:
    score=[0,0]
    n=int(input())
    if n==0:
        break
    else:
        for i in range(n):
            A,B=map(int,input().split())
            if A>B:
                score[0]+=A+B
            elif A==B:
                score[0]+=A
                score[1]+=B
            else:
                score[1]+=B+A
    print(*score)


Measured memory_bytes: 5616
#include <bits/stdc++.h>
using namespace std;
#define itn int
#define nibu(K,x) binary_search(K.begin(),K.end(),x)
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) x.begin(),x.end()
#define sz(x) x.size()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define out(x) cout<<x<<endl
#define put(x) out(x)
#define in(x) cin>>x
#define maxx(a,b,c) max(a,max(b,c))
#define minn(a,b,c) min(a,min(b,c))
using ll = unsigned long long;
using vl = vector<ll>;
using vs = vector<string>;
const double pi = 3.14159265358979;
const ll mod = 1000000007;
int main() {
  int N ;
  in(N);
  string S;
  in(S);
  int ans =0;
  
  for(int i=1;i<N;i++){
    map<char,bool> che;
  vector<char> E={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
 for(int i:E) che[E[i]]=false;
   string p = S.substr(0,i);
    string q = S.substr(i,N-i);
   // out(p<<" "<<q);
   int a = sz(p);
    int wa =0;
    rep(j,a){
     if(q.find(p[j])!=std::string::npos&&che[p[j]]==false) wa++; 
      che[p[j]]=true;
    }
    ans = max(wa,ans);
   // out(wa);
  }
  out(ans);
}


Measured memory_bytes: 256
// B - Addition and Multiplication
#include <bits/stdc++.h>
using namespace std;
#define rp(i,s,e) for(int i=(s);i<(e);++i)
int N,K;

int solve(){
	int ans = 1;
	rp(i,0,N){
		if(ans*2 < ans+K) ans*=2;
		else ans +=K;
	}
	return ans;
}

int main(){
	cin>>N>>K;
	cout<< solve() <<endl;
}

Measured memory_bytes: 256
N,K = list(map(int,input().split()))
A = list(map(int,input().split()))
p = 10**9+7
Aplus = []
Nplus = 0
Aminus = []
Nminus = 0
Aabs = []
for i in range(N):
    if A[i]>=0:
        Aplus.append(A[i])
        Nplus += 1
    else:
        Aminus.append(A[i])
        Nminus += 1
Aplus.sort(reverse=True)
Aminus.sort(reverse=False)

if K==N:
    out=1
    for i in range(K):
        out = out*A[i]%p
    print(out)
elif Nminus==N and K%2==1:
    out=1
    for i in range(K):
        out = out*Aminus[N-i-1]%p
    print(out)
else:
    l=0
    r=0
    out=1
    inf = float('inf')
    while K>0:
        if l+1<=Nplus-1:
            cand1 = Aplus[l]*Aplus[l+1]
        elif l==Nplus-1:
            cand1 = Aplus[l]
        else:
            cand1 = -1*inf

        if r+1<=Nminus-1:
            cand2 = Aminus[r]*Aminus[r+1]
        elif r==Nminus-1:
            cand2 = Aminus[r]
        else:
            cand2 = -1*inf

        if cand1>cand2 or K==1:
            out=out*Aplus[l]%p
            K += -1
            l += 1
        else:
            out=out*Aminus[r]*Aminus[r+1]%p
            K += -2
            r += 2
    print(out)


Measured memory_bytes: 107524
#include <bits/stdc++.h>
using namespace std;
int xx, ans, n, m, a[1000][1000];
int main() {
	cin>>n>>m;
	for (int i = 0; i < n; i++)
		for (int j = 0; j < m; j++)
			cin>>a[i][j];
	for (int i = 0; i < n; i++) {
		for (int j = i+1; j < n; j++) {
			xx = 0;
			for (int k = 0; k < m; k++) {
				xx += (a[i][k]-a[j][k])*(a[i][k]-a[j][k]);
			}
			int s = sqrt(xx);
			if (s*s == xx) ans++;
		}
	}
	cout<<ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,M;
  cin >> N;
  
  M = 0;
  vector<int> A(N);
  
  for (int i=0; i<N; i++) {
    cin >> A.at(i); 
  }
  
  for (int i=0; i<N; i++) {
    if ( (i+1)%2 == 1 && A.at(i)%2 == 1 ) {
      M = M + 1;
    }
  }
  
  cout << M << endl;
  
}

Measured memory_bytes: 3600
x = input();
cnt5=0;
cnt7=0;
for i in x:
    if i == '5':
        cnt5=cnt5+1
    else:
        if i == '7':
            cnt7=cnt7+1
if cnt5 == 2 and cnt7 == 1:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 2940
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int guideBook = sc.nextInt();
		int algorithm = sc.nextInt();
		int target = sc.nextInt();
		int[] priceInfo = new int[guideBook];
		int[][] guideBookInfo = new int[guideBook][algorithm];
		for(int i = 0;i < guideBook;i++) {
			priceInfo[i] = sc.nextInt();
			for(int j = 0; j < algorithm;j++) {
				guideBookInfo[i][j] = sc.nextInt();
			}
		}
		int answer = 0;
		for(int i = 0;i < 1 << guideBook;i++) {
			int[] rikaidoInfo = new int[algorithm];
			int price = 0;
			for(int j =0; j < guideBook;j++) {
				if((1 & (i >>j)) ==1) {
					price += priceInfo[j];
					for(int k =0; k < algorithm;k++) {
						rikaidoInfo[k]+= guideBookInfo[j][k];
					}
				}
			}
			for(int j =0; j < algorithm;j++) {
				if(target > rikaidoInfo[j]) {
					break;
				}
				if(j == algorithm -1) {
					if(answer ==0) {
						answer = price;
					}else {
						if(answer > price) {
							answer = price;
						}
					}
				}
			}
		}
		if(answer ==0) {
			System.out.println(-1);
			return;
		}
		System.out.println(answer);
	}
}

Measured memory_bytes: 37484
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

    	Main main=new Main();

    	main.run();

    }

    void run() {

    	Scanner sc=new Scanner(System.in);

    	int a=sc.nextInt();
    	int b=sc.nextInt();
    	int h=sc.nextInt();

    	int area=(a+b)*h/2;

    	System.out.println(area);
    }
}


Measured memory_bytes: 21460
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <map>
const int MOD = 1e9+7;
typedef long long ll;
using namespace std;


int main(){
 	int n, k;
 	string s;
 	string t = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
 	string u = "abcdefghijklmnopqrstuvwxyz";
 	cin >> n >> k >> s;
 	for (int i = 0; i < t.length(); i++){
 		if (s[k-1] == t[i]){
 			s[k-1] = u[i];
 		}
 	}
 	cout << s << endl;
 	return 0;
}


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

#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/rational.hpp>
namespace xxx = boost::multiprecision;
using Bint = xxx::cpp_int;
using Real = xxx::number<xxx::cpp_dec_float<1024>>;

#define int long long
#define pb(x) push_back(x)
#define m0(x) memset((x), 0, sizeof(x))
#define mm(x) memset((x), -1, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define bit(n) (1LL << (n))
#define bitset(a, b) (a) |= (1 << (b))
#define bitunset(a, b) (a) &= ~(1 << (b))
#define bitcheck(a, b) ((((a) >> (b)) & 1) == 1)
#define bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
constexpr int INF = (int)1e18;
constexpr int MOD = (int)1e9 + 7;
constexpr double PI = (double)acos(-1);
constexpr double EPS = (double)1e-10;
constexpr int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
constexpr int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
template <typename T>
void chmax(T &a, T b) { a = max(a, b); }
template <typename T>
void chmin(T &a, T b) { a = min(a, b); }
//
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

signed main() {
  Bint a, b;
  cin >> a >> b;
  cout << a % b << endl;

  return 0;
}



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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

template <typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
  cout << "{";
  for (int i = 0; i < vec.size(); i++)
    os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  cout << "}";
  return os;
}

// ====================================================================

int main() {
  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  s += "a";  // 番兵的な(?)

  // {1の数,0の数,1の数…}と交互に並べた配列を作る
  vector<int> v;
  int count = 0;
  if (s[0] == '0') v.push_back(0);  // 0個の1があるとみなす
  for (int i = 0; i < n; i++) {
    count++;
    if (s[i] != s[i + 1]) {
      v.push_back(count);
      count = 0;
    }
  }

  vector<ll> rui = {0};
  ll r = 0;
  for (auto x : v) {
    r += x;
    rui.push_back(r);
  }

  ll ans = 0;
  for (int i = 1; i < rui.size(); i += 2) {
    if (i + k * 2 >= rui.size()) {  // 右にはみ出す
      ans = max(ans, rui[rui.size() - 1] - rui[i - 1]);
    } else {
      ans = max(ans, rui[i + k * 2] - rui[i - 1]);
    }
  }

  // cout << v << endl;
  // cout << rui << endl;
  cout << ans << endl;
}


Measured memory_bytes: 1976
h,w=map(x->parse(Int,x),split(readline()))
s=[]
for i=1:h
	push!(s,readline())
end
a=[]
b=[]
for i=1:h
	f=0
	for j=1:w
		if s[i][j]=='#'
			f+=1
		end
	end
	push!(a,f>0)
end
for j=1:w
	f=0
	for i=1:h
		if s[i][j]=='#'
			f+=1
		end
	end
	push!(b,f>0)
end
for i=1:h
	if !a[i]
		continue
	end
	for j=1:w
		if b[j]
			print(s[i][j])
		end
	end
	print("\n")
end


Measured memory_bytes: 168620
#include <iostream>
using namespace std;
int a[30],n;
bool check(int m,int sum,int i){
    if(sum==m){
        
        return true;
    }
    if(i>=n){
        //cout<<"no"<<endl;
        return false;
    }
    bool res=check(m, sum+a[i],i+1) || check(m, sum, i+1);
    return res;
}
int main(){
    int q;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    cin >> q;
    for (int i = 0; i < q; i++)
    {
        int m;
        cin >> m;
        if(check(m,0,0)){
            cout<<"yes"<<endl;
        }else{
            cout<<"no"<<endl;
        }
    }
    
}


Measured memory_bytes: 3100
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <utility>
#include <vector>
using namespace std;

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

struct UnionFind
{
    vector<int> parent;
    vector<ll> siz;
    ll ineq; // 「不便さ」
    UnionFind(ll n) : parent(n), siz(n), ineq(n*(n-1)/2){
        for(int i = 0; i < n; i++) parent[i] = i;
        siz.assign(n, 1);
    }
 
    int root(int x){
        return x == parent[x] ? x : (parent[x] = root(parent[x]));
    }
 
    void unite(int x, int y){
        int rx = root(x), ry = root(y);
        if(rx != ry){
            if(rx > ry) swap(rx, ry);

            ineq -= siz[rx]*siz[ry];
            parent[rx] = parent[ry];
            siz[ry] += siz[rx];
        }
        return;
    }
};

int main()
{
    int n, m; cin >> n >> m;
    UnionFind u(n);
    vector<pair<int, int> > bridges(m);
    rep(i, m){
        int ai, bi; cin >> ai >> bi;
        bridges[i] = make_pair(ai-1, bi-1);
    }

    vector<ll> ans(m);
    reverse(bridges.begin(), bridges.end());
    ans[0] = u.ineq;
    rep(i, m-1){
        u.unite(bridges[i].first, bridges[i].second);
        ans[i+1] = u.ineq;
    }

    reverse(ans.begin(), ans.end());
    rep(i, m){
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 5692
//14
#include<iostream>
#include<map>
#include<algorithm>
#include<queue>

using namespace std;

struct D{
  int s[6],x,y;
  D(){
    for(int i=0;i<6;i++){
      s[i]=i+1;
    }
  }
  void r(int a,int b,int c,int d){
    int t=s[a];
    s[a]=s[b];
    s[b]=s[c];
    s[c]=s[d];
    s[d]=t;
  }
  void dr(int p){
    int d[][4]={{0,1,5,4},{0,4,5,1},{0,2,5,3},{0,3,5,2}};
    int dx[]={0,0,-1,1};
    int dy[]={-1,1,0,0};
    r(d[p][0],d[p][1],d[p][2],d[p][3]);
    x+=dx[p];
    y+=dy[p];
  }
  bool operator<(D a)const{
    if(x!=a.x){
      return x<a.x;
    }else if(y!=a.y){
      return y<a.y;
    }else{
      return lexicographical_compare(s,s+6,a.s,a.s+6);
    }
  }
};

int main(){
  for(int h,w;cin>>h>>w,h|w;){
    int g[10][10];
    for(int y=0;y<h;y++){
      for(int x=0;x<w;x++){
	cin>>g[y][x];
      }
    }
    int sy,sx,gy,gx;
    cin>>sy>>sx>>gy>>gx;
    typedef pair<int,D> S;
    priority_queue<S,vector<S>,greater<S> > que;
    D is;
    is.x=sx;
    is.y=sy;
    que.push(make_pair(0,is));
    map<D,bool> p;
    for(;;){
      int t=que.top().first;
      D c=que.top().second;
      if(c.x==gx&&c.y==gy)break;
      que.pop();
      if(p[c]++)continue;
      for(int i=0;i<4;i++){
	D n=c;
	n.dr(i);
	if(0<=n.x&&n.x<w&&0<=n.y&&n.y<h){
	  que.push(make_pair(t+n.s[5]*g[n.y][n.x],n));
	}
      }
    }
    cout<<que.top().first<<endl;
  }
  return 0;
}

Measured memory_bytes: 1332
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int K;cin >> K;
  vector<ll> v(K);
  rep(i,K)cin >> v[i];
  reverse(all(v));
  ll ax = 2,in = 2;
  rep(i,K){
    ll X = ax/v[i];
    ll Y = (in+v[i]-1)/v[i];
    ax = v[i]-1 + X*v[i];
    in = Y*v[i];
    if(ax-in<0){
      cout << -1 << endl;
      return 0;
    }
  }

  cout << in SP ax << endl;
  return 0;
}




Measured memory_bytes: 1024
#逆元

from fractions import gcd


def main():

  n=int(input())

  a=list(map(int,input().split()))
  mod=10**9+7

  b=0
  for i in a:
      b+=pow(i,mod-2,mod)


  L=a[0]
  def lcm(x,y):
      return x//gcd(x,y)*y

  for i in a:
      L=lcm(L,i)


  print(L*b%mod)

  
main()

Measured memory_bytes: 68328
function Main(input) {
  input = input.split('\n');
  var tmp = input[0].split(' ');

  var N = Number(tmp[0]);
  var A = Number(tmp[1]);

  var x = [0];
  x = x.concat(input[1].split(' ').map(Number));

  var dp = new Array(N + 1);
  for (var i = 0; i <= N; ++i) {
    dp[i] = new Array(N + 1);
    for (var j = 0; j <= N; ++j) {
      dp[i][j] = new Array(A * N + 1).fill(0);
    }
  }

  for (var i = 0; i < N; ++i) dp[i][0][0] = 1;

  for (var i = 1; i <= N; ++i) {
    for (var j = 1; j <= i; ++j) {
      for (var k = 1; k <= A * N; ++k) {
        if (k < x[i]) {
          dp[i][j][k] = dp[i - 1][j][k];
        } else {
          dp[i][j][k] = dp[i - 1][j][k] + dp[i - 1][j - 1][k - x[i]];
        }
      }
    }
  }

  var ans = 0;
  for (var j = 1; j <= N; ++j) {
    ans += dp[N][j][j * A];
  }

  console.log(ans);
}

// input = `8 5
// 3 6 2 8 7 6 5 9
// `;
// Main(input);

Main(require('fs').readFileSync('/dev/stdin', 'utf8'));


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

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

int main() {
    int n;
    cin >> n;
    int x0,x1,x;
    cin >> x0 >> x1;
    int g = gcd(x0, x1);
    for (int i = 0; i < n - 2; i++) {
        cin >> x;
        g = gcd(g, x);
    }
    cout << g << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  for(int h,m,s,hh,mm,ss;cin>>h>>m>>s>>hh>>mm>>ss;){
    int d=hh*3600+mm*60+ss-h*3600-m*60-s;
    cout << d/3600 << ' ' << (d-(d/3600*3600))/60 << ' ' << d-d/3600*3600-((d-(d/3600*3600))/60*60) <<endl;
  }
  return 0;
}

Measured memory_bytes: 1160
N = int(input())
A = list(map(int,input().split()))
cnt1,cnt2 = 0,0
S1,S2 = A[0],A[0]
#
if A[0]==0:
    cnt1,cnt2 = 1,1
    S1,S2 = 1,-1
elif A[0]>0:
    cnt2 += 1+A[0]
    S2 = -1
else:
    cnt1 += 1-A[0]
    S1 = 1
#
for i in range(1,N):
    K = S1+A[i]
    if S1>0 and K>=0:
        cnt1 += 1+K
        S1 = -1
    elif S1<0 and K<=0:
        cnt1 += 1-K
        S1 = 1
    else:
        S1 = K
#
for i in range(1,N):
    K = S2+A[i]
    if S2>0 and K>=0:
        cnt2 += 1+K
        S2 = -1
    elif S2<0 and K<=0:
        cnt2 += 1-K
        S2 = 1
    else:
        S2 = K
print(min(cnt1,cnt2))

Measured memory_bytes: 14468
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

score = sum(B)
num = A[0]
for i in A:
  if num == i-1:
    score += C[i-2]
  num = i
print(score)

Measured memory_bytes: 9144
#include<stdio.h>
#include<string.h>
#define LEN 100005
#define MAX 100005

typedef struct pp{
  char name[100];
  int t;
}P;

P Q[LEN+1];
int head,tail,n;

void enqueue(P x){
  Q[tail] = x;
  if(tail + 1 == MAX)tail=0;
  else tail++;
}

P dequeue(void){
  P x;

  x = Q[head];
  if(head + 1 == MAX)head = 0;
  else head++;

  return x;
}
int main(){
  int sum = 0,c;
  int i,q;
  P u;

  scanf("%d%d",&n,&q);
  for(i=0;i<n;i++)
    scanf("%s%d",Q[i].name,&Q[i].t);

  head = 0;
  tail = n;
  while(head != tail){
    u = dequeue();
    if(q > u.t)c = u.t;
    else c = q;
    u.t -= c;
    sum += c;
    if(u.t > 0)enqueue(u);
    else  printf("%s %d\n",u.name,sum);
  }
  return 0;
}

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

#define REP(var,start,end) for(int var=start; var<end; var++)

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


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>
#include <limits>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

template<typename T = long long>
class SegmentTree {
public:
    std::vector<T> ary;
    int n;
    const T default_value = 0;
    SegmentTree(int n) {
        this->n = 1;
        while (this->n < n) this->n *= 2;
        ary.resize(this->n * 2 - 1, 0);
    }
    T ope(T l, T r) {
        return std::max(l, r);
    }
    void update(int k, T d) {
        k += n - 1;
        ary[k] += d;
        while (k > 0) {
            k = (k - 1) / 2;
            ary[k] = ope(ary[2 * k + 1], ary[2 * k + 2]);
        }
    }
    T query(int a, int b) {
        return query(a, b, 0, n, 0);
    }
    T query(int a, int b, int l, int r, int i) {
        if (a <= l && b >= r) return ary[i];
        if (a >= r || b <= l) return default_value;
        int m = (l + r) / 2;
        T vl = query(a, b, l, m, 2 * i + 1);
        T vr = query(a, b, m, r, 2 * i + 2);
        return ope(vl, vr);
    }
};
void solve() {
    int n;
    cin >> n;
    VLL h(n), a(n), b(n), m(n);
    REP(i,0,n) cin >> h[i];
    REP(i,0,n) cin >> a[i];
    REP(i,0,n) b[i] = h[i];
    sort(all(b));
    map<LL,int> r;
    REP(i,0,n) {
        m[i] = b[i];
        r[b[i]] = i;
    }
    REP(i,0,n) b[i] = r[h[i]];
    SegmentTree<> seg(n);
    REP(i,0,n) {
        LL maxv = seg.query(0,b[i]);
        seg.update(b[i], maxv + a[i]);
    }
    cout << seg.query(0,n) << endl;
}

int main() {
    solve();
    
    return 0;
}

Measured memory_bytes: 23168
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define pb push_back
void solve(){
    int n; 
    cin>>n; 
    set<int>st;
    for(int i=0;i<n;i++){
        int x; 
        cin>>x; 
        st.insert(x);
    }
    int z = st.size();
    if(z==n){
        cout<<"YES"<<endl;
    }
    else {
        cout<<"NO"<<endl;
    }
}
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int t=1;
//	cin>>t;
	while(t--)solve();
	return 0;
}


Measured memory_bytes: 9600
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<functional>
#include<fstream>
#include<utility>
#include<bitset>
#include<map>
#include<deque>
#include<cmath>
#include<random>
#include<string.h>
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define rep(N) for (int i = 0; i < N; ++i)
#define Rep(a, b) for (int i = a; i < b; ++i)
#define For(i, N) for (int i = 0; i < N; ++i)
#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend()
#define makei(N) int N; cin >> N;
#define makel(N) ll N; cin >> N;
#define makes(s) string s; cin >> s;
#define maked(d) double d; cin >> d;
#define makev(v, N) vi v(N); rep(N)cin >> v[i];
#define mod 1000000007
#define re return 0

using namespace std;
using ll = long long int;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pii = pair<int, int>;
using pis = pair<int, string>;
using msi = map<string, int>;

template<typename T>
void say(T s) {
	cout << s << "\n";
}

template<typename T>
void say(vector<T> s) {
	auto itr = s.begin();
	cout << *(itr++);
	while (itr != s.end()) {
		cout << " " << *(itr++);
	}
	cout << "\n";
}

void saybool(bool b) {
	if (b)say("Yes");
	else say("No");
}

int main() {
	int A, B, C;
	cin >> A >> B >> C;
	saybool(A + B >= C);
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  string s;
  cin >> s;
  bool can = true;
  if(s[0] == '0')can = false;
  if(s[s.size() - 1] == '1')can = false;
  //cout << s[s.size() - 1] << endl;
  for(int i = 1;i < s.size() / 2;i++){
    if(s[i] != s[s.size() - i - 2])can = false;
  }
  if(!can){
    cout << -1 << endl;
  }
  else{
    ll mae = 0;
    for(int i = s.size() - 1;i >= 0;i--){
      if(s[i] == '1'){
        mae = i;
        i = -1;
        //cout << i << endl;
      }
    }
    vector<ll> res(s.size());
    for(int i = s.size() - 1;i >= 0;i--){
      //cout << s[i] << " ";
      /*if(s[i] == '0')cout << 1 << " " << i + 1 << endl;
      else{
        cout << mae + 1 << " " << i + 1 << endl;
        mae = i;
      }*/
      //cout << mae + 1 << " " << i + 1 << endl;
      res[i] = mae;
      if(s[i] == '1')mae = i;
    }
    for(int i = 0;i < s.size();i++){
      if(i == res[i])continue;
      cout << i + 1 << " " << res[i] + 1 << endl;
    }
  }
}

Measured memory_bytes: 2432
#include<bits/stdc++.h>
using namespace std;
using ll = int64_t;

int main(int , char **)
{
	int N,K;
	cin >> N >> K;
	ll c = 0;
	for(int i=0;i<N;i++){
		int x;
		cin >> x;
		c += min( (x), (K-x) );
	}
	printf("%ld\n",c*2);

	return 0;
}


Measured memory_bytes: 256
#include <iostream>                                        
#include <iomanip>                                         
using namespace std;                                       
                                                           
int main(void) {                                           
  int a, b;                                                
  cin >> a >> b;                                           
  cout << a/b << " " << a%b << " " << fixed << setprecision(5) << (double)a/b << endl;                               
  return 0;                                                
}                                                          
                             

Measured memory_bytes: 3280
#include <cstdio>
#include <climits>
#include <cassert>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <numeric>
#include <functional>
#include <tuple>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define FOR(x,xs) for(auto &x: xs)

using namespace std;
typedef long long ll;
typedef pair<int,int> PI;
typedef pair<ll,ll> PL;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<double, int> PDI;

struct bar {
  ll x, y, r;
};

int main() {
  ios::sync_with_stdio(false);
  bar s, t;
  cin >> s.x >> s.y >> t.x >> t.y;
  int N;
  cin >> N;
  vector<bar> ps(N);
  FOR(p,ps) {
    cin >> p.x >> p.y >> p.r;
  }
  ps.push_back({s.x, s.y, 0});
  ps.push_back({t.x, t.y, 0});
  vector<vector<double>> cost(N+2, vector<double>(N+2));
  REP(i,0,N+2) {
    REP(j,0,N+2) {
      if(i == j) {
        cost[i][j] = 0.0;
      } else {
        double dst = sqrt((ps[i].x - ps[j].x) * (ps[i].x - ps[j].x) +
                          (ps[i].y - ps[j].y) * (ps[i].y - ps[j].y));
        cost[i][j] = max(0.0, dst - ps[i].r - ps[j].r);
      }
    }
  }
  REP(k,0,N+2) {
    REP(i,0,N+2) {
      REP(j,0,N+2) {
        cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j]);
      }
    }
  }
  cout << setprecision(12) << cost[N][N+1] << endl;
  return 0;
}


Measured memory_bytes: 8320
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  ll x;
  cin >> x;
  cout << x / 11 * 2 + (x % 11 + 5) / 6 << endl;
}


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

int main() {
string S;
cin >> S;
string judge = "Yes";

for (int i = 0; i < S.size(); i += 2) {
    if (S.at(i) == 'L') {
        judge = "No";
        break;
    }
}
for (int i = 1; i < S.size(); i += 2) {
    if (S.at(i) == 'R') {
        judge = "No";
        break;
    }
}
cout << judge << endl;
}

Measured memory_bytes: 256
m=map(int,raw_input().split())
c=[0 for i in range(m[1])]
for j in range(m[0]):
        e=map(int,raw_input().split())
        r=0
        for i in range(m[1]):
                r+=e[i]
                c[i]+=e[i]
                print e[i],
        print r
s=0
for i in range(m[1]):
        s+=c[i]
        print c[i],
print s

Measured memory_bytes: 4240
from bisect import bisect_right

n, a, b = map(int, input().split())
h = [int(input()) for _ in range(n)]

h.sort()

c = a - b
top = h[n - 1] // b + 1
bottom = 1
while top - bottom > 0:
    temp = (top + bottom) // 2
    p = bisect_right(h, temp * b)
    count = 0
    for i in range(p, n):
        count += (h[i] - temp * b) // c
        if h[i] % c != 0:
            count += 1
    if count > temp:
        bottom = temp + 1
    else:
        top = temp
    #print(top, bottom, count, temp)

print(top)



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

const ll MAX = 1000000;
const ll MOD = 1000000007;

ll fac[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
    }
}

ll pow_kai(ll a,ll n){//aのn乗を計算します。
  ll x = 1;
  while(n > 0){//全てのbitが捨てられるまで。
    if(n&1){//1番右のbitが1のとき。
      x = x*a%MOD;
    }
    a = a*a%MOD;
    n >>= 1;//bit全体を右に1つシフトして一番右を捨てる。
  }
  return x;
}

// 二項係数計算
ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    ll tmp=1;
    for(ll i=n;i>=n-k+1;i--) tmp = (tmp*i)%MOD;
    
    return (tmp * pow_kai(fac[k],MOD-2)) % MOD;
}


int main()
{
    ll n,a,b;
    ll all;

    cin >> n >> a >> b;
    COMinit();


    all =pow_kai(2,n);
    ll ans =(all - COM(n,a) -COM(n,b) - 1)%MOD;

    while(ans<0){
        ans += MOD;
    }

    cout << ans <<endl;

 
    return 0;

}

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

using namespace std;
#define INF (1<<28)
#define DEKAI 1000000007
#define lp(i,n) for(int i=0;i<n;i++)
#define int long long
signed main(){
  int n;
  cin>>n;
  int stat=0,ans=0;
  lp(i,n){
    int a;
    cin>>a;
    if(a==0) stat=0;
    else{
      if(a%2==0){
        ans+=a/2;
      }
      else{
        if(stat==0) stat=1;
        else {
          stat=0;
          ans++;
        }
        ans+=a/2;
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
/*================================================================
rehtegot!
*   
*   File Name：bf.cpp
*   Author：YaliKiWi
*   Date：2019年11月13日
*   Discribe：
*
================================================================*/


#include<bits/stdc++.h>
using namespace std;
#define fo(i,s,e) for(register int i=s,i%:%:_end=e;i<=i%:%:_end;i++)
#define max_(x,y) ((x)>(y)?(x):(y))
#define min_(x,y) ((x)<(y)?(x):(y))
#define dd double
#define ull unsigned long long
#define ll long long
#define file(x) freopen(x".in","r",stdin),freopen(x".out","w",stdout)
using namespace std;
const long long N = 1e5 + 5;
pair<long long, long long> coins[N];
long long dp[N];
long long n;
long long pd[N];
long long x, y, z;
long long ans;
long long javab = 0;
bool cmp(pair<long long, long long> p1, pair<long long, long long> p2)
{
	long long v1 = p1.first - p1.second;
	long long v2 = p2.first - p2.second;
	return v1 < v2;
}
void calc()
{
	multiset<long long> s;
	for (long long i = 0; i < y; i++)
	{
		s.insert(coins[i].second);
		dp[y - 1] += coins[i].second;
	}
	for (long long i = y; i < n; i++)
	{
		long long tmp = coins[i].second;
		dp[i] = dp[i - 1];
		if (*s.begin() < tmp)
		{
			dp[i] = dp[i - 1] + tmp - *s.begin();
			s.erase(s.begin());
			s.insert(tmp);
		}
	}
	reverse(coins, coins + n);
	s.clear();
	for (long long i = 0; i < x; i++)
	{
		s.insert(coins[i].first);
		pd[x - 1] += coins[i].first;
	}
	for (long long i = x; i < n; i++)
	{
		pd[i] = pd[i - 1];
		long long tmp = coins[i].first;
		if (*s.begin() < tmp)
		{
			pd[i] = pd[i - 1] + tmp - *s.begin();
			s.erase(s.begin());
			s.insert(tmp);
		}
	}
	reverse(coins, coins + n);
	reverse(pd, pd + n);

}
int main() 
{
	//file("b");
	cin >> x >> y >> z;
	n = x + y + z;
	for (long long i = 0; i < x + y + z; i++)
	{
		long long a, b, c;
		cin >> a >> b >> c;
		coins[i] = {a - c, b - c};
		ans += c;
	}
	sort(coins, coins + n, cmp);
	calc();
	for (long long i = y - 1; i < n - x; i++)
	{
		javab = max(javab, ans + dp[i] + pd[i + 1]);
	}
	cout << javab;


}



Measured memory_bytes: 7424
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <math.h>
using namespace std;
typedef long long int ll;

ll mod=1e8+7;
ll dp[100100];
ll dp1[100100];

int main(){
	for(int i=1;i<=6;i++){
		dp[i]=pow(2,i-1);
	}
	for(int i=7;i<=100000;i++){
		(dp[i]+=dp[i-1]+dp[i-2]+dp[i-3]+dp[i-4]+dp[i-5]+1)%=mod;
	}
	for(int i=1;i<=4;i++){
		dp1[i]=pow(2,i-1);
	}
	for(int i=5;i<=100000;i++){
		(dp1[i]+=dp1[i-1]+dp1[i-2]+dp1[i-3]+1)%=mod;
	}
	while(1){
		string s; cin >> s;
		if(s=="#")break;
		int n=s.size();
		ll ans=1;
		for(int i=0;i<n;i++){
			char c=s[i];
			int cnt=0;
			while(i<n&&s[i]==c){
				i++;
				cnt++;
			}
			i--;
			if(c=='8'||c=='0')(ans*=dp1[cnt])%=mod;
			else (ans*=dp[cnt])%=mod;
		}
		cout << ans << endl;
	}
}


Measured memory_bytes: 5032