akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vp;
typedef vector<iii> vt;
typedef vector<vi> vv;
#define REP(i, n) for (ll i = 0; i < (n); ++i)

const ll INF = 1e15;

ll N;
vi X, L;

ll iceil(ll a, ll b)
{
    return (a + b - 1) / b;
}

int main()
{
    cin >> N;
    X = vi(N);
    L = vi(N);
    REP(i, N)
    {
        cin >> X[i] >> L[i];
    }

    vp A = vp(N);
    REP(i, N)
    {
        A[i] = ii(X[i] + L[i], X[i] - L[i]);
    }
    sort(A.begin(), A.end());

    ll prev = -INF;
    ll ans = 0;
    REP(i, N)
    {
        if (prev <= A[i].second)
        {
            ++ans;
            prev = A[i].first;
        }
    }

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

Measured memory_bytes: 3328
use proconio::{input, fastout};

#[fastout]
fn main() {
    input!{
        n: i32,
        m: i32,
	c: i32,
    }
    input!{
        b: [i32; m],
    }
    input!{
        a: [[i32; m]; n],
    }
    let mut ret = 0;
    for i in 0..n {
	let mut tmp = 0;
	for j in 0..m {
	    tmp += a[i as usize][ j as usize] * b[j as usize];
	}
	tmp += c;
	if tmp > 0 {
	    ret += 1;
	}
    }
    println!("{}", ret);
}


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

int main(){
    string s;
    cin >> s;
    bool flg[26] = {0};
    set<char> st;
    rep(i, s.length()) {
        flg[s[i]-'a'] = 1;
        st.insert(s[i]);
    }
    if ( st.size() != 26 ) {
        rep(i, 26) {
            if ( !flg[i] ) {
                s += (char)(i + 'a');
                break;
            }
        }
    }
    else {
        bool ng = 1;
        for ( int i = s.length() - 1; i >= 1; --i ) {
            char tmp_char;
            if ( s[i] > s[i-1] ) {
                flg[s[i]-'a'] = 0;
//                rep(j, 26) {
//                    cout << flg[j] << " ";
//                }
//                cout << endl;
                tmp_char = (char)(s[i-1] + 1 );
                while(1) {
//                    cout << tmp_s << endl;
                    if ( tmp_char > 'z' ) {
                        break;
                    }
                    if ( !flg[tmp_char-'a'] ) {
                        s = s.substr(0, i-1) + tmp_char;
                        ng = 0;
                        break;
                    }
                    ++tmp_char;
                }
            }
//            cout << ng << endl;
            if ( ng == 0 ) {
                break;
            }
            flg[s[i]-'a'] = 0;
        } 
        if ( ng ) {
            cout << -1 << endl;
            return 0;
        }
    }
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.*;

public class Main {

  static int a, b;
  
  public static void main(String[] args) throws Exception {
    
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    
    String[] in = br.readLine().split(" ");
    a = Integer.parseInt(in[0]);
    b = Integer.parseInt(in[1]);

    br.close();

    System.out.println(a * b + " " + (2 * (a+b)));

  }
}


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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    vector<ll> v;
    for(ll i =1;i<=9;i++){
        for(ll j=1;j<=9;j++){
            v.push_back(i*j);
        }
    }
    auto iter = find(v.begin(),v.end(),n);
    if(iter != v.end()){
        cout << "Yes";
    }else{
        cout << "No";
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
using namespace std;
using ll = long long;
using p = pair<int,int>;
using Graph = vector<vector<int>>;
 
const double PI = acos(-1);
ll Asum[200005];
ll Bsum[200005];
 
int main(){
    int N,M,K;
    cin >> N >> M >> K;
  
    //Asum[0]=0の分だけ配列が1大きい
    rep(ii,N) {
        int i = ii + 1;
        cin >> Asum[i];
        Asum[i]+=Asum[ii];
    }
  
    rep(ii,M) {
        int i = ii + 1;
        cin >> Bsum[i];
        Bsum[i]+=Bsum[ii];
    }
    
    int ans=0,j=M;
    rep(i, N+1) {
        if (Asum[i] > K) break;
        //output for debug
        //cout << "Asum:" << Asum[i] << ",Bsum:" << Bsum[j] << "\n";
        while (Bsum[j] > K - Asum[i]) {
            //output for debug 
            //cout << "A:" << Asum[i] << ",B:" << Bsum[j] << "\n";
            j--;
        }
        ans = max(ans,i+j);
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 6748
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef complex<double> P;
 
int main() {
  int a, b, c, d, e, f; cin >>a >>b >>c >>d >>e >>f;
  int sum = a + b * 5 + c * 10 + d * 50 + e * 100 + f * 500;
  cout <<(sum >= 1000 ? 1 : 0) <<endl;
  return 0;
}

Measured memory_bytes: 1160
N = int(input())
SP = []
for i in range(N):
    s,p = input().split()
    p = int(p)
    SP.append((s,p,i+1))
SP.sort(key=lambda x:-x[1])
SP.sort(key=lambda x:x[0])
for i in range(N):
    print(SP[i][2])

Measured memory_bytes: 38384
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		int wa = a+b;
		int sa = a-b;
		int seki = a*b;
		
		if (wa > sa) {
			
			if (wa > seki) {
				System.out.println (wa);
			}else {
				System.out.println (seki);
			}
		}else{
			if (sa > seki) {
				System.out.println (sa);
			}else {
				System.out.println (seki);
			}
			
		}
		
	}
}


Measured memory_bytes: 23124
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <algorithm>
#include <set>
#include <string>
#include <queue>

using namespace std;

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

int main(){
    int N;
    cin >> N;
    vector<int> as(N);
    rep(i, N){
        cin >> as[i];
    }
    sort(as.begin(), as.end());

    ll ans = 0;

    if(N % 2 == 0){
        rep(i, N){
            if(i + 1 >= N / 2 + 1){
                ans += 2 * as[i];
            }else{
                ans -= 2 * as[i];
            }
        }
        ans -= as[N / 2];
        ans += as[N / 2 - 1];
    }else{
        // 2+ 2- 1+ 1-
        rep(i, N){
            if(i + 1 >= (N + 1) / 2 + 1){
                ans += 2 * as[i];
            }else{
                ans -= 2 * as[i];
            }
        }
        ans += as[(N + 1)/ 2 - 1];
        ans += as[(N + 1) / 2 - 2];


        ll tmp = 0;
        sort(as.begin(), as.end(), greater<int>());
        rep(i, N){
            if(i + 1 >= (N + 1) / 2 + 1){
                tmp -= 2 * as[i];
            }else{
                tmp += 2 * as[i];
            }
        }
        tmp -= as[(N + 1)/ 2 - 1];
        tmp -= as[(N + 1) / 2 - 2];
        ans = max(ans, tmp);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<list>
#include<cstdlib>
#include<cstring>
using namespace std;

bool prime[1200];
int primeList[200];
int array[1130][16][190];
int Limit;

void
initArray(){
	for(int i=2;i<=1120;i++){
		for(int j=i+i;j<=1120;j+=i){
			prime[j]=false;
		}
		if(prime[i]==true){primeList[Limit++]=i;}
	}
	prime[0]=prime[1]=false;
}


int
rec(int n,int k,int index){
	//cout<<"("<<n<<","<<k<<","<<index<<")"<<primeList[index-1]<<endl;
	if(n==0&&k==0)return 1;
	if(n-primeList[index-1]<0)return 0;
	if(array[n][k][index]!=-1)return array[n][k][index];
	if(k==0)return 0;
	if(n < primeList[index-1])return 0;
	//cout<<"("<<n<<","<<k<<","<<index<<")"<<primeList[index-1]<<endl;
	int sum=0;
	for(int i=index;i<Limit;i++){
		if(n-primeList[i]<0)break;
		sum+=rec(n-primeList[i],k-1,i+1);
	}
	array[n][k][index]=sum;
	return sum;
}



int
main(){
	fill(prime,prime+1200,true);

	int n,k;
	initArray();
	memset(array,-1,sizeof(array));
	//memset(array,Limit,sizeof(int)*1130*16);
	for(;cin>>n>>k&&(n||k);){
		cout<<rec(n,k,0)<<endl;
	}

	return 0;
}

Measured memory_bytes: 13000
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
typedef long long ll;

int gi() {
	int x=0,o=1;char ch=getchar();
	while(!isdigit(ch)&&ch!='-') ch=getchar();
	if(ch=='-') o=-1,ch=getchar();
	while(isdigit(ch)) x=x*10+ch-'0',ch=getchar();
	return x*o;
}

struct dat {
	int a,b;
	bool operator<(const dat &A) const {
		return a>A.a;
	}
} p[N];

int n;
ll sum;

int main() {
	cin>>n;
	for(int i=1;i<=n;i++) {
		p[i].a=gi(),p[i].b=gi();
		sum+=p[i].a;
		p[i].a=max(p[i].a,p[i].b);
	}
	sort(p+1,p+n+1);
	int k=0;ll ss=0;
	for(int i=1;i<=n;i++) {
		ss+=p[i].a;
		if(ss>=sum) { k=i;break; }
	}
	ll P=1,Q=1;
	for(int i=1;i<=n;i++) {
		ll now=sum-(ss-p[min(i,k)].a);
		if(now<=p[i].b&&now*Q<P*p[i].b) P=now,Q=p[i].b;
	}
	P=Q-P+(n-k)*Q,Q*=n;
	ll g=__gcd(P,Q);P/=g,Q/=g;
	cout<<P<<' '<<Q<<endl;
	return 0;
}


Measured memory_bytes: 1024
from math import sin,radians,sqrt,cos
a,b,C=list(map(int,input().split()))
S=a*b*sin(radians(C))/2
print(S)
c=sqrt(a**2+b**2-2*a*b*cos(radians(C)))
print(a+b+c)
print(b*sin(radians(C)))


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

int main() {
  int n;
  cin >> n;
  vector<double> x(n);
  for(int i = 0; i < n; i++){
    cin >> x.at(i);
  }
  double count = 0; //逆数の総和
  for(int i = 0; i < n; i++){
    count  += 1 / x.at(i);
  }
  cout << 1 / count <<endl;
        
}

Measured memory_bytes: 256
s=input()
t=len(s)
ans=0
ruiseki=[int(s[-1]) for i in range(t)]
for i in range(1,t):
    ruiseki[i]=(ruiseki[i-1]+int(s[-1-i])*pow(10,i,2019))%2019
from collections import Counter
ans+=ruiseki.count(0)
C=Counter(ruiseki)
for x in C.values():
    ans+=x*(x-1)//2
print(ans)




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

int main(){
  int n;
  cin >> n;
  int a[n];
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  int cnt =0;
  for(int i=0;i<n;i++){
    if(i%2==0&&a[i]%2==1) cnt++;
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 3592
#include <stdio.h>
int main(){
	int N, D_1, D_2, D_3, D_4, D_5, D_6, D_7, D_8, D_9, D_10, D_11, Soma, N_1, N_2, N_3, N_4, N_5, N_6, N_7, N_8, N_9, N_10, N_11;
	scanf("%d", &N);
	D_1 = N % 10;
	N_1 = N/10;

	D_2 = N_1 % 10;
	N_2 = N_1/10;

	D_3 = N_2 % 10;
	N_3 = N_2/10;

	D_4 = N_3 % 10;
	N_4 = N_3/10; 

	D_5 = N_4 % 10;
	N_5 = N_4/10;

	D_6 = N_5 % 10;
	N_6 = N_5/10;

	D_7 = N_6 % 10;
	N_7 = N_6/10;

	D_8 = N_7 % 10;
	N_8 = N_7/10;

	D_9 = N_8 % 10;
	N_9 = N_8/10;

	D_10 = N_9 % 10;
	N_10 = N_9/10;

	D_11 = D_10 % 10;
	N_11 = N_10/10;

	Soma = D_1 + D_2 + D_3 + D_4 + D_5 + D_6 + D_7 + D_8 + D_9 + D_10 + D_11;
	if( N%Soma == 0)
		printf("Yes\n");
	else
		printf("No\n");


return 0;
}

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

int main() {

  int A, B; cin >> A >> B;
  int N = 0;
  while (N < B) {
    if (N * A - N + 1 >= B) {
      break;
    }
    N++;
  }
  cout << N << endl;
    
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		scan.next();
		String s = scan.next();
		scan.next();
		String b = s.charAt(0) + "";
		System.out.println("A" + b + "C");
	}
}

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

const int MAX = 60;

long long count(long long A, int size) {
    long long all = 1LL<<size;
    for (int i = 0; i < size; ++i) if (A & (1LL<<i)) all -= 1LL<<i;
    return all;
}

long long count(long long A, int size, int masksize) {
    long long all = 1LL<<size;
    long long res = all;
    int maxsize = 0;
    for (int i = 0; i < size; ++i) if (A & (1LL<<i)) maxsize = i+1, res -= 1LL<<i;
    if (masksize >= maxsize) return all;
    else return res + (1LL<<masksize);
}

long long solve(long long A, long long B) {
    if (A == B) return 1;
    int size = -1;
    for (int i = 0; i < MAX; ++i) if ( !(A & (1LL<<i)) && (B & (1LL<<i)) ) size = i;
    int bsize = 0;
    for (int i = 0; i < size; ++i) if (B & (1LL<<i)) bsize = i + 1;

    // size 桁が 0 の場合
    long long zero = count(A, size);
    
    // size 桁が 1 の場合
    long long one = count(A, size, bsize);
    
    return zero + one;
}

int main() {
    long long A, B; cin >> A >> B;
    cout << solve(A, B) << endl;
}


Measured memory_bytes: 764
S = input()
count = 0
N = len(S)
a = int((N-1)/2 )
b = int((N +3)/2)
if S[:a] ==S[b-1:]:
  pass
else:
  count +=1
SS = S[b-1:]

SSS =list(SS)
for i in range(len(SSS)):
  if SSS[i] != SSS[-i-1]:
    
    count +=1
if count==0:
  print('Yes')

else:
  print('No')

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


using namespace std;
double pi=3.14159265358979323846264338;
long long sum;
long long ma;
long long n,k,st,x,t;
long long pr(long long a, long long b){
	long long k=1;
	if(b==0)return 1;
	
	for(int i=0;i<b;i++)k=k*10;
	return k;
}
long long arr[200001];
bool che(long long a){
	long long cur=0;
	for(int i=0;i<n;i++){
		cur+=(arr[i]+a-1)/(a)-1;
	}
	if(cur<=k)return true;
	return false;
}
int main(){
	cin>>n>>x>>t;
	if(n%x==0)cout<<t*n/x<<endl;
	else cout<<(n/x+1)*t<<endl;
	return 0;
}

Measured memory_bytes: 3624
Program Insertion;
const   finput='Insertion.inp';
        foutput='Insertion.out';
var     n,tmp,k,j,i:longint;
        s,st:string;
begin
    //assign(input,finput);reset(input);
    //assign(output,foutput);rewrite(output);
    readln(n);
    readln(s);
    st:='(';
    k:=0;
    i:=1;
    repeat
        begin
        case s[i] of
                ')':dec(tmp);
                '(':inc(tmp);
        end;
        if tmp<0 then
                begin
                insert(st,s,k+1);
                inc(tmp);
                inc(i);
                end;
        end;
    inc(i);
    until i>length(s);
    st:=')';
    while tmp>0 do
        begin
        insert(st,s,length(s)+1);
        dec(tmp);
        end;
        write(s);
    //close(input);close(output);
end.



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

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

  string a, b;
  cin >> a >> b;
  a += b;
  int n = stoi(a);
  bool ans = 0;
  for (int i = 0; i < 316; i++)  {
    if ((i+1) * (i+1) == n) {
      ans = 1;
      break;
    }
  }
  if (ans) puts("Yes");
  else puts("No");
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 998244353;
const ll INF = mod * mod;
typedef pair<int, int>P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef pair<ll, ll> LP;
typedef vector<ll> vec;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-5;
const ld pi = acos(-1.0);

struct uf {
private:
	vector<int> par, ran;
	vector<int> cnt;
public:
	uf(int n) {
		par.resize(n, 0);
		ran.resize(n, 0);
		cnt.resize(n, 1);
		rep(i, n) {
			par[i] = i;
		}
	}
	int find(int x) {
		if (par[x] == x)return x;
		else return par[x] = find(par[x]);
	}
	void unite(int x, int y) {
		x = find(x), y = find(y);
		if (x == y)return;
		if (ran[x] < ran[y]) {
			par[x] = y; cnt[y] += cnt[x];
		}
		else {
			par[y] = x; cnt[x] += cnt[y];
			if (ran[x] == ran[y])ran[x]++;
		}
	}
	bool same(int x, int y) {
		return find(x) == find(y);
	}
	int comp(int x) {
		return cnt[find(x)];
	}
};

vector<int> G[1 << 17];

void solve() {
	int n; ll m; int  q; cin >> n >> m >> q;
	uf u(n);
	vector<P> v;
	int num = 0; ll ma = 0;
	rep(i, q) {
		int a, b, c; cin >> a >> b >> c;
		if (c == 0) {
			/*if (u.same(a, b)) {
				cout << "No" << endl; return;
			}*/
			if (!u.same(a, b)) {
				num++; ma++;
			}
			u.unite(a, b);
		}
		else {
			v.push_back({ a,b });
		}
	}
	map<P, bool> used;
	rep(i, v.size()) {
		int l = v[i].first, r = v[i].second;
		l = u.find(l), r = u.find(r);
		if (l > r)swap(l, r);
		if (l==r) {
			cout << "No" << endl; return;
		}
		if (used[{l, r}])continue;
		G[l].push_back(r); G[r].push_back(l);
		used[{l, r}] = true;
	}
	vector<bool> chked(n, false);

	ll dr = 0;
	vector<ll> z;
	int ad = 0;
	bool exi = false;
	rep(i, n) {
		int p = u.find(i);
		if (chked[p])continue;
		queue<int> q; q.push(p); chked[p] = true;
		vector<int> ids;
		while (!q.empty()) {
			int id = q.front(); q.pop();
			ids.push_back(id);
			rep(j, G[id].size()) {
				int to = G[id][j];
				if (chked[to])continue;
				chked[to] = true;
				q.push(to);
			}
		}
		int edges = 0;
		rep(j, ids.size()) {
			int id = ids[j];
			edges += G[id].size();
		}
		edges /= 2;
		ll len = ids.size();
		if(len>1)num += len;
		dr += len;
		z.push_back(len);
	}
	if (z == vector<ll>{2}) {
		cout << "No" << endl; return;
	}
	//cout << num << " " << ma << endl;
	ma += dr * (dr - 1) / 2;
	if (m < num || ma < m) {
		cout << "No" << endl; return;
	}
	cout << "Yes" << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//init();
	solve();
	//stop
	return 0;
}


Measured memory_bytes: 15604
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
#include <string>
#include <cstring>
using namespace std;

int main() {
	int n;
	cin>>n;
	vector<int> v(n);
	for (int i=0; i<n; ++i)
		cin>>v[i];
	auto lo=min_element(v.begin(), v.end());
	auto hi=max_element(v.begin(), v.end());
	int d=abs(*lo - *hi);
	cout<<d<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<tuple>
#include<iomanip>
#define int long 
using namespace std;

signed main() {
	string S,T;
	cin >> S >> T;
	vector<int> A(26);
	vector<int> B(26);
	for(int i = 'a';i <= 'z';i++) {
		for(int j = 0;j < S.size();j++) {
			if(S.at(j) == i) {
				A.at(i - 'a')++;
			}
			if(T.at(j) == i) {
				B.at(i - 'a')++;
			}
		}
	}
	sort(A.begin(),A.end());
	sort(B.begin(),B.end());
	bool C = true;
	for(int i = 0;i < 26;i++) {
		if(A.at(i) != B.at(i)) {
			C = false;
		}
	}
	if(C == true) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 904
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define int long long

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF (3e15)

using namespace std;

int N, A[200005], S[20005];

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

    cin >> N;
    REP(i, N) cin >> A[i];
    REP(i, N) {
        if (i == 0) {
            S[i] = A[i];
            continue;
        }
        S[i] = S[i - 1] + A[i];
    }
    sort(S, S + N);

    int ans = 0;
    int prev = INF;
    int cnt = 0;
    REP(i, N) {
        if (S[i] == 0) ans++;
        if (S[i] == prev) {
            cnt++;
        } else {
            if (cnt > 1) {
                ans += cnt * (cnt - 1) / 2;
            }
            cnt = 1;
        }
        prev = S[i];
    }
    if (cnt > 1) {
        ans += cnt * (cnt - 1) / 2;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1920
import java.io.File;
import java.io.IOException;
import java.util.*;
 
public class Main {
 
	public static void main(String[] args) throws IOException {
		//File file = new File("input.txt");
		//Scanner in = new Scanner(file);
		
		Scanner in = new Scanner(System.in);
		
		int n = in.nextInt();
		int m = in.nextInt();
      
		int[][] ab = new int[m][2];
        boolean[] tf = new boolean[n+1];
		
		for(int i = 0; i < m; i++) {
			ab[i][0] = in.nextInt();
            ab[i][1] = in.nextInt();
          if(ab[i][0] == 1) tf[ab[i][1]] = true;
		}
      
        for(int i = 0; i < m; i++) {
			if(tf[ab[i][0]] && ab[i][1] == n){
              System.out.println("POSSIBLE");
              return;
            }
		}
        
		System.out.println("IMPOSSIBLE");
	}
}


Measured memory_bytes: 108160
#include <bits/stdc++.h>
using namespace std;
	
#define int long long
#define pb push_back
#define ub upper_bound
#define lb upper_bound
#define mp make_pair
#define F first
#define S second
#define FOR(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define ve vector
#define vi vector<int>
#define vp vector<pair<int,int>>
#define vvi vector<vector<int>>
	
using ll = long long;
const ll INF = LLONG_MAX - 100;
ll mod = 1e9 + 7;
int dx[] = {-1,0,1,0}, dy[] = {0,1,0,-1};
vector<ll> prime;
	
class fact {
public:
	int fmod = 1e9+7;
	vector<int> fac, inv;
	fact (int n, int Mod = 1e9+7) {
		fmod = Mod;
		fac = vector<int>(n,0);
		inv = vector<int>(n,0);
		fac[0] = 1; for (int i = 1; i < n; i++) fac[i] = fac[i-1] * i % fmod;
		for (int i = 0;i < n;i++) inv[i] = fact::POW(fac[i],fmod-2);
	}
	ll nCr(ll n, ll r) {return (fac[n] * inv[r] % fmod) * inv[n-r] % fmod;}
	ll POW(ll a, ll b) {ll c = 1; while (b > 0) {if (b & 1) {c = a * c%fmod;}a = a * a%fmod; b >>= 1;}return c;}
};
	
template <class T = ll> T in() {T x; cin >> x; return (x);}
void DEBUG(vector<int> a) {for(int i=0;i<a.size();i++)cout<<a[i]<<" ";cout<<endl;}
void EMP(int x) {cout<<"!!!"<<x<<"!!!"<<endl;}
ll GCD(ll a, ll b) {ll c; while (b != 0) {c = a % b; a = b; b = c;}return a;}
ll LCM(ll a, ll b) {return a * b / GCD(a, b);}
ll POW(ll a, ll b) {ll c = 1; while (b > 0) {if (b & 1) {c = a * c%mod;}a = a * a%mod; b >>= 1;}return c;}
void PRI(ll n) {bool a[n + 1LL]; for (int i = 0; i < n + 1LL; i++) {a[i] = 1LL;}for (int i = 2; i < n + 1LL; i++) {if (a[i]) {prime.pb(i); ll b = i; while (b <= n) {a[b] = 0; b += i;}}}}
template <typename T> T chmin(T& a, T b) {if(a>b)a=b;return a;}
template <typename T> T chmax(T& a, T b) {if(a<b)a=b;return b;}
bool isSqrt(ll a) {return pow(sqrt(a),2) == a ? 1 : 0;}
void YesNo(bool a) {if (a) cout << "Yes"; else cout << "No"; cout << endl;}
void yesno(bool a) {if (a) cout << "yes"; else cout << "no"; cout << endl;}
void YESNO(bool a) {if (a) cout << "YES"; else cout << "NO"; cout << endl;}
	
bool solve() {
	int n; cin >> n;
	int a[n]; REP (i,n) cin >> a[i];
	bool flag = true; int b[n];
	int border; 
	for (int i = n/2+1;i <= n;i++) {
		b[i-1] = a[i-1];
	}
	for (int i = n/2;i >= 1;i--) {
		int p = i * 2;
		int tmp = 0;
		while (p <= n) {
			tmp += b[p-1];
			p += i;
		}
		if (tmp%2 == a[i-1]) b[i-1] = 0;
		else b[i-1] = 1;
	}
	int cnt = 0;
	REP (i,n) {
		if (b[i]) cnt++;
	}
	cout << cnt << endl;
	REP (i,n) {
		if (b[i]) cout << i+1 << endl;
	}
}
	
signed main() {
	// cin.tie(0);
	// ios::sync_with_stdio(false);
	solve();
}

Measured memory_bytes: 3968
class PriorityQueue
  def initialize(&comp)
    @heap = []
    @node_num = 0
    if !block_given?
      @comp = Proc.new { |x, y| x <= y }
    else
      @comp = comp
    end
  end

  attr_reader :heap

  def push(x)
    current_node_num = @node_num
    @node_num += 1
    while current_node_num > 0
      parent_node_num = (current_node_num - 1) / 2
      break if @comp.call(@heap[parent_node_num], x) # 逆転してないなら抜ける
      # 親ノードを下ろして自分を上に
      @heap[current_node_num] = @heap[parent_node_num]
      current_node_num = parent_node_num
    end
    @heap[current_node_num] = x
  end

  alias_method(:<<, :push)

  def pop
    # 最(小|大)値
    ret = @heap[0]
    # 根にもってくる値
    @node_num -= 1
    x = @heap[@node_num]
    # 根から下ろしていく
    i = 0
    while (a = i * 2 + 1) < @node_num
      # 子どうしを比較
      b = a + 1
      a = b if b < @node_num && @comp.call(@heap[b], @heap[a])
      break unless @comp.call(@heap[a], x)
      @heap[i] = @heap[a]
      i = a
    end
    @heap[i] = x
    return ret
  end

  def get
    @node_num == 0 ? nil : @heap[0]
  end

  def empty?
    return get.nil?
  end
end



q = PriorityQueue.new{|x, y| x > y}
ans = []
while true
  input = gets.chomp
  if input == "end"
    break
  elsif input == "extract"
    ans << q.pop
  else
    x = input.split[1].to_i
    q << x
  end
end
puts ans


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

#define ll long long
#define ull unsigned long long
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define debug(x) cerr<<#x<<": "<<x<<'\n'

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

template<class T=int>
T in(){T x;cin>>x;return (x);}
template<class T>
void print(T& x){cout<<x<<'\n';}

const int MOD =(int)1e9+7;
const int MAX =510000;

ll fac[MAX],finv[MAX],inv[MAX];
void COMint(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}
ll COM(int n,int k){
    if(n<k) return 0;
    if(n<0||k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}

ll gcd(ll a,ll b){
    if(b==0)return a;
    if(a>b){
        swap(a,b);
    }
    return gcd(a,b%a);
}
ll lcm(ll a,ll b){
    ll g;g=gcd(a,b);
    return a*b/g;
}
double ep(int all,double p){
    return all*(1/p);
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string key="keyence";
    int k;
    string s=in<string>();
    if(s.find("keyence")==0||s.find("keyence")==s.length()-7){
        print("YES");
        return 0;
    }else{
        REP(i,s.length()){
            if(s[i]==key[i]){
                k++;
            }else{
                break;
            }
        }
        for(int i=s.length()-(7-k);i<s.length();i++){
            
            if(s[i]==key[k]){
                k++;
            }else{
                print("NO");
                return 0;
            }
        }
    }
    print("YES");
    return 0;
}

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

const int MAXN=2100+5,MAXM=50000+10;
const long long int INF = 1e18;
bool visit[MAXN],inqueue[MAXN];
long long int head[MAXN],dist[MAXN],parent[MAXN],stamp;
long long int maxflow,mincost;
//parent indicates the index of the in-edge
queue<long long int> q;
struct EDGE{
   long long int to,r,cost,next;
}edge[MAXM*2];
long long int SPFA(int s,int t){
   for(int i=0;i<MAXN;i++)
      dist[i]=INF;
   memset(inqueue,0,sizeof inqueue);
   while(!q.empty()) q.pop();
   dist[s]=0;inqueue[s]=true;q.push(s);
   while(!q.empty()){
      long long int now=q.front();q.pop();inqueue[now]=false;
      for(long long int i=head[now];i!=-1;i=edge[i].next){
         if(edge[i].r>0){
            long long int next=edge[i].to;
            long long int cost=edge[i].cost;
            if(dist[next]>dist[now]+cost){
               parent[next]=i;
               dist[next]=dist[now]+cost;
               if(!inqueue[next]){
                  inqueue[next]=true;
                  q.push(next);
               }
            }
         }
      }
   }
   return dist[t];
}
void addedge(int a,int b,long long int r,long long int cost){
   edge[stamp]={b,r,cost,head[a]};
   head[a]=stamp++;
   edge[stamp]={a,0,-cost,head[b]};
   head[b]=stamp++;
}
void init(){
   stamp=maxflow=mincost=0;
   memset(head,-1,sizeof head);
}
void Minimum_Cost_Flow(int s,int t){
   while(SPFA(s,t)!=INF){
      long long int flow=INF,cost=0;
      long long int tmpnode=t;
      while(tmpnode!=s){
         flow=min(flow,edge[parent[tmpnode]].r);
         cost+=edge[parent[tmpnode]].cost;
         tmpnode=edge[parent[tmpnode]^1].to;
      }
      maxflow+=flow;
      mincost+=flow*cost;
      tmpnode=t;
      while(tmpnode!=s){
         edge[parent[tmpnode]].r-=flow;
         edge[parent[tmpnode]^1].r+=flow;
         tmpnode=edge[parent[tmpnode]^1].to;
      }
   }
}



int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	init();
	int n;
	cin>>n;
	long long int x,y,c;
	for(int i=1;i<=n;i++){
		cin>>x>>y>>c;
		addedge(2005,i,c,0);
		addedge(i,2001,INF,-(x+y));
		addedge(i,2002,INF,x-y);
		addedge(i,2003,INF,y-x);
		addedge(i,2004,INF,x+y);
	}
	for(int i=1;i<=n;i++){
		cin>>x>>y>>c;
		addedge(i+1000,2006,c,0);
		addedge(2001,i+1000,INF,(x+y));
		addedge(2002,i+1000,INF,y-x);
		addedge(2003,i+1000,INF,x-y);
		addedge(2004,i+1000,INF,-(x+y));
	}
	Minimum_Cost_Flow(2005,2006);
	cout<<-mincost<<endl;
}


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

int main(void){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);

  string S;
  long long K;
  cin >> S >> K;
  for (int i = 0; i < min((long long)S.size(), K); i++) {
    if (S[i] >= '2') {
      cout << S[i] << endl;
      return 0;
      }
  }
  cout << '1' << endl;

  return 0;
}


Measured memory_bytes: 3620
#include <stdio.h>
#include <math.h>
int main(){
 
  int a,b;
  double c,C,cc;
   
  scanf("%d %d %lf",&a,&b,&C);
 
  C=C*M_PI/180;
   
  printf("%.5lf\n",a*b*sin(C)/2);
 
  cc=a*a+b*b-2*a*b*cos(C);
 
  c=sqrt(cc);
 
  printf("%.5lf\n",a+b+c);
 
  printf("%.5lf\n ",b*sin(C));
 
  return 0;
 
}
 

Measured memory_bytes: 700
def main():
    def fact(n):
        if n == 0:
            return 1
        return n * fact(n-1)
    N = int(input())
    xy = [[int(i) for i in input().split()] for _ in range(N)]
    from math import hypot
    from itertools import permutations
    ans = 0
    for p in permutations(range(N)):
        for i in range(N-1):
            ans += hypot(xy[p[i]][0] - xy[p[i+1]][0],
                         xy[p[i]][1] - xy[p[i+1]][1])
    print(ans/fact(N))


if __name__ == '__main__':
    main()


Measured memory_bytes: 39920
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

using int64 = int64_t;

constexpr int64 MOD = 1000000007;

int main() {
    int N;
    int64 K;
    int64 count[100002];
    fill(count, count+100002, 0);
    cin >> N >> K;
    for (int j = 0; j < N; ++j) {
        int a, b; cin >> a >> b;
        count[a] += b;
    }

    int64 acc = 0;
    for (int j = 0; j <= 100000; ++j) {
        acc += count[j];
        if (acc >= K) {
            cout << j << endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
int main()
{

  int i, j, k, b, f, r, v, n, d[5][4][11];

  for ( i = 0; i < 5; i++)
    {
      for ( j = 0; j < 4; j++)
	{
	  for ( k = 0; k < 11; k++)
	    {
	      d[i][j][k] = 0;
	    }
	}
    }

  scanf("%d", &n);
  for ( i = 0; i < n; i++)
    {
      scanf("%d %d %d %d", &b, &f, &r, &v);
      d[b][f][r] = v + d[b][f][r];
    }

  for ( i = 1; i < 5; i++)
    {
      for ( j = 1; j < 4; j++)
	{
	  for ( k = 1; k < 11; k++)
	    {
	      printf(" %d", d[i][j][k]);
	    }
	  printf("\n");
	}
      if ( i < 4 )
	{
	  for ( b = 0; b < 20; b++)
	    {
	      printf("#");
	    }
	  printf("\n");
	}
    }
  return 0;
}

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

typedef pair<string, int> p;

int main() {

  int n, m;
  
  scanf("%d", &n);
  
  vector<string> s(n);
  
  for(int i = 0; i < n; i++){
    cin >> s[i];
  }

  scanf("%d", &m);
  
  vector<string> t(m);
  
  for(int i = 0; i < m; i++){
    cin >> t[i];
  }
  

  vector<p> counter;
 

  for(int i = 0; i < n; i++){
    bool flag = false;
    for(int j = 0; j < counter.size(); j++){
      if(s[i] == counter[j].first){
        counter[j].second++;
        flag = true;
      }
    }
    if(!flag){
      counter.push_back(make_pair(s[i], 1));
    }
  }
    
  for(int i = 0; i < m; i++){
    bool flag = false;
    for(int j = 0; j < counter.size(); j++){
      if(t[i] == counter[j].first){
        counter[j].second--;
        flag = true;
      }
    }
    if(!flag){
      counter.push_back(make_pair(t[i], -1));
    }
  }
  
  int big = 0;
  for(int j = 0; j < counter.size(); j++){
    if(big < counter[j].second){
      big = counter[j].second;
    }
  }

  cout << big << endl;

}



Measured memory_bytes: 256
li = list(map(int,input().split()))
li.sort()
N = li[0]
M = li[1]

if N == 1:
    if M == 1:
        print(1)
    else:
        print(M-2)
elif N == 2:
    print(0)
else:
    print((N-2)*(M-2))

Measured memory_bytes: 3060
import java.util.Scanner;
public class Main {
    public static final int DICE_NUM = 6;
    public static void main(String[] args) {
	Scanner scan = new Scanner(System.in);
	String[] input = scan.nextLine().split(" ");
	String[] input2 = scan.nextLine().split(" ");
	int[] face1 = new int[6];
	int[] face2 = new int[6];
	for (int i = 0; i < 6; i++) {
	    face1[i] = Integer.parseInt(input[i]);
	    face2[i] = Integer.parseInt(input2[i]);
	}
	Dice dice1 = new Dice(face1);
	Dice dice2 = new Dice(face2);
	if (dice1.checkSameDice(dice2)) {
	    System.out.println("Yes");
	} else {
	    System.out.println("No");
	}
    }
}
class Dice{
    int NORTH = 4;
    int SOUTH = 1;
    int WEST = 3;
    int EAST = 2;
    int TOP = 0;
    int BOTTOM = 5;
    int[] face = new int[6];
	
    Dice(int[] face){
	this.face = face;
    }

    void setFront(int front){
	while(face[SOUTH] != front){
	    turnRight();
	}
    }
    
    void setTop(int top, int bottom){
	int cnt = 0;
	while((face[TOP] != top || face[BOTTOM] != bottom) && cnt < 4){
	    turnSouth();
	    cnt++;
	}
	cnt = 0;
	while((face[TOP] != top || face[BOTTOM] != bottom) && cnt < 4){
	    turnEast();
	    cnt++;
	}
    }

    void turnRight(){
	turnEast();
	turnSouth();
	turnWest();
    }

    void turnEast(){
	int bottom = face[BOTTOM];
	int west = face[WEST];
	face[BOTTOM] = face[EAST];
	face[EAST] = face[TOP];
	face[WEST] = bottom;
	face[TOP] = west;
    }

    void turnWest(){
	int bottom = face[BOTTOM];
	int east = face[EAST];
	face[BOTTOM] = face[WEST];
	face[WEST] = face[TOP];
	face[EAST] = bottom;
	face[TOP] = east;
    }
	
    void turnNorth(){
	int bottom = face[BOTTOM];
	int south = face[SOUTH];
	face[BOTTOM] = face[NORTH];
	face[NORTH] = face[TOP];
	face[SOUTH] = bottom;
	face[TOP] = south;
    }

    void turnSouth(){
	int bottom = face[BOTTOM];
	int north = face[NORTH];
	face[BOTTOM] = face[SOUTH];
	face[SOUTH] = face[TOP];
	face[NORTH] = bottom;
	face[TOP] = north;
    }
    
    int getFace(int index){
	return face[index];
    }

    int getFront(){
	return face[SOUTH];
    }
    
    int getTop() {
	return getFace(TOP);
    }

    boolean checkSameDice(Dice dice2){
	int top1 = getTop();
	int bottom1 = getFace(BOTTOM);
	dice2.setTop(top1, bottom1);
	int[] side1 = new int[8];
	int[] side2 = new int[4];
	for (int i = 0; i < 4; i++) {
	    side1[i] = getFront();
	    side1[i+4]  = getFront();
	    side2[i] = dice2.getFront();
	    turnRight();
	    dice2.turnRight();
	}
	for (int i = 0; i < 4; i++) {
	    if (side1[0+i] == side2[0] && side1[1+i] == side2[1] && side1[2+i] == side2[2] && side1[3+i] == side2[3]) {
		return true;
	    }
	}
	return false;
    }
}
    

Measured memory_bytes: 26356
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1LL << 60
typedef long long int LL;
const int MOD = 1000000007;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }
//sort(all(x))とするとソートできるよ
// 10^x は pow(10,(x)) 
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main(){
    string S;cin >> S;
    int A,B,C,D;
    A = S[0] - '0';
    B = S[1] - '0';
    C = S[2] - '0';
    D = S[3] - '0';
    int op1,op2,op3;
    char o1,o2,o3;
    string ans = "asd";
    int tmp;
    rep(i,2) rep(j,2) rep(k,2){
        if(i)op1 = 1,o1 = '+';
        else op1 = -1,o1 = '-';
        if(j)op2 = 1,o2 = '+';
        else op2 = -1,o2 = '-';
        if(k)op3 = 1,o3 = '+';
        else op3 = -1,o3 = '-';
        tmp = A+(op1*B)+(op2*C)+(op3*D);
        if(tmp == 7){
            ans[0] = o1;
            ans[1] = o2;
            ans[2] = o3;
        }
    }
    cout << S[0] <<ans[0] << S[1] << ans[1] << S[2] << ans[2] << S[3] << "=7" << endl;
}   


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{
	  public static void main(String[] args) throws IOException{
	    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	    int n = Integer.parseInt(br.readLine());
	    System.out.println(n%2 == 1 ? n/2 + 1 : n/2);
	  }
	}

Measured memory_bytes: 21076
from functools import reduce
n = int(input())
al = list(map(int, input().split()))
ansl = [0]*n
test_list = al
  
# printing original list 

  
# List XOR 
# Using reduce() + lambda + "^" operator 
res = reduce(lambda x, y: x ^ y, test_list) 
  
# printing result  
sum = res
for i in range(n):
    ansl[i] = res^al[i]

"""
for i,youso in enumerate(al):
    for j in range(n):
        if i == j:
            continue
        else:
            ansl[j] ^= youso 

"""
print(' '.join(map(str, ansl)))

Measured memory_bytes: 113284
is_prime=[True]*55556
is_prime[0]=is_prime[1]=False

def solve(N):
    ans=[]
    for n in range(2,55556):
        if not is_prime[n]: continue
        if  n%5==1:
            ans.append(n)
        if len(ans)==N: break
        for m in range(n*n,55556,n): is_prime[m]=False
    return ans

N=int(input())
print(' '.join(map(str,solve(N))))


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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;

template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }
template<typename T>
bool isin(T y, T x, T h, T w) { return (0 <= y && 0 <= x && y < h && x < w); }
template<typename T>
bool isin1(T y, T x, T h, T w) { return (0 < y && 0 < x && y <= h && x <= w); }

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

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u; return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}


void Main() {
	string S; cin >> S;
	int prev = 2;
	int cnt = 0;
	for (int i = 0; i < S.size(); i++) {
		if (prev == 2) {
			prev = 1;
		} else {
			if (i > 0 && S[i] == S[i-1]) {
				i++;
				if (i == S.size()) break;
				prev = 2;
			}
		}
		cnt++;
	}
	cout << cnt << endl;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout << fixed << setprecision(20);
	Main();
	return (0);
}


Measured memory_bytes: 720
#include <bits/stdc++.h>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <limits>
#include <string>
#include <vector>

using namespace std;

const long long INF = 1LL << 60;

//各桁の和を出力
long long Sum(long long n) {
  long long m = 0;
  while (n) {
    m += n % 10;
    n /= 10;
  }
  return m;
}

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

void Comuse() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

#define comuse Comuse()
// nCk(comuseを使え)
long long combi(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// pCk(comuseを使え)
long long perm(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] % MOD) % MOD;
}

//最小公倍数(aとbの)
long long lcm(long long a, long long b) {
  long long n;
  n = a / __gcd(a, b) * b;
  return n;
}

// auto A = div(n)
vector<long long> div(long long n) {
  vector<long long> ret;
  for (long long i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) {
        ret.push_back(n / i);
      }
    }
  }
  sort(ret.begin(), ret.end());
  return ret;
}

//(aのn乗をmodで割ったあまり)
long long modpow(long long a, long long n, long long mod) {
  long long ans = 1;
  while (n > 0) {
    if (n & 1) {
      ans = ans * a % mod;
    }

    a = a * a % mod;

    n >>= 1;
  }

  return ans;
}

void solve();

const int MAX_N = 131072;
// segment tree
int NN;
int seg[MAX_N * 2 - 1];
void seguse() {
  for (int i = 0; i < 2 * NN - 1; i++) {
    seg[i] = INT_MAX;
  }
}

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

///////////////////////////////////////////////////////////

int A,B;

void solve() {
  cin >> A >> B;
  for(int i = 0; i < 10000; i++){
    if((int)(i * 0.08) == A && (int)(i * 0.10) == B){
      cout << i <<endl;
      return;
    }
  }
  cout << -1 <<endl;
}


Measured memory_bytes: 256
//#pragma GCC         optimize("O3")
#include            <bits/stdc++.h>
#include            <ext/pb_ds/assoc_container.hpp>
#include            <ext/pb_ds/tree_policy.hpp>
#define FastIO      ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define pb          push_back
#define mp          make_pair
#define mem(x,i)    memset(x,i,sizeof(x))
#define ff          first
#define ss          second
#define popcount(x) __builtin_popcount(x)
#define all(x)      x.begin(),x.end()
#define Case(t)     for(int ks=1;ks<=t;ks++)
#define fileout     freopen("output.txt","w",stdout)
#define filein      freopen("input.txt","r",stdin)
#define D(x)        cerr<< __LINE__ <<": "<< #x << " = "<<(x) <<'\n';
#define endl        '\n'

using namespace std;
using namespace __gnu_pbds;

using ll  = long long;
using ld  = long double;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using pil = pair<int,ll>;

const int INF    = 0x3f3f3f3f;
const ll LL_INF  = 0x3f3f3f3f3f3f3f3f;
const double PI  = acos(-1);
const double eps = 1e-4;
const int mod    = 1e9+7;
const int mx     = 5e5+5;
template <typename T>  using orderedSet =
    tree<T, null_type, less_equal<T>,
    rb_tree_tag, tree_order_statistics_node_update>;//find_by_order,order_of_key*/

/*------------------------------Graph Moves----------------------------*/
//const int fx[]= {+1,-1,+0,+0};
//const int fy[]= {+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*---------------------------------------------------------------------*/

//ll powmod(ll a,ll b){ll res=1;a%=mod;assert(b>=0);for(; b; b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
/*----------------------BitMask-----------------------------------------*/
//inline int setBit(int N,int pos){return N=N | (1<<pos);}
//inline int resetBit(int N,int pos){return N= N & ~(1<<pos);}
//inline bool checkBit(int N,int pos){return (bool) (N& (1<<pos));}

int main()
{
    char c;
    cin>>c;
    if(c=='A') puts("T");
    if(c=='T') puts("A");
    if(c=='C') puts("G");
    if(c=='G') puts("C");
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
#define sc(x) scanf("%d", &x)
#define pb push_back
#define mk make_pair
#define fi first
#define se second
#define ALL(x) x.begin(), x.end()
#define SZ(x) ((int)x.size())
#define sqr(x) ((x)*(x))
#define ABS(x) ((x)>=0?(x):(-(x)))
#define fastio ios::sync_with_stdio(0),cin.tie(0)
template<class T>T gcd(T a, T b){return b?gcd(b, a%b):a;}
const int maxn = 1e2+10;

int main()
{
    int n;
    sc(n);
    list<int> b(n, 0);
    for(auto &u : b)sc(u);
    vector<int> ans;
    for(int i = n-1; i >= 0; i--){
        int val = 1, res = 0;
        auto tmp = b.begin();
        for(auto it = b.begin(); it != b.end(); it++){
            int u = *it;
            if(u == val)res = val, tmp = it;
            val++;
        }
        if(!res){
            printf("-1\n");
            return 0;
        }
        else ans.pb(res), b.erase(tmp);
    }
    reverse(ans.begin(), ans.end());
    for(auto u : ans)printf("%d\n", u);
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,m;cin >> n >> m;
	vector<pair<int,pair<int,int>>> p(m);
	vector<pii> ans(m);
	rep(i,m){
		cin >> p.at(i).first >> p.at(i).second.first;
		p.at(i).second.second=i;
	}
	sort(p.begin(),p.end());
	int i=0;
	while(i<m){
		vector<pii> b;
		int x=p.at(i).first;
		while(i<m && p.at(i).first==x){
			b.pb(p.at(i).second);
			i++;
		}
		sort(b.begin(),b.end());
		rep(j,b.size()){
			ans.at(b.at(j).second)=mp(x,j+1);
		}
	}
	rep(i,m){
		string s="",t="";
		while(ans.at(i).first>0){
			char c='0'+ans.at(i).first%10;
			s=c+s;
			ans.at(i).first/=10;
		}
		while(ans.at(i).second>0){
			char c='0'+ans.at(i).second%10;
			t=c+t;
			ans.at(i).second/=10;
		}
		for(int j=s.size();j<6;++j){
			s="0"+s;
		}
		for(int j=t.size();j<6;++j){
			t="0"+t;
		}
		cout << s << t << endl;
	}
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
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; }
#define pb push_back
#define mp make_pair
#define F .first
#define S .second 
#define pll pair<ll,ll>
using ll=long long;
using ld=long double;
const ll INF = 1LL<<60;
const ll mod=1e9+7;
using namespace std;
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }

int main(){
    ll n;
    string s,t;
    cin>>s>>t;
    ll ans=1e11;
    rep(i,0,s.length()-t.length()+1){
        ll tmp=0;
        rep(j,0,t.length()){
            if(s[i+j]!=t[j])tmp++;
        }
        ans=min(ans,tmp);
    }
    cout<<ans;
}




Measured memory_bytes: 3620