akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Deque;

public class Main {

	private static final int BIG_NUM  = 2000000000;
	private static final int MOD  = 1000000007;

	public static void main(String[] args) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String input_str[] = new String[2];
		Deque<String> list = new ArrayDeque<String>();
		StringBuilder ans = new StringBuilder();

		try {
			int N = Integer.parseInt(br.readLine());

			for(int loop = 0; loop < N; loop++){
				input_str = br.readLine().split("\\s+");

				if(input_str[0].equals("insert")){
					list.addFirst(input_str[1]);
				}else if(input_str[0].equals("delete")){
					list.remove(input_str[1]);
				}else if(input_str[0].equals("deleteFirst")){
					list.removeFirst();
				}else if(input_str[0].equals("deleteLast")){
					list.removeLast();
				}
			}

			if(!list.isEmpty()){
				ans.append(list.getFirst());
				list.removeFirst();
			}
			while(!list.isEmpty()){
				ans.append(" ").append(list.getFirst());
				list.removeFirst();
			}

			System.out.println(ans.toString());

		} catch (NumberFormatException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}




Measured memory_bytes: 601464
from itertools import combinations
from collections import deque

N, M, X = map(int, input().split())
CA = [list(map(int, input().split())) for _ in range(N)]

row = [i for i in range(1, N+1)]
ans = float("INF")
for i in range(1, N+1):
  for v in combinations(row, i):
    q = deque(v)
    cost = 0
    Asum = [0]*M
    while q:
      a = q.popleft() - 1
      cost += CA[a][0]
      for j in range(M):
        Asum[j] += CA[a][j+1]
    flag = True
    for m in range(M):
      if Asum[m] < X:
        flag = False
    if flag:
      ans = min(ans, cost)
if ans == float("INF"):
  print(-1)
else:
  print(ans)

Measured memory_bytes: 9472
n, m = map(int, input().split())
a = [int(x) for x in input().split()]
p = [(a[i], 1) for i in range(n)]

for i in range(m):
    b, c = map(int, input().split())
    p.append((c, b))
    
p.sort()
p.reverse()
ans, count = 0, n
for (s, t) in p:
    k = min(count, t)
    ans += s * k
    count -= t
    if count <= 0:
        break
    
print(ans)



Measured memory_bytes: 28936
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {
   
fast();
//ll  t;cin>>t;while(t--)
{
  ll n,l;
  cin>>n>>l;
  string s[n];
  map<string,int>m;
  vector<string>v;
  for(int i=0;i<n;i++)
  {
   
    cin>>s[i];
    m[s[i]]=i;
    v.pb(s[i]);
    
  }
  sort(v.begin(),v.end());
  string zz="";
  for(auto it=v.begin();it!=v.end();it++)
  {
    zz=zz+*it;
  }
  
  cout<<zz<<endl;

}
return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <map>
#include <utility>

using namespace std;

int main(int argc, char const *argv[])
{
    int N;
    cin >> N;
    pair<pair<string, int>, int> p[100];
    string S;
    int P;
    int num;
    for (int i = 0; i < N; i++)
    {
        cin >> S >> P;
        p[i] = make_pair(make_pair(S, -1 * P), i);
    }
    
    sort(p, p + N);

    for (int i = 0; i < N; i++)
    {
        cout << p[i].second + 1 << endl;
    }

    return 0;
}

Measured memory_bytes: 1144
//https://onlinejudge.u-aizu.ac.jp/challenges/sources/JOI/Final/0516?year=2007

#include <bits/stdc++.h>

using namespace std;

int main() {
    int n, k;

    while (cin >> n >> k, n | k) {
        vector<int> a((unsigned) n);
        for (int i = 0; i < n; ++i) {
            cin >> a[i];
        }

        int s = accumulate(a.begin(), a.begin() + k, 0);
        int ans = s;
        for (int i = k; i < n; ++i) {
            s += a[i] - a[i - k];
            ans = max(ans, s);
        }

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

/*
 *
 */


Measured memory_bytes: 2988
from functools import reduce
from fractions import gcd
import math
import bisect
import itertools
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
INF = float("inf")


def main():
    N, K = map(int, input().split())
    print(min(N%K, K - N%K))


if __name__ == '__main__':
    main()

Measured memory_bytes: 66028
import sys
 
line = sys.stdin.readline()
str_a, str_b = line.split(" ")
a = int(str_a)
b = int(str_b)
 
if a > b:
    c = ">"
elif a < b:
    c = "<"
else:
    c = "=="
 
print "a %s b" % (c)

Measured memory_bytes: 6364
N = int(input())
ABs = []
As = []
Bs = []

tk = 0
ao = 0

for i in range(N):
  a,b = map(int, input().split())
  As.append(a)
  Bs.append(b)
  ABs.append((a+b, i))
  
ABs.sort(key=lambda x:x[0], reverse=True)

for i in range(N):
  if i%2 == 0:
    tk += As[ABs[i][1]]
  else:
    ao += Bs[ABs[i][1]]
    
print(tk-ao)

Measured memory_bytes: 96776
import math
from operator import mul
from functools import reduce

def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result
xy = list(map(int, input().split()))

if (2*xy[1]-xy[0]) % 3 == 0 and (2*xy[0]-xy[1]) % 3 == 0 and 2*xy[1]-xy[0] > -1 and 2*xy[0]-xy[1] > -1:
    a = (2*xy[1]-xy[0]) // 3
    b = (2*xy[0]-xy[1]) // 3
    print(cmb(a+b, a)%(10**9 + 7))
else:
    print(0)

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

int main() {
    int n, m;
    cin >> n >> m;
    priority_queue<int> que;
    for (int i = 0; i < n; ++i) {
        int a;
        cin >> a;
        que.push(a);
    }
    for (int i = 0; i < m; ++i) {
        int b = que.top();
        que.pop();
        que.push(b/2);
    }
    long long ans = 0;
    for (int i = 0; i < n; ++i) {
        ans += que.top();
        que.pop();
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 892
#include <stdio.h>
#include <string.h>
int main(){
  int N,i,j,min,flag;
  char C[36][3],T[3],D[36][3];
  scanf("%d",&N);
  for(i = 0; i < N; i++){
    scanf("%s",C[i]);
    strcpy(D[i],C[i]);
  }
  for(i = 0; i < N; i++){
    for(j = N-1; j >= i+1; j--){
      if((C[j][1] - '0') < (C[j-1][1] -'0')){
        strcpy(T,C[j]);
        strcpy(C[j],C[j-1]);
        strcpy(C[j-1],T);
      }
    }
  }
for(i = 0; i < N-1; i++){
    printf("%s ",C[i]);
  }
  printf("%s\n",C[i]);
  printf("Stable\n");

  for(i = 0; i < N; i++){
    min = i;
    for(j = i; j < N; j++){
      if((D[j][1] - '0') < (D[min][1] - '0')){
        min = j;
      }
  }
    strcpy(T,D[i]);
    strcpy(D[i],D[min]);
    strcpy(D[min],T);
  }
    for(i = 0; i < N-1; i++){
      printf("%s ",D[i]);
    }
    printf("%s\n",D[i]);
    flag = 1;
for(i = 0; i < N; i++){
      if(strcmp(C[i],D[i]) != 0) flag = 0;
    }
    if(flag)printf("Stable\n");
    else printf("Not stable\n");
    return 0;
}

Measured memory_bytes: 1048
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
int flag[15];
int x,y;

int main()
{
	scanf("%d%d",&x,&y);
	flag[1] = flag[3] = flag[5] = flag[7] = flag[8] = flag[10] = flag[12] = 1;
    flag[4] = flag[6] = flag[9] = flag[11] = 2;
    if(flag[x] == flag[y]) printf("Yes\n");
    else printf("No\n");

	return 0;
}

Measured memory_bytes: 128
from bisect import bisect_right

n = int(input())
a = sorted(list(map(int, input().split())))

pos = bisect_right(a, a[-1]/2)
if pos == 0 or abs(a[-1]/2 - a[pos-1]) > abs(a[-1]/2 - a[pos]):
    print(a[-1], a[pos])
else:
    print(a[-1], a[pos-1])

Measured memory_bytes: 85584
import java.io.*;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.StringTokenizer;

public class Main {

    public static void main(String[] args) throws IOException {
        init();
        int n = nextInt(), k = nextInt();

        ArrayList<Long> h = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            h.add(nextLong());
        }

        h.sort(Comparator.reverseOrder());
        long ans = 0;
        for (int i = k; i < n; i++) {
            ans += h.get(i);
        }

        System.out.println(ans);
    }

    //Input Reader
    private static BufferedReader reader;
    private static StringTokenizer tokenizer;

    private static void init() {
        reader = new BufferedReader(new InputStreamReader(System.in));
        tokenizer = new StringTokenizer("");
    }

    private static String next() throws IOException {
        String read;
        while (!tokenizer.hasMoreTokens()) {
            read = reader.readLine();
            if (read == null || read.equals(""))
                return "-1";
            tokenizer = new StringTokenizer(read);
        }

        return tokenizer.nextToken();
    }

    private static int nextInt() throws IOException {
        return Integer.parseInt(next());
    }

    private static long nextLong() throws IOException {
        return Long.parseLong(next());
    }
}

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

const int N=2e5+10;

int a[N],n;

int main()
{
    cin>>n;
    for(int i=0;i<n;i++) scanf("%d",a+i);
    ll ans=0;
    for(int i=1;i<n;i++) if(a[i]<a[i-1]) ans+=a[i-1]-a[i],a[i]=a[i-1];
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 4532
using CompLib.Util;
using System;

public class Program
{

    public void Solve()
    {
        var sc = new Scanner();
        int n = sc.NextInt();
        int m = sc.NextInt();

        long ans = 100 * (n - m) + 1900 * m;

       
        for (int i = 0; i < m; i++)
        {
            ans *= 2;
        }

        Console.WriteLine(ans);
    }

    public static void Main(string[] args) => new Program().Solve();
}

namespace CompLib.Util
{
    using System;
    using System.Linq;
    class Scanner
    {
        private int _index;
        private string[] _line;
        const char separator = ' ';

        public Scanner()
        {
            _index = 0;
            _line = new string[0];
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(separator);
                _index = 0;
            }
            return _line[_index++];
        }
        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(separator);
            _index = _line.Length;
            return _line;
        }
        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
    }
}

Measured memory_bytes: 11092
n, k = map(int, input().split())
a = list(map(int, input().split()))
ans = 0  # f(x)の最大値
x = 0 ## x(十進数)

## A_i <= 10**12なので A_i <= 2**40→２進数で41桁以下
for i in range(40, -1, -1): ## i <- 40, 39, 38, ... , 0 
    c = 0
    for ai in a:
        if (ai >> i) & 1: ## ai二進数のi+1桁目が1かどうか
            c += 1  ## すべてのaiについてi+1桁目の1の個数
            
    ### n-c「すべてのaiについてのi+1桁目の０の個数」が１の個数を上回るかつ
    ### xのi桁目に1を立てたとき十進数でxがk以下
    if (n - c) > c and x + (1 << i) <= k:
        x += 1 << i## xのi桁目は1を立てる。
        ans += (n - c) * (1 << i)## 答えに(n-c)*2^(i)をたす
    else:
        ## xのi桁目は0を立てる
        ans += c * (1 << i)
print(ans)

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

template<typename First, typename Second, typename Third>
struct triple {
   First first;
   Second second;
   Third third;
};

using namespace std;

void solve(){
      long long x,h;
      cin>>x;
      bool f=true;
      for(int i=0;i<x;i++){
               cin>>h;
               if(h%2==0){
                    if(h%3!=0&&h%5!=0){
                         f=false;
                    }
               }
      }
      if(f)
         cout<<"APPROVED";
      else 
        cout<<"DENIED";
}

int main(){
    std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
   
 
    solve(); 
   
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

#define MAX 10000
#define NIL -1

struct Node{
	int parent,left,right;
};

struct Node T[MAX];

int D[MAX];
int H[MAX];
int n;

void setDepth(int u,int d){
	if(u==NIL){
		return;
	}
	
	D[u]=d;
	setDepth(T[u].left,d+1);
	setDepth(T[u].right,d+1);
}

int setHeight(int u){
	int h1=0;
	int h2=0;
	
	if(T[u].left!=NIL){
		h1=setHeight(T[u].left)+1;
	}
	
	if(T[u].right!=NIL){
		h2=setHeight(T[u].right)+1;
	}
	
	return H[u] = (h1 > h2 ? h1 : h2);
}

int getSibling(int u){
	if(T[u].parent==NIL){
		return NIL;
	}
	
	if(T[T[u].parent].left != u && T[T[u].parent].left != NIL){
		return T[T[u].parent].left;
	}
	
	if(T[T[u].parent].right!=u && T[T[u].parent].right!= NIL){
		return T[T[u].parent].right;
	}
		
	return NIL;
}
	
void print(int u){
	printf("node %d: ",u);
	printf("parent = %d, ",T[u].parent);
	printf("sibling = %d, ",getSibling(u));
	
	int deg=0;
	
	if(T[u].left!=NIL){
		deg++;
	}
	if(T[u].right!=NIL){
		deg++;
	}
	
	printf("degree = %d, ",deg);
	printf("depth = %d, ",D[u]);
	printf("height = %d, ",H[u]);
	
	if(T[u].parent==NIL){
		printf("root\n");
	}
	else if(T[u].left == NIL && T[u].right == NIL){
		printf("leaf\n");
	}
	else{
		printf("internal node\n");
	}
}
	
int main (void){
	int i;
	int v,l,r;
	int root=0;
	
	scanf("%d",&n);
	
	for(i=0;i<n;i++){
		T[i].parent=NIL;
	}
	
	for(i=0;i<n;i++){
		scanf("%d %d %d",&v,&l,&r);
		T[v].left=l;
		T[v].right=r;
		if(l!=NIL){
			T[l].parent=v;
		}
		if(r!=NIL){
			T[r].parent=v;
		}
	}
	
	for(i=0;i<n;i++){
		if(T[i].parent==NIL){
			root=i;
		}
	}
		
	setDepth(root,0);
	setHeight(root);
		
	for(i=0;i<n;i++){
		print(i);
	}
	
	return 0;
}										


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

int main()
{
    int x;
    cin >> x;
    x = x / 200;
    switch(x) {
        case 2: printf("8"); break;
        case 3: printf("7"); break;
        case 4: printf("6"); break;
        case 5: printf("5"); break;
        case 6: printf("4"); break;
        case 7: printf("3"); break;
        case 8: printf("2"); break;
        case 9: printf("1"); break;
    }

    return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ii = pair<int, int>;
#define sz(x) (int)(x).size()
/* --- */
ll freq[6], taken[6];

ll calc (int k) {
	if (k == 5) {
		int cnt = 0;
		for (int i = 0; i < 5; i++) cnt += taken[i];
		if (cnt != 3) return 0;
		ll ans = 1;
		for (int i = 0; i < 5; i++) if (taken[i])
			ans *= freq[i];
		return ans;
	}

	ll ans = 0;
	taken[k] = 0;
	ans += calc(k + 1);
	taken[k] = 1;
	ans += calc(k + 1);
	return ans;
}

int main() {
	char buf[100];
	int n;
	map<char, int> id;
	string s = "MARCH";
	for (int i = 0; i < sz(s); i++) id[s[i]] = i;
	memset(freq, 0, sizeof freq);
	memset(taken, 0, sizeof taken);

	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%s", buf);
		if (id.find(buf[0]) == id.end()) continue;
		freq[id[buf[0]]]++;
	}
	
	printf("%lld\n", calc(0));
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
using namespace __gnu_pbds;
using namespace std;
 
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long ll;
typedef long double ld;	

ll mod = 1e9+7;

struct job{
	ll time;
	ll dead;
	bool operator <(const job& rhs) const{
		return dead < rhs.dead;
	}
};

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n;
	cin >> n;
	vector <job> arr(n);
	for (int z=0;z<n;z++){
		cin >> arr[z].time >> arr[z].dead;
	}
	sort(arr.begin(),arr.end());
	ll current = 0;
	bool ok = true;
	for (int z=0;z<n;z++){
		current += arr[z].time;
		if (current > arr[z].dead){
			ok = false; break;
		}
	}
	if (ok) cout << "Yes" << endl;
	else cout << "No" << endl;
	cin >> n;
}

Measured memory_bytes: 3456
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoderTemplate {
    class Program {
        static void Main (string[] args) {
            var N = ReadInt ();
            var h = ReadInts ();
            Console.WriteLine (Go (h));
        }

        static int Go (IList<int> h) {
            if (h.Count == 0) {
                return 0;
            }
            var minIndex = h.IndexOf (h.Min ());
            var grows = h.Select (x => x - h[minIndex]);
            // PrintEnum (h);
            // PrintEnum (grows);
            return h[minIndex] + Go (grows.Take ((minIndex + 1) - 1).ToList ()) + Go (grows.Skip (minIndex + 1).ToList ());
        }

        /* Input & Output*/
        static int ReadInt () {
            return int.Parse (Console.ReadLine ());
        }
        static List<int> ReadInts () {
            return Console.ReadLine ().Split (' ').Select (c => int.Parse (c)).ToList ();
        }
        static List<List<int>> ReadColumns (int n) {
            /*
            入力例
            A1 B1
            A2 B2
            ...
            An Bn

            出力例
            [[A1,A2,...,An], [B1,B2,...,Bn]]
            */
            var seq = Enumerable.Range (0, n).Select (i => ReadInts ()).ToList ();
            return Enumerable.Range (0, seq.First ().Count ()).Select (i => seq.Select (items => items[i]).ToList ()).ToList ();
        }
        static void PrintEnum<T> (IEnumerable<T> list) {
            Console.Write (list.First ());
            foreach (var item in list.Skip (1)) {
                Console.Write ($" {item}");
            }
            Console.Write ("\n");
        }
        static void PrintLnEnum<T> (IEnumerable<T> list) {
            foreach (var item in list) {
                Console.WriteLine (item);
            }
        }

        /* Numeric Function */
        static int Fact (int n) {
            return Enumerable.Range (1, n).Aggregate (1, ((i, k) => i * k));
        }
        static int PermNum (int n, int m) {
            if (m > n) {
                return 0;
            }
            return Enumerable.Range (n - m, m + 1).Aggregate (1, ((i, k) => i * k));
        }
        static int CombNum (int n, int m) {
            return PermNum (n, m) / Fact (m);
        }
        // 最大公約数 (m ≧ n)
        static int GCD (int m, int n) {
            if (n == 0) {
                return m;
            } else {
                return GCD (n, m % n);
            }
        }
        // 最小公倍数 (m ≧ n)
        static int LCM (int m, int n) {
            return GCD (m, n) / (m * n);
        }

    }
}

Measured memory_bytes: 13280
#include<bits/stdc++.h>
using namespace std;
long long int k,i,j,n,m,l,x,y,z;
int main()
{
    scanf("%lld",&n);
    l=0;
    x=0;
    for(i=1;i<=sqrt(n);i++){
        if(n%i==0){
            if(i==1){
                x=n-1;
            }
            else{
                l=n/i;
                l+=i;
                l-=2;
                if(l<x)
                    x=l;
            }
        }
    }
    printf("%lld",x);

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define rep(i,x,y) for(int i=x;i<y;i++)
#define repr(i,x,y) for(int i=x;i>=y;i--) 
#define mod 1000000007
using namespace std;
 
void Onigiri()
{
  int n;
  cin>>n;
  string s;
  cin>>s;
  int cntR[n+2]={0},cntB[n+2]={0},cntG[n+2]={0};
  for(int i=n-1;i>=0;i--)
  {
    cntR[i]=cntR[i+1];
    cntG[i]=cntG[i+1];
    cntB[i]=cntB[i+1];
    cntR[i]+=(s[i]=='R')?1:0;
    cntG[i]+=(s[i]=='G')?1:0;
    cntB[i]+=(s[i]=='B')?1:0;
  }

  int ans=0;
  for(int i=0;i<n;i++)
  {
    for(int j=i+1;j<n;j++)
    {
        if(s[i]==s[j])continue;
        int rok;if(s[i]=='R'||s[j]=='R')rok=0;else rok=1;
        int bok;if(s[i]=='B'||s[j]=='B')bok=0;else bok=1;
        int gok;if(s[i]=='G'||s[j]=='G')gok=0;else gok=1;
        if(rok)
        {
            ans+=cntR[j+1];
            if(s[j+j-i]=='R')ans-=1;
        }
        if(gok)
        {
            ans+=cntG[j+1];
            if(s[j+j-i]=='G')ans-=1;
        }
        if(bok)
        {
            ans+=cntB[j+1];
            if(s[j+j-i]=='B')ans-=1;
        }
 
    }
  }
  cout<<ans;
}
signed main()
{
   ios_base::sync_with_stdio(false);cin.tie(NULL);
   #ifdef Zoro
   freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
   #endif  
 
   int t=1; 
  // cin>>t;
 
   while(t--)
   {Onigiri();}
 
   cerr<<"\n"<<(float)clock()/CLOCKS_PER_SEC*1000<<" ms"<<endl;
   return 0;
}

Measured memory_bytes: 3844
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF (1ll << 60)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
using vl = vector<ll>;
using vvl = vector<vl>;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int main() {
    ll K, A, B;
    cin >> K >> A >> B;
    if(A + 2 >= B or K < A) {
        cout << K + 1 << endl;
        return 0;
    }
    ll res = A;
    K -= A - 1;
    if(K % 2 == 1) {
        res++;
        K--;
    }
    res += (B - A) * (K / 2);
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
//start 2019/8/9 20:24
#include<iostream>
using namespace std;

int main(){
    int N;
    bool flag;
    cin >> N;
    int H[N];
    for(int i=0; i<N; i++){
        cin >> H[i];
    }

    flag=false;
    for(int i=0; i<N-1; i++){
        if(  H[i]-H[i+1] > 1  ){
            cout << "No" << endl;
            return 0;
        }else if( ( H[i]-H[i+1] == 1)  ){
            if(flag){
            cout << "No" << endl;
            return 0;
            }
            H[i]-=1;
            flag=true;
        }else if( H[i]-H[i+1] < 0 ){
            flag=false;
        }
    }

    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<set>
#include<cmath>
#include<iomanip>
#include<functional>
using namespace std;

int INF = 1e9 + 7;

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

int main() {
	while (1) {
		ll a, b;
		cin >> a >> b;
		if (a == 0) return 0;

		b -= a;

		ll ans1000 = b / 1000;
		b %= 1000;

		ll ans500 = b / 500;
		b %= 500;

		ll ans100 = b / 100;

		cout << ans100 << " " << ans500 << " " << ans1000 << endl;
	}
}


Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main() {
	//min(a,b)...a,bの小さいほう
	//max(a,b)...     大きいほう
	int a;
	int b;
	int c;
	int d;
	int e;
	std::cin >> a;
	if (a < 1000) {
		cout << "ABC" << "\n";
	}
	else if(a >= 1000) {
		cout << "ABD" << "\n";
	}
	
	std::cin >> e;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<cmath>
#include<cstdio>
#include<cstring>
#include<bitset>
#include<iostream>
#include<algorithm>
#include<string>
#include<utility>
#include<tuple>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<numeric>
#include<functional>
#include<iomanip>
#include<random>
using namespace std;


#define IOS ios::sync_with_stdio(false),cin.tie(0)
#define REP(i,n) for(ll i = 0;i < n;i++)
#define FOR(i,a,b) for(ll i = a;i < b;i++)
#define ALL(x) (x).begin(),(x).end()
#define dump(x) cout << (x) << endl
#define LMAX 9223372036854775807LL
#define LMIN -9223372036854775807LL

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) {}
	void unionSet(int x, int y) {
		x = root(x), y = root(y);
		if (x != y) {
			if (data[y] < data[x])swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

ll gcd(ll a, ll b) {
	if (b == 0)return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}
ll digitsum(ll a) {
	int sum = 0;
	while (a) {
		sum += a % 10;
		a /= 10;
	}
	return sum;
}
int getdigit(ll a) {
	return to_string(a).size();
}
int countpow(ll a, ll b) {
	int ans = 0;
	if (b == 0)return -1;
	while (1) {
		if (a % b == 0) {
			a /= b;
			ans++;
		}
		else break;
	}
	return ans;
}
int to_num(char c) {
	if (c >= '0' && c <= '9')return (c - '0');
	else return -1;
}



int main() {
	IOS;
	int h, w;
	cin >> h >> w;
	vector<vector<ll>> a(10, vector<ll>(10, 0));
	REP(i, 10) {
		REP(j, 10)cin >> a[i][j];
	}
	REP(k, 10) {
		REP(i, 10) {
			REP(j, 10)a[i][j] = min(a[i][j], a[i][k] + a[k][j]);
		}
	}
	ll sum = 0;
	REP(i, h) {
		REP(j, w) {
			int x;
			cin >> x;
			if (x != -1)sum += a[x][1];
		}
	}
	dump(sum);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i=0; i<int(n); i++)
#define RNG(i, f, t) for(int i=int(f); i<=int(t); i++)
#define REV(i, f, t) for(int i=int(f); i>=int(t); --i)
#define ALL(v) (v).begin(), (v).end()
bool RELAXED = false;
template<int,typename T> struct MINMAX{ T val; MINMAX(T val) : val(val) {} };
template<typename T> MINMAX<1,T> MAX(T val) { return MINMAX<1,T>(val); };
template<typename T> MINMAX<2,T> MIN(T val) { return MINMAX<2,T>(val); };
template<typename T, typename U> inline T& operator|=(T &lhs, MINMAX<1,U> rhs) { return lhs = (rhs.val > lhs ? (RELAXED=true,rhs.val) : (RELAXED=false,lhs)); }
template<typename T, typename U> inline T& operator|=(T &lhs, MINMAX<2,U> rhs) { return lhs = (rhs.val < lhs ? (RELAXED=true,rhs.val) : (RELAXED=false,lhs)); }
template<typename T> inline vector<T> readVector(int n) { vector<T> vec(n); FOR(i,n) cin>>vec[i]; return vec; }
template<typename T> void EXIT(T answer) { cout<<answer<<endl; exit(0); }
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef signed long long int ll;

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

    int n;
    string s;
    cin>>n>>s;

    char prev='?';
    int ans=0;
    for(char c : s)
    {
        if(c!=prev)
            ans++;
        prev=c;
    }
    cout<<ans<<endl;

    return 0;
}



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

int vector_finder(std::vector<int> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return true;
  }
  else { // 発見できなかったとき
    return false;
  }
}

int main(){
    int n;
    // vector<vector<int>> = vec(3, vector<int>(3));
    int array[3][3];
    

    rep(i,3){
        int a,b,c;
        cin >> a >> b >> c;
        array[i][0] = a;
        array[i][1] = b;
        array[i][2] = c;
    }
    cin >> n;
    vector<int> vec(n);
    rep(i,n){
        int tmp;
        cin >> tmp;
        vec.push_back(tmp);
    }
    
    if(vector_finder(vec, array[0][0]) && vector_finder(vec, array[0][1]) && vector_finder(vec, array[0][2])){
        cout << "Yes" << endl;
    }
    else if(vector_finder(vec, array[1][0]) && vector_finder(vec, array[1][1]) && vector_finder(vec, array[1][2])){
        cout << "Yes" << endl;
    }
    else if(vector_finder(vec, array[2][0]) && vector_finder(vec, array[2][1]) && vector_finder(vec, array[2][2])){
        cout << "Yes" << endl;
    }
    else if(vector_finder(vec, array[0][0]) && vector_finder(vec, array[1][0]) && vector_finder(vec, array[2][0])){
        cout << "Yes" << endl;
    }
    else if(vector_finder(vec, array[0][1]) && vector_finder(vec, array[1][1]) && vector_finder(vec, array[2][1])){
        cout << "Yes" << endl;
    }
    else if(vector_finder(vec, array[0][2]) && vector_finder(vec, array[1][2]) && vector_finder(vec, array[2][2])){
        cout << "Yes" << endl;
    }
    else if(vector_finder(vec, array[0][0]) && vector_finder(vec, array[1][1]) && vector_finder(vec, array[2][2])){
        cout << "Yes" << endl;
    }
    else if(vector_finder(vec, array[2][0]) && vector_finder(vec, array[1][1]) && vector_finder(vec, array[0][2])){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }


    
}

Measured memory_bytes: 256
#pragma region header
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define resort(v) sort((v).rbegin(), (v).rend())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
using ll = long long;
using P = pair<int, int>;
/* ----------------よく使う数字や配列----------------- */
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
constexpr ll mod = 1e9+7;
constexpr int inf = INT32_MAX/2;
constexpr ll INF = LLONG_MAX/2;
constexpr long double eps = DBL_EPSILON;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */

/* --------------------テンプレート------------------ */
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
/* ----------------------end----------------------- */

/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i % mod;
}
ll gcd(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcd(b, a % b); 
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a / gcd(a, b) * b ;
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
bool isprime(int n) { //素数判定
    if(n==1)return false;
    if(n==2)return true;
    for(int i = 2;i<=sqrt(n);i++) {
        if(n%i==0) return false;
    }
    return true;
}
/* ----------------------end----------------------- */
#pragma endregion

signed main() {
    int n,k;cin >> n >> k;
    cout << (n/k)*(n/k)*(n/k)+(!(k&1))*(n*2>=k)*((n-k/2)/k+1)*((n-k/2)/k+1)*((n-k/2)/k+1) << endl;
    return 0;
}

Measured memory_bytes: 3664
// inputに入力データ全体が入る
function Main(input) {
	var tmp = input.split("\n")[0].split(" ");
	var a = Number.parseInt(tmp[0]);
	var b = Number.parseInt(tmp[1]);
	var k = Number.parseInt(tmp[2]);
  	if (0 < k) {
  		if (k < a) {
    		a -= k;
      		k = 0;
    	} else {
          	k -= a;
          	a = 0;
        }
    }
  	if (0 < k) {
  		if (k < b) {
    		b -= k;
      		k = 0;
    	} else {
          	k -= b;
          	b = 0;
        }
    }
  	//出力
	console.log('%s %s', a, b);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define all(a) a.begin(), a.end()

signed main() {
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	int n; cin >> n;
	vector <int> a(n), b(n);

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

	int check = 0;

	for(int i = n - 1; i >= 0; i--) {
		a[i] += check;
		if(a[i] % b[i] == 0) continue;
		check += b[i] - (a[i] % b[i]);
	}

	cout << check << endl;

	return 0;
}

Measured memory_bytes: 4784
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv,
    std.functional, std.math, std.numeric, std.range, std.stdio, std.string,
    std.random, std.typecons, std.container;

ulong MAX = 1_000_100, MOD = 1_000_000_007, INF = 1_000_000_000_000;
alias sread = () => readln.chomp();
alias lread(T = long) = () => readln.chomp.to!(T);
alias aryread(T = long) = () => readln.split.to!(T[]);
alias Clue = Tuple!(long, "x", long, "y", long, "h");
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);

long cnt;

void main()
{
    auto n = lread();
    auto a = aryread();
    auto box = new long[](n + 1);
    foreach(e; a)
        box[e]++;
    long s;
    foreach (e; box)
    {
        if(e > 1)
        {
            s += e * (e - 1) / 2;
        }
    }
    foreach(i; iota(n))
    {
        writeln(s - (box[a[i]] - 1));
    }
}

bool is_reverse(string s)
{
    bool ret = true;
    foreach(i; iota(s.length))
    {
        ret &= (s[i] == s[$ - 1 - i]);
    }
    return ret;
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}


Measured memory_bytes: 13988
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Map;
import java.util.Map.Entry;

import java.util.PriorityQueue;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.TreeSet;

public class Main {
	
	public static void main(String[] args) throws IOException {
		try(final Scanner sc = new Scanner(System.in)){
			final int N = sc.nextInt();
			final int M = sc.nextInt();
			
			Map<Integer, Set<Integer>> adj = new HashMap<Integer, Set<Integer>>();
			for(int i = 0; i < N; i++) { adj.put(i, new HashSet<Integer>()); }
			
			int[] in_degs = new int[N];
			
			for(int i = 0; i < M; i++) {
				final int x = sc.nextInt() - 1;
				final int y = sc.nextInt() - 1;
				
				adj.get(x).add(y);
				in_degs[y]++;
			}
			
			LinkedList<Integer> queue = new LinkedList<Integer>();
			for(int i = 0; i < N; i++) {
				if(in_degs[i] == 0) { queue.add(i); }
			}
			
			int[] DP = new int[N];
			
			while(!queue.isEmpty()) {
				final int node = queue.poll();
				
				for(final int next : adj.get(node)) {
					in_degs[next]--;
					DP[next] = Math.max(DP[next], DP[node] + 1);
					
					if(in_degs[next] == 0) { queue.add(next); }
				}
			}
			
			System.out.println(Arrays.stream(DP).max().getAsInt());
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

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

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}

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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second

typedef long long ll;
typedef pair<int,int> P;
typedef pair<P,P> PP;

struct edge {
	int to,cost;
	edge(int t,int c):to(t),cost(c) {}
};

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

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

struct Edge {
	int to,cap,rev;
	Edge(int t,int c,int r):to(t),cap(c),rev(r) {}
};

int n,a[105];
vector<Edge> g[105];
bool used[105];

void add_edge(int from,int to,int cap) {
	g[from].pb(Edge(to,cap,g[to].size()));
	g[to].pb(Edge(from,0,g[from].size()-1));
}

int dfs(int v,int t,int f) {
	if(v==t) return f;
	used[v]=true;

	REP(i,g[v].size()) {
		Edge &e=g[v][i];
		if(!used[e.to]&&e.cap>0) {
			int d=dfs(e.to,t,min(e.cap,f));
			if(d>0) {
				e.cap-=d;
				g[e.to][e.rev].cap+=d;
				return d;
			}
		}
	}
	return 0;
}

ll max_flow(int s,int t) {
	ll f=0;
	while (true) {
		fill(used,used+105,false);
		int d=dfs(s,t,INF);
		if(d==0) return f;
		f+=d;
	}
	return f;
}

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

	cin>>n;
	REP(i,n) cin>>a[i+1];

	ll sum=0;
	int s=0,t=n+1;
	FOR(i,1,n+1) {
		if(a[i]<=0) add_edge(s,i,-a[i]);
		else {
			sum+=a[i];
			add_edge(i,t,a[i]);
		}
	}
	FOR(i,1,n+1) for(int j=2*i;j<=n;j+=i) add_edge(i,j,INF);

	cout<<sum-max_flow(s,t)<<endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod=1e9+7;
ll n,k,ans,now,s,dp[100000][101],sum[100000][101];

int main(){
  cin >> n >> k;
  ll t=sqrt(n);
  for(ll i=1;i<=t;i++) dp[i][1]=1;
  now=t+1,s=n/t-1;
  for(ll i=s;i>=1;i--){
    dp[now][1]=n/i-n/(i+1);
    now++;
  }
  for(ll i=2;i<=k;i++){
    for(ll j=1;j<now;j++){
      sum[j][i-1]=(sum[j-1][i-1]+dp[j][i-1])%mod;
    }
    for(ll j=1;j<now;j++){
      dp[j][i]=(sum[now-j][i-1]*dp[j][1])%mod;
    }
  }
  for(ll i=1;i<now;i++){
    ans=(ans+dp[i][k])%mod;
  }
  cout << ans << endl;
}

Measured memory_bytes: 102656
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007 

int main() {
	ll n,h;
	cin>>n>>h;
	vector<ll>a,b;
	ll amax=0;
	for(ll i=0;i<n;i++){
		ll x,y;
		cin>>x>>y;
		amax=max(x,amax);
		b.push_back(y);
	}
	sort(b.begin(),b.end());
	reverse(b.begin(),b.end());
	ll cnt=0,dm=0,now=0;
	while(dm<h&&now!=n){
		if(b[now]<amax){
			break;
		}
		dm+=b[now];
		now++;
		cnt++;
	}
	cout << cnt+max(ll(0),(h-dm+amax-1)/amax);
	// your code goes here
	return 0;
}

Measured memory_bytes: 1400
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>
 
#define REP(i,n) for(i=0;i<n;i++)
 
int iin() {
    int i;
    scanf("%d", &i);
    return i;
}
 
long long llin() {
    long long i;
    scanf("%lld", &i);
    return i; 
}
 
double din() {
    double i;
    scanf("%lf", &i);
    return i;
}
 
char cin() {
    char c;
    scanf("%c", &c);
    return c;
}
 
void stin(char *s) {
    scanf("%s", s);
}
 
void iout(int i) {
    printf("%d\n", i);
}
 
void llout(long long i) {
    printf("%lld\n", i);
}
 
void dout(double i) {
    printf("%lf\n", i);
}
 
void cout(char c) {
    printf("%c\n", c);
}
 
void stout(char *s) {
    printf("%s\n", s);
}
 
int main() {
  	int f = 0, n = 0;
  	int m, i;
  	REP(i, 3) {
    	m = iin();
  		if (m == 5) f++;
  		if (m == 7) n++;
    }
  	(f == 2 && n == 1) ? stout("YES") : stout("NO");
    return 0;
}

Measured memory_bytes: 128
N = int(input())
R = []

for i in range(N):
    x, l = map(int, input().split())
    R.append((x + l, x - l))

R.sort()

l = -(1 << 40)

cnt = 0
for r in R:
    if l <= r[1]:
        cnt += 1
        l = r[0]

print(cnt)


Measured memory_bytes: 22736
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;
int e, y;
int main(){
    cin >> e >> y;
    if(e==0){
        if(1868<=y&&y<=1911) cout << "M" << y-1867<<endl;
        else if(1912<=y&&y<=1925) cout << "T" << y-1911 << endl;
        else if(1926<=y&&y<=1988)cout << "S" << y-1925 << endl;
        else if(1989<=y&&y<=2016) cout << "H" << y-1988<<endl;
    }else if(e==1){
        cout << 1867+y<<endl;
    }else if(e==2){
        cout << 1911+y << endl;
    }else if(e==3){
        cout << 1925+y << endl;
    }else{
        cout << 1988+y << endl;
    }
    return 0;
}


Measured memory_bytes: 3112
#include <iostream>
#include <fstream>
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <numeric>
#include <functional>
#include <string> 
#include <vector>
#include <bitset>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>

using namespace std;
using ll = long long;

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;

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

const ll MOD = (ll)1e9 + 7;
const ll HINF = (ll)1e18;
const ll LINF = (ll)1e9;
const long double PI = 3.1415926535897932384626433;

template<class T> void corner(bool flg, T hoge) {
	if (flg) {
		cout << hoge << endl;
		exit(0);
	}
	else return;
}

template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {
	o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;
}

template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {
	o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;
}

template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {
	o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;
}

template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {
	o << "{" << obj.first << ", " << obj.second << "}"; return o;
}

template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {
	o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;
}

void print(void) {
	cout << endl;
}

template <class Head> void print(Head&& head) {
	cout << head;
	print();
}

template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {
	cout << head << " ";
	print(forward<Tail>(tail)...);
}

void YN(bool flg) {
	cout << ((flg) ? "YES" : "NO") << endl;
}

void Yn(bool flg) {
	cout << ((flg) ? "Yes" : "No") << endl;
}

void yn(bool flg) {
	cout << ((flg) ? "yes" : "no") << endl;
}

int main() {
	int N; cin >> N;
	V<ll> p(N); REP(i, N) cin >> p[i];
	cout << accumulate(ALL(p), 0LL) - *max_element(ALL(p)) / 2 << endl;




	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int h,w,d;
    cin>>h>>w>>d;
    int n=h*w;
    int a[h][w];
    vector<pair<int,int>>x(n);
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin>>a[h][w];
            x[a[h][w]-1]={i,j};
        }
    }
    long long cost[n];
    for(int i=0;i<d;i++)cost[i]=0;
    for(int i=0;i+d<n;i++)cost[i+d]=cost[i]+abs(x[i+d].first-x[i].first)+abs(x[i+d].second-x[i].second);
    int q;
    cin>>q;
    int l[q],r[q];
    for(int i=0;i<q;i++)cin>>l[i]>>r[i];
    for(int i=0;i<q;i++)cout<<cost[r[i]-1]-cost[l[i]-1]<<endl;
    return 0;
}

Measured memory_bytes: 3328
// 見せてやるぜ、奇跡ってやつをよぉ……
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
template < class T > inline bool chmax(T& a, T b) {if (a < b) { a=b; return true; } return false; }
template < class T > inline bool chmin(T& a, T b) {if (a > b) { a=b; return true; } return false; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    V<string> a(n);
    vll row(n, 0), col(n, 0);
    ll bc = 0;
    REP(i, n) {
        cin >> a[i];
        REP(j, n) {
            if (a[i][j] == '#') {
                bc++;
                row[i]++;
                col[j]++;
            }
        }
    }

    ll wc = 0;
    REP(i, n) if (col[i] != n) wc++;
    cout << '\n';

    if (bc == 0) cout << -1 << '\n';
    else {
        ll ans = HIGHINF;
        REP(i, n) {
            ll tmp;
            if (col[i] > 0) tmp = n - row[i];
            else tmp = n - row[i] + 1;
            chmin(ans, tmp + wc);
        }
        cout << ans << '\n';
    }
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll n;
  cin >> n;
  vl a(n, 0);
  rep(i, n - 1) {
    ll x;
    cin >> x;
    a[x - 1]++;
  }
  rep(i, n) cout << a[i] << '\n';
}

Measured memory_bytes: 4824
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int N;
int dp[30];
string aa="aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
int dp2[30];
int main(){
	cin>>N;
	REP(i,30){
	    dp[i]=10000;
	}
	REP(i,N){
	    REP(j,30){
	        dp2[j]=0;
	    }
	    string s;
	    cin>>s;
	    REP(j,s.size()){
	        dp2[s[j]-'a']++;
	        aa[s[j]-'a']=s[j];
	    }
	    REP(j,30){
	        dp[j]=min(dp[j],dp2[j]);
	    }
	}
	REP(i,30){
	    //string a='a'+i;
	    REP(j,dp[i]){
	        cout<<aa[i];
	    }
	}
        cout<<endl;
	return(0);
}

Measured memory_bytes: 256