akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
using namespace std;

int a[110];

int main() {
    int N;
	cin >> N;
	for (int i = 0; i < N; i++) cin >> a[i];
	sort(a, a + N);
    reverse(a, a + N);
	int A = 0, B = 0;
	for (int i = 0; i < N; i++) {
        if (i % 2 == 0) {
            A += a[i];
        } else {
            B += a[i];
        }
    }
	cout << A - B << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();
		scan.close();
		if(a < b && b < c) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 26188
#include <vector>
#include <iostream>
using namespace std;
const int M = 1000000007;

long long modexp(int x, long long e, int m) {
    long long ans = 1, p = x % m;
    while (e > 0) {
        if (e % 2 != 0) ans = (ans * p) % m;
        p = (p * p) % m;
        e >>= 1;
    }
    return ans;
}

int main() {
    int n, k; cin >> n >> k;
    vector<int> mu(k+1, 1);
    vector<bool> b(k+1, true);
    for (int p = 2; p <= k; p++) {
        if (b[p]) {
            for (int q = 2*p; q <= k; q += p) b[q] = false;
            for (int q = p; q <= k; q += p) mu[q] *= -1;
            if ((long long)p*p <= k)
                for (int q = p*p; q <= k; q += p*p) mu[q] = 0;
        }
    }
    long long ans = 0;
    for (int a = 1; a <= k; a++)
        for (int b = 1; a*b <= k; b++)
            ans += mu[b] * modexp(k / a / b, n, M) * a % M;
    cout << (ans % M + M) % M << endl;
}


Measured memory_bytes: 3764
#include<bits/stdc++.h>
using namespace std;
const int N=200010;
long long a[N],b[N];
long long n,m,k;

int main(){ 
    cin>>n>>m>>k;
    for(int i=1;i<=n;i++) {
        long long temp;
        cin>>temp;
         a[i]=a[i-1]+temp;
    }
    for(int i=1;i<=m;i++) {
        long long temp;
        cin>>temp;
        b[i]=b[i-1]+temp;
    }
    long long ans=0,j=m;
    for(int i=0;i<=n;i++){
        if(a[i]>k) break;
        while(b[j]>k-a[i]) j--;
        ans=max(i+j,ans);
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 6748
#include <bits/stdc++.h>
#define ll long long
#define all(a) (a).begin(),(a).end()

using namespace std;

int main(int argc, char const *argv[]) {
  int N;
  int sum=0;
  scanf("%d",&N);
  std::vector<int> A(N);
  for (size_t i = 0; i < N; i++) {
    std::cin >> A[i];
    sum+=A[i];
  }
  double ave=(double)sum/N;
  int point=0;
  int averag=round(ave);
  for (size_t i = 0; i < N; i++) {
    point+=pow(A[i]-averag,2);
  }
  printf("%d\n",point);
  return 0;
}


Measured memory_bytes: 256
/*
一个点从u移到相邻节点v时，若删掉(u,v)后u这边的连通块大小为sizu，v这边的连通块大小为sizv，那么dv=du−sizv+sizu
所以考虑按d从大到小（也就是从叶子向上，这样能得到正确的siz）的顺序确定每个点x的父亲：这个点的d必须是dx−(n−sizx)+sizx
然后判一下根
*/
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 7;
int n, v2[N], fa[N], sz[N];
long long v[N], ds[N];
map<long long, int> tp;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++)
    scanf("%lld", &v[i]), tp[v[i]] = v2[i] = i, sz[i] = 1;
  sort(v2 + 1, v2 + n + 1, [&](int a, int b) {return v[a] < v[b];});
  for (int i = n; i > 1; i--) {
    long long tp2 = v[v2[i]] - n + sz[v2[i]] * 2;
    if (!tp[tp2]) return 0 & puts("-1");
    int sb = tp[tp2];
    ds[sb] += ds[v2[i]] + sz[v2[i]];
    sz[sb] += sz[v2[i]];
    fa[v2[i]] = sb;
  }
  if (ds[v2[1]] != v[v2[1]]) {printf("-1\n"); return 0;}
  for (int i = 1; i <= n; i++)if (fa[i])
      printf("%d %d\n", i, fa[i]);
  return 0;
}

Measured memory_bytes: 10368
n,k = gets.split.map(&:to_f)
p = 0
n.to_i.times do |i|
  j = 0
  count = 0
  while (i+1) * 2**j < k
    j += 1
    count +=1
  end
  p += 1/n * (1/(2**count).to_f)
end
puts p

Measured memory_bytes: 1916
using System;

namespace aoj5a
{
    class Program
    {
        static int Main(string[] args)
        {
            for (;;)
            {
                string[]HandW = (Console.ReadLine()).Split(' ');
                int H = int.Parse(HandW[0]);
                int W = int.Parse(HandW[1]);

                if(H+W == 0)
                {
                    return 0;
                }

                for (int i = 1; i <= H; i++)
                {
                    for (int j= 1; j <= W; j++)
                    {
                        bool frame = false;
                        if ((i+j)%2 == 0)
                        {
                            frame = true;
                        }
                        Console.Write(frame ? '#' : '.');
                    }
                    Console.WriteLine();
                }
                Console.WriteLine();
            }


            
        }
    }
}

Measured memory_bytes: 8780
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10

#solve
def solve():
    a, b, c, k = LI()
    ans = a * (-1) ** k - b * (-1) ** k
    if abs(ans) > 10 ** 18:
        print("Unfair")
    else:
        print(ans)
    return


#main
if __name__ == '__main__':
    solve()


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

const int INF = 1<<28;

int dfs(int pi, int pj, int c, bool &flag, vector<vector<int> > &g) {
  static int di[] = {0,1,1, 0,-1,-1};
  static int dj[] = {1,1,0,-1,-1, 0};
  g[pi][pj] = -1;
  int res = 1;
  for(int k = 0; k < 6; ++k) {
    int ni = pi + di[k];
    int nj = pj + dj[k];
    if(ni < 0 || ni >= g.size()) continue;
    if(nj < 0 || nj >= g[ni].size()) continue;
    if(g[ni][nj] == 0) flag = true;
    if(g[ni][nj] != c) continue;
    res += dfs(ni, nj, c, flag, g);
  }
  return res;
}

int main() {
  for(int N, C; cin >> N >> C && (N|C); ) {
    vector<vector<int> > G(N);
    for(int i = 0; i < N; ++i) {
      G[i].resize(i+1);
      for(int j = 0; j <= i; ++j) {
        cin >> G[i][j];
      }
    }

    int res = -INF;
    for(int i = 0; i < N; ++i) {
      for(int j = 0; j <= i; ++j) {
        if(G[i][j] == 0) {
          vector<vector<int> > g = G;
          g[i][j] = C;
          int sum = 0;
          for(int a = 0; a < N; ++a) {
            for(int b = 0; b <= a; ++b) {
              if(g[a][b] > 0) {
                bool flag = false;
                int d = (g[a][b] == C ? -1 : 1);
                int tmp = dfs(a, b, g[a][b], flag, g);
                if(!flag) {
                  sum += tmp * d;
                }
              }
            }
          }
          res = max(res, sum);
        }
      }
    }
    cout << res << endl;
  }
  return 0;
}

Measured memory_bytes: 1220
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstdlib>
using namespace std;

int main(){
  int A, B;
  cin >> A >> B;
  if (B % A == 0) {
    cout << A+B << endl;
  } else {
    cout << B-A << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

ll n,a[100001];
ll ans[100001];
int main(){
    cin>>n;
    ll sum=0,sum2=0;
    rep(i,n){
        cin>>a[i],sum+=a[i];
        if(i&1) sum2+=a[i];
    }
    ans[0]=sum-sum2*2;
    FOR(i,1,n) ans[i]=a[i-1]*2-ans[i-1];
    rep(i,n) cout<<ans[i]<<" ";
    cout<<endl;
    return 0;
}


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

int main(){
  int N,M,ans=0,a;
  cin>>N>>M;
  
  for(int i=0;i<M;i++){
    cin>>a;
    ans+=a;
  }
  ans=N-ans;
  if(ans>=0)cout<<ans;
  else cout<<-1;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#define dbg(x...) do { cout << "\033[32;1m " << #x << " -> "; err(x); } while (0)
void err() { cout << "\033[39;0m" << endl; }
template<template<typename...> class T, typename t, typename... A>
void err(T<t> a, A... x) { for (auto v: a) cout << v << ' '; err(x...); }
template<typename T, typename... A>
void err(T a, A... x) { cout << a << ' '; err(x...); }
#else
#define dbg(...)
#endif
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;
template<class T> void mkuni(vector<T>&v)
{
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
}
template<class T>
void print(T x,int suc=1)
{
    cout<<x;
    if(suc==1) cout<<'\n';
    else cout<<' ';
}
template<class T>
void print(const vector<T>&v,int suc=1)
{
    for(int i=0;i<v.size();i++)
    print(v[i],i==(int)(v.size())-1?suc:2);
}
const int maxn=2e5+7;
int nxt[maxn][26];
bool vis[maxn];
pi pre[maxn];
string s;
void pr(pi x)
{
    if(x.first)
        pr(pre[x.first]);
    cout<<(char)(x.second+'a');
}
int main()
{
    cin>>s;
    int cur[26];
    memset(cur,-1,sizeof(cur));
    for(int i=0;i<26;i++) cur[i]=maxn-1;
    for(int i=0;i<maxn;i++)
    {
        for(int j=0;j<26;j++) nxt[i][j]=maxn-1;
    }
    for(int i=s.length();i>=0;i--)
    {
        for(int j=0;j<26;j++) nxt[i][j]=cur[j];
        if(i)
            cur[s[i-1]-'a']=i;
    }
    queue<int> q;
    q.push(0);
    vis[0]=1;
    while(!q.empty())
    {
        auto u=q.front();q.pop();
        //dbg(u.id);
        if(u==maxn-1)
        {
            pr(pre[u]);
            cout<<'\n';
            break;
        }
        for(int j=0;j<26;j++)
        {
            int nn=nxt[u][j];
            if(!vis[nn])
            {
                vis[nn]=1;
                pre[nn]=make_pair(u,j);
                q.push(nn);
            }
        }
    }
}

Measured memory_bytes: 22916
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,k;
  cin>>n>>k;
  char s[n+1];
  cin>>s;
  for(int i=0;i<n;i++)
  {
    if(i+1==k)
    {
      s[i]=s[i]+32;
    }
  }
cout<<s;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <algorithm>

using namespace std;

template <typename T>
void WriteLine_Container(const T& container);
void InsertionSort(vector<int>& v, int n, int g, int& cnt);
void ShellSort(vector<int>& v, int n);

int main() {
    int len;
    cin >> len;
    vector<int> A(len);
    for (int i = 0; i < len; i++) cin >> A[i];

    ShellSort(A, A.size());

    for_each(A.begin(), A.end(), [](int x) {
        cout << x << endl;
    });

    return 0;
}



template <typename T>
void WriteLine_Container(T& container) {

    auto it = container.begin();
    while (true) {
        cout << *it;
        it++;
        if (it == container.end()) break;
        else cout << " ";
    }
    cout << endl;
}


void InsertionSort(vector<int>& v, int n, int g, int& cnt) {
    for (int i = g; i < n; i++) {
        int temp = v[i];
        int j = i - g;
        while (j >= 0 && v[j] > temp) {
            v[j + g] = v[j];
            j = j - g;
            cnt++;
        }
        v[j + g] = temp;
    }
}


void ShellSort(vector<int>& v, int n) {
    int cnt = 0;

    list<int> li;
    li.push_front(1);
    
    for (int i = 4; i < v.size(); i = i * 3 + 1) {
        li.push_front(i);
    }
    int m = li.size();

    cout << m << endl;
    
    WriteLine_Container(li);
    
    for_each(li.begin(), li.end(), [&](int x) {
        InsertionSort(v, n, x, cnt);
    });

    
    cout << cnt << endl;
}

Measured memory_bytes: 6704
#include<stdio.h>{

	int main(){
		int max=0,x=0,i,n;
		char S[n];
		scanf("%d",&n);
		scanf("%s",S);
		for(i=0;i<n;i++){
			if(S[i]=='I'){
				x++;
			}
			else{
				x--;
			}
			if(x>max){
				max=x;
			}
		}
		printf("%d",max);
	}

Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int n,K,A[1001010];
int Gcd(int a,int b){
	if (!b) return a;
	return Gcd(b,a%b);
}
int main(){
	scanf("%d %d",&n,&K);
	int g=0,Max=0;
	for (int i=1;i<=n;i++){
		scanf("%d",&A[i]);
		g=Gcd(g,A[i]);
		Max=max(Max,A[i]);
	}
	if (Max<K){
		cout<<"IMPOSSIBLE"; return 0;
	}
	for (int i=1;i<=n;i++)
		if (A[i]>=K&&(A[i]-K)%g==0){
			cout<<"POSSIBLE"; return 0;
		}
	cout<<"IMPOSSIBLE";
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define Mod 1000000007
#define eps 1e-6
#define ll long long
#define INF 0x3f3f3f3f
#define MEM(x, y) memset(x, y, sizeof(x))
#define Maxn 1000000 + 10
using namespace std;
int N;
int len[Maxn];
int result = 0;
int main()
{
    int a,b;
    cin>>a>>b;
    if(a>9||b>9)
    cout<<-1<<endl;
    else
    {
        cout<<a*b<<endl;
    }
    
}


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

def parse(s):
    if '.' not in s:
        return int(s)*10**9
    else:
        n = len(s)-s.find('.')
        s = s[:-n]+s[-n+1:]+(10-n)*'0'
        return  int(s)

A = [parse(input()) for _ in range(N)]
count = []
for i in range(N):
    n2 = 0
    n5 = 0
    n = A[i]
    while True:
        if n%2==0:
            n2 += 1
            n//=2
        else:
            break
    while True:
        if n%5==0:
            n5 += 1
            n//=5
        else:
            break
    n2 = min(n2,18)
    n5 = min(n5,18)
    count.append((n2,n5))

d = {}
for i in range(19):
    for j in range(19):
        d[(i,j)] = 0
for i in range(N):
    d[count[i]] += 1

dsum = {}
for i in range(19):
    for j in range(19):
        dsum[(i,j)] = 0
        for k in range(18-i,19):
            for l in range(18-j,19):
                dsum[(i,j)] += d[(k,l)]

ans = 0
for i in range(N):
    ans += dsum[count[i]]
    if count[i][0]>=9 and count[i][1]>=9:
        ans -= 1
ans //= 2
print(ans)

Measured memory_bytes: 100432
#include <bits/stdc++.h>
#define fst first
#define snd second
#define pb push_back
#define eb emplace_back
#define mt make_tuple
using namespace std;

const int N = 100005;

int a, b, c, aa, bb, cc;

int main() {
	scanf("%d%d%d", &a, &b, &c);
	aa = a, bb = b, cc = c;
	int ans = 0;
	while (true) {
		if (aa & 1 || bb & 1 || cc & 1) break;
		if (ans > 1 && a == aa && b == bb && c == cc) {
			ans = -1;
			break;
		}
		int ta = bb / 2 + cc / 2;
		int tb = aa / 2 + cc / 2;
		int tc = aa / 2 + bb / 2;
		aa = ta, bb = tb, cc = tb;
		ans++;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
/*siddharth goyal*/
#include<bits/stdc++.h>
using namespace std;
#define   pb              push_back
#define   REP(i,n)        for(i=1;i<=n;i++)
#define   FOR(i,a,b)      for(i=a;i<=b;i++)
#define   all(v)          v.begin(),v.end()
#define   F               first
#define   S               second
#define   vl              vector<LL>
#define   itr             ::iterator it
#define   lb              lower_bound
#define   ub              upper_bound
#define   LL              long long
#define   ULL             unsigned long long
#define   ret             return 
LL n,i,j,ans = 0;
int main()
{   // Read the constraints,highlights,Time Limit,Test Cases
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n ; 
    LL x,gcd = 0 ; 
    REP(i,n) 
      cin>>x , gcd = __gcd(x,gcd) ; 
    cout<<gcd ; 
}
//Check for 0,1 and other corner cases.

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
 
struct word{
  char data[33];
};
struct word in[400];
 
int main(){
  
  char a[33];
  int count[400];
  int i,j,ans1,ans2,p=0,temp,max,lengs;
   
  for(i=0;i<400;i++){
    if(scanf("%s", &a)==EOF){
      p=1;
      temp=i;
    }
    in[i]=*(struct word *)a;
    if(p==1) break;
  }
  max=-1;
 
  for(i=0;i<temp;i++){
    lengs=strlen(in[i].data);
    if(lengs>max){
      max=lengs;
      ans1=i;
    }
  }
  for(i=0;i<temp;i++){
    count[i]=0;
  }
  for(i=0;i<temp;i++){
    for(j=0;j<i;j++){
      if(strcmp(in[i].data,in[j].data)==0){
    count[j]++;
      }
    }
  }
  max=-1;
  for(i=0;i<temp;i++){
    if(max<count[i]){
      max=count[i];
      ans2=i;
    }
  }
   
  printf("%s %s\n", in[ans2].data, in[ans1].data);
 
  return 0;
}

Measured memory_bytes: 564
#include <algorithm>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <random>
#include <set>
#include <stdio.h>
#include <string>
#include <utility>
#include <vector>

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<pair<double, double>> ps(n);
  pair<double, double> g = make_pair(0, 0);
  for (int i = 0; i < n; i++)
    cin >> ps[i].first >> ps[i].second;
  for (int i = 0; i < n; i++) {
    g.first += ps[i].first;
    g.second += ps[i].second;
  }
  g.first /= n;
  g.second /= n;
  for (int i = 0; i < n; i++) {
    ps[i].first -= g.first;
    ps[i].second -= g.second;
  }
  vector<double> ans(n);
  long long m = 1000000;
  for (int i = 0; i < m; i++) {
    double x = cos(M_PI * i * 2 / m), y = sin(M_PI * i * 2 / m);
    int id = 0;
    double maxV = -1145141919;
    for (int j = 0; j < n; j++) {
      double val = x * ps[j].first + y * ps[j].second;
      if (maxV < val) {
        maxV = val;
        id = j;
      }
    }
    ans[id] += 1;
  }
  for (int i = 0; i < n; i++) {
    printf("%.6lf\n", ans[i] / m);
  }
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
using ll = long long;
using ii = pair<int, int>;
using vi = vector<int>;

#define errp(...) fprintf(stderr, __VA_ARGS__)

const int N = 100010;
char s[N];
int n;

bool can () {
	string a = string(s), tmp;
	while (!a.empty()) {
		if (a.size() < 5) return false;
		tmp = a.substr(a.size() - 5, 5);
		if (tmp == "erase" || tmp == "dream") {
			for (int i = 0; i < 5; i++) a.pop_back();
			continue;
		}
		if (a.size() < 6) return false;
		tmp = a.substr(a.size() - 6, 6);
		if (tmp == "eraser") {
			for (int i = 0; i < 6; i++) a.pop_back();
			continue;
		}
		if (a.size() < 7) return false;
		tmp = a.substr(a.size() - 7, 7);
		if (tmp == "dreamer") {
			for (int i = 0; i < 7; i++) a.pop_back();
		}
		else return false;
	}
	return true;
}

int main () { 
	scanf("%s", s);
	n = strlen(s);
	if (can()) printf("YES\n");
	else printf("NO\n");	
}

Measured memory_bytes: 384
{-# LANGUAGE BangPatterns #-}
import Control.Monad
import Data.Maybe
import Debug.Trace
import Data.List
import qualified Data.Map.Strict as Map
import qualified Data.IntMap.Strict as IntMap
import qualified Data.Set as Set
import qualified Data.IntSet as IntSet
import Data.Functor
import Data.Array
-- import Data.Array.Unboxed
import Control.Monad.ST
import Data.Array.ST
import Data.Char
import qualified Data.ByteString.Char8 as B
import Data.Maybe (fromJust)

main :: IO ()
main = B.getLine >>= putStrLn . unwords . map show . solve . B.unpack

solve :: String -> [Int]
solve = toList . go 0 
  where
    go _ [] = []
    go i ('R':'L':ss) = (i, j):(go 0 $ dropWhile (=='L') ss)
      where
        j = length $ takeWhile (=='L') ss
    go i ('R':ss) = go (i + 1) ss
    
    toList [] = []
    toList ((i, j):ijs) = (replicate i 0) 
      ++ [x + j `mod` 2, x + i `mod` 2 ] 
      ++ (replicate j 0) 
      ++ (toList ijs)
        where
          x = 1 + i `div` 2 + j `div` 2



Measured memory_bytes: 5756
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

int main(void) {
    string s,t;

    cin>>s>>t;

    sort(s.begin(),s.end());
    sort(t.begin(),t.end(),greater<char>());
    if(s < t) {
        cout<<"Yes"<<endl;
    } else {
        cout<<"No"<<endl;
    }

    return 0;
}




Measured memory_bytes: 888
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	nums := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&nums[i])
	}

	count := 0
	f := true
	for f {
		for i, t := range nums {
			if t%2 == 0 {
				nums[i] /= 2
			} else {
				f = false
			}
		}
		if f {
			count++
		}
	}
	fmt.Println(count)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<27;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-11;
const ll mod=1e9+7;
//const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
const int dx[13]={1,0,0,1,1,1,1,0,0,1,1,1,1};
const int dy[13]={0,1,0,1,-1,0,0,1,1,1,-1,1,-1};
const int dz[13]={0,0,1,0,0,1,-1,1,-1,1,1,-1,-1};

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	while(1){
		int n;
		cin>>n;
		ll t=0;
		for(int i=0;i<n;i++){
			int p,x;
			char c;
			cin>>p>>c>>x;
			t+=x*(c=='('?1:-1);
			cout<<(t==0?"Yes":"No")<<endl;
		}
		break;
	}
}


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

int price = 700;
char optional[3] = {0};

int solve() {
  for (int i = 0; i < 3; i++) {
    if (optional[i] == 'o') price += 100;
  }
  return price;
}

int main() {
  cin >> optional;
  printf("%d\n", solve());
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		
		Scanner s = new Scanner(System.in);
		
		int d = s.nextInt();
		int t = s.nextInt();
		int ss = s.nextInt();
		
		if(Math.ceil((double)d / (double)ss) <= t)
			System.out.println("Yes");
		else
			System.out.println("No");

	}

}

Measured memory_bytes: 35716
from itertools import product

N, M = map(int, input().split())
S = []
for _ in range(M):
    _, *s = map(int, input().split())
    S.append(s)
P = [int(s) for s in input().split()]

cnt = 0
for ss in product([0, 1], repeat=N):
    for i in range(M):
        if sum(ss[sj - 1] for sj in S[i]) % 2 != P[i]:
            break
    else:
        cnt += 1

print(cnt)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(){
 int a,b,i,f,r;bool c[21][21];char ch;
 while(cin>>i,i){
  memset(c,0,sizeof(c));
  while(i--)cin>>a>>b,c[a][b]=1;
  cin>>i,a=b=10,c[a][b]=0;
  while(i--){
   cin>>ch>>f;
   while(f--){
    switch (ch) {
     case 'N':b++;break;
     case 'E':a++;break;
     case 'S':b--;break;
     case 'W':a--;break;
    }
    c[a][b]=0;
   }
  }
  a=b=20,f=0;
  while(a--)for(r=0;r<21;r++)if(c[a][r])f++;
  cout<<(f?"No":"Yes")<<endl;
 }
}

Measured memory_bytes: 3028
import java.io.*;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		Scanner scan = new Scanner(System.in);
        String s = scan.next();
        int a = Integer.parseInt(s);
         s = scan.next();
        int b = Integer.parseInt(s);
        
        if (a > b){
        	System.out.println("a > b");
        }
        if (a < b){
        	System.out.println("a < b");
        }
        if (a == b){
        	System.out.println("a == b");
        }
		
	}
}

Measured memory_bytes: 25888
#include<iostream>
using namespace std;
long long N, K, A[1<<18];
int main(){
  cin>>N>>K;
  for(int i=1; i<=N; i++) cin>>A[i];
  for(int i=K+1; i<=N; i++) {
    if(A[i-K]<A[i]) cout<<"Yes"<<endl;
    else
      cout<<"No"<<endl;
  }
  return 0;
}

Measured memory_bytes: 5184
#include <stdio.h>
#include <iostream>
#include <cstdio>
#include <algorithm> 
#include <stdio.h>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <list>
#include <utility>
#include <set>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <bitset>
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include <random>

using namespace std;

static const double EPS = 1e-9;
template<class T> bool INRANGE(T x, T a, T b) { return a <= x && x <= b; }
template<class T> void amin(T &a, T v) { if (a > v) a = v; }
template<class T> void amax(T &a, T v) { if (a < v) a = v; }
int ROUND(double x) { return (int)(x + 0.5); }
bool ISINT(double x) { return fabs(ROUND(x) - x) <= EPS; }
bool ISEQUAL(double x, double y) { return fabs(x - y) <= EPS * max(1.0, max(fabs(x), fabs(y))); }
double SQSUM(double x, double y) { return x * x + y * y; }
#define PI  (acos(-1))
#define ARRAY_NUM(a) (sizeof(a)/sizeof(a[0])) 
#define NG (-1)
#define BIG ((int)1e9+10)
#define BIGLL ((ll)4e18)
#define SZ(a) ((int)(a).size())
#define SQ(a) ((a)*(a))
typedef unsigned long long ull;
typedef long long ll;



int main()
{
	int n, a, b, c, d;
	cin >> n >> a >> b >> c >> d;
	a--;
	b--;
	c--;
	d--;

	string s;
	cin >> s;

	bool ok = true;

	for (int i=a;i<c;i++)
	{
		if (s[i] == '#' && s[i + 1] == '#')
		{
			ok = false;
		}
	}

	for (int i = b; i<d; i++)
	{
		if (s[i] == '#' && s[i + 1] == '#')
		{
			ok = false;
		}
	}


	if (c > d && ok)
	{
		ok = false;
		for (int i=b; i<=d;i++)
		{
			if (s[i-1]=='.' && s[i + 1] == '.'&& s[i] == '.')
			{
				ok = true;
			}
		}
	}






	if (ok)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}




	return 0;
}


Measured memory_bytes: 640
def main17():
    buf = input("");
    bufs = buf.split();
    hai = [];
    for i in range(len(bufs)):
        hai.append(int(bufs[i]));
    buf = input("");
    bufs = buf.split();
    hai2 = [];
    pen = 0;
    for i in range(len(bufs)):
        hai2.append(int(bufs[i]));
    for i in range(len(hai2)):
        if hai[2] < hai2[i]:
            break;
        else:
            pen = pen + 1;
    if pen < len(hai2) / 2:
        print(pen);
    else:
        print((len(hai2) - pen));




if __name__ == '__main__':
    main17()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef long double ld;
const double pi=acos(-1.0);
const ll mod=pow(10,9)+7;
const ll INF=pow(2,31)-1;
typedef pair<int,int> P;
typedef vector<int> vi;

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

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

int main(){
    ios::sync_with_stdio(false);
    int n,m; cin >>n >> m;
    int k[35];
    int a[35][35];
    int cnt[35]={};
    rep(i,n){
        cin >> k[i];
        rep(j,k[i]){
            cin >> a[i][j];
            cnt[a[i][j]-1]++;
        }
    }
    int ans=0;
    rep(i,sizeof(cnt)/sizeof(*cnt)){
        if(cnt[i]==n) ans++;
    }
    cout << ans << endl;
    return 0;
}

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

#define fast ios_base::sync_with_stdio(false),cin.tie(NULL)
#define ldb long double 
#define db double
#define int long long

#define fr first
#define se second
#define lb lower_bound 
#define ub upper_bound 
#define pb push_back
#define mpr make_pair

#define pi pair<int,int>
#define pdb pair<db,db>
#define pldb pair<ldb,ldb>

#define vi vector<int>
#define vdb vector<db>
#define vldb vector<ldb>
#define vpi vector< pi >

#define mi map<int,int>
#define mdb map<db,db>
#define mldb map<ldb,ldb>


#define forr(a,b) for (int i = (a); i < (b); ++i)
#define rrof(a,b) for (int i = (b)-1; i >= (a); --i)

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)

const int md = 1e9+7;
const int MX = 2e5+5;
const int INF = 1e18; 
const ldb PI = 4*atan((ldb)1);

int power_md(int a,int n)
{
 int res=1;
 while(n)
{
 if(n%2)
  res=(res%md*a%md)%md;
  a=(a%md*a%md)%md;
  n/=2;
}
res%=md;
return res;
}

int power(int a,int n)
{
 int res=1;
 while(n)
{
 if(n%2)
  res*=a;
  a=a*a;
  n/=2;
}
return res;
}

int abst(int a)
{
 return ((a<0)?(-1*a):(a));
}

class cmp_set{
public:
	bool operator() (int a, int b){
		return a > b;
	}
};

vector<string> vec_splitter(string s) {
	s += ',';
	vector<string> res;
	while(!s.empty()) {
		res.push_back(s.substr(0, s.find(',')));
		s = s.substr(s.find(',') + 1);
	}
	return res;
}
void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx, 
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; } 
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
	if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
	stringstream ss; ss << H;
	cerr << args[idx] << " = " << ss.str();
	debug_out(args, idx + 1, LINE_NUM, T...);
}
#ifdef XOX
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif

/*int ter_search(int l,int r)
{
    while((r-l)>0)
    {
        int m1=l+(r-l)/3;
        int m2=r-(r-l)/3;
        int f1=f(m1);
        int f2=f(m2);
        if(f1>f2)
         l=m1+1;
         else
          r=m2-1;
    }
    return f(l);
}*/

int32_t main()
{
    int x;
    cin>>x;
    if(x==7||x==5||x==3)
    cout<<"YES\n";
    else
     cout<<"NO\n";
     return 0;
}

Measured memory_bytes: 3548
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)
N = parse(readline())
A = parseMap(split(readline()))
B = parseMap(split(readline()))
before_monster = sum(A)
for i in 1:N
    if A[i] > B[i]
        A[i] -= B[i]
    else
        A[i+1] = maximum([A[i+1] - (B[i] - A[i]),0])
  		A[i] = 0  
  end
end             
println(before_monster - sum(A))

Measured memory_bytes: 152780
#include <iostream>
#include <deque> 
#include <string> 
using namespace std;
int main(void){
    
    string s;
    cin >> s;
    deque<char> dq;
    
    for(int i=0;i<s.size();i++){
        dq.push_back(s[i]);
    }
    
    int q;
    cin >> q;
    
    int que,rl;
    char c;
    int state = 1;
    while(q--){
        
        cin >> que;
        
        if(que==1){
            state *= -1;
        }else{
            cin >> rl >> c;
            if((state==1&&rl==1 )||(state==-1&&rl==2)){
                dq.push_front(c);
            }else{
                dq.push_back(c);
            }
        }
        // cout << "a" << endl;
    }
    // cout << state << endl;
    if(state==1){
        for(int i=0;i<dq.size();i++){
            cout << dq[i];
        }
    }else{
        for(int i=dq.size()-1;i>=0;i--){
            cout << dq[i];
        }
    }
    cout << endl;
}


Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<map>
#include<iomanip>
#include<tuple>
#include<bitset>


using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define printfloat(x) cout << fixed << setprecision(7) << (x) << endl;
#define printbit(x) cout << bitset<15>(x) << endl;
using ll = long long int;



long double pi = 3.14159265359;

string s,t;
int ans;
int main(){
    cin >> s >> t;
    rep(i,3){
        if(s[i] == t[i]){
            ans ++;
        }
    }
    cout << ans << endl;

return 0;
}

Measured memory_bytes: 3624
#include <deque>
#include <cstdio>
#include <algorithm>
#pragma warning(disable : 4996)
using namespace std;
struct state { long long a, b; };
inline bool operator<(const state& s1, const state& s2) { return s1.a < s2.a; }
int N; long long D, A[33], B[33];
long long sa1[32777], sb1[32777], sa2[32777], sb2[32777]; // bit-dp sum
int cnt1, cnt2; state vl[14348922], vr[14348922]; // meet-in-the middle
int que[14348922]; // searching deque
int main() {
	scanf("%d%lld", &N, &D);
	for (int i = 0; i < N; i++) scanf("%lld%lld", &A[i], &B[i]);

	// Meet-in-the-middle Algorithm
	int sep1 = (N >> 1), sep2 = N - sep1;
	for (int i = 0; i < sep1; i++) {
		int b1 = (1 << i), b2 = (1 << (i + 1));
		for (int j = b1; j < b2; j++) {
			sa1[j] = sa1[j - b1] + A[i];
			sb1[j] = sb1[j - b1] + B[i];
		}
	}
	for (int i = 0; i < sep2; i++) {
		int b1 = (1 << i), b2 = (1 << (i + 1));
		for (int j = b1; j < b2; j++) {
			sa2[j] = sa2[j - b1] + A[i + sep1];
			sb2[j] = sb2[j - b1] + B[i + sep1];
		}
	}
	cnt1 = 0;
	for (int i = 0; i < 1 << sep1; i++) {
		int r = (1 << sep1) - i - 1, j = r;
		do {
			// i -> remain, j -> anna, k -> bruno
			int k = r - j;
			vl[cnt1++] = state{ sa1[k] - sa1[j], sb1[k] - sb1[j] };
			j = (j - 1) & r;
		} while (j != r);
	}
	cnt2 = 0;
	for (int i = 0; i < 1 << sep2; i++) {
		int r = (1 << sep2) - i - 1, j = r;
		do {
			// i -> remain, j -> anna, k -> bruno
			int k = r - j;
			vr[cnt2++] = state{ sa2[k] - sa2[j], sb2[k] - sb2[j] };
			j = (j - 1) & r;
		} while (j != r);
	}
	sort(vl, vl + cnt1);
	sort(vr, vr + cnt2);
	int cl = 0, cr = 0, dl = 0, dr = 0;
	long long ret = 0;
	for (int i = cnt2 - 1; i >= 0; i--) {
		while (cr < cnt1 && vl[cr].a + vr[i].a <= D) {
			while ((dr - dl) && vl[que[dr - 1]].b <= vl[cr].b) dr--;
			que[dr++] = cr++;
		}
		while (cl < cnt1 && vl[cl].a + vr[i].a < -D) {
			if ((dr - dl) && que[dl] == cl) dl++;
			cl++;
		}
		if (dr - dl) ret = max(ret, vr[i].b + vl[que[dl]].b);
	}
	printf("%lld\n", ret);
	return 0;
}

Measured memory_bytes: 457940
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
using P = pair<int,int>;
int dp[110000][3];
int act[110000][3];
int main()
{
    int n;
    cin >> n;
    rep(i,n)rep(j,3)cin >> act[i][j];
    rep(i,n)rep(j,3){
        dp[i+1][(j+1)%3] = max(dp[i+1][(j+1)%3],dp[i][j] + act[i][(j+1)%3]);
        dp[i+1][(j+2)%3] = max(dp[i+1][(j+2)%3],dp[i][j] + act[i][(j+2)%3]);
    }
    cout << max({dp[n][0],dp[n][1],dp[n][2]}) << endl;

    return 0;
}

Measured memory_bytes: 2560
import java.util.*;
public class Main{
	public static void main(String[] args){
      	Scanner sc = new Scanner(System.in);
    	int a = sc.nextInt();
      	int b = sc.nextInt();
      	double t = sc.nextDouble();
      	int sec = (int)((t+0.5)/a);
      	int sum = b*sec;
      	System.out.println(sum);
    }
}

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

namespace agc027_a
{
	class Program
	{
		static void Main(string[] args)
		{
			long[] x = Console.ReadLine().Split().Select(long.Parse).ToArray();
			long[] a = Console.ReadLine().Split().Select(long.Parse).ToArray();
			Array.Sort(a);
			int ret = 0;
			for (int i = 0; i < x[0] && x[1] >= a[i]; i++)
			{
				x[1] -= a[i];
				ret++;
			}
			if (ret == x[0] && x[1] > 0) ret--;
			Console.WriteLine(ret);
		}
	}
}

Measured memory_bytes: 13524
import java.util.Scanner;

public class Main {
    public static void main (String[] args)
    {
        int h, w, i;
        String[] sh = new String[1000];
        String[] sw = new String[1000];
        Scanner sc = new Scanner(System.in);

        try
        {
            for (i = 0; true; i++)
            {
                sh[i] = sc.next();
                sw[i] = sc.next();
                if (sw[i].equals("0") && sh[i].equals("0")) break;
            }

            sc.close();

            int I = i;

            for (i = 0; i < I; i++)
            {
                h = Integer.parseInt(sh[i]);
                w = Integer.parseInt(sw[i]);

                for (int j = 1; j <= h; j++)
                {
                    for (int k = 1; k <= w; k++)
                    {
                        if (k == 1 || k == w || j == 1 || j == h) System.out.print("#");
                        else System.out.print(".");
                    }
                    System.out.println();
                }
                System.out.println();
            }
        }
        catch (NumberFormatException e)
        {
            System.out.println(e);
        }
    }
}


Measured memory_bytes: 35180
#include<bits/stdc++.h>
#include<string>
using namespace std;
#define rt return
#define ll long long int
#define ff first
#define ss second
#define pb push_back
int t;
string str;
//#define vl
map<pair<string,string>,int> mp;
int main()
{
    int n; string s;
   cin >> n >> s;
   ll ans=0;
    for(ll mask=0;mask<(1<<n);mask+=1){
      string a, b;
      for(ll i=0;i<n;i++){
         if (mask & (1<<i)) {
            a.push_back(s[i]);
         } else {
            b.push_back(s[i]);
         }
      }
      mp[{a, b}]++;
   }

   string t = s;
   reverse(t.begin(),t.end());
   for(ll mask=0;mask<(1<<n);mask+=1){
      string a, b;
      for(ll i=0;i<n;i++){
         if (mask & (1<<i)) {
            a.push_back(t[i]);
         } else {
            b.push_back(t[i]);
         }
      }
      ans += mp[{a, b}];
   }
   cout << ans << endl;

    rt 0;
}


Measured memory_bytes: 91904
n = int(input())
l1 = []
for i in range(n):
    l1.append(int(input()))
l2 = sorted(l1, reverse=True)
m1 = l2[0]
m2 = l2[1]
for i in range(n):
    if (l1[i] == m1):
        print(m2)
    else:
        print(m1)


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

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  
  for (int i = 0; i < N; i++)
  {
    cin >> a.at(i); 
  }

  int x = a.at(0) - 1;
  int cnt = 1;
  for (int i = 1; i < N; i++)
  {
     if(x == 1) {
       cout << cnt << endl;
       return 0;
     } else
     {
       x = a.at(x) - 1;
       cnt++;
     }
  }

  cout << -1 << endl;
  
}

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

int main(void) {
	int a,b;
	char op;

	while(1) {
		cin >> a >> op >> b;
		switch(op) {
			case '+':
			cout << a+b << endl;
			continue;
			case '-':
			cout << a-b << endl;
			continue;
			case '*':
			cout << a*b << endl;
			continue;
			case '/':
			cout <<  floor(a/b) << endl;
			continue;
			case '?':
			return 0;
			default:
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 1240
/*
* @Author: wxyww
* @Date:   2019-03-16 20:14:43
* @Last Modified time: 2019-03-16 20:41:22
*/
#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<queue>
#include<vector>
#include<ctime>
using namespace std;
typedef long long ll;
const int N = 200000 + 100,mod = 1e9 + 7;
ll read() {
	ll x=0,f=1;char c=getchar();
	while(c<'0'||c>'9') {
		if(c=='-') f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9') {
		x=x*10+c-'0';
		c=getchar();
	}
	return x*f;
}
int a[N],f[N],cnt[N];
int main() {
	int n = read();
	f[1] = 1;
	for(int i = 1;i <= n;++i) {
		a[i] = read();
		if(i == 1) {
			cnt[a[i]] = i;
			continue;
		}
		f[i] = f[i - 1];
		if(cnt[a[i]] != i - 1) f[i] += f[cnt[a[i]]],f[i] %= mod;
		cnt[a[i]] = i;
	}
	cout<<f[n];

	return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
using P = pair<int, int>;
using ll = long long;
 
int main(){
	int n;
  	string s;
  	cin >> n >> s;
  
  	int ans = 0;
  	rep(i, n){
    	if(s[i] != s[i+1]) ans++;
    }
  
  	cout << ans << endl;
}

Measured memory_bytes: 3660
#include<stdio.h>
#include<string.h>
typedef long long int ll;
int main()
{

    int n,k,i;
    char a[15];
    scanf("%d",&n);
    getchar();
    for(i=0;i<n;i++)
        scanf("%c",&a[i]);
    scanf("%d",&k);
    for(i=0;i<n;i++)
    {
        if(a[k-1]==a[i])
            printf("%c",a[i]);
        else
            printf("*");
    }
	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		long a = sc.nextLong();
		long b = sc.nextLong();
		
		long blue = (n / (a + b)) * a + Math.min(a, (n % (a + b)));
		System.out.println(blue);
		sc.close();
	}
}


Measured memory_bytes: 23636
#pragma GCC optimize("O3")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pii pair<int,int>
#define pb push_back
#define N 200003
#define inf (ll)1e9+11
#define warmup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
ll mod=1e9+7;   

bool compare(pii a,pii b)
{
    if(a.second==b.second)
        return a.first>b.first;
    return a.second<b.second;
}   

signed main()
{
    warmup
    
    int n;
    cin>>n;
    pii p[n+1];
    int i,j,x,l;
    for(i=1;i<=n;++i)
        cin>>x>>l, p[i].first=x-l, p[i].second=x+l;
    sort(p+1,p+n+1,compare);
    j=1;
    int cnt=1;
    for(i=2;i<=n;++i)
    {
        if(p[i].first>=p[j].second)
        {
            ++cnt;
            j=i;
        }   
    }   
    cout<<cnt;
    
    return 0;
}


Measured memory_bytes: 1024
import itertools
n, a, b, c = map(int, input().split())
lis = []
for i in range(n):
    lis.append(int(input()))

res = 10**9

for g in itertools.product([0, 1, 2, 3], repeat=n):
    s = [[], [], [], []]
    for i, gg in enumerate(g):
        s[gg].append(lis[i])
    if not s[0] or not s[1] or not s[2]:
        continue
    else:
        x, y, z = sorted([sum(s[0]), sum(s[1]), sum(s[2])])
        l, m, n = len(s[0]), len(s[1]), len(s[2])
        pnt = abs(x-c) + abs(y-b) + abs(z-a) + 10*(l+m+n-3)
        res = min(pnt, res)
print(res)


Measured memory_bytes: 3064
STDIN.each_line do |line|
	a,b,c,d,e,f = line.split.map(&:to_f)
	x = (b*f-c*e)/(b*d-a*e)
	y = (c-a*x)/b
	puts sprintf("%.3f %.3f",x+0.0,y+0.0)
end

Measured memory_bytes: 8660
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<functional>
#include<queue>
#include<algorithm>
#include<complex>
#include<cstdlib>
#include<cctype>
 
#define DBG cout << '!' << endl;
#define REP(i,n) for(int i = 0;i < (n);i++)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int i = 0;i < (n);i++)cout << v[i] << ' ';cout << endl << endl;}
#define SHOW2d(v,i,j) {for(int a = 0;a < i;a++){for(int b = 0;b < j;b++)cout << v[a][b] << ' ';cout << endl;}cout << endl;}
#define ALL(v) v.begin(),v.end()
 
using namespace std;
 
typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;
 
ll mozi[26];
 
int main()
{
	string str;
	
	cin >> str;
	REP(i,str.size())
	{
		mozi[str[i] - 'a']++;
	}
	
	
	//SHOW1d(mozi,26);
	ll tmp = str.size();
	ll ans = tmp * (tmp - 1) / 2 + 1;
	
	REP(i,26)
	{
		if(mozi[i] > 1)
		{
			ans -= mozi[i] * (mozi[i] - 1) / 2;
		}
	}	
	
	
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define put(n) cout<<(n)<<endl
#define FOR(i,num,N) for(int(i)=(num);(i)<(N);++(i))
#define RFOR(i,num,N) for(int (i)=(num);(i)>(N);--(i))
#define all(v) (v).begin() , (v).end()
#define rall(v) (v).rbegin() , (v).rend()


int main(){
    int N,right = 0;
    cin>>N;
    vector<int> A(N);
    FOR(i,0,N) cin>>A[i];
    long long ans = 0,sum = 0;

    for(int left=0;left<N;++left){
        while(right < N && ((sum ^ A[right]) == (sum + A[right]))){
            sum += A[right];
            ++right;
        }
        ans += (right - left);
        if(left == right) ++right;
        else sum -= A[left];
    }
    put(ans);
}

Measured memory_bytes: 1152
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
n=ii()
a,b,c=[],[],[]

for i in range(n):
    x,y,z=mii()
    a.append(x)
    b.append(y)
    c.append(z)

dp=[[0]*n for i in range(3)]
dp[0][0],dp[1][0],dp[2][0]=a[0],b[0],c[0]
for i in range(1,n):
    for j in [0,1,2]:
        if j==0:dp[0][i]=max(dp[1][i-1]+a[i],dp[2][i-1]+a[i])
        elif j==1:dp[1][i]=max(dp[0][i-1]+b[i],dp[2][i-1]+b[i])
        elif j==2:dp[2][i]=max(dp[1][i-1]+c[i],dp[0][i-1]+c[i])

print(max(dp[0][-1],dp[1][-1],dp[2][-1]))



Measured memory_bytes: 85080
#include <bits/stdc++.h>
using namespace std;
 
int main(void)
{
    int n,k,p;
    cin >> n >> k;
    vector<int> num(n);
    for(int i=0;i<n;i++){
        cin >> num.at(i);
        if(num.at(i)==1) p=i;
    }
    cout <<(n+k-3)/(k-1);
}

Measured memory_bytes: 640
import math

if __name__ == "__main__":
    _, M = map(int, input().split())

    A, B = map(int, input().split())

    for i in range(1, M):
        a, b = map(int, input().split())
        A = max(A, a)
        B = min(B, b)

    print(max(B - A + 1, 0))



Measured memory_bytes: 3060
n=int(input())
*a,=map(int,input().split())
*b,=map(int,input().split())
ans=0
for i in range(n):
  if a[i]>b[i]:
    ans-=a[i]-b[i]
  else:
    ans+=(b[i]-a[i])//2
print('No' if ans<0 else 'Yes')

Measured memory_bytes: 4596
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<map>
#include<queue>
#include<stack>
#include<deque>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<numeric>
#include<cctype>
using namespace std;

#define Yes(a) a ? "Yes" : "No";
#define YES(a) a ? "YES" : "NO";
#define rep(i,n) for(int i=0;i<n;i++)

void sout(string* a, string* b) {
	if (*a > * b) {
		string c = *a;
		*a = *b;
		*b = c;
	}
}

int combination(int n, int k) {
	if (n > k && k > 0) {
		return (combination(n - 1, k) + combination(n - 1, k - 1));
	}
	else
		return 1;
}

int main() {
	int n;
	int s = 0, x = 0;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a.at(i);
		s += a.at(i);
	}
	sort(a.begin(), a.end());
	for (int i = 0; i < n; i++) {
		if (i % 2 == 0) {
			x += a.at(i);
		}
	}
	cout << abs(2 * x - s) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>

using namespace std;

int main(int argc, char const *argv[])
{
    string S;
    cin >> S;
    int n = S.size();
    int s[n];
    for(int i=0; i<n; i++){
        s[i] = S[i] - '0';
    }

    long sum = 0;
    int max_i = pow(2, n-1);
    for(int i=0; i<max_i; i++){
        long d = 1;
        for(int j=0; j<n; j++){
            sum += d * s[n - 1 - j];
            if((i >> j)&1){
                d = 1;
            }
            else{
                d *= 10;
            }
        }
    }

    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
a = int(input())
b = list(map(int,input().split()))
from collections import defaultdict
d = defaultdict(int)
for i in b:
    d[i]+=1
sorted_d = sorted(d.items(),key=lambda x:x[0],reverse=True)

rec_cnt = 0
rec_len_list = []
for k,v in sorted_d:
    if rec_cnt == 0:
        if v >= 4:
            rec_len_list = [k,k]
            rec_cnt=2
        elif v >= 2:
            rec_len_list.append(k)
            rec_cnt=1
        else:
            pass
    elif rec_cnt == 1:
        if v >= 2:
            rec_len_list.append(k)
            rec_cnt+=1
    else:
        break
if len(rec_len_list) < 2:
    print(0)
else:
    print(rec_len_list[0] * rec_len_list[1])

Measured memory_bytes: 22152