akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#define tr(a,b) (a)+=(b);(b)=(a)-(b);(a)-=(b);

main(){
    int N;
    int i;
    int max,min;

    scanf("%d",&N);

    int a[N];

    for(i=0;i<N;i++)
        scanf("%d",a+i);

    min=1001;
    max=-1;
    for(i=0;i<N;i++){
        if(min>a[i])
            min=a[i];
        if(max<a[i])
            max=a[i];
    }

    printf("%d\n",max-min);

    return 0;
}

Measured memory_bytes: 128
n, k = [int(x) for x in input().split()]
a = [0 for _ in range(n + 1)]
while k:
    d = int(input())
    x = [int(x) for x in input().split()]
    for e in x:
        a[e] += 1
    k -= 1
ans = -1
for e in a:
    if not e:
        ans += 1
print(ans)


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

#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

#define MAXX 500005
#define INF INT_MAX

#define PI   3.14159265358979323846264338327950

#define PB push_back
#define PF push_front
#define F first
#define S second

#define fixx(n) fixed << setprecision(n)

#define ll 	 long long

#define mod  1000000007

map<int, bool> mp;
map<int, int> mp1;
int main()
{
	FAST;
	int n, m;
	cin >> n >> m;
	int p[m+6];
	string s[m+6];
	ll ans = 0;
	int a1 = 0;
	for(int i = 0; i < m; i ++){
		cin >> p[i] >> s[i];
		if(s[i] == "AC" && !mp[p[i]] ){
			a1 ++;
			ans += mp1[p[i]];
			mp[p[i]] = true;
		}
		if(!mp[p[i]] && s[i] == "WA"){
			mp1[p[i]] ++;
		}
	}
	cout << a1 << " " << ans;
	return 0;
}

Measured memory_bytes: 16448
n,m=map(int,input().split())
h = list(map(int,input().split()))
a = [list(map(int,input().split())) for j in range(m)]
# print("h:",h)
# print("a",a)
can_go = [[] for i in range(n)]
# print(can_go)
for i in a:
    # print(i)
    can_go[i[0]-1].append(i[1])
    can_go[i[1]-1].append(i[0])
# print(can_go)
b = 0
ans=0
for i,j in enumerate(can_go):
    # for j in can_go:
    b= 0

    for k in j:
        # print( h[k-1]-h[i])
        if h[k-1]>=h[i]:
            b=1
            # print("break")
            break
    if b==1:
        b=0
    else:
        ans+=1
print(ans)

Measured memory_bytes: 41248
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>

using namespace std;
int main() {
    int N;
    cin >> N;
    long long plus = 0;
    long long minus = 0;
    long long A[N];
    long long B[N];
    for(int i = 0; i < N; i++){
        cin >> A[i];
    }
    for(int i = 0; i < N; i++){
        cin >> B[i];
    }
    for(int i = 0; i < N; i++){
        long long tmp = B[i] - A[i];
        if(tmp > 0){
            if(tmp % 2 == 1){
                tmp--;
            }
            plus += tmp;
        }else{
            minus += -tmp;
        }
    }
    if(plus >= minus * 2){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 384
#include <iostream>

using namespace std;

int
main()
{
        int x, a, b, ax, bx;

        cin >> x >> a >> b;
        ax = abs(a - x);
        bx = abs(b - x);

        if (ax < bx) {
                cout << "A" << endl;
        } else {
                cout << "B" << endl;
        }
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
void func (int cnt,int nowN,int nowS);
int n,s,ans=0;
int main()
{
    while(1){
        scanf("%d%d",&n,&s);
        if(n==0&&s==0)break;
        func (0,0,0);
        printf("%d\n",ans);
        ans=0;
    }
    return 0;
}
void func (int cnt,int nowN,int nowS)
{
    if(cnt==10){
        if(nowN==n&&nowS==s)ans++;
        return;
    }
    /*
    if(cnt==10)return;
    if(cnt==9&&nowN==n&&nowS==s)ans++;
    */

    func(cnt+1,nowN+1,nowS+cnt);//?????¶
    func(cnt+1,nowN,nowS);//?????°??????
}

Measured memory_bytes: 1188
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll a,b,c;
  cin >> a >> b >> c;
  ll ans = 1e16;
  if(a * b * c % 2 == 0) ans = 0;
  else ans = min(a*b, min(b*c, c*a));
  cout << ans << '\n';
  return 0;
}

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

#define REP(i,n) for(int i=0;i<(n);i++)
#define REAP(i,a,n) for(int i=(a);i<(n);i++)
#define YES cout<<"Yes"<<endl
#define NO cout<<"No"<<endl
#define fr first
#define sc second
#define pb push_back
#define All(v) v.begin(),v.end()
typedef long long ll;

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

    int r;
    cin >> r;
    if(r<1200)cout << "ABC\n";
    else if(r<2800)cout << "ARC\n";
    else cout << "AGC\n";

    return 0;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i < (n); i++)
#define lower(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
using namespace std;
using ll = long long;
int INF = 1001001001;

int main() {
  ll a, b, k;
  cin >> a >> b >> k;
  if(k > 0 && k <= a) {
    a -= k;
  } else if (k > a && k <=a+b) {
    b = a + b - k;
    a = 0;
  } else if (k > a + b) {
    a = b = 0;
  }
  printf("%lld %lld\n", a, b);
  return 0;
}

Measured memory_bytes: 3760
H,W = input().split()
H = int(H)
W = int(W)

ans = [[0 for i in range(W+1)] for j in range(H+1)]


S = []
for i in range(H):
    raw = input()
    S.append(raw)

for i in range(H):
    for j in range(W):
        temp = 0
        if S[i][j] == "#":
            ans[i][j] = "#"
            for k in range(3):
                for l in range(3):
                    if i+k >0 and j+l >0:
                        if ans[i+k-1][j+l-1] != "#":
                            ans[i+k-1][j+l-1] +=1


for i in range(H):
    for j in range(W):
        print(str(ans[i][j]), end="")
    print("")


Measured memory_bytes: 44140
import java.util.Scanner;

public class Main {
	static String ans="Yay!";
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//Map<Long,Integer>map=new HashMap<>();
		int n=5;
		int sum=0;int rim=0;
		int a[]=new int[n];
		for(int i=0;i<n;i++) {
			a[i]=sc.nextInt();
		}
		for(int i=0;i<n;i++) {
			if(a[i]%10==0)sum+=a[i];
			else {
				rim=Math.max(rim,10-(a[i]%10));
				sum+=10-(a[i]%10)+a[i];
			}
		}
		System.out.println(sum-rim);
	}
}


Measured memory_bytes: 21844
import java.util.*;
import java.util.stream.*;

public class Main {

    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {

            int N = sc.nextInt();
            long[] A = new long[N];
            for (int i = 0; i < N; i++) {
                A[i] = sc.nextLong();
            }

            int min = Arrays.stream(A).mapToInt(a -> {
                int ret = 0;
                for (int i = 1; i < 50; i++) {
                    if (((a >> i) << i) != a) {
                        ret = i - 1;
                        break;
                    }
                }
                return ret;
            }).min().getAsInt();

            System.out.println(min);

        }
    }

}

Measured memory_bytes: 26704
import java.util.Scanner;

class Main {

    public static void main(String[] args)  {
	Scanner sc = new Scanner(System.in);

	int N, M;
	N = sc.nextInt();
	M = sc.nextInt();

	int L[] = new int[M];
	int R[] = new int[M];
	for (int i = 0; i < M; i++) {
	    L[i] = sc.nextInt();
	    R[i] = sc.nextInt();
	}

	int l = L[0];
	int r = R[0];
	for (int i = 1; i < M; i++) {
	    if (l < L[i])
		l = L[i];
	    if (r > R[i])
		r = R[i];
	}

	if (r - l < 0)
	    System.out.println(0);
	else
	    System.out.println(r - l + 1);
    }
}

Measured memory_bytes: 83044
import java.io.*;
public class Main {

    private static int N;
    private static long[] divisors = new long[10000001];

    private static long result = 0;
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));

        N = Integer.parseInt(br.readLine());



        for (int i = 1; i <= 10000000; i++) {
            for (int j = 1; j <= 10000000 / i; j++) {
                if(i*j > 10000000)break;
                divisors[i * j]++;
            }
        }

        for(int i=1;i<=N;i++){
            result += divisors[i] * i;
        }
        System.out.println(result);


    }
}


Measured memory_bytes: 112496
#include<stdio.h>
int main()
{
    int n, y;
    scanf("%d %d", &n, &y);
    y /= 1000;
    int a, b, c;
    for (a = 0; a <= n; a++)
    {
        for (b = 0; b <= n - a; b++)
        {
            c = n - a - b;
            if (10 * a + 5 * b + c == y)
            {
                printf("%d %d %d\n", a, b, c);
                return 0;
            }
        }
    }
    printf("-1 -1 -1\n");
    return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <iostream>
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
typedef pair<int,int> Pint;
//typedef pair<ll, ll> P;
typedef pair<int, pair<int, int>> P;
//typedef tuple<int,int,int> T;
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 2147483600;//10^9
ll MOD  = 1000000007;
//vector<int> dy = {0,0,1,-1, 0, 1, 1, -1, -1}, dx = {1,-1,0,0, 0, 1, -1, 1, -1};
//vector<int> dy = {0, 0, 1, -1}, dx = {1, -1, 0, 0};



int main(void){
    cin.tie(0);
   	ios::sync_with_stdio(false);
    int A, B;
    cin >> A >> B;
    if(A <= 5){
        B = 0;
    }
    if(6 <= A && A <= 12){
        B /= 2;
    }
    cout << B << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<deque>
#define jio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
//#define mp make_pair
#define pb push_back
#define lld long long int
#define clr clear()
#define ff first
#define ss second
#define N 1000005
//#define M 1000
#define endl '\n'
#define c_s_b() __builtin_popcount()

#define sze 10000009
#define pii pair<int,int>
#define big 100009
#define int long long

using namespace std;

int n,m;
vector<int>adj[big];
int dp[big];
void add_edge(int x,int y){
    adj[x].pb(y);
}

int dfs(int src){
   //int len=0;
   //if(adj[src].size()==0) return 0;
   if(dp[src]!=-1) return dp[src];
   int len=0;
   for(int i=0;i<adj[src].size();i++){
       int node=adj[src][i];
        len=max(len,dfs(node)+1);
        dp[src]=len;


   }
   return len;


}


int32_t main(){
   jio;
    cin>>n>>m;
    for(int i=0;i<big;i++) adj[i].clr;
    int x,y;
    while(m--){
        cin>>x>>y;
        add_edge(x,y);
    }
    int max_len=INT_MIN;
    memset(dp,-1,sizeof(dp));
    int len;
    for(int i=1;i<=n;i++){
        len=dfs(i);
        max_len=max(len,max_len);

    }
    cout<<max_len<<endl;



    return 0;


}


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


  
int main(){
  long n,count;
  string s,r;
  cin >> s;
  n =  s.length();
  r = '0';
  for(long i ; i < n-1 ; i++){
    r +='0';
  }
  for(long j; j < n ; j+=2){
    r.at(j)='1';
  }
  for(long k ; k < n ; k++){
    if(s.at(k)==r.at(k))
      count++;
  }
  if(count>n/2)
    count=n-count;
  cout << count << endl;
      }

Measured memory_bytes: 640
import sys
sys.setrecursionlimit(10**8)
input = sys.stdin.readline
import bisect

N,Q = map(int,input().split())
# STX = [list(map(int,input().split())) for _ in range (N)]
STX = []
vals = set()
for _ in range(N):
    s,t,x = map(int,input().split())
    STX.append((max(0,s-x), max(0,t-x), x))
    vals.add(max(0,s-x))
    vals.add(max(0,t-x))
D = [int(input()) for _ in range(Q)]
for d in D:
    vals.add(d)
vals = list(vals)
vals.sort()
L = len(vals)
mapping = [-1]*(L+1)
imos = [[] for _ in range(L+1)]
STX.sort(key=lambda x:x[2])
priority = 0 
for s,t,x in STX:
    s1 = bisect.bisect_left(vals, s)
    t1 = bisect.bisect_left(vals, t)
    imos[s1].append([1, priority, x])
    imos[t1].append([0, priority, x])
    priority += 1

import heapq
cur = -1
cur_priority = 10**9
que = [(cur_priority, cur)]
valid_priority = [True]*(N+1)
for i in range(L+1):
    for f,p,x in  imos[i]:
        if f:
            heapq.heappush(que, (p, x))
        else:
            valid_priority[p] = False
    
    while que[0][1]!=-1 and valid_priority[que[0][0]]==False:
        heapq.heappop(que)
    mapping[i] = que[0][1]

for d in D:
    d1 = bisect.bisect_left(vals, d)
    print(mapping[d1])



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

int main() {
    int N;
    cin >> N;
    vector<int> t(N), x(N), y(N);
    bool check = true;
    for (int i = 0; i < N; i++) {
        cin >> t[i] >> x[i] >> y[i];
        int distance, time;
        if (i != 0) {
            distance = abs(x[i] - x[i - 1]) + abs(y[i] - y[i - 1]);
            time = t[i] - t[i - 1];
        } else {
            distance = abs(x[i]) + abs(y[i]);
            time = t[i];
        }
        if (time < distance || time % 2 != distance % 2) {
            check = false;
        }
    }
    cout << (check ? "Yes" : "No") << endl;
}


Measured memory_bytes: 1408
# problem 7
# cell inversion
N = int(input())
S = input()
if S[0]=="W":
    print(0)
    exit()
mod = 10**9 + 7
D = [-1]  # left -1 right 1
for i in range(2*N-1):
    if S[i] != S[i+1]:
        D.append(D[-1])
    else:
        D.append(D[-1]*(-1))
left = []
for i in range(2*N):
    if D[i] < 0:
        left.append(i)
sums = [0 for i in range(2*N)]
for i in range(2*N):
    if D[i] > 0:
        sums[i] += 1
for i in range(2*N-2, -1, -1):
    sums[i] += sums[i+1]
ans = 1
for i in range(2, N+1):
    ans *= i
    ans %= mod
if len(left)!=N:
    print(0)
    exit()
for i in range(N):
    ans *= sums[left[i]]-(N-1-i)
    ans %= mod
print(ans)


Measured memory_bytes: 24624
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define sz(c) ((int)(c).size())
 
using namespace std;

int main() {
    long long n, x;
    cin >> n >> x;
    long long l[n];
    rep(i, n) cin >> l[i];

    long long count = 1;
    long long acc = 0;
    for(auto i = 0; i < n; i++) {
        acc += l[i];
        if(acc <= x) {
            count += 1;
        }
    }
    cout << count << endl;
}


Measured memory_bytes: 256
import sys
input = lambda: sys.stdin.readline().rstrip()
N = int(input())
C = [int(a) - 1 for a in input().split()]
X = [[] for i in range(N)]
head = [-1] * (N + 1)
to = [0] * (N - 1 << 1)
nxt = [0] * (N - 1 << 1)
for i in range(N-1):
    x, y = map(int, input().split())
    x, y = x-1, y-1
    nxt[i] = head[x]
    to[i] = y
    head[x] = i
    j = i + N - 1
    nxt[j] = head[y]
    to[j] = x
    head[y] = j

def EulerTour(n, i=0):
    f = lambda k: k * (k + 1) // 2
    USED = [0] * n
    ORG = [0] * n
    TMP = [0] * n
    ANS = [f(n)] * n
    
    P = [-1] * n
    ct = 0
    ET1 = [0] * n
    ET2 = [0] * n
    while i >= 0:
        e = head[i]
        if e < 0:
            ET2[i] = ct
            USED[C[i]] += 1 + TMP[i]
            if i:
                k = ET2[i] - ET1[i] + 1 - USED[C[P[i]]] + ORG[i]
                ANS[C[P[i]]] -= f(k)
                TMP[P[i]] += k
            i = P[i]
            continue
        
        j = to[e]
        if P[i] == j:
            head[i] = nxt[e]
            continue
        
        P[j] = i
        head[i] = nxt[e]
        i = j
        ORG[i] = USED[C[P[i]]]
        ct += 1
        ET1[i] = ct
    
    for i in range(n):
        ANS[i] -= f(n - USED[i])
    return ANS

print(*EulerTour(N, 0), sep = "\n")

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

using namespace std;

int main() {
    int a, b;
    cin >> a >> b;
    if (a >= 13) {
        cout << b << endl;
    } else if (a >= 6) {
        cout << b/2 << endl;
    } else {
        cout << 0 << endl;
    }
	return 0;
}

Measured memory_bytes: 764
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

using namespace std;
using namespace __gnu_pbds; 
  
#define ll long long
#define X first
#define Y second
#define all(x) x.begin(), x.end()
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
	enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
	ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
	*this << "[";
	for (auto it = d.b; it != d.e; ++it)
		*this << ", " + 2 * (it == d.b) << *it;
	ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

const int mod = 1e9 + 7;
const int MX = (int)2e5;

void add_self(int &x, int y){x += y; if(x >= mod) x -= mod;}
void sub_self(int &x, int y){x -= y; if(x < 0) x += mod;}
void mul(int &x, int y){x = x * 1LL * y % mod;}

int main(){

	cin.tie(0); cout.tie(0);
	ios_base::sync_with_stdio(0);

	// int n, k;
	// cin >> n >> k;
	// vector<array<int, 2>> vec(n);
	// bool zero = false;
	// for(auto &p : vec){
	// 	cin >> p[0];
	// 	p[1] = p[0] < 0; // neg
	// 	p[0] = abs(p[0]);
	// 	if(p[0] == 0) zero = true;
	// }
	// sort(all(vec));

	// int res = 1;

	// cout << res << endl;

	int n;
	cin >> n;
	vector<int> vec(n);
	for(auto &x : vec) cin >> x;
	sort(all(vec));
	ll res = vec[n - 1];
	int need = n - 2;
	for(int i = n - 2; need && i >= 1; --i){
		int can = min(need, 2);
		while(can--) res += vec[i], need--;
	}

	cout << res << endl;

	return 0;
}


Measured memory_bytes: 3996
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
ll N,K;
int main(){
  cin>>N>>K;
  vector<ll>A(N);
  for(ll i=0;i<N;i++)
    cin>>A[i];
  ll a=1;
  if(K==0){
  ll ans=0;
    for(ll i=0;i<N;i++)
      ans+=(0^A[i]);
    cout<<ans<<endl;
  }else{
  while(a<=K)a*=2; a/=2;
  ll sum=0;
  while(1){
  ll sum1=0;ll sum2=0;
    for(ll i=0;i<N;i++){
    sum1+=(a^A[i]);
      sum2+=(0^A[i]);
    }
      if(sum2<=sum1 && sum+a<=K)sum+=a;
      if(a==1)break;
      else
        a/=2;
      }ll ans=0;
    for(ll i=0;i<N;i++)
      ans+=(sum^A[i]);
    cout<<ans<<endl;
  }
  return 0;
}

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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define ALL(x) x.begin(),x.end()
#define EPS (1e-8)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

typedef long long ll;
typedef pair<int,int> ii;

inline bool LT(double a,double b) { return !equals(a,b) && a < b; }
inline bool LTE(double a,double b) { return equals(a,b) || a < b; }

struct Data { ll l, r; };
int n;
ll L;
vector<Data> segs;

bool cmp1(Data d1, Data d2) {
  if( d1.l != d2.l ) return d1.l < d2.l;
  return d1.r > d2.r;
}

int solve1() {
  sort(ALL(segs),cmp1);
  assert( segs[0].l == 0 );
  ll cur = segs[0].r-1LL;
  int mini = 1;
  ll maxi = segs[0].r-1LL;
  REP(i,1,n) {
    if( cur < segs[i].l ) {
      int j = i;
      while( j < n && cur + 1LL == segs[j].l ) {
	maxi = max(maxi,segs[j].r-1LL);
	++j;
      }
      i = j;
      cur = maxi-1LL;
      ++mini;
    }
    maxi = max(maxi,segs[i].r);
  }
  if( cur != L-1LL ) ++mini;
  return mini;
}

#define IN 1
#define OUT 0
struct Event {
  ll p;
  int type;
  bool operator < ( const Event &e ) const {
    if( p != e.p ) return p < e.p;
    return type > e.type;
  }
};


 

int solve2() {
  deque<Event> deq;
  rep(i,n) {
    deq.push_back((Event){segs[i].l, IN});
    deq.push_back((Event){segs[i].r, OUT});
  }
  sort(ALL(deq));
  int maxi = 0;
  int sum = 0;
  
  while( !deq.empty() ) {
    Event e = deq.front(); deq.pop_front();
    if( e.type == OUT ) {
      //cout << "[OUT] sum = " << sum << ", e.p = " << e.p << ", " << e.type << " : " << n-sum+1 << endl;
      maxi = max(maxi,n-sum+1);
    }
    
    if( e.type == IN ) ++sum;
    else               --sum;
    while( !deq.empty() && e.p == deq.front().p && e.type == deq.front().type ) {
      deq.pop_front();
      if( e.type == IN ) ++sum;
      else               --sum;
    }
    if( e.type == IN ) {
      //cout << "[IN] sum = " << sum << ", e.p = " << e.p << ", " << e.type << " : " << n-sum+1 << endl;
      maxi = max(maxi,n-sum+1);
    }
  }
  return maxi;
}

void compute() {
  int ans1 = solve1();
  int ans2 = solve2();
  cout << ans1 << " " << ans2 << endl;
}

int main() {
  cin >> n >> L;
  segs.resize(n);
  rep(i,n) {
    cin >> segs[i].l >> segs[i].r;
  }
  compute();
  return 0;
}



Measured memory_bytes: 12028
class Union_Find:
    def __init__(self, N):
        self.N = N
        self.par = [i for i in range(N)]
        self.height = [0 for i in range(N)]
        self.size = [1 for i in range(N)]
    def Find(self, x):
        if self.par[x] == x:
            return x
        self.par[x] = self.Find(self.par[x])
        return self.par[x]
    def Size(self, x):
        return self.size[self.Find(x)]
    def Union(self, x, y):
        x, y = self.Find(x), self.Find(y)
        if x == y:
            return
        if self.height[x] < self.height[y]:
            self.par[x] = y
            self.size[y] += self.size[x]
        else:
            self.par[y] = self.par[x]
            self.size[x] += self.size[y]
            if self.height[x] == self.height[x]:
                self.height[x] += 1
    def Same(self, x, y):
        return self.Find(x) == self.Find(y)

from collections import defaultdict
N, M = map(int, input().split())
bs, res, uf, y, dic = [], [], Union_Find(N), N * (N - 1) // 2, defaultdict(int)
for _ in range(M):
    bs.append(list(map(lambda x: int(x) - 1, input().split())))
for b in bs[::-1]:
    res.append(y)
    if not uf.Same(b[0], b[1]):
        y -= uf.Size(b[0]) * uf.Size(b[1])
    uf.Union(b[0], b[1])
for r in res[::-1]:
    print(r)


Measured memory_bytes: 36868
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>


int main()
{long long int n,l,sum=0,i,j,flag=0,temp,t=0;
scanf("%lld%lld",&n,&l);
long long int arr[n];
for(i=1;i<=n;i++)
{
    arr[i]=l+i-1;
    if(arr[i]==0)
    flag=1;
}
for(i=1;i<=n-1;i++)
{
    for(j=i+1;j<=n;j++)
    {
        if(arr[i]>arr[j])
        {t++;
            temp=arr[i];
            arr[i]=arr[j];
            arr[j]=temp;
            
        }
       
    }
}

if(arr[1]>0)
{arr[1]=0;
    for(i=1;i<=n;i++)
    sum=sum+arr[i];
}

else if(arr[1]<=0 && flag==0)
{
    arr[n]=0;
    for(i=1;i<=n;i++)
    sum=sum+arr[i];
}
else if(arr[1]<=0 && flag==1)
{
for(i=1;i<=n;i++)
 sum=sum+arr[i];
}

printf("%lld",sum);











return 0;
}  
    
    
    
    
    
    
    


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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;

#define rep(i, j, k) for (int i = j; i < k; i++)
#define pb push_back
#define all(x) x.begin(), x.end()
#define mt make_tuple

#define iv inline void
#define ii inline int
#define ill inline ll

template <typename S, typename T>
inline bool smin(S &l, T r) {
  return r < l ? l = r, 1 : 0;
}
template <typename S, typename T>
inline bool smax(S &l, T r) {
  return l < r ? l = r, 1 : 0;
}

constexpr int MOD = 1e9 + 7;  // 998244353;

template <typename S>
inline S mod(S &l) {
  return l = (l % MOD + MOD) % MOD;
}
template <typename S, typename T>
inline S add(S &l, T r) {
  return mod(l += r);
}
ill po(ll v, ll u) {
  return u ? po(v * v % MOD, u >> 1) * (u & 1 ? v : 1) % MOD : 1;
}

void fileIO(string s) {
  freopen((s + ".in").c_str(), "r", stdin);
  freopen((s + ".out").c_str(), "w", stdout);
}

constexpr int N = 3e3 + 10;

int n, A[N], B[N];
string s;

string dp[N];

int main() {
#ifndef LOCAL
  // fileIO("");
#endif

  cin >> n >> s;

  int lptr = 0, rptr = 0;
  rep(i, 0, 2 * n) {
    if (s[i] == 'a')
      A[lptr++] = i;
    else
      B[rptr++] = i;
  }

  for (int i = n - 1; ~i; i--) {
    dp[i] = dp[i + 1];
    if (A[i] < B[i]) {
      int j = i;
      while (j < n && A[j] < B[i]) j++;
      smax(dp[i], "ab" + dp[j]);
    } else {
      set<int> st;
      st.insert(A[i]);
      st.insert(B[i]);
      int j = i + 1;
      while (j < n && min(A[j], B[j]) < *st.rbegin()) {
        st.insert(A[j]);
        st.insert(B[j]);
        j++;
      }
      string t = "";
      for (auto e : st) t.pb(s[e]);
      smax(dp[i], t + dp[j]);
    }
  }

  cout << dp[0] << endl;

  return 0;
}


Measured memory_bytes: 14976
n = int(input())
s = input()
e = [0]
w = [s[1:].count('E')]
for i in range(1, n):
  e.append(e[-1]+(s[i-1]=='W'))
  w.append(w[-1]-(s[i]=='E'))
print(min(a+b for a,b in zip(e,w)))

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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  
  int n;
  cin >> n;
  
  vector<ll> a(n);
  vector<ll> b(n);
  
  rep(i, 0, n) {
    cin >> a[i];
    b[a[i]-1]++;
  }
  
  ll ans = 0;
  rep(i, 0, n)
    ans += b[i]*(b[i]-1)/2; 
  
  rep(i, 0, n) {
      ll answer = ans - b[a[i]-1]*(b[a[i]-1]-1)/2 + (b[a[i]-1]-1)*(b[a[i]-1]-2)/2;
      cout << answer << "\n";
  }

}


Measured memory_bytes: 5760
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <complex>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << #x << " = " << (x) << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100010


int main(){
  int n;
  int a[SIZE], ans = 0;
  
  scanf("%d",&n);

  for(int i=0;i<n;i++){
    scanf("%d",a+i);
  }

  int  counter = 0;
  
  for(int i=1;i<=n;i++){
    if(i == a[i-1]){
      counter++;
    }else{
      ans += (counter+1)/2;
      counter = 0;
    }
  }

  ans += (counter+1)/2;

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


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


void solve(long long N, long long K, long long S){
    for(int i = 0;i < K;i++){
        cout<<S<<" ";
    }
    for(int i = 1;i <= 1e9;i++){
        if(S % i != 0){
            for(int j = K;j < N;j++){
                cout<<i<<" ";
            }
            break;
        }
    }
    cout<<endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    long long S;
    scanf("%lld",&S);
    solve(N, K, S);
    return 0;
}


Measured memory_bytes: 1280
import sys
import itertools
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
XY = [lr() for _ in range(N)]
XY = [x + y * 1j for x, y in XY]

cen_cand = [] # list of candidates which is center of a cercle
'''
z = (ab(a-b).conjugete()) / (a.conjugate()*b-a*b.conjugate())
'''
def find_center(a, b, c):
    #cを原点とする
    a -= c; b -= c
    if abs((a * b.conjugate()).imag) < 0.5:
        # 同一直線上
        return None
    num = a * b * (a-b).conjugate()
    den = a.conjugate() * b
    den -= den.conjugate()
    return (num / den) + c

for comb in itertools.combinations(XY, 3):
    o = find_center(*comb)
    if o is None:
        continue
    cen_cand.append(o)

for a, b in itertools.combinations(XY, 2):
    o = (a+b) / 2
    cen_cand.append(o)

cen_cand = np.array(cen_cand); XY = np.array(XY)
answer = np.abs(cen_cand[:, None] - XY[None, :]).max(axis=1).min()
print(answer)
# 28

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

int main() {
	
	// input
	int n, m;
	cin >> n >> m;
	
	string image [n];
	string templ [m];
	
	for (int i = 0; i < n; i++) {
		cin >> image[i];
	}
	for (int i = 0; i < m; i++) {
		cin >> templ[i];
	}
	
	bool found = false;
	
	// horizontal
	for (int i = 0; i <= n-m; i++) {
		// vertical
		for (int j = 0; j <= n-m; j++) {
			// substring match
			if (image[i].substr(j,m) == templ[0]) {
				if (m == 1) found = true;
				// check the lines below
				for (int k = 1; k < m; k++) {
					if (image[i+k].substr(j,m) != templ[k]) break;
					if (k == m - 1) found = true;
				}
			}
			// no match - continue
		}
	}
	
	if (found) cout << "Yes";
	else cout << "No";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
template<typename T1, typename T2>
inline bool cmx (T1& a, T2 b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int main() {
  std::cin.tie(0); std::cin.sync_with_stdio(false);
  int n, m; std::cin >> n >> m;
  std::vector<long long> a(n, 0);
  for (int i = 1; i < n; i++) {
    std::cin >> a[i];
    a[i] += a[i - 1];
  }
  std::vector<std::vector<int>> b(m, std::vector<int>(n));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      std::cin >> b[j][i];
    }
  }
  std::vector<std::vector<long long>> dp(n + 1, std::vector<long long>(n + 1, 0));
  auto add = [&] (int i0, int i1, int j0, int j1, long long x) {
    if (i1 <= n && j1 <= n) dp.at(i1).at(j1) += x;
    if (i1 <= n) dp.at(i1).at(j0) -= x;
    if (j1 <= n) dp.at(i0).at(j1) -= x;
    dp.at(i0).at(j0) += x;
  };
  auto cum = [&] {
    for (int i = 0; i <= n; i++) {
      for (int j = 0; j <= n; j++) {
        if (i > 0) dp.at(i).at(j) += dp.at(i - 1).at(j);
        if (j > 0) dp.at(i).at(j) += dp.at(i).at(j - 1);
        if (i > 0 && j > 0) dp.at(i).at(j) -= dp.at(i - 1).at(j - 1);
      }
    }
  };
  for (auto const& c :  b) {
    assert((int)c.size() == n);
    auto ord = [&]{
      std::vector<int> ord(n);
      std::iota(ord.begin(), ord.end(), 0);
      std::sort(ord.begin(), ord.end(), [&c](int i, int j){return c[i] > c[j];});
      return ord;
    }();
    std::vector<int> ckd;
    for (auto x : ord) {
      auto lb = std::lower_bound(ckd.begin(), ckd.end(), x);
      int l = (lb == ckd.begin() ? 0 : *std::prev(lb) + 1);
      int r = (lb == ckd.  end() ? n : *lb);
      ckd.insert(lb, x);
      add(l, x + 1, x + 1, r + 1, c[x]);
    }
  }
  cum();
  long long ret = 0;
  for (int l = 0; l <= n; l++) {
    for (int r = l + 1; r <= n; r++) {
      cmx(ret, dp[l][r] - (a[r - 1] - a[l]));
    }
  }
  std::cout << ret << std::endl;
  return 0;
}

Measured memory_bytes: 199808
#include <algorithm>
#include <climits>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <vector>

#define int long long int
constexpr int INF = std::numeric_limits<int>::max();
constexpr int NINF = std::numeric_limits<int>::min();
using namespace std;

map<int, int> memo;

int comb2Ck(int k) {
  if (k % 2 == 0) {
    return k / 2 * (k - 1);
  } else {
    return (k - 1) / 2 * k;
  }
}

void solve() {
  int N, M;
  cin >> N >> M;

  int sum = 0;
  memo[0]++;
  while (N--) {
    int a;
    cin >> a;
    sum += a;
    memo[sum % M]++;
  }

  int ans = 0;
  for (auto pair : memo) {
    int cnt = pair.second;
    ans += comb2Ck(cnt);
  }

  cout << ans << endl;
}

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


Measured memory_bytes: 4224
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(a) (a).begin(), (a).end()

using namespace std;

int nextInt() {int a; cin >> a; return a;}
char nextChar() {char a; cin >> a; return a;}
double nextDouble() {double a; cin >> a; return a;}
string nextString() {string a; cin >> a; return a;}

void inputVector(vector<int> &v, int &n) {rep(i,n){v.push_back(nextInt());}}
void inputVector(vector<double> &v, int &n) {rep(i,n){v.push_back(nextDouble());}}
void inputVector(vector<string> &v, int &n) {rep(i,n){v.push_back(nextString());}}

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

	int ret = abs(abs(a) - abs(b));
	if (abs(a) < abs(b)) {
		if (a * b < 0) ret++;
		else if (a < 0 && b < 0) ret += 2;
		else if (a == 0 && b < 0) ret++;
	} else if (abs(a) > abs(b)) {
		if (a > 0 && b > 0) ret += 2;
		else if (a * b < 0) ret += 1;
		else if (b == 0 && a > 0) ret++;
	} else {
		if (a != b) ret = 1;
	}

	cout << ret << endl;

    return 0;
}


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

//二項計数常よをサクっと求める。逆元
const int MAX = 4000;
const int MOD = 1000000007;

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

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
    COMinit();
    int N,K;
    cin >> N >> K;
    for(int i = 1; i <= K; i++){
        long long blue = COM(K - 1, i - 1)%MOD;
        long long red =COM(N - K + 1,i)%MOD;
        cout << blue*red%MOD << endl;
    }        
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

int main(){
    Init();
    string s; cin >> s;
    bool ans = false;
    rep(i, s.size()-1) if(s[i] == 'A' && s[i+1] == 'C') ans = true;
    (ans) ? Yes() : No();
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn=1000000;
#include <vector>
bool arr[maxn+1]={false};
vector<int> produce_prim_number()
{
        vector<int> prim;
        prim.push_back(2);
        int i,j;
        for(i=3;i*i<=maxn;i+=2)
        {
                if(!arr[i])
                {
                        prim.push_back(i);
                        for(j=i*i;j<=maxn;j+=i)
                                arr[j]=true;
                }
        }
        while(i<maxn)
        {
                if(!arr[i])
                        prim.push_back(i);
                i+=2;
        }
        return prim;
}
//计算n!中素数因子p的指数
int cal(int x,int p)
{
        int ans=0;
        long long rec=p;
        while(x>=rec)
        {
                ans+=x/rec;
                rec*=p;
        }
        return ans;
}
//计算n的k次方对m取模，二分法
int pow(long long n,int k,int M)
{
        long long ans=1;
        while(k)
        {
                if(k&1)
                {
                        ans=(ans*n)%M;
                }
                n=(n*n)%M;
                k>>=1;
        }
        return ans;
}
//计算C（n，m）
int combination(int n,int m)
{
    if(n==0||n==1)
        return 0;
        const int M=10007;
        vector<int> prim=produce_prim_number();
        long long ans=1;
        int num;
        for(int i=0;i<prim.size()&&prim[i]<=n;++i)
        {
                num=cal(n,prim[i])-cal(m,prim[i])-cal(n-m,prim[i]);
                ans=(ans*pow(prim[i],num,M))%M;
        }
        return ans;
}
int main()
{
int n,m;
cin>>n>>m;
int ans=0;
if(n==1&&m==1)
ans=0;
else
{
   ans+=combination(n,2);
   ans+=combination(m,2);
}
       cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 1988
#include <iostream>
#include <string.h>
#include <vector>
#include <deque>
#include <bitset>
#include <string>
#include <limits.h>
#include <stdint.h>
#include <algorithm>
#include <tuple>
#include <iomanip>
#include <set>
#include <assert.h>
using namespace std;

int main(int argc, char* argv[])
{
	if (argc >= 2) {
		FILE* fp = freopen(argv[1], "r", stdin);
	}

	int A, B;
	cin >> A >> B;
	int C = A + B;
	if ((A % 3) == 0 || (B % 3) == 0 || (C % 3) == 0) {
		cout << "Possible";
	} else {
		cout << "Impossible"; 
	}
	
	return 0;
}


Measured memory_bytes: 256
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.math;


void main() {
    int h, w;
    scan(h, w);

    auto ban = new char[][](h, w);
    iota(h).each!(i => ban[i] = readln.chomp.to!(char[]));

    auto cnt = new int[](26);
    foreach (i ; 0 .. h) {
        foreach (j ; 0 .. w) {
            cnt[ban[i][j] - 'a']++;
        }
    }

    if (h & 1) swap(h, w);

    auto odd = cnt.count!"a % 2 == 1".to!int;
    auto even = cnt.count!"a % 2 == 0 && a % 4 != 0".to!int;
    auto m4 = cnt.count!"a % 4 == 0".to!int;

    bool ok;

    if ((h & 1) && (w & 1)) {
        if (odd == 1 && even <= (h / 2 + w / 2)) {
            ok = 1;
        }
    }
    else if (w & 1) {
        if (odd == 0 && even <= (h / 2)) {
            ok = 1;
        }
    }
    else {
        if (odd == 0 && even == 0) {
            ok = 1;
        }
    }

    writeln(ok ? "Yes" : "No");
}



void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}


Measured memory_bytes: 380
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define si(x) scanf("%d", &x)
#define sc(x) scanf("%c", &x)
#define sl(x) scanf("%lld", &x)
#define pl(x) printf("%lld\n", x)
#define pi(x) printf("%d\n", x)
#define pii pair <int, int>
#define pll pair <long long, long long>
#define gu getchar_unlocked
#define pu putchar_unlocked
#define setbits __builtin_popcountll
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define speed ios::sync_with_stdio(false)

const int N = 100005;

int main(){
    string s;
    cin>>s;
    int flag = 1;
    for(int i = 0; i < s.size(); i += 2){
        if(s[i] == 'R' || s[i] == 'U' || s[i] == 'D'){
            continue;
        }
        else{
            flag = 0;
        }
    }
    for(int i = 1; i < s.size(); i += 2){
        if(s[i] == 'L' || s[i] == 'U' || s[i] == 'D'){
            continue;
        }
        else{
            flag = 0;
        }
    }
    if(flag == 0){
        cout<<"No"<<endl;
    }
    else{
        cout<<"Yes"<<endl;
    }
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
int a[1010],b[1010];
int c[1010];
void mul_gjd(int rp)
{
	memset(c,0,sizeof(c));
	int len=a[0]+b[0];
	for (int i=1;i<=a[0];++i)
	{
		int upup=0;
		for (int j=1;j<=b[0];++j)
		{
			c[i+j-1]=a[i]*b[j]+upup+c[i+j-1];
			upup=c[i+j-1]/10;
			c[i+j-1]%=10;
		}
		c[i+b[0]]=upup;
	}
	c[0]=len;
	while ((c[len]==0)&&(len>1))
	{
		len--;
	}
	bool zz=false;
	for (int i=len;i>=1+rp;--i)
	{
		zz=true;
		cout<<c[i];
	}
	if (!zz)
	{
		cout<<0;
	}
	cout<<"\n";
}
int main()
{
	string s1,s2;
	cin>>s1>>s2;
	a[0]=s1.length();
	b[0]=s2.length();
	for (int i=0;i<a[0];++i)
	{
		a[a[0]-i]=s1[i]-'0';
	}
	int point=0;
	for (int i=0;i<b[0];++i)
	{
		if (s2[i]=='.')
		{
			point=b[0]-1-i;
			int j=i;
			while (j<=b[0])
			{
				s2[j]=s2[j+1];
				j++;
			}
		}
	}
	b[0]--;
	for (int i=0;i<b[0];++i)
	{
		b[b[0]-i]=s2[i]-'0';
	}
	mul_gjd(point);
    return 0;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
#include <atcoder/all>

using namespace std;
using namespace atcoder;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
#define ALL(x) x.begin(),x.end() 
#define SIZE(x) ll(x.size())

#define INF 1000000000000 //10^12:∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange

#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}

template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}

void solve() {
    int N, Q;
    cin >> N >> Q;
    fenwick_tree<ll> fw(N);
    REP(i, N) {
        int a;
        cin >> a;
        fw.add(i, a);
    }
    
    REP(i, Q) {
        int t, u, v;
        cin >> t >> u >> v;
        if (t == 0)
        {
            fw.add(u, v);
        }
        else
        {
            cout << fw.sum(u, v) << endl;
        }
    }
}

int main() {
    solve();
    return 0;
}

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

namespace ABC131
{
    class B
    {
        static void Main(string[] args)
        {

            int[] a = Console.ReadLine().Split(' ').Select(v => int.Parse(v)).ToArray();
            int N = a[0], L = a[1];

            List<int> list = new List<int>();
            for(int i = 0; i < N; i++)
            {
                int taste = i + 1 + L - 1;
                list.Add(taste);
            }

            var listex = list.OrderBy(x => Math.Abs(x));
            int sum = listex.Skip(1).Sum();
            Console.WriteLine(sum);
        }

    }
}


Measured memory_bytes: 13396
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;

int main(){
    long n, d, x;
    cin >> n >> d >> x;
    int a[n+1];
    for(int i = 1; i <= n; i++){
        cin >> a[i];
    }
    int ans = x;
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= d; j+=a[i]){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#import sys
MOD = 10 ** 9 + 7
INFI = 10**10
#input = sys.stdin.readline
import math

import itertools

#import bisect

import copy
from functools import lru_cache

def sosuhante(n):
    for k in range(2, int(math.sqrt(n))+1):
        if n% k ==0:
            return False
    return True
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def kingaku(a,b,n):
    keta=len(str(n))
    return a*n+b*keta

def my_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default

#    h,w,a,b = map(int, input().split())
#    c = [[0 for j in range(n)] for i in range(n)]




def main():
    n,m=map(int,input().split())
    broken=set(int(input()) for _ in range(m))
    dp=[0]*(n+5)
    dp[0]=1
    dp[1]=1
    ans=0
    for i in range(2,n+1):
        if i-1 not in broken:
            dp[i]+=dp[i-1]%MOD
        if i-2 not in broken:
            dp[i]+=dp[i-2]%MOD
    if n==1:
        print(1)
    else:
        print(dp[n]%MOD)

if __name__ == "__main__":

    main()

Measured memory_bytes: 58328
import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter

val br = BufferedReader(InputStreamReader(System.`in`))
val pw = PrintWriter(System.out)
fun main(args : Array<String>) {
    func()
    pw.flush()
}

fun func() {
    // 回答をここに書く
    val R = nextInt()
    val s = when {
        R < 1200 -> "ABC"
        R < 2800 -> "ARC"
        else -> "AGC"
    }
    println(s)
}

// 入力取得
fun next() = br.readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun listOfString() = next().split(" ")
fun listOfInt() =listOfString().map { it.toInt() }
fun listOfLong() =listOfString().map { it.toLong() }
fun listOfDouble() =listOfString().map { it.toDouble() }

// 約数のList
fun divisor(value : Long) : List<Long> {
    val max = Math.sqrt(value.toDouble()).toLong()
    return (1..max)
        .filter { value % it == 0L }
        .map { listOf(it, value / it) }
        .flatten()
        .sorted()
}

// 範囲内の素数を取得
// fromだけ指定すると戻り値の個数で素数判定ができる
fun prime(from : Long, to : Long = from) : List<Long> {
    return (from..to).filter { i ->
        val max = Math.sqrt(i.toDouble()).toLong()
        (2..max).all { j ->  i % j != 0L }
    }
}

// 素因数分解
fun decom(value : Long) : List<Long>{
    if (value == 1L) return listOf(1)
    val max = Math.sqrt(value.toDouble()).toLong()
    return prime(2, max).filter { value % it == 0L }
}

// 最大公約数
fun gcd(a : Long, b : Long) : Long {
    return if (a % b == 0L) b else gcd(b, a % b)
}

// 文字列を入れ替え
fun swap(base : String, a : String, b : String) : String {
    return base.map {
        when (it) {
            a.toCharArray()[0] -> b
            b.toCharArray()[0] -> a
            else -> it.toString()
        }
    }.joinToString()
}

fun println(value : Any) {
    pw.println(value)
}

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

int main()
{
	float x;
	int a, b, c;
	cin >> a >> b;

	x = (a + b) / 2.;
	c = int(x);

	if (x > c) {
		c = c + 1;
	}
	cout << c << endl;
}

Measured memory_bytes: 256
import heapq

N,M=map(int,input().split())
H=list(map(int,input().split()))

d={i:[0] for i in range(1,N+1)}

for _ in range(M):
    a,b=map(int,input().split())
    d[a].append(-(H[b-1]))
    d[b].append(-(H[a-1]))

ans=0
for i in range(1,N+1):
    hq=d[i]
    heapq.heapify(hq)
    s=heapq.heappop(hq)
    if (-s)<H[i-1]:
        ans+=1

print(ans)


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

typedef long long ll;

#define REP(i,n) for(int i=0;i<n;i++)

int A, B, C;

int main() {
  scanf("%d %d %d", &A, &B, &C);
  if (C-(A-B) >=0)
    printf("%d\n", C-(A-B));
  else printf("0\n");
  
  return 0;
}


Measured memory_bytes: 256