akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>

using namespace std;

char change (char c)
{
    if(c=='0')
        return '1';

    return '0';
}

int main()
{
    string s;
    cin>>s;

    int i;
    char c = '0';
    int cnt1 = 0;
    for(i=0;i!=s.length();i++)
    {
        if(s[i]!=c)
            cnt1++;

        c = change(c);  // define
    }

    int cnt2 = 0;
    c = '1';
    for(i=0;i!=s.length();i++)
    {
        if(s[i]!=c)
            cnt2++;

        c = change(c);
    }

    cout<<min(cnt1,cnt2);

    return 0;
}


Measured memory_bytes: 512
# 2019/07/08
# かんにんぐ

n=int(input())
A=list(map(int,input().split()))

res=[0]*n
res[0]=sum(A)-2*sum(A[1:n:2])

for i in range(n-1):
    res[i+1]=2*A[i]-res[i]

print(*res)

Measured memory_bytes: 14032
#include<cstdio>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
const int dxy[]={0,-1,0,1,0};
bool fld[6000][6000];
int compress(int *x1,int *x2,int w,int n){
    vector<int>xs;
    for(int i=0;i<n;i++){
        for(int d=-1;d<=1;d++){
            if(x1[i]+d>=0&&x1[i]+d<w)xs.push_back(x1[i]+d);
            if(x2[i]+d>=0&&x2[i]+d<w)xs.push_back(x2[i]+d);
        }
    }
    sort(xs.begin(),xs.end());
    xs.erase(unique(xs.begin(),xs.end()),xs.end());
    for(int i=0;i<n;i++){
        x1[i]=lower_bound(xs.begin(),xs.end(),x1[i])-xs.begin();
        x2[i]=lower_bound(xs.begin(),xs.end(),x2[i])-xs.begin();
    }
    return xs.size();
}
int main(){
    int x1[1000],x2[1000],y1[1000],y2[1000];
    int h,w,n;
    while(scanf("%d%d",&w,&h),h||w){
        scanf("%d",&n);
        for(int i=0;i<n;i++)scanf("%d%d%d%d",x1+i,y1+i,x2+i,y2+i);
        w=compress(x1,x2,w,n);
        h=compress(y1,y2,h,n);
        fill(*fld,*fld+6000*6000,false);
        for(int i=0;i<n;i++){
            for(int y=y1[i];y<y2[i];y++){
                for(int x=x1[i];x<x2[i];x++){
                    fld[y][x]=true;
                }
            }
        }
        int ans=0;
        for(int y=0;y<h;y++){
            for(int x=0;x<w;x++){
                if(fld[y][x])continue;
                ans++;
                queue<pair<int,int> >Q;
                Q.push(pair<int,int>(y,x));
                fld[y][x]=true;
                while(Q.size()){
                    int sy=Q.front().first,sx=Q.front().second;
                    Q.pop();
                    for(int i=0;i<4;i++){
                        int ty=sy+dxy[i+1],tx=sx+dxy[i];
                        if(ty<0||ty>=h||tx<0||tx>=w)continue;
                        if(fld[ty][tx])continue;
                        Q.push(pair<int,int>(ty,tx));
                        fld[ty][tx]=true;
                    }

                }
            }
        }
        printf("%d\n",ans);
    }
    return 0;
}

Measured memory_bytes: 36240
#include<iostream>
#include<cstdio>
using namespace std;
const int N=200005;
int n;
int d[N];
long long c[N];
int main()
{
	scanf("%d",&n);
	long long sumc=0,sum=0;
	for(int i=1;i<=n;i++)
	{
		scanf("%d%lld",&d[i],&c[i]);
		sumc+=c[i],sum+=d[i]*c[i];
	}
	printf("%lld",(sum-1)/9+sumc-1);
	return 0;
}

Measured memory_bytes: 6024
#include<bits/stdc++.h>
using namespace std;
#define SORT(x) sort(x.begin(),x.end())
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
int main(){
    int n,x;
    cin>>n>>x;
    int l[n];
    for(int i=0;i<n;i++){
        cin>>l[i];
    }
    int pos=0,ans=0;
    for(int i=0;i<n;i++){
        pos+=l[i];
        if(pos<=x)  ans++;
    }
    ans++;
    cout<<ans<<endl;
    return 0;
}


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

using namespace std;

#define int long long
#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define INF 1e9
#define LINF 1e18

typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> Pi;
typedef pair<P, P> PP;

const int MOD = 1e9 + 7;
const int dy[]={0, 0, 1, -1};
const int dx[]={1, -1, 0, 0};

template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int a[3];
    rep(i, 3) cin >> a[i];
    sort(a, a + 3);
    if(a[0] % 2 == a[1] % 2) cout << (a[2] - a[1] + a[2] - a[0]) / 2 << endl;
    else cout << (a[2] - a[1] + a[2] - a[0]) / 2 + 2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

int main(){
  ll n;
  cin>>n;
  vector<ll> res;
  for(ll i=1;i*i<=n;i++){
    if(n%i==0){
      res.push_back(i);
      if(i!=n/i){
        res.push_back(n/i);
      }
    }
  }
  int ans=0;
  rep(i,1,res.size()){
    ll cur=n;
    while(cur%res[i]==0){
      cur/=res[i];
    }
    if(cur%res[i]==1){
      ans++;
    }
  }
  vector<ll> a;
  for(ll i=1;i*i<=n-1;i++){
    if((n-1)%i==0){
      a.push_back(i);
      if(i!=(n-1)/i){
        a.push_back((n-1)/i);
      }
    }
  }
  cout<<ans+a.size()-1<<endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define INF INT_MAX
#define MOD 1000000007
#define fcout cout << fixed << setprecision(15)
#define int long long
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
#define sec second
#define fir first
typedef long long ll;
typedef pair<int, int> P;
typedef priority_queue<int> pque;
typedef vector<int> Vec;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a/gcd(a,b)*b;};
int mod(int a,int b){return (a+b-1)/b;};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;};
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;};



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

	int n;
	double m;
	cin >> n >> m;
	int a[n];
	rep(i, n) cin >> a[i];
	double sum = 0;
	rep(i, n) sum += a[i];
	int cnt = 0;
	rep(i, n) {
		if(a[i] >= sum / (4 * m)) cnt++;
	}
	yorn(cnt >= m);
	return 0;
}

Measured memory_bytes: 256
N=int(input())
S=input()
r=0
g=0
b=0
for i  in range(N):
	if S[i]=="R":
		r+=1
	elif S[i]=="G":
		g+=1
	else:
		b+=1
w=0
for i in range(N-2):
	for j in range(1,int((N-i+1)/2)):
		if S[i]!=S[i+j] and S[i+j]!=S[i+j+j] and S[i]!=S[i+j+j]:
			w+=1
print((r*g*b)-w)

Measured memory_bytes: 73664
/* --- author: dxm --- */
#include<bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;

#define INF 1e9
#define Inf 1e18
#define rep(i,n) for(int (i)=0;(i)<n;i++)
#define REP(i,n) for(int (i)=1;(i)<=n;i++)
#define mp make_pair
#define pb push_back
#define fst first
#define snd second
typedef long long ll;
typedef double db;
typedef long double ldb;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;

void qread(int &x){
	int neg=1;x=0;
	char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')neg=-1;c=getchar();}
	while(c>='0'&&c<='9')x=10*x+c-'0',c=getchar();
	x*=neg;
}

const int maxn=200005;
int n,d; 
int a[maxn];
ll ans;

class node{
public:
	pair<ll,int>val,sx,sy,tx,ty;
}t[maxn*4];
namespace Segtree{
	#define ls cur<<1
	#define rs cur<<1|1
	void pushup(int cur){
		t[cur].sx=min(t[ls].sx,t[rs].sx);
		t[cur].sy=min(t[ls].sy,t[rs].sy);
		t[cur].tx=min(t[ls].tx,t[rs].tx);
		t[cur].ty=min(t[ls].ty,t[rs].ty);
		t[cur].val=min(t[ls].val,t[rs].val);
		if(t[ls].sy.fst+t[rs].tx.fst<t[cur].val.fst)
			t[cur].val=mp(t[ls].sy.fst+t[rs].tx.fst,t[rs].tx.snd);
		if(t[rs].sx.fst+t[ls].ty.fst<t[cur].val.fst)
			t[cur].val=mp(t[rs].sx.fst+t[ls].ty.fst,t[ls].ty.snd);
	}
	void build(int cur,int l,int r){
		if(l==r){
			t[cur].val=mp(Inf,Inf);
			if(l==1){
				t[cur].sx=mp(1LL*l*d+a[l],l);
				t[cur].sy=mp(-1LL*l*d+a[l],l);
				t[cur].tx=mp(Inf,Inf);
				t[cur].ty=mp(Inf,Inf);
			}
			else{
				t[cur].sx=mp(Inf,Inf);
				t[cur].sy=mp(Inf,Inf);
				t[cur].tx=mp(1LL*l*d+a[l],l);
				t[cur].ty=mp(-1LL*l*d+a[l],l);
			}
			return;
		}
		int mid=l+r>>1;
		build(ls,l,mid);build(rs,mid+1,r);
		pushup(cur);
	}
	void update(int cur,int l,int r,int k){
		if(l==r){
			swap(t[cur].sx,t[cur].tx);
			swap(t[cur].sy,t[cur].ty);
			return;
		}
		int mid=l+r>>1;
		if(k<=mid)update(ls,l,mid,k);
		else update(rs,mid+1,r,k);
		pushup(cur); 
	}
}

int main(){
#ifdef FILE
	freopen("FILE.in","r",stdin);
	freopen("FILE.out","w",stdout);
#endif
	scanf("%d%d",&n,&d);
	REP(i,n)scanf("%d",&a[i]);
	Segtree::build(1,1,n);
	REP(i,n-1){
		node cur=t[1];
		ans+=cur.val.fst;
		Segtree::update(1,1,n,cur.val.snd);
	}
	printf("%lld\n",ans);
#ifdef TIME
	printf("Running Time = %d ms\n",int(clock()*1000.0/CLOCKS_PER_SEC));
#endif
	return 0;
}

/*
Input:
-----------------
Output:
*/


Measured memory_bytes: 44160
#include<bits/stdc++.h>
/*
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <vector>
*/
#define rep(i, m, n) for(int i = m;i < n;i++)
#define repr(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define INF 999999999
using namespace std;

int main(){
    long long n; cin >> n;
    vector<int> a(n);
    rep(i, 0, n) cin >> a[i];
    sort(a.rbegin(), a.rend());
    long long x = 0;
    long long y = 0;

    rep(i, 0, n-1){
        if(a[i] == a[i+1]){
            if(x == 0){
                 x = a[i];
                 i++;
            }
            else{
                y = a[i];
                break;
            }
        }
    }
    cout << x * y << endl;

    return 0;
}


Measured memory_bytes: 640
N = int(input())
s = ["".join(sorted(input())) for i in range(N)]

#print(s)

#出現文字列
sdict = {}

for i in range(N):

    s_i = str(s[i])

    if s_i in sdict:
        #組み合わせが増えるので
        sdict[s_i]+= 1
        continue

    else:
        sdict[s_i] = 1

ans = 0
for i in sdict.values():
    ans += i*(i-1)//2
print(ans)


Measured memory_bytes: 19400
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

use std::cmp::Ordering;

struct Data {
    name: String,
    score: u32,
    id: u32
}

fn main() {
    let n = read();
    let mut v: Vec<Data> = (0..n)
        .map(|i| {
            Data {
               name: read::<String>(),
               score: read::<u32>(),
               id: i + 1
           }
       }).collect();
    v.sort_by(|a, b| {
        let result = a.name.cmp(&b.name);
        if result != Ordering::Equal {
            return result;
        }
        else if a.score > b.score {
            return Ordering::Less;
        }
        Ordering::Greater
    });
    for a in v {
        println!("{}", a.id);
    }
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf  1000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

vector<ll> p;
set<ll> st,st2;
void init(){
    int n = 100000;
    vector<bool>z(n+1,true);
    z[0] = z[1] = false;
    for(ll i=2;i<=n;i++){
        if(z[i]){
            if(i<=2200){
                p.push_back(i);
            }else{
                st.insert(i);
                st2.insert(i*i);
            }
            for(ll j=2*i;j<=n;j+=i){
                z[j] = false;
            }
        }
    }
}

int main(){
    int n;
    cin >> n;
    vector<ll> s(n);
    map<ll,ll> mp,mp2;  
    ll ans=0;
    init();
    rep(i,n)cin >> s[i];
    for(int i=0;i<n;i++){
        ll tmp = 1;
        ll tmp2 = 1;
        for(ll x:p){
            while(1){
                if(s[i]!=0&&s[i]%(x*x*x)==0){
                    s[i]/=(x*x*x);
                }else{
                    if(s[i]==0){
                        break;
                    }
                    if(s[i]%(x*x)==0){
                        tmp *= x*x;
                        s[i]/= x*x;
                        tmp2 *= x;
                    }else if(s[i]%x==0){
                        tmp *= x;
                        s[i]/= x;
                        tmp2 *= x*x;
                    }
                    break;
                }
            }
        }
        //cout << s[i]*tmp << " " << tmp2 << endl;
        if(s[i]*tmp==1){
            mp[0]++;
        }else{
            if(s[i]==1){
                s[i]*= tmp;
                mp[s[i]]++;
                mp2[s[i]] = tmp2;
            }else if(st.count(s[i])==1){
                tmp2 *= s[i]*s[i];
                s[i] *= tmp;
                mp[s[i]]++;
                mp2[s[i]] = tmp2;
            }else if(st2.count(s[i])==1){
                tmp2 *= s[i]*s[i];
                s[i] *= tmp;
                mp[s[i]]++;
                mp2[s[i]] = tmp2;
            }else{
                ans++;
            }
        }
    }
    if(mp.find(0)!=mp.end()){
        ans++;
        mp.erase(0);
    }
    while(mp.size()!=0){
        auto itr = mp.begin();
        ll x = mp[mp2[itr->first]];
        if(x>itr->second){
            ans += x; 
        }else{
            ans += itr->second;
        }
        mp.erase(itr->first);
        mp.erase(mp2[itr->first]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 12288
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
		string[] input = Console.ReadLine().Split(' ');
		int h = int.Parse(input[0]);
		int w = int.Parse(input[1]);
    string[] strings = new string[h];
    for(int i = 0; i < h; i++)
    {
      strings[i] = Console.ReadLine();
    }
    long answer = 0;
    long[,] lumpsW = new long[h,w];
    long[,] lumpsH = new long[h,w];

    for(int i = 0; i < h; i++)
    {
      for(int j = 0; j < w; j++)
      {
        if(j == 0)
        {
          if(strings[i][j] == '.') lumpsW[i,j] = 1;
        }else
        {
          if(strings[i][j] == '.') lumpsW[i,j] = lumpsW[i,j-1]+1;
        }
      }
    }

    for(int i = 0; i < h; i++)
    {
      for(int j = w-2; j >= 0; j--)
      {
        if(strings[i][j+1] != '#') lumpsW[i,j] = lumpsW[i,j+1];
      }
    }

    for(int i = 0; i < w; i++)
    {
      for(int j = 0; j < h; j++)
      {
        if(j == 0)
        {
          if(strings[j][i] == '.') lumpsH[j,i] = 1;
        }else
        {
          if(strings[j][i] == '.') lumpsH[j,i] = lumpsH[j-1,i]+1;
        }
      }
    }

    for(int i = 0; i < w; i++)
    {
      for(int j = h-2; j >= 0; j--)
      {
        if(strings[j+1][i] != '#') lumpsH[j,i] = lumpsH[j+1,i];
      }
    }

    for(int i = 0; i < h; i++)
    {
      for(int j = 0; j < w; j++)
      {
        if(strings[i][j] == '.')
        {
          //Console.WriteLine(i+" "+j+" "+lumpsH[i,j]+" "+lumpsW[i,j]);
          answer = Math.Max(answer,lumpsH[i,j]+lumpsW[i,j]-1);
        }
      }
    }

		Console.WriteLine(answer);
	}
}

Measured memory_bytes: 90184
N, K = map(int, input().split())
p = [int(i) for i in input().split()]

for i in range(N) :
  p[i] = p[i] * (p[i] + 1) // 2 / p[i]
  
p = [0] + p

for i in range(1, N + 1) :
  p[i] += p[i - 1]

ret = 0
for i in range(K, N + 1) :
  ret = max(ret, p[i] - p[i-K])
  
print(ret)

Measured memory_bytes: 72072
n = input()

a = ['+','-']
b = ''
for i in a:
    for j in a:
        for k in a:
            if eval(n[0]+i+n[1]+j+n[2]+k+n[3]) == 7:
                b =n[0]+i+n[1]+j+n[2]+k+n[3]+'=7'
                break
print(b)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")
// #pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;

bool ok[100005];

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

    int n; cin >> n;
    int ans = n + 1;

    map<int, int> v1, v2;

    for (int i = 1; i <= n; i++) {
        int t; cin >> t;
        if (i % 2 == 1) v1[t]++;
        else v2[t]++;
    }

    vector<pair<int, int>> p1, p2;
    for (auto p : v1) p1.push_back({p.second, p.first});
    for (auto p : v2) p2.push_back({p.second, p.first});
    sort(p1.begin(), p1.end()); reverse(p1.begin(), p1.end());
    sort(p2.begin(), p2.end()); reverse(p2.begin(), p2.end());

    if (p1.size() == 1 && p2.size() == 1 && p1.front().second == p2.front().second) {
        cout << n / 2 << endl;
        return 0;
    }

    for (int i = 0; i < min((int)p1.size(), 3); i++)
        for (int j = 0; j < min((int)p2.size(), 3); j++) {
            if (p1[i].second != p2[j].second) {
                ans = min(ans, n - p1[i].first - p2[j].first);
            }
        }
    cout << ans << endl;
}

Measured memory_bytes: 6140
#include <stdio.h>
int main(void)
{
int S;
int h;
int m;
int s;

scanf("%d",&S);

h = S / 3600;
m = ( S - 3600 * h ) / 60;
s = S % 60;

printf("%d:%d:%d\n",h,m,s);

return 0;

}

Measured memory_bytes: 592
#include<bits/stdc++.h>
using namespace std;
#define int long
main(){
  int l,r,m=2018;
  cin>>l>>r;
  if(r-l>2017){cout<<0;return 0;}
  for(int i=l;i<r;++i)for(int j=l+1;j<=r;++j)m=min(m,(i*j)%2019);
  cout<<m;
}

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

int main(){
    string s;
    cin>>s;
    
    bool flag=true;
    int cnt=0;
    for(int i=0;i<s.length();i++){
        if(i==0){
            if(s[i]!='A') flag=false;
        }else if(i>=2&&i<=s.length()-2){
            if(s[i]=='C') cnt++;
        }else if(s[i]>='A'&&s[i]<='Z') flag=false;
    }
    if(cnt!=1) flag=false;
    if(flag) cout<<"AC"<<endl;
    else cout<<"WA"<<endl;
}


Measured memory_bytes: 3628
#include <iostream>


int main(void){

	int space, y, z;
	std::cin >> space >> y >> z;

	int cnt = 0;
	space -= (2 * z);
	while(space >= y){
		cnt++;
		space -= y + z;
	}

	std::cout << cnt << std::endl;

	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
int main(){
char O[52]={},E[52]={};
char K[104]={};
scanf("%s %s",O,E);
for(int i=0;i<=49;i++){
K[2*i]=O[i];
K[2*i+1]=E[i];
}
printf("%s",K);
return 0;
}

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

int main() {
	int n, a; cin >> n >> a;
	int L = a;
	int R = a + n - 1;
	
	int eat;
	if (R <= 0) eat = R;
	else if (L >= 0) eat = L;
	else eat = 0;

	int ans = (R + L)*(R - L + 1) / 2 - eat;
	cout << ans << endl;
	return 0;
}


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

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// #pragma GCC optimize("Ofast")

using namespace std;
using ll = long long;

// MACRO
// for loop
#define REP(i, n) for (ll i = 0; i < ll(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= ll(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= ll(b); i--)

// for vector
#define ALL(x) x.begin(), x.end()
#define SIZE(x) ll(x.size())
#define SORT(x) sort(ALL(x))
#define RSORT(x) sort(ALL(x), greater<int>())
#define RSORTS(x) sort(ALL(x), greater<string>())
#define FIND(x, n) find(ALL(x), n)
#define VFOR(e, x) for (auto &e : x)

// Constant
const ll INF = 1000000000000; // 10^12:  ∞
const int MOD = 1000000007;   // 10^9+7: Congruence ceremony MOD
const int MAXR = 100000;      // 10^5:   Array Max Range
const char EL = '\n';         // newline

// alias
#define EB emplace_back // push as last element
#define PP pop_back     // pop last element
#define MP make_pair    // pair constractor
#define F first         // first element of pair
#define S second        // second element of pair

// change max/min
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;
}

// optimize in/out
#define OPTIMIZE_CIN_COUT() \
  cin.tie(0);               \
  ios::sync_with_stdio(false);

template <typename... Args>
void input(Args... args)
{
  for (int &e : {args...})
  {
    cin >> e;
  }
}
#define INPUT1(a) \
  int a = 0;      \
  cin >> a;
#define INPUT2(a, b) \
  int a = 0;         \
  int b = 0;         \
  cin >> a >> b;
#define INPUT3(a, b, c) \
  double a = 0;         \
  int b = 0;            \
  int c = 0;            \
  cin >> a >> b >> c;
#define INPUTS(s) \
  string s = "";  \
  cin >> s;

#define INPUTA(n, a) \
  int n = 0;         \
  cin >> n;          \
  vector<int> a(n);  \
  REP(i, n)          \
  {                  \
    cin >> a[i];     \
  }
#define INPUTB(x, y, b)                     \
  int x = 0, y = 0;                         \
  cin >> x >> y;                            \
  vector<vector<int>> b(y, vector<int>(x)); \
  REP(i, y)                                 \
  {                                         \
    REP(j, x)                               \
    {                                       \
      cin >> b[i][j];                       \
    }                                       \
  }

int main()
{
  OPTIMIZE_CIN_COUT();

  // INPUT1(N);
  // INPUT2(A, B);
  INPUT3(N, X, T);
  // INPUTS(S);
  // INPUTA(N, A);
  // INPUTB(X, Y, B);

  long num = ceil(N / X) * T;
  cout << num;
}


Measured memory_bytes: 3724
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,m;
	cin>>a>>b>>m;
	int aa[a],bb[b];
	int ans=INT_MAX;
	for(int i=0;i<a;i++)
	{
		cin>>aa[i];
		ans=min(ans,aa[i]);
	}
	int ans1=INT_MAX;
	for(int i=0;i<b;i++)
	{
		cin>>bb[i];
		ans1=min(ans1,bb[i]);
	}
	ans+=ans1;
	for(int i=0;i<m;i++)
	{
		int c,d,f;
		cin>>d>>f>>c;
		ans=min(ans,(aa[d-1]+bb[f-1]-c));

	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1024
//树的直径板子 
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int a,b,n,l,dis[200100],S;
vector <int> G[200100];
void dfs(int u,int f)
{
    dis[u]=dis[f]+1;
    for(int i=0;i<G[u].size();i++)
	{
        if(G[u][i]!=f) dfs(G[u][i],u);
    }
}

int main(){
	scanf("%d",&n);
	for(int i = 1;i < n;i ++){
		cin >> a >> b;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	dfs(1,0);
    for(int i=1;i<=n;i++) if(dis[i]>dis[S]) S=i;  
    dfs(S,0);
    for(int i=1;i<=n;i++) l=max(l,dis[i]-1);
    
	if(l % 3 == 1) printf("Second\n"); 
	else	printf("First\n");
    return 0;
}


Measured memory_bytes: 21376
N, M, Q = map(int, input().split())
ABCD = []
for i in range(Q):
    A, B, C, D = map(int, input().split())
    ABCD.append((A, B, C, D))

def solve(N, M, Q, ABCD):
    As = []
    dfs(As, [1], N)
    answer = 0
    for A in As:
        point = 0
        for a, b, c, d in ABCD:
            point += d if A[b] - A[a] == c else 0
        answer = max(answer, point)
    print(answer)


def dfs(As, A, N):
    if len(A) == N+1:
        As.append(A)
        return
    a = A[-1]
    for b in range(a, M+1):
        A_ = A[:]
        A_.append(b)
        dfs(As, A_, N)
    
solve(N, M, Q, ABCD)





Measured memory_bytes: 28784
#include <iostream>
#include <algorithm>
#include <math.h>
using namespace std;

int main() {
	int a[3];
	cin >> a[0] >> a[1] >> a[2];
	sort(a,a+3);
	int b = a[2] - a[0];
	int c = a[2] - a[1];
	int ans = 0;
	if ((b-c)%2==0) {ans = c+(b-c)/2;}
	else {ans = c+(b-c)/2+2;}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  string w;
  int A[26]={0};
  int a=0;
  cin>>w;
  for(int i=0;i<w.size();i++) A[w[i]-'a']++;
  for(int i=0;i<26;i++) a+=A[i]%2;
  cout<<(a?"No":"Yes")<<endl;
}

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

using namespace std;

int main(){
    ios:: sync_with_stdio(0);

    int n, a[100005], b[100005], c[100005], dp[100005][3];
    cin >> n;

    for(int i = 0; i < n; ++i){
        cin >> a[i] >> b[i] >> c[i];
    }

    dp[0][0] = a[0];
    dp[0][1] = b[0];
    dp[0][2] = c[0];

    for(int i = 1; i < n; ++i){
        dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + a[i];
        dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + b[i];
        dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + c[i];
    }

    cout << max(dp[n - 1][0], max(dp[n - 1][1], dp[n-1][2]) );
}


Measured memory_bytes: 2560
n,m=map(int,input().split())
l=[list(map(int,input().split())) for i in range(m)]

num_l=[1 for i in range(n)]
bit_l=[1]+[0 for i in range(n-1)]

for x,y in l:
  x-=1
  y-=1
  if bit_l[x]==1 and num_l[x]==1:
    bit_l[x]=0
    bit_l[y]=1
    num_l[x]-=1
    num_l[y]+=1
  elif bit_l[x]==1 and num_l[x]>=2:
    bit_l[y]=1
    num_l[x]-=1
    num_l[y]+=1
  else:
    num_l[x]-=1
    num_l[y]+=1

print(bit_l.count(1))

Measured memory_bytes: 29768
#include <stdio.h>

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

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

	d = a / b;
	r = a % b;
	f = 1.0 * a / b;

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

	return 0;
}

Measured memory_bytes: 636
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		String s = sc.next();
		String t = sc.next();
		int a = sc.nextInt();
		int b = sc.nextInt();
		String u = sc.next();

		if (s.equals(u)) {
			System.out.println((a - 1) + " " + b);
		} else if (t.contains(u)) {
			System.out.println(a + " " + (b - 1));
		}

		sc.close();
	}
}


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

using int64 = long long;

int main() {
	int n, k;
	cin >> n >> k;
	
	vector<int64> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	
	vector<int64> cum_best_score(n + 1, 0), cum_score(n + 1, 0);
	for (int i = 0; i < n; i++) {
		cum_best_score[i + 1] = max((int64)0, a[i]);
		cum_score[i + 1] += a[i];
		
		cum_best_score[i + 1] += cum_best_score[i];
		cum_score[i + 1] += cum_score[i];
	}
	
	int64 ans = -(1LL << 50);
	for (int i = 0; i + k <= n; i++) {
		int64 score = cum_best_score[i] + cum_best_score[n] - cum_best_score[i + k];
		score += max((int64)0, cum_score[i + k] - cum_score[i]);
		
		ans = max(ans, score);
	}
	cout << ans << endl;
	
	
	return 0;
}

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

int mod = 1000000007;
int64_t large = 9223372036854775807;

int main()
{
    int N;
    cin >> N;
    int count = 0;
    for (int i = 0; i < N; i++)
    {
        int tmp;
        cin >> tmp;
        if (tmp != i + 1)
            count++;
    }
    cout << (count == 0 || count == 2 ? "YES" : "NO");
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>

using namespace std;

int main() {

	int hito[1000];
	int m,n;
	int a;
	int counter = 0;
	int counter2 = 0;
	int k = 0;

	while (1) {
		cin >> n >> m;

		if (n == 0 && m == 0) {
			break;
		}

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

		while (1) {
			if (hito[k] == 1) {
				counter++;
			}

			if (counter == m) {
				hito[k] = 0;
				counter = 0;
				counter2++;
			}

			if (counter2 == n){
				cout << k + 1 << endl;
				counter =0;
				counter2 = 0;
				k = 0;
				break;
			}

			k++;

			if (k >= n) {
				k = 0;
			}
		}
	}

	return 0;
}

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

public class Main {

    public void solve() {
        String s = in.nextToken(), t = "CODEFESTIVAL2016";
        int a = 0;
        for (int i = 0; i < 16; i++) {
            if (s.charAt(i) != t.charAt(i)) {
                a++;
            }
        }
        out.println(a);
    }

    public void run() {
        in = new FastScanner();
        out = new PrintWriter(System.out);
        solve();
        out.close();
    }

    FastScanner in;
    PrintWriter out;

    class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(String fileName) {
            try {
                br = new BufferedReader(new FileReader(fileName));
            } catch (FileNotFoundException e) {
            }
        }

        public FastScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String nextToken() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(nextToken());
        }

        long nextLong() {
            return Long.parseLong(nextToken());
        }

        double nextDouble() {
            return Double.parseDouble(nextToken());
        }
    }

    public static void main(String[] args) {
        new Main().run();
    }
}


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

int N,W;
int w[10010];
vector<int> V[10];
int ans = 0,v[10010];

int judge(int a,int b,int c,int d)
{
    int now = 0,res = 0;
    for(int i = 0; i < a; i++)
    {
        now += w[0];
        res += V[0][i];
        if(now > W)return 0;
    }
    for(int i = 0; i < b; i++)
    {
        now += w[0] + 1;
        res += V[1][i];
        if(now > W)return 0;
    }
    for(int i = 0; i < c; i++)
    {
        now += w[0] + 2;
        res += V[2][i];
        if(now > W)return 0;
    }
    for(int i = 0; i < d; i++)
    {
        now += w[0] + 3;
        res += V[3][i];
        if(now > W)return 0;
    }
    return res;
}

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

    for(int i = 0; i < N; i++)
    {
        V[w[i] - w[0]].push_back(v[i]);
    }
    for(int i = 0; i < 4; i++)
    {
        sort(V[i].begin(),V[i].end());
        reverse(V[i].begin(),V[i].end());
    }

    for(int i = 0; i <= V[0].size(); i++)
    {
        for(int j = 0; j <= V[1].size(); j++)
        {
            for(int k = 0; k <= V[2].size(); k++)
            {
                for(int l = 0; l <= V[3].size(); l++)
                {
                    ans = max(ans,judge(i,j,k,l));
                }
            }
        }
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 256
using System;

namespace Test
{
    class MainClass
    {
        static void Main()
        {
            Console.ReadLine();
            var numsS = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            Console.ReadLine();
            var numsT = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            int ans = 0;

            foreach (var t in numsT)
            {
                var right = numsS.Length;
                var left = 0;
                var mid = 0;

                while (left < right)
                {
                    mid = (left + right) / 2;
                    if (t == numsS[mid])
                    {
                        ans++;
                        break;
                    }
                    else if (t < numsS[mid])
                    {
                        right = mid;
                    }
                    else
                    {
                        left = mid + 1;
                    }
                }
            }

            Console.WriteLine(ans);
        }
    }
}

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

typedef pair<int,int>   II;
typedef vector< II >      VII;
typedef vector<int>     VI;
typedef vector< VI > 	VVI;
typedef long long int 	LL;
typedef unsigned long long int ULL;

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(a) (int)(a.size())
#define ALL(a) a.begin(),a.end()
#define SET(a,b) memset(a,b,sizeof(a))
#define LET(x,a) __typeof(a) x(a)

#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
//Works for forward as well as backward iteration

#define gu getchar
#define pu putchar
#define si(n) scanf("%d",&n)
#define dout(n) printf("%d\n",n)
#define sll(n) scanf("%lld",&n)
#define lldout(n) printf("%lld\n",n)

#define DRT() int t; si(t); while(t--)

#define PlUSWRAP(index,n) index = (index+1)%n		//index++; if(index>=n) index=0
#define MINUSWRAP(index,n) index = (index + n -1)%n 	//index--; if(index<0) index=n-1
#define ROUNDOFFINT(d) d = (int)((double)d + 0.5)	//Round off d to nearest integer

#define FLUSHN while(gu()!='\n')
#define FLUSHS while(gu()!=' ')

#define TRACE

#ifdef TRACE
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;

#else

#define trace1(x)
#define trace2(x, y)
#define trace3(x, y, z)
#define trace4(a, b, c, d)
#define trace5(a, b, c, d, e)
#define trace6(a, b, c, d, e, f)

#endif

#define off ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
LL n;
vector<LL> a;
vector<LL> b;

int main() {
	// #ifndef ONLINE_JUDGE
 //    freopen("input.txt", "r", stdin);
 //    freopen("output.txt", "w", stdout);
	// #endif
	off;
	cin>>n;
	a.resize(n+1);
	b.resize(n);
	rep(i,0,n+1)
	cin>>a[i];
	rep(i,0,n)
	cin>>b[i];
	LL killed = 0;
	rep(i,0,n)
	{
		if(a[i]>=b[i])
		{
			a[i]-=b[i];
			killed+=b[i];
			b[i]=0;
		}
		else
		{
			killed+=a[i];
			b[i]-=a[i];
			a[i]=0;
		}
		if(a[i+1] >= b[i])
		{
			a[i+1]-=b[i];
			killed+=b[i];
			b[i]=0;
		}
		else
		{
			killed+=a[i+1];
			b[i]-=a[i+1];
			a[i+1]=0;
		}
	}
	cout<<killed;
  	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <queue>

using namespace std;

#define INF 1<<30

typedef pair<int, int> P;

vector<P>G[100005];
int N, M;
int damage[100005];
int d[100005];

void dijkstra(int s){
  priority_queue<P, vector<P>, greater<P> >Q;
  fill(d, d + N, INF);
  d[s] = 0;
  Q.push(P(0, s));

  while(!Q.empty()){
    P p = Q.top(); Q.pop();
    int v = p.second;
    if(d[v] < p.first) continue;
    for(int i=0; i < G[v].size();i++){
      P e = G[v][i];
      if(d[e.first] > d[v] + e.second){
	d[e.first] = d[v] + e.second;
	Q.push(P(d[e.first], e.first));
	//	cout << e.first << " " << d[e.first] << endl;
      }
    }
  }
}

int main()
{
  int s, t;
  cin >> N >> M >> s >> t; s--; t--;
  for(int i=0;i<N;i++){
    cin >> damage[i];
  }
  for(int i=0;i<M;i++){
    int a, b;
    cin >> a >> b; a--; b--;
    G[a].push_back(make_pair(b, damage[b]));
  }

  for(int i=0;i<N-1;i++){
    G[i+1].push_back(make_pair(i, 0));
  }

  /*  for(int i=0;i<N;i++){
    for(int j=0;j<G[i].size();j++){
      cout << G[i][j].first << " " ;
    }
    cout << endl;
    }*/

  dijkstra(s);

  cout << d[t] << endl;
  return 0;
}

Measured memory_bytes: 11208
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
#define int long
#define ll long long
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) x.size()
#define fi first
#define se second
const int INF = 1e9;
using namespace std;

template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;

using pi=pair<int,int>;
using vi=vc<int>;

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(20);

    int N; cin >> N;
    vi a,b,v;
    rep(i,N){
        int m; cin >> m;
        if(m>0) a.eb(m);
        else b.eb(m); 
    }

    sort(all(a));
    sort(all(b));
    if(a.size()==0){
        a.eb(b[b.size()-1]);
        b.erase(b.end()-1);
    }
    else if(b.size()==0){
        b.eb(a[0]);
        a.erase(a.begin());
    }

    rep(i,a.size()-1){
        v.eb(b[0]);
        v.eb(a[i]);
        b[0]-=a[i];
    }
    rep(i,b.size()){
        v.eb(a[a.size()-1]);
        v.eb(b[i]);
        a[a.size()-1]-=b[i];
    }

    cout << a[a.size()-1] << endl;
    for(auto a:v){
        cout << a << endl;
    }
}

Measured memory_bytes: 5104
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int ll;

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

int main()
{
	string s;
	cin >> s;

	int l=-1,r=-1;
	for(int i = 1; i < s.length(); i++){
		if(s[i] == s[i-1]){
			l=i,r=i+1;
			break;
		}else if(i < s.length()-1 && s[i-1] == s[i+1]){
			l=i;
			r=i+2;
			break;
		}
	}

	cout << l << " " << r << endl;

	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define inf 1000000000000000000
#define lli long long int
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string s,t;
    cin>>s>>t;
    lli n=s.length(), m=t.length();
    lli dp[n+1][m+1];
    for(int i=0; i<=n; i++)
        dp[i][0]=0;
    for(int i=0; i<=m; i++)
        dp[0][i]=0;
    for(int i=1; i<=n; i++)
    {
        for(int j=1; j<=m; j++)
        {
            if(s[i-1]==t[j-1])
                dp[i][j]=dp[i-1][j-1]+1;
            else
                dp[i][j]=max(dp[i-1][j], dp[i][j-1]);
        }
    }
    vector <char> v;
    int i=n,j=m;
    while(1)
    {
        if(i==0||j==0)
        break;
        if(dp[i][j]>max(dp[i-1][j],dp[i][j-1]))
            v.pb(s[i-1]), i--, j--;
        else if(dp[i][j]==dp[i-1][j])
            i--;
        else
            j--;
    }
    for(int i=v.size()-1; i>=0; i--)
        cout<<v[i];
    return 0;
}

Measured memory_bytes: 73936
# -*- coding: utf-8 -*-

n = int(input())
h = list(map(int, input().split()))
#print(h)

dp = [0 for _ in range(n)]

count = 0
for i in range(n-1, 0, -1):
#    print("test:"+str(i))
    if h[i-1] >= h[i]:
#        print("count+1")
        count += 1
        dp[i-1] = count
    else:
#        print("count -> 0")
        dp[i-1] = 0
        count = 0
#print(dp)
print(max(dp))

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

using namespace std;

const int kMod = 1e9 + 7;

vector<vector<int>> Mul(vector<vector<int>> a, vector<vector<int>> b) {
    int n = a.size();
    vector<vector<int>> res(n, vector<int>(n, 0));

    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            for (int k = 0; k < n; ++k) {
                res[i][j] = (res[i][j] + 1LL * a[i][k] * b[k][j]) % kMod;
            }
        }
    }
    return res;
}

vector<vector<int>> Exp(vector<vector<int>> mat, long long k) {
    int n = mat.size();
    vector<vector<int>> res(n, vector<int>(n, 0));
    for (int i = 0; i < n; ++i) res[i][i] = 1;

    while (k) {
        if (k % 2) res = Mul(mat, res);
        mat = Mul(mat, mat);
        k /= 2;
    }
    return res;
}

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

    vector<vector<int>> g(n, vector<int>(n, 0));
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            cin >> g[i][j];
        }    
    }

    g = Exp(g, k);

    int ans = 0;
    for (int i = 0; i < n; ++i)
        for (int j = 0; j < n; ++j)
            ans = (ans + g[i][j]) % kMod;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a) for (ll i = 0; i < (a); ++i)
#define pb push_back
#define all(v) v.begin(),v.end()
#define sort_1(v) sort(v.begin(),v.end())
#define sort_2(v) sort(v.begin(),v.end(),greater<ll>())
#define reverse(v) reverse(v.begin(),v.end())
typedef long long ll;
typedef long double la;
using namespace std;

int main(){
    int a,b,c,d,k;
    cin >> a >> b >> c >> d >> k;
    int time1 = a*60+b;
    int time2 = c*60+d;
    cout << time2 - time1 - k << endl;
}


Measured memory_bytes: 3632
#include<iostream>

using namespace std;

int main(void){
  int k,c,sum,i;

  while(1){
    sum=0;
    cin >> k;

    if(k==0)break;

    for(i=0;i<(k*(k-1))/2;i++){
      cin>>c;
      sum+=c;

  }

  
cout << sum/(k-1)<<endl;
}


  return 0;
}

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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< pii >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define in(x, a, b) ((a) <= (x) && (x) < (b))
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Decimal fixed << setprecision(10)

//int dxy[5] = {0, 1, 0, -1, 0};
// cmd

bool check(vi &data)
{
    rep(i, data.size()) {
        if (data[i]) return true;
    }
    return false;
}

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

    vi mmn(26, 0), mm(10, 0);
    string st;
    cin >> st;
    
    rep(i, st.size()) {
        if (in(st[i], '0', '9'+1)) {
            mm[st[i] - '0']++;
        } else {
            mmn[st[i] - 'a']++;
        }
    }
/*
    rep(i, mmn.size()) {
        cout << mmn[i] << " ";
    }cout << endl;
*/
    int ans = 0;
    while (check(mmn)) {
        int ptr = 0;
        while (!mmn[ptr]) ptr++;
        int len = 0;
        for (; ptr < mmn.size(); ptr++) {
            if (mmn[ptr]) {
                len++;
                mmn[ptr]--;
            } else {
                break;
            }
        }
        if (len >= 3) ans += 3;
        else ans += len;
        //cout << len << " " << ans << endl;
    }

    /*
    rep(i, mm.size()) {
        cout << mm[i] << " ";
    }cout << endl;
    */
    while (check(mm)) {
        int ptr = 0;
        while (!mm[ptr]) ptr++;
        int len = 0;
        for (; ptr < mm.size(); ptr++) {
            if (mm[ptr]) {
                len++;
                mm[ptr]--;
            } else {
                break;
            }
        }
        if (len >= 3) ans += 3;
        else ans += len;
        //cout << len << " " << ans << endl;
    }

    std::cout << ans << std::endl;

    return 0;
}



Measured memory_bytes: 3228
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            int N = cin.ReadInt;
            var AB = new int[N][];
            for(int i=0;i<N;i++){
                AB[i] = cin.ReadIntArray(2);
            }
            var ABs = AB.OrderBy(x => x[1]);
            long curtime = 0;
            string ans = "Yes";
            foreach(int[] L in ABs){
                curtime += L[0];
                if(curtime > L[1]){
                    ans = "No";
                    break;
                }
            }
            WriteLine(ans);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator =' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
    }
}

Measured memory_bytes: 29604
//実装が重そうな問題はある程度考えてから書く
//初期化を忘れずに（特に二分探索とか）
//コーナーケースを考えて（特に場合分けとか）
//不可解すぎるバグは配列外参照（配列の長さ）を検討
#include "bits/stdc++.h"
#define YES "YES"
#define NO "NO"
#define YESNO OUT(three(solve(),YES,NO))
#define ECHO OUT(solve())
#define three(A,B,C) ((A)?(B):(C))
#define FOR(i,a,b)  for(LL i=(a);i< (LL)(b);i++)
#define EFOR(i,a,b) for(LL i=(a);i<=(LL)(b);i++)
#define RFOR(i,a,b) for(LL i=(a);i>=(LL)(b);i--)
#define REP(i,b) FOR(i,zero,b)
#define EREP(i,b) EFOR(i,zero,b)
#define RREP(i,b) RFOR(i,b-1,zero)
#define ALL(c) c.begin(),c.end()
#define UNIQUE(c) sort(ALL(c));c.erase(unique(ALL(c)),c.end())
#define MAX(c) (*max_element(ALL(c)))
#define MIN(c) (*min_element(ALL(c)))
#define MP make_pair
#define FI first
#define SE second
#define SI(x) (LL(x.size()))
#define PB emplace_back
#define DEBUG(a) OUT(a)
#define DEBUG2(a,b) OUT2(a,b)
#define cat cout << __LINE__ << endl
#define OUT(a) cout << (a) << endl
#define OUT2(a,b) cout << (a) <<" "<<(b) << endl
#define int long long
#define zero 0LL
#define pb PB
using namespace std;
template<typename T> inline bool middle(T a, T b, T c) { return b <= a && a <= c; }
template<class T> inline bool MX(T &l, const T &r) { return l < r ? l = r, 1 : 0; }
template<class T> inline bool MN(T &l, const T &r) { return l > r ? l = r, 1 : 0; }
typedef long long LL;
typedef double ld;
typedef LL ut;
typedef vector<ut> VI;
typedef vector<VI> VII;
typedef pair<ut, ut> pr;
typedef pair<ut, pr> ppr;
typedef vector<pr> Vpr;
typedef vector<ppr> Vppr;
typedef priority_queue<pr, Vpr ,greater<pr> > PQ;
inline void outputVI(VI x) { REP(i, SI(x)) { cout << three(i, " ", "") << x[i]; }OUT(""); }
int dx[] = { 0,1,0,-1,0 }, dy[] = { 1,0,-1,0,0 };
const int SIZE1 =3e5 + 1000;
const int SIZE2 = 5010;
const int SIZE3 = 22;
const int SIZE = SIZE1;
const LL p = 7 + 1e9;
const LL INF = 1LL << 60;
const long double EPS = 1e-7;
ut N, M, K, X, L, Y,H,W,Q;
// ut A,B,C,D,E,F,G,H,I,J,O,P,Q,R,T,U;
VI edges[SIZE];
LL vals[SIZE], nums[SIZE], maps[SIZE3][SIZE3], answer = zero;
LL A[SIZE], B[SIZE];
LL solve() {
	REP(i, 3) cin >> A[i];
	LL minium = 0;
	REP(i, 3) MX(minium, A[i]);
	REP(i, 3) if (minium == A[i]) {
		cout << (char)('A' + i) << endl;
	}

	return 0;
}
signed main() {
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(10);

	solve();
//	cin >> N;
	return 0;
}


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

using namespace std;

int main()
{
    int n ;
    scanf("%d",&n);

    double cnt = 1.0*n/3;

    int ans = int(cnt);

    if(ans == 1)
    {
        if(n!=3)
            ans++;
    }
    printf("%d\n",ans);

    return 0;
}


Measured memory_bytes: 256