akhauriyash/Code-Regression huggingface dataset:
//
// Created by chuan on 2020-04-11.
//


#include <unordered_map>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>

using ll = long long ;

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);

    ll N;
    cin >> N;

    string s;
    cin >> s;

    unordered_map<char, vector<ll>> indices{};
    for (int i = 0; i < N; ++i) {
        indices[s[i]].push_back(i);
    }

    string uc{"RGB"};

    ll cnt {};
    for (int i = 0; i < 3; ++ i) {
        vector<ll>& idx = indices[uc[i]]; // R, G or B

        char l = uc[(i+1)%3];
        char r = uc[(i+2)%3];
        ///cout<<" l " << l <<" r " << r << " mid " << uc[i]<<endl;
        vector<ll>& left = indices[l];
        vector<ll>& right = indices[r];
        for (auto c : idx) {
            for (auto j : left) {
                if (j > c) break;
                auto diff = c - j;
                auto t = c + diff;
                //cout<<" c " << c <<" j " << j <<" l " << l <<" r " << r << " mid " << uc[i]<<endl;
                auto p = lower_bound(right.begin(), right.end(), c);
                cnt += (right.end() - p);
                if (binary_search(right.begin(),right.end(), t)) cnt --;
            }

            for (auto j : right) {
                if (j > c) break;
                auto diff = c - j;
                auto t = c + diff;
                //cout<<" c " << c <<" j " << j <<" l " << l <<" r " << r << " mid " << uc[i]<<endl;
                auto p = lower_bound(left.begin(), left.end(), c);
                cnt += (left.end() - p);
                if (binary_search(left.begin(),left.end(), t)) cnt --;
            }
        }
    }
    cout<<cnt<<endl;

    return 0;
}


Measured memory_bytes: 3752
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
typedef long long ll;
const ll infl = 1LL<<60;
template <typename X>
struct BellmanFord{
  int node;
  vector<vector<pair<int,X>>> edge;
  vector<X> d;

  BellmanFord(int _n){
    node = _n;
    d.assign(node,-infl);
    edge.resize(node);
  }
  
  //辺の追加
  void add_edge(int from,int to,X cost){
    edge[from].push_back(make_pair(to,cost));
  }
 
  void bellmanford(int s){
    d[s] = 0;
    rep(i,node-1){
      rep(j,node){
	if(d[j]==-infl) continue;
	for(auto& k:edge[j]){
	  d[k.first] = max(d[k.first],d[j]+k.second);
	}
      }
    }
    
    vector<bool> pos(node,0);
    rep(i,node){
      rep(j,node){
	if(d[j]==-infl) continue;
	for(auto& k:edge[j]){
	  if(d[k.first]<d[j]+k.second){
	    pos[k.first] = true;
	    d[k.first] = d[j] + k.second;
	  }
	  if(pos[j]) pos[k.first] = true; 
	}
      }
    }

    rep(i,node) if(pos[i]) d[i] = infl;
    
  }

};

int main()
{
  int n,m;
  cin >> n >> m;
  vector<int> a(m),b(m);
  vector<ll> c(m);
  rep(i,m){
    cin >> a[i] >> b[i] >> c[i];
    a[i]--;
    b[i]--;
  }

  BellmanFord<ll> bf(n);

  rep(i,m) bf.add_edge(a[i],b[i],c[i]);

  bf.bellmanford(0);

  if(bf.d[n-1]!=infl) cout << bf.d[n-1] << "\n";
  else cout << "inf" << "\n";
  return 0;
}


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

#define int long long

typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
template<class T,class U>void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>void chmax(T &t,U f){if(t<f)t=f;}

int T;
int t[30];
int m[100];

int dp[111][30];

void solve(){
    rep(i,T)cin>>t[i];


    fill_n(m,100,1001001);
    int N;cin>>N;
    while(N--){
        int D,M;
        cin>>D>>M;
        D--;
        chmin(m[D],M);
    }


    fill_n(*dp,111*30,1<<25);
    dp[0][0]=0;
    rep(i,100){
        rep(j,T){
            if(t[j]<=m[i]){
                chmin(dp[i+1][(j+1)%T],dp[i][j]);
            }
            chmin(dp[i+1][1%T],dp[i][j]+1);
        }
    }
    int ans=1<<25;
    rep(i,T)chmin(ans,dp[100][i]);
    cout<<ans<<endl;
}

signed main(){
    while(cin>>T,T)solve();
    return 0;
}

Measured memory_bytes: 3004
#include "bits/stdc++.h"
using namespace std;

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

	if (s.at(0) == 'S') {
		cout << "Cloudy";
	}
	else if (s.at(0) == 'C') {
		cout << "Rainy";
	}
	else if (s.at(0) == 'R') {
		cout << "Sunny";
	}
	cout << endl;
}


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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;

void Main(){
    int n; 
    cin >> n;
    n %= 1000;
    if(n != 0) n = 1000 - n;
    cout << n << endl;
    return;
}

int main(){
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}

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

typedef long long ll;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    int k,u;
    int v;
    int table[200][200]={};
    for(int i=0;i<n;i++){
        cin >> u;
        cin >> k;
        for(int j=0;j<k;j++){
            cin >> v;
            table[u-1][v-1]=1;
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(j)cout << " ";
            cout << table[i][j];
        }
        cout << endl;
    }

    return 0;
}



Measured memory_bytes: 3276
#include <bits/stdc++.h>
using namespace std;
inline void chmin (long long& a, long long b) {
  if (a > b) a = b;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n), b(n);
  vector<pair<int, int>> c(2 * n);
  for (int i = 0; i < n; i++) {
    cin >> a[i] >> b[i];
    c[i * 2] = {a[i], i};
    c[i * 2 + 1] = {b[i], i};
  }
  sort(c.begin(), c.end());
  vector<int> ckd(n, false);
  long long ret = 0;
  for (int i = 0; i < n; i++) {
    ret += c[i].first;
    ckd[c[i].second] = true;
  }
  bool ok = false;
  for (int i = 0; i < n; i++) {
    if (!ckd[i]) {
      ok = true;
      break;
    }
  }
  if (!ok) {
    if (c[n - 1].second != c[n].second) {
      ret += c[n].first - c[n - 1].first;
    } else {
      ret += min(-c[n - 1].first + c[n + 1].first, -c[n - 2].first + c[n].first);
    }
  }
  for (int t = 0; t < 2; t++) {
    long long tmp = 0;
    for (int i = 0; i < n; i++) {
      tmp += a[i];
    }
    chmin(ret, tmp);
    swap(a, b);
  }
  cout << ret << '\n';
  return 0;
}

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

int main()
{
    int n, x;
    cin >> n >> x;
    int l[103] {0};
    int ans = 1;
    for(int i = 1; i <= n; i++){
        cin >> l[i];
        l[i] += l[i - 1];
        if(l[i] <= x) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
N = int(input())

if N < 1000:
  ans = "ABC"
  
  N += 1000
  N = str(N)
  N = N[1:]
  ans += N
  
else:
  ans = "ABD"
  
  N -= 999
  N += 1000
  N = str(N)
  N = N[1:]
  ans += N
  
print(ans[:3])

Measured memory_bytes: 3064
N =str(input())

#print(N[-1])
if N[-1] =="3":
    print("bon")

elif N[-1] == "0":
    print("pon")

elif N[-1] == "1":
    print("pon")

elif N[-1] == "6":
    print("pon")

elif N[-1] == "8":
    print("pon")

elif N[-1] == "2":
    print("hon")

elif N[-1] == "4":
    print("hon")

elif N[-1] == "5":
    print("hon")

elif N[-1] == "7":
    print("hon")

elif N[-1] == "9":
    print("hon")


Measured memory_bytes: 9140
#include <bits/stdc++.h>
using namespace std;
#define iinf 2000000000
#define linf 1000000000000000000LL
#define ulinf 10000000000000000000ull
#define MOD1 1000000007LL
#define mpr make_pair
typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned long UL;
typedef unsigned short US;
typedef pair < int , int > pii;
clock_t __stt;
inline void TStart(){__stt=clock();}
inline void TReport(){printf("\nTaken Time : %.3lf sec\n",(double)(clock()-__stt)/CLOCKS_PER_SEC);}
template < typename T > T MIN(T a,T b){return a<b?a:b;}
template < typename T > T MAX(T a,T b){return a>b?a:b;}
template < typename T > T ABS(T a){return a>0?a:(-a);}
template < typename T > void UMIN(T &a,T b){if(b<a) a=b;}
template < typename T > void UMAX(T &a,T b){if(b>a) a=b;}
int n,a[200005],b[200005],c[200005];
bool got[200005];
LL res;
multiset < int > cur;
int main(){
    // inputting start
    // 数据结构记得初始化！ n，m别写反！
    scanf("%d",&n);
	int i,j,k;
	for(i=0;i<n;++i){
		scanf("%d",a+i);
	}
    #ifdef LOCAL
        TStart();
    #endif
    // calculation start
    // 数据结构记得初始化！ n，m别写反！
	j=0;
	for(i=0;i<n;++i){
		while(j<n&&a[j]-j>=-i){
			cur.insert(a[j]-j);
			++j;
		}
		b[i]=j-1;
		c[i]=b[i]-i;
		if(!cur.empty()) cur.erase(cur.find(a[i]-i));
	}
	for(i=0;i<n;++i){
		// a[i]-i=-k
		// k=i-a[i]
		if(a[i]>i){
			printf("-1\n");
			return 0;
		}
		k=i-a[i];
		if(b[k]<i){
			printf("-1\n");
			return 0;
		}
		if(!got[k]){
			got[k]=1;
			res+=(LL)c[k];
		}
	}
    cout<<res<<endl;
    #ifdef LOCAL
        TReport();
    #endif
    return 0;
}

Measured memory_bytes: 12032
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE BangPatterns #-}

module Main where

import Debug.Trace
import qualified Data.Map.Strict as Map


main :: IO ()
main = do
  getLine
  s <- map read . words <$> getLine
  j <- map (map read . words) . lines <$> getContents
  --s `traceShow` j `traceShow` print $ solve s j
  print $ solve s j


solve :: [Int] -> [[Int]] -> Int
--solve s j = uf' `traceShow` cnt
solve s j =  cnt
  where
    z = zip [1..] s
    tbl = foldr ins Empty $ j
    --ins [i, a] uf = uf `traceShow` union i a uf
    ins [i, a] uf = union i a uf
    (cnt, uf') = check 0 z tbl

check :: Int -> [(Int, Int)] -> UnionFind -> (Int, UnionFind)
check !cnt [] uf = (cnt, uf)
check !cnt ((i, a):ss) uf = check (if b then cnt + 1 else cnt) ss uf'
   where
     (b, uf') = same i a uf

data UnionFind = Empty | Tree (Map.Map Int Int)
deriving instance Show (UnionFind) 

root :: Int -> UnionFind -> (Int, UnionFind)
root !a Empty = (a, set a a Empty)
root !a !uf@(Tree !t) = (s, set a s uf')
  where
    (!s, !uf') = case (Map.lookup a t) of Just k -> if a == k then (k, uf) else root k uf
                                          Nothing -> (a, uf)

union :: Int -> Int -> UnionFind -> UnionFind
union !a !b !uf = Tree t'
  where
    (!ar, !uf') = root a uf
    (!br, !uf'') = root b uf'
    !t' = case uf'' of Tree t -> if ar == br then t else Map.insert ar br t
                       Empty -> Map.empty

same :: Int -> Int -> UnionFind -> (Bool, UnionFind)
same !a !b !uf = (ar == br, uf'')
  where
    (!ar, !uf') = root a uf
    (!br, !uf'') = root b uf'

set :: Int -> Int -> UnionFind -> UnionFind
set !a !b !Empty = Tree (Map.insert a b Map.empty)
set !a !b !(Tree !t) = Tree (Map.insert a b t)


Measured memory_bytes: 68220
#include <math.h>
#include <stdio.h>

// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_1_C

int is_prime(int x) {
    if (x == 2)
        return 1;
    if (x % 2 == 0)
        return 0;
    int i;
    for (i = 2; i < (int)sqrt(x) + 1; i++) {
        if (x % i == 0)
            return 0;
    }
    return 1;
}

int main(int argc, char **argv) {
    int n;
    int x;
    int cnt = 0;
    scanf("%d", &n);
    while (n > 0) {
        n--;
        scanf("%d", &x);
        if (is_prime(x))
            cnt++;
    }
    printf("%d\n", cnt);
    return 0;
}


Measured memory_bytes: 2052
S = str(input())
hantei = True
if S[0]!='A':
  hantei = False
if S[2:-1].count('C') != 1:
  hantei = False
if S[1:].replace('C','') != (S[1:].replace('C','')).lower():
  hantei = False
print('AC' if hantei else'WA')

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

#define int long long

signed main(){
    int a, b, k;
    cin >> a >> b >> k;

    if(a >= k){
        cout << a-k << " " << b << endl;
    }else{
        cout << 0 << " " << max(b-(k-a), 0ll) << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef struct _node {
    int key;
    struct _node *next;
    struct _node *prev;
} Node;
typedef Node *Nodepointer;

Nodepointer make_1node(int key){
    Nodepointer ret = malloc(sizeof(Node));
    ret->key = key;
    ret->next = NULL;
    ret->prev = NULL;
    return ret;
}

void delete_node(Nodepointer target){
    if(target -> next != NULL){
        target -> next ->prev = target -> prev;
    }
    if(target -> prev != NULL){
        target -> prev -> next = target -> next;
    }
    free(target);
}

int main(){
    int i, n, key;
    char command[12];
    Nodepointer head, tail, data, temp;
    head = tail = NULL;
    scanf("%d", &n);
    for(i = 0; i < n; i++){
        scanf("%s%d", command, &key);
        if (strcmp(command, "insert") == 0){
            data = make_1node(key);
            // 要素なし
            if (head == NULL){
                tail = data;
            }
            else{
                data->next = head;
                head->prev = data;
            }
            head = data;

            // deleteがない場合はdelete処理をしなくて良いので
            // continueで戻す
            continue;
        }
        if (strcmp(command, "delete") == 0){
            for(data = head; data != NULL; data = data->next){
                if (data->key == key){
                    break;
                }
            }
            if(data == NULL){
                // 該当データがなければdelete処理をせず
                // continueで戻す
                continue;
            }
        }
        if (strcmp(command, "deleteFirst") == 0){
            data = head;
        }
        if (strcmp(command, "deleteLast") == 0){
            data = tail;
        }
        if(head == data){
            head = head->next;
        }
        if(tail == data){
            tail = tail->prev;
        }
        delete_node(data);
    }
    for(i = 0, data = head; data != NULL; i++, data = data -> next){
        if(i){
            printf(" ");
        }
        printf("%d", data->key);
        fflush(stdout);

    }
    printf("\n");
    for(data = head; data != NULL; data = head){
        head = data->next;
        delete_node(data);
    }
    return 0;
}



Measured memory_bytes: 32948
N = int(input())
listA = list(map(int,input().split()))
listB = list(map(int,input().split()))
sumA = 0
sumB = 0
sumList = []
for i in range(N):
	sumList.append(sum(listA[0:i + 1]) + sum(listB[i:N]))
print(max(sumList))

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

int main()
{
    int n,m;
  cin>>n>>m;
  int a[m];
  for(int i=0;i<m;i++)
    cin>>a[i];
  valarray<int> v(a,m);
    int x= v.sum();
  if(x>n)
  {
    cout<<"-1"<<endl;
    return 0;}
  else
  {
    int t=n-x;
    cout<<t<<endl;
  }
return 0;
}


Measured memory_bytes: 3696
#include<ctime>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cmath> 
#include<cstring> 
#include<cassert>
#include<string>
#include<sstream>
#include<fstream>
#include<deque>
#include<queue>
#include<vector>
#include<map>
#include<list>
#include<stack>
#include<set>
#include<bitset>
#include<iomanip>
#include<utility>
#include<functional>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cwchar>
#include<cwctype>
#include<exception>
#include<locale>
#include<numeric>
#include<new>
#include<stdexcept>
#include<limits>
using namespace std;

#define ll long long
#define INF 1e9
#define rep(i,n) for(int (i)=0;(i)<n;i++)
#define REP(i,n) for(int (i)=1;(i)<=n;i++)
#define repd(i,n) for(int (i)=n-1;(i)>=0;i--)
#define REPD(i,n) for(int (i)=n;(i)>0;i--) 
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
#define pii pair<int,int>
#define sz(s) s.size()
#define all(s) (s.begin(),s.end())

const int maxn=200005;
int n;
ll ans=INF*INF,S;
int a[maxn];

int main(){
	ios::sync_with_stdio(false);
	cin>>n;
	REP(i,n)cin>>a[i],S+=(ll)a[i];
	ll sum=0;
	REP(i,n-1){
		sum+=(ll)a[i];
		ans=min(ans,abs(sum-(S-sum)));
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	private static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		int n = sc.nextInt();
		int max = 0;
		int ans = 0;
		for (int i = 0; i < n; i++) {
			int tmp = sc.nextInt();
			max = Math.max(max, tmp);
			ans += tmp;
		}
		System.out.println(ans - max / 2);
	}
}

Measured memory_bytes: 23252
#include <iostream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <numeric>
#include <string>
#include <bitset>

using namespace std;

int main(){
    int n, ans = 100000;
    cin >> n;
    
    for(int i = 1; i < n; i++){
        int sum = 0;
        string s = to_string(i);
        for(string::iterator itr = s.begin(); itr < s.end(); itr++)
            sum += (int)(*itr -  '0');
        s = to_string(n - i);
        for(string::iterator itr = s.begin(); itr < s.end(); itr++)
            sum += (int)(*itr -  '0');
        if(sum < ans)
            ans = sum;
    }
    cout << ans << endl;
    return 0;
}


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

#define fastread std::ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl '\n'
#define pb push_back
#define mp make_pair
#define print(a) for(auto x:a) cout<<x<<' ';cout<<endl;
#define printM(b) for(auto y:b) {print(y);}
#define printP(p) cout<<p.first<<' '<<p.second<<endl;

using namespace std;

typedef long long int ll;
typedef long double ld;
typedef unsigned long long ull;

vector<ll> g[100010], r[100010];
vector<ll> cnt;
vector<bool> vis;
map<ll, bool> root;
ll mx;

ll dfs(ll cur, ll d)
{
    //cout<<cur+1<<endl;
    if(cnt[cur] > 0)
    {
        return cnt[cur]+1;
    }
    mx = max(mx, d);

    ll x=-1;
    for(auto adj: g[cur])
        x = max(x, dfs(adj, d+1));
    
    cnt[cur] = max(cnt[cur], x);
    return cnt[cur] + 1;
}

int main()
{
	fastread;
	
	ll n, m, i, j, x, y;

    cin>>n>>m;

    for(i=0 ; i<n ; ++i)
        g[i].clear();
    cnt = vector<ll>(n, 0);
    vis = vector<bool>(n, 0);
    root.clear();

    for(i=0 ; i<m ; ++i)
    {
        cin>>x>>y;

        x--, y--;
        g[x].pb(y);
        r[y].pb(x);
    }

    
    //for(i=0 ; i<n ; ++i)
    //    cout<<root[i]<<' ';
    //cout<<endl;
    
    mx = 0;
    for(i=0 ; i<n ; ++i)
            dfs(i, 0);
    
    for(i=0 ; i<n ; ++i)
        mx = max(mx, cnt[i]);
    cout<<mx;
    
    return 0;
}

Measured memory_bytes: 14720
#include<iostream>
#include<algorithm>
using namespace std;
const int MAX = 100;
struct exCard
{
	int card1;
	int card2;
	int sum;
};
int main()
{
	while (true)
	{
		int n, m;
		cin >> n >> m;
		if (!n && !m)
			break;
		int T[MAX], H[MAX];
		int sumT = 0;
		int sumH = 0;
		for (int i = 0; i < n; i++)
		{
			cin >> T[i];
			sumT += T[i];
		}
		for (int i = 0; i < m; i++)
		{
			cin >> H[i];
			sumH += H[i];
		}
		bool flag = false;
		exCard C{ -1,-1,999999999 };
		for (int i = 0; i < n; i++)
		{
			for (int j = 0; j < m; j++)
				if (sumT - T[i] + H[j] == sumH - H[j] + T[i])
				{
					flag = true;
					if (T[i] + H[j] < C.sum)
					{
						C.card1 = T[i];
						C.card2 = H[j];
						C.sum = T[i] + H[j];
					}
				}
		}
		if (!flag)
			cout << -1 << endl;
		else
			cout << C.card1 << " " << C.card2 << endl;
	}
}


Measured memory_bytes: 3072
#[allow(unused_imports)]
use std::collections::VecDeque;
#[allow(unused_imports)]
use std::cmp;
#[allow(unused_imports)]
use std::collections::HashMap;

#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        #[allow(unused_variables)]
        #[allow(unused_mut)]
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
 
    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
 
    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };
 
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
 
    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };
 
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };
 
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("parse error")
    };
}

fn main() {
    input!{
        n: i64
    }
    let mut answer = 0;
    for i in 1..n+1 {
        if i % 3 != 0 && i % 5 != 0 {
            answer += i;
        }
    }
    println!("{}", answer);
}


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

inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	for (; ch < '0' || ch > '9'; ch = getchar()) if (ch == '-') f = -1;
	for (; ch >= '0' && ch <= '9'; ch = getchar()) x = (x << 1) + (x << 3) + ch - '0';
	return x * f;
}

const int N = 3e6 + 5;
const int P = 998244353;
int fac[N], ifac[N];

int Pow(int x, int t)
{
	int res = 1;
	for (; t; t >>= 1, x = 1LL * x * x % P)
		if (t & 1) res = 1LL * res * x % P;
	return res;
}

int C(int n, int m)
{
	if (n < m || m < 0) return 0;
	return 1LL * fac[n] * ifac[m] % P * ifac[n - m] % P;
}

int solve(int n, int m, int k)
{
	int res = 0;
	for (int i = m & 1; i <= k; i += 2)
		res = (res + 1LL * C(n, i) * C((m - i) / 2 + n - 1, n - 1) % P) % P;
	return res;
}

int main()
{
	int n = read();
	int m = read();
	
	fac[0] = 1;
	for (int i = 1; i < N; ++i) fac[i] = 1LL * i * fac[i - 1] % P;
	ifac[N - 1] = Pow(fac[N - 1], P - 2);
	for (int i = N - 1; i >= 1; --i) ifac[i - 1] = 1LL * i * ifac[i] % P;
	
	int ans = solve(n, 3 * m, m);
	ans = (ans - 1LL * n * (solve(n, m, m) - solve(n - 1, m, m)) % P + P) % P;
	printf("%d\n", ans);
	
	return 0;
}


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

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

	long long quotient = N / K;
	long long remainder = N % K;

	long long add = 0;
	if (N > quotient) {
		add = abs(remainder - K);
	}

	long long answer = min(remainder, add);

	std::cout << answer << std::endl;

	return 0;
}

Measured memory_bytes: 256
a, b = map(int, raw_input().split())
w, h = 100, 100
grid = [list("#"*(w/2)+"."*(w/2)) for i in range(h)]
d = (w/2-1)/2
for i in range(a-1):
    r = 2*(i / d)
    c = 2*(i % d)
    grid[r][c] = "."
for i in range(b-1):
    r = 2*(i / d)
    c = w-1-2*(i % d)
    grid[r][c] = "#"
print "%d %d" % (w,h)
print "\n".join(map("".join,grid))

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

#define rep(i, N) for (int i = 0; i < N; i++)
#define pb push_back

typedef long long ll;

int main() {
	int N; cin >> N;
    string s; cin >> s;
    vector<int> sum(N + 1);
    rep(i, N) sum[i + 1] = sum[i] + (s[i] == 'E');
    int ans = N;
    rep(i, N) {
        int left = i - sum[i];
        int right = sum[N] - sum[i + 1];
        ans = min(ans, left + right);
    }
    cout << ans << endl;
}


Measured memory_bytes: 1796
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
static const ll MOD = 1000000007;

int main(){
  ll N;
  cin >> N;
  vector<ll> a(N);
  for(int i = 0 ; i < N; i++){
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  bool flag = true;
  for(int i = 1; i < N; i++){
    if(a[i] == a[i-1]){
      flag = false;
      break;
    }
  }
  if(flag){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
    
}


Measured memory_bytes: 1792
#include <cstdio>
#include <cstring>
using namespace std;
char S[111];
int n;
int main() {
	scanf("%s", S);
	n = strlen(S);
	for (int i = 0; i < n - 1; i++) {
		if (S[i] == 'C') {
			for (int j = i + 1; j < n; j++) {
				if (S[j] == 'F') {
					puts("Yes");
					return 0;
				}
			}
		}
	}
	puts("No");
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>

int main(){
    int X,N;
    std::cin>>X>>N;
    std::vector<int>P(N);
    int Distance=0;
    int ans;
    for(auto& p:P){
        std::cin>>p;
    }
    while(1){
        auto itr1=std::find(P.begin(),P.end(),X-Distance);
        auto itr2=std::find(P.begin(),P.end(),X+Distance);
        if(itr1==P.end()){
            ans=X-Distance;
            break;
        }else if(itr2==P.end()){
            ans=X+Distance;
            break;
        }
        Distance++;
    }
    std::cout<<ans;
    return 0;
}

Measured memory_bytes: 3632
//                     بِسْمِ ٱللَّٰهِ ٱلرَّحْمَٰنِ ٱلرَّحِيمِ
//                   لآ اِلَهَ اِلّا اللّهُ مُحَمَّدٌ رَسُوُل اللّهِ





#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef double db;

#define endl "\n"

const int MOD = 1000000007;


int main()
{
    ios::sync_with_stdio(0);cin.tie(0);
    string x;
    cin >> x;
    for(int i=0;i<x.size();i+=2){
        cout <<x[i];
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 3752
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, o, n) for (auto i = (o); (i) < (n); ++(i))
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (auto i = (n)-1; (i) >= 0; --i)
#define REPI(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define REPIR(itr, v) for (auto itr = v.rbegin(); itr != v.rend(); ++itr)
#define fi first
#define se second
#define ll long long
#define V2(name, h, w) vector<vector<int> > name((h), vector<int>(w));
int main(){
	int N, M, X, Y; cin >> N >> M >> X >> Y;
	vector<int> x, y;
	x.reserve(101), y.reserve(101);
	REP(i,N){
		int tmp; cin >> tmp;
		x.push_back(tmp);
	}
	REP(i,M){
		int tmp; cin >> tmp;
		y.push_back(tmp);
	}
	sort(x.begin(), x.end());
	sort(y.begin(), y.end());
	if( x.back() < Y and y.front() > X and x.back() < y.front()) cout << "No War" << endl;
	else cout << "War" << endl;

}


Measured memory_bytes: 256
#pragma region Library

#include <algorithm>
#include <array>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>

using namespace std;

using ll = long long int; // int_fast64_t;

template <class T> using vt = vector<T>;
template <class T> using vvt = vector<vector<T>>;
using vi = vt<int>;
using vvi = vvt<int>;
using vl = vt<ll>;
using vvl = vvt<ll>;

constexpr int INF = 1 << 30;  // 1073741824 2倍すると-2147483648
constexpr ll INFL = 1l << 62; // 4611686018427387904 2倍すると-0.9*10^18
constexpr int dx4[] = {0, 1, 0, -1};
constexpr int dy4[] = {1, 0, -1, 0};
constexpr int dx8[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dy8[] = {0, -1, 0, 1, -1, -1, 1, 1};
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define FORR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define RANGE(i, a, b) for (int i = (a); i <= (b); i++)
#define RANGER(i, a, b) for (int i = (b); i >= (a); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) RFOR(i, 0, (n))

#pragma endregion

int n, m;
int x[100000];
int dx[100000];

int main() {
  cin >> n >> m;
  REP(i, m) cin >> x[i];
  sort(x, x + m);
  REP(i, m - 1) dx[i] = x[i + 1] - x[i];
  sort(dx, dx + m - 1, [](auto a, auto b) { return a > b; });
  int result = 0;
  REP(i, m - 1) result += dx[i];
  // cout << result << endl;

  REP(i, min(n - 1, m - 1)) result -= dx[i];
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define reg register
int n,l,r,sum;
int main()
{
	scanf("%d",&n);
	for(reg int i=1;i<=n;i++)
	{
		scanf("%d%d",&l,&r);
		sum+=r-l+1;
	}
	printf("%d\n",sum);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-2;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;

struct segt {
private:
	int sz;
	vector<int> node;
public:
	segt(int n) {
		sz = 1;
		while (sz < n)sz *= 2;
		node.resize(2 * sz - 1, -mod);
	}
	void update(int k, int a) {
		k += sz - 1;
		node[k] = max(node[k],a);
		while (k > 0) {
			k = (k - 1) / 2;
			node[k] = max(node[2 * k + 1], node[2 * k + 2]);
		}
	}
	int query(int a, int b, int k = 0, int l = 0, int r = -1) {
		if (r < 0)r = sz;
		if (r <= a || b <= l)return -mod;
		else if (a <= l && r <= b)return node[k];
		else {
			int vl = query(a, b, 2 * k + 1, l, (l + r) / 2);
			int vr = query(a, b, 2 * k + 2, (l + r) / 2, r);
			return max(vl, vr);
		}
	}
};

P s, g;
int n;
P x[1 << 18];

map<int, int> mp;
bool comp(P a, P b) {
	if (a.first != b.first)return a.first < b.first;
	else return a.second > b.second;
}
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> s.first >> s.second >> g.first >> g.second;
	if (s.first > g.first)swap(s, g);
	cin >> n;
	rep(i, n) {
		cin >> x[i].first >> x[i].second;
	}
	if (s.second > g.second) {
		s.second = -s.second;
		g.second = -g.second;
		rep(i, n) {
			x[i].second = -x[i].second;
		}
	}
	sort(x, x + n);
	vector<int> v;
	v.push_back(s.second); v.push_back(g.second);
	rep(i, n) {
		v.push_back(x[i].second);
	}
	sort(v.begin(), v.end()); int len = unique(v.begin(), v.end()) - v.begin();
	rep(i, len) {
		mp[v[i]] = i;
	}
	segt st(len);
	st.update(mp[s.second], 0);
	vector<P> u;
	rep(i, n) {
		u.push_back(x[i]);
	}
	sort(u.begin(), u.end());
	rep(i, u.size()) {
		if (u[i].first < s.first || u[i].second < s.second || u[i].first>g.first || u[i].second>g.second)continue;
		int id = mp[u[i].second];
		int z = st.query(0, id+1) + 1;
		st.update(id, z);
	}
	int num = st.query(0, mp[g.second] + 1);
	ld d = abs(s.first - g.first) + abs(s.second - g.second);
	ld ans = d * 100 - num * (20 - 5 * pi);
	int dist = min(g.first - s.first, g.second - s.second);
	if (dist + 1 == num) {
		ans += 5 * pi;
	}
	cout << fixed << setprecision(12) << ans << endl;
	//stop
		return 0;
}

Measured memory_bytes: 16244
///
// File:  b.go
// Author: ymiyamoto
//
// Created on Sat Jun  9 16:58:59 2018
//
package main

import "fmt"

var N, X int

func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func f(a, b int) int {
	if a < b {
		return f(b, a)
	} else if a == b {
		return a
	}
	n := max((a-b)/b, 1)
	return 2*n*b + f(a-n*b, b)
}

func main() {
	fmt.Scan(&N, &X)

	fmt.Println(N + f(X, N-X))
}


Measured memory_bytes: 512
/***********************
*  Author: xuziyuan    * 
***********************/

#include <bits/stdc++.h>

#define rt0 return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define replet(c) for(char c='a';c<='z';c++)
#define LL long long
#define pii pair <int,int>
#define pb push_back
#define fi first
#define se second
#define mpr make_pair
#define sqr(a) ((a)*(a))

using namespace std;

const LL MOD=1e9+7;

int a[4];
bool vis[10];

int main()
{
	cin>>a[0]>>a[1]>>a[2]>>a[3];
	rep(i,4) vis[a[i]]=true;
	if(vis[1]&&vis[9]&&vis[7]&&vis[4]) puts("YES");
	else puts("NO");
	rt0;
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int app;
    int taste;
    
    cin>>app>>taste;
    
    vector<int> X(app);
    int count=0;
    int zero=0;
    
    for(int i=0;i<app;i++){
        X.at(i)=taste+i;
        if(X.at(i)==0)zero=1;
    }//この後全部足せ
    
    if(zero==1){//0が含まれている場合
        int allsum=0;
        for(int i:X){
            allsum+=i;
        }
        cout<<allsum<<endl;
    }else{
        for(int i=0;i<app;i++){
            if(X.at(i)<0)count++;
        }
        if(count==app){//全てマイナスの場合
            int allsum=0;
            sort(X.begin(),X.end());
            for(int i=0;i<X.size()-1;i++){
                allsum+=X.at(i);
            }
            cout<<allsum<<endl;
        }else{//全てプラスの場合
            int allsum=0;
            sort(X.begin(),X.end());
            for(int i=1;i<X.size();i++){
                allsum+=X.at(i);
            }
            cout<<allsum<<endl;
        }
    }
    
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FOR(i,a,b) for(int i=int(a);i<=int(b);i++)
#define ROF(i,a,b) for(int i=int(b);i>=int(a);i--)
#define pb push_back
#define pq priority_queue
#define ps push
#define x first
#define y second
using namespace std;
int n;
double tmp,temp,anw;
priority_queue<double,vector<double>,greater<double> > a;
int main(){
    cin>>n;
    FOR(i,1,n){
        cin>>tmp;
        a.push(tmp);
    }
    FOR(i,1,n-1){
        temp=a.top(); a.pop();
        temp+=a.top(); a.pop();
        temp/=2;
        a.push(temp);
    }
    printf("%f",a.top());
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

int main() {
  LL N; cin >> N;
  LL sum = 0;
  vector<LL> A(N);
  for (int i = 0; i < N; ++i) {
    cin >> A[i];
    sum += A[i];
  }

  LL num = (N * (N + 1LL)) / 2;
  if (sum % num) {
    cout << "NO" << endl;
    return 0;
  }

  LL k = sum / num;

  for (int i = 0; i < N; ++i) {
    LL d = A[(i + 1) % N] - A[i] - k;
    if (d > 0 || (-d) % N) {
      cout << "NO" << endl;
      return 0;
    }
  }

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


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

int main(){
    long long ans = 0;
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    int left = 0;
    int right = 0;
    int tmp = a[0];
    while (1){
        if (right == n - 1){
            ans += right - left + 1;
            left++;
            if (left > right) break;
            continue;
        }
        bool flag = true;
        for (int i = 0; i < 20; i++){
            if ((a[right + 1] >> i) & 1){
                if ((tmp >> i) & 1) flag = false;
            }
        }
        if (flag) right++, tmp ^= a[right];
        else {
            ans += right - left + 1;
            tmp ^= a[left];
            left++;
            if (left > right) right = left, tmp = a[left];
        }
        if (left == n) break;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define int long long
using namespace std;
typedef long long ll;
int n,a[200005],sum=0;
signed main(){
	cin>>n;
	for(int i=0;i<n;i++) cin>>a[i];
	for(int i=1;i<n;i++) {
		if(a[i]<a[i-1]){
			sum+=a[i-1]-a[i];
			a[i]=a[i-1];
		}
	}
	cout<<sum;
	return 0;
}

Measured memory_bytes: 5192
from collections import defaultdict,deque

fact = [1 for i in range(1000001)]
fact[1] = 0
z = 2
while 1:
    j = 2
    while z*j < 1000001:
        fact[z*j] = 0
        j += 1
    for j in range(z+1,1000001):
        if fact[j]:
            z = j
            break
    else:
        break
d = defaultdict(lambda : None)
f = [None for i in range(1000001)]
x,y,di = 0,0,"d"
f[1] = (0,0)
d[(0,0)] = 1
for i in range(2,1000001):
    if di == "d":
        if d[(x+1,y)] == None:
            x += 1
            di = "r"
        else:
            y += 1
    elif di == "r":
        if d[(x,y-1)] == None:
            y -= 1
            di = "u"
        else:
            x += 1
    elif di == "u":
        if d[(x-1,y)] == None:
            x -= 1
            di = "l"
        else:
            y -= 1
    else:
        if d[(x,y+1)] == None:
            y += 1
            di = "d"
        else:
            x -= 1
    d[(x,y)] = i
    f[i] = (x,y)
v = [[] for i in range(1000001)]
for i in range(1,1000001):
    x,y = f[i]
    for j in range(-1,2):
        if d[(x+j,y+1)] != None:
            v[i].append(d[(x+j,y+1)])

while 1:
    m,n = map(int, input().split())
    if m == n == 0:
        break
    ans = [-1 for i in range(m+1)]
    q = deque()
    q.append(n)
    ans[n] = fact[n]
    while q:
        x = q.popleft()
        for y in v[x]:
            if y <= m:
                if ans[y] < 0:
                    ans[y] = ans[x]+fact[y]
                    q.append(y)
                else:
                    if ans[x]+fact[y] > ans[y]:
                        ans[y] = ans[x]+fact[y]
    ma = max(ans)
    if ma == 0:
        print(0,0)
    else:
        for i in range(m+1)[::-1]:
            if fact[i]:
                if ans[i] == ma :
                    k = i
                    break
        print(ma, k)



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

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    priority_queue<int> q;
    rep(i,n) q.push(a[i]);
    int max_1 = q.top();
    q.pop();
    int max_2 = q.top();
    q.pop();

    rep(i,n) {
        if (a[i] != max_1) a[i] = max_1;
        else a[i] = max_2;
    }
    rep(i,n) cout << a[i] << endl;
    return 0;
}

Measured memory_bytes: 3316
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>
#include<queue>
#include<iterator>

using namespace std;

typedef long long ll;

typedef std::pair<int, int> ipair;
bool lessPair(const ipair& l, const ipair& r){return l.second < r.second;}
bool morePair(const ipair& l, const ipair& r){return l.second > r.second;}

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

const ll MOD = 1e9 + 7;
// const long long INF = 1LL<<60;
void add(long long &a, long long b) { a += b; if (a >= MOD) a -= MOD; }
void sub(long long &a, long long b) { a -= b; if (a < 0) a += MOD; }
void mul(long long &a, long long b) { a *= b; a %= MOD; }
ll llmin(ll a, ll b) { if (a < b) return a; else return b; }
ll llmax(ll a, ll b) { if (a < b) return b; else return a; }
ll llabs(ll a) { if (a >= 0) return a; else return - a; }
ll llmodpow(ll a, ll n) {
   if (n == 0) return 1;
   ll tmp = llmodpow(a, n / 2);
   mul(tmp, tmp);
   if (n & 1) mul(tmp, a);
   return tmp;
}

int main() {
   string S;
   cin >> S;
   int N = (int)S.size();
   int cntR = 0;
   int cntL = 0;
   int ans[N];
   memset(ans, 0, sizeof(ans));
   map<int, ipair> log;
   int tmp = 0;
   for (int i = 0; i < N; i++) {
      if (S[i] == 'R') cntR++;
      else cntL++;
      if (i > 0 && S[i] == 'L' && S[i - 1] == 'R') {
         tmp = i - 1;
      }
      if (i > 0 && S[i] == 'R' && S[i - 1] == 'L') {
         log[tmp] = ipair(cntL - 1, cntR - 2);
         // cout << i - 1 << " " << cntL - 1 << " " << cntR - 1 << endl;
         cntL = 0;
         cntR = 1;
      }
   }
   log[tmp] = ipair(cntL - 1, cntR - 1);
   for (auto it = log.begin(); it != log.end(); it++) {
      int i = it->first;
      cntR = it->second.second;
      cntL = it->second.first;
      // cout << i << " " << cntR << " " << cntL << endl;
      if ((cntR + cntL) % 2 == 0) {
         ans[i] = (cntR + cntL) / 2 + 1;
         ans[i + 1] = (cntR + cntL) / 2 + 1;
      } else {
         if (cntL % 2 == 0) {
            ans[i] = (cntR + cntL) / 2 + 1;
            ans[i + 1] = (cntR + cntL) / 2 + 2;
         } else {
            ans[i + 1] = (cntR + cntL) / 2 + 1;
            ans[i] = (cntR + cntL) / 2 + 2;
         }
      }
   }
   for (int i = 0; i < N; i++) {
      cout << ans[i] << " ";
   }
   cout << endl;
   return 0;
}


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

class Problem
{
    public static void Main(string[] args)
    {
            var s = Console.ReadLine();
            if (s.Where(c => c == 'a').Count() == 1 && s.Where(c => c == 'b').Count() == 1 && s.Where(c => c == 'c').Count() == 1) Console.WriteLine("Yes");
            else Console.WriteLine("No");    }
}

Measured memory_bytes: 11220
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
lint N, M;
lint dp[100100];
vector<vector<lint> > G;

lint rec(lint start){
  if(dp[start] != -1) return dp[start];
  lint ans = 0;
  for(auto next : G[start]){
    ans = max(ans, rec(next) + 1);
  }
  return dp[start] = ans;
}

signed main(){
  cin >> N >> M;
  memset(dp, -1, sizeof(dp));
  G.resize(N);
  for(lint i = 0; i < M; i++){
    lint x, y; cin >> x >> y;
    G[x - 1].push_back(y - 1);
  }
  lint ans = 0;
  for(lint i = 0; i < N; i++){
    ans = max(ans, rec(i));
  }
  cout << ans << endl;
}


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

using namespace std;

#define int 		long
#define endl		"\n"
#define mod			1000000007
#define IOS			ios::sync_with_stdio(0), cin.tie(0)

int32_t main() {

	IOS;

	int n;
	cin >> n;
	vector<int> v(n);

	for (int i = 0; i < n; i++)
		cin >> v[i];

	sort(v.begin(), v.end());
	vector<int> freq(1000001);

	for (int i = 0; i < n; i++) {

		if (freq[v[i]])
			continue;
		if (i + 1 < n && v[i] == v[i + 1]) {
			freq[v[i]]++;
		}

		for (int j = v[i] * 2; j <= v[n - 1]; j += v[i])
			freq[j]++;
	}

	int ans = 0;

	for (int i = 0; i < n; i++)
		if (!freq[v[i]])
			ans++;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 12700
a=list(map(int,input().split()))
k,h=a[1],a[1]
k+=a[0]-a[0]%2
k+=a[3]-a[3]%2
k+=a[4]-a[4]%2
if min(a[0],a[3],a[4])>0:
    h+=3
    a[0],a[3],a[4]=a[0]-1,a[3]-1,a[4]-1
    h+=a[0]-a[0]%2
    h+=a[3]-a[3]%2
    h+=a[4]-a[4]%2
print(max(k,h))

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

int main()
{
    ll n, m;
    cin >> n >> m;
    vector<ll> h(n);
    vector<set<ll>> mat(n, set<ll>());
    rep(i, n){
        cin >> h[i];
    }
    rep(i, m){
        ll a, b;
        cin >> a >> b;
        mat[a-1].insert(b-1);
        mat[b-1].insert(a-1);
    }

    ll ans = 0;
    rep(i, n){
        bool flg = true;
        for(auto& other : mat[i]) {
            if (h[i] <= h[other] ) {
                flg = false;
                break;
            }
        }
        if (flg){
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 17972
#include <bits/stdc++.h>
#define fst first
#define snd second
#define rep(n) for(lint I = 0; (I) < (lint)(n); ++(I))
#define repeat(i, n) for(lint i = 0; (i) < (lint)(n); ++(i))
#define repeat_to(i, n) for(lint i = 0; (i) <= (lint)(n); ++(i))
#define repeat_from(i, m, n) for(lint i = (m); (i) < (lint)(n); ++(i))
#define repeat_from_to(i, m, n) for(lint i = (m); (i) <= (lint)(n); ++(i))
#define repeat_reverse_from_to(i, m, n) for(lint i = (m); (i) >= (lint)(n); --(i))
#define el cout<<endl
#define es cout<<" "
#define dump(x) cout<<" "<<#x<<"="<<x
#define pdump(p) cout<<" "<<#p<<"=("<<p.fst<<","<<p.snd<<")"
#define vdump(v) for(size_t I=0; I<v.size(); ++I){cout<<" "<<#v<<"["<<I<<"]="<<v[I];} cout<<endl
using namespace std; using lint = long long; using ld = long double;
using pii = pair<int, int>; using pll = pair<lint, lint>;
template<class T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<class T, class... Ts> 
auto make_vec(size_t a, Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));}

int main(void) {
    lint n, m;
    cin >> n >> m;
    vector<lint> a(n);
    repeat (i, n) cin >> a[i];
    sort(a.begin(), a.end());
    
    vector<pll> x(m);
    repeat (i, m) cin >> x[i].fst >> x[i].snd;
    sort(x.begin(), x.end(), [](pll a, pll b){return a.snd > b.snd;});
    
    int idx = 0;
    repeat (i, n) {
        if (x[idx].fst == 0) {
            ++idx;
        }
        if (idx >= m) break;
        if (x[idx].fst > 0) {
            if (a[i] < x[idx].snd) {
                a[i] = x[idx].snd;
                x[idx].fst -= 1;
            }
            else break;
        }
        //vdump(a); pdump(x[idx]); el;
    }
    cout << accumulate(a.begin(), a.end(), 0LL) << endl;
}

Measured memory_bytes: 2560
from fractions import gcd
n=int(input())
a=list(map(int,input().split()))
r=[a[-1]]
l=[a[0]]
for i in range(1,n-1):
    l.append(gcd(l[i-1],a[i]))
    r.append(gcd(r[i-1],a[-1-i]))
ans=r[-1]    
for i in range(n-2):
    ans=max(ans,gcd(l[i],r[-2-i]))
ans=max(ans,l[-1])
print(ans)

Measured memory_bytes: 16148
#include<stdio.h>
int main(void)
{
	int n,m,i,b=0;
	int a[100],t=0;

	scanf("%d %d",&n,&m);

	for(i=0;i<=n-1;i++){
		scanf("%d",&a[i]);
		t=t+a[i];

	}
	for(i=0;i<=n-1;i++){
		if(a[i]*4*m>=t){
	b++;
}
}

	if(b>=m)
	 printf("Yes");
        else
           printf("No");

     return 0;
}


Measured memory_bytes: 1728
n, m=map(int, input().split())
AC, WA=[0]*n, [0]*n
ac, wa=0, 0
for _ in range(m):
  p, s=list(map(str, input().split()))
  p=int(p)-1
  if AC[p]==0 and s=='WA':
    WA[p]+=1
  elif AC[p]==0 and s=='AC':
    AC[p]=1
    wa+=WA[p]
    ac+=1
  
print(ac, wa)

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

using namespace std;
const int N = 100000+5;

int main () {
    // L_i = gcd(A_1, A_2, A_3, ... A_i)
    // R_i = gcd(A_i, A_{i+1}, A_{i+1}, ..., A_n)
    int n;
    int A[N];
    int R[N];
    int L[N];

    cin >> n;
    for (int i=1; i<=n; i++) {
        cin >> A[i];
        L[i] = A[i];
        R[i] = A[i];
    }

    // precomputing L[i]
    for (int i=1; i<=n; i++) {
        L[i] = __gcd(L[i], L[i-1]);
    }
    // precomputing R[i]
    for (int i=n; i>0; i--) {
        R[i] = __gcd(R[i], R[i+1]);
    }

    // computing each m_i and the max value
    int res = 0;
    for (int i=1; i<=n; i++) {
        int m = __gcd(L[i-1], R[i+1]);
        if (m > res) {
            res = m;
        }
    }

    cout << res;
    return 0;
}


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

using namespace std;

int main(){
  long long n;
  cin>>n;
  string s="";
  while(n){
	s=char('a'+(n-1)%26)+s;
    n=(n-1)/26;
  }
  cout<<s;
  return 0;
}


Measured memory_bytes: 3628