akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<bitset>
#include<vector>
#include<deque>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<iomanip>
#include <functional>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const int INF = 1 << 28;
const double EPS = 1e-10;
//cout << fixed << std::setprecision(9)
//memset(a, 0, sizeof(a));
//--------------------------

int n, m;
int p[100005];
int y[100005];

map<int, int> year;
int ken[100005];

map<int, int> mp;

int main()
{
	cin >> n >> m;

	for (int i = 0;i < m;i++) {
		cin >> p[i] >> y[i];
		mp.insert(make_pair(y[i], p[i]));
	}

	map<int, int>::iterator itr;
	for (itr = mp.begin(); itr != mp.end(); itr++) {
		int yy = itr->first;
		int pp = itr->second;

		ken[pp]++;
		year.insert(make_pair(yy, ken[pp]));
	}

	for (int i = 0;i < m;i++) {
		std::cout << std::setfill('0') << std::right << std::setw(6) << p[i];
		int tmp = y[i];
		std::cout << std::setfill('0') << std::right << std::setw(6) << year[tmp] << endl;
	}

	return 0;
}


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

// #include <atcoder/all>

using namespace std;

// boost
#include <boost/multiprecision/cpp_int.hpp>
using boost::multiprecision::cpp_int;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;
using vld = vector<ld>;
using vvld = vector<vld>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

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

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

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

#define mod (ll)(1e9 + 7)
// #define mod (998244353ll)

const long long INF = 1LL << 60;

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

  ll k;
  cin >> k;
  rep(i, k) {
    cout << "ACL";
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 3588
#include <iostream>


using namespace std;




int main(){
	

	int n;
	int a[5000];
	int max;
	int temp;
	
	while(cin>>n&&n){
	for(int i=0;i<n;i++)cin>>a[i];
	max=a[0];
	
	for(int i=0;i<n;i++){
		temp=0;
		for (int j=i; j<n; j++) {
			temp+=a[j];
		
		if (max<temp) {
			max=temp;
		}
		}
	}
	
	
	cout << max <<endl;
	}
		
	return 0;
}
 

Measured memory_bytes: 0
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <iostream>

using namespace std;
typedef long long ll;

int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  vector<ll> x(n);
  vector<ll> y(n);
  vector<ll> z(n);
  for (int i = 0; i < n; ++i) scanf("%lld %lld %lld", &x[i], &y[i], &z[i]);

  ll ans = -1e18;
  for (int i = 0; i < 1<<3; ++i) {
    vector<ll> sums(n);
    for (int j = 0; j < n; ++j) {
      ll tmp = 0;
      if (i & 1) {
	tmp += x[j];
      } else {
	tmp -= x[j];
      }

      if (i >> 1 & 1) {
	tmp += y[j];
      } else {
	tmp -= y[j];
      }

      if (i >> 2 & 1) {
	tmp += z[j];
      } else {
	tmp -= z[j];
      }
      sums[j] = tmp;
    }
    sort(sums.rbegin(), sums.rend());
    ll tmp = 0;
    for (int j = 0; j < m; ++j) {
      tmp += sums[j];
    }
    ans = max(ans, tmp);
  }
  printf("%lld\n", ans);
  return 0;
}



Measured memory_bytes: 256
import re
s = input()
f = s[:2]
b = s[2:]
flg_fm = False
flg_bm = False

if f[0] == '0' and bool(re.search('[1-9]', f[1])) or f[0] == '1' and bool(re.search('[0-2]', f[1])):
    flg_fm = True
if b[0] == '0' and bool(re.search('[1-9]', b[1])) or b[0] == '1' and bool(re.search('[0-2]', b[1])):
    flg_bm = True

if flg_fm and flg_bm:
    print('AMBIGUOUS')
elif flg_bm:
    print('YYMM')
elif flg_fm:
    print('MMYY')
else:
    print('NA')

Measured memory_bytes: 9864
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n, k = map(int, readline().split())
aa = []
for i in range(k):
    readline()
    aa += list(map(int, readline().split()))
cnt = 0
for i in range(1, n + 1):
    if i not in aa:
        cnt += 1
print(cnt)


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

int N;
vector<int> vi;

void solve(){
  long int count = 0;
  long int sum = 0;
  for(int i = 0; i < N; i++){
    if(vi[i] != 0){
      sum += vi[i];
    }
    else{
      count += sum / 2;
      sum = 0;
    }
  }
  if(sum > 0) count += sum / 2;
  cout << count << endl;
  return ;
}

int main(){
  cin >> N;
  for(int i = 0; i < N; i++){
    int tmp;
    cin >> tmp;
    vi.push_back(tmp);
  }
  vi.push_back(0);
  solve();
  return 0;
}


Measured memory_bytes: 892
S = input()
A = int(S[0] + S[1])
B = int(S[2] + S[3])

if 1 <= A <= 12 and 1 <= B <= 12:
    print('AMBIGUOUS')
elif (A > 12 or A <= 0) and 1 <= B <= 12:
    print('YYMM')
elif 1 <= A <= 12 and (B > 12 or B <= 0):
    print('MMYY')
else:
    print('NA')


Measured memory_bytes: 9024
import java.util.Arrays;
import java.util.Scanner;

public class Main {
public static void main(String[] args) {
		
		Scanner keyboard = new Scanner(System.in); 
		
		int N = keyboard.nextInt();
		int K = keyboard.nextInt();
		
		String[] hate = new String[K];
		
		for(int i = 0; i < K; i ++) {
			hate[i] = keyboard.next();
		}
		
		boolean error = true;
		
		while(error) {
			String NN = String.valueOf(N);
			
			String[] bunkatsu = new String[NN.length()];			
			
			for(int i = 0; i < NN.length(); i ++) {
				bunkatsu[i] = NN.substring(i, i+1);	
			}
			for(int i = 0; i < NN.length(); i ++) {
				if(Arrays.asList(hate).contains(bunkatsu[i])){
					 N ++;
					 break;
		          }else if(i == NN.length() - 1){
		               error = false;
		          }
				}
		}
		System.out.println(N);
		keyboard.close();
	}
}

Measured memory_bytes: 36988
x = int(input())
if 400 <= x <= 599: print(8)
elif 600 <= x <= 799: print(7)
elif 800 <= x <= 999: print(6)
elif 1000 <= x <= 1199: print(5)
elif 1200 <= x <= 1399: print(4)
elif 1400 <= x <= 1599: print(3)
elif 1600 <= x <= 1799: print(2)
elif 1800 <= x <= 1999: print(1)

Measured memory_bytes: 61624
import kotlin.math.abs

fun main() {
  val N = readInt()
  val W = readInts()
  var min = Int.MAX_VALUE
  for (i in 1 until N) {
    val l = W.subList(0, i)
    val r = W.subList(i, W.size)
    val d = abs(l.sum() - r.sum())
    min = kotlin.math.min(min, d)
  }
  println(min)
}

fun gcd(a: Int, b: Int): Int = if (a < b) gcd(b, a) else if (b == 0) a else gcd(b, a % b)
fun gcd(a: Long, b: Long): Long = if (a < b) gcd(b, a) else if (b == 0L) a else gcd(b, a % b)
fun lcm(a: Int, b: Int): Int = (a * b) / gcd(a, b)
fun lcm(a: Long, b: Long): Long = (a * b) / gcd(a, b)

fun readString() = readLine()!!
fun readStrings() = readLine()!!.split(" ")
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readInts() = readLine()!!.split(" ").map { it.toInt() }
fun readLongs() = readLine()!!.split(" ").map { it.toLong() }


Measured memory_bytes: 36584
#include <bits/stdc++.h>
#define N 15
#define M 5000
#define INF 1061109567
using namespace std;
int n,m,tem[M],dp[M];
int main(){
	int i,j,a[1010],b,x,mask[1010];
	cin>>n>>m;
	memset(tem,63,sizeof(tem));
	memset(dp,63,sizeof(dp));
	for(i=0;i<m;i++)
	{
		cin>>a[i]>>b;
		mask[i]=0;
		for(j=0;j<b;j++)
		{
			cin>>x;
			mask[i]|=(1<<(x-1));
		}
	}
	for(i=1;i<(1<<n);i++)
	{
		for(j=0;j<m;j++)
		{
			if((mask[j]&i)==i)
			{
				tem[i]=min(tem[i],a[j]);
				dp[i]=tem[i];
			}
		}
	}
	for(i=1;i<(1<<n);i++)
	{
		for(j=1;j<i;j++)
		{
			if((i&j)!=j)
			{
				continue;
			}
			dp[i]=min(dp[i],dp[j]+dp[i-j]);
		}
	}
	if(dp[(1<<n)-1]==INF)
	{
		cout<<-1<<endl;
	}
	else
	{
		cout<<dp[(1<<n)-1]<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
// C++ 14
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)

int main() {
  int n; cin >> n;
  string s; cin >> s;
  vector<int> R(n+1, 0), G(n+1, 0), B(n+1, 0);
  loop(i,0,n) {
    R[i+1] = R[i] + (s[i] == 'R');
    G[i+1] = G[i] + (s[i] == 'G');
    B[i+1] = B[i] + (s[i] == 'B');
  }
  ll ans = 0;
  for (int k=n-1; k>=2; k--) {
    for (int j=k-1; j>=1; j--) {
      if (s[j]==s[k]) continue;
      set<char> S;S.insert(s[j]); S.insert(s[k]);
      int d = k-j;
      int i = j;
      if (!S.count('R')) {
        ans += R[i];
        if (j-d>=0 and s[j-d] == 'R') ans--;
      }
      if (!S.count('G')) {
        ans += G[i];
        if (j-d>=0 and s[j-d] == 'G') ans--;
      }
      if (!S.count('B')) {
        ans += B[i];
        if (j-d>=0 and s[j-d] == 'B') ans--;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3668
import java.util.BitSet;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

public class Main{
	public static String r = "qwertasdfgzxcvb";
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		while(true){
			char[] s = in.next().toCharArray();
			if(s[0] == '#') break;
			boolean right = false;
			int count = 0;
			for(int i=0; i<s.length; i++){
				boolean hand = r.indexOf(s[i])!=-1;
				if(hand != right){
					right = hand;
					if(i>0) count++;
				}
			}
			System.out.println(count);
		}
	}
}

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

using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
typedef long int li;

int main()
{
    IOS;
    //freopen("fr.txt","r",stdin);
    string s,t;
    cin>>s>>t;
    int c1=0;
    for(int i=0;i<s.length();i++){
        if(s[i]!=t[i])
            c1++;
    }
    cout<<c1<<endl;

    return 0;
}


Measured memory_bytes: 3776
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();

		String ans = "No";
		if(a == b+c){
			ans = "Yes";
		}else if(b == a+c){
			ans = "Yes";
		}else if(c == a+b){
			ans = "Yes";
		}

		System.out.println(ans);
	}
}

Measured memory_bytes: 10196
#include<stdio.h>
main()
{
    int a,b,c,d;
    scanf("%d",&a);
    b=a/3600;
    a=a%3600;
    c=a/60;
    a=a%60;

    printf("%d:%d:%d\n",b,c,a);

    return 0;




}



Measured memory_bytes: 2040
import math

n = int(input())
a = []
ans = 0
count = [0] * 5
for i in range(5):
    a.append(int(input()))
    count[i] = math.ceil(n / a[i])

for i in range(1, 5):
    if count[i] < count[i - 1]:
        count[i] = count[i - 1]

print(count[4] + 4)


Measured memory_bytes: 3060
import java.util.*;
public class Main{
	public static void main(String[] args){
		int ans = 0;
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		
		int[] trees = new int[n];
		for(int i=0; i<n; i++){
			trees[i] = sc.nextInt();
		}
		
		quick_sort(trees, 0, n-1);
		
		int min = trees[n-1];
		for(int i=0; i<n-k+1; i++){
			if(trees[i+k-1] - trees[i] < min){
				min = trees[i+k-1] - trees[i];
			}
		}
		
		System.out.println(min);
	}
	
	static void quick_sort(int[] d, int left, int right) {
		if(left>=right){
				return;
		}
		int p = d[(left+right)/2];
		int l = left, r = right, tmp;
		while(l<=r){
			while(d[l] < p){ l++; }
			while(d[r] > p){ r--; }
			if (l<=r) {
				tmp = d[l]; d[l] = d[r]; d[r] = tmp;
				l++;
				r--;
			}
		}
		quick_sort(d, left, r);
		quick_sort(d, l, right);
	}
}

Measured memory_bytes: 51716
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO.Compression;
using System.IO.Pipes;
using System.Linq;
using System.Numerics;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var WHC = ReadInts();
            var W = WHC[0];
            var H = WHC[1];
            var C = WHC[2];

            var a = Gcd(W, H);

            var ans = (W / a) * (H / a);
            WriteLine(ans*C);
        }
        //最大公約数
        public static int Gcd(int a, int b)
        {
            if (a < b)
            {
                return Gcd(b, a);
            }
            while (b != 0)
            {
                var reminder = a % b;
                a = b;
                b = reminder;
            }
            return a;
        }

        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}



Measured memory_bytes: 17992
while True :
    p=int(input())
    if p==0 : break
    c=[0]*10
    for k in range(p):
        a=int(input())
        c[a]=c[a]+1
    for i in range(10):
        if c[i]==0 : print("-", end="")
        else : 
            for j in range(c[i]): 
                print("*", end="")
        print("")


Measured memory_bytes: 7580
# -*- coding: utf-8 -*-
import sys
# sys.setrecursionlimit(10**6)
# buff_readline = sys.stdin.buffer.readline
buff_readline = sys.stdin.readline
readline = sys.stdin.readline

INF = 2**62-1


def read_int():
    return int(buff_readline())


def read_int_n():
    return list(map(int, buff_readline().split()))


def read_float():
    return float(buff_readline())


def read_float_n():
    return list(map(float, buff_readline().split()))


def read_str():
    return readline().strip()


def read_str_n():
    return readline().strip().split()


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap



@mt
def slv(N, M, AB):
    from collections import defaultdict, deque
    g = defaultdict(list)
    for a, b in AB:
        g[a].append(b)

    def bfs(s):
        q = deque()
        q.append(s)
        prev = {}
        while q:
            u = q.popleft()
            for v in g[u]:
                if v in prev:
                    continue
                q.append(v)
                prev[v] = u
                if v == s:
                    break

        if s not in prev:
            return None

        cycle = [s]
        v = s
        while True:
            v = prev[v]
            if v == s:
                break
            cycle.append(v)
        return cycle

    ans = None
    for i in range(1, N+1):
        t = bfs(i)
        if t is not None:
            if ans is None:
                ans = t
            else:
                ans = t if len(t) < len(ans) else ans
    if ans is not None:
        return [len(ans)] + ans
    return [-1]


def main():
    N, M = read_int_n()
    AB = [read_int_n() for _ in range(M)]
    print(*slv(N, M, AB), sep='\n')


if __name__ == '__main__':
    main()


Measured memory_bytes: 46040
'use strict'

const main = input => {
	const args = input.split('\n').map(arg => arg.split(' '))
	const a = parseInt(args[0][0], 10)
	const b = parseInt(args[0][1], 10)
	if (a > 8 || b > 8) console.log(':(')
	else console.log('Yay!')
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))


Measured memory_bytes: 7372
def merge(A, l, m, r):
    L = A[l:m] + [10 ** 9 + 1]
    R = A[m:r] + [10 ** 9 + 1]
    i, j = 0, 0
    for k in range(l, r):
        if L[i] <= R[j]:
            A[k] = L[i]
            i += 1
        else:
            A[k] = R[j]
            j += 1
    global cnt
    cnt += r - l

def mergeSort(A, l, r):
    if r - l > 1:
        m = (l + r) // 2
        mergeSort(A, l, m)
        mergeSort(A, m, r)
        merge(A, l, m, r)

n = int(input())
A = list(map(int, input().split()))
cnt = 0
mergeSort(A, 0, n)
print(" ".join(list(map(str, A))))
print(cnt)

Measured memory_bytes: 68784
{-# LANGUAGE PartialTypeSignatures #-}
module Main (main) where

import qualified Data.ByteString.Char8 as C8
import qualified Data.Char as C
import qualified Data.List as L

main :: IO ()
main = readInts >>= output . solve

solve :: [Int] -> _
solve [x] = head [(a,b) | a <- [-200..200], b <- [-200..200], a^5-b^5==x]

output :: _ -> IO ()
output (a,b) = putStrLn (show a <> " " <> show b)

-- utils
readInts :: IO [Int]
readInts = L.unfoldr (C8.readInt . C8.dropWhile C.isSpace) <$> C8.getLine


Measured memory_bytes: 3780
#include<iostream>
#include<algorithm>
#define str std::string 
bool operator <(str a,str b)
{
	for(int i=0;i<a.length();++i)
		if(a[i]!=b[i])
			return a[i]<b[i];
	return 0;
}
str s[105];
int n;
int main()
{
	scanf("%d%*d",&n);
	for(int i=0;i<n;++i)
		std::cin>>s[i];
	std::sort(s,s+n);
	for(int i=0;i<n;++i)
		std::cout<<s[i];
	puts("");
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;
ll INF = 1e18;

int main() {
  //
  ll h,w;
  cin>>h>>w;
  map<int,int> mp;
  rep(i,h) {
    string a;
    cin>>a;
    rep(j,w){
      int code = a[j] - 'a';
      if (mp.find(code) == mp.end()) {
        mp[code]=1;
      } else {
        mp[code]++;
      }
    }
  }
  int oddcnt = 0;
  int x2cnt = 0;
  for (auto& x : mp) {
    if (x.second&1) oddcnt++;
    else if (x.second % 4) x2cnt++;
  }
  if ((h&1)&&(w&1)) {
    if (oddcnt == 1 && x2cnt <= ((h-1)/2 + (w-1)/2)) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  } else if (h&1) {
    if (oddcnt == 0 && x2cnt <= w/2) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  } else if (w&1) {
    if (oddcnt == 0 && x2cnt <= h/2) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  } else {
    if (oddcnt == 0 && x2cnt == 0) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }
  return 0;
}


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

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

    int n;
    cin >> n;

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

    sort(a.begin(), a.end());
    a.push_back(a[n - 1] + 1);
    n++;

    int r = 0;
    int b = a[0] - 1, c = 0;
    for (int i = 0; i < n; i++) {
        if (a[i] == b) {
            c++;
        } else {
            if (c < b) r += c; else r += c - b;
            b = a[i];
            c = 1;
        }
    }

    cout << r << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstring>
#include <math.h>
#include <numeric>
#include <queue>
#define rep(i,s,n) for (int i=s;i<n;++i)
#define drep(i,s,n) for (int i=n;i>=s;--i)
#define all(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define print(x) cout<<(x)<<endl
using namespace std;
typedef long long ll;

int gcd(int a,int b)
{if (a%b == 0) return(b);
 else          return(gcd(b,a%b));}
int lcm(int a,int b)
{return a*b/gcd(a,b);}
void printv(vector<auto> v) {cout<<'[';rep(i,0,v.size()){cout<<v[i]<<',';}cout<<']'<<endl;}
void printvv(vector<vector<auto>> vv)
{
  cout<<'['<<endl;
  rep(q,0,vv.size()){cout<<'[';rep(p,0,vv.at(q).size())cout<<vv.at(q).at(p)<<',';cout <<']'<<endl;}
  cout<<']'<<endl;
}
void solve(); int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}
int step_x[] = {-1,0,0,1};
int step_y[] = {0,-1,1,0};
//------------------------------------------------------------
int n,ans=0;

void solve() {
  cin>>n;

  vector<vector<ll>> v(n, vector<ll>(2));

  rep(i,0,n)
  {
    ll x,l;
    cin >> x >> l;
    v[i][0]=x-l;
    v[i][1]=x+l;
  }

  sort(all(v), [](const vector<ll> &a, const vector<ll> &b){return a[1]<b[1];});

  ll r=-(1e9+1);
  rep(i,0,n)
  {
    if(r<=v[i][0])
    {
      ans++;
      r=v[i][1];
    }

  }

  print(ans);

  return;
}


Measured memory_bytes: 5760
# Begin Header {{{
from math import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations, combinations_with_replacement
# }}} End Header
# _________コーディングはここから！！___________
n = int(input())
if n%1000 == 0:
    print(0)
else:
    print(1000-n%1000)

Measured memory_bytes: 9376
#include <stdio.h>

int main(void) {
	int N=0,K=0,X=0,Y=0,A=0;

	scanf("%d %d %d %d",&N,&K,&X,&Y);

	if(N>K) {
		A = K*X+(N-K)*Y;
	}
	else {
		A = N*X;
	}

	printf("%d\n",A);
}


Measured memory_bytes: 128
using System;
namespace _1{
    class program
    {
  
        static void Main()
        {
            string[] s = Console.ReadLine().Split();
            int a, b, c, d;
            a = int.Parse(s[0]);
            b = int.Parse(s[1]);
            c = int.Parse(s[2]);
            if(a < b)
            {
                if(c < a)
                {
                    d = a;     
                    a = c;
                    c = b;
                    b = d;
                }
                else if(c < b)
                {
                    d = c;
                    c = b;
                    b = d;
                }
            }
            else
            {
                if (a < c)
                {
                    d = a;
                    a = b;
                    b = d;
                }
                else if(b < c)
                {
                    d = a;
                    a = b;
                    b = c;
                    c = d;
                }
                else
                {
                    d = a;
                    a = c;
                    c = d;                    
                }
            }
             Console.WriteLine(a + " " + b + " " + c);
           
        }
    }
}


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

#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define REP(i, n)  for(int i=0;i<(n);++i)
#define REPr(i, n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define FORqr(i, m, n) for(int i = (n);i >=(m);--i)
#define PB push_back
#define MP make_pair
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x, S) (S.count(x) != 0)
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x, y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
using namespace std;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
const ll MOD = 1e9+7;

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

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;
}
///////////////////////////////////////////////
/*(._.)*/
int main(){
	int K,X;
	cin >> K >> X;
	int M = X+K-1;
	int N = X-K+1;
	FORq(i,N,M){
		cout << i << " ";
	}
	cout << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
ll c[405][405],f[405],r[405],rui[405][405][135];
int n,a[405],b[405],pos[405],pos2[405],t[405][405];
ll modpow(ll x,ll n){
	ll res=1;
	while(n>0){
		if(n&1) res=res*x%mod;
		x=x*x%mod;
		n>>=1;
	}
	return res;
}
int main(){
	cin>>n;
	repn(i,n)cin>>a[i],pos[a[i]]=i;
	repn(i,n)cin>>b[i],pos2[b[i]]=i;
	rep(i,405)rep(j,i+1){
		if(j==0||j==i) c[i][j]=1;
		else c[i][j]=(c[i-1][j]+c[i-1][j-1])%mod;
	}
	f[0]=r[0]=1;
	repn(i,400) f[i]=f[i-1]*1LL*i%mod,r[i]=modpow(f[i],mod-2);
	rep(i,n+1)rep(j,n+1){
		repn(k,n){
			if(pos[k]<=i||pos2[k]<=j) t[i][j]++;
		}
	}
	repn(k,n/3){
		repn(x,n){
			repn(y,n){
				rui[x][y][k]=rui[x-1][y][k]+rui[x][y-1][k]-rui[x-1][y-1][k];
				if(x<pos[b[y]] && y<pos2[a[x]] && 2*k<=t[x][y] && t[x][y]<=3*k-1){
					ll D=rui[x-1][y-1][k-1];
					if(k==1)D++;
					D=D%mod*r[3*k-3-t[x-1][y-1]]%mod;
					rui[x][y][k] += D*f[3*k-t[x][y]]%mod;
				}
				rui[x][y][k]%=mod;
			}
		}
	}
	ll ans=rui[n][n][n/3];
	rep(i,n)if(i%3!=0)ans=ans*1LL*i%mod;
	cout<<(ans%mod+mod)%mod<<endl;
}


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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }

vector<vector<ll>> dp;
vector<ll> a, sum;

ll dfs(int l, int r) {
  if (dp[l][r]!=-1) return dp[l][r];
  else if (l==r) return dp[l][r] = 0;
  ll result = LLINF;
  repr(i,l,r) result = min(result, (sum[r+1]-sum[l])+dfs(l,i)+dfs(i+1,r));
  return dp[l][r] = result;
}

int main() {
  int N; cin >> N;
  dp.resize(N,vector<ll>(N,-1));
  a.resize(N); rep(i,N) cin >> a[i];
  sum.resize(N+1,0); rep(i,N) sum[i+1] = sum[i] + a[i];
  ll result = dfs(0,N-1);
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 1536
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

from collections import Counter

N = int(input())
A = [int(i) for i in input().split()]

ans = -1
A_ = Counter(A)
cnt = 0
if N % 2 == 1:
    if A_[0] != 1:
        ans = 0
    for i in range(2,N,2):
        if A_[i] != 2:
            ans = 0
            break
        cnt += 1
else:
    for i in range(1,N,2):
        if A_[i] != 2:
            ans = 0
            break
        cnt += 1

if ans == 0:
    print(ans)
else:
    print(2**cnt%mod)


Measured memory_bytes: 16852
Num =  1000000007 
n,m = map(int,input().split())
a = [False] * (n+1)
for i in range(m):
    tmp = int(input())
    a[tmp] = True
dp = [1 for i in range(n+1)]
dp[0] = 1
if a[1]:
    dp[1] = 0

for i in range(2,n+1):
    if a[i]:
        dp[i] = 0

    else:
        dp[i] = dp[i-1] + dp[i-2]
print(dp[-1]%Num)

Measured memory_bytes: 460788
n,q=map(int,input().split())
s=input()
t=[0]*(n+1)
for i in range(n):
	t[i+1]=t[i]+(1 if s[i:i+2]=='AC' else 0)
for i in range(q):
	l,r=map(int,input().split())
	print(t[r-1]-t[l-1])

Measured memory_bytes: 7748
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>

using namespace std;

struct Time {
	int hour;
	int minute;
};

vector<Time> get_input() {
	int n;
	cin >> n;
	vector<Time> ninput(n);
	for (int i = 0; i < n; i++) {
		cin >> ninput[i].hour;
		cin >> ninput[i].minute;
	}
	return ninput;
}

bool operator<(Time a, Time b) {
	if (a.hour < b.hour) {
		return true;
	} else if (a.hour > b.hour) {
		return false;
	} else {
		if (a.minute < b.minute) {
			return true;
		} else {
			return false;
		}
	}
}

void print_time(Time t) {
	printf("%d:%02d", t.hour, t.minute);
}

bool equal_time(Time a, Time b) {
	if (a.hour == b.hour && a.minute == b.minute) {
		return true;
	} else {
		return false;
	}
}

vector<Time> remove_equal_time(vector<Time> t) {
	vector<Time> result;
	result.push_back(t[0]);;
	Time prevTime = t[0];
	for (int i = 1; i < t.size(); i++) {
		if (!equal_time(t[i], prevTime)) {
			result.push_back(t[i]);
		}
		prevTime = t[i];
	}
	return result;
}

int main() {
	vector<Time> ninput = get_input();
	vector<Time> minput = get_input();
	copy(minput.begin(), minput.end(), back_inserter(ninput));
	sort(ninput.begin(), ninput.end());

	vector<Time> result = remove_equal_time(ninput);

	print_time(result[0]);
	for (int i = 1; i < result.size(); i++) {
		cout << " ";
		print_time(result[i]);
	}
	cout << endl;
}

Measured memory_bytes: 1256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N = int(readline())
A = list(map(int, readline().split()))

s = 0
e = N - 1
buy = 0
m = 1000

while s +1 < N and A[s] >= A[s+1]:
    s += 1
while e-1>=0 and A[e-1]>=A[e]:
    e -= 1
    
if s >= e:
    print(m)
else:
    while s < e: 
        i = s
        t = m//A[s]
        while i+1<N and A[i]<=A[i+1]:
            i += 1
        m += t*(-A[s] + A[i])
        s=i
        while s+1<N and A[s]>=A[s+1]:
            s+=1
    print(m)

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

using namespace std;

const int NS = (int)1e5+4;
char s[NS];
int stk[NS], top, ans, N;

int main(){
    scanf("%s", s); N = strlen(s);
    for(int i=0;i<N;++i){
        stk[top++] = s[i]-'0';
        while(top>=2&&stk[top-1]!=stk[top-2]) top-=2, ++ans;
    }
    printf("%d", ans*2);
    return 0;
}


Measured memory_bytes: 768
n = int(input())
a = list(map(int, input().split()))
count_even = 0
count_fizz = 0
for i in range(n):
  if a[i]%2==0:
    count_even+=1
    if a[i]%3==0 or a[i]%5==0:
      count_fizz+=1
      
    
if count_even == count_fizz:
  print('APPROVED')
else:
  print('DENIED')

Measured memory_bytes: 3060
#include<stdio.h>
int main(){
  int x,y,z;

  scanf("%d %d",&x, &y);

  // x >= y にする
  if(x < y){
    z = y;
    y = x;
    x = z;
  }

  while(z = x % y){
    x = y;
    y = z;
  }

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


Measured memory_bytes: 2124
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) for (int i = 0, lp_num_##_i = (int)(n); i < lp_num_##_i; ++i)
#define FORE(x, a) for (auto &x : a)
#define ALL(a) a.begin(), a.end()
#define SZ(a) ((int)a.size())

template <class T, class U>
bool chmax(T &a, const U &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T, class U>
bool chmin(T &a, const U &b) { if (a > b) { a = b; return 1; } return 0; }

template <class T, class U>
bool contains(const T &cont, const U &elem) {
	return cont.find(elem) != cont.end();
}

int N, M;
int ans;
int f[110][110];

vector<int> V;
void rec() {
	if (SZ(V) > 1) {
		int tmp = 0;
		REP(i, SZ(V)) {
			int friendliness = 1e9;
			REP(j, SZ(V)) {
				if (i == j) continue;
				chmin(friendliness, f[V[i]][V[j]]);
			}
			tmp += friendliness;
		}
		chmax(ans, tmp);
	}

	for (int i = V.back() + 1; i < N; i++) {
		bool ok = true;
		REP(j, SZ(V)) {
			if (f[i][V[j]] == 0) {
				ok = false;
				break;
			}
		}
		if (!ok) continue;

		V.push_back(i);
		rec();
		V.pop_back();
	}
}

signed main() {
	cin >> N >> M;
	REP(i, M) {
		int a, b, c;
		cin >> a >> b >> c;
		a--, b--;
		f[a][b] = f[b][a] = c;
	}

	ans = 0;
	REP(i, N) {
		V.push_back(i);
		rec();
		V.pop_back();
	}
	cout << ans << endl;	
}


Measured memory_bytes: 3248
// E - Yutori
#include <bits/stdc++.h>
using namespace std;

int main(){
	int N,K,C; string S;
	cin>>N>>K>>C>>S;

	vector<int> R(N,-1);

	int c = 0;
	int r_pos = 0;
	for(int r=N-1; r>=0; --r){
		if(c > 0) c--;
		else{
			if(S[r] == 'o'){
				R[r_pos++] = r;
				if(r_pos > K) return 0; // 働ける日に余裕があると、その日に必ず働く必要がない
				c = C;
			}
		}
	}

	reverse(R.begin(), R.begin() + r_pos);

	c = 0;
	int l_pos = 0;
	for(int l=0; l<N; ++l){
		if(c > 0) c--;
		else{
			if(S[l] == 'o'){
				if(R[l_pos++] == l) cout<< l + 1 <<endl;
				c = C;
			}
		}
	}

}

Measured memory_bytes: 2564
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++) 
#define all(v) begin(v),end(v)
using ll = long long;

int main() {
  int a,b,k;cin>>a>>b>>k;
  for(int i=a;i<min(a+k,b-k+1);i++)cout<<i<<endl;
  for(int i=max(a,b-k+1);i<=b;i++)cout<<i<<endl;
}

Measured memory_bytes: 3636
import java.util.*;

public class Main {
	int w,h;
	int[][] map;
	int[][] cost;
	int ansx, ansy;
	
	
	public void loop(int y, int x, int d){
		if(map[y][x]==0){
			System.out.println(x + " " + y);
			return;
		}
		
		cost[y][x] = 1;
		if(d==1){
			if(cost[y-1][x]==1){
				System.out.println("LOOP");
				return;
			}else{
				loop(y-1,x,map[y-1][x]);
			}
		}else if(d==2){
			if(cost[y][x+1]==1){
				System.out.println("LOOP");
				return;
			}else{
				loop(y,x+1,map[y][x+1]);
			}
		}else if(d==3){
			if(cost[y+1][x]==1){
				System.out.println("LOOP");
				return;
			}else{
				loop(y+1,x,map[y+1][x]);
			}
		}else if(d==4){
			if(cost[y][x-1]==1){
				System.out.println("LOOP");
				return;
			}else{
				loop(y,x-1,map[y][x-1]);
			}
		}
	
	}
	
	
	public static void main(String[] args) {
		Main A = new Main();
		Scanner sc = new Scanner(System.in);
		
		while(true){
			A.h = sc.nextInt();
			A.w = sc.nextInt();
			if(A.h==0 && A.w==0)break;
			
			A.map = new int[A.h][A.w];
			A.cost = new int[A.h][A.w];
			
			for(int i=0;i<A.h;i++){
				String s = sc.next();
				for(int j=0;j<A.w;j++){
					String t = s.substring(j,j+1);
					if(t.compareTo("^")==0){
						A.map[i][j] = 1;
					}else if(t.compareTo(">")==0){
						A.map[i][j] = 2;
					}else if(t.compareTo("v")==0){
						A.map[i][j] = 3;
					}else if(t.compareTo("<")==0){
						A.map[i][j] = 4;
					}		
				}
			}
			A.loop(0, 0, A.map[0][0]);

		}
	}	
}

Measured memory_bytes: 24660
#include<bits/stdc++.h>
using namespace std;
typedef long long int uli;
const int mx=1e3+10;
const uli oo=1e18;
vector<int>g[mx];
uli x[mx];
uli f[2][5000+10];
uli dp[mx];
bool ok=true;
void dfs(int u){
  uli sm=0;
  for(int v:g[u]){
    dfs(v);
    sm+=dp[v]+x[v];
  }
  if(g[u].empty()){
    dp[u]=0;
    return;
  }
  int b=0;
  for(int s=0;s<=x[u];s++)f[b][s]=sm-s;
  for(int v:g[u]){
    b^=1;
    for(int s=0;s<=x[u];s++){
      uli p=dp[v],q=x[v];
      f[b][s]=oo;
      for(int it=0;it<2;it++){
        if(p+s<=x[u]){
          f[b][s]=min(f[b][s],f[b^1][s+p]);
        }
        swap(p,q);
      }
    }
  }
  dp[u]=f[b][0];
  if(dp[u]>=oo)ok=false;
}
int main(){
  int n;
  scanf("%d",&n);
  for(int i=1;i<n;i++){
    int pi;
    scanf("%d",&pi);
    --pi;
    g[pi].push_back(i);
  }
  for(int i=0;i<n;i++)scanf("%lld",x+i);
  dfs(0);
  if(ok)puts("POSSIBLE");
  else puts("IMPOSSIBLE");
  return 0;
}


Measured memory_bytes: 384
#include <cstdio>
#include <cmath>

int main(){
    int n;
    scanf("%d",&n);
    unsigned long long p = 1;
    for(int i = 1; i <= n; i++){
        p = (p * i) % (int)(pow(10,9) + 7);
    }
    printf("%lld\n",p);

    return 0;
}

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

struct Dice {
	int d[6], E, S, U;
	Dice(int a[]) {
		rep(i, 6)d[i] = a[i];
		E = 2; S = 1; U = 0;
	}
	void rotate(char C) {
		int a = E, b = S, c = U;
		switch (C) {
		case'E':E = U; U = 5 - a; break;
		case'N':U = S; S = 5 - c; break;
		case'S':S = U; U = 5 - b; break;
		case'W':U = E; E = 5 - c; break;
		case'R':S = E; E = 5 - b; break;
		case'L':E = S; S = 5 - a; break;
		}
	}
	int rotate(int a, int b) {
		rep(k, 2) {
			rep(i, 4) {
				rep(j, 4) {
					if (a == d[U] && b == d[S])return d[E];
					rotate('E');
				}
				rotate('S');
			}
			rotate('L');
		}
	}
};
int main() {
	int a[6]; rep(i, 6)cin >> a[i];
	Dice d(a);
	int q; cin >> q;
	rep(i, q) {
		int a, b; cin >> a >> b;
		cout << d.rotate(a, b) << endl;
	}
}

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

int main()
{
    int n,m,i,j,flag=1;
    cin>>n>>m;
    int arr[m];
    long long sum=0,ans;
    for(i=0;i<m;i++)
    {
        cin>>arr[i];
        sum+=arr[i];
    }
    if(sum>n) cout<<-1<<endl;
    else{
        cout<<n-sum<<endl;
    }

    return 0;
}




Measured memory_bytes: 3676
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import _collections
import string
from functools import lru_cache

class cin():
    def int():
        return int(sys.stdin.readline().rstrip())
    def string():
        return sys.stdin.readline().rstrip()
    def mapInt():
        return [int(x) for x in cin.string().split()]
    def stringList(n):
        return [input() for i in range(n)]
    def intListList(n):
        return [cin.mapInt() for i in range(n)]
    def intColsList(n):
        return [int(input()) for i in range(n)]
        
class Math():
    def gcd(a,b):
        if b == 0:
            return a
        return Math.gcd(b,a % b)
    def lcm(a,b):
        return (a * b) // Math.gcd(a,b)
    def roundUp(a,b):
        return -(-a // b)
    def toUpperMultiple(a,x):
        return Math.roundUp(a,x) * x
    def toLowerMultiple(a,x):
        return (a // x) * x
    def nearPow2(n):
        if n <= 0:
            return 0
        if n & (n - 1) == 0:
            return n
        ret = 1
        while(n > 0):
            ret <<= 1
            n >>= 1
        return ret

MOD = int(1e09) + 7

def main():
    N = cin.int()
    A = cin.intColsList(N)

    m1,m2 = sorted(A,reverse=True)[0],sorted(A,reverse=True)[1]
    for a in A:
        if a == m1:
            print(m2)
        else:
            print(m1)
    return

if __name__ == "__main__":
    main()


Measured memory_bytes: 68768
#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
#include<algorithm>
#include<functional>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;

#define rep(i,x,y) for(int i=(x); i<(y); ++i)
const int INF = (1<<30);
const ll INFLL = 1LL<<62;
const long double EPS = 1e-12;

template <typename T>
void vec_print(vector<T> VEC){
  rep(i, 0, VEC.size()){
    cout << VEC[i] << " ";
  }
  cout << "\n";
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  rep(i, 0, MAT.size()){
    rep(j, 0, MAT[i].size()){
      cout << MAT[i][j] << " ";
    }
    cout << "\n";
  }
};

class HOGE{
  public:
    ll index;
    ll value;
    HOGE(ll index, ll value){
      this->index = index;
      this->value = value;
    };
    ~HOGE(void){
      return;
    };

    void print(void){
      cout << "index : " << index << ", value : " << value << "\n";
      return;
    };
    
    bool operator==(const HOGE &obj){
      return (this->value == obj.value);
    };
    bool operator<(const HOGE &obj){
      return (this->value < obj.value);
    };
    bool operator>(const HOGE &obj){
      return (this->value > obj.value);
    };
};

constexpr ll DIVIDE = (1E+9)+7;

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  string S;
  cin >> S;

  ll A = 0;
  ll AB = 0;
  ll ABC = 0;
  ll tmp=1;

  for(int i=0; i<S.size(); ++i){
    if(S[i]=='A') A += tmp;
    if(S[i]=='B') AB += A;
    if(S[i]=='C') ABC += AB;
    if(S[i]=='?'){
      ABC = AB + ABC*3;
      AB = A + AB*3;
      A = tmp + A*3;
      tmp*=3;
    }
    A = A%DIVIDE;
    AB = AB%DIVIDE;
    ABC = ABC%DIVIDE;
    tmp = tmp%DIVIDE;
  }

  cout << ABC%DIVIDE << "\n";

  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph= vector<vector<int>>; 
#define rep(i,n) for (ll i=0; i < (n); ++i)
#define rep2(i,n,m) for(ll i=n;i<=m;i++)
#define rep3(i,n,m) for(ll i=n;i>=m;i--)
#define pb push_back
#define eb emplace_back
#define ppb pop_back
#define fi first 
#define se second
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
// ミント
const int mod = //1e9+7 ;
998244353;

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
//昆布
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
}   ;
 
mint modpow(ll a,ll b){
 if(b==0) return 1 ;
 mint c= modpow(a,b/2) ;
 if(b%2==1) return c*c*a ;
 else return c*c ;
}

mint komb(ll n,ll m){
  mint x=1 ;mint y=1 ;
  rep(i,m){
    x*= n-i ;
    y*= i+1 ;
  }
  return x/y ;
}

  mint dp[3005][3005] ;
int main(){
 ll a,b,c,d ;cin>>a>>b>>c>>d ;
 dp[a][b]=1 ;
 rep2(i,a+1,c){
   dp[i][b]= dp[i-1][b]*b ;
 }
 rep2(i,b+1,d){
   dp[a][i]= dp[a][i-1]*a ;
 }
 rep2(i,a+1,c){
   rep2(j,b+1,d){
     dp[i][j]= dp[i-1][j]*j+ dp[i][j-1]*i
     -dp[i-1][j-1]*(i-1)*(j-1) ;
   }
 }
    cout<<dp[c][d]<<endl;
    return 0;
  }
   

Measured memory_bytes: 74180
#include <bits/stdc++.h>
#define int long long
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define leng(n) (int)(log10(n)+1)
#define INF 9000000000000000000
using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm

signed main() {
  int n,m;
  cin >> n >> m;
  vector<vector<tuple<int,int,int>>> city(n,vector<tuple<int,int,int>>(0));
  int a,b;
  tuple<int,int,int> en;
  rep(i,0,m){
    cin >> a >> b;
    en = make_tuple(a,b,i);
    city[a-1].pb(en);
  }
  rep(i,0,n) sort(ALL(city[i]));
  
  vector<pair<int,string>> ans(0);
  string s,t,u;
  rep(i,0,n){
    rep(j,0,city[i].size()){
      a = get<2>(city[i][j]);
      
      t = "";
      u = "";
      rep(k,0,6-leng(i+1)) t += '0';
      rep(k,0,6-leng(j+1)) u += '0';
      s = t + to_string(i+1) + u + to_string(j+1);
      
      
      ans.pb(make_pair(a,s));
    }
  }
  sort(ALL(ans));
  rep(i,0,m) cout << ans[i].second << endl;
}


Measured memory_bytes: 14832
import java.util.Scanner

object Main extends App {
  val sc = new Scanner(System.in)
  val X, Y = sc.nextInt
  val t = Y / 2 - X
  val c = X - t
  val ans = if (Y % 2 == 0 && t >= 0 && c >= 0) "Yes" else "No"
  println(ans)
}


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

int main() {
    int n; cin >> n;
    double a;
    if(n % 2 == 0){
        a = n/2;
    }else{
        a = n/2 + 1;
    }
    printf("%.10f", a/n);

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cfloat>
#include<cassert>
#include<cmath>
#include<vector>
#include<algorithm>
#include<stdio.h>
using namespace std;
 
#define EPS (1e-10)
#define equals(a, b) (fabs((a) - (b)) < EPS )
#define dle(a, b) (equals(a, b) || a < b )
static const double PI = acos(-1);

class Point{
public:
  double x, y;
  
  Point ( double x = 0, double y = 0): x(x), y(y){}
  
  Point operator + ( Point p ){ return Point(x + p.x, y + p.y); }
  Point operator - ( Point p ){ return Point(x - p.x, y - p.y); }
  Point operator * ( double a ){ return Point(x*a, y*a); }
  Point operator / ( double a ){ return Point(x/a, y/a); }
  
  double abs() { return sqrt(norm());}

  double norm() { return x*x + y*y; }

  void rotate(double s,Point g = Point(0.0,0.0)){
    x=x-g.x;
    y=y-g.y;
    double nx=x*cos(s)-y*sin(s);
    double ny=x*sin(s)+y*cos(s);
    x=nx+g.x;
    y=ny+g.y;
  }
  
  bool operator < ( const Point &p ) const {
    return x != p.x ? x < p.x : y < p.y;
  }
  
  bool operator == ( const Point &p ) const {
    return fabs(x-p.x) < EPS && fabs(y-p.y) < EPS;
  }
};
typedef Point Vector;
double getDistance(Point a,Point b){
  return sqrt(pow(a.x-b.x,2.0)+pow(a.y-b.y,2.0));
}



//PerfectCircle
class Circle{
public:
  Point o;
  double r;
  
  Circle ( Point o = Point(0.0,0.0), double r = 0.0): o(o), r(r){}
  
  double area() { return r*r*PI; }

};

int getCrossState(Circle a,Circle b){

  double x=getDistance(a.o,b.o);
  if(x+b.r < a.r)return 2; 
  else if(x+a.r<b.r)return -2;
  else if(x<=a.r+b.r)return 1;
  else return 0;
  
}






vector<Point> getCrossPoints(Circle a,Circle b){

  
  vector<Point> res;
  if(getCrossState(a,b)!=1){
    return res;
  }


  double n = getDistance(a.o,b.o);
  double rate = b.r/(a.r+b.r);
  
  n*=rate;
  
  double h = sqrt(abs(b.r * b.r - n*n));
  
  //cout<<a.o.y<<" "<<b.o.y<<endl;
  Point g = b.o+((a.o-b.o)*rate);

  //cout<<g.x<<' '<<g.y<<endl;
  Vector gb = b.o-g;

  gb.rotate( PI/2.0);

 

  res.push_back(g + gb*(h/gb.abs()));

  if(abs(h)<EPS)return res;
  gb.rotate(PI);
  res.push_back(g + gb*(h/gb.abs()));

  return res;
}

int main(){
  Circle t[100];
  vector <Point> crosspoints,tmp;
  int n,cnt,ans;
  char ch;
  while(cin>>n){
    if(n==0)break;
    crosspoints.clear();
    tmp.clear();
    
    for(int i=0;i<n;i++){
      cin>>t[i].o.x>>ch>>t[i].o.y;
      t[i].r=1.0;
      for(int j=i-1;j>=0;j--){
	tmp=getCrossPoints(t[i],t[j]);
	for(int k=0;k<(int)tmp.size();k++){
	  if(tmp[k].x<0.0||tmp[k].y<0.0)continue;
	  if(tmp[k].x>10.0||tmp[k].y>10.0)continue;
	  crosspoints.push_back(tmp[k]);
      }//k
    }//j
  }//i
  
  crosspoints.push_back(Point(0.0,0.0));
  crosspoints.push_back(Point(10.0,0.0));
  crosspoints.push_back(Point(0.0,10.0));
  crosspoints.push_back(Point(10.0,10.0));
  


  ans=0;
    for(int i=0;i<(int)crosspoints.size();i++){
      //cout<<crosspoints[i].x<<" "<<crosspoints[i].y<<endl;
      cnt=0;
      for(int j=0;j<n;j++){
	if(getDistance(crosspoints[i],t[j].o)<=t[j].r+EPS)cnt++;
      }
      ans=max(ans,cnt);
    }
    
    cout<<ans<<endl;
  }//while
  return 0;
}

Measured memory_bytes: 1276