akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  reverse(s.begin(),s.end());
  vector<int> r(s.size()+1,0);
  int p=1;
  for(int i=0;i<s.size();i++){
    r.at(i+1)=(r.at(i)+(int)(s.at(i)-'0')*p)%2019;
    p=p*10%2019;
  }
  map<int,int> rm;
  for(int i=0;i<=s.size();i++)
    rm[r.at(i)]++;
  int64_t c=0;
  for(auto x:rm)
    c+=x.second*(x.second-1)/2;
  cout<<c<<endl;
}

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

signed main() {
  string S;
  cin >> S;
  
  string abc = "abcdefghijklmnopqrstuvwxyz";
  int ans = 1000;
  
  for( int i = 0; i < abc.size(); i++ ){
    string T = S;
    int cnt = 0;
    while( true ){
      if( T == string(T.size(), abc.at(i)) ) break;
      string tochu(T.size()-1, ' ');
      for( int j = 0; j < tochu.size(); j++ ){
        if( T.at(j) == abc.at(i) || T.at(j+1) == abc.at(i) ){
          tochu.at(j) = abc.at(i);
        }else{
          tochu.at(j) = T.at(j);
        }
      }
      T = tochu;
      cnt++;
    }
    ans = min(ans, cnt);

  }
  cout << ans << endl;
    
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
const int mod = 1000000007;

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

    vector<int> broken(n+1);
    rep(i, m) {
        int a;
        cin >> a;
        broken[a] = 1;
    }

    vector<int> dp(n+2);  // dp[i] : i段目からn段目に上る場合の数をmodで割ったあまり

    dp[n] = 1;
    for(int i = n-1; i >= 0; i--) {
        if(broken[i]) {
            dp[i] = 0;
            continue;
        }
        dp[i] = (dp[i+1] + dp[i+2])%mod;
    }
    
    cout << dp[0] << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
vector<pair<int,int> >v[100005];
int in[100005],mk[100005];
main()
{
	int t,p,a,b,w;
    scanf("%d%d",&t,&p);
    for(int i = 0;i < p;i++)
    {
        scanf("%d%d%d",&a,&b,&w);
        v[a].push_back(make_pair(b,w));
        v[b].push_back(make_pair(a,-w));
    }
    for(int i = 1;i <= t;i++)
    {
        mk[i]=-1.1e9;
    }
    for(int i = 1;i <= t;i++)
    {
        if(mk[i]==-1.1e9)
        {
            mk[i]=0;
            queue<int>q;
            q.push(i);
            while(!q.empty())
            {
                int cur=q.front();
                for(int j = 0;j < v[cur].size();j++)
                {
                    int go=v[cur][j].first,wa=v[cur][j].second;
                    if(mk[go]==-1.1e9)
                    {
                        mk[go]=mk[cur]+wa;
                        q.push(go);
                    }
                    else if(mk[go]!=mk[cur]+wa)
                    {

                        printf("No");
                        return 0;
                    }
                }
                q.pop();
            }
        }
    }
    printf("Yes");
}


Measured memory_bytes: 9344
#include<bits/stdc++.h>
//#include"Hamadneh"

typedef int i32;
typedef long long i64;
typedef unsigned int u32;
typedef unsigned long long u64;


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


#define debug(x)  cerr<<x<<"\n";
#define loop(i,n) for(i32 i = 0; i < n; ++i)
#define pi  pair<int,int>
#define ti  tuple<int,int,int>
#define mt  make_tuple
#define mk  make_pair
#define vi  vector<int>
#define vll vector<i64>
#define fastInOut ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pr(a) for(auto x:a) cout<<x<<" ";
#define prmap(m) for(auto x:m) cout<<x.first<<" "<<x.second<<"\n";
using namespace std;
i64 h,w,n;
int main() 
{ 
    fastInOut
    cin>>h;
    set <i32>v;
    int c=1;
    for(int i=0;i<h;i++){
         cin>>w;
         if(v.size()==0)
             v.insert(w);
         else {
             if(w<=*v.begin())
                 c++;
            v.insert(w);
         }
    }
    cout<<c;
   return 0; 
} 

Measured memory_bytes: 9728
#include <iostream>
#include <cstdlib>
#include <time.h>
#include <algorithm>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#include <array>
#include <string>
#include <iomanip>
#include <cmath>
#define _USE_MATH_DEFINES
using namespace std;

typedef long long int ll;

int main(){
	cin.sync_with_stdio(false);
	cin.tie(0);
	ll a, b;
	cin >> a >> b;
	cout << max({a+a-1, a+b, b+b-1});
	return 0;
}

Measured memory_bytes: 3596
// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}

const int N = 110;
int n , a[N][N];

int main(){
  scanf("%d",&n);
  if(n == 2) return puts("-1") , 0;
  rep(i,0,n) rep(j,0,n-1)
    a[i][j] = (i + j + 1) % n;
  if(n % 2 == 0) {
    rep(i,0,n/2) for(int j=0;j+1<n-1;j+=2)
      swap(a[i][j] , a[i][j + 1]);
  }
  rep(i,0,n) rep(j,0,n-1)
    printf("%d%c",a[i][j]+1," \n"[j==n-2]);
  return 0;
}


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

int main() {
  int N, K, x, sum;
  cin >> N >> K;
 
  for (int i = 0; i < N  ; i++) {
    cin >> x;
    if (x <= (K-x)) {
      sum += 2*x;
    }
    else { sum += 2*(K-x);
         }
  }
  cout << sum << endl;
}

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

using namespace std;
typedef long long int lli;

const int MAXN = 1010;
const int MOD = 1000000007;

int n;

bool isPrime[MAXN];

int main()
{
	scanf("%d",&n);

	memset( isPrime , true , sizeof(isPrime) );

	lli ans = 1;

	for(int i = 2 ; i <= n ; i++)
	{
		if( !isPrime[i] ) continue;

		lli qtd = 0;

		for(int k = 1 ; k <= n ; k++)
		{
			lli pot = i;

			while( k%pot == 0 )
			{
				qtd++;
				pot *= i;
			}
		}

		ans *= qtd + 1;
		ans %= MOD;

		for(int j = 2*i ; j <= n ; j += i)
			isPrime[j] = false;
	}

	printf("%lld\n",ans);
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <vector> 
#include <numeric>
#include <cmath>
#include <queue>
#include <iomanip>
#include <functional>

#define CHMAX(a,b) a = std::max(a,b)
#define CHMIN(a,b) a = std::min(a,b)
#define MAXMIN(a,b,c) std::max(a,min(b,c))
#define CHABS(a) a = std::abs(a) 
#define COUT(a) std::cout << a << std::endl
#define CERR(a) std::cerr << a << std::endl
#define FOR(n) for(lli i = 0; i < n; i++)

using namespace std;
using lli = long long int;
using pll = pair<lli, lli>;
using tlll = tuple<lli, lli, lli>;
using vll = vector<lli>;

lli mod197 = 1000000007LL;
lli INF = 10000000000000;

// ax + by = gcd(a,b) 最大公約数
template< typename T >
T extgcd(T a, T b, T& x, T& y) {
	T d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1;
		y = 0;
	}
	return d;
}

int A[15][15] = {};

int main(void) {

	int N;
	cin >> N;

	for (int i = 0; i < N; i++) {
		int a;
		cin >> a;
		for (int j = 0; j < a; j++) {
			int x, y;
			cin >> x >> y;
			x--;
			//1 == unkind , 2 == honesty
			A[i][x] = y + 1;
		}
	}

	int ans = 0;
	for (int i = 0; i <= (1 << N); i++) {
		int count = 0;
		bool flag = true;
		for (int j = 0; j < N; j++) {
			int t = (i >> j) & 1;
			if (t == 0) {
				continue;
			}
			count++;
			//t == 1 , honesty
			for (int k = 0; k < N; k++) {
				if (A[j][k] == 1) {
					if (((i >> k) & 1) == 0) {

					}
					else {
						flag = false;
					}
				}
				else if(A[j][k] == 2){
					if (((i >> k) & 1) == 1) {

					}
					else {
						flag = false;
					}
				}
			}
		}
		if (flag) {
			CHMAX(ans, count);
		}
	}

	COUT(ans);


	return 0;
}


Measured memory_bytes: 256
class SegmentTreeDual():
    def __init__(self, n, op, id, commutative=False):
        self.n = n
        self.op = op
        self.id = id
        self.commutative = commutative
        self.log = (n - 1).bit_length()
        self.size = 1 << self.log
        self.d = [id] * self.size
        self.lz = [id] * (2 * self.size)

    def build(self, arr):
        for i, a in enumerate(arr):
            self.d[i] = a

    def propagate(self, k):
        if self.lz[k] == self.id: return
        if k < self.size:
            self.lz[2 * k] = self.op(self.lz[k], self.lz[2 * k], )
            self.lz[2 * k + 1] = self.op(self.lz[k], self.lz[2 * k + 1])
        else:
            self.d[k - self.size] = self.op(self.lz[k], self.d[k - self.size])
        self.lz[k] = self.id

    def get(self, p):
        res = self.d[p]
        p += self.size
        for i in range(self.log):
            res = self.op(self.lz[p >> i], res)
        return res

    def range_apply(self, l, r, f):
        if l == r: return
        l += self.size
        r += self.size
        if not self.commutative:
            for i in range(self.log)[::-1]:
                self.propagate(l >> i)
                self.propagate(r >> i)
        while l < r:
            if l & 1:
                self.lz[l] = self.op(f, self.lz[l])
                l += 1
            if r & 1:
                r -= 1
                self.lz[r] = self.op(f, self.lz[r])
            l >>= 1
            r >>= 1

import sys
input = sys.stdin.buffer.readline

N, Q = map(int, input().split())

stx = SegmentTreeDual(N, min, 10**18, False)
sty = SegmentTreeDual(N, min, 10**18, False)

x = [N - 1] * (N - 1) + [0]
y = [N - 1] * (N - 1) + [0]

stx.build(x)
sty.build(y)

res = (N - 2) * (N - 2)

for _ in range(Q):
    q, k = map(int, input().split())
    if q == 1:
        g = stx.get(k - 1)
        res -= g - 1
        sty.range_apply(1, g, k - 1)
    if q == 2:
        g = sty.get(k - 1)
        res -= g - 1
        stx.range_apply(1, g, k - 1)

print(res)

Measured memory_bytes: 94684
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    S = SS()
    len_S = len(S)

    ans = 0
    for i in range(2 ** (len(S) - 1)):
        tmp = S[0]
        for j in range(len_S - 1):
            if i >> j & 1:
                ans += int(tmp)
                tmp = S[j+1]
            else:
                tmp += S[j+1]
        ans += int(tmp)

    print(ans)

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 10136
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int a = scanner.nextInt();
		String op = scanner.next();
		int b = scanner.nextInt();
		if(op.equals("+")){
			System.out.println(a+b);
		}else{
			System.out.println(a-b);
		}
	}

}


Measured memory_bytes: 22868
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define vl vaector<long>
#define vll vector<long long int>
#define vC  vector<char>
#define FastIO ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define db(...) ZZ(#__VA_ARGS__, __VA_ARGS__)
ll pow(ll x, ll y,ll m) { ll res = 1;x=x%m; while (y > 0) { if (y & 1) res = ((res%m) * (x%m))%m; y = y >> 1; x = ((x%m) * (x%m))%m; } return res%m; }
template <typename Arg1> void ZZ(const char* name, Arg1&& arg1){std::cerr << name << " = " << arg1 << endl;}
template <typename Arg1, typename... Args>void ZZ(const char* names, Arg1&& arg1, Args&&... args)
{
    const char* comma = strchr(names + 1, ',');
    std::cerr.write(names, comma - names) << " = " << arg1;
    ZZ(comma, args...);
}
const ll INF = 0xFFFFFFFFFFFFFFFL;
int clz(unsigned long long N) { return N ? 64 - __builtin_clzll(N) : -INF;}//may not work for some compiler returns position of msb; 
clock_t time_p=clock();
void abhigyan10()
{time_p=clock()-time_p;cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";}
ll seed;
mt19937 rng(seed=chrono::steady_clock::now().time_since_epoch().count());
inline ll rnd(ll l=0,ll r=INF){return uniform_int_distribution<ll>(l,r)(rng);}
#define clrbuf cin.ignore(numeric_limits<streamsize>::max(),'\n');
#define preciset(x) cout<<setprecision(x)<<fixed;
const ll mod =1000000007;
ll modinv(ll x)
{
    return pow(x,mod-2,mod);
}
int main()
{
        FastIO
        int n,i,coins;
        cin>>n;
        double ph;
       
        double dp[n+1]={0};
        dp[0]=1;
        for(coins=0;coins<n;coins++)
        {
             cin>>ph;
            for(i=coins+1;i>=0;i--)
            {
                dp[i]= (i==0?0:dp[i-1]*ph) + dp[i]*(1-ph);
            }
        }
        double ans=0.0;
        for(i=n/2+1;i<=n;i++)
        {
            ans+=dp[i];
        }
        preciset(10)
        cout<<ans;
        return 0;
}

Measured memory_bytes: 3852
#include<bits/stdc++.h>
using namespace std;
int pali(int n)
{
    int x=n,rev=0,rem;
    while (n>0)
    {
        rem=n%10;
        rev= rev*10 + rem;
        n=n/10;
    }
    if (x==rev)
        return 1;
    else 
        return 0;
}
int main()
{
    int a,b,i,count=0;
    cin>>a>>b;
    for (i=a;i<=b;i++)
    {
        if (pali(i))
            count++;
    }
    cout<<count<<endl;
}

Measured memory_bytes: 384
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}



	public void run() {
		Scanner sc = new Scanner(System.in);
		int q=sc.nextInt();
		boolean p[]=new boolean[100000+1];
		for(int i=2; i<=100000; i++) p[i]=true;
		for(int i=2; i*i<=100000; i++) {
			if(p[i]) {
				for(int j=i+i; j<100000; j+=i) {
					p[j]=false;
				}
			}
		}
		int c[] = new int[100000+1];
		c[0]=c[1]=0;
		for(int i=2; i<=100000; i++) {
			if(p[i]&p[(i+1)/2]) {
				c[i]++;
			}
		}
		for(int i=0; i<100000; i++)c[i+1] +=c[i];
		for(int i=0; i<q; i++) {
			int l=sc.nextInt();
			int r=sc.nextInt();
			int cnt=0;
			int ans = c[r]-c[l-1];
			System.out.println(ans);
		}
		sc.close();
	}
}


Measured memory_bytes: 74980
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define PI acos(-1)
typedef  long long ll;
ll gcd(ll x,ll y){
   if(y==0) return x;
   else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
   return x/gcd(x,y)*y;
}

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

   vector<int> a(n);
   vector<int> c={0,0,0};

   rep(i,n){
      cin>>a[i];
      if(a[i]%4==0){
         c[2]++;
      }
      else if(a[i]%2==0){
         c[1]++;
      }
      else{
          c[0]++;
      }
   }

   if(c[1]==0){
      if(c[0]<=c[2]+1) cout<<"Yes";
      else cout<<"No";
   }
   else{
      if(c[0]<=c[2]) cout<<"Yes";
      else cout<<"No";
   }




   return 0;
}


Measured memory_bytes: 3780
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		
		int[] a = new int[n];
		int[] b = new int[n];
		int[] c = new int[n];
		
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
			b[i] = sc.nextInt();
			c[i] = sc.nextInt();
		}
		
		long[][] dp = new long[n][3]; // 0:a, 1:b, 2:c
		dp[0][0] = a[0];
		dp[0][1] = b[0];
		dp[0][2] = c[0];
		
		for (int i = 1; i < n; i++) {
			dp[i][0] = a[i] + Math.max(dp[i - 1][1], dp[i - 1][2]);
			dp[i][1] = b[i] + Math.max(dp[i - 1][2], dp[i - 1][0]);
			dp[i][2] = c[i] + Math.max(dp[i - 1][0], dp[i - 1][1]);
		}
		
		long max = 0;
		for (int i = 0; i < 3; i++)
			max = Math.max(max, dp[n - 1][i]);
		
		System.out.println(max);
		
		sc.close();
	}
}



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


int main(){
  int64_t N,K,S;
  cin >> N >> K >> S;
  for(int64_t i=0;i<K;i++){
    cout << S << " ";
  }
  for(int64_t i=K;i<N;i++){
    if(S==1000000000){
      cout << S-1 << " ";
    }else{
      cout << S+1 << " ";
    }
    
  }
  cout << endl;
}


Measured memory_bytes: 1280
#include<bits/stdc++.h>    
using namespace std;
#define ll long long 
#define pi pair<ll,ll>
#define pd pair<ld,ld>
#define pb push_back
#define inf 1e16
#define mod 998244353
#define en '\n'
#define ld long double
#define ff first
#define ss second
#define ull unsigned long long 
#define fr(a,b,c) for(int a = b ; a <= c ; a ++ )
const ll MAXN = 200010;
ll pw(ll b, ll r, ll md){
	ll ans = 1;
	while(r){
		if(r&1)ans = (ans*b)%md;
		b = (b*b)%md;
		r>>=1;
	}
	return ans;
}
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	ll n;cin>>n;
	string arr[n];fr(i,0,n-1)cin>>arr[i];
	sort(arr,arr+n);
	ll counter = 0 ;
	ll ans = 1 ;
	string val = arr[0];
	fr(i,0,n-1){
		if(val==arr[i])counter++;
		else {
			ans++;
			val =  arr[i];
			counter=1;
		}
	}
	cout<<ans<<en;
	return 0 ; 
}

Measured memory_bytes: 9900
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
using P = pair<int, int>;
long mod = (long) 1e9 + 7;

int main(){
    
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    
    if((a-1)/d < (c-1)/b){
        cout << "No" << "\n";
    } else {
        cout << "Yes" << "\n";
    }
    
    return 0;
}


Measured memory_bytes: 3100
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <queue>
using namespace std;


const int N = 123;


int main() {
	int a[3];
	cin >> a[0] >> a[1] >> a[2];
	sort(a , a + 3);
	if(a[0] == a[1] && a[1] == a[2] && a[2] == a[0]) { puts("Yes");}
	else puts("No");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using itn = int;
using namespace std;
int GCD(int a, int b){
    return b ? GCD(b, a%b) : a;
}
int main(){
    int A,B;
    string S;
    bool ok=true;
    cin >> A >> B >> S;
    if(S.size()==A+B+1){
        if(S[A]=='-'){
            for(int i=0; i<S.size(); i++){
                if(i==A) continue;
                if(!(0<=S[i]-'0' && S[i]-'0'<=9)){
                    ok=false;
                    break; 
                }
            }
        }else{
            ok=false;
        }
    }else{
        ok=false;
    }
    if(ok) puts("Yes");
    else puts("No");
    return 0;
}

Measured memory_bytes: 256
nl = lambda: list(map(int, input().split()))
sl = lambda: input().split()
n = lambda: int(input())
s = lambda: input()

N = n()
A = nl()

res = 1000000000
for a in A:
    count = 0
    while a % 2 == 0:
        a //= 2
        count += 1
    if count < res:
        res = count
print(res)


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

int main(){
	while(1){
		int n;
		cin>>n;
		if(n==0)break;
		int ans=0;
		int mini=1001;
		int maxi=0;
		for(int i = 0;i<n;i++){
			int a;
			cin>>a;
			ans+=a;
			mini=min(mini,a);
			maxi=max(maxi,a);
		}
		cout<<(ans-maxi-mini)/(n-2)<<endl;
	}
	return 0;
}

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

int main(){
    int n , q; cin >> n >> q;
    vector<queue<int>> a(n);
    rep(i , q){
        int s , t , value;
        cin >> s;
        if( s == 0 ){
            cin >> t >> value;
            a[t].push(value);
        } else if ( s == 1 ){
            cin >> t;
            if(a[t].empty()) continue;
            cout << a[t].front() << endl;
        } else {
            cin >> t;
            if(a[t].empty()) continue;
            a[t].pop();
        }
    }
}


Measured memory_bytes: 4220
#include <iostream>
#include <vector>
#include<list>
#include <algorithm>
#include <string>
#include <math.h>
#include<map>
#include <utility>

#include<queue>
using namespace std;
#define REP(i,k,n) for(int i=k;i<n;i++)
 
#define INF 1844674407370955161
typedef long long int ll;
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
#define MOD 1000000007


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

    if(N<10){
        cout << N << endl;
    }else if(N<100){
        cout << 9 << endl;
    }else if(N<1000){
        cout << 9 + N - 100 + 1 << endl;
    }
    else if (N < 10000)
    {
        cout << 9 + 900 << endl;
    }
    else if(N<100000)
    {
        cout << 9 + 900 + N - 10000 + 1 << endl;
    }
    else
    {
        cout << 9 + 900 + 90000 << endl;
    }
    return 0;
}

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

int main() {
char c;
cin >> c;
if(c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u') cout << "vowel" << endl;
else cout << "consonant" << endl;
 }

Measured memory_bytes: 3584
#include<cstdio>
#include<cctype>
#include<cstring>
#include<cstdlib>
#include<iostream>
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define reg register
typedef long long ll;
using namespace std;
inline int read(){
	int x=0,f=1;char c=getchar();
	for(;c<'0'||c>'9';f=c=='-'?-1:1,c=getchar());
	for(;c>='0'&&c<='9';x=(x<<3)+(x<<1)+c-'0',c=getchar());
	return x*f;
}
const int inf=0x3f3f3f3f;
const int MN=1e5+5;
struct edge{int t,nxt;}es[MN<<1]; 
int h[MN],cnt;
inline void ins(int s,int t){
	es[++cnt]=(edge){t,h[s]};h[s]=cnt;es[++cnt]=(edge){s,h[t]};h[t]=cnt;
}
int n,m,l[MN],r[MN],f=1,v[MN];
bool vis[MN];
inline void dfs(int st,int fa){
	for(reg int i=h[st];i&&f;i=es[i].nxt){
		reg int t=es[i].t;if(t==fa)continue;
		dfs(t,st);if(r[t]==inf)continue;
		l[t]--;r[t]++;
		if(r[st]==inf){r[st]=r[t];l[st]=l[t];continue;}
		if((r[st]&1)^(r[t]&1)){f=0;continue;}
		l[st]=max(l[st],l[t]);r[st]=min(r[st],r[t]);
	}
	if(l[st]>r[st])f=0;
}
inline void dfs2(int st,int fa){
	if(!vis[st]){
		vis[st]=1;
    	if(l[st]<=v[fa]+1&&v[fa]<r[st])v[st]=v[fa]+1;
    	else v[st]=v[fa]-1;
	}
    for(reg int i=h[st];i;i=es[i].nxt)if(es[i].t!=fa)dfs2(es[i].t,st);
}
int main(){
	n=read();for(reg int i=1;i<n;i++)ins(read(),read());
	memset(l,~0x3f,sizeof(l));memset(r,0x3f,sizeof(r));
	m=read();for(reg int i=1,x;i<=m;i++)x=read(),l[x]=r[x]=v[x]=read();
	dfs(1,0);puts(f?"Yes":"No");if(!f)return 0;if(!vis[1])v[1]=l[1],vis[1]=1;
	dfs2(1,0);for(reg int i=1;i<=n;i++)printf("%d\n",v[i]);
	return 0;
}

Measured memory_bytes: 6528
#include<stdio.h>
#include<stdlib.h>
#include<stdint.h>
#include<inttypes.h>

typedef int32_t i32;

#define ALLOC(size,type) ((type*)calloc((size),sizeof(type)))

i32 query (i32 v) {
  printf ("%" PRIi32 "\n", v);
  fflush (stdout);
  char s[5];
  scanf ("%s", s);
  if (s[0] == 'Y') return 2;
  return s[1] == 'e' ? 1 : 0;
}

void run (void) {
  i32 n, k;
  scanf ("%" SCNi32 "%" SCNi32, &n, &k);
  i32 *a = ALLOC (n * n, i32);
  i32 *b = ALLOC (n * n, i32);
  i32 len = 0;
  for (i32 i = 1; i <= n; i *= 2) {
    for (i32 j = i + 1; j <= n; ++j) {
      if ((j & i) == i) {
        a[len] = i;
        b[len] = j;
        len++;
      }
    }
  }
  printf ("%" PRIi32 "\n", len);
  for (i32 i = 0; i < len; ++i) {
    printf ("%" PRIi32 " %" PRIi32 "\n", a[i], b[i]);
  }
  fflush (stdout);
  while (k--) {
    i32 ans = 0;
    for (i32 i = 1; i <= n; i *= 2) {
      i32 res = query (i);
      if (res == 2) {
        break;
      }
      if (res == 1) {
        ans |= i;
      }
    }
    if (ans > 0) {
      query (ans);
    }
  }
}

int main (void) {
  run();
  return 0;
}



Measured memory_bytes: 3332
#include <bits/stdc++.h>
#define rep(i, s, e) for(int i = s; i < e; i++)
#define rrep(i, s, e) for(int i = s; i > (s)-(e); i--)
#define pr(s) std::cout << s << std::endl
#define prb(s) std::cout << s
using namespace std;



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


  int a,b,c,d;
  cin >> a >> b >> c >> d;

  if (a*b > c*d) pr(a*b);
  else pr(c*d);


  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
string s;
cin>>s;
if(s=="ABC")
cout<<"ARC"<<endl;
else if(s=="ARC")
cout<<"ABC"<<endl;
    
    return 0;
    
}

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

int main(){
  int N;
  cin >> N;
  vector<int> p(N);
  for (int i = 0; i < N; i++) {
    cin >> p.at(i);
  }
  sort(p.begin(),p.end());
  p.at(N-1) /= 2;
  int sum=0;
  for (int i = 0; i < N; i++) {
    sum += p.at(i);
  }
  cout << sum << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <math.h>
using namespace std;
#define maxn 100005
int a[maxn];

int main()
{
	int n, x;
	cin >> n >> x;
	for (int i = 1; i <= n; i++){
		scanf("%d", &a[i]);
	}
	long long ans = 0;
	for (int i = 2; i <= n; i++){
		if (a[i] + a[i - 1] > x){
			ans += a[i] + a[i - 1] - x;
			if (x >= a[i-1])
				a[i] = x - a[i - 1];
			else{
				a[i] = 0;
			}
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace atcoder115_C
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] t_input = Console.ReadLine().Split().Select(i => int.Parse(i)).ToArray();
            int N = t_input[0];
            int K = t_input[1];
            int result = (int)Math.Pow(10,9);
            int[] high = new int[N];
            for (int i = 0; i < N; i++)
            {
                high[i] = int.Parse(Console.ReadLine());
            }
            Array.Sort(high);
            
            for(int i = 0;i<N-K+1;i++)
            {
                if (high[i + K-1] - high[i] < result) result = high[i + K-1] - high[i];

            }

            Console.WriteLine(result);
        }
    }
}


Measured memory_bytes: 15584
import math
import itertools
N = int(input())
X = []
Y = []
num = []
for i in range(N):
  x,y = map(int,input().split())
  X.append(x)
  Y.append(y)
  num.append(i)
p = itertools.permutations(num, N)
count_sum = 0
for i in p:
  count=0
  for j,k in enumerate(i):
    if j<N-1:
      count+=math.sqrt((X[k]-X[i[j+1]])**2+(Y[k]-Y[i[j+1]])**2)
  count_sum+=count
      
print(count_sum/math.factorial(N)) 


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

typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1e9+7;
#define rep(i,N) for(ll i=0; i<(N); i++)
#define rep1(i,N) for(ll i=1; i<(N); i++)
#define pb push_back

ll A,B,C;
ll X,Y;
ll ans=mod;

int main(){

cin.tie(0);
ios::sync_with_stdio(false);

cin>>A>>B>>C>>X>>Y;

rep(x,X+1){
	ll costA=A*x+2*C*(X-x);
	ll costB;
	if(X-x>=Y){
		costB=0;
	}else{
		costB=(Y-(X-x))*min(B,2*C);
	}
	ans=min(ans,costA+costB);
}

cout<<ans<<endl;

}
	


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<atcoder/all>
using namespace std;
using namespace atcoder;
int main(){
  int n,m;
  cin>>n>>m;
  mf_graph<int> g(n*m+2);
  for(int i=0;i<n*m;i++){
    int y=i/m;
    int x=i%m;
    if((y+x)%2==0)
      g.add_edge(n*m,i,1);
    else
      g.add_edge(i,n*m+1,1);
  }
  vector<string> s(n);
  for(int i=0;i<n;i++)
    cin>>s.at(i);
  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
      if((i+j)%2==1||s.at(i).at(j)=='#')
        continue;
      if(i+1<n&&s.at(i+1).at(j)=='.')
        g.add_edge(i*m+j,(i+1)*m+j,1);
      if(j+1<m&&s.at(i).at(j+1)=='.')
        g.add_edge(i*m+j,i*m+j+1,1);
      if(i-1>=0&&s.at(i-1).at(j)=='.')
        g.add_edge(i*m+j,(i-1)*m+j,1);
      if(j-1>=0&&s.at(i).at(j-1)=='.')
        g.add_edge(i*m+j,i*m+j-1,1);
    }
  }
  cout<<g.flow(n*m,n*m+1)<<endl;
  auto e=g.edges();
  for(int i=0;i<e.size();i++){
    if(e.at(i).from==n*m||e.at(i).to==n*m+1||e.at(i).flow==0)
      continue;
    int x=min(e.at(i).from,e.at(i).to);
    int y=max(e.at(i).from,e.at(i).to);
    if(y-x==1){
      s.at(x/m).at(x%m)='>';
      s.at(y/m).at(y%m)='<';
    }
    if(y-x==m){
      s.at(x/m).at(x%m)='v';
      s.at(y/m).at(y%m)='^';
    }
  }
  for(int i=0;i<n;i++)
    cout<<s.at(i)<<endl;
}

Measured memory_bytes: 5608
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n) ;i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
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 main(int argc, char const *argv[]) {
  int n;
  cin >> n;
  vector<double> v(n);
  rep(i,n) cin >> v[i];
  sort(all(v));
  //reverse(all(v));
  double ans=(v[0]+v[1])/2;
  for(int i=2; i<n; i++){
    ans=(ans+v[i])/2;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <numeric>
#include <queue>
#include <map> 
#include <set>
#include <string>
#include <functional>
#include <list>
#include <random>
#include <time.h>
#include <iomanip>
#define int long long
#define double long double
#define oku7 1000000007
#define MAXN (int)1e+5 * 2+1
#define LL_MAX 9223372036854775807	//ない環境用
#define LL_HALFMAX 9223372036854775807 / 2	//ない環境用
using namespace std;
std::mt19937 mt((int)time(0));

int dx[4] = { 0, 1, 0, -1 }; // x軸方向への変位
int dy[4] = { 1, 0, -1, 0 }; // y軸方向への変位

signed main() {
	int D, N;
	cin >> D >> N;
	int ans = 1;
	for (int i = 0; i < D; i++) {
		ans *= 100;
	}
	ans *= N;

	if (N == 100 && N != 2) {
		int mul = 1;
		for (int i = 0; i < D; i++) {
			mul *= 100;
		}
		ans += mul;
	}


	//int ans = 0;

	cout << ans << "\n";


	return 0;
}

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

using namespace std;
#define ll long long 
#define lf long double
#define F first
#define S second
#define pb push_back
typedef vector <ll> vi;
typedef vector <pair <ll,ll> > vii;

ll gcd(ll a,ll b)
{
	if(b==0)
		return a;
	return gcd(b,a%b);
}
int main() 
{
	ll T=1;
	while(T--)
	{
	ll a,b;
	cin>>a>>b;
	ll g=gcd(a,b);
	vi fac;
	ll p=g;
	//cout<<"g: "<<g<<endl;
	for(ll i=2;i*i<=g;i++)
	{
		if(p%i==0)
		{
			fac.pb(i);
			//ut<<"i: "<<i<<endl;
			while(p%i==0)
			{
				p/=i;
			}
		}
	}
	fac.pb(p);
	if(p!=1)
		fac.pb(1);
	//cout<<"p:"<<p<<endl;
	//cout<<"fac:\n";
	//for(auto i:fac)
		//cout<<i<<" ";
	//cout<<endl;
	cout<<fac.size()<<endl;
	}
	
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <list>
#include <algorithm>
#include <set>
#include <queue>

using namespace std;
#define ll long long

int main()
{
    //freopen("aa_input.txt", "r", stdin);
    int test=1;
    //cin>>test;

    while(test--){
        double w, h, x, y;
        cin>>w>>h>>x>>y;
        double ans1 =   (w*h)/2;
        if(x+x==w && y+y == h){
            //cout<<ans1<<" "<<1<<endl;
            printf("%lf 1", ans1);
            printf("\n");
        }
        else{
            //cout<<max(ans1,ans2)<<" "<<0<<endl;
            printf("%lf 0",ans1);
            printf("\n");
        }
    }
    return 0;
}
/*

riaadmorshed@gmail.com

*/

Measured memory_bytes: 256
Scanf.scanf "%d %d" (fun n k ->
    let a = Array.init n (fun _ -> Scanf.scanf " %d" (fun a -> a)) in
    Array.sort (fun a b -> compare (abs a) (abs b)) a;

    let z = 1_000_000_007 in

    let ( *@) a b = (((a * b) mod z) + z) mod z in

    let rec loop rest i m z p minm minp =
        if rest = 0 then m, z, p, minm, minp else
            let m = if a.(i) < 0 then m + 1 else m in
            let z = if a.(i) = 0 then z + 1 else z in
            let p = if a.(i) > 0 then p + 1 else p in
            loop (rest - 1) (i - 1) m z p (if a.(i) < 0 then i else minm) (if a.(i) > 0 then i else minp)
    in
    let m, z, p, minm, minp = loop k (n - 1) 0 0 0 n n in
    let prod f t =
        let rec loop i acc =
            if i > t then acc else loop (i + 1) (acc *@ a.(i))
        in
        loop f 1
    in
    let prod2 f t skip alter =
        let rec loop i acc =
            if i > t then acc else
                let acc = if i = skip then acc else acc *@ a.(i) in
                loop (i + 1) acc
        in
        loop f a.(alter)
    in
    Printf.printf "%d\n" @@ if z > 0 then 0 else ( (* z = 0 *)
        if k = n then prod 0 (n - 1) else
        if m mod 2 = 0 then prod (n - k) (n - 1) else ( (* z = 0 && m % 2 = 1 *)
            let rec loop i maxm maxp zero =
                if i = n - k then maxm, maxp, zero else
                    if a.(i) > 0 then loop (i + 1) maxm i zero else
                    if a.(i) < 0 then loop (i + 1) i maxp zero else
                                      loop (i + 1) maxm maxp true
            in
            let maxm, maxp, zero = loop 0 (-1) (-1) false in
            (* case:
                * p > 0 && m % 2 = 1:
                    * maxm >= 0 && maxp >= 0 -> compare prod / a.(minm) * a.(maxp)
                                                        prod / a.(minp) * a.(maxm)
                    * maxm >= 0 && maxp <  0 -> prod / a.(minp) * a.(maxm)
                    * maxm <  0 && maxp >= 0 -> prod / a.(minm) * a.(maxp)
                    * else -> 0
                * p = 0 && m % 2 = 1 && zero -> 0
                * p = 0 && m % 2 = 1 && !zero -> phase2
             *)
            if p > 0 then (
                if maxm >= 0 && maxp >= 0 then (
                    if a.(maxp) * a.(minp) > a.(maxm) * a.(minm) then prod2 (n - k) (n - 1) minm maxp
                                                                 else prod2 (n - k) (n - 1) minp maxm
                ) else
                if maxm >= 0 && maxp <  0 then prod2 (n - k) (n - 1) minp maxm else
                if maxm <  0 && maxp >= 0 then prod2 (n - k) (n - 1) minm maxp else 0
            ) else (
                if maxp >= 0 then prod2 (n - k) (n - 1) minm maxp else
                if zero then 0 else prod 0 (k - 1)
            )
        )
    )
)


Measured memory_bytes: 7584
import sys
import socket

hostnames = ['N551J', 'F551C', 'X553M']
input_file = 'b1.in'
if socket.gethostname() in hostnames:
    sys.stdin = open(input_file)


def read_int_list():
    return list(map(int, input().split()))


def read_int():
    return int(input())


def read_str_list():
    return input().split()


def read_str():
    return input()


def solve():
    n, m = read_int_list()
    a = read_int_list()
    res = n - sum(a)
    if res < 0:
        res = -1
    return res


def main():
    res = solve()
    print(res)


if __name__ == '__main__':
    main()


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

#define int long long

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

int H, W, h, w;
int ans_imos[501];

signed main() {
    cin >> H >> W >> h >> w;
    if (H % h == 0 && W % w == 0) {
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
    if (H % h != 0) {
        for (int i = 0; i <= H / h; i++) {
            ans_imos[i * h] = -i;
        }
        for (int i = 0; i <= H / h; i++) {
            for (int j = 0; j < h - 1 && i * h + j < H; j++) {
                ans_imos[1 + i * h + j] = H / h - i + 1;
            }
        }
        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                cout << ans_imos[i + 1] - ans_imos[i] << " ";
            }
            cout << endl;
        }
    } else {
        for (int i = 0; i <= W / w; i++) {
            ans_imos[i * w] = -i;
        }
        for (int i = 0; i <= W / w; i++) {
            for (int j = 0; j < w - 1 && i * w + j < W; j++) {
                ans_imos[1 + i * w + j] = W / w - i + 1;
            }
        }
        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                cout << ans_imos[j + 1] - ans_imos[j] << " ";
            }
            cout << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 1408
N = int(input())
s = []
for i in range(N):
    s.append(input())

M = int(input())
t = []
for i in range(M):
    t.append(input())

#print(s)
#print(t)
max_score = 0

for e in s:
    score = s.count(e) - t.count(e)
    if score > max_score:
        max_score = score

print(max_score)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int N;
float x,ans=0;
int main(){
  cin >> N;
  for(int i=0;i<N;i++){
    cin >> x;
    string s;
    cin >> s;
    if(s=="JPY");
    else x*=380000;
    ans+=x;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
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; }
//(a+b-1)/b
//priority_queue<ll, vector<ll>, greater<ll>> q;

signed main(){
	ll n,a,b; cin>>n>>a>>b;
	cout<<(n-a+1)*(n-b+1)<<endl;



	return 0;
}

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

const int MAX = 510000;
const int MOD = 998244353;
long long 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;
	}
}
// 二項係数計算
long long 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;
}


vector<ll> powm;

int main() {
	COMinit();
	ll n, m, k;
	cin >> n >> m >> k;
	powm.push_back(1);
	for (ll i = 1; i < n; ++i) {
		powm.push_back((powm[i - 1] * (m - 1)) % MOD);
	}
	ll ans = 0;
	for (ll i = 0; i <= k; ++i) {
		ans += (COM(n - 1, i) * powm[n - i - 1]) % MOD;
      ans %= MOD;
	}
	ans = (ans * m) % MOD;
	cout << ans << endl;
}


Measured memory_bytes: 17228
#include <iostream>
#include <math.h>
#include <cstdio>
#include <stdio.h>
#include <cmath>
using namespace std;
int main(){
	double x=0,y=0,c=0;
	int a,b;
	while(scanf("%d,%d",&a,&b) != EOF){
		if(a==0 && b==0) break;
		x += (double)a*(double)sin(c*6.0*asin(0.5)/180.0);
		y += (double)a*(double)cos(c*6.0*asin(0.5)/180.0);
		c += (double)b;
		if(c>(double)180){
			c -= (double)360;
		}
		if(c<(double)-180){
			c += (double)360;
		}
	}
	cout<<(int)x<<endl<<(int)y<<endl;
	return 0;
}

Measured memory_bytes: 1212
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int x,y;
    while(true){
    cin >> x;
    cin >> y;
        if(x == 0 && y == 0){
            break;
        }
        if(x < y){
            cout << x << " " << y << endl;
    }
    else{cout << y << " " << x << endl;
    }
    }
}


Measured memory_bytes: 3000
using System;
using System.Linq;
using System.Collections.Generic;
using System.Numerics;
using static System.Console;

class Solver {
    Scanner sc = new Scanner();

    public void Solve() {
        var A = sc.nextInt();
        var B = sc.nextInt();
        if (A*B % 2 == 1) {
            WriteLine("Yes");
        } else {
            WriteLine("No");
        }
    }
}



class Scanner {
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner() {
        s = new string[0];
        i = 0;
    }

    public string next() {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt() {

        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0) {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong() {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0) {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble() {
        return double.Parse(next());
    }

    public double[] ArrayDouble(int N, double add = 0) {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

class Program {
    static void Main(string[] args) {
        Solver s = new Solver();
        s.Solve();
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
#define all(x) (x).begin(),(x).end()
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define irp(i,s,e) for(int i=(s);i>(e);--i)

ll nCr(ll n, ll r){
	ll a = n, b = r;
	// for(ll i=0; i<r; ++i){
	while(r>1){
		a *= --n;
		b *= --r;
	}
	return a/b;
}

int N;
vi A;

ll solve(){

	map<ll,ll> a,b;
	rp(i, 1, N+1){
		a[i+A[i]]++;
		b[i-A[i]]++;
		// b[abs(i-A[i])]++;

		// cout<<" i "<<i;
		// cout<<" Ai "<<A[i];
		// cout<<" i+Ai "<<i+A[i];
		// cout<<" i-Ai "<<i-A[i];
		// // cout<<" abs(i-Ai) "<<abs(i-A[i]);
		// cout<<"\n";

	}

	// puts("---");
	// for(auto x:a){
	// 	cout<<" i+Ai "<<x.first;
	// 	cout<<" c "<<x.second;
	// 	cout<<"\n";
	// }

	// puts("---");
	// for(auto x:b){
	// 	cout<<" i-Ai "<<x.first;
	// 	cout<<" c "<<x.second;
	// 	cout<<"\n";
	// }
	// puts("---");

	ll ans = 0;
	for(auto ai:a){
		ll x = ai.second;
		ll y = b[ai.first];
		// if(n < r) swap(n, r);
		// if(r!=0){
			ans += x*y;
		// }
	}

	return ans;
}

int main(){
	cin>>N;
	A.resize(N+1);
	rp(i, 1, N+1) cin>>A[i];
	cout<< solve() <<endl;
}


Measured memory_bytes: 38300
#include <stdio.h>

int main(void) 
{
	int num;
	int i;
	int j;
	int cards[4][13];
	char a;
	int b;
	
	for(i = 0; i < 4; i++)
	{
		for(j = 0; j < 13; j++)
		{
			cards[i][j] = 0;
		}
	}
	
	scanf("%d", &num);
	for(i = 0; i < num * 2; i++)
	{
		a = '\0';
		b = 0;
		scanf("%c %d", &a, &b);
		
		if(a == 'S')
		{
			cards[0][b - 1] = 1;
		}
		if(a == 'H')
		{
			cards[1][b - 1] = 1;
		}
		if(a == 'C')
		{
			cards[2][b - 1] = 1;
		}
		if(a == 'D')
		{
			cards[3][b - 1] = 1;
		}
//		printf("[%c][%d]?????\???\n", a, b);
	}
	
	for(i = 0; i < 4; i++)
	{
		for(j = 0; j < 13; j++)
		{
			if(cards[i][j] == 0)
			{
				if(i == 0)
				{
					printf("S %d\n", j + 1);
				}
				if(i == 1)
				{
					printf("H %d\n", j + 1);
				}
				if(i == 2)
				{
					printf("C %d\n", j + 1);
				}
				if(i == 3)
				{
					printf("D %d\n", j + 1);
				}
			}
		}
	}
	return 0;
}

Measured memory_bytes: 596
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace abc117_b
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = Convert.ToInt32(Console.ReadLine());
            string[] input = Console.ReadLine().Split(' ');
            int[] num = new int[N];
            for (int i = 0; i < N; i++)
            {
                num[i] = Convert.ToInt32(input[i]);
            }

            Array.Sort(num);
            int sum = 0;
            for (int i = 0; i < N - 1; i++)
            {
                sum += num[i];
            }
            if (num[N - 1] < sum)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}


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

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

template<class T> istream& operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; }

class Solver {
  public:
    bool solve() {
        auto fail = [] () { cout << "No" << endl; exit(0); };

        int N; cin >> N;
        vector<int> P(N); cin >> P;
        rep(i, N) P[i]--;

        {
            int i = 0;
            for(; i < N; i++) {
                if(P[i] != i) {
                    int start = i;
                    if(i + 1 >= N or P[i + 1] != i + 1) fail();
                    vector<int> left, right;
                    while(i < N) {
                        (P[i] < i ? left : right).push_back(P[i]);
                        if(i + 1 >= N or P[i + 1] != i + 1) break;
                        i += 2;
                    }
                    bool ok = true;
                    rep(j, left.size() - 1) ok &= left[j] < left[j + 1];
                    rep(j, right.size() - 1) ok &= right[j] < right[j + 1];
                    if(not ok) fail();
                    int end = min(N, i + 1);
                    if(*min_element(begin(P) + start, begin(P) + end) < start) fail();
                    if(*max_element(begin(P) + start, begin(P) + end) >= end) fail();
                }
            }
        }

        cout << "Yes" << endl;

        return 0;
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    Solver s;
    s.solve();
    return 0;
}


Measured memory_bytes: 2748
import queue

n,m = map(int, input().split())
routs = [[] for i in range(n + 1)]
for i in range(m):
    a, b = map(int,input().split())
    routs[a].append(b)
    routs[b].append(a)

parent = [-1] * (n-1)
visit = ["yet"]*(n)
visit[0] = "done"
q = queue.Queue()
q.put(1)
while not q.empty():
    temp = q.get()
    for i in routs[temp]:
        if visit[i-1] == "yet":
            q.put(i)
            if parent[i-2] == -1:
                parent[i-2] = temp
            visit[i-1] = "done"

print("Yes")
for i in parent:
    print(i)    
    

Measured memory_bytes: 35000
#include<iostream>
#include<algorithm>
#include<math.h>
#include<vector>
#include<map>
#include<set>
#include<iomanip>

using namespace std;
using ll = long long;

const int MOD = 1e9 + 7;
const int INF = numeric_limits<int>::max();
const ll LLINF = numeric_limits<ll>::max();
const double PI = acos(-1.0);

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

int main() {
    int X, Y; cin >> X >> Y;

    cout << X + Y / 2 << endl;
    return 0;
}


Measured memory_bytes: 256