akhauriyash/Code-Regression huggingface dataset:
{-# OPTIONS_GHC -O2 #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE BangPatterns #-}
module Main where

import Control.Arrow
import Control.Monad
import Control.Monad.ST
import Control.Monad.State.Strict
import Data.Char
import Data.Function
import Data.Graph
import Data.List
import Data.Maybe
import qualified Data.Vector as V
import qualified Data.Vector.Mutable as VM
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector.Unboxed.Mutable as UM
import qualified Data.ByteString.Char8 as C
import qualified Data.ByteString.Unsafe as B
import qualified Data.ByteString.Builder as BSB
import System.IO (stdout)

type Parser a = C.ByteString -> Maybe (a, C.ByteString)

parseInt :: Parser Int
parseInt = C.readInt . C.dropWhile isSpace

parseInt2 :: Parser (Int, Int)
parseInt2 = runStateT $
    (,) <$> StateT (C.readInt . C.dropWhile isSpace)
        <*> StateT (C.readInt . B.unsafeTail)
 
parseInt3 :: Parser (Int, Int, Int)
parseInt3 = runStateT $
    (,,) <$> StateT (C.readInt . C.dropWhile isSpace)
        <*> StateT (C.readInt . B.unsafeTail)
        <*> StateT (C.readInt . B.unsafeTail)
 
parseInt4 :: Parser (Int, Int, Int, Int)
parseInt4 = runStateT $
    (,,,) <$> StateT (C.readInt . C.dropWhile isSpace)
        <*> StateT (C.readInt . B.unsafeTail)
        <*> StateT (C.readInt . B.unsafeTail)
        <*> StateT (C.readInt . B.unsafeTail)

-- prime means pred
parseInt' :: Parser Int
parseInt' = fmap (pred *** id) . parseInt

getInts :: IO [Int]
getInts = unfoldr parseInt <$> C.getLine

-- prime means pred
getInts' :: IO [Int]
getInts' = unfoldr parseInt' <$> C.getLine

getIntTuple :: IO (Int, Int)
getIntTuple = do
  a:b:_ <- getInts
  return (a, b)

-- prime means pred
getIntTuple' :: IO (Int, Int)
getIntTuple' = do
  a:b:_ <- getInts'
  return (a, b)

getIntTuple3 :: IO (Int, Int, Int)
getIntTuple3 = do
  a:b:c:_ <- getInts
  return (a, b, c)

getIntTuple4 :: IO (Int, Int, Int, Int)
getIntTuple4 = do
  a:b:c:d:_ <- getInts
  return (a, b, c, d)

getIntVec :: Int -> IO (U.Vector Int)
getIntVec n = U.unfoldrN n parseInt <$> C.getLine

-- prime means pred
getIntVec' :: Int -> IO (U.Vector Int)
getIntVec' n = U.unfoldrN n parseInt' <$> C.getLine

---------------------------------------------------------

wins :: Int -> U.Vector Int -> U.Vector Int
wins n is = U.create $ do
  ws <- UM.replicate n 0
  U.forM_ is $ \i -> do
    UM.modify ws (+1) i
  return ws

pr :: Int -> U.Vector Int -> IO ()
pr k ws = do
  U.forM_ ws $ \w -> do
    putStrLn $ if w > k then "Yes" else "No"

main :: IO ()
main = do
  (n,k,q) <- getIntTuple3 :: IO (Int, Int, Int)
  as <- U.replicateM q (fmap pred (readLn :: IO Int))
  let ws = wins n as
  -- print ws
  pr (q - k) ws


Measured memory_bytes: 3068
#include<iostream>
#include<math.h>
using namespace std;

int main(){
    int N, D;
    int count = 0;
    cin >> N >> D;
    int X[N], Y[N];

    for (int i = 0; i < N; i++) {
        cin >> X[i] >> Y[i];
    }

    for (int i = 0; i < N; i++) {
        if (pow(pow(X[i], 2.0) + pow(Y[i], 2.0), 0.5) <= D){
            count++;
        }
    }

    cout << count << endl;

}

Measured memory_bytes: 5684
#include "bits/stdc++.h"

using namespace std;
using ll = long long int;
using ullong = unsigned long long;
#define rep(i,n) for(int i = 0; i < n; i++)
#define FOR(i, a, b)  for(int i = (a); i < (b) ; i++)
#define pb push_back
#define SORT(v,n) sort(v, v+n)
#define ALL(x) (x).begin(),(x).end()
#define debug(x) cerr << #x << ": " << x << '\n'
#define int ll
int INF = 1e9;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
typedef pair<int, int> Vec2;
const int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
const int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };

signed main() {
	ios::sync_with_stdio(false);
	int n, m;
	cin >> n >> m;
	int ans = 0;
	vector<Vec2> ba(m);
	rep(i, m) {
		int a, b;
		cin >> a >> b;
		ba[i] = { b,a };
	}
	sort(ALL(ba));
	int cut = 0;
	rep(i, m) {
		if (ba[i].second <= cut) continue;
		cut = ba[i].first - 1;
		ans++;
	}

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


Measured memory_bytes: 1792
import java.util.*;

public class Main{

    public static void main(String args[]){

        Scanner sc = new Scanner(System.in);
        String str = "";

        str = sc.next();

        if (Character.isUpperCase( str.charAt( 0 ))){
            System.out.println('A');
        }else{
            System.out.println('a');
        }
    }
}



Measured memory_bytes: 35640
{-# LANGUAGE OverloadedStrings #-}
import qualified Data.Text as T
import qualified Data.Text.IO as T

replaceAP :: T.Text -> T.Text
replaceAP = (T.replace "xxxxx" "peach") . (T.replace "peach" "apple") . (T.replace "apple" "xxxxx")

main :: IO ()
main = T.putStrLn . replaceAP =<< T.getLine

Measured memory_bytes: 4012
#include<stdio.h>
#include<math.h>
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<complex>

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

using namespace std;

vector<int> box(3);
const int bign = 1000000000;
int counter;

int main(){
  int a,b,c,n;
  cin >> box[0] >> box[1] >> box[2] >> n;
  sort(box.begin(),box.end(),greater<int>());
  for(int i = 0; i < 3005; i++){
    for(int j = 0; j < 3005; j++){
      if(i*box[0]+j*box[1] > n){continue;}
      if((n-(i*box[0]+j*box[1])) % box[2] == 0){counter++;}
    }
  }

  cout << counter << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)

typedef int long long ll;
using namespace std;
typedef pair<int,int> P;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll MOD=1e9+7;
static const int MAX = 100;
static const int INF = (1<<23);
template<class T> T gcd(T a, T b){return b? gcd(b,a%b) : a;}
template<class T> T lcm(T a,T b){return a / gcd(a,b)*b;}

int main(){
    int n;
    cin>>n;
    vector<int> v(n);
    rep(i,n){

        cin>>v[i];
    }
    int mi = v[0];
    int ans = 1;
    for(int i=1;i<n;i++){
        if(mi>v[i]){
            mi=v[i];
            ans++;
        }
    }
    cout<<ans<<endl;


    
return 0;
}


Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int W, H, x, y, r;

bool check_right()
{
    return (x + r) <= W;
}

bool check_left()
{
    return 0 <= (x - r);
}

bool check_upper()
{
    return (y + r) <= H;
}

bool check_lower()
{
    return 0 <= (y - r);
}

int main()
{
    cin >> W >> H >> x >> y >> r;

    cout << ((check_right() && check_left() && check_upper() && check_lower()) ?
            "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    string s;
    cin >> s;
    set<char> se;
    rep(i, s.size())se.insert(s[i]);
    bool val = true;
    if((se.find('N')==se.end()) != (se.find('S')==se.end()))val = false;
    if((se.find('E')==se.end()) != (se.find('W')==se.end()))val = false;
    if(val)cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3580
main = do
  [n,y] <- map read . words <$> getLine
  putStrLn $ unwords . map show $ head ([[a,b,c] |a <- [0..n],b<- [0..n-a],let c =(n-a-b), c >= 0 && 10000*a + 5000*b + 1000*c == y] ++ [[-1,-1,-1]])

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

int main() {
  string S;
  cin >> S;
  if (S.at(1) == 'B') {
    cout << "ARC" << endl;
  }
  if (S.at(1) == 'R') {
    cout << "ABC" << endl;
  }
}

Measured memory_bytes: 3624
def main():
    n,k,*a=map(int,open(0).read().split())
    a,f=sorted(a[:n]),sorted(a[n:],reverse=1)
    ok=10**12
    ng=-1
    while ok-ng>1:
        mid=(ok+ng)//2
        l=k
        for b,g in zip(a,f):
            t=b-mid//g
            if t>0:l-=t
        if l<0:ng=mid
        else:ok=mid
    print(ok)
main()

Measured memory_bytes: 49540
#include<bits/stdc++.h>
using namespace std;
const int N=8e5+50,mod=924844033,G=5,Gi=554906420;
int n,ver[N*2],nxt[N*2],head[N],tot,sz[N],b[N],a[N],J[N],I[N],lim=1,lo=-1,r[N];
void add(int x,int y){ver[++tot]=y;nxt[tot]=head[x];head[x]=tot;}
void dfs(int x,int ff){
    sz[x]=1;
    for(int i=head[x],y;i;i=nxt[i])
        if((y=ver[i])!=ff)dfs(y,x),sz[x]+=sz[y],b[sz[y]]++;
    b[n-sz[x]]++;
}
int power(int x,int y){
    int z=1;
    for(;y;y>>=1,x=1ll*x*x%mod)if(y&1)z=1ll*z*x%mod;
    return z;
}
void NTT(int *a,int op){
    for(int i=0;i<lim;i++)if(i<r[i])swap(a[i],a[r[i]]);
    for(int i=1;i<lim;i<<=1)
        for(int t=i<<1,j=0,Wn=power(op>0?G:Gi,(mod-1)/t);j<lim;j+=t)
            for(int k=0,w=1;k<i;k++,w=1ll*w*Wn%mod){
                int x=a[j+k],y=1ll*a[i+j+k]*w%mod;
                a[j+k]=(x+y)%mod;a[i+j+k]=(x-y)%mod;
            }
    if(op<0)for(int i=0,inv=power(lim,mod-2);i<lim;i++)a[i]=1ll*a[i]*inv%mod;
}
int C(int n,int m){return 1ll*J[n]*I[m]%mod*I[n-m]%mod;}
int main(){
    scanf("%d",&n);J[0]=I[0]=I[1]=1;
    for(int i=2;i<=n;i++)I[i]=mod-1ll*mod/i*I[mod%i]%mod;
    for(int i=1;i<=n;i++)J[i]=1ll*J[i-1]*i%mod,I[i]=1ll*I[i-1]*I[i]%mod;
    for(int i=1,x,y;i<n;i++){
        scanf("%d%d",&x,&y);
        add(x,y);add(y,x);
    }
    dfs(1,0);
    for(int i=1;i<=n;i++)a[i]=I[n-i],b[i]=1ll*b[i]*J[i]%mod;
    
    while(lim<=2*n)lim<<=1,lo++;
    for(int i=1;i<lim;i++)r[i]=r[i>>1]>>1^(i&1)<<lo;
    NTT(a,1);NTT(b,1);
    for(int i=0;i<lim;i++)a[i]=1ll*a[i]*b[i]%mod;
    NTT(a,-1);
    for(int i=1;i<=n;i++)printf("%d\n",((1ll*n*C(n,i)-1ll*a[i+n]*I[i])%mod+mod)%mod);
    return 0;
}

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

int main() {
  int a,b;
  cin >>a>>b;
  int saidai;
  saidai = a+b;
  saidai = max(saidai,a-b);
  saidai = max(saidai,a*b);
  
  cout << saidai << endl;

}


Measured memory_bytes: 256
na, nb, m = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
min_a = min_b = 10**9
for i in range(na):
    min_a = min(min_a, a[i])
for i in range(nb):
    min_b = min(min_b, b[i])
ans = min_a + min_b
for i in range(m):
    x, y, c = map(int, input().split())
    x -= 1
    y -= 1
    ans = min(ans, a[x] + b[y] - c)
print(ans)


Measured memory_bytes: 97384
function Main(input) {
    //xは縦芳香、ｙは横方向で8芳香の動き方
    var dx = [1,1,0,-1,-1,-1,0,1];
    var dy = [0,1,1,1,0,-1,-1,-1];
    
    var input = input.split('\n');
    var hw = input[0].split(' ').map(n => parseInt(n, 10));
    var h = hw[0];
    var w = hw[1];
    //二重配列にして升目作る,arr[i行][j列]で各マスをとってこれるようになる
    var board = [];
    for(i = 1; i <= h; i++) board.push(input[i].split(''));
    //爆弾を除いた全てのマスから8芳香探索して爆弾の数を数えてその数をマスに入れる
    for(i = 0; i < h; i++) {
        for(j = 0; j < w; j++) {　//まず全てのマスを参照するfor文を回す
            if(board[i][j] == '#') continue;　//爆弾を除く
            var cnt = 0;
            //八芳香を見ていく。マス(i,j)からk番目の方向に進む先は
            //(i+dx[k], j+dy[k])となる(0<= k < 8)
            for(k = 0; k < 8; k++) {
                x = i + dx[k];
                y = j + dy[k];
                //(x,y)が枠外に行かないかつ爆弾である時にカウントする
                if(x >= 0 && x < h && y >= 0 && y < w && board[x][y] == '#') cnt++;
            }
            //8芳香のカウントが終わった後マスにその数字をを入れる
            board[i][j] = cnt;
        }
    }
    //boardをは二重の配列になってるのでboardでコンソールすると配列で出力されるし、多段にならない。
    //board[i行]の要素をjoinしてboard[i行]をループ出力すると文字列かつ多段に出力される。
    for(i = 0; i < h; i++) console.log(board[i].join(''))
}

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

Measured memory_bytes: 20552
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws Exception {
	    String str = Io.read();

	    Solver solver = new Solver(str);

	    int answer = solver.solve();

	    Io.write(answer);
    }
}

class Solver {

    private String line;

    private String answer = "";

    public Solver(String line) {
        this.line = line;
    }

    public int solve() {
        StringBuilder builder = new StringBuilder();

        for (int i = 0; i < line.length(); i++) {
            if (isACGT(line.charAt(i))) {
                builder.append(line.charAt(i));
            } else {
                String tmp = builder.toString();

                if (answer.length() < tmp.length()) {
                    answer = tmp;
                }
                builder.setLength(0);
            }
        }
        String tmp = builder.toString();

        if (answer.length() < tmp.length()) {
            answer = tmp;
        }

        return answer.length();
    }

    private boolean isACGT(char c) {
        switch(c) {
            case 'A':
                return true;

            case 'C':
                return true;

            case 'G':
                return true;

            case 'T':
                return true;

            default:
                return false;
        }
    }
}

class Io {

    /**
     * 標準入力から1行ずつ受け取る
     * @return
     * @throws IOException
     */
    public static String read() throws IOException
    {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line = br.readLine();

        br.close();
        return line;
    }

    /**
     * 標準出力
     * @param answer
     */
    public static void write(int answer)
    {
        System.out.println(answer);
    }
}

Measured memory_bytes: 22996
def main():
    n,k=map(int,input().split())
    v=list(map(int,input().split()))
    ans=0
    for a in range(min(n,k)+1):
        for b in range(min(n,k)-a+1):
            chk=v[:a]+v[n-b:]
            chk.sort()
            x,s=0,sum(chk)
            while x<k-(a+b) and len(chk)>x:
                s-=min(0,chk[x])
                x+=1
            ans=max(ans,s)
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 40304
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <chrono>
#include <random>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <iomanip>
#include<string>
using namespace std;
#define ll long long
typedef pair<ll , ll > pii;
ll mod=998244353;
ll p=1e9+7;

int  main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    ll n,a,b;
    cin>>n>>a>>b;
    if( (b-a) %2 == 0 ){
        cout<<(b-a)/2;
    }
    else{
        ll ans=min(a-1,n-b)+1+(b-a-1)/2;
        cout<<ans;
    }
    return 0;
}


Measured memory_bytes: 256
from collections import Counter
H, W, N = map(int, raw_input().split(' '))

T = Counter()

for _ in range(N):
    x, y = map(lambda _x: int(_x) - 1, raw_input().split(' '))
    T[(x, y + 1)] += 1
    T[(x, y)] += 1
    T[(x, y - 1)] += 1
    T[(x-1,y+1)] += 1
    T[(x-1,y)] += 1
    T[(x-1,y-1)] += 1
    T[(x + 1, y + 1)] += 1
    T[(x + 1, y)] += 1
    T[(x + 1, y - 1)] += 1

ans = [0] * 10
total_points = H * W - (2 * H) - (2 * (W-2))
positive_points = 0
for (x, y), c in T.iteritems():
    if 0 < x < H-1 and 0 < y < W-1:
        ans[c] += 1
        positive_points += 1
ans[0] = total_points - positive_points

for i in range(10):
    print ans[i]

Measured memory_bytes: 173908
def get_ints():
  return list(map(int, input().split()))

n, h = get_ints()
maxHit = 0
throw = []
for i in range(n):
  x, y = get_ints()
  maxHit = max(maxHit, x)
  throw.append(y)

throw.sort()
throw.reverse()
ans = 0
for d in throw:
  if h <= 0:
    print(ans)
    exit(0)
  if d <= maxHit:
    break
  h -= d
  ans += 1

print(ans + (h + maxHit - 1) // maxHit)



Measured memory_bytes: 58072
using System;
using System.Linq;
 

    class Program
    {
        static void Main(string[] args)
        {
 
		// 整数の入力
		var a = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
		var b = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
		long playingDay = a[0];
 
	    for (int i = 0; i < a[1]; i++)
        {
            playingDay -= b[i];
            if (playingDay < 0)
            {
                playingDay = 0L;
                playingDay = -1L;
                break;
            }
        }
		
		//出力
		Console.WriteLine(playingDay);
 
        }
    }

Measured memory_bytes: 28928
#include<bits/stdc++.h>
#include <cstring>
using namespace std;
#define ll  long long
#define endl '\n'
const ll mod = 1000000007;
const double PI = 3.141592653589793238463;
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int x;
    bool b=false;
    cin>>x;
    if (x>81)
        cout<<"No\n";
    else
    {
        for (int i=1;i<=9;i++){
            if (x%i==0)
            {
                if (x/i<10)
                {
                    b=true;
                    break;
                }
            }
        }
        if (b)
            cout<<"Yes\n";
        else
            cout<<"No\n";
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <math.h>
#include <map>
#include <time.h>

using namespace std;

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

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod (ll)(1e9+7)
#define int ll

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
  int n, ans = 0;
  cin >> n;

  rep(i, 1, min((int)100000, n)) {
    if(n / i == n % i) ans += i;
  }
  dep(i, n / 100000, 1) {
    if((n - i) % i == 0) {
      int k = (n - i) / i;
      if(n / k == n % k) ans += k;
    }
  }

  cout << ans << endl;
}


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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}


int main(void){
	int32 a, b;
	vector<int32> v();
	string s;
  	cin >> a >> b;
    cout << (a*b%2 ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
int mod;
int po(int a,int b){
    int res=1;
    while(b!=0){
        if(b&1){
            res*=a;
            res%=mod;
        }
        a*=a;
        a%=mod;
        b/=2;
    }
    return res;
}
int inv(int a){
    return po(a,mod-2);
}
bool p(int a){
  if(a<=1)
    return false;
  if(a==2)
    return true;
  if(a%2==0)
    return false;
  for(int i=3;i*i<=a;i+=2)
    if(a%i==0)
      return false;
  return true;
}
int32_t main(){
    int n;
    cin>>n;
  while(!p(n))
    n++;
  cout<<n;
    return 0;
}

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

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(a)-1;i>=b;i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(_v) for(auto _x:_v){cout<<_x<<" ";}cout<<endl
#define printVS(_vs) for(auto _x : _vs){cout << _x << endl;}
#define printVV(_vv) for(auto _v:_vv){for(auto _x:_v){cout<<_x<<" ";}cout<<endl;} cout << endl;
#define printP(_p) cout << _p.first << " " << _p.second << endl
#define printVP(_vp) for(auto _p : _vp) printP(_p);

typedef long long ll;
typedef pair<int, int> Pii;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<Pii> vp;
const int inf = 1e9;
const int mod = 1e9 + 7;

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

    string a, b, c;
    cin >> a >> b >> c;
    cout << a[0] << b[0] << c[0] << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MAXn = 50 + 10;
char ch[MAXn][MAXn];
int dx[4] = {0, 0, 1, -1}, dy[4] = {1, -1, 0, 0}, n, m;

bool isok(int x, int y) {
	return min(x, y) >= 0 && x < n && y < m;
}
int main() {
	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	cin >> n >> m;
	for (int i = 0; i < n; i++)
		for (int j = 0; j < m; j++)
			cin >> ch[i][j];
	for (int i = 0; i < n; i++)
		for (int j = 0; j < m; j++)
			if (ch[i][j] == '#') {
				bool flag = false;
				for (int x = 0; x < 4; x++)
					if (isok(i + dx[x], j + dy[x]) && ch[i+dx[x]][j+dy[x]] == '#')
						flag = true;
				if (!flag)
					return cout << "No",0;
			}
	cout << "Yes";
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**7)
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N, Q = map(int, readline().split())
G = [[] for _ in range(N+1)]
score = [0]*(N+1)
for i in range(N-1):
  x,y = map(int, readline().split())
  G[x].append(y)
  G[y].append(x)

for _ in range(Q):
  a,p = map(int, readline().split())
  score[a] += p
  
def dfs(a,b):
  score[a] += score[b]
  for x in G[a]:
    if x == b:
      continue
    dfs(x,a)
    
dfs(1,0)
print(*score[1:])

Measured memory_bytes: 230908
#include<cstdio>

using namespace std;

int main(){
  int a,b,c,f[101]={},cnt=0;
  scanf("%d %d %d",&a,&b,&c);
  f[a]=1;
  f[b]=1;
  f[c]=1;
  for(int i=0;i<=100;i++)
    cnt+=f[i];
  printf("%d\n",cnt);
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);

    if (sc.next().equals("H")) {
      if (sc.next().equals("H")) {
        System.out.println("H");
      } else {
        System.out.println("D");
      }
    } else {
      if (sc.next().equals("D")) {
        System.out.println("H");
      } else {
        System.out.println("D");
      }
    }

  }
}

Measured memory_bytes: 35468
from collections import Counter
import itertools
n = int(input())
ary = []
for i in range(n):
    s = input()[0]
    if s == "M" or s == "A" or s =="R" or s =="C" or s == "H":
        ary.append(s)
count = Counter(ary)
s = set(count.keys())
cnb = list(itertools.combinations(s,3))
ans = 0
for a,b,c in cnb:
    ans += count[a] * count[b] * count[c]
print(ans)

Measured memory_bytes: 4224
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;


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

    vector<int> l(n);
    for(int i = 0; i < n; i++) scanf("%d", &l[i]);

    sort(l.begin(), l.end());
    ll ans = 0;
    for (int i = 0; i < n - 2; i++) {
        for (int j = i + 1; j < n - 1; j++) {
            auto itr = lower_bound(l.begin(), l.end(), l[i] + l[j]);
            int neg = distance(itr, l.end());
            ans += n - 1 - j - neg;
        }
    }
    printf("%lld\n", ans);
}

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

int main() {
  string S;
  cin >> S;

  int ans = INT_MAX;
  for (int i = 0; i < S.size() - 2; i++) {
    int X = stoi(S.substr(i, 3));
    ans = min(ans, abs(X - 753));
  }

  printf("%d", ans);
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String... args) {
        Scanner sc = new Scanner(System.in);
        double r = sc.nextDouble();

        System.out.println(String.format("%.6f", r * r * Math.PI) + " " + String.format("%.6f", 2 * Math.PI * r));
    }
}


Measured memory_bytes: 28444
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
typedef pair<int, int> P;

const int INF = 100000000;
int n;
vector<vector<P> > V;
int d[100000];

void bfs(int s){
    queue< pair <int,int> > Q;
    for(int i = 0; i < n; i++){
        d[i] = INF;
    }
    
    d[s] = 0;
    int t, w;
    Q.push(make_pair(s, 0));
    while(!Q.empty()){
        t = Q.front().first;
        w = Q.front().second;
        Q.pop();
    
        for(int i = 0; i < V[t].size(); i++){
            if(d[V[t][i].first] == INF) {
                d[V[t][i].first] = w + V[t][i].second;
                Q.push(make_pair(V[t][i].first, d[V[t][i].first]));
            }
        }
    }
}

int main(void){
    // Your code here!
    cin >> n;
    int s, t, w;
    V.resize(n);
    for(int i = 0; i < n-1; i++){
        cin >> s >> t >> w;
        V[s].push_back(make_pair(t, w));
        V[t].push_back(make_pair(s, w));
    }
    
    bfs(0);
    int x = -1;
    int maxv = 0;
    for(int i = 0; i < n; i++){
        if(d[i]==INF) continue;
        if(maxv < d[i]){
            x = i;
            maxv = d[i];
        }
    }
    
    bfs(x);
    maxv = 0;
    for(int i = 0; i < n; i++){
        if(d[i]==INF) continue;
        if(maxv < d[i]){
            maxv = d[i];
        }
    }
    
    cout << maxv << endl;
}



Measured memory_bytes: 9936
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <climits>
#include <bitset>
#include <list>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main(){
    int n, a, b;
    cin >> n >> a >> b;
    cout << min(a,b) << " " << max(a+b-n,0) << endl;
    return 0;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
a = list(map(int, input().split()))

keta = 0
kc = k
while kc != 0:
    kc = kc//2
    keta += 1

i = keta-1
num = 0
res = 0

while i != -1:
    num *= 2
    count0 = 0
    count1 = 0
    for j in a:
        if j & pow(2, i) == 0:
            count0 += 1
        else:
            count1 += 1
    if count0 >= count1 and k >> i >= num+1:
        num += 1
    i -= 1
    
for i in a:
    res += num ^ i
    
print(res)

Measured memory_bytes: 14620
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
ll n,d[100][100],a[50],m;
void init()
{
	for(ll i=0;i<=n;i++)
	{
		for(ll j=0;j<=n;j++)d[i][j]=(1ll<<60);
		d[i][i]=0;
	}
}
int main()
{
	scanf("%lld",&n);
	ll i,j,k,u,v;
	init();
	for(i=1;i<n;i++)
	{
		scanf("%lld%lld",&u,&v);
		d[u][v]=d[v][u]=(1ll<<(i-1));
	}
	for(k=1;k<=n;k++)for(i=1;i<=n;i++)for(j=1;j<=n;j++)
	d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
	scanf("%lld",&m);
	for(i=0;i<m;i++)
	{
		scanf("%lld%lld",&u,&v);
		a[i]=d[u][v];
	}
	ll ans=0;
	for(j=0;j<(1ll<<m);j++)
	{
		ll base=0,cnt=0;
		for(k=0;k<m;k++)
		{
			if((j>>k)&1)base|=a[k],cnt++;
		}
		ll num=__builtin_popcountll(base);
		if(cnt&1)ans-=(1ll<<(n-1-num));
		else ans+=(1ll<<(n-1-num));
	}
	printf("%lld\n",ans);
}

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

using pii = pair<int,int>;
using ll = long long;
#define rep(i, j) for(int i=0; i < (int)(j); i++)
#define repeat(i, j, k) for(int i = (j); i < (int)(k); i++)
#define all(v) v.begin(),v.end()
#define debug(x) cerr << #x << " : " << x << endl

template<class T> bool set_min(T &a, const T &b) { return a > b  ? a = b, true : false; }
template<class T> bool set_max(T &a, const T &b) { return a < b  ? a = b, true : false; }
// vector
template<class T> istream& operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; }
template<class T> ostream& operator << (ostream &os , const vector<T> &v) { for(const T &t : v) os << "\t" << t; return os << endl; }
// pair
template<class T, class U> ostream& operator << (ostream &os , const pair<T, U> &v) { return os << "<" << v.first << ", " << v.second << ">"; }

const int INF = 1 << 30;
const ll INFL = 1LL << 60;

class ModInt{
  public:
    static const ll MOD = 1000000007LL;
    ll x;
    ModInt():x(0){};
    ModInt(ll x){
        while(x < 0) x += MOD;
        x %= MOD;
        this->x = x;
    }
    ModInt& operator += (const ModInt &l){ x += l.x; if( x >= MOD) x -= MOD; return *this; }
    ModInt& operator -= (const ModInt &l){ x -= l.x; if( x < 0 ) x += MOD; return *this; }
    ModInt& operator *= (const ModInt &l){ x = (x * l.x) % MOD; return *this; }
    ModInt operator +(const ModInt &l) const { return ModInt( x + l.x); }
    ModInt operator -(const ModInt &l) const { return ModInt( x - l.x); }
    ModInt operator *(const ModInt &l) const { return ModInt( x * l.x); }
};

// @warning rの部分はmodとってはいけない
ModInt pow(const ModInt &n, ll r){
    if(r == 0) return ModInt(1);
    ModInt ret = pow(n, r / 2);
    ret *= ret;
    if(r % 2 != 0) ret = ret * n;
    return ret;
}

// @waring nはMODと互いに素
ModInt inverse(const ModInt &n){
    return pow(n, ModInt::MOD - 2);
}


ModInt factorial(const ModInt &n){
    ModInt ret =1;
    for(ll i=n.x; i>1; i--){
        ret*=i;
    }
    return ModInt(ret);
}

ostream& operator << (std::ostream& os,const ModInt& a){ os << a.x; return os;}
istream& operator >> (std::istream& is,ModInt& a){ is >> a.x; return is;}


class Solver {
  public:
    bool solve() {
        int N, K; cin >> N >> K;
        vector<ModInt> factorials(N * 2);
        factorials[0] = 1;
        rep(i, N * 2 - 1) factorials[i + 1] = factorials[i] * (i + 1);

        repeat(i, 1, K + 1) {
            int B = K - i, R = N - K - (i - 1);
            if(B < 0 or R < 0) cout << 0 << endl;
            else {
                ModInt r = factorials[R + i] * inverse(factorials[R] * factorials[i]);
                ModInt b = factorials[B + i - 1] * inverse(factorials[B] * factorials[i - 1]);
                cout << r * b << endl;
            }
        }
        return 0;
    }
};

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


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

class Program
{
	static void Main()
	{
        int[] input = InInts().ToArray();
        double a = (double)input[0];
        double b = (double)input[1];
        double x = (double)input[2];
        double tan;
        if (a * a * b <= x * 2)
            tan = (2 * b / a) - (2 * x / (a * a * a));
        else
            tan = (a * b * b) / (2 * x);
        Console.WriteLine(ToAngle(Math.Atan(tan)));
	}

	static string[] InStrs()
	{
		return Console.ReadLine().Split(' ');
	}
	static IEnumerable<int> InInts()
	{
		return Console.ReadLine().Split(' ').Select(x => int.Parse(x));
	}
	static IEnumerable<long> InLongs()
	{
		return Console.ReadLine().Split(' ').Select(x => long.Parse(x));
	}

    static double ToAngle(double Radian)
    {
        return Radian * 180 / Math.PI;
    }
}

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

int f(long long int x) {
  if (x % 2 != 0) {             // odd number
    return 0;
  }
  return f(x/2) + 1;
}

int main(int argc, char *argv[])
{
  int n;
  std::vector<long long int> a;
  int ops = 0;

  cin >> n;
  a.resize(n);
  for (int i = 0; i < n; ++i) {
    int temp;
    cin >> temp;
    a[i] = temp;
  }
  bool done_div = false;

  for (int i = 0; i < n; ++i) {
    ops += f(a[i]);
  }

  cout << ops << endl;


  return 0;
}


Measured memory_bytes: 3700
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;

vector<pair<int,int>> e[100000];
ll d[100000];

void dfs(int v,int p){
    for(auto u:e[v]){
        int nt=u.first;
        int ct=u.second;
        if(nt!=p){
            d[nt]=d[v]+ct;
            dfs(nt,v);
        }
    }
}

int main(){
    int n;
    cin>>n;
    for(int i=0;i<n-1;i++){
        int a,b,c;
        cin>>a>>b>>c;
        --a,--b;
        e[a].push_back({b,c});
        e[b].push_back({a,c});
    }
    int q,k;
    cin>>q>>k;
    dfs(--k,-1);
    for(int i=0;i<q;i++){
        int x,y;
        cin>>x>>y;
        --x,--y;
        cout<<d[x]+d[y]<<endl;
    }
}


Measured memory_bytes: 12800
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> P;
typedef pair<int64_t, int64_t> Pll;
  
int main() {
    string s;
    cin >> s;
    set<char> T;
    for (int i = 0; i < s.size(); i++) {
        T.insert(s.at(i));
    }
    for (char i = 'a'; i < 'z' + 1; i++) {
        if (!T.count(i)) {
            cout << i << endl;
            return 0;
        }
    }
    cout << "None" << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    int menu[5];
    for(int i=0;i<5;i++)cin>>menu[i];
    int arr[5] = {0,1,2,3,4};
    int ans = 100000;
    do{
        int sum = 0;
        for(int i=0;i<5;i++){
            if(i == 4){
                sum += menu[arr[i]];
            }   
            else{
                sum += ((menu[arr[i]] + 9) / 10) * 10;
            }
        }
        ans = min(ans,sum);
    }while(next_permutation(arr,arr+5));
    
    cout << ans << endl;
}


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

int main()
{
	int W, H, x, y, r;

	cin >> W >> H >> x >> y >> r;

	if (x + r > W || x - r < 0 || y + r > H || y - r < 0) {
		cout << "No" << endl;
	} else {
		cout << "Yes" << endl;
	}

	return 0;
}

Measured memory_bytes: 3108
l=input().split()
n=int(l[0])
w=int(l[2])
l=input().split()
a=[]
for i in range(n):
  a.append(int(l[n-1-i]))
s=[]
m=[]
if n>=3:
  s.append(abs(a[1]-a[0]))
  s.append(max(abs(a[2]-a[0]),abs(a[1]-a[0])))
  m=[s[0],min(s[0],s[1])]
  x=min(abs(a[2]-a[0]),m[0])
  for i in range(2,n-2):
    if(max(abs(a[i]-a[0]),m[i-2])>x):
      x=max(abs(a[i]-a[0]),m[i-2])
    s.append(max(abs(a[i+1]-a[0]),x,abs(a[1]-a[0])))
    m.append(min(s[-1],m[-1]))
  s.reverse()
  if n==3:
    del(s[0])
  res=[abs(w-a[0]),abs(a[1]-a[0])]
  a.reverse()
  for i in range(n-2):
    res.append(min(abs(a[-2]-a[-1]),abs(a[i]-a[-1]),min(s[i:])))
  print(max(res))
if n==2:
  print(max(abs(w-a[0]),abs(a[1]-a[0])))
if n==1:
  print(abs(w-a[0]))
s.append

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

int main()
{
    int a, b, k;
    cin >> a >> b >> k;
    vector<int> ans;
    if (a > b)
    {
        swap(a, b);
    }
    rep(i, 1, a + 1)
    {
        if (a % i == 0 && b % i == 0)
        {
            // cout << i << endl;
            ans.push_back(i);
        }
    }
    cout << ans[ans.size() - k] << endl;
    return 0;
}


Measured memory_bytes: 3596
/**
 * @brief  素朴な文字列照合アルゴリズムを扱います
 * @date   2016/03/31
 */



//****************************************
// 必要なヘッダファイルのインクルード
//****************************************

#include <iostream>
#include <string>
#include <cstring>



//****************************************
// 型シノニム
//****************************************

using string_t = const char*;
using strlen_t = int;



//****************************************
// 関数の定義
//****************************************

/**
 * @brief  素朴な文字列照合アルゴリズム
 *
 * @note   手続きNAIVE-STRING-MATCHERの実行にはΟ((n-m-1)m)時間かかり、この限界は最悪の場合には改良できない
 *         たとえば、テキスト文字列がa^n(n個のaからなる文字列)、パターンがa^mの場合を考える. n-m+1個の可能なシフトsの
 *         それぞれに対して、そのシフトが正当であることを確認するために、文字の比較をm回繰り返す必要がある
 *         したがって、最悪実行時間はΘ((n-m+1)m)となり、m = floor(n/2)ならば、Θ(n^2)である
 *         このアルゴリズムは前処理を必要とせず、NAIVE-STRING-MATCHERの実行時間は照合時間と一致する
 *
 * @param  string_t T テキストT
 * @param  string_t P パターンP
 */
void naive_string_matcher(string_t T, string_t P)
{
    strlen_t n = strlen(T);
    strlen_t m = strlen(P);

    // パターンを含む"テンプレート"をずらしてゆき、テンプレート上のすべての文字が
    // テキストの対応する文字と一致するシフトに出会えれば、それを"書き留めて"ゆく
    for (strlen_t s = 0; s <= n - m; s++) {

        // 現在のシフトが正当か無効かを判定する 
        strlen_t t;
        for (t = 0; t < m; t++) {
            if (T[s + t] != P[t]) { break; }
        }

        // 発見した正当なシフトsを出力する
        if (t == m) {
            std::cout << s << std::endl;
        }
    }
}



//****************************************
// エントリポイント
//****************************************

int main()
{
    using namespace std;

    string T, P;
    cin >> T >> P;

    naive_string_matcher(T.c_str(), P.c_str());
    
    return 0;
}

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

namespace ConsoleApp62 {
    class Program {
        static void Main(string[] args) {
            string S = Console.ReadLine();
            string T = Console.ReadLine();

            int ans = 0;

            for (int i = 0; i < S.Length; i++) {
                if (S[i] == T[i]) {
                    ans++;
                }
            }

            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13140
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner reader = new Scanner(System.in);
		int A = reader.nextInt();
		int B = reader.nextInt();
		int T = reader.nextInt();
		int ans = B * (T / A);

		System.out.println(ans);
		reader.close();

	}
}





Measured memory_bytes: 22996
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author champon
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define ceill(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
ll mod = 1e9+7;
void ans(bool b, ostream& out=cout){ out << (b ? "Yes" : "No") << endl; }
void ans2(bool b, ostream& out=cout){ out << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b) a=b; return a<b; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a) a=b; return b<a; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill((T*)array, (T*)(array+N), val);}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

class debug
{
public:
    template<typename T> void vdeb(T vec);
    template<typename T1, typename T2> void adeb(T1 *arr, T2 n);
    template<typename T> void mdeb(T mp);
};

#endif //INCLUDE_DEBUG_HPP

template<typename T> void debug::vdeb(T vec)
{
    cout << "#vector set debug" << endl;
    for(auto vv : vec) cout << vv << " ";
    cout << endl;
}

template<typename T1, typename T2> void debug::adeb(T1 *arr, T2 n)
{
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}

template<typename T> void debug::mdeb(T mp)
{
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
debug dbg;

class BPalindromicNumbers {
public:
	void solve(std::istream& in, std::ostream& out)
	{
	    int a, b;
	    in >> a >> b;
	    int res = 0;
	    for(int i=a; i<=b; i++){
	        string num = to_string(i);
	        int len = num.length();
	        string f = num.substr(0, len/2);
	        string b = num.substr(len%2==0 ? len/2 : len/2+1, len);
            reverse(b.begin(), b.end());
	        if(f == b) res++;
	    }

	    out << res << endl;
	}
};


int main() {
	BPalindromicNumbers solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define ull unsigned long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define _h cout<<"here"<<endl;
#define fill(a,v) memset(a,v,sizeof(a));
#define all(v) v.begin(),v.end()
#define rep(i,n) for(int i=0;i<n;i+=1)
#define prd(a,n) rep(i,n) cout<<a[i]<<" \n"[i==n-1];// printf("%s\n"," " );
#define ff first
#define ss second
#define pu push_back
const int inf = 1e9+10;
const ll INF = 2e18+10;
const int Mod = 1e9+7;
const int MAXN = 1000010;
const int N=2e5+10;
const int M=210;
const int M1=1e9+7;
const int M2=1e9+9;
const int base=131;
vector<int> G[N];
ll H[N],P[N];
int main()
{
  ios::sync_with_stdio(0), cin.tie(0); cout.tie(0);
  // freopen("input.txt","r",stdin);
  // freopen("output.txt","w",stdout);
  int n;
  cin>>n;
  for(int i=1;i<n;i++)
  {
    int u,v;
    cin>>u>>v;
    G[u].pu(v);
    G[v].pu(u);
  }
  // for(int i=1;i<=n;i++) sort(G[i].begin(),G[i].end());
  H[0]=0;
  for(int i=1;i<=n;i++)
  {
    int val=-1;
    ll cnt=0;
    for(int j=0;j<G[i].size();j++)
    {
      int x=G[i][j];
      if(x<i)
      {
        val=max(val,j);
        cnt+=x;
      }
    }
    val++;
    H[i]=val;
    P[i]=cnt;
  }
  // for(int i=0;i<=n;i++) cout<<i<<" "<<H[i]<<endl;

  // P[0]=0;
  // for(int i=1;i<=n;i++) P[i]=P[i-1]+H[i];
  ll ans=0,prev=0;
  for(int i=1;i<=n;i++)
  {
    ll val=prev+i-P[i];
    ans+=val;
    prev=val;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 18144
#include <bits/stdc++.h>
#define ll long long int
#include<list>
#include<algorithm>
#define ld long double
#define pb push_back
#define FF first
#define SS second
#define rep(a,b,c) for(a=b;a<c;a++)
#define repr(a,b,c) for(a=b-1;a>=c;a--)
#define PLL pair<ll, ll>
#define inf 100000001
#define mod 1000000007
#define LB lower_bound
#define UB upper_bound
#define MP make_pair
#define PQ priority_queue
#define rep1 for(i=1;i<=n;i++)
#define VLL vector<ll>
#define EF else if
const double pi  =3.141592653589793238463;
#define all(x) (x).begin(), (x).end()
#define SORT(A) sort(A.begin(), A.end());
#define REVERSE(A) reverse(A.begin(), A.end());
#define UMP unordered_map
#define MAX LLONG_MAX
#define MIN LLONG_MIN
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define test1(x)                cerr<<#x<<": "<<x<<endl
#define test2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define test3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define test4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define test5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define test6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
using namespace std;
/*
    //string with spaces
    std::string str;
    std::getline(std::cin >> std::ws, str);
*/
ll myXOR(unsigned long long int x, unsigned long long int y)
{
    return (x|y)&(~x|~y);   
}
ll powerLL(ll x, ll n) 
{ 
    ll result = 1; 
    while (n) { 
        if (n & 1) 
            result = result * x % mod; 
        n = n / 2; 
        x = x * x % mod; 
    }
    return result; 
}
int main()
{
    // fastio
    ll a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r, t,u,w,x,y,z;
    string str, ss, str1;
    cin>>n;
    unordered_map<string, ll>store;
    rep(i,0,n){
        cin>>str;
        store[str]++;
    }
    cout<<"AC x "<<store["AC"]<<endl;
    cout<<"WA x "<<store["WA"]<<endl;
    cout<<"TLE x "<<store["TLE"]<<endl;
    cout<<"RE x "<<store["RE"];
}

Measured memory_bytes: 3664
#include<iostream>
#include<algorithm>
#include<cstdint>
using namespace std;

const int MAX = 100001;
int main() {
	int N, M;
	static int A[MAX];
	cin >> N >> M;
	for (int i = 0;i < N;++ i) cin >> A[i];
	static int sum[MAX]; // Aの累積和 ただしmod M上で考える
	sum[0] = A[0] % M;
	for (int i = 1;i < N;++ i) sum[i] = (A[i] + sum[i - 1]) % M;
	sort(sum, sum+N);
	int64_t ans = 0;
	for (int l = 0, r = 0;l < N;r = l > r ? l : r) {
		if (r < N && sum[l] == sum[r]) ++ r; // r < N && 範囲が条件を満たす場合
		else {
			ans += (int64_t)(r - l - (sum[l] == 0 ? -1 : 1)) * (r - l) / 2; // 往々にしてオーバーフローするのでint64_tの検討を
			l = r;
		}
	}
	cout << ans;
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり
また、コンテスト後に https://31536000.hatenablog.com/ で解説していると思うので、良かったら読んでねー

まず、Mの倍数という条件に注目。
これ、mod M上で考えると良さそうだよね？(xがMの倍数⇔x mod M==0)
そこで全てmod M上で考えると、[l, r]区間がMの倍数であるという条件がA_lからA_rまで全て足すとmod M==0になるという条件に変わった
ここで、A_lからA_rまでの合計が分かっていると計算が楽そう→累積和を使ってみよう
累積和B_i = Σ[k=1, i]A_iとすると、[l, r]区間はΣ[k=l, r]A_i == Σ[k=1, r]A_k - Σ[k=1, l-1]A_k == B_r - B_{l-1}で導出できるね
さて、この時のB_rとB_{l-1}について何が成立すると条件を満たすだろうか？
これは、つまりB_r - B_{l-1} mod M == 0、つまりB_r mod MとB_{l-1} mod Mが等しいということ
逆に、これさえ満たせば全て条件を満たすので、今x個のB_iがmod M上で同値ならば、そのうち任意の2個に対して条件を満たすのでxC2 == (x-1)x/2個が条件を満たす
ただしB_i mod M==0ならば1個でも条件を満たすからxC2+x == x(x+1)/2個が条件を満たすことに注意ね
これはBについてソートしておけば単調性があるので簡単に調べられるよ
なお、最大ケースはN==10^5、全てのA_i==Mの倍数を満たすときで、この時答えは(10^5)(100001)/2=5,000,050,000とint型に収まらないことに注意ね
*/

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

#define MAX_V 1000000

map<ll, ll> prime_factor(ll n) {
	map<ll, ll> res;
	for(int i = 2; i * i <= n; i++) {
		while(n % i == 0) {
			++res[i];
			n /= i;
		}
	}
	if(n != 1) res[n] = 1;
	return res;
}

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

	int N;
	cin >> N;
	ll res = 0;
	rep(i, 0, N) {
		ll a;
		cin >> a;
		map<ll, ll> m = prime_factor(a);
		res += m[2];
	}
	cout << res << endl;

}


Measured memory_bytes: 256
#include <cctype>
#include <cfloat>
#include <climits>
#include <cmath>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <ios>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <forward_list>
#include <random>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <unordered_map>
#include <unordered_set>
#endif

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define lcm( a, b ) (a)/__gcd((a),(b))*(b)
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 100005;

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

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

    int n, p;
    cin >> n >> p;
    LL a[n];
    int even = 0, odd = 0;
    for( int i = 0; i < n; ++i ) {
        cin >> a[i];
        if( a[i] % 2 ) ++odd;
        else ++even;

    }

    if( p == 1 && even == n ) {
        cout << 0 << endl;
        return 0;

    }
    if( p == 0 && even == n ) {
        LL res = 1;
        for( int i = 0; i < n; ++i ) res <<= 1;
        cout << res << endl;
        return 0;

    }

    LL res = 1;
    for( int i = 0; i < n - 1; ++i ) res <<= 1;

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256