akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

using namespace std;

#define mp make_pair
#define pb push_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(),(x).end()

template<class T> inline bool chkmax(T& a,T b){ return a<b?a=b,1:0; }
template<class T> inline bool chkmin(T& a,T b){ return a>b?a=b,1:0; }

template<typename T> inline T& read(T& x){
    static char c; bool flag=0;
    while(!isdigit(c=getchar())) if(c=='-') flag=1;
    for(x=c-'0';isdigit(c=getchar());(x*=10)+=c-'0');
    if(flag) x=-x;
    return x;
}

typedef long long LL;
typedef pair<LL,LL> PLL;

const int maxn=360,mo=1e9+7;
const LL INF=0x3f3f3f3f3f3f3f3fll;

int n,ans;
LL m,a[maxn];

struct Info{
    LL b,c;
    bool operator < (const Info& rhs) const{
        return c<rhs.c;
    }
} p[maxn];

int minval(LL l,LL r){
    int ret=0;
    for(int i=59;~i;i--){
        if((l&(1ll<<i))==(r&(1ll<<i))) ret+=(l>>i)&1;
        else{ ret+=(l&((1ll<<i)-1))?1:0; break; }
    }
    return ret;
}

map<vector<LL>,vector<PLL> > Map;

void modify(int pos,LL k){
    if(k<0) return;
    LL w=INF; vector<LL> t;
    for(int i=1;i<=n;i++){
        t.pb(p[i].b-(i<=pos));
        chkmin(w,t.back());
    }
    if(w<0) return;
    for(int i=0;i<n;i++) t[i]-=w;
    sort(ALL(t));
    Map[t].pb(mp(max(w-k,0ll),w));
}

int main(){
	Map.clear();
        read(n); read(m); ans=0;
        for(int i=1;i<=n;i++) read(a[i]);

        for(int k=0;k<=60;k++){
            for(int i=1;i<=n;i++) p[i].b=a[i]>>k,p[i].c=a[i]&((1ll<<k)-1);
            sort(p+1,p+n+1);
            LL L=0,R;
            for(int i=1;i<=n;i++){
                int pos=i;
                while(pos<n&&p[i].c==p[pos+1].c) ++pos;
                R=p[i].c;
                modify(i-1,m-k-minval(L,R));
                L=R+1; i=pos;
            }
        }

        for(auto it=Map.begin();it!=Map.end();it++){
			vector<PLL> t=it->second;
			sort(ALL(t)); LL L=0,R=-1;
			for(int i=0;i<SZ(t);i++){
				if(t[i].first>R){
					(ans+=(R-L+1)%mo)%=mo;
					L=t[i].first; R=t[i].second;
				}
				else chkmax(R,t[i].second);
			}
			(ans+=(R-L+1)%mo)%=mo;
        }

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

    return 0;
}


Measured memory_bytes: 16512
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
	    int a = Integer.parseInt(sc.next());
	    int b = Integer.parseInt(sc.next());
	    int c = Integer.parseInt(sc.next());
	    int d = Integer.parseInt(sc.next());
	    if (a < b) {
	        System.out.println(a * c);
	    } else {
	        System.out.println((b * c) + ((a - b) * d));
	    }
    }
}


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

using namespace std;

double Helon(double a, double b, double c){
  double s = ( a + b + c) / 2;
  return sqrt( s * ( s-a) * (s-b) * (s-c));}

int main(){
 double x1,y1,x2,y2,x3,y3; cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
  
  double a = sqrt(pow(x2-x1,2.0) + pow(y2-y1,2.0));
  double b = sqrt(pow(x3-x2,2.0) + pow(y3-y2,2.0));
  double c = sqrt(pow(x1-x3,2.0) + pow(y1-y3,2.0)); //３辺の長さをそれぞれ求める
  
  double L = max(a,max(b,c));
  
  double r = (2*Helon(a,b,c)) / ( a + b + c); //内接円の半径
  
  cout << fixed << setprecision(11) << ( r * L) / ( 2*r + L) << endl;
  return 0;}
  

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <array>

using ll = long long;

int main() {
  std::string input;
  std::cin >> input;
  std::reverse(input.begin(), input.end());

  std::vector<ll> dp(13);
  dp[0] = 1;
  int b = 1;
  const ll kMod = 1e9+7;
  for (auto c : input) {
    std::vector<ll> next(13);
    for (int i = 0; i < 13; i++) {
      if (c == '?') {
        for (int j = 0; j < 10; j++) {
          (next[(i + j*b)%13] += dp[i]) %= kMod;
        }
      } else {
        (next[(i+(c- '0')*b)%13] = dp[i]) %= kMod;
      }
    }
    dp = next;
    b = (b * 10) % 13;
  }
  std::cout << dp[5] << std::endl;

  return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
#define int long long
typedef pair<int,int>P;
typedef pair<int,P>P2;
#define F first
#define S second
int dy[]={-1,0,1,0};
int dx[]={0,1,0,-1};

signed main(){
	int x,y;
	int a,b,c;
	cin>>a>>b>>c;

	cout<<min(a+b,min(b+c,a+c))<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef DEBUG
#include "_debug.cpp"
#include "callable.hpp/callable.hpp"
#endif
#define endl '\n'
using namespace std;
using ll = long long;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin >> s;
    vector<pair<char, int>> v = {{s[0], 1}};
    for(int i = 1; i < s.size(); i++) {
        if(s[i] != v.back().first) {
            v.push_back({s[i], 1});
        } else {
            v.back().second++;
        }
    }
    int k = 0;
    for(int i = 1; i < v.size() - 1; i++) {
        if(v[i-1].first == 'J' and v[i].first == 'O' and v[i+1].first == 'I'
        and v[i-1].second >= v[i].second and v[i].second <= v[i+1].second) {
            k = max(k, v[i].second);
        }
    }
    cout << k << endl;
    return 0;
}



Measured memory_bytes: 13064
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>

using namespace std;

int main() {
	string s1, s2, tes;
	bool flag = false;
	int cnt;
	cin >> s1 >> s2;
	if (s1 == s2) {
		flag = true;
	} else {
		for (int i = 0; i < s1.size(); i++) { //操作を行う回数
			cnt = 0;
			tes = "";
			for (int j = i; cnt < s1.size(); j++) { //1文字1文字見る
				if (j == s1.size()) {
					j = 0;
				}
				tes += s1[j];
				cnt++;
			}
			if (tes == s2) {
				flag = true;
				break;
			}
		}
	}
	if (flag) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<ll,ll> P;
#define fi first
#define se second
set<string> c;
const ll mod=1000000007;
const ll mod2=998244353;
const ll inf=100000000000000000;
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),b(n);
for(int i=0;i<n;i++)cin>>a.at(i);
int odd=n/2,even=odd-1;
if(n%2==0){
for(int i=0;i<n;i++){
    if(i%2==0){
        b.at(odd)=a.at(i);
        odd++;
    }
    else{
        b.at(even)=a.at(i);
        even--;
    }
}
}
else{
    for(int i=0;i<n;i++){
    if(i==0||i%2==1){
        b.at(odd)=a.at(i);
        odd++;
    }
    else{
        b.at(even)=a.at(i);
        even--;
    }
}
}
for(int i=0;i<n;i++)cout<<b.at(i)<<" ";
cout<<endl;
}



Measured memory_bytes: 3712
#include <iostream>
#include <cmath>
using namespace std;
using ll = long long;

int main(){
	int n, k;
	ll cnt;
	cin >> n >> k;

	cnt = pow((n/k), 3);

	// Kが奇数のとき
	if(k%2 == 1){
		cout << cnt << endl;
		return 0;
	}

	// Kが偶数のとき
	cnt += pow((n+k/2)/k, 3);

	cout << cnt << endl;
	return 0;
}

// Kについて
// 奇数: mod = 0 を数え上げる
// 偶数: mod = 0, 1/2*K を数え上げる

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    int now = 1;
    for(int i = 0; i < n; i++) {
        if(a[i] == now) {
            now++;
        }
    }
    if(now == 1) {
        cout << -1 << endl;
        return 0;
    }
    cout << n - now + 1 << endl;
}

Measured memory_bytes: 1024
// AtCoder ABC104: A - Garden
// 2019.9.11 bal4u

#include <stdio.h>

int main()
{
	int i, j, k, N, ans;
	
	scanf("%d", &N);
	ans = 0;
	for (i = 3; i <= N; i+=2) {
		k = 0;
		for (j = 1; j <= i; j++) if (i % j == 0) k++;
		if (k == 8) ans++;
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>

using namespace std;

int main()
{
    int line,ch;
    cin>>line>>ch;
    string c;
    string arr[line];
    for (int i =0;i<line;i++){
            cin>>c;
            arr[i]=c;
    }
    for(int j=0;j<line;j++){
        cout<<arr[j]<<endl;
         cout<<arr[j]<<endl;

    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
   int E,Y;
   cin >> E >> Y;
   if(E==0){
       if((1868<=Y)&&(Y<=1911)){
           cout << "M" << (Y-1867) << endl;
       }
       else if((1912<=Y)&&(Y<=1925)){
           cout << "T" << (Y-1911) << endl;
       }
       else if((1926<=Y)&&(Y<=1988)){
           cout << "S" << (Y-1925) << endl;
       }
       else if((1989<=Y)&&(Y<=2016)){
           cout << "H" << (Y-1988) << endl;
       }
   }
   else if(E==1){
       cout << 1867+Y << endl;
   }
   else if(E==2){
       cout << 1911+Y << endl;
   }
   else if(E==3){
       cout << 1925+Y << endl;
   }
   else if(E==4){
       cout << 1988+Y << endl;
   }

}


Measured memory_bytes: 3112
package main

import "fmt"

func main() {
  var d int
  fmt.Scan(&d)
  
  switch d {
  case 22: fmt.Println("Christmas Eve Eve Eve")
  case 23: fmt.Println("Christmas Eve Eve")
  case 24: fmt.Println("Christmas Eve")
  default: fmt.Println("Christmas")
  }
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <set>
#include <string>
using namespace std;
using llong = long long;

set<string> s;
string str;
int a, b;

void dfs(int x, int y) {
	if (x == a && y == b) {
		s.insert(str);
		return;
	}
	
	if (x <= 3 && y >= 5) return;
	if (y <= 3 && x >= 5) return;
	if (x == 5 && y == 5) return;
	if (x == 6 && y == 4) return;
	if (y == 6 && x == 4) return;
	
	str.push_back('A');
	dfs(x + 1, y);
	str.pop_back();
	
	str.push_back('B');
	dfs(x, y + 1);
	str.pop_back();
	
	return;
}

int main() {
	cin >> a >> b;
	
	dfs(0, 0);
	
	for (auto &x:s) {
		cout << x << endl;
	}
	
	return 0;
}


Measured memory_bytes: 3204
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define PI 3.141592653589793238462643383279502884L
#define make_unique(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define Sort(vec) sort(vec.begin(),vec.end())
#define RSort(vec) sort(vec.rbegin(),vec.rend())
#define endl "\n"
#define tr1(i) cout<<i<<endl;
#define tr2(i,j) cout<<i<<" "<<j<<endl;
#define tr3(i,j,k) cout<<i<<" "<<j<<" "<<k<<endl;
#define vvi vector<vector<int> > 
#define vvl vector<vector<ll> >
#define all(st) st.begin(),st.end()
#define vpl vector<pair<ll,ll> >
#define vpi vector<pair<int,int> >
#define pi pair<int,int>
#define pl pair<ll,ll>
#define al vector<list<int> >
#define vs vector<string>
#define vb vector<bool>
#define vi vector<int>
#define vl vector<ll>
#define vc vector<char>
#define rep(i,l,r) for(int i=l;i<r;i++)
#define repit(st) for(auto it=st.begin();it!=st.end();it++)
#define ull unsigned long long int
#define eb emplace_back
#define pb push_back
#define ll long long int
#define minf -(1e18)
#define inf 1e18
#define f first
#define se second
#define mod 1000000007
using namespace std;
using namespace __gnu_pbds; 
ll mi(ll n,ll m){ll pw=n%m;ll ex=m-2;ll ans=1;while(ex){if(ex&1) ans = ans*pw%m;pw = pw*pw%m;ex>>=1;}return ans%mod;}
ll pw(ll a,ll n){ll pw=a;ll ex=n;ll ans=1;while(ex){if(ex&1) ans = ans*pw;pw = pw*pw;ex>>=1;}return ans;}
ll pwm(ll a,ll n){ll pw=a%mod;ll ex=n;ll ans=1;while(ex){if(ex&1) ans = ans*pw%mod;pw = pw*pw%mod;ex>>=1;}return ans%mod;}
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }
template<typename T> using ordered_set=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
//st.order_of_key(num)->number of elements < num
//st.find_by_order(i)->iterator of ith element in sorted order starting from zero
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll max(ll a,ll b){return a>b?a:b;}
ll min(ll a,ll b){return a<b?a:b;}
ll Abs(ll x){return x>0?x:(-x);}
ll Ceil(ll a,ll b){return a/b+(a%b!=0);}
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define mkp make_pair
//#define int long long int
//Binary_Search->dp->greedy
//auto check = [&](ll x){};
//function<long long(int)> choose2 = [&](int n) {};
void dfs(int v,vvi&adj,vb&vis){
	vis[v]=true;
	for(int nbs:adj[v]){
		if(!vis[nbs]) dfs(nbs,adj,vis);
	}
}
void solve(){
	ll n,m;
	cin>>n>>m;
	vvi adj(n);
	vl deg(n);
	for(int i=0;i<m;i++){
		int u,v,w;
		cin>>u>>v>>w;
		u--;v--;
		adj[u].pb(v);
		adj[v].pb(u);
		deg[u]++;
		deg[v]++;
	}
	vpi vec;
	for(int i=0;i<n;i++) vec.eb(deg[i],i);
	vector<bool> vis(n);
	RSort(vec);
	ll cnt=0;
	for(int i=0;i<n;i++){
		if(!vis[i]){
			cnt++;
			dfs(i,adj,vis);
		}
	}
	cout<<cnt<<endl;
	
	
	
}
int main(){
int t=1;
//scanf("%d",&t);
while(t--){
	solve();
}
return 0;
}    

Measured memory_bytes: 12148
#include <iostream>
#include <vector>
#include <math.h>
#include <cmath>
#include <algorithm>
#include <string>
#include <cstring>
#include <regex>

using namespace std;

using ll = long long;
using pii = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using vvs = vector<vs>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vpii = vector<pii>;
using vvpii = vector<vpii>;

#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define rFOR(i,a,b) for(int i=(b);i>=(a);i--)
#define SORT(a) sort((a).begin(),(a).end());
#define rSORT(a) sort((a).rbegin(),(a).rend());
#define UNIQUE(a) (a).erase(unique((a).begin(),(a).end()),(a).end());
#define yn(a) cout <<((a)?"yes":"no")<<endl;
#define Yn(a) cout <<((a)?"Yes":"No")<<endl;
#define YN(a) cout <<((a)?"YES":"NO")<<endl;
#define Say(a) cout <<(a);
#define Sal(a) cout <<(a)<<endl;

const ll MOD = 1e9+7;
const string alp = "abcdefghijklmnopqrstuvwxyz";
const string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}

int isP(int n) {
    if(n<=1) return 0;
    FOR(i,2,(int)sqrt(n)) {
        if(n%i==0) return 0;
    }
    return 1;
}

//sankou
//vvi = vector<vector<int>>(20, vector<int>(10, 0));

//seiki
//#include <regex>
/*bubun*/
//regex_search("u32", regex("[0-9]"));      // true
/*kanzen*/
//regex_match("u32", regex("(i|u)\\d+"));   // true

int main() {

    ll T,A,B,C,D,gc,can=1;
    cin >>T;
    FOR(i,0,T-1){
        cin >>A>>B>>C>>D;
        can=1;
        if(A<B) can=0;
        if(A>=B){
            if(B>D) can=0;
            if((B<=D)&&(C<B)){
                if(D==B){
                    if(A%B>C) can=0;
                }
                if(D>B){
                    if(A%B>C) can=0;
                    if(A%B<=C){
                        gc=gcd((D-B),B);
                        if((C-(C-A%B)%gc)+gc<B) can=0;
                    }
                }
            }
        }
        Yn(can);
    }
    
    return 0;
}

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

typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define REP(i,n) for (int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
 
using namespace std;

signed main(){
    
    int n,c;
    cin >> n >> c;
    int d[31][31];
    int cc[501][501];
    REP(i,c) REP(j,c) cin >> d[i][j]; 
    REP(i,n) REP(j,n) cin >> cc[i][j];

    int iro[3][31] = {0};
    REP(i,n){
        REP(j,n){
            iro[(i+j+2)%3][cc[i][j]]++;
        }
    }

    int cst[3][31] = {0};
    REP(i,3){
        REP(j,c){
            REP(l,c){
                cst[i][j] += iro[i][l+1]*d[l][j];
            }
        }
    }

    REP(i,3){
        REP(j,c){
            //cerr << cst[i][j] << " ";
        }
        //cerr << endl;
    }

    vector<pair<int,int>> a0,a1,a2;
    REP(i,c){
        a0.push_back(MP(cst[0][i],i));
        a1.push_back(MP(cst[1][i],i));
        a2.push_back(MP(cst[2][i],i));
    }
    SORT(a0);
    SORT(a1);
    SORT(a2);
    vector<int> ans;
    REP(i,3){
        REP(j,3){
            REP(k,3){  
                if(a0[i].se == a1[j].se || a0[i].se == a2[k].se || a2[k].se == a1[j].se){
                   ans.push_back(100000000000);
                }else ans.push_back(a0[i].fi + a1[j].fi + a2[k].fi);
            }
        }
    }
    SORT(ans);
    cout << ans[0] << endl;

    
    return 0;
}
//g++ -std=c++14 code1.cpp


Measured memory_bytes: 2176
#include <atcoder/all>

#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using namespace atcoder;
using lint = long long int;
long long int INF = 1001001001001001LL;
int inf = 1000000007;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;

template<typename T1,typename T2>inline void chmin(T1 &a,const T2 &b){if(a>b) a=b;}
template<typename T1,typename T2>inline void chmax(T1 &a,const T2 &b){if(a<b) a=b;}

#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()

/* do your best */

int main() {
  
  int n, d; cin >> n >> d;
  vector<int> x(n);
  vector<int> y(n);

  for (int i = 0; i < n; i++) {
    cin >> x[i] >> y[i];
  }

  two_sat ts(n);
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      if (abs(x[i] - x[j]) < d) {
        // x[i] と x[j] は同時に使えない
        // 否定を取った論理式を追加する
        ts.add_clause(i, false, j, false);
      }
      if (abs(x[i] - y[j]) < d) {
        ts.add_clause(i, false, j, true);
      }
      if (abs(y[i] - x[j]) < d) {
        ts.add_clause(i, true, j, false);
      }
      if (abs(y[i] - y[j]) < d) {
        ts.add_clause(i, true, j, true);
      }
    }
  }

  if (!ts.satisfiable()) {
    cout << "No" << endl;
    return 0;
  }

  cout << "Yes" << endl;
  auto answer = ts.answer();
  for (int i = 0; i < n; i++) {
    if (answer[i]) {
      cout << x[i] << endl;
    } else {
      cout << y[i] << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 3248
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}
func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}
func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}
func fSum(a []float64) float64 {
	x := 0.
	for _, v := range a {
		x += v
	}
	return x
}
func bOut(f bool, x string, y string) {
	if f {
		fmt.Println(x)
	} else {
		fmt.Println(y)
	}
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	s := Scan()
	x := 0
	for _, v := range s {
		if string(v) == "p" {
			x++
		}
	}
	fmt.Println(len(s)/2 - x)
}


Measured memory_bytes: 2104
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
using namespace std;
int main()
{
    int a,b;
    scanf("%d%d",&a,&b);
    if(a<=b)
        printf("0\n");
    else
        printf("%d\n",a-b);
    return 0;
}


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

int main(){
    int cards[4][13]={};
    int n,a;
    char k;
    scanf("%d",&n);
    for(int i =0;i<n;i++){
        scanf("%c",&k);
        scanf("%c %d",&k,&a);
        switch(k){
            case 'S':cards[0][a-1]=1;break;
            case 'H':cards[1][a-1]=1;break;
            case 'C':cards[2][a-1]=1;break;
            case 'D':cards[3][a-1]=1;break;
        }
    }
    for(int i= 0;i<4;i++){
        for(int j=0;j<13;j++){
            if(cards[i][j]==0){
                switch(i){
                    case 0:printf("S %d\n",j+1);break;
                    case 1:printf("H %d\n",j+1);break;
                    case 2:printf("C %d\n",j+1);break;
                    case 3:printf("D %d\n",j+1);break;
                }
            }
        }
    }
    }
   



Measured memory_bytes: 2636
#include<cstdio>
#include<algorithm>
using namespace std;
int a,b;
long long ans=0;
void solve()
{
    for(int i=b+1;i<=a;i++)
    {
        for(int j=0;j<=a/i;j++)
        {
            int d=j*i;
            int am=min(1+a-d,i);
            int rm=max(0,am-b);
            ans+=rm;
            if(rm&&j==0&&b==0)ans--;
        }
    }
}
main()
{
    scanf("%d%d",&a,&b);
    solve();
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 128
#include<stdio.h>

int main()
{
    int i, n, m, cx, cy, x_max = -999, y_min = 999, war = 1;
    scanf("%d %d %d %d", &n, &m, &cx, &cy);
    
	int x[n], y[m];
	
	for(i = 0; i < n; i++){
		scanf("%d", &x[i]);
		if(x_max < x[i]){
			x_max = x[i];
		}
	}
	
	for(i = 0; i < m; i++){
		scanf("%d", &y[i]);
		if(y_min > y[i]){
			y_min = y[i];
		}
	}
	
	for(i = x_max + 1; i <= y_min; i++){
		if(cx < i && i <= cy){
			war = 0;
			break;
		}
	}
	
	if(war == 1){
		printf("War");
	}else{
		printf("No War");
	}

    return 0;
}

Measured memory_bytes: 128
x = int(input())
target_ls = [0]
base = 1
base_ls = [0]
while True:
    new = (base)**5
    target_ls.append(new)
    target_ls.append(-new)
    base_ls.append(base)
    base_ls.append(-base)
    target_ls.sort()
    base_ls.sort()
    if target_ls[-1] - target_ls[-2] > 10**9:
        break
    base += 1
len_target= len(base_ls)
for i,a in enumerate(base_ls):
    for j,b in enumerate(base_ls):
        if target_ls[i] - target_ls[j] == x:
            ans = [a,b]
print(ans[0],ans[1])

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

using namespace std;

#define ll long long

template<typename T>
struct BellmanFord {
	struct edge {
		int u, v; T w;
		edge(int from, int to, T weight) {
			u = from;
			v = to;
			w = weight;
		}
	};

	int n; // 頂点数
	vector<vector<int>> G;
	vector<int> used, reach;
	BellmanFord(int n) : n(n), G(n), used(n, 0), reach(n, 0) {}

	vector<edge> es;
	void add_edge(int u, int v, T c) {
		es.emplace_back(u, v, c);
		G[u].emplace_back(v);
	}

	void dfs(int v) {
		if (used[v]) return;
		used[v] = 1;
		for (int u : G[v])
			dfs(u);
	}

	// fromからtoまでの最短経路を求める.
	// 負閉路がある場合にはneg_loopに1が格納される.
	T build(int from, int to, int& neg_loop) {
		for (int i = 0; i < n; i++) {
			fill(used.begin(), used.end(), 0);
			dfs(i);
			reach[i] = used[to];
		}
		const T INF = numeric_limits<T>::max();
		vector<T> ds(n, INF);
		ds[from] = 0;
		for (int j = 0; j < n; j++) {
			bool update = 0;
			for (auto e : es) {
				if (!reach[e.u] || !reach[e.v] || ds[e.u] == INF) continue;
				if (ds[e.v] > ds[e.u] + e.w) {
					ds[e.v] = ds[e.u] + e.w;
					update = 1;
				}
			}
			if (!update) break;
			if (j == n - 1) {
				neg_loop = 1;
				return INF;
			}
		}
		neg_loop = 0;
		return ds[to];
	}
};

signed main() {
	int n, m, p;
	cin >> n >> m >> p;
	BellmanFord<int> g(n + 1);
	for (int i = 0; i < m; ++i) {
		int a, b, c;
		cin >> a >> b >> c;
		g.add_edge(a, b, p - c);
	}

	int neg;
	int res = g.build(1, n, neg);

	if (neg) cout << -1 << endl;
	else cout << max(0, -res) << endl;

	return 0;
}

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

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, X, T;
    cin >> N >> X >> T;
    ll ans = 0;
    ll num = 0;
    while (num < N) {
        num += X;
        ans += T;
    }
    cout << ans << endl;
    return 0;
}

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

namespace ext {
	using namespace std;
	template<class T>
	struct Vector : std::vector<T> {
		using std::vector<T>::vector;
		char dil = ' ';
		Vector<T> accum() {
			Vector<T> res(this->size() + 1);
			for (size_t i = 0; i < this->size(); i++) {
				res[i+1] = (*this)[i] + res[i];
			}
			return res;
		}
		Vector<T> zaatsu() {
			map<T, int> m;
			for (auto& e: *this) m[e] = 1;
			int count = 0;
			for (auto& e: m) e.second = count++;
			Vector<T> res = *this;
			for (auto& e: res) e = m[e];
			return res;
		}
		friend istream& operator>>(istream& is, vector<T>& t) {
			for (auto& e: t) cin >> e;
			return is;
		}
		friend ostream& operator<<(ostream& os, vector<T>& t) {
			t.print(' ', os);
			return os;
		}
		void print(char del = ' ', ostream& os = cout) {
			for (size_t i = 0; i < this->size(); i++) {
				os << (*this)[i];
				if (i + 1 != this->size()) os << del;
				os.flush();
			}
		}
		void println(char del = ' ', ostream& os = cout) {
			print(del, os);
			cout << endl;
		}
		long long crossing_merge() {
			auto t = *this;
			return t.crossing_merge_sub();
		}
		// 半開区間
		long long crossing_bit(T min_v = -1, T max_v = -1) {
			if (min_v == -1) min_v = this->min();
			if (max_v == -1) max_v = this->max() + 1;
			Vector<T> bit(max_v - min_v + 1, 0);
			long long res = 0;
			for (auto e: *this) {
				e = max_v - e;
				for (size_t x = e - 1; x; x -= x & -x) {
					res += bit[x];
				}
				for (size_t x = e; x < bit.size() ; x += x & -x) {
					bit[x]++;
				}
			}
			return res;
		}
		bool permutation() {
			return next_permutation(this->begin(), this->end());
		}
		T& max() {
			return *max_element(this->begin(), this->end());
		}
		T& min() {
			return *min_element(this->begin(), this->end());
		}
private:
		long long crossing_merge_sub() {
			if (this->size() == 1) return 0;
			int x = this->size() / 2;
			Vector<T> left(this->begin(), this->begin() + x);
			Vector<T> right(this->begin() + x, this->end());
			long long res = left.crossing_merge_sub() + right.crossing_merge_sub();
			left.push_back(numeric_limits<T>::max()); right.push_back(numeric_limits<T>::max());
			size_t l = 0, r = 0;
			while (l + r < this->size()) {
				if (left[l] < right[r]) {
					(*this)[l+r] = left[l];
					l++;
				} else {
					(*this)[l+r] = right[r];
					r++;
					res += x - l;
				}
			}
			return res;
		}
	};
}

using namespace std;
using namespace ext;

bool isok(int k, const Vector<int>& a) {
	Vector<int> v(a.size()+1);
	auto res = 0LL;
	for (int i = 0; i < a.size(); i++) {
		v[i+1] = (a[i] >= k) ? 1 : -1;
		v[i+1] += v[i];
	}
	res += v.crossing_bit() ;
	auto al = (long long) a.size() * (a.size() + 1) / 2;
	return res <= al - res;
}

int main() {
	namespace std = ext;
	using std::vector;
	int N;
	cin >> N;
	Vector<int> a(N);
	cin >> a;
	int ng = 1e9 + 10;
	int ok = 0;
	int cnt = 0;
	while (ng - ok > 1) {
		int mid = (ng + ok) / 2;
		if (isok(mid, a)) ok = mid;
		else ng = mid;
	}
	cout << ok << endl;
}

Measured memory_bytes: 1472
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	long long a,b,c,x,y,t;
	bool flag;
	while(cin>>a>>b>>c>>x>>y)
	{
		flag=0;
		if(x>y)swap(x,y),swap(a,b);
		if(c*2<=a+b)
		{
			t=x*c*2;
			if(c*2<b)
			{
				t+=(y-x)*2*c;
				flag=1;
			}
		}
		else {
			t=(a+b)*x;
		}
		if(flag==0)t+=(y-x)*b;
		cout<<t<<endl;
	 } 
}

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

int main() {
  int H, N;
  cin >> H >> N;
  int A[N];
  int sum = 0;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    sum = sum + A[i];
  }
  
  if (sum >= H) {cout << "Yes" << endl;}
  else {cout << "No" << endl;}
  
  
}

Measured memory_bytes: 640
//
// Created on 2020/03/22.
//

//#include <bits/stdc++.h>
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <ios>
#include <iomanip>
#include <numeric>

#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;
const long long LINF =1e18;
const int INF = 1e9;


int main() {
    string s;
    cin>>s;
    string temp = "&";
    int n = s.size();
    s = temp + s;

    int l = n;
    for (int k = 1; k <= n; ++k) {
        if(s[k] != s[l]){
            cout<<"No"<<endl;
            return 0;
        }
        l --;
    }

    int j = 1;
    for(int i = (n-1)/2 ; i >= 1;i--){
        if (s[i] != s[j]){
            cout<<"No"<<endl;
            return 0;
        }
        j++;
    }

    j = n;
    for(int i = (n+3)/2 ; i <= n;i++){
        if (s[i] != s[j]){
            cout<<"No"<<endl;
            return 0;
        }
        j--;
    }

    cout<<"Yes"<<endl;
}


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

int main(){

  while(1){
    int a, b;
    string op;
    cin>>a>>op>>b;
    if(op == "?") break;

    int ans;
    if(op == "+") ans = a + b;
    if(op == "-") ans = a - b;
    if(op == "*") ans = a * b;
    if(op == "/") ans = a / b;

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


Measured memory_bytes: 3172
#include <bits/stdc++.h>
 
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
 
typedef long long ll;
typedef vector<ll> vl;
typedef long double ld;
typedef vector<ld> vd;
typedef bool bl;
typedef vector<bl> vb;
 
const ll e5 = 1 << 20;
const ll mod = 998244353;
const ll e3 = 1 << 13;
const ll INF = 1ll << 60;
 
int main() {
  int n, x;
  cin >> n >> x;

  vl l(n, 0);
  rep(i, n) {
    cin >> l[i];
  }
  
  int cnt = 1;
  int sum = 0;
  rep(i, n) {
    sum += l[i];
    if (sum <= x) {
      cnt += 1;
    } else {
      break;
    }
  }

  cout << cnt << endl;

  return 0;
}

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

int main()
{
	int N, K;
	cin >> N >> K;
	int ans = 0;
	for( int i = 0; i < N; i++ ) {
		int x;
		cin >> x;
		ans += min( x * 2, (K - x) * 2 );
	}

	cout << ans << endl;
}


Measured memory_bytes: 3676
#include <algorithm>
#include <iostream>
#include <limits.h>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <vector>
#include <cstdio>
#include <iomanip>
#define ll long long
#define rep2(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define rep3(i,a,b) for(int i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define queint queue<int>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>//大きい順
#define pqg priority_queue<int,vec,greater<int>>//小さい順
#define pb push_back
#define vec vector<int>
#define vecvec vector<vector<int>>
#define vecll vector<ll>
#define vecvecll vector<vector<ll>>
#define bs binary_search
#define All(c) (c).begin(),(c).end()
#define mp make_pair
using namespace std;
int in(){int x;scanf("%d",&x);return x;}
//ll lin(){ll x;scanf("%d",&x);return x;}
int main(){
    int n=in();
    vector<double> v(n);
    rep(i,n){
        double d;
        cin>>d;
        v[i]=d;
    }
    double tmp=0;
    rep(i,n){
        tmp+=1/v[i];
    }
    cout<<1/tmp<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl; 
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
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; }

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    stack<char> st;
    int n;cin>>n;
    string s;cin>>s;
    rep(i,n){
        if(st.empty()||st.top()!=s[i]){
            st.push(s[i]);
        }
    }
    cout<<(st.size())<<endl;
    return 0;
}


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

int main(void){

    char s0[8], s1[101], s2[8];

    scanf("%s%s%s", s0, s1, s2);

    printf("A%cC\n", s1[0]);

    return 0;
}

Measured memory_bytes: 1708
import sys
n,k = map(int, sys.stdin.readline().rstrip("\n").split())
a = [int(s) for s in sys.stdin.readline().rstrip("\n").split()]
p = 1
for i in range(k,n):
    if a[i-k] < a[i]:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 94296
//abc109b
#include <stdio.h>
#include <string.h>

int main(void) {
	int n;
	int fdupl = 1;
	int fcont = 1;
	scanf("%d",&n);
	char str[n][11];
	for(int i=0;i<n;i++) {
		scanf(" %s",&str[i][0]);
	}
	for(int i=1;i<n;i++) {
		if (str[i][0]!=str[i-1][strlen(&str[i-1][0])-1]) {
			fcont = 0;
			break;
		}
		for(int j=0;j<i;j++) {
			if (!strcmp(&str[i][0],&str[j][0])) {
				fdupl = 0;
				break;
			}
		}
	}
	if (fdupl&&fcont) printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 128
#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);

  int n, k;
  cin >> n >> k;
  vector<int> l(n);
  rep(i, 0, n) cin >> l[i];
  sort(l.rbegin(), l.rend());

  int ans = 0;
  rep(i, 0, k) ans += l[i];
  cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		
		Scanner keyboard = new Scanner(System.in); 
		
		long A = keyboard.nextLong();
		long B = keyboard.nextLong();
		long C = keyboard.nextLong();
		long X = keyboard.nextLong();
		long Y = keyboard.nextLong();
		
		long Large = X >= Y ? X : Y;
		long small = X <= Y ? X : Y; 
		
		long sum = 0;
		long nokori = Large - small;
		
		if(A+B > 2*C) {
			sum = small*(2*C);
			
			if(Large == X) {
				if(A < 2*C) {
					sum += nokori*A;
				}else {
					sum += nokori*2*C;
				}
			}else{
				if(B < 2*C) {
					sum += nokori*B;
				}else {
					sum += nokori*2*C;
				}
			}
			
		}else {
			sum = A*X + B*Y;
		}
		
		System.out.print(sum);
		keyboard.close();
	}
}

Measured memory_bytes: 35512
#include <bits/stdc++.h>
#define INF INT_MAX
#define ll  long long
#define ull unsigned long long
#define rep(i,n) for(ll i=0; i<n; ++i)
#define FOR(i, s, e) for(ll i=s; i<e; ++i)
#define MOD 1000000007
using namespace std;
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; cin >> N;
  vector<int> B(N-1);
  vector<int> A(N, INT_MAX);
  rep(i, N-1) cin >> B[i];
  rep(i, N-1) {
    chmin(A[i], B[i]);
    A[i+1] = B[i];
  }
  ll ans = 0;
  rep(i, N) ans+=A[i];
  cout << ans << endl;
}

Measured memory_bytes: 256
N,M = map(int, input().split())
scorebook = [[] for _ in range(N)]
for i in range(M):
    p,S = input().split()
    p = int(p)-1
    scorebook[p].append(S)
maru = 0
batu = 0
for score in scorebook:
    try:
        batu += score.index("AC")
        maru += 1
    except:
        pass
print(maru, batu)

Measured memory_bytes: 25432
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define loop(i, a, n) for(int i = (a); i < (n); i++)
#ifdef _DEBUG
#define dd(x) cout << #x << " : " << x << endl
#else
#define dd(x)
#endif
using namespace std;
using ll = int64_t;

int main(){
    int n = 5;

    rep(i, n){
        int x; cin >> x;
        if(!x) {
            cout << i+1 << endl;
            break;
        }
    }

    return 0;
}

Measured memory_bytes: 3600
import copy
D, G = map(int, input().split())
pc = [list(map(int, input().split())) for i in range(D)]

if G // 100 <= D:
    print(1)
else:
    N = 0
    for i in range(D):
        pc[i].append((i+1)*100*pc[i][0]+pc[i][1])
        N += pc[i][0]
    dp = [[0, [pc[i][0] for i in range(D)]] for j in range(N)]

    for i in range(N):
        for j in reversed(range(D)):
            if i+1 >= pc[j][0]:
                for k in range(1, pc[j][0]+1):
                    if dp[i - k][1][j] == k:
                        if dp[i][0] < dp[i - k][0] + pc[j][1] + dp[i - k][1][j]*100*(j+1):
                            dp[i][0] = dp[i - k][0] + pc[j][1] + \
                                dp[i - k][1][j]*100*(j+1)
                            dp[i][1] = copy.deepcopy(dp[i-k][1])
                            dp[i][1][j] = 0

            if dp[i-1][1][j] > 0:
                if dp[i][0] < dp[i-1][0] + (j+1)*100:
                    dp[i][0] = dp[i-1][0] + (j+1)*100
                    dp[i][1] = copy.deepcopy(dp[i-1][1])
                    dp[i][1][j] -= 1

        if dp[i][0] >= G:
            print(i+1)
            break


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

int main() {
  std::string x(4, ' ');
  scanf("%s", &x[0], x.size());
  if (x[0] == x[1] && x[1] == x[2] || x[1] == x[2] && x[2] == x[3])
    printf("Yes");
  else
    printf("No");
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <deque>
#include <cctype>
#include <cstdio>
#include <math.h>
#include <set>
using namespace std;
int main(void){
    string s;
    cin >> s;
    vector<int> num(10);
    for(int i=0;i<s.length();i++){
        num[i] = stoi(s.substr(i,1));
    }
    long long ans=0;
    for(int i=0;i<1<<(s.length()-1);i++){
        long long nm = num[0];
        for(int j=0;j<s.length()-1;j++){
            if(i&1<<j){
                ans+=nm;
                nm = 0;
            }
            nm = nm*10+(num[j+1]);
        }
        ans+=nm;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
while True:
    n = int(input())
    if n == 0:
        exit()
    p = [None] * n
    for i in range(n):
        m, *p[i] = map(int, input().split())
    k, *l = map(int, input().split())
    ans = []
    for i in range(n):
        if all(x in p[i] for x in l):
            ans.append(i + 1)
    print(ans[0] if len(ans) == 1 else -1)



Measured memory_bytes: 5668
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")
#include <bits/stdc++.h>

#define int long long
#define double long double
#define endl '\n'
#define gcd __gcd
#define f first
#define s second
#define what_is(x) cerr << #x << " is " << x << endl;
#define all(x) x.begin(), x.end()
const int inf = __LONG_LONG_MAX__;

using namespace std;

void fast_io() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
}

signed main() {
  fast_io();

  int k, x;
  cin >> k >> x;

  if (500 * k >= x) {
    cout << "Yes\n";
  } else {
    cout << "No\n";
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <cstdio>

using namespace std;

struct edge {
	int to, cost;
	edge(int t, int c) : to(t), cost(c) { }
};
typedef pair<int, int> P;

int prim ( int n, vector<vector<edge> >* E )
{
	vector<bool> used(n, false);

	priority_queue<P, vector<P>, greater<P> > que;
	que.push(P(0, 0));

	int res = 0;
	while (!que.empty()) {
		P p = que.top(); que.pop();
		
		int v = p.second;
		if (used[v]) { continue; }
		used[v] = true;
		res += max(0, p.first / 100 - 1);
		
		vector<edge> es = (*E)[v];
		for (int i = 0; i < es.size(); ++i) {
			edge& e = es[i];
			if (!used[e.to]) { que.push(P(e.cost, e.to)); }
		}
	}
	return res;
}

int main ( void )
{
	int n;

	while (cin >> n, n) {
		int m;
		cin >> m;

		vector<vector<edge> > E(n);

		for (int i = 0; i < m; ++i) {
			int a, b, c;
			scanf("%d,%d,%d", &a, &b, &c);

			E[a].push_back(edge(b, c));
			E[b].push_back(edge(a, c));
		}

		cout << prim(n, &E) << endl;
	}
	return 0;
}

Measured memory_bytes: 1452
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInts = map ( fst . fromJust . B.readInteger ) . B.words <$> B.getLine
readNInts = readInt >>= flip replicateM readInt

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = do
	[ k, a, b ] <- readInts
	if b - a < 2 || k < a
		then print $ 1 + k
		else let k' = k - ( a - 1 ) in print $ a + k' `div` 2 * ( b - a ) + k' `mod` 2

Measured memory_bytes: 380
#include <bits/stdc++.h>
using namespace std;
typedef long long i64;
const int N = 4e2+5, P = 998244353;
int n, SA, SB, A[N], B[N], f[N][N][N], ans; i64 fac[N], ifac[N]; void fix(int &x) { x<P?0:x-=P; }
i64 qp(i64 a, int b) { i64 c = 1; for( ; b; b >>= 1, a = a*a%P) if(b&1) c = c*a%P; return c; }
int main()
{
    scanf("%d", &n); for(int i = 1; i <= n; ++i) scanf("%d", A+i), scanf("%d", B+i), SA += A[i], SB += B[i];
    f[0][0][0] = P-1, fac[0] = 1; for(int i = 1, t = max(SA, SB); i <= t; ++i) fac[i] = fac[i-1]*i%P;
    ifac[max(SA, SB)] = qp(fac[max(SA, SB)], P-2); for(int i = max(SA, SB); ~i; --i) ifac[i-1] = ifac[i]*i%P;
    for(int i = 1, SA = 0, SB = 0; i <= n; ++i)
    {
        for(int j = 0; j <= SA; ++j) for(int k = 0; k <= SB; ++k) 
            f[i][j][k] = f[i-1][j][k];
        SA += A[i], SB += B[i];
        for(int j = A[i]; j <= SA; ++j) for(int k = 0; k <= SB; ++k)
            for(int l = 0; l <= k&&l < B[i]; ++l)
                fix(f[i][j][k] += P-f[i-1][j-A[i]][k-l]*qp(A[i], l)%P*ifac[l]%P);
    } 
    for(int j = 1; j <= SA; ++j) for(int k = 0; k <= SB; ++k)
        fix(ans += f[n][j][k]*qp(qp(j, P-2), k+1)%P*fac[k]%P);
    printf("%lld\n", (i64)ans*SA%P);
    return 0;
}

Measured memory_bytes: 132360
#include<bits/stdc++.h>
using namespace std;
int a[200005];
int b[200005];

int a1[200005];
int b1[200005];

int n;
bool check(int k)
{
	int val = (1 << k)*2;
	for(int i = 0 ; i < n ; i++)
	{
		a1[i] = a[i] % val;
		b1[i] = b[i] % val;
	}
	sort(b1,b1+n);
	long long sum = 0;
	int T = (1 << k);
	for(int i = 0 ; i < n; i++)
	{
		long long aa = lower_bound(b1, b1 + n, 2*T - a1[i]) -  lower_bound(b1, b1 + n, T - a1[i]) ;
		long long bb = lower_bound(b1, b1 + n, 4*T - a1[i]) -  lower_bound(b1, b1 + n, 3*T - a1[i]) ;
		sum += aa+bb;
	}
	return bool(sum & 1);

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

	for(int i = 0 ; i < n ; i++)
		scanf("%d",&b[i]);
	
	long long ans = 0;
	
	for(int i = 0; i < 29; i++)
	{
		if(check(i))
			ans |= (1 << i);
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 3328
using System;
using System.Linq;

namespace AtCoder.ABC043
{
    class ProblemC
    {
        static void Main()
        {
            var text = ReadLine().ToArray();

            //for (var i = 2; i <= text.Length; i++)
            //{
            //    for (var j = 0; j < text.Length - i + 1; j++)
            //    {
            //        if (text.Skip(j).Take(i).GroupBy(v => v).Any(v => v.Count() * 2 > i))
            //        {
            //            Console.WriteLine($"{j + 1} {j + i}");
            //            return;
            //        }
            //    }
            //}

            for (var i = 0; i < text.Length - 1; i++)
            {
                if (text[i] == text[i + 1])
                {
                    Console.WriteLine($"{i + 1} {i + 2}");
                    return;
                }
            }
            for (var i = 0; i < text.Length - 2; i++)
            {
                if (text[i] == text[i + 2])
                {
                    Console.WriteLine($"{i + 1} {i + 3}");
                    return;
                }
            }
            Console.WriteLine($"{-1} {-1}");
        }

        public static string ReadLine() => Console.ReadLine();

        public static int ReadInt() => int.Parse(ReadLine());

        public static int[] ReadIntArray() => ReadLine().Split(' ').Select(v => int.Parse(v)).ToArray();
    }
}


Measured memory_bytes: 13268
from heapq import heappush, heappop
import math
import sys
input = sys.stdin.readline

n, m = map(int, input().split())
A =list(map(int, input().split()))
Hq = []
for a in A:
  heappush(Hq, -a)
 
for _ in range(m):
  max = -heappop(Hq)
  heappush(Hq, -math.floor(max/2))
print(-sum(Hq))  

Measured memory_bytes: 14380
def main():
    from heapq import heappush,heappop
    (n,m,s),*t=[map(int,r.split())for r in open(0)]
    e=[[]for _ in range(8**6)]
    for u,v,a,b in t[:m]:
        for i in range(2501-a):
            e[(i+a)*51+u]+=(b,i*51+v),
            e[(i+a)*51+v]+=(b,i*51+u),
    for i,(c,d)in enumerate(t[m:],1):
        for j in range(2501-c):
            e[j*51+i]+=(d,(j+c)*51+i),
    x=[10**18]*8**6
    f=[1]*8**6
    q=[(0,min(2500,s)*51+1)]
    while q:
        c,v=heappop(q)
        if f[v]<1:continue
        x[v],f[v]=c,0
        for p,w in e[v]:
            if f[w]:heappush(q,(c+p,w))
    for i in range(2,n+1):print(min(x[i::51]))
main()

Measured memory_bytes: 117800
N = int(input())
A = list(map(int, input().split()))
A.sort()

for i in range(N-1):
    while True:
        A[i+1] %= A[i]
        A[i+1], A[i] = A[i], A[i+1]
        if A[i] == 1:
            print(1)
            exit(0)
        elif A[i] == 0:
            break

print(A[-1])


Measured memory_bytes: 14252
<?php
$ary = array();
while($line = trim(fgets(STDIN))){
    $tmp = explode(" ", $line);
    if($tmp[0] == 0 && $tmp[1] == 0) {
        for($j = 0; $j < sizeof($ary);$j++){
            print($ary[$j]);
        }
        break;
    }
    $bread = '#';
    $meet = '#';
    for($i = 1;$i < $tmp[1] - 1;$i++){
        $bread .= "#";
        $meet .= ".";
    }
    $bread .= "#\n";
    $meet .= "#\n";
    
    array_push($ary, $bread);
    for($i = 1;$i < $tmp[0] - 1;$i++){
        array_push($ary, $meet);
    }
    array_push($ary, $bread . "\n");
}



Measured memory_bytes: 9304
#include<bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SZ(x) ((int)(x).size())
#define debug(x) cerr << #x << ": " << x << '\n'
#define INF 999999999
typedef long long int Int;
using ll = long long;
using VI = vector<int>;

int main(){
  int x,y,z;
  cin >> x >> y >> z;
  int count = 0;
  x-=z;
  while(x>0){
    x-=y;
    x-=z;
    count++;
  }
  cout << (x<0?count-1:count) << endl;
}


Measured memory_bytes: 256
N = gets.chomp.to_i
AS = gets.chomp.split.map(&:to_i)

rains = [0] * N
AS.size.times do |i|
  rains[0] += AS[i] * ((-1)**(i % 2))
end

1.upto(N - 1) do |i|
  rains[i] = (AS[i - 1] - rains[i - 1] / 2) * 2
end

puts rains.join(" ")


Measured memory_bytes: 15236