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

#define rep(i,x,y) for(ll i=(x);i<(y);i++)
#define rrep(i,x,y) for(ll i=(ll)(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
#ifdef LOCAL
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#define dassert(...) assert(__VA_ARGS__)
#else
#define dump(x)
#define debug(x)
#define dassert(...)
#endif
//#define int long long

typedef long long ll;
const ll MOD = 1e9 + 7;
const long double EPS = 1e-8;

void solve(long long N, std::vector<long long> L){
    sort(all(L));
    int answer = 0;
    rep(i,0,N) {
        rep(j,i+1,N) {
            auto itr = lower_bound(all(L), L[i] + L[j]);
//            debug(i);
//            debug(j);
//            debug(distance(L.begin()+j, itr));
            answer += distance(L.begin()+j+1, itr);
        }
    }
    cout << answer << endl;
}

signed main(){
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    long long N;
    scanf("%lld",&N);
    std::vector<long long> L(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&L[i]);
    }
    solve(N, std::move(L));
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
 
using namespace std;
 
int main(){
    int n,taro_point = 0,hanako_point = 0,j;
    char taro_card[101],hanako_card[101];
    scanf("%d",&n);
    for(int i = 0; i < n; i++){
        scanf("%s %s",taro_card,hanako_card);
        for(j = 0; taro_card[j] != '\0' && hanako_card[j] != '\0' && taro_card[j] == hanako_card[j];j++);
        if(taro_card[j] == '\0'){
            if(hanako_card[j] == '\0'){
                taro_point += 1;
                hanako_point += 1;
            }else{
                hanako_point += 3;
            }
        }else if(hanako_card[j] == '\0'){
            taro_point += 3;
        }else if(hanako_card[j] > taro_card[j]){
            hanako_point += 3;
        }else{
            taro_point += 3;
        }
    }
    printf("%d %d\n",taro_point,hanako_point);
}


Measured memory_bytes: 2700
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define X first
#define Y second
#define REP(i,a) for(int i=0;i<a;++i)
#define REPP(i,a,b) for(int i=a;i<b;++i)
#define FILL(a,x) memset(a,x,sizeof(a))
#define	foreach( gg,itit )	for( typeof(gg.begin()) itit=gg.begin();itit!=gg.end();itit++ )
#define	mp make_pair
#define	pb push_back
#define sz(a) int((a).size())
#define all(a)  a.begin(), a.end()
#define	debug(ccc)	cout << #ccc << " = " << ccc << endl;
#define present(c,x) ((c).find(x) != (c).end())
const double eps = 1e-8;
#define EQ(a,b) (fabs((a)-(b))<eps)
inline int max(int a,int b){return a<b?b:a;}
inline int min(int a,int b){return a>b?b:a;}
inline ll max(ll a,ll b){return a<b?b:a;}
inline ll min(ll a,ll b){return a>b?b:a;}
const int mod = 1e9+7;
const int N = 1e6+10;
const ll inf = 1e18;

ll power(ll a,ll n){
	if(n==0){
		return 1;
	}
	ll b = power(a,n/2);
	b = b*b%mod;
	if(n%2) b= b*a%mod;
	return b;
}

int add(int a,int b){ return (a+b)%mod;}
int mul(int a,int b){ return (ll)a*b%mod;}

int v[30];

int main(){
	int n,flag=0,y=0,x,ans=0;
	scanf("%d",&n);
	REP(i,n)
	{
		scanf("%d",&x);
		y^=x;
		REP(i,30)
		{
			if (x&(1<<i))
			{
				v[i]++;
				break;
			}
		}
	}
	while(y&&!flag)
	{
		for(int i=29;i>=0;i--)
		{
			if (y&(1<<i))
			{
				if (v[i])
				{
					ans++;
					y^=(1<<i);
					y^=(1<<i)-1;
				}
				else {flag=1; break;}
			}
		}
	}
	if (flag) printf("-1\n");
	else printf("%d\n",ans);
return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static class UnionFind {
		int[] param;
		int[] rank;
		int N;
		int xlen;
		
		public UnionFind(int n) {
			N=n;
			param = new int[N];
			rank = new int[N];
			for(int i=0; i<N; i++)
				param[i] = i;
		}
		
		public void init() {
			for(int i=0; i<N; i++)
				param[i] = i;
			Arrays.fill(rank, 0);
		}
		
		public UnionFind(int x, int y) {
			this(x*y);
			xlen=y;
		}
		
		public boolean same(int a, int b) {
			return getRoot(a)==getRoot(b);
		}
		
		public boolean same(int x1, int y1, int x2, int y2) {
			return same(x1*xlen+y1, x2*xlen+y2);
		}
		
		public int getRoot(int a) {
			if(param[a]==a) return a;
			else return (param[a] = getRoot(param[a]));
		}
		
		public void unite(int a, int b) {
			a = getRoot(a);
			b = getRoot(b);
			if(a==b)
				return;
			
			if(rank[a] < rank[b]) {
				param[a] = b;
			} else {
				param[b] = a;
				if(rank[a]==rank[b])
					rank[a]++;
			}
		}
		
		public void unite(int x1, int y1, int x2, int y2) {
			unite(x1*xlen+y1, x2*xlen+y2);
		}
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int M = sc.nextInt();
		int K = sc.nextInt();
		
		HashMap<Integer, HashSet<Integer>> exclude = new HashMap<>();
		
		UnionFind uf = new UnionFind(N);
		for(int i=0; i<M; i++) {
			int A = sc.nextInt()-1;
			int B = sc.nextInt()-1;
			uf.unite(A, B);
			
			HashSet<Integer> setA = exclude.get(A);
			if(setA==null) {
				setA = new HashSet<Integer>();
			}
			setA.add(B);
			exclude.put(A, setA);
			
			HashSet<Integer> setB = exclude.get(B);
			if(setB==null) {
				setB = new HashSet<Integer>();
			}
			setB.add(A);
			exclude.put(B, setB);
		}
		for(int i=0; i<K; i++) {
			int C = sc.nextInt()-1;
			int D = sc.nextInt()-1;
			if(!uf.same(C, D))
				continue;
			
			HashSet<Integer> setC = exclude.get(C);
			if(setC==null) {
				setC = new HashSet<Integer>();
			}
			setC.add(D);
			exclude.put(C, setC);
			
			HashSet<Integer> setD = exclude.get(D);
			if(setD==null) {
				setD = new HashSet<Integer>();
			}
			setD.add(C);
			exclude.put(D, setD);
		}

		int[] count = new int[N];
		for(int i=0; i<N; i++) {
			int root = uf.getRoot(i);
			count[root]++;
		}
		
		for(int i=0; i<N; i++) {
			HashSet<Integer> ex = exclude.get(i);
			int candidate = count[uf.getRoot(i)] - 1 - (ex==null ? 0 : ex.size());
			System.out.print(candidate + (i==N-1 ? "\n" : " "));
		}
		sc.close();
	}
}


Measured memory_bytes: 206092
#include <algorithm>
#include <bitset>
#include <cctype>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*----------------------------------------*/

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n; cin >> n;
  vector<int> a(n); REP(i, n) cin >> a[i];
  sort(ALL(a));
  int sz = n;
  int ans = 0;
  while (sz > 1) {
    int now = a.back();
    a.erase(a.end() - 1);
    --sz;
    REP(j, 30) {
      long long beki = 1LL << (j + 1);
      if (beki <= now) continue;
      int index = lower_bound(ALL(a), beki - now) - a.begin();
      if (index == sz || a[index] != beki - now) continue;
      ++ans;
      a.erase(a.begin() + index);
      --sz;
      break;
    }
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 1024
import sys
from collections import deque

def solve():
    N = int(input())
    AB = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k"]
    Ans = []
    q = deque()
    q.append(("a", 1, 0))
    while q:
        current, length, maxW = q.popleft()
        if length == N: Ans.append(current)
        else:
            q.append((current + "a", length + 1, maxW))
            for k in range(maxW + 1):
                q.append((current + AB[k + 1], length + 1, max(k + 1, maxW)))
    Ans.sort()
    for a in Ans: print(a)
    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 22168
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;

namespace atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var xy = Console.ReadLine().Split(' ').Select(num => int.Parse(num)).ToArray();
            Console.WriteLine(xy[0] + xy[1] / 2);
        }
    }
}

Measured memory_bytes: 28200
import std.stdio;
import std.string;
import std.conv;
import std.array;
import std.algorithm;
import std.math;

void main() {
  int n = readln.chomp.to!int;
  auto a = readln.chomp.split.map!(to!int).array;

  auto m = reduce!(min, max)(a);

  if (m[0] == m[1]) {
    writeln(0);
  }
  else if (m[0] >= 0) {
    writeln(n - 1);
    for (int i = 0; i < n - 1; ++i) {
      writeln(i + 1, " ", i + 2);
    }
  }
  else if (m[1] < 0) {
    writeln(n - 1);
    for (int i = n - 1; i > 0; --i) {
      writeln(i + 1, " ", i);
    }
  }
  else {
    if (abs(m[0]) > abs(m[1])) {
      writeln(n - 1 + n - 1);

      int p;
      for (int i = 0; i < n; ++i) {
        if (a[i] == m[0]) {
          p = i;
          break;
        }
      }
      for (int i = 0; i < n; ++i) {
        if (i == p) continue;
        writeln(p + 1, " ", i + 1);
      }
      for (int i = n - 1; i > 0; --i) {
        writeln(i + 1, " ", i);
      }
    }
    else {
      writeln(n - 1 + n - 1);

      int p;
      for (int i = 0; i < n; ++i) {
        if (a[i] == m[1]) {
          p = i;
          break;
        }
      }
      for (int i = 0; i < n; ++i) {
        if (i == p) continue;
        writeln(p + 1, " ", i + 1);
      }
      for (int i = 0; i < n - 1; ++i) {
        writeln(i + 1, " ", i + 2);
      }
    }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll unsigned long long
#define ld long double
#define pii pair<ll, ll>
#define SZ(x) ((int)(x).size())
ll mod = 1e9 + 7;
//const double pi = acos(-1.0);
/*
ll kmp(string x)
{
    ll n= x.length();
    //cout<<x<<endl;
    vector<ll> lcp(x.length(), 0);
    for(ll i=1;i<n;i++)
    {
        ll j=lcp[i-1];
        while(j>0 && x[j]!=x[i])
            j=lcp[j-1];
        if(x[i]==x[j])
            j++;
        lcp[i]=j;
    }
    return lcp[n-1];
}

int N = 1000002;
int ar[100002];
void sieve()
{
    for(int i=1;i<=N;i++)
        ar[i] = 1;
    ar[0] = 0;
    for(int i=2;i*i<=N;i++)
    {
        if(ar[i] && i*i<=N)
        {
            for(int j = i*i; j<=N;j+=i)
                ar[j] = 0;
        }
    }
}

ll modex(ll a,ll b){
    if(b<=0){
        return 1;
    }
    if(b%2==0)
    {
        ll x = modex(a, b/2);
        return ((x*x)%mod);
    }
    else
        return ((a%mod * modex(a, b-1))%mod);
}

ll c[1010][1010];

ll combina(ll i, ll j){
        for (int i=0;i<=1005;i++)
        for (int j=0;j<=i;j++)
        {
            if (j==i||j==0)
                c[i][j]=1;
            else
            c[i][j]=c[i-1][j-1]+c[i-1][j];
            c[i][j]%=mod;
        }
        return c[i][j];
}
void find_fac(int x){
    vector<ll> di;
    for(ll i = 2; i*i <= x; i++)
    {
        if(x%i==0){
            di.push_back(i);
            while(x%i==0)
                x/=i;
        }
    }
    if(x > 1)
        di.push_back(x);
}
*/

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cout<<fixed;
    cout.precision(12);
    int s = 0;
    for(int i=0;i<5;i++)
    {
        int x;
        cin>>x;
        s += x;
    }
    cout<<15-s<<endl;
    return 0;
}


Measured memory_bytes: 3624
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
using namespace std;
typedef pair<int,int> P;
double dat[100][100];
int dp[6][1010];//動的計画法
int prime[10000001];
char str[1010][1010];
vector<pair<int,int> > pc[100001];
int ABS(int a){return max(a,-a);}
int main(){
	long long ans,a,b,x;
	cin>>a>>b>>x;
	if(b==0) cout<<1<<endl;
	else if(a!=0)cout<<b/x-(a-1)/x<<endl;
	else cout<<b/x+1<<endl;
	return 0;
}

Measured memory_bytes: 4352
lst = [ [ int(i) for i in input().split() ] for j in range(3) ]

n = int(input())

for _ in range(n):
  x = int(input())
  for d in lst:
    if d[0] == x:
      d[0] = -1
    elif d[1] == x:
      d[1] = -1
    elif d[2] == x:
      d[2] = -1

for d in lst:
  if d[0] == d[1] == d[2] == -1:
    print('Yes')
    exit()
for i in range(3):
  if lst[0][i] == lst[1][i] == lst[2][i] == -1:
    print('Yes')
    exit()
for i in range(3):
  if lst[i][0] == lst[i][1] == lst[i][2] == -1:
    print('Yes')
    exit()
if lst[0][0] == lst[1][1] == lst[2][2] == -1:
  print('Yes')
  exit()
if lst[0][2] == lst[1][1] == lst[2][0] == -1:
  print('Yes')
  exit()
print('No')


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


int main() {
    ll X,Y;
    cin>>X>>Y;
    ll count=1;

    while (X<=Y){
        X*=2;
        if(X>Y)break;
        count++;
    }
    cout<<count<<endl;
}

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 (int i = 0; i < (int)(n); i++)
typedef long long ll;

int main()
{
    int n; cin >> n;
    ll a = 0;
    for (int i = 1; i <= n; ++i) {
        if ((i % 3 != 0) && (i%5 != 0)) a += i;
    };

    cout << a << endl;
    return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <stack> // s.top()
#include <bitset>
#include <queue> // s.front()
using namespace std;

typedef long long Int;
typedef pair<Int,Int> P;
#define print(x) cout<<(x)<<endl

#define INF10 10000000000
#define INF5 100000
#define EPS 1e-10
#define MOD 1000000007


int main() {
	Int N;
	Int div = 1e9 + 7;
	cin >> N;

	Int score = 1;

	for (Int i = 1; i <= N; i++) {
		score *= i;
		score %= div;
	}
	print(score);







	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<limits>
#include<cmath>
#include<string>
#include<algorithm>
#include<iomanip>

using namespace std;

int main()
{
  int n, q;
  cin >> n;
  int A[n];
  for(int i=0;i<n;++i) cin>>A[i];

  cin>>q;
  int P[q];
  for(int i=0;i<q;++i) cin>>P[i];

  int count=0;
  for(int i=0;i<q;++i) {
    for(int j=0;j<n;++j) {
      if (A[j]==P[i]) {
        ++count;
        break;
      }
    }
  }

  cout << count << endl;
}


Measured memory_bytes: 3112
import collections

n, m, p = map(int, input().split())
dist1 = []
edges1 = [[] for _ in range(n)]
edges2 = [[] for _ in range(n)]
for _ in range(m):
    a, b, c = map(int, input().split())
    a -= 1
    b -= 1
    dist1.append((a, b, (c - p) * -1))
    edges1[a].append(b)
    edges2[b].append(a)

def dfs(edges, start):
    stack = [start]
    use = {start, }
    while stack:
        x = stack.pop()
        for y in edges[x]:
            if y in use:
                continue
            stack.append(y)
            use.add(y)
    return use


def bellman_ford(dist):
    v = [float('inf')] * n
    v[0] = 0
    for _ in range(n):
        updated = False
        for a, b, c in dist:
            if v[a] + c < v[b]:
                updated = True
                v[b] = v[a] + c
        if not updated:
            return max(0, v[n - 1] * -1)
    return -1

use = dfs(edges1, 0) & dfs(edges2, n - 1)
dist2 = [(a, b, c) for a, b, c in dist1 if a in use and b in use]
print(bellman_ford(dist2))


Measured memory_bytes: 5348
#include<stdio.h>
int main()
{
    long long int a,j=100,i=1,k=0;
    scanf("%lli",&a);
    for(;i==1;)
    {
        j=j+j/100;
        if(j>=a)
        {
            i++;
        }
        k++;
    }
    printf("%lli\n",k);
    return 0;
}


Measured memory_bytes: 1736
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

class Main {

	public static void main(String[] args) throws IOException {
		Scanner sc=new Scanner(System.in);
		int a=sc.nextInt(),b=sc.nextInt(),c=sc.nextInt();
                long k=sc.nextLong();
		if(k%2==0)
			System.out.println(a-b);
		else
			System.out.println(b-a);
		
		

	}
	static class Scanner
	{
		BufferedReader br;
		StringTokenizer st;
		public Scanner(InputStream s)
		{
			br=new BufferedReader(new InputStreamReader(s));
		}
		public Scanner(String s) throws FileNotFoundException
		{
			br=new BufferedReader(new FileReader(s));
		}
		public String nextLine() throws IOException
		{
			return br.readLine();
		}
		public String next() throws IOException
		{
			while(st==null || !st.hasMoreTokens())
				st=new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		public int nextInt() throws IOException
		{
			return Integer.parseInt(next());
			
		}
		public double nextDouble() throws IOException
		{
			return Double.parseDouble(next());
		}
		public boolean ready() throws IOException
		{
			return br.ready();
		}
		public long nextLong() throws IOException
		{
			return Long.parseLong(next());
		}
	}

}


Measured memory_bytes: 21204
import bisect
N = int(input())
Alist = list(map(int,input().split()))
Blist = list(map(int,input().split()))
Clist = list(map(int,input().split()))
Alist.sort()
Clist.sort()
retnum = 0 
for i in Blist:
    Anum = bisect.bisect_left(Alist,i)
    Cnum =  N - bisect.bisect_right(Clist,i)
    retnum +=(Anum * Cnum)
print(retnum)


Measured memory_bytes: 23328
#include <bits/stdc++.h>
using namespace std;
#define repr(i, a, b) for (int i = a; i < b; i++)
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
#define mod 1000000007

ll gcd(ll x,ll y) {return y ? gcd(y,x%y) : x;} 
ll lcm(ll x,ll y) {return x/gcd(x,y)*y;}

bool is_prime(ll x) {
  for(int64_t i = 2; i * i <= x; i++) {
    if(x % i == 0) return false;
  }
  return true;
}

int main(){
    ll n,ans=0;
    cin >> n;
    vector<ll> a;
    ll m=n;
    while(n!=1){
        if(is_prime(n)){
            a.push_back(n);
            break;
        }
        ll now=0,now2=0;
        for(ll i=2;i<n;i++){
            if(n%i==0){
                now=i;
                //cout << now << endl;
                break;
            }
        }
        now2=now;
        while(n%now==0){
            a.push_back(now2);
            now2*=now;
            n/=now;
        }
    }
    
    sort(a.begin(),a.end());
    
    for(ll i=0;i<a.size();i++){
        if(m%a[i]==0){
            ans++;
            m/=a[i];
        }
    }
    
    cout << ans << endl;
    
    return 0;
}











Measured memory_bytes: 3604
#define _USE_MATH_DEFINES
#include<iostream>
#include<fstream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<climits>
#include<set>
#include<map>
#include<cmath>
#include<iomanip>
#include<iterator>
#include<queue>
#include<stack>
#include<cctype>
#include<deque>
#include<time.h>
#include<bitset>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<sstream>
//by Skeef79

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

#pragma warning(disable : 4996)
#pragma comment(linker, "/STACK:16777216")
#define pb push_back
#define en '\n'
#define for0(i,n) for(int i = 0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define vec vector
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

const int INF = 2000000000;
const ll LINF = 2000000000000000000;

template<typename T> void print(vector<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cout << a[i] << ' ';
	cout << en;
}

template<typename T> void print(deque<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cout << a[i] << ' ';
	cout << en;
}

template<typename T> void print(vector<vector<T>>& a)
{
	for (int i = 0; i < a.size(); i++)
	{
		for (int j = 0; j < a[i].size(); j++)
			cout << a[i][j] << ' ';
		cout << en;
	}
}

template <typename T> void input(vector<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cin >> a[i];
}

template<typename T> void input(deque<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cin >> a[i];
}

template<typename T> void input(vector<vector<T>>& a)
{
	for (int i = 0; i < a.size(); i++)
		for (int j = 0; j < a[i].size(); j++)
			cin >> a[i][j];
}


void solve()
{
	int n;
	string s;
	cin >> n >> s;
	int ans = 0;
	for (int i = 0; i < n - 3+1; i++)
		if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C')
			ans++;
	cout << ans;


}

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

#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
#endif

	int tst = 1;
	//cin >> tst;
	while (tst--)
		solve();
}

Measured memory_bytes: 256
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    return divisors

N = int(input())
l = make_divisors(N)
l.sort()

ans = sum(l)-len(l)
for i in l:
    if i <= 1:
        continue
    if N%(i-1) == N//(i-1):
        break
    else:
        ans -= i-1

print(ans)

Measured memory_bytes: 39024
def main():
    h,w = map(int,input().split())
    a=[]
    que=[]
    for _ in range(h):
        a.append(list(input()))
    for i in range(h):
        for j in range(w):
            if a[i][j]=="#":
                que.append([i,j])
                a[i][j]=0
    ans=0
    while que!=[]:
        tank=[]
        for i,j in que:
            if j<w-1 and a[i][j+1]==".":
                tank.append([i,j+1])
                a[i][j+1]=a[i][j]+1
            if 0<j and a[i][j-1]==".":
                tank.append([i,j-1])
                a[i][j-1]=a[i][j]+1
            if i<h-1 and a[i+1][j]==".":
                tank.append([i+1,j])
                a[i+1][j]=a[i][j]+1
            if 0<i and a[i-1][j]==".":
                tank.append([i-1,j])
                a[i-1][j]=a[i][j]+1
        que=tank
        ans+=1
    print(ans-1)
if __name__ == "__main__":
    main()

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

int main()
{
	int N, M;
	cin >> N >> M;
	vector<int> sum(N + 1);
	for (int i = 0; i < M; i++) {
		int L, R;
		cin >> L >> R; --L;
		sum[L]++;
		sum[R]--;
	}
	for (int i = 0; i < N; i++) {
		sum[i + 1] += sum[i];
	}
	int res = 0;
	for (int i = 0; i < N; i++) {
		res += sum[i] == M;
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
  ll N,a=0,b=0; string S; cin>>N>>S;
  for(int i=0; i<N; i++){
    if(S[i]=='(') a++;
    else{
      a--;
      b=min(a,b);
    }
  }
  if(b<0){
    while(b){
      b++,a++;
      S.insert(0,"(");
    }
  }
  N=S.size();
  if(a>0){
    while(a){
      a--;
      S.insert(N,")");
    }
  }
  cout<<S<<endl;
}

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

using namespace std;

int main(){
    int n;
    cin >> n;
    string str[2];
    for(auto&& i : str){
        cin >> i;
    }
    long long ans = 1;
    static const int INF = 1e9 + 7;
    bool before;
    for(int x = 0; x < n; x++){
        if(str[0][x] == str[1][x]){
            if(x == 0){
                ans *= 3;
            }else{
                if(before){
                    ans *= 2;
                }
            }
            before = true;
        }else{
            if(x == 0){
                ans *= 6;
            }else{
                if(before){
                    ans *= 2;
                }else{
                    ans *= 3;
                }
            }
            x++;
            before = false;
        }
        ans %= INF;
    }
    cout << ans << "\n";
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {

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

	private void solve() throws IOException {
		try {
			solveA();
			// solveB();
			// solveC();
			// solveD();
			// solveE();
			// solveF();
		} finally {
			if (in != null) {
				in.close();
			}
			if (out != null) {
				out.flush();
				out.close();
			}
		}

	}

	private void solveA() {
		int numN = nextInt();
		if (numN < 1200) {
			out.print("ABC");
		} else {
			out.print("ARC");
		}

	}

	private void solveB() {
		int numN = nextInt();

		out.println("");
	}

	private void solveC() {
		int numN = nextInt();

		out.println("");
	}

	private void solveD() {
		int numN = nextInt();

		out.println("");
	}

	private void solveE() {
		int numN = nextInt();

		out.println("");
	}

	private void solveF() {
		int numN = nextInt();

		out.println("");
	}

	private final PrintWriter out = new PrintWriter(System.out);
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
	}

	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
}

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

typedef long long ll;
const int INF = 1e9;
const ll LINF = 1e18;
const int mod = 1e9+7;

#define pi pair<int,int>
#define pl pair<lld,lld>

#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl

#define mem0(x) memset(x,0,sizeof(x))
#define fillnum(x,n) fill(begin(x),end(x),n)
#define asort(x) sort(x.begin(),x.end())
#define dsort(x,t) sort(x.begin(),x.end(),greater<t>())
#define vuniq(x) x.erase(unique(x.begin(), x.end()), x.end())

#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)

int main() {
    ll N,T;
    vector<ll> t;
    cin >> N >> T;
    ll ans = 0;
    for (int i = 0; i < N; i++) {
        ll a; cin >> a;
        t.pb(a);
    }
    t.pb(10e9+10e9+7);
    for (int i = 0; i < N; i++) {
        ans += min(T,t[i+1]-t[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 5320
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>
#include <iterator>

using namespace std;

typedef unsigned int UI;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;
typedef istringstream ISS;
typedef ostringstream OSS;

#define REP( i, m, n ) for ( int i = (int)( m ); i < (int)( n ); ++i )
#define FOR( v, c ) for ( auto &v : c )

#define EACH( it, c ) for ( auto it = c.begin(); it != c.end(); ++it )
#define ALL( c ) (c).begin(), (c).end()

#define PB( n ) push_back( n )
#define MP( a, b ) make_pair( ( a ), ( b ) )
#define EXIST( c, e ) ( (c).find( e ) != (c).end() )

#define fst first
#define snd second

#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define DEBUG( x ) cerr << __FILE__ << ":" << __LINE__ << ": " << #x << " = " << ( x ) << endl

VI cut( VI cards, int k )
{
	VI res( cards.begin() + k, cards.end() );
	res.insert( res.end(), cards.begin(), cards.begin() + k );
	return res;
}

VI realShuffle( VI cards )
{
	const int N = cards.size() / 2;

	VI res;
	REP( i, 0, N )
	{
		res.PB( cards[i] );
		res.PB( cards[ N + i ] );
	}
	return res;
}

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

 	int n, m;
	cin >> n >> m;

	VI cards( 2 * n );
	REP( i, 0, 2 * n )
	{
		cards[i] = i + 1;
	}

	REP( i, 0, m )
	{
		int k;
		cin >> k;

		if ( k )
		{
			cards = cut( cards, k );
		}
		else
		{
			cards = realShuffle( cards );
		}
	}

	for_each( ALL( cards ), []( int a ){ cout << a << endl; } );

	return 0;
}

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

typedef long long ll;
const ll mod=1e9+7;
const int N=200000;

void Run()
{
     ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}
ll a[N],s,res,f;
map<char,ll>mp;
vector<ll>v;
int main()
{
    Run();
    for(int i=1;i<=5;i++)
    {
        cin>>a[i];
        if(a[i]==0)
        {
            cout<<i;
            break;
        }
    }
}


Measured memory_bytes: 3616
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::{i32, i64, u32, u64, usize, f64};
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{VecDeque, HashMap, BTreeMap, HashSet, BTreeSet};
#[allow(unused_imports)]
use std::io::{stdout, Write, BufWriter};
#[allow(unused_imports)]
use std::mem::{swap};

fn main() {
    input!{
        h: usize,
        w: usize,
        rows: [String; h],
    }
    let out = stdout();
    let mut out = BufWriter::new(out.lock());
    let orig_rows = rows.clone();
    let rows: Vec<_> = rows.into_iter().filter(|row| ! row.chars().all(|p| p == '.')).collect();
    let rows: Vec<_> = rows.into_iter().map(|row| row.chars().collect::<Vec<char>>()).collect();
    let mut js = vec![];
    for i in 0..w {
        if ! orig_rows.iter().map(|row| row.chars().nth(i).unwrap()).all(|p| p == '.') { js.push(i); }
    }
    for row in rows {
        for &j in &js { write!(out, "{}", row[j]).unwrap(); }
        writeln!(out, "").unwrap();
    }
}


Measured memory_bytes: 4352
n = int(input())
a = list(map(int,input().split()))
ans = [0]*(n)

ans[n//2]=a[0]

#ケツから１こ飛ばしであたまからいれていく
for i in range(0,n//2,1):
    ans[i]=a[n-1-2*i]
    ans[n-1-i]=a[n-2-2*i]

print(" ".join(map(str,ans)))

Measured memory_bytes: 115508
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
using namespace std;
#define ll long long
int main(){
    string str;
    cin >> str;
    string key="keyence";
    int flag=0;
    int i;
    for(i=0;i<=7;i++){
      if(str.substr(0,i)+str.substr(str.size()-7+i,7-i)==key)flag=1;
    }
    if(flag==1){
      cout << "YES";
    }else{
      cout << "NO";
    }
    return 0;
}


Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

fn main() {
    input! {
        n: usize,
        s: [chars;n],
        m: usize,
        t: [chars;m]
    }

    let sc = count(&s);
    let tc = count(&t);
    let mut ret = 0;
    for (key, &value) in sc.iter() {
        let tmp = *tc.get(key).unwrap_or(&0);
        if value > tmp {
            ret = std::cmp::max(ret, value - tmp);
        }
    }
    println!("{}", ret);
}

#[allow(dead_code)]
fn count<T: Eq + std::hash::Hash + Clone>(slice: &[T]) -> std::collections::HashMap<T, usize> {
    let mut hmap = std::collections::HashMap::new();
    for item in slice {
        *hmap.entry(item.clone()).or_insert(0) += 1;
    }
    hmap
}

Measured memory_bytes: 4352
package main

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

func main() {
	s := IOInitialize()
	s.Buffer([]byte{}, math.MaxInt64)
	S := String(s)
	T := String(s)
	sList := strings.Split(S, "")
	tList := strings.Split(T, "")
	mA := map[string]string{}
	mB := map[string]string{}
	for i, strA := range sList {
		strB := tList[i]
		if strA == strB {
			mA[strA] = strB
			mB[strB] = strA
			continue
		}
		if _, ok := mA[strA]; ok {
			if mA[strA] == strB {
				continue
			} else {
				fmt.Println("No")
				return
			}
		} else {
			if _, ok := mB[strB]; ok {
				fmt.Println("No")
				return
			} else {
				mA[strA] = strB
				mB[strB] = strA
				continue
			}
		}
	}
	fmt.Println("Yes")
}

func IOInitialize() *bufio.Scanner {
	s := bufio.NewScanner(os.Stdin)
	s.Split(bufio.ScanWords)
	return s
}

func Int(s *bufio.Scanner) int {
	if !s.Scan() {
		panic("scan error")
	}

	value, err := strconv.Atoi(s.Text())
	if err != nil {
		panic("text to int error")
	}
	return value
}

func String(s *bufio.Scanner) string {
	if !s.Scan() {
		panic("scan error")
	}

	return s.Text()
}

func scanNums(s *bufio.Scanner, len int) (nums []int) {
	for i := 0; i < len; i++ {
		num := Int(s)
		nums = append(nums, num)
	}
	return
}

func scanstrings(s *bufio.Scanner, len int) (strs []string) {
	for i := 0; i < len; i++ {
		str := String(s)
		strs = append(strs, str)
	}
	return
}


Measured memory_bytes: 8576
#include <set>
#include <cstdio>
using namespace std;
int score[100010],show[100010];
int main(){
	set<pair<int,int> >s;
	int N,R,L,d,t,x,c=0,m,n,i;
	scanf("%d%d%d",&N,&R,&L);
	for(i=1;i<=N;i++)s.insert(make_pair(0,0));
	for(;R--;){
		scanf("%d%d%d",&d,&t,&x);
		show[s.begin()->second]+=t-c,c=t;
		s.erase(make_pair(-score[d],d));
		score[d]+=x;
		s.insert(make_pair(-score[d],d));
	}
	show[s.begin()->second]+=L-c;
	for(n=i=1,m=show[i];i<=N;i++)if(m<show[i])m=show[i],n=i;
	printf("%d\n",n);
}

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

int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	int n, k, sum = 0; cin >> n >> k;
	int ara[n];
	for (int i = 0; i < n; ++i)
	{
		cin >> ara[i];
	}
	sort(ara, ara + n);
	for (int i = 0; i < k; ++i)
	{
		sum += ara[i];
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 3644
import java.util.*;
public class Main {
  public static void main(String[] args){

    int[] array = new int[101];

    for(int i = 1 ;i <=9 ; i++ ){
      for(int j = 1 ;j <=9 ; j++ ){
        array[i*j] = 1;
      }
    }


    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    if(array[a] == 1 ){
      System.out.println("Yes");
    } else {    	
      System.out.println("No");
    }
  }
}

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

int main(){
  string N;
  cin >> N;
  if(N[0] == N[1] && N[1] == N[2]){
    cout << "Yes" << endl;
  }else if(N[1]==N[2] && N[2] == N[3]){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
//Love and Freedom.
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#define ll long long
#define inf 20021225
#define mdn 998244353
using namespace std;
int f[4100][4100];
char ch[2100]; int n;
int pre[2100];
int main()
{
	scanf("%s",ch+1); n = strlen(ch+1);
	for(int i=1;i<=n;i++)	pre[i]=pre[i-1]+ch[i]-'0';
	f[0][0] = 1;// int ans = 0;
	for(int i=1;i<=n*2;i++)
	{
		for(int j=0;j<=min(pre[min(i,n)],i);j++)
		{
			if(j>0 && ((i<=n && pre[i]>=j) || (i>n && pre[n]>=j)))	f[i][j] = (f[i][j] + f[i-1][j-1])%mdn;
			if((i<=n && 2*i-pre[i]>=i-j) || (i>n && 2*n-pre[n]>=i-j))	f[i][j] = (f[i][j] + f[i-1][j])%mdn;
		}
	}
	printf("%d\n",f[n*2][pre[n]]);
	return 0;
}

Measured memory_bytes: 64256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int main() {
	vector<long long> a;
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		long long a1;
		cin >> a1;
		a.emplace_back(a1);
	}
	sort(a.begin(), a.end());
	long long sum = 0, ans = 1000000007;
	for (int i = 0; i < n-1; i++) {
		sum += a[i];
		if (sum * 2 < a[i + 1]) {
			ans = n - i - 1;
		}
	}
	if (ans == 1000000007) {
		ans = n;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a;
  int b;
  int x;
  int y;
  cin >> a >> b;
  x = a % 2;
  y = b % 2;

  if (x == 1 && y == 1) {
    cout << "Odd" << endl;
  }  
  else {
    cout << "Even" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define test int t;cin>>t;while(t--)
void fastcode()
{
    /*
    cout<<fixed<<setprecision(2);
    π = 3.141592653;
    itoa to convert any system itoa(n,bin,2)
    */
    std::ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
int main()
{
    /*freopen(" ","r",stdin);
    freopen(" ","w",stdout);*/
    fastcode();
    int a=0,b=0,c=0,d=0;
    test
    {
        string s;
        cin>>s;
        if(s=="AC")
        {
            a++;
        }
        else if (s=="WA")
        {
            b++;
        }
        else if (s=="TLE")
        {
            c++;
        }
        else
        {
            d++;
        }
    }
    cout<<"AC x "<<a<<"\n";
    cout<<"WA x "<<b<<"\n";
    cout<<"TLE x "<<c<<"\n";
    cout<<"RE x "<<d;
    return 0;
}


Measured memory_bytes: 3672
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String input = sc.nextLine();
        boolean aFound = false;
        boolean bFound = false;
        boolean cFound = false;
        for( int i = 0 ; i<3 ;i++) {
            if(input.charAt(i) == 'a') {
                aFound =true;
            }
            else if(input.charAt(i)=='b') {
                bFound = true;
            }
            else {
                cFound =true;
            }
        }
        if(aFound && bFound && cFound) {
            System.out.println("Yes");
        }
        else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 23764
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
using namespace std;
char s[100010];
int main()
{
	int len=0;
	int p=0,g=0;
	while(cin>>s[++len]) 
	{
		if(s[len]=='p') p++;
		if(s[len]=='g') g++;
	}
	len--;
	int num=len/2;
	//cout<<p<<" "<<g<<" "<<len<<" "<<num<<endl; 
	if(p<g) cout<<num-p;
	if(p==g) cout<<0;
	if(p>g) cout<<num-p;
	return 0;
}

//错一个点 

Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<complex>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using Complex = complex<double>;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1145141919810364364LL;
double PI = acos(-1.0);
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)


ll comb[110][110];
void combinit(ll p) {
	for (int i = 0; i <= p; i++) {
		comb[i][0] = 1LL;
		comb[i][i] = 1LL;
	}
	for (int i = 1; i <= p; i++) {
		for (int j = 1; j <= i - 1; j++) {
			comb[i][j] = comb[i - 1][j] + comb[i - 1][j - 1];
		}
	}
}


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

	combinit(105);
	ll N, P;
	cin >> N >> P;
	ll cnt0 = 0;
	ll cnt1 = 0;
	for (int i = 0; i < N; i++) {
		int A;
		cin >> A;
		if (A % 2 == 0)cnt0++;
		else cnt1++;
	}

	ll ans = 0;
	for (int k = 0; k <= N; k++) {
		for (int l = 0; l <= k; l++) {
			if (l % 2 == P)ans += comb[cnt0][k-l] * comb[cnt1][l];
		}
	}
	puts(ans);
	return 0;
}

Measured memory_bytes: 384
#include <iostream>

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

int partition(int *A, int p, int r) {
  int x = A[r];

  int i = p;
  for (int j = p; j < r; ++j) {
    if (A[j] <= x) {
      int temp = A[i];
      A[i] = A[j];
      A[j] = temp;
      i++;
    }
  }

  int temp = A[i];
  A[i] = A[r];
  A[r] = temp;

  return i;
}

int main() {
  int n;
  std::cin >> n;
  int A[n];
  rep(i, n) std::cin >> A[i];

  int q = partition(A, 0, n - 1);
  rep(i, n) {
    if (i)
      std::cout << ' ';
    if (i == q)
      std::cout << "[" << A[i] << "]";
    else
      std::cout << A[i];
  }

  std::cout << '\n';

  return 0;
}



Measured memory_bytes: 3364
n = int(input())
user = [input() for i in range(n)]

m = int(input())
locked = True
for i in range(m):
    t = input()
    if t in user:
        if locked:
            locked = False
            print("Opened by", t)
        else:
            locked = True
            print("Closed by", t)
    else:
        print("Unknown", t)


Measured memory_bytes: 5608
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0;i < (n);i++)
using ll = long long;
const ll MOD=1000000007;
const double pi=acos(-1);





int main() 
{
  ll a; cin>>a;
  cout<<a+a*a+a*a*a<<endl;
  return 0;
}


Measured memory_bytes: 3588
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e12;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rep(i,N) for(ll i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1
#define MAX_N 100100

ll sq(ll num) { return num*num; }
ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	if (n == 1)return x%MOD;
	ll res = sq(mod_pow(x, n / 2));
	res %= MOD;
	if (n % 2 == 1) {
		res *= x;
		res %= MOD;
	}
	return res;
}
ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

int n, m;
string s[110];
int cnt[110];

int main() {
	cin >> n >> m;
	ll e = 0;
	rep(i, m) {
		cin >> s[i];
		rep(j, n) {
			cnt[i] += (s[i][j] == 'W');
		}
		e += cnt[i];
	}
	ll ans = 0;
	rep(i, n) {
		ll sum = 0;
		rep(j, m) {
			if (s[j][i] == 'W')cnt[j]--;
			else cnt[j]++;
			sum += cnt[j];
		}
		if (sum < e) {
			e = sum;
			ans = i + 1;
		}
	}
	cout << ans << " " << ans + 1 << endl;
}

Measured memory_bytes: 4624
import sys, io, os, re
from bisect import bisect, bisect_left, bisect_right, insort, insort_left, insort_right
from pprint import pprint
from math import sin, cos, pi, radians, sqrt, floor, ceil
from copy import copy, deepcopy
from collections import deque
from fractions import gcd
from functools import reduce
from itertools import groupby
from heapq import heapify, heappush, heappop

# sys.setrecursionlimit(5000)

n1 = lambda: int(sys.stdin.readline().strip())
nn = lambda: list(map(int, sys.stdin.readline().strip().split()))
f1 = lambda: float(sys.stdin.readline().strip())
fn = lambda: list(map(float, sys.stdin.readline().strip().split()))
s1 = lambda: sys.stdin.readline().strip()
sn = lambda: list(sys.stdin.readline().strip().split())
nl = lambda n: [n1() for _ in range(n)]
fl = lambda n: [f1() for _ in range(n)]
sl = lambda n: [s1() for _ in range(n)]
nm = lambda n: [nn() for _ in range(n)]
fm = lambda n: [fn() for _ in range(n)]
sm = lambda n: [sn() for _ in range(n)]

def array1(n, d=0): return [d] * n
def array2(n, m, d=0): return [[d] * m for x in range(n)]
def array3(n, m, l, d=0): return [[[d] * l for y in xrange(m)] for x in xrange(n)]
def linc(A, d=1): return map(lambda x: x + d, A)
def ldec(A, d=1): return map(lambda x: x - d, A)

N = n1()
A = nn()

A.sort(reverse=True)

ans = 0
for i in range(1, N):
    j = i // 2
    ans += A[j]

print(ans)


Measured memory_bytes: 110548
#include <bits/stdc++.h>
using namespace std;
const long long mod = pow(10, 9) + 7;
const long long MOD = 998244353;
const long long INF = 1LL << 60;
const int inf = pow(10, 9) + 7;
template <class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template <class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, int B) {return (A + (B - 1)) / B;}
long long divCeil(int A, long long B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, long long B) {return (A + (B - 1)) / B;}

int main()
{
  int N;
  cin >> N;
  vector<int> a(N);
  int sum = 0;
  for (int i = 0; i < N; i++)
  {
    cin >> a.at(i);
    sum += a.at(i);
  }
  
  int m = inf, ans;
  for (int i = 0; i < N; i++)
  {
    if ( chmin( m, abs(N * a.at(i) - sum) ) ) ans = i;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256