akhauriyash/Code-Regression huggingface dataset:
//#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<cstdio>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<utility>
#include<algorithm>
#include<cstring>
#include<sstream>
#include <iomanip>

using namespace std;

typedef long long ll ;
typedef double db;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector< pair<int,int> > vii;
const double pi = 2*acos(0) ;

#define pf		  	printf
#define sf			  scanf
#define pb(a)         push_back(a)
#define mp			make_pair
#define fi			 first
#define se			 second
#define for0(i,n)        for(int i=0;i<n;i++)
#define for1(i,n)        for(int i=1;i<=n;i++)
#define forab(i,a,b)       for(int i=a;i<=b;i++)
#define lcm(a, b)     ((a)*((b)/gcd(a,b)))
#define sq(a)		   (a)*(a)
#define nw				"\n"
#define abs(x)		fabs(x)
#define pcase(z,x)    cout<<"Case "<<z<<": "<<x<<"\n"
int main()
{
	int w,a,b,ans;
	cin>>w>>a>>b;
	if(b>a+w) ans = b-(a+w);
	else if(a>b+w) ans= a - (b+w);
	else ans=0;
	
	cout<<ans<<nw;
	
	return 0;
}

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

class Program
{
    static void Main(string[] args)
    {
        string[] input = Console.ReadLine().Split();
        long A = long.Parse(input[0])-1;
        long B = long.Parse(input[1]);
        long C = long.Parse(input[2]);
        long D = long.Parse(input[3]);
        long gcd = Gcd(C, D);
        long B_num = B - (B / C + B / D - B / (C*D/gcd));
        long A_num = A - (A / C + A / D - A / (C*D/gcd));
        Console.WriteLine(B_num-A_num);
    }
    public static long Gcd(long a, long b)
    {
        if (a < b)
            // 引数を入替えて自分を呼び出す
            return Gcd(b, a);
        while (b != 0)
        {
            var remainder = a % b;
            a = b;
            b = remainder;
        }
        return a;
    }

}


Measured memory_bytes: 11092
#include <stdio.h>

int main() {
    int a,b,c,d;
    scanf("%d %d %d %d", &a,&b,&c,&d);
    if(a==1 || a==3 || a==5 || a==7 || a==8 || a==10 || a==12){
        if(a+1==c && b==31 && d==1)
            printf("1\n");
        else
            printf("0\n");
    }
    else if(a==2){
        if(a+1==c && b==28 && d==1)
            printf("1\n");
        else
            printf("0\n");        
    }
        
    else{
        if(a+1==c && b==30 && d==1)
            printf("1\n");
        else
            printf("0\n");        
    }
	return 0;
}

Measured memory_bytes: 128
// by adiforluls
#pragma GCC optimize ("-O2")
#include<bits/stdc++.h>
using namespace std;
#define FAST   ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ll          long long
#define ld          long double
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define mii         map<int,int>
#define vi          vector<int>
#define vll         vector<long long>
#define all(a)      (a).begin(),(a).end()
#define clz(a)      __builtin_clz(a) // count leading zeroes
#define ctz(a)      __builtin_ctz(a) // count trailing zeroes
#define popc(a)     __builtin_popcount(a) // count set bits (for ints only diff for ll)
#define lul         1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define SIZE        1000005
#define F           first
#define S           second
#define debug(x)    cerr << #x << " = " << x << endl;
#define mod         998244353

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " = " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " = " << arg1<<" |";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

#define endl        '\n'
const ld PI = acos(-1.0);
const int INF = 0x3f3f3f3f;

void solve()
{
  string s; cin>>s;
  int ok1=0,ok2=0;
  int dig1=(s[0]-'0')*10 + s[1]-'0',dig2=(s[2]-'0')*10 + s[3]-'0';
  ok1=(dig1>=1 and dig1<=12);
  ok2=(dig2>=1 and dig2<=12);
  if(ok1 and !ok2) cout<<"MMYY";
  if(!ok1 and ok2) cout<<"YYMM";
  if(ok1 and ok2) cout<<"AMBIGUOUS";
  if(!ok1 and !ok2) cout<<"NA";
} 
int main()
{   
    FAST;
    // #ifndef ONLINE_JUDGE
     // freopen("input.txt", "r", stdin);
     // freopen("output.txt", "w", stdout);
   //  #endif
    int t; t=1;
    while(t--){
       solve();
    }
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <climits>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;

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

const int INF = 1e9;
const long long LINF = 1e18;


bool containD(int n, const vector<bool>& D) {
    while (n != 0) {
        int d = n % 10;

        if (D[d]) {
            return true;
        }

        n /= 10;
    }
    return false;
}

int main() {
    int N, K;
    cin >> N >> K;

    string strN = to_string(N);

    vector<bool> D(10, false);
    for (int i = 0; i < K; i++) {
        int Di;
        cin >> Di;
        D[Di] = true;
    }

    for (int i = 0; i <= 100000; i++) {
        if (!containD(N + i, D)) {
            cout << N + i << endl;
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 256
import numpy as np

n,q=map(int,input().split())
s=str(input())

line = np.zeros([n,])
count = 0
for i in range(1,n):
    if (s[i-1:i+1]=="AC"): 
        count += 1
    line[i]=count 
        
for i in range(q):
    l,r = map(int,input().split())
    target = line[r-1] - line[l-1]
    print(int(target))

Measured memory_bytes: 14044
#include<stdio.h>
int main(){
  int a,b,c,i,j,n[100],k=0;
  scanf("%d%d%d",&a,&b,&c);
  if(a<b){
    j=b;
  }else{
    j=a;
  }
  for(i=1;i<=j;i++){
    if(a%i==0&&b%i==0){
      n[k]=i;
      k++;
    }
  }
  c=k-c;
  printf("%d\n", n[c]);
  return 0;
}


Measured memory_bytes: 128
#include<math.h>
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define ll long long int
#define py printf("Yes\n")
#define pn printf("No\n")
#define in cin>>
using namespace std;
const int INF = 1001001001;

int main()
{
    int a[3],k;
    in a[0]>>a[1]>>a[2]>>k;
    sort(a,a+3);
    cout<<a[0]+a[1]+a[2]*pow(2,k)<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>

using namespace std;

int main()
{
    int a,b,c,arr[105];

    while(scanf("%d %d %d",&a,&b,&c)==3)
    {
        memset(arr,0,sizeof(arr));

        arr[a]++;
        arr[b]++;
        arr[c]++;

        int cnt=0;

        for(int i=1; i<=100; i++)
        {
            if(arr[i]>=1)
                cnt++;
        }

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

    return (0);
}


Measured memory_bytes: 256
#include <stdio.h>
main(){
  int n[10],a,b,i,nsum,m;
  while(scanf("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d",&n[0],&n[1],&n[2],&n[3],&n[4],&n[5],&n[6],&n[7],&n[8],&n[9],&a,&b) !=EOF){
    double t=0,x;
    nsum=0;
   for(i=0;i<10;i++){
     nsum+=n[i];
   }
   t=nsum/(double)(a+b);
   x=t*(double)a;
   m=0;
   for(i=0;i<10;i++){
     if((double)x-m>0&&(double)x-m<n[i]){
       i++;
       break;
     }
     else if(x-m==0) break;
     else m+=n[i];
   }
   printf("%d\n",i);
 
  }
  return 0; 
}

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

using namespace std ;

#define sz(v) (int)v.size()
#define ll long long
#define all(v)  v.begin() , v.end()
#define rall(v)  v.rbegin() , v.rend()
#define pf push_front
#define pb push_back
#define fast FastInputOutput() ;
#define Clear( container , value ) memset( container , value , sizeof container )
#define PI acos( -1.0 )
#define forn( t , v , be , n ) for( t v = be ; v < n ; v++ )
#define fore( x , j ) for( auto x : j )
#define se second
#define fr first
//#define c_b fflush(stdin);

const ll Long_max = numeric_limits < ll > :: max() ;
const int Int_max = numeric_limits < int > :: max() ;

void File_input( string pathIn ) {
    freopen( pathIn.c_str(), "r", stdin ) ;
}

void File_output( string pathOut ) {
    freopen( pathOut.c_str(), "w", stdout ) ;
}

int msg() {
    srand( time( 0 ) ) ;
    vector < string > st = {
        "Wish everyone high ratings!",
        "Good luck!",
        "Have fun!",
        "Please, read all the problems!",
        "Go Go fight!"
    } ;
    cerr << st[ rand() % sz( st ) ] ;
    return 0 ;
}

void FastInputOutput() {
    ios_base :: sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;
    cout.tie( 0 ) ;
}

int a , b ;
bool is(int c ){
int rev = 0 , t = c ;
while( c ){
    rev = rev * 10 + c % 10 ;
    c /= 10 ;
}
return rev == t ;
}

int main() {
   cin >> a >> b ;
   int cn = 0 ;
   forn( int , i , a , b + 1 ){
     cn += is( i ) ;
   }
   cout << cn ;
   return 0 ;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<string>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<map>
#include<set>
#include<limits>
#include<bitset>
#include<array>
#include<numeric>
#include<iomanip>
#include<functional>

using namespace std;
typedef long long int ll;

#define C(I) cout<<(I)<<endl

ll n,m,a,b,c,x,y,z,aa[100010],ba[100010];
bool r,ra,rb,rc;
string s,sa,sb,sc;
char ca,cb,cc;
vector<ll> va,vb,vc;

int main(){
    cin>>s;
    for(int i=0;i<s.size();i++){
        if(s[i]==',')cout<<" ";
        else cout<<s[i];
    }
    cout<<endl;
}

Measured memory_bytes: 256
fun main() = Thread(null, ::abc169c, "(^o^)", 128 * 1024 * 1024).apply { start() }.join()

@OptIn(ExperimentalStdlibApi::class)
fun abc169c() {
    val (a, b) = readLine()!!.split(' ')

    val (decimal, integer) = b.split(".")
    val multiply = decimal.toLong() * 100 + integer.padEnd(2, '0').toLong()

    val answer = a.toLong() * multiply / 100

    println(answer)
}



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

int main() {
    int k, n, c;
    while (cin >> k, k) {
        n = k * (k-1) / 2;
        int sum = 0;
        for (int i=0; i<n; ++i) {
            cin >> c;
            sum += c;
        }
        cout << sum / (k-1) << endl;
    }
    return 0;
}

Measured memory_bytes: 1160
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)
    def sum(self, i):  # 区間 [1, i]の和
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s
    def add(self, i, x):  # iにxを加算
        while i <= self.size:
            self.tree[i] += x
            i += i & -i  
    def pos(self, idx):  # idxの値を取得
        return self.sum(idx) - self.sum(idx-1)
    def lower_bound(self, w):  # w以上の値を持つ最小のidxを検索
        if w <= 0:
            return 0
        idx = 0
        k = 1
        while k*2 <= self.size:
            k *= 2
        while k > 0:
            if idx+k <= self.size and self.tree[idx+k] < w:
                w -= self.tree[idx+k]
                idx += k
            k //= 2
        return idx+1

N, K = MAP()
A = LIST()

bit = Bit(max(N, max(A)))
inv = 0
for i, a in enumerate(A):
	inv += i-bit.sum(a)
	bit.add(a, 1)
ans = inv*K%mod

cnt = [0]*(max(A)+1)
for a in A:
	for b in A:
		if a < b:
			cnt[a] += 1

for n in cnt:
	ans += n*((K*(K-1))//2)
	ans %= mod
print(ans)


Measured memory_bytes: 5324
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

//Ghost Buster!
public class Main{

	public static int h;
	public static int w;
	public static char[] pattern;

	public static char[][] map;
	public static int[][] opt;
	public static int[][] move = {{1,0},{0,-1},{0,1},{-1,0},{0,0}};

	public static int dir(char c){
		return c=='2'?0:c=='4'?1:c=='6'?2:c=='8'?3:4;
	}

	public static int si;
	public static int sj;
	public static int ti;
	public static int tj;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true){
			h = sc.nextInt();
			w = sc.nextInt();
			if(h==0&&w==0)break;
			map = new char[h][w];
			for(int i=0;i<h;i++){
				char[] s = sc.next().toCharArray();
				for(int j=0;j<w;j++){
					map[i][j] = s[j];
					if(s[j]=='A'){
						si = i;
						sj = j;
						map[i][j] = '.';
					}
					if(s[j]=='B'){
						ti = i;
						tj = j;
						map[i][j] = '.';
					}
				}
			}
			pattern = sc.next().toCharArray();
			opt = new int[h][w];
			for(int[]a:opt)Arrays.fill(a, Integer.MAX_VALUE);
			opt[si][sj] = 0;
			List<int[]> list = new ArrayList<int[]>();
			list.add(new int[]{si,sj});
			int dis = 1;
			while(!list.isEmpty()){
				List<int[]> next = new ArrayList<int[]>();
				for(int[] a : list){
					for(int k=0;k<4;k++){
						int i = a[0] + move[k][0];
						int j = a[1] + move[k][1];
						if(0<=i&&i<h&&0<=j&&j<w&&map[i][j]=='.'&&opt[i][j]==Integer.MAX_VALUE){
							opt[i][j] = dis;
							next.add(new int[]{i, j});
						}
					}
				}
				list = next;
				dis++;
			}
			int ans = 1000;
			int mi = 0;
			int mj = 0;
			int step = 0;
			while(step <= ans){
				if(opt[ti][tj]<=step){
					if(step < ans){
						ans = step;
						mi = ti;
						mj = tj;
					}
				}
				int k = dir(pattern[step%pattern.length]);
				step++;
				int ni = ti + move[k][0];
				int nj = tj + move[k][1];
				if(0<=ni&&ni<h&&0<=nj&&nj<w){
					ti = ni;
					tj = nj;
				}
			}
			System.out.println(ans==1000?"impossible":(ans+" " + mi + " " + mj));
		}
	}
}

Measured memory_bytes: 12000
import sys

def main():
  input = sys.stdin.readline
  S = str(input())
  ans = 'WA'
  if S[0] == 'A':
    if 'C' in S[2:-2]:
      S = S.replace('A', '', 1)
      S = S.replace('C', '', 1)
      if S.islower():
        ans = 'AC'
        
  print(ans)


if __name__ == '__main__':
  main()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define boost  ios_base::sync_with_stdio(0);
#define N 1000
#define ll long long int
#define pb push_back
#define f first
#define s second
#define fo(i,a,b) for(i = a; i < b; i++)
#define foe(i, a,b) for(i = a; i <= b; i++)
#define tc long long int t; cin >> t; while(t--)
#define vect vector <ll>
#define pll pair<ll,ll>
#define vpll vector<pair<ll,ll>>
#define be begin
#define en end

int main(){
	boost;
	ll i;
	ll n;
	cin >> n;
	vector<ll> dp(3);
	ll day;
	for(day = 0; day < n; day++){
   		vector<ll> new_dp(3, 0);
   		ll c[3];
    	for(i = 0; i < 3; i++){
        	cin >> c[i];
    	}
    	ll j;
    	for(i = 0; i < 3; i++){
            for(j = 0; j < 3; j++){
                if(i != j){
                    new_dp[j] = max(new_dp[j], dp[i] + c[j]);
                }
            }
        }
        dp = new_dp;
	}
	cout << max({dp[0], dp[1], dp[2]}) <<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
string qst;
void replace(int s, int f, string rep){
    int c=0;
    for(int i=s;i<f+1;i++){
        qst[i]=rep[c];
        c++;
    }
}
void reverse(int s, int f){
    char tmp[1000];
    int c=0;
    for(int i=s;i<f+1;i++){
        tmp[i]=qst[f-c];
        c++;
    }
    for(int i=s;i<f+1;i++){
        qst[i]=tmp[i];
    }
}
void print(int s, int f){
    for(int i=s;i<f+1;i++){
        cout<<qst[i];
    }
    cout<<endl;
}
int main(){
    string sen,rep;
    int rep_s,rep_f,rev_s,rev_f,p_s,p_f;
    int n;
    cin>>qst>>n;
    for(int i=0;i<n;i++){
        cin>>sen;
        if(sen=="replace"){
            cin>>rep_s>>rep_f>>rep;
            replace(rep_s,rep_f,rep);
        }
        else if(sen=="reverse"){
            cin>>rev_s>>rev_f;
            reverse(rev_s,rev_f);
        }
        else if(sen=="print"){
            cin>>p_s>>p_f;
            print(p_s,p_f);
        }
    }
    return 0;
}



Measured memory_bytes: 3220
#include<iostream>
using namespace std;
#include<cstring>
#include<cstdio> 
char s[1010000];
int gs[1010];
int pre[1010];
int main()
{
	while(scanf("%s",s)!=EOF)
	{
		int len=strlen(s);
		memset(gs,0,sizeof(gs));
		memset(pre,0,sizeof(pre));
		int l=-1,r=-1;
		for (int i=0;i<len;i++)
		{
			if (gs[s[i]]!=0)
			{
				if (i-pre[s[i]]<=2)
				{
					l=pre[s[i]]+1;
					r=i+1;
					break;
				}
			}
			gs[s[i]]++;
			pre[s[i]]=i;
		}
		cout<<l<<" "<<r<<endl;
	}
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
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;
}
bool is_prime(ll n) {
  for (ll i = 2; i*i <= n; i++) {
    if (n%i == 0) return false;
  }
  return n != 1;
}
ll mod_pow(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll res = mod_pow(x*x%mod, n/2, mod);
  if (n & 1) res = res * x % mod;
  return res;
}

int main() {
    ll res1 = INF, res2 = INF;
    ll a;
    rep(i, 3) {
        cin >> a;
        res1 = min(res1, a);
    }
    rep(i, 2) {
        cin >> a;
        res2 = min(res2, a);
    }
    cout << res1 + res2 - 50 << endl;
}


Measured memory_bytes: 3112
use std::io::*;
use std::str::*;
use std::collections::HashSet;

fn read<T: FromStr>() -> Option<T> {
    let stdin = stdin();
    let s = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok()
}

fn main() {
    let a: i64 = read().unwrap();
    let b: i64 = read().unwrap();
    let k: i64 = read().unwrap();
    let mut answer = HashSet::new();
    for i in 0..k {
        let x = a + i;
        let y = b - i;
        if i > ((b - a) as f64 / 2.0) as i64 {
            break;
        }
        answer.insert(x);
        answer.insert(y);
    }
    let mut answer = answer.into_iter().collect::<Vec<i64>>();
    answer.sort_by(|a, b| a.cmp(b));
    for ans in answer.iter() {
        println!("{}", ans);
    }
}


Measured memory_bytes: 4352
n = int(input())
x = list(map(int,input().split()))
s = [0] * (max(x) - min(x) + 1)
ans = 0
#
for p in range(min(x),max(x)+1):
    for j in range(n):
        s[p - x[0]] += (x[j] - p)**2
#
ans = min(s)
print(ans)


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

const int N = 10000;


void initTbl(unsigned char* p, unsigned char*rev_p){
	p[0]=1;
	rev_p[N-1]=1;

    for(int i=4; i<N; i+=2){
        p[i-1] = 1;
		rev_p[(N-1)-(i-1)] = 1;
    }
 
    for(int j=3; j*j<=N; j+=2){
        for(int k=j; j*k<=N ;k+=2){
            p[j*k-1] = 1;
			rev_p[(N-1)-(j*k-1)] = 1;
        }
    }
}

//1004
int main(){
	unsigned char isprime[N]={0};
	unsigned char rev_isprime[N]={0};

	initTbl(isprime, rev_isprime);

	int n;
	while(cin >> n){
		int count=0;
		int ofs=N-n;
		for(int i=0; i<n; ++i){
			if(isprime[i]==0 && rev_isprime[i+ofs]==0){
				++count;
			}
		}
		cout << count << endl;
#ifdef DEBUG
		for(int i=0; i<n; ++i){
			cout.width(3);
			cout << i+1 ;
		}
		cout << endl;
		for(int i=0; i<n; ++i){
			cout.width(3);
			cout <<  (isprime[i]?"":"*") ;
		}
		cout << endl;
		for(int i=0; i<n; ++i){
			cout.width(3);
			cout << (rev_isprime[i+ofs]?"":"*");
		}
		cout << endl;
#endif

	}
	return 0;
}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}
ll nextLong() { ll x; scanf("%lld", &x); return x;}

int main2() {
  int N = nextInt();
  cout << (N+1) / 2 << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}

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

typedef long long ll;

static const int MAX = 1e6+5;
// static const int NIL = -1;
// static const ll INF = 1<<21;
static const ll MOD = 1e9 + 7;

bool compPair(const pair<int, int>& arg1, const pair<int, int>& arg2) {
    return arg1.first > arg2.first;
}

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

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

ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(void) {
    int x, y;
    cin >> x >> y;
    
    if((x+y)%3!=0) {
        cout << 0 << endl;
        return 0;
    }

    int n = (2*y-x)/3, m = (2*x-y)/3;

    COMinit();

    cout << COM(n+m, m) << endl;

    return 0;
}


Measured memory_bytes: 23680
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define INF 1e9

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

    int X[3];
    cin >> X[0] >> X[1] >> X[2];
    sort(X, X+3);

    cout << X[2]*10+X[1]+X[0];

}

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

using namespace std;

void temp(int *x, int *y)
{
	int temp;
	temp = *x;
	*x = *y;
	*y = temp;
}

int main(void)
{
	int n;
	while(cin >> n && n != 0)
	{
		vector<int> a(n);
		for (int i = 0; i < n; ++i)
			cin >> a[i];

		int counter = 0;

		for (int i = n; i > 0; --i)
		{
			for(int k = 0;k < i-1;k++)
			{
				if(a[k] > a[k+1])
				{
					temp(&a[k], &a[k+1]);
					counter++;
				}
			}
		}

		cout << counter << endl;
	}

	return 0;
}


Measured memory_bytes: 3048
/*
 * じょえチャンネル
 * 高評価・チャンネル登録よろしくおねがいします！
 * https://www.youtube.com/channel/UCRXsI3FL_kvaVL9zoolBfbQ
 */
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define all(v) v.begin(),v.end()
#define inf (int)(3e18)
#define P pair<int,int>
#define mod (int)(1e9+7)
template<class T> inline void chmin(T &a, T b) {
	a = min(a, b);
}
template<class T> inline void chmax(T &a, T b) {
	a = max(a, b);
}

struct Segtree{
	int size=1;
	vector<int>dat;
	void update(int a,int x,int k=0,int l=0,int r=-1){
		if(r==-1)r=size;
		if(r-l==1){dat[k]=x;return;}
		if(a<(l+r)/2)update(a,x,k*2+1,l,(l+r)/2);
		else update(a,x,k*2+2,(l+r)/2,r);
		dat[k]=max(dat[k*2+1],dat[k*2+2]);
	}
	int query(int a,int b,int k=0,int l=0,int r=-1){
		if(r==-1)r=size;
		if(r<=a||b<=l)return -inf;
		if(a<=l&&r<=b)return dat[k];
		int lv=query(a,b,k*2+1,l,(l+r)/2);
		int rv=query(a,b,k*2+2,(l+r)/2,r);
		return max(lv,rv);
	}
	Segtree(int x){
		while(size<x)size*=2;
		dat.resize(size*2-1,-inf);
	}
};
int N;
int r[200005];
P p[200005];
int dp[200005];
signed main(){
	cin>>N;
	rep(i,N)cin>>p[i].first>>p[i].second;
	sort(p,p+N);
	Segtree segtree(N);
	for(int i=N-1;i>=0;i--){
		int rr=lower_bound(p,p+N,make_pair(p[i].first+p[i].second,0ll))-p;
		int q=segtree.query(i,rr);
		r[i]=max(q,i);
		segtree.update(i,r[i]);
	}
	dp[N]=1;
	for(int i=N-1;i>=0;i--){
		dp[i]=dp[i+1]+dp[r[i]+1];
		dp[i]%=998244353;
	}
	cout<<dp[0]<<endl;
}


Measured memory_bytes: 10624
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;

namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }


        static void Main(string[] args)
        {
            var N = Sarray()[0];
            var A = Sarray();
            var o = new Dictionary<long, long>();
            var e = new Dictionary<long, long>();
            for (var i = 0; i < A.Length; ++i)
            {
                if (i % 2 == 0)
                {
                    if (!o.ContainsKey(A[i]))
                        o[A[i]] = 1;
                    else
                        ++o[A[i]];
                }
                else
                {
                    if (!e.ContainsKey(A[i]))
                        e[A[i]] = 1;
                    else
                        ++e[A[i]];
                }
            }
            long maxvo1 = -1;
            long maxvo2 = -1;
            o[-1] = 0;
            foreach(var kv in o)
            {
                if (o[maxvo1] <= kv.Value)
                {
                    maxvo2 = maxvo1;
                    maxvo1 = kv.Key;
                }
                else if (o[maxvo2] <= kv.Value)
                    maxvo2 = kv.Key;
            }
            long maxve1 = -1;
            long maxve2 = -1;
            e[-1] = 0;
            foreach (var kv in e)
            {
                if (e[maxve1] <= kv.Value)
                {
                    maxve2 = maxve1;
                    maxve1 = kv.Key;
                }
                else if (e[maxve2] <= kv.Value)
                    maxve2 = kv.Key;
            }

            if (maxvo1 == maxve1)//最長が同じ文字
            {
                if (o[maxvo1] < e[maxve1])
                    N -= e[maxve1] + o[maxvo2];
                else if (e[maxve1] < o[maxvo1])
                    N -= o[maxvo1] + e[maxve2];
                else
                {
                    var max = Math.Max(o[maxvo2], e[maxve2]);
                    N -= o[maxvo1] + max;
                }
            }
            else
                N -= e[maxve1] + o[maxvo1];
            WriteLine(N);
        }
    }
}


Measured memory_bytes: 25184
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<queue>
#include<stack>
using namespace std;
#define vel vector<long long>
#define vvel vector<vel>
#define int long long
#define rep(i,n) for(long long i=0;i<n;i++)
#define rp(i,n) for(long long i=1;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define mmax(a,b) a=max(a,b)
#define mmin(a,b) a=min(a,b)
#define mkp make_pair
#define pin pair<int,int>
#define V vector
long long p = 1000000007;
vel par;
int ru(int a, int r) {
	if (r == 0) { return 1; }
	int ans = ru(a, r / 2);
	ans *= ans; ans %= p;
	if (r % 2 == 1) { ans *= a; ans %= p; }
	return ans;
}
signed main() {
	string l; cin >> l;
	int co = 0;
	int ans = 0;
	int n = l.size();
	rep(i, n) {
		if (l[i] == '1') {
			ans += (ru(2, co)*ru(3, n - 1 - i)) % p;
			ans %= p;
		}
		co += (l[i]-'0');
	}
	ans += ru(2, co); ans %= p;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 512
package main

import (
	"fmt"
	"math"
)

// 2018-08-04T14:42:31+0800
// 2018-08-04T14:54:30+0800
// 2018-08-04T15:27:19+0800 # @see https://arc091.contest.atcoder.jp/submissions/2940934
// 2018-08-04T15:32:40+0800 # @see https://arc091.contest.atcoder.jp/submissions/2940951
// 2018-08-04T15:38:28+0800 # @see https://arc091.contest.atcoder.jp/submissions/2940961
// 2018-08-04T15:40:22+0800 # @see https://arc091.contest.atcoder.jp/submissions/2940967
// 2018-08-04T19:13:38+0800
func main() {
	var N, A, B int
	fmt.Scanf("%d%d%d", &N, &A, &B)
	if N == 1 {
		if A != 1 || B != 1 {
			fmt.Println(-1)
			return
		} else {
			fmt.Println(1)
			return
		}
	}
	if A+B > N+1 {
		fmt.Println(-1)
		return
	}
	if false {
		min := 0
		NN := N
		root := 0
		for ; true; {
			root = int(math.Sqrt(float64(NN)))
			NN = NN - root*root
			if NN <= 2 {
				min += NN
				break
			}
			min += root
		}
		if A+B < min {
			fmt.Println(-1)
			return
		}
	} else {
		if A*B < N {
			fmt.Println(-1)
			return
		}
	}

	if B == 1 {
		for i := 0; i < N-1; i++ {
			fmt.Print(i+1, " ")
		}
		fmt.Println(N)
		return
	}
	if A == 1 {
		for i := N - 1; i > 0; i-- {
			fmt.Print(i+1, " ")
		}
		fmt.Println(1)
		return
	}

	// Now divide N to A groups while the largest one is B
	// (A-1)*span + B = N
	span := (N - B) / (A - 1)
	left := (N - B) - span*(A-1)
	reversePrintSlice(1, B)
	for i := 0; i < A-1; i++ {
		if i < left {
			reversePrintSlice(B+1+(span+1)*i, span+1)
		} else {
			reversePrintSlice(B+1+span*i+left, span)
		}
	}
	fmt.Println()
	return

	out := make([]int, N)
	iout := 0
	// span <= span <= B
	for i := 0; i < A-2; i++ {
		for ii := 0; ii < span; ii++ {
			out[iout] = i*span + span - ii
			iout++
		}
	}
	i := A - 2
	for ii := 0; ii < left; ii++ {
		out[iout] = i*span + left - ii
		iout++
	}
	for ii := 0; ii < B; ii++ {
		out[iout] = i*span + left + B - ii
		iout++
	}
	for i := 0; i < N-1; i++ {
		fmt.Print(out[i], " ")
	}
	fmt.Println(out[N-1])
}

func reversePrintSlice(from, length int) {
	for i := from + length - 1; i >= from; i-- {
		fmt.Print(i, " ")
	}
}

Measured memory_bytes: 7424
#include <algorithm>
#include <array>
#include <cstddef>
#include <cstdint>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <vector>

using namespace std;

int main()
{
    int a, p;
    cin >> a >> p;

    cout << ((p + 3 * a) / 2) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(int argc, char* argv[])
{
	string N;
	int i;
	cin>>N;
	for (i=0;i<N.length();i++){
		if (N[i]=='7'){
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
	return 0;
}

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

int main() {
    string s;
    int cnt[3]{}, k;
    cin >> s;
    for(auto c : s){
        ++cnt[c-'a'];
    }
    // abcabc...のように並べるので
    k = *min_element(cnt,cnt+3);
    cout << (cnt[0]-k < 2 && cnt[1]-k < 2 && cnt[2]-k < 2 ? "YES" : "NO") << endl;
    return 0;
}


Measured memory_bytes: 512
func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}

let nab=readInts()
let n=nab[0]
let l=nab[1]
var sum=0
var min=l
for i in 2...n{
  var c=l+i-1
  sum+=c
  if(abs(c)<abs(min)){sum-=c
                      sum+=min
                      min=c
                      }
}

print(sum)

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

using namespace std;

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

    unsigned int m;
    cin >> m;
    vector<int> b(m);
    for (int i = 0; i < m; ++i) {
        cin >> b[i];
    }

    cout << lexicographical_compare(a.begin(), a.end(), b.begin(), b.end()) << endl;
    return 0;
}


Measured memory_bytes: 3120
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Globalization;
using System.Diagnostics;
using static System.Console;
using Pair = System.Collections.Generic.KeyValuePair<int, int>;

class Program
{
    static void Main()
    {
        SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().Solve();
        Out.Flush();
    }
    Scanner cin = new Scanner();
    readonly int[] dd = { 0, 1, 0, -1, 0 };
    readonly int mod = 1000000007;
    readonly string alfa = "abcdefghijklmnopqrstuvwxyz";


    void Solve()
    {
        var S = cin.Next;
        WriteLine(S.LastIndexOf('Z') - S.IndexOf('A') + 1);
    }

}

class Scanner
{
    string[] s; int i;
    char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] Scan { get { return ReadLine().Split(); } }
    public int[] Scanint { get { return Array.ConvertAll(Scan, int.Parse); } }
    public long[] Scanlong { get { return Array.ConvertAll(Scan, long.Parse); } }
    public double[] Scandouble { get { return Array.ConvertAll(Scan, double.Parse); } }
    public string Next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return Next;
        }
    }
    public int Nextint { get { return int.Parse(Next); } }
    public long Nextlong { get { return long.Parse(Next); } }
    public double Nextdouble { get { return double.Parse(Next); } }
}

Measured memory_bytes: 4312
//#include<bits/stdc++.h>
    #include<iostream>
    using namespace std;
    const int N = 1000005;
    int main(){
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
        long long  n;  cin >> n;
        long long a = 100,ans = 0;
        while(a < n){
            a += a/100;
            ans++;
        }
        cout << ans;
        return 0;
    }

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

#define ll long long
#define fi first
#define se second
#define mp make_pair

#define fastio() ios_base::sync_with_stdio(false);cin.tie(NULL);
#define endl "\n"

using namespace std;

ll x;
void solve(){
	double per=(double)1.01;
	ll cur=100;
	int year=0;
	while(cur<x){
		cur=cur*per;
		year+=1;
	}
	cout<<year<<endl;
}

int main(){
	
	fastio();
	
	cin>>x;
	
	solve();
	
	return 0;
}

Measured memory_bytes: 3640
#include<iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <set>

using namespace std;

long long gcd(long long a, long long b){
    if (a%b == 0){
        return b;
    }else{
        return gcd(b,a%b);
    }
}

int main()
{
    // 整数の入力
    long long N,ai,i,T;
    cin >> N;
    for (i= 0;i<N;i++){
        cin >> ai;
        if (i ==0 ){
            T = ai;
        }else{
            T = ai* (T / gcd(T,ai));
        }
    }

    cout << T<< endl;
    return 0;
}

Measured memory_bytes: 256
def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    if K == 2:
        print(N - 1)
    else:
        ans = 10**10
        for k in range(K):
            v = 0
            if k > 0:
                v += 1
            v += (N - k) // (K - 1)
            if (N - k) % (K - 1) > 1:
                v += 1
            if v < ans:
                ans = v
        print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 95788
package main

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

func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	A := make([]int, n)
	for i := 0; i < n; i++ {
		A[i] = nextInt()
	}

	ans := mergeSort(A, 0, n)

	fmt.Println(strings.TrimRight(fmt.Sprintf("%+v", A)[1:], "]"))
	fmt.Println(ans)
}

func merge(A []int, left int, mid int, right int) int {
	//A[left:right]を、midで2つに分ける
	n1 := mid - left
	n2 := right - mid
	L := make([]int, n1)
	R := make([]int, n2)

	for i := 0; i < n1; i++ {
		L[i] = A[left+i]
	}
	for i := 0; i < n2; i++ {
		R[i] = A[mid+i]
	}
	L = append(L, 1000000000)
	R = append(R, 1000000000)
	i := 0
	j := 0

	for k := left; k < right; k++ {
		if L[i] < R[j] {
			A[k] = L[i]
			i++
		} else {
			A[k] = R[j]
			j++
		}
	}

	return right - left
}

func mergeSort(A []int, left int, right int) int {
	if left+1 < right {
		mid := (left + right) / 2
		//左半分に対して、マージソート
		a := mergeSort(A, left, mid)
		//右半分に対して、マージソート
		b := mergeSort(A, mid, right)
		//↑をマージ
		c := merge(A, left, mid, right)
		return a + b + c
	} else {
		return 0
	}
}



Measured memory_bytes: 31660
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
#define fore(i,a,b) for(ll i=(ll)(a);i<=(ll)(b);++i)
#define rep(i,n) fore(i,0,(n)-1)
#define rfore(i,a,b) for(ll i=(ll)(b);i>=(ll)(a);--i)
#define rrep(i,n) rfore(i,0,(n)-1)
#define all(x) (x).begin(),(x).end()
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
template<class T>
bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>
bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}

void solve(){
    ll n;cin>>n;
    vl a;
    ll t=n;
    for(ll i=2;i*i<=t;i++){
        while(t%i==0){
            a.push_back(i);
            t/=i;
        }
    }
    if(t>1)a.push_back(t);
    cout<<n<<":";
    rep(i,a.size())cout<<" "<<a[i];
    cout<<endl;
}

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



Measured memory_bytes: 3220
#include<bits/stdc++.h>
const int N=103,M=1e9+7;
using namespace std;
int n,m,a[N],b[N],f[N][N],i,j,tp;
inline int ksm(int t){
	if(t<0)return 1;
	int y=1;long long x=2;
	for(;t;t>>=1)
	t&1?y=y*x%M:0,x=x*x%M;
	return y;
}
inline void trans(int d){
	d=min(d,a[i+1]);
	f[i+1][d]=(f[i+1][d]+
	1ll*ksm(b[a[i]]-b[max(j,a[i+1])])*tp)%M;
}
int main(){
	scanf("%d",&n);
	for(i=0;i<n;i++)
	scanf("%d",a+i),b[i]=--a[i];
	sort(b,b+n+1),m=unique(b,b+n+1)-b;
	for(i=0;i<n;i++)
	a[i]=lower_bound(b,b+m,a[i])-b;
	f[0][0]=1;
	for(i=0;i<n;i++)
	for(j=0;j<=a[i];j++)
	if(tp=f[i][j])
	trans(j),trans(a[i]);
	printf("%d",f[n][0]);
}

Measured memory_bytes: 256
// Problem : D - Not Divisible
// Contest : AtCoder - AtCoder Beginner Contest 170
// URL : https://atcoder.jp/contests/abc170/tasks/abc170_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
#define F first
#define S second
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define pb push_back
#define mk make_pair
#define fast                    \
  ios_base::sync_with_stdio(0); \
  cin.tie(0);                   \
  cout.tie(0);
#define rep(i, a, b) for (ll i = a; i < b; i++)
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define sz(x) (int)x.size()
#define mem(a, val) memset(a, val, sizeof(a))
#define deci(x) cout << fixed << setprecision(x);
#define bitcount(x) __builtin_popcountll(x)

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

const long long int mod = 1e9 + 7;
const long double EPS = 1e-12;
const int N = 2e6 + 20;

ll vis[N];

void solve() {
  ll n;
  cin >> n;
  vector<ll> v(n);
  rep(i, 0, n) {
    cin >> v[i];
    vis[v[i]]++;
  }
  sort(all(v));
  ll ans = 0;
  for (ll i = 1; i < N; i++) {
    if (vis[i]) {
      ans += (vis[i] == 1);
      for (ll j = i + i; j < N; j += i) {
        vis[j] = 0;
      }
    }
  }
  cout << ans;
}
int main() {
  fast;
  ll t;
  t = 1;

  // cin>>t;

  while (t--) {
    solve();
  }

  return 0;
}


Measured memory_bytes: 20360
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long LL;
typedef long double ld;
typedef vector<ll>VI;
typedef pair<ll,ll>P;
#define VV(T) vector<vector<T>>
#define sz(x) int(x.size())
#define PI 3.1415926535897932384626433832795
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define ALL(a)  (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define c_max(a, b) (((ll)a)>((ll)b)?(a):(b))
#define c_min(a,b) (((ll)a)<((ll)b)?(a):(b))
#define chmax(x,a) x=max(x,a)
#define chmin(x,a) x=min(x,a)
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define $(x) {cout<<#x<<" = " <<(x)<<endl;}
#define fi first
#define se second
#define MAX 100100//5
#define MAX2 200100
#define MAX6 1001001//6
#define MAX7 10010010//7
#define SENTINEL 2000000000//9
const int MOD = 1000000007;
#define INF 1<<30
#define INFTY 1LL<<61
#define MAX_INT INT_MAX
#define Endl '\n'
#define CLR(mat) memset(mat, 0, sizeof(mat))
inline ll GCD(ll a,ll b){return b?GCD(b,a%b):a;}
inline ll lcm(ll a,ll b){return a*b/GCD(a,b);}
template<class T> bool contain(const std::string& s, const T& v) {
   return s.find(v) != std::string::npos;
}
using Edge=pair<int,ll>;
using Graph=vector<vector<ll> >;//ll or Edge
//const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
// sort_reverse -> greater<long long>()
// vector型から重複を削除 list.erase(unique(ALL(list)),list.end());
// g++ -o a a.cpp -Wall -lm -std=c++17
//push_back -> emplace_back
string S;
void add(ll &a,ll b){
   a+=b;
   if(a>=MOD)a-=MOD;
}
ll dp[MAX][4];
int main(){
   cin>>S;
   memset(dp,0,sizeof(dp));
   dp[0][0]=1;
   rep(i,sz(S)){
      rep(j,4){
         if(S[i]!='?')add(dp[i+1][j],dp[i][j]);
         else add(dp[i+1][j], dp[i][j]*3%MOD);
         dp[i+1][j]%=MOD;
      }
      if(S[i]=='A' || S[i]=='?')dp[i+1][1]+=dp[i][0];
      if(S[i]=='B' || S[i]=='?')dp[i+1][2]+=dp[i][1];
      if(S[i]=='C' || S[i]=='?')dp[i+1][3]+=dp[i][2];
      rep(j,4)dp[i+1][j]%=MOD;
   }
   cout<<dp[sz(S)][3]<<endl;
}

Measured memory_bytes: 6868
#include "bits/stdc++.h"
#define ll long long
#define vl vector<ll>
#define pl pair<ll,ll>
#define rep(i,b) for(ll i=0;i<b;i++)

using namespace std;

int main(){
    ll h,n,a,b;
    cin>>h>>n;
    vl dp(10005,10e9);
    dp[h]=0;
    rep(i,n){
        cin>>a>>b;
        for(ll j=h;j;j--) dp[max(0LL, j - a)] = min(dp[max(0LL, j - a)], dp[j] + b);
    }
    cout<<dp[0]<<endl;
}

Measured memory_bytes: 384
#include <cstdio>
#include <iostream>
#include <cstring>
#include <string>
#include <iterator>
#include <set>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;

typedef long long LL;
const int maxn = 1000020;
const LL INF = 100000000000000LL;
const LL mod = 998244353;
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define For(i,a,b) for(int i=a;i<=b;++i)

int n;
int a, b;
char s[maxn];
int w;

void solve() {
    int len = strlen(s + 1);
    for(int i = 1;i <= len;i += w) printf("%c", s[i]);
    cout << endl;
}

int main() {
    while(cin >> s + 1 >> w) {
        solve();
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <stack>
#include <vector>
#include <utility>
#include <list>
#include <algorithm>
#include <cmath>
using namespace std;

int main()
{
    int count = 1;
    while (true)
    {
        int n;
        cin >> n;
        if (n == 0)
            return 0;

        int x[n], y[n];
        cin >> x[0] >> y[0];
        for (int i = 1; i < n; i++)
        {
            cin >> x[i] >> y[i];
            x[i] -= x[0];
            y[i] -= y[0];
        }

        double S = 0;
        double tmp;
        for (int i = 2; i < n; i++)
        {
            S += x[i] * y[i - 1] - x[i - 1] * y[i];
        }
        S /= 2;
        printf("%d %.1lf\n", count++, S);
    }
}



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

int d1, d2, n;
vector<pair<int, int>> s1, s2;

int c1[600][600], c2[600][600];

template<class T, class U>
void boji(T c, U& s, int x, int y) {
	for (auto p : s)
		for (int dx=-1; dx<=1; dx+=2)
			for (int dy=-1; dy<=1; dy+=2) {
				int xx = x + dx*p.first;
				int yy = y + dy*p.second;

				if (xx < 0 || xx >= 2*n || yy < 0 || yy >= 2*n)
					continue;

				if (!c[xx][yy]) {
					c[xx][yy] = 3 - c[x][y];
					boji(c, s, xx, yy);
				}
			}
}

vector<pair<int, int>> sx[4];

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

	cin >> n >> d1 >> d2;
	for (int i=0; i<=2*n; i++) {
		for (int j=0; j<=2*n; j++) {
			if (i*i + j*j == d1)
				s1.push_back({i, j});
			if (i*i + j*j == d2)
				s2.push_back({i, j});
		}
	}

	for (int i=0; i<2*n; i++)
		for (int j=0; j<2*n; j++)
			if (!c1[i][j]) {
				c1[i][j] = 1;
				boji(c1, s1, i, j);
			}

	for (int i=0; i<2*n; i++)
		for (int j=0; j<2*n; j++)
			if (!c2[i][j]) {
				c2[i][j] = 1;
				boji(c2, s2, i, j);
			}

	for (int i=0; i<2*n; i++)
		for (int j=0; j<2*n; j++) {
			int x = c1[i][j] + 2*c2[i][j] - 3;
			sx[x].push_back({i, j});
		}

	for (int i=0; i<4; i++) {
		if (sx[i].size() >= n*n) {
			for (int j=0; j<n*n; j++) 
				cout << sx[i][j].first << ' ' << sx[i][j].second << '\n';
			return 0;
		}
	}
}

Measured memory_bytes: 57332
s=input()
s=s[::-1]
n=len(s)

count=[0]*2019
count[0]=1
num,d=0,1

for i in s:
  num+=int(i)*d
  num%=2019
  d*=10
  d%=2019
  count[num]+=1

ans=0
for i in count:
  ans+=i*(i-1)//2
  
print(ans)


Measured memory_bytes: 9356
#include <bits/stdc++.h>
#define ll long long
#define MAX 200010
#define rep(i,l,r) for(int (i)=(l);(i)<(r);(i)++)
using namespace std;

int main() {
    ll n;
    cin>>n;
    vector<ll> a(n),num(MAX,0);
    rep(i,0,n){
        cin>>a[i];
        num[--a[i]]++;
    }
    vector<ll> aa(MAX,0),bb(MAX,0);
    ll sum=0;
    rep(i,0,MAX){
        if(num[i]<2)continue;
        else{
            aa[i]=(num[i]*(num[i]-1))/2;
            bb[i]=((num[i]-2)*(num[i]-1))/2;
        }
        sum+=aa[i];
    }
    
    rep(i,0,n)cout<<sum-(aa[a[i]]-bb[a[i]])<<endl;
}

Measured memory_bytes: 9216
N,M,K=map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

import bisect
for i in range(1,N):
    A[i] += A[i-1]
for i in range(1,M):
    B[i] += B[i-1]


res = bisect.bisect_right(B,K)

for i in range(N):
    if K >= A[i]:
        j=bisect.bisect_right(B,K-A[i])
        res=max(res, i+1+j)

print(res)


Measured memory_bytes: 40768
#include <iostream>
void show(long long int n) {
	if (n == 1) std::cout << 1;
	else if (n == 0) std::cout << 0;
	else {
		if (n % 2 != 0) {
			show(-((n - 1) / 2));
			std::cout << 1;
		}
		else {
			show(-(n / 2));
			std::cout << 0;
		}
	}
}
int main() {
	long long int n;
	std::cin >> n;
	show(n);
}

Measured memory_bytes: 256
from collections import defaultdict
S = input()

d = defaultdict(int)

for i in range(len(S)):
    d[S[i]] += 1
f = 0
for i in range(len(S)):
    if d[S[i]] != 2:
        f = 1

if f == 0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 38256
#include<iostream>
#include<algorithm>
#include<map>
#include<set>
#include<string>
#include<bits/stdc++.h>
#include<vector>
using namespace std;
using ll = long long;
using lli = long long int;
ll MM = 1000000000;
ll mod = MM + 7;
#define INF (ll)1e18
#define pi acos(-1.0)
signed main(){
    int n; cin >> n;
    int a, b; cin >> a >> b;
    if((b-a)%2 == 0) cout << "Alice" << endl;
    else cout << "Borys" << endl;
}

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



int main(){
    string s;
    cin >> s;
    bool ok = false;
    string s_r = s;
    reverse(s_r.begin(), s_r.end());
    if(s == s_r){
        int n = s.size();
        string sub1 = s.substr(0, (n-1)/2);
        // cout << sub1 << endl;
        string sub1_r = sub1;
        reverse(sub1_r.begin(), sub1_r.end());
        if(sub1 == sub1_r){
            string sub2 = s.substr((n-1)/2+1);
            // cout << sub2 << endl;
            string sub2_r = sub2;
            reverse(sub2_r.begin(), sub2_r.end());
            if(sub2 == sub2_r){
                ok = true;
            }
        }
    }
    cout << (ok?"Yes":"No") << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#ifdef WIN32
#define ld "%I64d"
#else
#define ld "%lld"
#endif
using namespace std;
int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	if(n == 1 && m == 1){
		putchar('1');
		return 0;
	}
	if(n == 1){
		printf("%d",m - 2);
		return 0;
	}
	if(m == 1){
		printf("%d",n - 2);
		return 0;
	}
	printf(ld,1ll * (n - 2) * (m - 2));
	return 0;
}

Measured memory_bytes: 256