akhauriyash/Code-Regression huggingface dataset:
import sys
sys.setrecursionlimit(10**7) #再帰関数の上限,10**5以上の場合python
import math
from copy import copy, deepcopy
from copy import deepcopy as dcp
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque
#deque(l), pop(), append(x), popleft(), appendleft(x)
#q.rotate(n)で → にn回ローテート
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate,combinations,permutations#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
#import fractions#古いatcoderコンテストの場合GCDなどはここからimportする
from functools import lru_cache#pypyでもうごく
#@lru_cache(maxsize = None)#maxsizeは保存するデータ数の最大値、2**nが最も高効率
from decimal import Decimal

def input(): 
    x=sys.stdin.readline()
    return x[:-1] if x[-1]=="\n" else x
def printl(li): _=print(*li, sep="\n") if li else None
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def main():
    mod = 1000000007
    #w.sort(key=itemgetter(1),reversed=True)  #二個目の要素で降順並び替え

    N = int(input())
    #N, K = map(int, input().split())
    #A = tuple(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    #S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列
    ans=0
    for i in range(1,N+1):
        d=N//i
        ans+=i*(1+d)*d//2

    print(ans)





if __name__ == "__main__":
    main()

Measured memory_bytes: 77468
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <iomanip>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

int ctoi(char);

struct DataSet
{
    int index;
    string city;
    int score;

    bool operator<(const DataSet &right) const
    {
        return city == right.city ? score > right.score : city < right.city;
    }
};

int main()
{
    int N;
    cin >> N;
    vector<DataSet> array;
    rep(i, N)
    {
        DataSet ds;
        ds.index = i + 1;
        cin >> ds.city >> ds.score;
        array.push_back(ds);
    }
    sort(array.begin(), array.end());

    for (DataSet d : array)
    {
        cout << d.index << endl;
    }
}

int ctoi(char c)
{
    if (c >= '0' && c <= '9')
    {
        return c - '0';
    }
    return -1;
}


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

int main()
{
        using namespace std;

        string str;
        string left = "", right = "";
        int q, tempT;
        // 1なら普通、-1なら反転
        bool strInverse = false;

        cin >> str;
        cin >> q;

        for(int i=0; i<q; i++)
        {
                cin >> tempT;

                if(tempT==1)
                {
                    strInverse = !strInverse;
                } else
                if(tempT==2)
                {
                    int f;
                    char c;

                    cin >> f;
                    cin >> c;

                    if(strInverse==f-1)
                    {
                        left = c + left;
                    } else
                    {
                        right = right + c;
                    }
                }
        }

        str = left + str + right;

        if(strInverse==true)
        {
            reverse(str.begin(), str.end());
        }

        cout << str << endl;

        return 0;
}


Measured memory_bytes: 1512
import java.util.*;

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

		int n = scanner.nextInt();
		int v[][] = new int[n][];
		
		for (int i = 0; i < n; i ++) {
			int u = scanner.nextInt() - 1;
			int k = scanner.nextInt();
			
			v[u] = new int[k];
			
			for (int j = 0; j < k; j ++) {
				v[u][j] = scanner.nextInt() - 1;
			}
		}

		scanner.close();
		
		Stack<Integer> stack = new Stack<>();
		int t = 0;
		int d[] = new int[n];
		int f[] = new int[n];
		int i[] = new int[n];
		
		for (int j = 0; j < n; j ++) {
			stack.push(j);
			
			while(!stack.empty()) {
				int u = stack.peek();
				
				if (d[u] == 0) d[u] = ++ t;
				
				if (i[u] >= v[u].length) {
					stack.pop();
					if(f[u] == 0) f[u] = ++ t;
					continue;
				}
				
				if (d[v[u][i[u]]] == 0) stack.push(v[u][i[u]]);
				i[u] ++;
			}
		}
		
		for (int j = 0; j < n; j ++) {
			System.out.println((j + 1) + " " + d[j] + " " + f[j]);
		}
	}
} 



Measured memory_bytes: 28132
#include <iostream>
#include <string>
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;
typedef long long ll;
typedef pair<int, int> i_i;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin>>s;
  if(s[s.length()-1] == 's')
    cout << s << "es\n";
  else
    cout << s << "s\n";

  return 0;
}


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

int main(int argc, char const *argv[])
{
    int N;
    cin >> N;
    vector<int> d(N);
    for(int i = 0; i < N; i++) {
        cin >> d[i];
    }
    sort(d.begin(), d.end());
    cout << d[N/2] - d[N/2-1] << endl;
    return 0;
}


Measured memory_bytes: 640
/* Atcoder abc166b
 * See tasks at: https://atcoder.jp/contests/abc166/tasks/abc166_b
 */
#include <bits/stdc++.h>

#define until(symbol, max) for (int symbol = 0; (symbol) < (max); (symbol)++)

using namespace std;
using ll = long long;
int main()
{
    int n, k;
    cin >> n >> k;
    
    vector<int> sunuke(n);
    until(i, k)
    {
        int d;
        cin >> d;
        
        until(j, d)
        {
            int a;
            cin >> a;
            sunuke.at(a - 1)++;
        }
    }
    
    cout << count_if(sunuke.begin(), sunuke.end(), [](auto& v) { return v == 0; });
    
    return 0;
}


Measured memory_bytes: 3604
N = int(input())
T = list(map(int, input().split()))
M = int(input())
t_sum = sum(T)
result = []
for _ in range(M):
    p, x = map(int, input().split())
    tmp = sum(T) - (T[p-1] - x)
    result.append(tmp)
for item in result:
    print(item)




Measured memory_bytes: 3188
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    x=INT()
    for i in range(x,100004):
        flg=1
        lim=int(x**0.5+1)
        for k in range(2,lim):
            if i%k==0:
                flg=0
                break
        if flg==1:
            print(i)
            break
if __name__ == '__main__':
    do()

Measured memory_bytes: 9312
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <map>
#include <iomanip>
using namespace std;

typedef long long ll;

ll a[123456], b[132456];
map<ll, ll, std::greater<ll> >mp;
int main(int argc, char const *argv[])
{
    // freopen("input.txt", "r", stdin);
    int N, A, B;
    cin>>N;
    for (int i = 0; i < N+1; ++i)
    {
        cin>>a[i];
    }
    for (int i = 0; i < N; ++i)
    {
        cin>>b[i];
    }
    ll res = 0;
    for (int i = 0; i < N; ++i)
    {
        res += min(b[i], a[i]);
        if(a[i] >= b[i])a[i] -= b[i], b[i] = 0;
        else b[i] -= a[i], a[i] = 0;
        // cout << res << " ";
        res += min(b[i], a[i+1]);
        if(a[i+1] >= b[i])a[i+1] -= b[i], b[i] = 0;
        else b[i] -= a[i+1], a[i+1] = 0;
        // cout << res << " ";
    }
    cout << res << endl;
    return 0;
}


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

#define dbg(a)  cerr << __LINE__ << ": " << #a << " = " << a << '\n'

const int N=2e5+5, I=1e9;
int n, st[2][4*N];

void make_less(int i, int l, int r, int x, int u=1, int s=0, int e=n-1){
  if(l>e or r<s) return ;
  if(l<=s and e<=r){
    st[i][u] = min(st[i][u], x);
    return ;
  }
  int v=2*u, w=2*u+1, m=(s+e)/2;
  if(st[i][u]!=I){
    st[i][v] = min(st[i][v], st[i][u]);
    st[i][w] = min(st[i][w], st[i][u]);
    st[i][u]=I;
  }
  make_less(i,l,r,x,v,s,m);
  make_less(i,l,r,x,w,m+1,e);
}

int at(int i, int idx, int u=1, int s=0, int e=n-1){
  if(s==e)  return st[i][u];
  int v=2*u, w=2*u+1, m=(s+e)/2;
  if(st[i][u]!=I){
    st[i][v] = min(st[i][v], st[i][u]);
    st[i][w] = min(st[i][w], st[i][u]);
    st[i][u]=I;
  }
  if(idx<=m)  return at(i,idx,v,s,m);
  else  return at(i,idx,w,m+1,e);
}

int main(){
  ios::sync_with_stdio(0), cin.tie(0);
  
  for (int i = 0; i < 4*N; ++i){
    st[0][i] = st[1][i] = 1e9;
  }

  int q; cin >> n >> q;
  st[0][1]=st[1][1]=n-1;
  long long ans = 1LL*(n-2)*(n-2);
  int row_done[n], col_done[n];
  memset(row_done, 0, sizeof(row_done));
  memset(col_done, 0, sizeof(col_done));
  while (q--){
    int tp; cin >> tp;
    if(tp==1){
      int col;  cin >> col;
      if(col_done[col]) continue;
      int free_row = at(1, col);
      ans -= max(0, free_row-1);
      make_less(0, 0, free_row, col-1);
      col_done[col]=1;
    } else {
      int row;  cin >> row;
      if(row_done[row]) continue;
      int free_col = at(0, row);
      ans -= max(0, free_col-1);
      make_less(1, 0, free_col, row-1);
      row_done[row]=1;
    }
  }
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 11436
#include <iostream>
#include <string>
#include <map>
#include <cmath>
#include <set>
 
using namespace std;
 
int main() {
  int n, m;
  cin >> n;
  map<string, int> mp;
  set<string> st;
  string s;
  int MAX = 0;
  for (int i = 0; i < n; i++) {
    cin >> s;
    mp[s]++;
    st.insert(s);
  }
  cin >> m;
  for (int i = 0; i < m; i++) {
    cin >> s;
    mp[s]--;
    st.insert(s);
  }
  for (set<string>::iterator ite = st.begin(); ite != st.end(); ite++) {
    MAX = max(MAX, mp[*(ite)]);
  }
  cout << MAX << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

int n, w;
vector<int> data;

int main()
{
  cout << setprecision(10);
  while (scanf("%d %d ", &n, &w) == 2) {
    if (n == 0 && w == 0) {
      break;
    }
    data.resize(n);

    for (int i = 0; i < n; i++) {
      scanf("%d ", &data[i]);
    }
    int M = *max_element(data.begin(), data.end());
    int c = M / w;
    double ink = 0.0;
    
    vector<int> count(M / w + 1, 0);
    for (vector<int>::iterator it = data.begin(); it != data.end(); it++) {
      count[*it / w]++;
    }
    int a = *max_element(count.begin(), count.end());
    for (vector<int>::iterator it = data.begin(); it != data.end(); it++) {
      ink += (double)(c - (*it) / w) / c;
    }
    ink /= a;
    ink += 0.01;
    cout << ink << endl;
  }
}

Measured memory_bytes: 0
#include<stdio.h>
#define N 102
int main(){
  int o,k,n,i,j;
  int M[N][N];
  int M2;
  
  scanf("%d",&o);
  
  for(i=1;i<=o;i++){
    for(j=1;j<=o;j++){
      M[i][j]=0;
    }
  }
  
  for(i=1;i<=o;i++){
    scanf("%d%d",&n,&k);
    for(j=1;j<=k;j++){
      
      scanf("%d",&M2);
      M[n][M2]=1;
    }
  }
  for(i=1;i<=o;i++){
    for(j=1;j<=o;j++){
      if(j!=1) printf(" ");
      printf("%d",M[i][j]);
	}
    printf("\n");
  }
  return 0;
}



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

int main() {
    int N,ans;
    cin >> N;
    ans = 100000;
    for(int i = 0;i < N; i++){
        int A,count = 0;
        cin >> A;
        while(A % 2 == 0){
            count++;
            A /= 2;
        }
        if(ans >= count){
            ans = count;
        }
    }
    cout << ans << endl;
}


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

int main(){
  vector<int> vc(3);
  int a, b, c, k;
  rep(i, 3) cin >> vc[i];
  cin >> k;

  rep(i,k){
    if(vc[1] <= vc[0]){
      vc[1] *= 2;
    }else if(vc[2] <= vc[1]){
      vc[2] *= 2;
    }
  }

  if(vc[0] < vc[1] & vc[1] < vc[2]){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3620
#include <stdio.h>
#include <string.h>

int main(){
  char str[5];
  int a, b;
  int c = 0, d = 0;
  scanf("%s" ,str);
  b = atoi(&str[2]);
  str[2] = '\0';
  a = atoi(str);
  if(a < 1 || a > 12)c = 1;
  if(b < 1 || b > 12)d = 1;
  if(c && d)printf("NA\n");
  else if(!c && !d)printf("AMBIGUOUS\n");
  else if(!c)printf("MMYY\n");
  else printf("YYMM\n");
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <numeric>
#include <iomanip>
#include <set>
#include <string.h>

using namespace std;

typedef long long ll;

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REP3(i,st,en) for(ll (i)=(st);(i)<(en);(i)++)

using P = pair<ll, ll>;
const int MOD = 1e9+7;
const ll INF = 1e+14;
const double PI = 3.14159265349;


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

  ll N;
  cin >> N;


  cout << (N+1)*N/2 << "\n";
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <cmath>
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP2(i, m, n) for (int i = (m); i < (int)(n); ++i)
#define REPR(i, n) for (int i = (n)-1; i >= 0; --i)
#define REPR2(i, m, n) for (int i = (n)-1; i >= (m); --i)
#define REPx(x, a) for(auto x : a)
#define ALL(a) a.begin(), a.end()
#define SORT(a) sort(ALL(a))
#define SORTR(a) sort(ALL(a), greater<int>())
#define REVERSE(a) reverse(ALL(a))
#define bit_search(bit, n) REP(bit, 1<<(n))
#define bit_check(bit, i) (bit>>(i)) & 1
#define setpre(n) fixed << setprecision((n))
#define UNIQUE(a) do {SORT(a); (a).erase(unique(ALL(a)), (a).end());} while(0)
#define MAX(a) *max_element(ALL(a))
#define MIN(a) *min_element(ALL(a))
#define bisect_left(a, x) lower_bound(ALL(a), (x)) - a.begin()
#define bisect_right(a, x) upper_bound(ALL(a), (x)) - a.begin()
#define INPUT(a) REP(i, a.size()) cin >> a[i];
#define INPUTP(a) REP(i, a.size()) cin >> a[i].first >> a[i].second;
#define ENDL cout << endl;
using namespace std;
using LL = long long;
using LD = long double;
using PII = pair<int, int>;
using VPII = vector<PII>;
using PLL = pair<LL, LL>;
using VPLL = vector<PLL>;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VC = vector<char>;
using VS = vector<string>;
using VB = vector<bool>;
using VD = vector<double>;
const LL INF = 1e18;
const LL MOD = 1e9 + 7;

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

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	VLL A(n), B(n);
	INPUT(A); INPUT(B);
	VLL mar(n);
	REP(i, n) mar[i] = A[i] - B[i];
	SORT(mar);
	VLL prev = mar;
	int r = n-1;
	REP(l, n-1)
	{
		if (mar[l] >= 0) break;
		while(mar[l] < 0)
		{
			if (r <= l) break;
			if (-mar[l] <= mar[r])
			{
				mar[r] += mar[l];
				mar[l] = 0;
			}
			else
			{
				mar[l] += mar[r];
				mar[r] = 0;
			}
			if (mar[r] == 0) r--;
		}
	}
	int ans = 0;
	REP(i, n)
	{
		if (mar[i] < 0)
		{
			cout << -1 << endl;
			return 0;
		}
		if (prev[i] != mar[i]) ans++;
	}
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 3328
<?php
fscanf(STDIN, '%d %d', $daiCnt, $roadCnt);
$heights = array_map('intval', explode(' ', trim(fgets(STDIN))));
$memo = array_fill(0, $daiCnt, 0);
for ($i=0; $i < $roadCnt; $i++) { 
    fscanf(STDIN, '%d %d', $a, $b);
    $memo[$a-1] = max($memo[$a-1], $heights[$b-1]);
    $memo[$b-1] = max($memo[$b-1], $heights[$a-1]);
}
$ans = 0;
for ($i=0; $i < $daiCnt; $i++) { 
    if ($memo[$i] < $heights[$i]) {
        $ans++;
    }
}
echo $ans;

Measured memory_bytes: 26796
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		while(sc.hasNext()){
			long a=sc.nextLong(),b=sc.nextLong(),c=sc.nextLong();
			if(a%2==1 && b%2==1 && c%2==1) System.out.println(Math.min(b*c,Math.min(b*a,c*a)));
			else System.out.println(0);
		}
	}
}

Measured memory_bytes: 9808
import sys
input = sys.stdin.readline

# from bisect import bisect_left as bl, bisect_right as br
# from collections import deque
N, M = map(int, input().split())
A = [0] * N
B = [0] * N
for i in range(N):
    a, b = map(int, input().split())
    A[i] = a
    B[i] = b

S = sorted(A)
D = {a: i for i, a in enumerate(S)}

BB = [0] * (N+1)
for i in range(N):
    BB[D[A[i]] + 1] = B[i]

for i in range(1, N+1):
    BB[i-1] ^= BB[i]

def bl(L, k):
    l, r = -1, len(L)
    while r - l > 1:
        m = (l+r) // 2
        if L[m] >= k:
            r = m
        else:
            l = m
    return r

A = [D[a] for a in A]
X = [[] for _ in range(N+1)]
DD = {}
for i in range(M):
    l, r = map(int, input().split())
    l = bl(S, l)
    r = bl(S, r+1)
    X[l].append(r)
    X[r].append(l)
    DD[(l<<18) + r] = i
    DD[(r<<18) + l] = i

# Q = deque([i for i in range(N+1)])
# Q = [i for i in range(N+1)]
P = [-1] * (N+1)
CH = [[] for _ in range(N+1)]
R = []
done = [0] * (N+1)
for ii in range(N+1):
    Q = [ii]
    while Q:
        i = Q.pop()
        if P[i] < 0:
            R.append(i)
            done[i] = 1
        for j in X[i]:
            if P[j] >= 0: continue
            if j != P[i] and done[j] == 0:
                R.append(j)
                done[j] = 1
                P[j] = i
                CH[i].append(j)
                # X[j].remove(i)
                # deque.append(Q, j)
                Q.append(j)

ANS = []
for i in R[1:][::-1]:
    if BB[i]:
        BB[i] ^= 1
        BB[P[i]] ^= 1
        if P[i] < 0:
            print(-1)
            exit()
        ANS.append(DD[(i<<18) + P[i]] + 1)
if sum(BB) == 0:
    print(len(ANS))
    print(*sorted(ANS))
else:
    print(-1)

Measured memory_bytes: 120320
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
int dp[55][2];
signed main(){
    int n,p;cin >> n >> p;
    vector<int> a(n);
    rep(i,n)cin >> a[i];
    dp[0][0] = 1;
    rep(i,n)rep(j,2){
        dp[i+1][j] += dp[i][j];
        dp[i+1][(j+a[i])%2] += dp[i][j];
    }
    cout << dp[n][p] << endl;
    
    
    return 0;
}

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

int main(){
    int N, P[100000];
    cin >> N;
    for(int i=0; i<N; i++) cin >> P[i];
    int now = 0;
    string ans = "";
    stack<int> st;
    for(int i=0; i<N; i++){
        while(now < P[i]){
            now++;
            st.push(now);
            ans.push_back('(');
        }
        if(st.size() && st.top() == P[i]){
            st.pop();
            ans.push_back(')');
        }else{
            cout << ":(" << endl;
            return 0; 
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 3700
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a,b;
        while(true){
            a=sc.nextInt();b=sc.nextInt();
            if(a==0 && b==0)break;
            for(int i=0;i<a;i++){
                if(i==0 || i==a-1){
                for(int j=0;j<b;j++){
                    System.out.print("#");
                }
                System.out.println();continue;
                }
                for(int j=0;j<b;j++){
                    if(j==0 || j==b-1)System.out.print("#");
                    else System.out.print(".");
                }
                System.out.println();
            }
            System.out.println();
        }
    }
}


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

int main() {
    int n; cin >> n;
    for (int i = 1; i <= 9; i++) {
        for (int j = 1; j <= 9; j++) {
            if (i * j == n) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

int main() {
	int w_n, h_n;
	while(cin >> w_n >> h_n, w_n|h_n){
		map<int, int> ps;
		{
			vi xs;
			int x = 0, dx;
			xs.push_back(x);
			REP(i, w_n){
				cin >> dx;
				x += dx;
				xs.push_back(x);
			}

			int y = 0, dy;
			for(int xx:xs){
				ps[xx-y]++;
			}
			REP(i, h_n){
				cin >> dy;
				y += dy;
				for(int xx:xs){
					ps[xx-y]++;
				}
			}
		}

		int sum = 0;
		for(auto t:ps){
			int n = t.second;
			sum += n*(n-1)/2;
		}

		cout << sum << endl;
	}
}

Measured memory_bytes: 28000
#include <iostream>
#include <bits/stdc++.h>
#define mod 998244353

typedef long long ll;

using namespace std;

void Fastio(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

ll fact[1000006], inv[1000006];

ll fp(ll base, ll exp)
{
    if (exp == 0)
        return 1;
    ll ans = fp(base, exp / 2);
    ans = (ans * ans) % mod;
    if (exp % 2 != 0)
        ans = (ans * (base % mod)) % mod;
    return ans;
}

void calcFacAndInv(ll n)
{
    fact[0] = inv[0] = 1;
    for (ll i = 1; i <= n; i++)
    {
        fact[i] = (i * fact[i - 1]) ;
        inv[i] = fp(fact[i], mod - 2);
    }
}

ll ncr(ll n, ll r)
{
    return ((fact[n] * inv[r]) % mod * inv[n - r]) % mod;
}

ll npr(ll n, ll r)
{
    return (fact[n] * inv[n - r]) % mod;
}

long double  NCR(int n, int m){
    long double res = 1;
    m = min(m, n - m);
    for(int i = 0; i < m; i++){
        res = res * ( n - i) / (i + 1);
 }
    return res;
}
ll tol(string a){
    ll res=0;
    while(a[0]=='0'){
        a.erase(a.begin());
    }
    if(a=="")a="0";
    for(int i=0; i<a.size(); i++){
        res*=10; res+=a[i]-'0';
    }
    return res;
}

int primeFactors(int n)
{
    ll c=0;
    while (n % 2 == 0)
    {
        c++;
        n = n/2;
    }
    for (int i = 3; i*i <= n; i = i + 2)
    {
        while (n % i == 0)
        {
            c++;
            n = n/i;
        }
    }
    if (n > 2)
        c++;
    return c;
}
class data{
    public:
    ll l, r, d, w;
    bool operator <(data& d){
        return w>d.w || (w==d.w && this->d>d.d);
    }
};
ll n, arr[100005], dp[100005][2][2];
ll solve(int i, int l, int ch){
    if(i==n)return 0;
    if(dp[i][l][ch]!=-1)return dp[i][l][ch];
    ll res1=-1e18,res2=-1e18;
    /*if(ch){
        if(!l)res1=solve(i+1,1)+arr[i];
        else
    }
    else {

    }*/
    return dp[i][l][ch]=max(res1,res2);
}
int main()
{
    Fastio();
    cin>>n;
    /*for(int i=0; i<n; i++){cin>>arr[i];}
    memset(dp,-1,sizeof(dp));
    cout<<solve(0,0)<<'\n';
*/
    map<string,int>mp;
    for(int i=0; i<n; i++){
        string x; cin>>x; mp[x]++;
    }
    priority_queue<pair<int,string> >q;
    for(auto it : mp){
        q.push({it.second,it.first});
    }
    int mx=q.top().first;
    set<string>s;
    while(!q.empty() && q.top().first==mx){
        s.insert(q.top().second);
        q.pop();
    }
    for(auto it : s){
        cout<<it<<'\n';
    }
    return 0;
}



Measured memory_bytes: 38636
#include <iostream>

using namespace std;

int main()
{
  int d;
  cin >> d;
  
  long long int s = 0, yen = 1000;
  
  int i = 1, cur, nxt;
  cin >> cur;
  do
  {
    cin >> nxt;
    if (s == 0)
    {
      if (nxt > cur)
      {
        s = yen / cur;
        yen -= s * cur;
      }
    }
    else
    {
      if (nxt < cur)
      {
        yen += s * cur;
        s = 0;
      }
    }
    cur = nxt;
  }
  while (++i < d);
  
  yen += s * nxt;
  cout << yen;
  
  return 0;
}


Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int sum=700;
	char s[3];
	scanf("%s",s);
	for(int i=0;i<3;i++)
		if(s[i]=='o')
			sum+=100;
	printf("%d",sum);
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    private static final int r     = 0,
    		                 c     = 1,
    		                 EMPTY = -1;

    private static int[]   p;
    private static int[][] m;

    public static void main(String[] args) {

        //input
         Scanner sc = new Scanner(System.in).useDelimiter(System.getProperty("line.separator"));
         int N = sc.nextInt();
         p = new int[N+1];
         m = new int[N][N];
         String[] s = null;
       	 for(int i=0;i<N;i++){
       		 s = sc.next().split("\\s");
       		 p[i] = Integer.parseInt(s[r]);
       	 }
       	 p[N] = Integer.parseInt(s[c]);

         //calculation
       	 int i,j,k,l,q;
       	 for(l=1;l<N;l++){
       		 for(i=0;i<N-l;i++){
       			 j = i + l;
       			 m[i][j] = EMPTY;
       			 for(k=i;k<j;k++){
       				 q = m[i][k] + m[k+1][j] + p[i]*p[k+1]*p[j+1];
       				 if(q < m[i][j] || m[i][j] == EMPTY){
       					 m[i][j] = q;
       				 }
       			 }
       		 }
       	 }

         //output
       	 System.out.println(m[0][N-1]);
    }
}

Measured memory_bytes: 19640
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
using namespace std;
int main() {
	int n;
	int a[101000];
	int ni = 0, ans = 0, ans1;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (a[i] % 4 == 0) {
			ans++;
		}
		else if (a[i] % 2 == 0) {
			ni++;
		}
	}
	ans1 = (ans + 1) * 2 - 1;
	if (ans == 0) {
		ans1 = 1;
	}
	if (ans1 >= n) {
		cout << "Yes" << endl;
	}
	else if (n - ans1 + 1<= ni) {
		if (ni == 1) {
			cout << "No" << endl;
			return 0;
		}
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}
	

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define int long long
int n,m,k;
signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

   cin>>n>>m>>k;
   vector<vector<char>> a(n,vector<char>(m));
   for(int i=0;i<n;i++)
   {
       for(int j=0;j<m;j++)
       {
           cin>>a[i][j];
       }
   }
   int ans=0;
   for(int row=0;row<(1<<n);row++)
   {
       for(int col=0;col<(1<<m);col++)
       {
           int black=0;
           for(int i=0;i<n;i++)
           {
               for(int j=0;j<m;j++)
               {
                   if(!(row&(1<<i)) && !(col&(1<<j)) && a[i][j]=='#')
                   black++;
               }
           }
           ans+=(black==k);
       }
   }
   cout<<ans<<endl;
}

Measured memory_bytes: 3616
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
char str[100005];
int main()
{
	char aa;
	long long l,s;
	while(cin>>str)
	{
		s=0;
		l=strlen(str);
		aa=str[0];
		for(int i=1;i<l;i++)
		{
			if(aa!=str[i])
			{
				aa=str[i];
				s+=1;
			}
		}
		cout<<s<<endl;
	}
	return 0;
}


Measured memory_bytes: 384
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main(){
    int a,b,c,mina,maxa,n;
    char s[100010];
    a=b=c=0;
    scanf("%s",s);
    n=strlen(s);
    for(int i=0;i<n;i++){
        if(s[i]=='a'){
            a++;
        }
        else if(s[i]=='b'){
            b++;
        }
        else{
            c++;
        }
    }
    mina=maxa=a;
    maxa=max(maxa,b);
    maxa=max(maxa,c);
    mina=min(mina,b);
    mina=min(mina,c);
    if(maxa-mina>1){
        printf("NO\n");
    }
    else{
        printf("YES\n");
    }
}

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

int main(){
    int d , n ;
    cin >> d >> n ;
    int A[3][100] ;
    int j = 0 ;
    int k = 0 ;
    int l = 0 ;
    for( int i = 1 ; i < 1e8 ; i++ ){
        if(i%100 != 0 && j < 100 ){
            A[0][j] = i ;
            j++ ;
        }
        if(i%100 == 0 && k < 100 ){
            if((i/100)%100 == 0 ){
                if(((i/100)/100)%100 == 0 ) continue ;
                A[2][k] = i ;
                k++ ;  
            }
            else{
                if( l < 100 ) A[1][l] = i ;
                l++ ;
            }
        }
    }
    cout << A[d][n-1] << endl;
}


Measured memory_bytes: 3612
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>


using namespace std;

int main()
{
	int d;
	while (scanf("%d", &d) != EOF)
	{
		int area = 0;
		for (int x = 0; x < 600; x += d)
		{
			area += x*x * d;
		}
		printf("%d\n", area);
	}

	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#define rep(i,n) for(int (i) = 0, i_len = n; (i) < (i_len); ++(i))
#define repp(i,n) for(int (i) = 1, i_len = n; (i) <= (i_len); ++(i))
#define per(i,n) for(int (i) = n-1; (i) >= 0; --(i))
#define perr(i,n) for(int (i) = n; (i) > 0; --(i))
#define sz(x) ((int)(x).size())
#define popcnt __builtin_popcount
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).begin(),(v).end(),greater<>()
#define Pi 3.1415926535
#define MOD = 1e9+7;
using namespace std;
using ll = long long;
using pint = pair<int,int>;
using itn = int;
using vint = vector<int>;
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;}
template<class T> T gcd(T a, T b){return b?gcd(b,a%b):a;}
template<class T> T lcm(T a, T b){return a*b/gcd(a,b);}
void yes(){cout << "Yes" << endl;}
void no(){cout << "No" << endl;}

int solve(){
    int n; cin >> n;
    ll ans = 0;
    repp(i,n){
        repp(j,n){
            repp(l,n){
                ans += gcd(gcd(i,j),l);
            }
        }
    }

    cout << ans << endl;

    return 0;
}

int main(){
    cin.tie(0);
    cout << fixed << setprecision(10);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}


Measured memory_bytes: 3656
import java.util.*;
import java.io.*;
import java.math.BigDecimal;
import java.math.BigInteger;

public class Main {
	static PrintWriter out;
	static StringBuilder sb;
	static int mod = 1000000007;
	static long inf = (long) 1e16;
	static ArrayList<Integer>[] ad;
	static int n, g;
	static long[][][] memo;
	static HashSet<Integer> h;
	static long[] a;
	static HashSet<Integer> leaves;

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		out = new PrintWriter(System.out);
		n = sc.nextInt();
		g = 1 + n % 2;
		a = sc.nextArrLong(n);
		memo = new long[n][g + 1][2];
		for (long[][] h : memo)
			for (long[] k : h)
				Arrays.fill(k, -1);
		System.out.println(dp(0, g, 0));
		out.close();
	}

	static long dp(int i, int lg, int l) {
		if (i == n && lg != 3)
			return 0;
		if (i == n)
			return -inf;
		if (memo[i][lg][l] != -1)
			return memo[i][lg][l];
		long ans = 0;
		if (l == 1)
			ans = dp(i + 1, lg, 0);
		else {
			ans = dp(i + 1, lg, 1) + a[i];
			if (lg > 0)
				ans = Math.max(ans, dp(i + 1, lg - 1, 0));
		}
		return memo[i][lg][l] = ans;
	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}

		public Scanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public char nextChar() throws IOException {
			return next().charAt(0);
		}

		public Long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public int[] nextArrInt(int n) throws IOException {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		public long[] nextArrLong(int n) throws IOException {
			long[] a = new long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		public boolean ready() throws IOException {
			return br.ready();
		}

		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
}

Measured memory_bytes: 93748
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>

#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long LL;
using namespace std;

int main() {
	int n; cin >> n;
	vector<int> p(n);
	for (int &x : p)cin >> x;

	int mi = 1145141919;
	int cnt = 0;

	rep(i, n) {
		mi = min(mi, p[i]);
		if (mi == p[i]) cnt++;
	}
	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 1024
#include <iostream>

#define ll long long
#define MOD 1000000007

ll power_mod(ll x, ll n, ll mod) {
  if (n == 0)
    return 1;
  else if (n % 2)
    return x * power_mod(x, n - 1, mod) % mod;
  else
    return power_mod(x * x % mod, n / 2, mod);
}

ll facts[200010];
ll rfacts[200010];

ll comb(ll n, ll k) {
  if (n == 0 || k == 0 || n - k == 0) return 1;
  return (facts[n] * rfacts[k] % MOD) * rfacts[n - k] % MOD;
}

int main() {
  int h, w, a, b;
  std::cin >> h >> w >> a >> b;

  ll f = 1;
  for (int i = 1; i <= h + w; i++) {
    f = f * i % MOD;
    facts[i] = f;
    rfacts[i] = power_mod(f, MOD - 2, MOD);
  }

  ll sum = 0;
  for (int i = b + 1; i <= w; i++) {
    ll left = comb(h - a + i - 2, h - a - 1);
    ll right = comb(a + w - i - 1, a - 1);
    sum += left * right % MOD;
    sum %= MOD;
  }

  std::cout << sum << std::endl;

  return 0;
}

Measured memory_bytes: 3328
import sys
sys.setrecursionlimit(10**5)

n,m = map(int,input().split())

v = [-1] * (n + 1)
x = [[] for _ in range(n + 1)]

for _ in range(m):
    a,b = map(int,input().split())
    x[a].append(b)

def dfs(i):
    if v[i] != -1:
        return v[i]

    rt = 0
    for node in x[i]:
        tmp = dfs(node) + 1
        if rt < tmp:
            rt = tmp

    #メモ化再帰
    v[i] = rt
    return rt

ans = 0

for k in range(1,n+1):
    tmp2 = dfs(k)

    if tmp2 > ans:
        ans = tmp2

print(ans)

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

int n = 50;
long long a[50];

int main() {
	ios_base::sync_with_stdio(0);
	long long k;
	cin >> k;
	for (int i = 0; i < n; i++) {
		a[i] = i;
	}
	
	for (int i = 0; i < n; i++) {
		a[i] += k / n;
	}
	
	for (long long i = 0; i < k % n; i++) {
		a[i] += n;
		for (int j = 0; j < n; j++) {
			if (i == j) continue;
			a[j]--;
		}
	}
	
	cout << n << "\n";
	for (int i = 0; i < n; i++) {
		cout << a[i] << " ";
	}
	
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n;
    cin >> n;
    vector<ll> a(n);
    map<ll, ll> cnt;
    rep(i, n) {
        cin >> a[i];
        cnt[a[i]]++;
    }
    auto itb = cnt.begin();
    auto itl = cnt.end(); itl--;
    ll minv = itb->first;
    ll minc = itb->second;
    ll maxv = itl->first;
    ll maxc = itl->second;
    ll diff = maxv - minv;
    if (sz(cnt) > 2) {
        cout << "No" << endl;
    }
    else if (diff > 1) {
        cout << "No" << endl;
    }
    else if ((diff == 0) && (minv != (n - 1)) && ((2 * minv) > n)) {
        cout << "No" << endl;
    }
    else if ((diff == 1) && (minc >= maxv) || ((2 * (maxv - minc)) > maxc)) {
        cout << "No" << endl;
    }
    else {
        cout << "Yes" << endl;
    }
    return 0;
}


Measured memory_bytes: 7296
// ctrl+shift+b
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll N; cin >> N;
    bool flag = false;
    rep(i, N / 4 + 1){
        ll res = N - i * 4;
        if (res % 7 == 0){flag = true;}
    }
    string ans = flag ? "Yes" : "No";
    cout << ans << endl;
}

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


Measured memory_bytes: 3632
import java.util.Scanner;

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

		int a = sc.nextInt();
		int b = sc.nextInt();

		if (a + b == 3) {
			System.out.println("3");
		} else if (a + b == 4) {
			System.out.println("2");
		} else {
			System.out.println("1");
		}

		sc.close();
	}
}

Measured memory_bytes: 26812
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)*}
    };
}

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)*}
    };
}

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, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

//
// # Examples
//
// # integers
// input! { n: usize, m: usize, ... }
//
// # array
// input! { n: usize, v: [i32; n], }
//
// # matrix
// input! { n: usize, m: usize, mat: [[]] }
//
// # string
// input! { s: chars }
//
// 3 4
// ####
// #..#
// .#.#
//
// input!{
//     h: usize,
//     w: usize,
//     board: [chars; h],
// }

// https://practice.contest.atcoder.jp/tasks/practice_1
//fn main() {
//    input!{
//        a: usize, b: usize, c: usize,
//        foo: chars,
//    }
//    let s: String = foo.into_iter().collect();
//    println!("{} {}", a+b+c, s);
//}

fn main() {
    input!{
        r: usize
    }
    if r < 1200 {
        println!("ABC");
    } else if r < 2800 {
        println!("ARC");
    } else {
        println!("AGC");
    }
}

Measured memory_bytes: 4352
// Author -- Frame

#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<iostream>

#define lowbit(x) ((x)&(-x))
#define Finline __inline__ __attribute__ ((always_inline))
#define DEBUG printf("Running on Line %d in Function %s\n",__LINE__,__FUNCTION__)

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;

const int inf=0x3f3f3f3f,Inf=0x7fffffff;
const ll INF=0x7fffffffffffffff;
const double eps=1e-10;

uint seed=19260817;
const uint _RAND_MAX_=4294967295u;
Finline uint Rand(){return seed=seed*998244353u+1000000007u;}

template <typename _Tp>_Tp gcd(const _Tp &a,const _Tp &b){return (!b)?a:gcd(b,a%b);}
template <typename _Tp>Finline _Tp abs(const _Tp &a){return a>0?a:-a;}
template <typename _Tp>Finline _Tp max(const _Tp &a,const _Tp &b){return a<b?b:a;}
template <typename _Tp>Finline _Tp min(const _Tp &a,const _Tp &b){return a<b?a:b;}
template <typename _Tp>Finline void chmax(_Tp &a,const _Tp &b){(a<b)&&(a=b);}
template <typename _Tp>Finline void chmin(_Tp &a,const _Tp &b){(b<a)&&(a=b);}
template <typename _Tp>Finline bool _cmp(const _Tp &a,const _Tp &b){return abs(a-b)<=eps;}
template <typename _Tp>Finline void read(_Tp &x)
{
    register char ch(getchar());
    bool f(false);
    while(ch<48||ch>57) f|=ch==45,ch=getchar();
    x=ch&15,ch=getchar();
    while(ch>=48&&ch<=57) x=(((x<<2)+x)<<1)+(ch&15),ch=getchar();
    if(f) x=-x;
}
template <typename _Tp,typename... Args>Finline void read(_Tp &t,Args &...args)
{
    read(t);read(args...);
}
Finline int read_str(char *s)
{
    register char ch(getchar());
    while(ch==' '||ch=='\r'||ch=='\n') ch=getchar();
    register char *tar=s;
    *tar=ch,ch=getchar();
    while(ch!=' '&&ch!='\r'&&ch!='\n'&&ch!=EOF) *(++tar)=ch,ch=getchar();
    return tar-s+1;
}

const int N=55;
struct edge{
	int v,nxt;
}c[N<<1];
int front[N],cnt;
Finline void add(int u,int v)
{
	c[++cnt]=(edge){v,front[u]},front[u]=cnt;
}
int Fa[N],dep[N];
void dfs(int x,int fa)
{
	Fa[x]=fa,dep[x]=dep[fa]+1;
	for(int i=front[x];i;i=c[i].nxt)
	{
		if(c[i].v!=fa)
		{
			dfs(c[i].v,x);
		}
	}
}
int u[N],v[N];
bool flag[N];
int main()
{
	int n;
	read(n);
	int x,y;
	for(int i=1;i<n;++i)
	{
		read(x,y);
		add(x,y),add(y,x);
	}
	dfs(1,0);
	int m;
	read(m);
	for(int i=1;i<=m;++i)
	{
		read(u[i],v[i]);
	}
	ll ans=0;
	for(int st=0;st<1<<m;++st)
	{
		memset(flag,0,n+3);
		int sign=__builtin_popcount(st)&1?-1:1;
		for(int i=1;i<=m;++i)
		{
			if((st>>(i-1))&1)
			{
				int a=u[i],b=v[i];
				if(dep[b]>dep[a]) std::swap(a,b);
				while(dep[a]>dep[b])
				{
					flag[a]=true;
					a=Fa[a];
				}
				while(a!=b)
				{
					flag[a]=flag[b]=true;
					a=Fa[a],b=Fa[b];
				}
			}
		}
		ll qwq=1;
		for(int i=2;i<=n;++i)
		{
			if(!flag[i])
			{
				qwq<<=1;
			}
		}
		ans+=sign*qwq;
	}
	printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = a; i < (n); i++)
#define rrep(i, n, k) for (int i = (n); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
const int MOD = 1e9+ 7;
const int INF = 2e18;

signed main() {
    int N, K, Q;
    cin >> N >> K >> Q;
    vector<int> A(N);
    cin >> A;
    set<int> check;
    int ans = INF;
    for (int i = 0; i < N; i++) {
        vector<int> get;
        vector<int> save;
        for (int j = 0; j < N; j++) {
            if (check.find(A[j]) != check.end()) {
                if (save.size() >= K) {
                    sort(save.begin(), save.end());
                    for (int k = 0; k + K - 1 < save.size(); k++) {
                        get.push_back(save[k]);
                    }
                }
                save = vector<int>();
            } else {
                save.push_back(A[j]);
            }
        }
        if (save.size() >= K) {
            sort(save.begin(), save.end());
            for (int k = 0; k + K - 1 < save.size(); k++) {
                get.push_back(save[k]);
            }
        }

        if (get.size() < Q) break;
        sort(get.begin(), get.end());
        ans = min(ans, get[Q - 1] - get[0]);
        check.insert(get[0]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 384
#include<stdio.h>
#include <iostream>
using namespace std;
int main(void)
{
    string S,T;
    cin >> S;
    cin >> T;
 

if(S==T.erase(T.size()-1)){
cout << "Yes";
}
else{
cout << "No";
 }
 
return 0;
}

Measured memory_bytes: 3072