akhauriyash/Code-Regression huggingface dataset:
//=================================
// Created on: 2018/07/06 04:08:37
//=================================
#include <bits/stdc++.h>
using namespace std;
int main()
{
    for (int H, W;;) {
        cin >> W >> H;
        if (H == 0 and W == 0) { break; }
        vector<string> f(H);
        for (int i = 0; i < H; i++) { cin >> f[i]; }
        using P = pair<int, string>;
        vector<vector<P>> dp(H + 1, vector<P>(W + 1, P{0, ""}));
        dp[H - 1][W - 1] = isalpha(f[H - 1][W - 1]) ? P{0, ""} : P{1, string(1, f[H - 1][W - 1])};
        for (int sum = H + W - 3; sum >= 0; sum--) {
            for (int y = min(sum, H - 1); y >= max(sum - W + 1, 0); y--) {
                const int x = sum - y;
                if (isalpha(f[y][x])) {
                    dp[y][x] = P{0, ""};
                    continue;
                } else {
                    dp[y][x] = max({dp[y][x], {dp[y][x + 1].first + 1, string(1, f[y][x]) + dp[y][x + 1].second}, {dp[y + 1][x].first + 1, string(1, f[y][x]) + dp[y + 1][x].second}});
                }
            }
        }
        P ans = P{0, ""};
        for (int i = H - 1; i >= 0; i--) {
            for (int j = W - 1; j >= 0; j--) {
                if (f[i][j] == '0') { continue; }
                ans = max(ans, dp[i][j]);
            }
        }
        cout << ans.second << endl;
    }
    return 0;
}



Measured memory_bytes: 3224
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;
public class Main {
    public static void main(String[] args) throws Exception {
         Scanner sc = new Scanner(System.in);
         int row = sc.nextInt();//row
         int col = sc.nextInt();//col
         int[] sum_v = new int[col];
         int sum_h = 0;
         int sum = 0;
         for(int i=0;i<row;i++){
            for(int j=0;j<col;j++){
                int tmp = sc.nextInt();
                sum_v[j] += tmp;
                sum += tmp;
                System.out.print(tmp + " ");
            }
            sum_h += sum;
            System.out.println(sum);
            sum=0;
         }
         for(int i=0;i<col;i++){
            System.out.print(sum_v[i] + " ");
         }
         System.out.println(sum_h);
    }
}

Measured memory_bytes: 32080
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define DEBUG(x) cerr << (#x) << ": " << (x) << endl
#define DEBUG_VEC(v)          \
  cerr << #v << ": ";         \
  REP(__i, (v).size())        \
  cerr << ((v)[__i]) << ", "; \
  cerr << endl

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

int main() {
  ios::sync_with_stdio(false);
  int N, Q;
  cin >> N >> Q;

  string s;
  cin >> s;

  vi acc(N);
  char prev = s[0];
  for (int i = 1; i < N; ++i) {
    acc[i] = acc[i - 1];
    if (prev == 'A' and s[i] == 'C') acc[i] += 1;
    prev = s[i];
  }

  // DEBUG_VEC(acc);

  int l, r;
  REP(i, Q) {
    cin >> l >> r;
    // acc[l - 1] because beginning letter is at the index (l - 2)
    //    and the last of the initial two letter set is at (l - 1)
    int res = acc[r - 1] - acc[l - 1];
    cout << res << endl;
  }
  return 0;
}


Measured memory_bytes: 1488
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long int
#define f find
#define ub upper_bound
#define lb lower_bound
#define in insert
#define bs binary_search   

int main() 
{ 
    string s,t;
    cin>>s>>t;
    int dp[s.length()+1][t.length()+1];
    for(int i=0;i<=s.length();i++)
        for(int j=0;j<=t.length();j++)
        {
            if(i==0 || j==0)
                dp[i][j]=0;
            else if(s[i-1]==t[j-1])
                dp[i][j]=1+dp[i-1][j-1];
            else
                dp[i][j]=max(dp[i][j-1],dp[i-1][j]);
        }
    string ans;
    int i=s.length(),j=t.length();
    while(i!=0 && j!=0)
    {
        if(dp[i][j]==max(dp[i][j-1],dp[i-1][j]))
        {
            if(dp[i][j]==dp[i][j-1])
                j--;
            else
                i--;
        }
        else
        {
            ans.pb(s[i-1]);
            i--;
            j--;
        }
    }
    reverse(ans.begin(),ans.end());
    cout<<ans;
    return 0; 
} 

Measured memory_bytes: 35456
#include <stdio.h>
#include <stdlib.h>
 
int main(void){
    char i,j,k;
    scanf("%c%c%c", &i,&j,&k);
if(i!='7' & j!='7' & k!='7'){
  printf("No");
}
  else{
    printf("Yes");
  }
  return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <vector>

using namespace std;

int func(int x, int y, int z){
    return x*x + y*y + z*z + x*y + y*z + z*x;
}

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

    vector<int> f(N+1, 0);
    
    for(int x=1; x<100; x++){
        for(int y=1; y<100; y++){
            for(int z=1; z<100; z++){
                int ff = func(x,y,z);
                if(ff <= N)
                    f[func(x,y,z)]++;
            }
        }
    }

    for(int i=1; i<=N; i++){
        cout << f[i] << endl;
    }

    return 0;   
    
}

Measured memory_bytes: 3588
#include <queue>
#include <tuple>
#include <cstdio>
#include <cstring>
using namespace std;
#define SENTINEL 9999999
typedef tuple<int,int,int> tiii; //building, floor, depth
int M[2][101],B[2][101],n;
int bfs(int i){
		memset(M,99,sizeof(M));
		queue<tiii> q;
		q.push(make_tuple(i,0,0));M[i][0]=0;
		for(;!q.empty();){
			tiii t=q.front();q.pop();
			int building=get<0>(t);
			int floor=get<1>(t);
			int depth=get<2>(t);
			for(;B[building][floor]==1&&B[building][floor+1]==1;){
				if(M[building][floor+1]>M[building][floor])M[building][floor+1]=M[building][floor];
				floor++;
			}
			for(;B[building][floor]==2;){
				if(M[building][floor-1]>M[building][floor])M[building][floor-1]=M[building][floor];
				floor--;
			}
			if(floor==n-1)return depth;
			for(i=2;i>=0;i--)if(floor+i<n&&M[building^1][floor+i]>M[building][floor]){
				M[building^1][floor+i]=M[building][floor];
				q.push(make_tuple(building^1,floor+i,depth+1));
			}
		}
		return SENTINEL;
}
int main(){
	int i,j;
	for(;scanf("%d",&n),n;){
		for(j=0;j<2;j++){
			for(i=0;i<n;i++)scanf("%d",B[j]+i),M[j][i]=SENTINEL;
			B[j][i]=0,M[j][i]=SENTINEL;
		}
		i=min(bfs(0),bfs(1));
		printf(i==SENTINEL?"NA\n":"%d\n",i);
	}
}

Measured memory_bytes: 1020
N, M = map(int, input().split())
mod = int(1e+9 + 7)
A = [-1] + [int(input()) for i in range(M)] + [N+1]
B = []
for i in range(M+1):
  B.append(A[i+1] - A[i] - 1)
C = [0, 1]
for i in range(max(B)):
  C.append(C[i] + C[i+1])
com = 1
for i in range(len(B)):
  com *= C[B[i]] % mod
  com %= mod
print(com)

Measured memory_bytes: 460020
import fractions
T = int(input())

for i in range(T):
  a, b, c, d = map(int, input().split())

  if d<b or a<b:
    print('No')
    continue

  if b-1<=c:
    print('Yes')
    continue

  gcd=fractions.gcd(d,b)
  e=b-gcd+a%gcd
  if e>c:
    print('No')
  else:
    print('Yes')



Measured memory_bytes: 5592
def grinp(h):
  ret=[]
  for i in range(h):
    ret.append(list(input()))
  return ret
n,m=map(int,input().split())
ngr=grinp(n)
mgr=grinp(m)

for i in range(n-m+1):
  for j in range(n-m+1):
    flag=True
    for k in range(m):
      for l in range(m):
        if ngr[i+k][j+l]!=mgr[k][l]:
          flag=False
          break
      if not flag:
        break
    if flag:
      print("Yes")
      break
  if flag:
    break
else:
  print("No")

Measured memory_bytes: 9212
#include <stdio.h>

#define INF 1000000000

#define min(a, b) (((a) < (b)) ? (a) : (b))

const int di[2][9] = {{-2, -1, -1, 0, 0, 0, 1, 1, 2}, {-2, -1, -1, 0, 0, 0, 1, 1, 2}};
const int dj[2][9] = {{1, 1, 2, 1, 2, 3, 1, 2, 1}, {-1, -2, -1, -3, -2, -1, -2, -1, -1}};

typedef struct {
	int i, j, f, d;
} PairCoordDis;

PairCoordDis heap[32400];
int hsize;

inline void insert(int i, int j, int f, int d) {
	int ii;
	for (ii = hsize++; ii > 0 && d < heap[ii - 1 >> 1].d; ii = ii - 1 >> 1)
		heap[ii] = heap[ii - 1 >> 1];
	heap[ii] = (PairCoordDis){i, j, f, d};
}

inline int calcNextIdx(int i) {
	return i * 2 + 1 + (i * 2 + 2 < hsize && heap[i * 2 + 1].d > heap[i * 2 + 2].d);
}

inline PairCoordDis delete(void) {
	int i;
	int nextIdx;
	const PairCoordDis root = heap[0], last = heap[--hsize];

	for (i = 0; i * 2 + 1 < hsize && last.d > heap[nextIdx = calcNextIdx(i)].d; i = nextIdx)
		heap[i] = heap[nextIdx];
	heap[i] = last;

	return root;
}

char field[60][30];
int cost[60][30];
int d[60][30][2];

inline void dijkstra(int h, int w, int si, int sj, int sf) {
	int i, j;

	for (i = 0; i < h; i++)
		for (j = 0; j < w; j++)
			d[i][j][0] = d[i][j][1] = INF;

	d[si][sj][sf] = 0;
	insert(si, sj, sf, 0);
	while (hsize > 0) {
		const PairCoordDis fromP = delete();
		const int nf = fromP.f ^ 1;

		if (fromP.d > d[fromP.i][fromP.j][fromP.f])
			continue;

		for (i = 0; i < 9; i++) {
			const int ni = fromP.i + di[fromP.f][i], nj = fromP.j + dj[fromP.f][i];
			if (ni >= 0 && ni < h && nj >= 0 && nj < w)
				if (fromP.d + cost[ni][nj] < d[ni][nj][nf]) {
					d[ni][nj][nf] = fromP.d + cost[ni][nj];
					insert(ni, nj, nf, d[ni][nj][nf]);
				}
		}
	}
}

int main(void) {
	int i, j, k;
	int w, h;

	while (scanf("%d %d", &w, &h), w) {
		int min;

		for (i = 0; i < h; i++)
			for (j = 0; j < w; j++) {
				scanf(" %c", field[i] + j);
				cost[i][j] = field[i][j] == 'X' ? INF : field[i][j] <= '9' ? field[i][j] - '0' : 0;
			}

		min = INF;
		for (i = 0; i < w; i++)
			if (field[h - 1][i] == 'S')
				for (j = 0; j < 2; j++) {
					dijkstra(h, w, h - 1, i, j);
					for (k = 0; k < w; k++)
						if (field[0][k] == 'T') {
							min = min(min, d[0][k][0]);
							min = min(min, d[0][k][1]);
						}
				}

		printf("%d\n", min == INF ? -1 : min);
	}

	return 0;
}

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

int main() {
	int n;
	cin >> n;
	string w[100];
	for (int i = 0; i < n; i++)
		cin >> w[i];
	for (int i = 0; i < n - 1; i++) {
		if (w[i][w[i].size() - 1] != w[i + 1][0]) {
			cout << "No" << endl;
			return 0;
		}
	}
	for (int i = 0; i < n - 1; i++) {
		for (int j = i + 1; j < n; j++) {
			if (w[i] == w[j]) {
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
using namespace std;
char in[210000];
int main(){
	scanf("%s",in);
	int del=0;
	int s=0;
	int n=0;
	for(int i=0;in[i];i++){
		if(in[i]=='S')s++;
		else{
			if(s){
				s--;del+=2;
			}
		}
		n++;
	}
	printf("%d\n",n-del);
}

Measured memory_bytes: 384
n, m = map(int, input().split())
x = list(map(int, input().split()))
x.sort()

diff = [x[i+1] - x[i] for i in range(m-1)]
diff.sort(reverse=True)

diffsum = 0
for i in range(m-1):
    diffsum = diffsum + diff[i]

if n >= m:
    print(0)
else:
    for j in range(n-1):
        diffsum = diffsum - diff[j]
    print(diffsum)

Measured memory_bytes: 13968
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define prtd(var, i) cout << fixed << setprecision(i) << var << endl;
using namespace std;
#define ll long long

int main(){
    ll a;
    long double b;
    cin >> a >> b;
    long double t = (long double)a * b;
    ll ans = floor(t);
    cout << ans << endl;

}

Measured memory_bytes: 3728
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) (int)(x).size()
using namespace std;
using ll = long long;
constexpr ll INF = 3000000000000000000;

int main() {
    string A, B, C;
    cin >> A >> B >> C;
    if (A[SZ(A) - 1] == B[0] && B[SZ(B) - 1] == C[0]) cout << "YES\n";
    else cout << "NO\n";
    return 0;
}


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

int main()
{
  int a,b,c;
  int res=0;
  cin >> a>>b>>c;

  int amodb = a%b;

  for(int i=1;i<=b;i++){
    if(c==(amodb*i)%b) {
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
}

Measured memory_bytes: 256
#include<iostream>
int main() {
	int a, b;
	std::cin >> a >> b;
	if (a > b) {
		std::cout << "a > b\n";
	}
	else if(a < b) {
		std::cout << "a < b\n";
	}
	else {
		std::cout << "a == b\n";
	}
	return 0;
}


Measured memory_bytes: 3028
from collections import deque
n, k = (int(x) for x in input().split())
p = [int(x) for x in input().split()]
d = deque(p)
tmax = 0
pmax = 0
for i, pp in enumerate(p):
    pmax += pp
    if i >= k:
        pmax -= d.popleft()
    if pmax > tmax:
        tmax = pmax
ans = (tmax + k) / 2
print(ans)

Measured memory_bytes: 25572
#include<bits/stdc++.h>
using namespace std;
 
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
#define f0(i,a,b) for(int i=a;i<b;i++)
#define f1(i,a,b) for(int i=a;i<=b;i++)
#define f2(i,a,b) for(int i=a;i>b;i--)
#define f3(i,a,b) for(int i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define int long long
#define fi first
#define se second
#define mod 1000000007
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define test int t;cin>>t;while(t--)
int mini(int a,int b)
{
    if(a>b)return b;
    return a;
}
signed main(){
    fast
int x,k,d;
cin>>x>>k>>d;

if(x==0)
{
    if(k%2==0)cout<<"0";
    else cout<<d;
}
else if(x>0)
{int g=x/d;
 if(k-g<=1){cout<<abs(x-k*d);return 0;}

    

if((k-g)%2==1)g++;

    //int u=k*d-x;
    cout<<mini(abs(x-d*g-2*d),mini(abs(x-d*g),abs(x-d*g+2*d)));
}
else if(x<0)
{
    x*=-1;
    int g=x/d;
    if(k-g<=1){cout<<abs(x-k*d);return 0;}
if((k-g)%2==1)g++;
    //int u=k*d-x;
    cout<<mini(abs(x-d*g-2*d),mini(abs(x-d*g),abs(x-d*g+2*d)));

    
}
}

Measured memory_bytes: 3648
#include<stdio.h>
int main(){
	int m,i,j,n,k,c,cc,x,max;
	while(scanf("%d %d",&n,&k),n!=0 && k!=0){
		c=0,x=0,max=0;
		int a[100002]={0};
		for(i=0;i<k;i++){
			scanf("%d",&m);
			a[m]=1;
			if(m==0)c=1;
		}
		cc=c;
		for(i=1;i<=n;i++){
			if(a[i]==1)x++;
			else if(c==1){
				x++;
				c=0;
				m=i+1;
			}
			else{
				if(cc==1)c=1;
				if(max<x)max=x;
				x=0;
				if(cc==1)i=m-1;
				
			}
		}
if(max<x)max=x;
		printf("%d\n",max);
	}
	return 0;
}


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

int main() {
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  if (a+b>c+d)
    cout << "Left" << endl;
  else if (a+b==c+d)
    cout << "Balanced" << endl;
  else
    cout << "Right" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

ll s[51];
ll t[51];

ll calc(ll n, ll x) {
    if(x == 0) return 0;
    if(n == 0) return 1;
    if(s[n-1] + 2 <= x) {
        return t[n-1] + 1 + calc(n-1, x - s[n-1] - 2); 
    }
    else {
        return calc(n-1, x-1);
    }
}

int main(){
    ll n, x;
    cin >> n >> x;
    s[0] = 1;
    REP(i, 1, 51) s[i] = s[i-1]*2 + 3;
    t[0] = 1;
    REP(i, 1, 51) t[i] = t[i-1]*2 + 1;
    cout << calc(n, x) << endl;
    return 0;
}

Measured memory_bytes: 256
import bisect
import cmath
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353


r = int(sys.stdin.buffer.readline())
if r < 1200:
    print('ABC')
elif r < 2800:
    print('ARC')
else:
    print('AGC')


Measured memory_bytes: 13548
#include<bits/stdc++.h>
#define speedio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;

typedef long long       ll;
typedef long double     ld;

typedef vector<int>     vi;
typedef vector<bool>    vb;
typedef vector<ll>      vll;
typedef vector<vi>      vvi;
typedef vector<vll>     vvll;
typedef vector<string>  vs;

typedef pair<int, int>  pii;
typedef pair<ll, int>   pli;
typedef pair<ll, ll>    pll;
typedef vector< pii >   vpi;
typedef vector< pll >   vpll;

// typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> oset;

#define pb           push_back
#define mod          1000000007
#define INF          1e17
#define mini         INT_MIN
#define maxo         INT_MAX
#define eb           emplace_back
#define ff           first
#define ss           second
#define re           return 
#define endl         "\n" 

#define all(c)       c.begin(),c.end()
#define be           begin()
#define en           end()
#define sz(x)        (ll)x.size()
#define mem(a,val)   memset(a,val,sizeof(a))
#define mk(x,y)      make_pair(x,y)
#define mid(s,e)     ((s)+((e)-(s))/2) 

#define fo(i,a,b)     for(ll i = (ll)(a); i <= (ll)(b); i++)
#define rf(i,a,b)    for(ll i = (ll)(a); i >= (ll)(b); i--)
#define read(a,n)    for(int i=0;i<n;i++)cin>>a[i];
#define show(a,n)    for(int i=0;i<n;i++)cout<<a[i]<<' ';cout<<endl;
#define p2(n)        (1LL << (n))
#define deb(x) cout <<#x << " = " << x << " | " << "LINE: "<<__LINE__<< endl;
template<typename... T> void rd(T&... args) { ((cin >> args), ...); }
template<typename... T> void pp(T... args) { ((cout << args << " "), ...); cout<<"\n"; }

void add(ll &x, ll y){ x += y; if(x>=mod) x %= mod; if(x<0) x = x%mod + mod; }

//============== *** START OF CODE ***




void solve()
{
    ll ans = 0;
    int k;rd(k);
    fo(i,1,k){
        fo(j,1,k){
            ll g = __gcd(i,j);
            fo(w,1,k){
                ans+=__gcd(g,w);
            }
        }
    }   
    pp(ans);
    
}


void prep(){}

//=============== *** END OF CODE ***

int main(){
    speedio; cout<<fixed<<setprecision(12);

// #ifndef ONLINE_JUDGE
//     freopen("input.txt", "r", stdin);
//     freopen("output.txt", "w", stdout);
// #endif

    prep();
    int t = 1;
    // cin >> t;
    while(t--)
        solve();

    return 0;
}

Measured memory_bytes: 3592
import java.util.*;
public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);

    int N = sc.nextInt();

    int A [] = new int [1000];

    int max =0;
    int min =1000;
    int x;

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

      max = Math.max(max,A[i]);
      min = Math.min(min,A[i]);
    }
     x = max-min;
     System.out.println(x);


}
}

Measured memory_bytes: 21716
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int N, a[100], count = 0;
    
    scanf("%d", &N);
    for(int i = 0; i < N; i++)
    {
        scanf("%d", &a[i]);
    }
    
    for(int i = 0; i < N; i=i+2)
    {
        //printf("%d\n",a[i]);
        if(a[i] % 2 == 1) count++;
    }
        
        
    printf("%d\n",count);
}


Measured memory_bytes: 3756
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		Scanner scan = new Scanner(System.in);

		int N_zentai;
		int i_maekara;

		N_zentai = scan.nextInt();
		i_maekara = scan.nextInt();

		System.out.println(N_zentai - i_maekara + 1);

	}

	//***********************以下共通関数************************************************
	/**
	 * 文字列を反転して返す
	 * @param pStr 文字列
	 * @return 反転した文字列
	 */
	public static String myReverse(String pStr) {
		if (pStr.length() < 1) {
			return "";
		}

		StringBuffer sb = new StringBuffer(pStr);
		return sb.reverse().toString();
	}

	/**
	 * 余りを求める。
	 * @param a
	 * @param b
	 * @return 余り。余りがマイナスの時はプラスで返す。
	 */
	public static long myMod(long a, long b) {
		long ret = 0;

		ret = a % b;

		if (ret < 0) {
			ret += b;
		}

		return ret;
	}

	/**
	 * 乗数を求める ※mod対応
	 * @param kisu 基数
	 * @param josu 乗数
	 * @param primeNumMod_0 法 mod値 使わない場合は「0」
	 * @return
	 */
	public static long myPowWithMod(long kisu, long josu, long primeNumMod_0) {

		long ans = 1;

		//乗数が0の場合→1
		if (josu == 0)
			return 1;

		if (primeNumMod_0 == 0) {
			//modを使わないとき

			while (josu > 0) {

				if (josu % 2 == 0) {
					//累乗が偶数の時

					kisu *= kisu;
					josu = josu / 2;
				} else {
					//累乗が奇数の時
					ans *= kisu;
					josu--;
				}
			}

			return ans;

		} else {
			//modを使うとき

			//初めに桁を落とす
			kisu = myMod(kisu, primeNumMod_0);

			while (josu > 0) {

				if (josu % 2 == 0) {
					//累乗が偶数の時

					kisu *= myMod(kisu, primeNumMod_0);
					josu = josu / 2;

				} else {
					//累乗が奇数の時
					ans *= myMod(kisu, primeNumMod_0);
					josu--;

				}
			}

			return myMod(ans, primeNumMod_0);

		}

	}

}


Measured memory_bytes: 27108
#include <bits/stdc++.h>
int dp[100000] = {}, h[100000] = {};
void solve(int m)
{
  dp[0] = 0;
  dp[1] = std::abs(h[1] - h[0]);
  if(m > 1){
    if(dp[m-1] == 0){
      solve(m - 1);
    }
    dp[m] = std::min(dp[m-1] + std::abs(h[m] - h[m-1]),
                     dp[m-2] + std::abs(h[m] - h[m-2]));
  }
}                    
int main(void)
{
  int n;
  std::cin >> n;
  for(int i = 0; i != n; i++){
    std::cin >> h[i];
  }
  solve(n-1);
  std::cout << dp[n-1] << std::endl;
  return 0;
}

Measured memory_bytes: 4096
#include<bits/stdc++.h>
 
#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
 
using namespace std;
 
typedef long long ll;
 
#define MAX 100010
 
int N;
ll A,B,X[MAX], dp[MAX];
 
void compute() {
  rep(i,N+1) dp[i] = LLONG_MAX;
  dp[0] = 0;
  REP(i,1,N) {
    dp[i] = min(dp[i],dp[i-1] + B);
    dp[i] = min(dp[i],dp[i-1] + (X[i]-X[i-1])*A);
    /*
    dp[i] = min(dp[i],dp[i-1] + B);
    rep(j,i) {//愚直にやるとこうなる TLE
      dp[i] = min(dp[i],
                  dp[j]+(X[i]-X[j])*A);
    }
    */
  }
  cout << dp[N-1] << endl;
}
 
int main() {
  if( 0 ) {
    srand((unsigned int)time(NULL));
    N = 10000;
    A = rand() % 1000 + 1;
    B = A + rand() % 100;
    cout << N << " " << A << " " << B << endl;
    ll cur = 1;
    rep(i,N) {
      if( i ) cout << " ";
      cout << cur;
      cur += ( rand() % 1000 + 1 );
    } puts("");
    return 0;
  }
  cin >> N >> A >> B;
  rep(i,N) cin >> X[i];
  compute();
  return 0;
}

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

int main(void){
	int K,S;
	cin >> K >> S;

	int ans = 0;

	for(int x = 0; x <= K; ++x){
		for(int y = 0; y <= K; ++y){
			int z = S - x - y;
			if(0 <= z and z <= K){
				ans = ans + 1;
			}
		}
	}

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

Measured memory_bytes: 256
D=int(input())
C=list(map(int,input().split()))
S=[list(map(int,input().split())) for i in range(D)]
T=[]
result=0
last=[0 for i in range(26)]

#初期解の算出
for i in range(D):
    change=[S[i][j]+(last[j]+1)*C[j] for j in range(26)]
    t=change.index(max(change))
    T.append(t+1)
    print(t+1)
    result+=S[i][t]
    last[t]=-1
    for j in range(26):
        last[j]+=1
        result-=C[j]*last[j]

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

#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define lfs <<fixed<<setprecision(10)<<
#define test cout<<"test"<<endl;
#define fi first
#define se second
#define MP make_pair
#define rep(i,n,m) for(ll i = n; i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = n - 1; i >= (ll)(m); i--)
typedef long long ll;
typedef long double ld;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
void chmin(T &a,T b){if(a>b)a=b;}
template<typename T>
void chmax(T &a,T b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>v,ll n){cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
template<typename T>
void emp(map<T,ll>&m, T x){m.emplace(x,0).first->second++;}

int main(){
  cin.tie(NULL);
  ios_base::sync_with_stdio(false);
  ll res=0,res1=INF,res2=-INF,buf=0;
  bool judge = true;
  ll n;cin>>n;
  vector<ll>s(n);
  rep(i,0,n)cin>>s[i];
  rep(i,1,n-1){
    buf=0;
    set<ll>t;
    t.insert(0);
    for(ll j=1;i*(j+1)<n-1;j++){
      if(t.find(i*j)!=t.end())break;
      buf+=s[i*j];
      t.insert(i*j);
      if(t.find(n-1-i*j)!=t.end())break;
      buf+=s[n-1-i*j];
      t.insert(n-1-i*j);
      chmax(res,buf);
    }
  }
  cout<<res<<endl;
  return 0;
}

Measured memory_bytes: 7808
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define rep(i,n) for(int i=0; i<(n); ++i)
#define reps(i,f,n) for(int i=(f); i<=(n); ++i)
#define outl(x) cout<< (x) << '\n'
#define fi first
#define se second
using namespace std;
using pii = pair<int,int>;

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

   int N, X;
   int a[105];

   cin >> N >> X;
   int sum = 0;

   int minv = 1 << 28;
   rep(i, N) {
      cin >> a[i];
      sum += a[i];
      minv = min(minv, a[i]);
   }


   int cnt = N;
   X -= sum;


   outl(cnt + (X / minv));
}



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

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

/*
#include "boost/multiprecision/cpp_int.hpp"
#include "boost/multiprecision/cpp_dec_float.hpp"
namespace mp = boost::multiprecision;
typedef mp::cpp_int LL;
typedef mp::number<mp::cpp_dec_float<1024>> DD;// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
*/
 
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define rrep(i,r,l) for(ll i=r;i>=l;i--)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-12;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
//#define endl "\n"  //インタラクティブで消す！！！！！！！！！！！！！！！！！！！！！
#define SORT(v) sort(v.begin(),v.end())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define POSL(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define POSU(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
template<class T,class S>
inline bool chmax(T &a, S b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
template<class T,class S>
inline bool chmin(T &a, S b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

void mod_print(ll k){
    ll P=50000;
    rep(y,1,P){
        ll x=mod(y*k);
        
        if(abs(x)<=P||x+P>=i_7){
            if(x+P>=i_7){
                x-=i_7;
            }
            cout<<x<<"/"<<y<<endl;
            //cout<<setprecision(5)<<(dd)x/(dd)y;
            return;
        }
    }
    cout<<"nun"<<endl;
}
#define all(c) c.begin(),c.end()
typedef vector<ll> vl;
//////////////////////////

int main(){fastio
    ll q;cin>>q;
    while(q--){
        int n,m,a,b;cin>>n>>m>>a>>b;
        cout<<floor_sum(n,m,a,b)<<endl;
    }
    
    return 0;
}


Measured memory_bytes: 3568
"use strict";
process.stdin.resume();
process.stdin.setEncoding('utf8');

var lines = []
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});

reader.on('line', (line) => {
  lines.push(line);
});
/* 入力は 
 */

var re = /\s+|$/;
reader.on('close', () => {
    var n = Number(lines[0].trim());
    var a = lines[1].trim().split(re);
    console.log(a.reverse().join(' '));
});


Measured memory_bytes: 16220
#include <iostream>
#include <map>

using namespace std;

int main()
{
    int n;
    
    cin >> n;
    while (n--) {
        string inp;
        map<int, char> m;
        int idx = 0;

        cin >> inp;

        m[idx] = inp[0];
        for (int i = 1; i < inp.size(); i += 3) {
            if (inp[i] == '-') 
                m[++idx] = inp[i + 2];
            else if (inp[i + 1] == '-') 
                m[--idx] = inp[i + 2];
        }
        
        map<int, char>::iterator it = m.begin();
        for ( ; it != m.end(); it++) 
            cout << (*it).second;
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 1204
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <set>
#define INF 1000000000
#define LLINF 2000000000000000
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define LOOP(i,N) for(int i=0;i<N;i++)
#define LOOP1(i,N) for(int i=1;i<=N;i++)
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
// #define int long long

signed main(){
  int a,b,c;
  string s;
  int ans = 0;
  cin >> a >> b;
  if(a >= 10) cout << b << endl;
  else cout << b + (100 * (10 - a)) << endl;
}


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

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

int main() {
    int n,k; cin >> n >> k;
    int sum = 0;
    
    rep(i,n){
        int x; cin >> x;
        int j = min(x,(k-x));
        sum += j*2;
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
/// Containers Start
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
/// C Header Files
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <math.h>
#include <stdio.h>
/// Containers End

using namespace std;

/// Math Start
#define PI acos(-1.0)
#define Pi 3.141592653589793
#define EPS (1e-7)
#define INF (0x3f3f3f3f)
/// Math End

/// Extra Start
#define nn '\n'
#define pb push_back
#define ull unsigned long long
#define ll long long
#define MOD 1000000007
#define sz(a) int((a).size())
#define space " "
#define All(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
/// Extra End

#define rep(i, n) for (int i = 0; i < n; i++)
#define Cini(a)                                                                \
    int a;                                                                     \
    cin >> a;
#define Cinii(a, b)                                                            \
    int a, b;                                                                  \
    cin >> a >> b;
#define Ciniii(a, b, c)                                                        \
    int a, b, c;                                                               \
    cin >> a >> b >> c;
#define Cins(s)                                                                \
    string s;                                                                  \
    cin >> s;
#define Cinss(s1, s2)                                                          \
    string s1, s2;                                                             \
    cin >> s1 >> s2;
#define Cinc(c)                                                                \
    char c;                                                                    \
    cin >> c;
/// Functions End


/// Debug Start
#define deb(x) cout << #x << ": " << x << endl
#define deb2(x, y) cout << #x << ": " << x << '\t' << #y << ": " << y << endl;
#define deb3(x, y, z)                                                          \
    cout << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": "   \
         << z << endl;
/// Debug End

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

/**>>>>>>>>>>>>>>>>>>> END <<<<<<<<<<<<<<<<<<**/

/// template


signed main(void) {
    cin.sync_with_stdio(false);
    cin.tie(0);
    Cini(N);
    vector<int> a(N),l(N+1,0),r(N+1,0);
    // l(i) [0,i)の最大 i=0,,,,N
    // r(i) [i,N)の最大 i=N,,,,0
    rep(i,N) cin >> a[i];
    rep(i,N) l[i+1] = max(l[i],a[i]);
    rep(i,N) r[N - 1 -i] = max(r[N-i],a[N - 1 -i]);
    rep(i,N){
        cout << max(l[i],r[i+1]) << nn;
    }

    return 0;
}

Measured memory_bytes: 3968
#include<bits/stdc++.h>
#define PI 3.141592653589
#define ll long long
using namespace std;

int main(){
  int h, w;
  string s[50];
  cin >> h >> w;

  for(int i=0; i<h; ++i) cin >> s[i];

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

  for(int i=0; i<h; ++i){
    for(int j=0; j<w; ++j){
      if(s[i][j]=='#') continue;

      int cnt = 0;
      for(int k=0; k<8; ++k){
        const int ni = i + dy[k];
        const int nj = j + dx[k];

        if(ni<0 || h<=ni) continue;
        if(nj<0 || w<=nj) continue;

        if(s[ni][nj] == '#')cnt++;
      }

      s[i][j] = char(cnt + '0');
    }
  }

  for(int i=0; i<h; ++i) cout << s[i] << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<set>
#define INF 1e8
using namespace std;
int main(void){
    // Your code here!
#define ar array

int ar[3]{-1,-1,-1};
int n,m;
cin >>n>>m;

for(int i=0;i<m;i++){
    int a,b;
    cin>>a>>b;
    if((a==1 && b==0 && n!=1) || (ar[a-1]!=-1 && ar[a-1]!=b)){
          cout<<-1;
        return 0;
    }
    ar[a-1]=b;
}
    if(ar[0]==-1 && n==1)
    {
        cout<<0;
        return 0;
    }
        

    if(ar[0]==-1)
            ar[0]=1;
    if(ar[1]==-1)
        ar[1]=0;
      if(ar[2]==-1)
        ar[2]=0;
        
if(n==1)
cout<<ar[0];
else if(n==2)
cout<<ar[0]*10+ar[1];
else
cout<<ar[0]*100+ar[1]*10+ar[2];
}


Measured memory_bytes: 3596
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {

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

		// 整数の入力
		int n = sc.nextInt();
		ArrayList<Integer> aryNum = new ArrayList<Integer>();

		for (int i = 0; i < n; i++) {
			aryNum.add(sc.nextInt());
		}

		Collections.sort(aryNum, Collections.reverseOrder());

		int maxLength = aryNum.get(0);
		aryNum.remove(0);

		int sumLength = 0;

		for (int val : aryNum) {
			sumLength = sumLength + val;
		}

		if (maxLength < sumLength) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

		sc.close();
	}
}

Measured memory_bytes: 23124
#![allow(unused_imports)]
// use itertools::Itertools;
use proconio::{input, marker::*};

fn main() {
    input! {
        n: usize,
        k: usize,
        mut pp: [usize; n]
    };
    pp.sort();
    let sum = pp[0..k].iter().sum::<usize>();
    println!("{}", sum);
}


Measured memory_bytes: 2116
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef pair<int, int> pii;  // pair<int, int> に pii という別名を付ける
typedef long long ll;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string N;
  cin >> N;
  if(N == "ARC"){
    cout << "ABC" << endl;
  }
  else{
    cout << "ARC" <<endl;
  }
}

Measured memory_bytes: 3612
<?php

$stdin = trim(fgets(STDIN));  

$number = explode(" ", $stdin);

$a = $number[0];
$b = $number[1];
$c = $number[2];

if ($a < $b) {
    if ($b < $c) {
        echo "Yes";
    } else {
        echo "No";
    }
} else {
    echo "No";
}

?>

Measured memory_bytes: 6532
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
constexpr int MOD = 1000000007;
constexpr int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const double PI = acos(-1.0);
// cout << fixed << setprecision(14);
 
signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N, K;
	cin >> N >> K;
	vector<int> vec1, vec2;
	P p[N];
	rep(i,N){
		int a, b;
		cin >> a >> b;
		p[i] = P(a, b);
		vec1.push_back(a);
		vec2.push_back(b);
	}
	sort(vec1.begin(), vec1.end());
	sort(vec2.begin(), vec2.end());
	int ans = INF;
	for(int i=0;i<N;i++){
		int a = vec1[i];
		for(int j=i+1;j<N;j++){
			int b = vec1[j];
			for(int k=0;k<N;k++){
				int c = vec2[k];
				for(int l=k+1;l<N;l++){	
					int d = vec2[l];	
					int cnt = 0;
					for(int m = 0;m<N;m++){
						if(a<= p[m].first && p[m].first <= b && c<=p[m].second && p[m].second<=d){
							cnt++;
						}
					}
					if(cnt>=K) chmin(ans, (b-a)*(d-c));
				}
			}
		}
	}
	cout << ans << endl;
}

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

using namespace std;

int main() {

  string str;
  cin >> str;

  int64_t start = str.size(), end = 0;
  for(int64_t i=0;i<str.size();i++) {
    if(str[i] == 'A') {
      start = i;
      break;
    }
  }
  for(int64_t i=str.size();i>=0;i--) {
    if(str[i] == 'Z') {
      end = i;
      break;
    }
  }

  cout << end - start + 1 << endl;

  return 0;
}


Measured memory_bytes: 640
import java.util.*;
public class Main {

 public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	char[] s = sc.nextLine().toCharArray();
	int[] r=new int[s.length];Arrays.fill(r,0);
	int rc=1,lc=0,rltmp=0; 
	for(int i=1;i<s.length;i++){
		if(s[i]=='R'){
			if(s[i-1]=='L'){//LR境目
				r[rltmp]=(int)Math.ceil(lc/2.0)+rc/2;//最初のL
				r[rltmp-1]=lc/2+(int)Math.ceil(rc/2.0);//最後のR
				rc=0;lc=0;
			}
			rc++;
		}else{
			if(s[i-1]=='R'){//ＲL境目
				rltmp=i;
			}
			lc++;
		}
	}
   	r[rltmp]=(int)Math.ceil(lc/2.0)+rc/2;//最初のL
	r[rltmp-1]=lc/2+(int)Math.ceil(rc/2.0);//最後のR
	
	for(int rr:r)System.out.print(rr+" ");
	System.out.println();
 }
}

Measured memory_bytes: 41900
#[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()));
        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)*}
    };
}

#[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, 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! {
        a: i64,
        b: i64,
        k: i64,
    }
    let mut count = 0;
    for i in (1..std::cmp::max(a + 1, b + 1)).rev() {
        if a % i == 0 && b % i == 0 {
            count += 1;
            if count == k {
                println!("{}", i);
                return;
            }
        }
    }
}


Measured memory_bytes: 4352
import sys
input=sys.stdin.readline
import heapq
def dijkstra(s,graph,n):
    dist=[float("inf") for i in range(n+1)]
    dist[s]=0
    pq=[]
    heapq.heapify(pq)
    heapq.heappush(pq,(0,s))
    while pq:
        mini_dis,node=heapq.heappop(pq)
        if dist[node]<mini_dis: continue
        for w,point in graph[node]:
            if dist[point]<w:continue
            newlen=dist[node]+w
            if newlen<dist[point]:
                heapq.heappush(pq,(newlen,point))
                dist[point]=newlen
    return dist
N,M,S,T=map(int,input().split())
graph_yen=[[] for i in range(N+1)]
graph_snuke=[[] for i in range(N+1)]
for _ in range(M):
    u,v,a,b=map(int,input().split())
    graph_yen[u].append((a,v))
    graph_yen[v].append((a,u))
    graph_snuke[u].append((b,v))
    graph_snuke[v].append((b,u))
    
yen=dijkstra(S,graph_yen,N)
snuke=dijkstra(T,graph_snuke,N)
minimum_case=[10**15 for i in range(N+1)]
for i in range(N):
    minimum_case[1+i]-=(yen[i+1]+snuke[i+1])
for i in range(N-1,-1,-1):
    minimum_case[i]=max(minimum_case[i],minimum_case[i+1])
for i in range(1,N+1):
    print(minimum_case[i])

Measured memory_bytes: 80380
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<bitset>
#include<time.h>
using namespace std;
typedef long long ll;
typedef unsigned int uint;
#define INF ((1<<30)-1+(1<<30))
#define INFLL (1LL << 60)
#define MOD 1000000007
#define rep(i, n) for(int i=0; i<(n); ++i)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }


class Combination
{
	vector<ll> fact, finv, inv;
public:
	Combination(int n) {
		inv.resize(n + 1, 1);
		fact.resize(n + 1, 1);
		finv.resize(n + 1, 1);
		for (int i = 2; i <= n; ++i) {
			inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
			fact[i] = fact[i - 1] * i % MOD;
			finv[i] = finv[i - 1] * inv[i] % MOD;
		}
	}
	ll cmb(int n, int k) {
		return fact[n] * (finv[k] * finv[n - k] % MOD) % MOD;
	}
	//permutation
	ll prm(int n, int k) {
		return fact[n] * finv[n - k] % MOD;
	}
};

int main()
{
	int N, M; cin >> N >> M;
	auto C = Combination(M);

	//数列の選び方の総数
	//ll numA = C.cmb(M, N) * C.prm(N, N) % MOD; = C.prm(M, N);
	ll numA = C.prm(M, N);
	//数列B
	ll notB = 0;
	int sign = 1;
	for (int i = 1; i <= N; ++i) {
		notB += sign * C.cmb(N, i) * C.prm(M - i, N - i);
		notB = (MOD + notB) % MOD;
		sign *= -1;
	}
	ll numB = (MOD + numA - notB) % MOD;
	cout << numA * numB % MOD << endl;
	return 0;
}


Measured memory_bytes: 14376
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define rep(i,n) for(int i=0;i<(int)n;i++)
const int INF = (1LL<<31)-1;

int N,M,s,t;
vector<vector<int> > G(100010);
vector<vector<int> > d(100010,vector<int>(3,-1));
void bfs(int s){
    d[s][0] = 0;
    queue<P> que; que.push({s,0});
    while(!que.empty()){
        P q = que.front();
        que.pop();
        int v = q.first;
        int parity = q.second;
        for(auto nv : G[v]){
            int np = (parity + 1) % 3;
            if(d[nv][np]==-1){
                que.push({nv,np});
                d[nv][np] = d[v][parity]+1;
            }
        }
    }
}
int main(){
    cin >> N >> M;
    rep(i,M){
        int u,v; cin >> u >> v;
        G[u].push_back(v);
    }
    cin >> s >> t;

    bfs(s);
    if(d[t][0]==-1) cout << "-1" << endl;
    else cout << d[t][0]/3 << endl;
}

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

typedef long long ll;
ll inf = 1e9*7;
ll N,K;

ll merge_count(vector<ll> &a){
	int n = a.size();
	if(n<=1) return 0;
	ll cnt = 0;
	vector<ll> b(a.begin(),a.begin() + n/2);
	vector<ll> c(a.begin() + n/2, a.end());
	cnt += merge_count(b);
	cnt += merge_count(c);
	int ai = 0,bi = 0,ci = 0;
	while(ai<n){
		if(bi<b.size() && (ci == c.size() || b[bi] <= c[ci])){
			a[ai++] = b[bi++];
		}else{
			cnt += n/2 - bi;
			a[ai++] = c[ci++];
		}
	}
	return cnt;
}

int main(){
	cin >> N >> K;
	vector<ll> A(N+1);
	A[0] = 0;
	for(int i=1;i<=N;i++){
		cin >> A[i];
		A[i] -= K;
		A[i] += A[i-1];
	}
	cout << N*(N+1)/2 - merge_count(A) << endl;
}

Measured memory_bytes: 4992
#include<iostream>
#include<vector>

using namespace std;

int main(void){
  int N, M;
  cin >> N >> M;
  vector<int> v(N + 1);
  for(int i = 0; i < M; i++){
    int a, b;
    cin >> a >> b;
    v[a]++;
    v[b]++;
  }
  for(int i = 1; i <= N; i++) cout << v[i] << endl;
  return 0;
}


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

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<bool> VB;
typedef vector<double> VD;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define LB lower_bound
#define UB upper_bound

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a);i>(b);--i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL INF = 1000000000;
const LL MOD = 1000000007;

//other
//-------------------------------------------
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define FI first
#define SE second

int main() {
  string S;
  cin >> S;
  int t=0, ans=0, N = SZ(S);
  
  REP(i,N) {
    if(S.at(i) == 'A' || S.at(i) == 'C' || S.at(i) == 'G' || S.at(i) == 'T') {
      t++;
      ans=max(ans,t); 
    }
    else {
      t=0;     
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fir first
#define sec second
#define db double
#define ll long long
#define ev eg[i].v
#define pb push_back
#define INF 1000000007
#define pir pair<int,int>
#define Rep(i,l,r) for(int i=(l);i<=(r);++i)
#define RepD(i,r,l) for(int i=(r);i>=(l);--i)
#define RepG(i,x) for(int i=hd[x];i;i=eg[i].nxt)
using namespace std;

const int N=2e5+5;

int n,m;
int a[N];

bool check(int x){
	Rep(i,x*2+1,2*n)
		if(a[i]+a[2*n+2*x-i+1]<m) return 0;
	return 1;	
}

int main(){
    scanf("%d%d",&n,&m);
    Rep(i,1,2*n) scanf("%d",&a[i]);
    sort(a+1,a+2*n+1);
    int l=0,r=n,pos,ans=0;
    while(l<r-1){
        int mid=l+r>>1;
        if(check(mid)) r=mid;
        else l=mid;
    }
    if(check(l)) pos=2*l;
    else pos=2*r;
    Rep(i,1,pos) ans=max(ans,a[i]+a[pos+1-i]);
    Rep(i,pos+1,2*n) ans=max(ans,a[i]+a[2*n+pos-i+1]-m);
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 1024