akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int num;
  int i;
  int pn[20];
  int count=0;
    
  cin >> num;
  for(i=0;i<num; i++)
    cin >> pn[i];
    
  for(i=1;i<num-1;i++){
    if(pn[i-1] < pn[i] && pn[i] < pn[i+1])
      count++;
    else if(pn[i+1] < pn[i] && pn[i] < pn[i-1])
      count++;
  }
  cout << count << endl;
}


Measured memory_bytes: 256
import java.util.*;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static int M = 10;
	public static void main(String[] args) {
		int i,j,k;
		Scanner sc = new Scanner(in);
		long x = parseLong(sc.next());
		long y = parseLong(sc.next());
		sc.close();
		long a=x;
		int cnt=0;
		while(a<=y) {
			cnt++;
			a *= 2;
		}
		out.println(cnt);
	}
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, K, sum = 0, a, b;
  cin >> N >> K;
  
   for(int i = 0; i < N; i++){
     int x;
     cin >> x;
     a = x;
     b = K - x;
     
     if(a < b){
       sum += a * 2;
     }
     else{
       sum += b * 2;
     }
   }
  cout << sum << endl;
}

Measured memory_bytes: 3596
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

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

/*
    freopen("input","r",stdin);
    freopen("output","w",stdout);
*/

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    vector<int> A(3);
    cin >> A[0] >> A[1] >> A[2];
    sort(A.begin(), A.end());
    if (A[0] == A[2]) {
    	cout << 0 << endl;
    	return 0;
    }
    int sum = A[0] + A[1] + A[2];
    int all = 3 * A[2];
    if ((all - sum) % 2 == 0) {
    	cout << (all - sum) / 2 << endl;
    	return 0;
    }
    all += 3;
    cout << (all - sum) / 2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)

using namespace std;

int main() {
  int n, m;

  cin >> n;
  int solve_times[n];
  REP(i, n) cin >> solve_times[i];

  cin >> m;
  int result_times[m];
  REP(i, m)
  {
    int question_num, cheat_time;
    cin >> question_num >> cheat_time;

    result_times[i] = 0;

    REP(j, n)
    {
      if (j == (question_num-1)) {
        result_times[i] += cheat_time;
      } else {
        result_times[i] += solve_times[j];
      }
    }
  }

  REP(i, m)
      cout << result_times[i] << "\n";

  return (0);
}


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

int main() {
	long long n;
	cin >> n;
	if (n % 2 == 1) {
		cout << 0 << endl;
		return 0;
	}
	long long ans = 0;
	for (long long x = 10; x <= n; x *= 5) {
		ans += n / x;
	}
	cout << ans << endl;
	return 0;
}

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

class BaseXor:
    def __init__(self):
        self.size = 0
        self.base = []
    
    def base_calculate(self, x, b):
        return min(x, x ^ b)

    def make_base(self, x):
        for b in self.base:
            x = self.base_calculate(x, b)
        return x
    
    def change_base(self, x):
        for i in range(self.size):
            self.base[i] = self.base_calculate(self.base[i], x)

    def add_base(self, x):
        x = self.make_base(x)
        if x == 0:
            return False
        self.change_base(x)
        self.base.append(x)
        self.base.sort()
        self.size += 1
        return True
    
    def judge_linearly_dependent(self, x):
        for b in self.base:
            x = self.base_calculate(x, b)
        res = True if x else False
        return res

def solve(n, a, s):
    base = BaseXor()
    judge = False
    for i in range(n-1, -1, -1):
        x = s[i]
        if x == "0":
            base.add_base(a[i])
        else:
            judge = base.judge_linearly_dependent(a[i])
            if judge:
                break
    
    res = 1 if judge else 0
    return res

def main():
    t = int(input())
    ans = [0]*t
    for i in range(t):
        n = int(input())
        a = list(map(int, input().split()))
        s = input()
        res = solve(n, a, s)
        ans[i] = res
    print(*ans, sep="\n")
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 9292
#include <iostream>
#include <cstdio>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)

int x[55];
ll dp[55][55][2550];

int main(void){
	int n, a; cin >> n >> a;
	rep(i, n){
		cin >> x[i]; 
	}

	rep(i, 55)rep(j, 55)rep(k, 2550) dp[i][j][k] = 0;
	dp[0][1][x[0]] = 1; dp[0][0][0] = 1;
	for (int i = 0; i < n - 1; ++i){
		for (int j = 0; j <= n; ++j){
			for (int k = 0; k <= 2500; ++k){
				if(dp[i][j][k] == 0) continue;
				//i + 1番目を選ぶ
				dp[i + 1][j + 1][k + x[i + 1]] += dp[i][j][k];
				//i + 1選ばない
				dp[i + 1][j][k] += dp[i][j][k];
			}
		}
	}

	ll ans = 0;
	for (int j = 1; j <= n; ++j){
		int aim = j * a;
		if(aim <= 2500 && dp[n - 1][j][aim] != 0){
			ans += dp[n - 1][j][aim];
		}
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 60544
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
using ll = long long;

typedef long long ll;
typedef vector<ll> VL;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define INF 999999999


int A[5010];

int Z(string s){
  int ans=0;
  int c=0;
  FOR(i,1,s.size()){
    if(i+A[i-c]<c+A[c]){
      A[i]=A[i-c];
    }
    else{
      int j=max(0,c+A[c]-i);
      while(i+j<s.size() && s[j] == s[i+j])++j;
      A[i]=j;
      c=i;
    }
  }
  FOR(i,1,s.size())ans=max(ans,min(i,A[i]));
  return ans;
}

int main(){
  int N;
  string s;
  cin >> N >> s;
  int ans=0;
  FOR(i,1,N){
    ans=max(ans,Z(s));
    s.erase(0,1);
  }
  cout << ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <map>
#include <set>
#define ull unsigned long long
#define ll long long
using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b;
    cin >> a >> b;
    int s = abs(a-b);
    int l=0;
    for(int i=1;i<=s;i++){
        l+=i;
    }
    cout << l-b << endl;

    return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (int i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()

const int MAX = 22;
int N, A[MAX], B[MAX], C[MAX];

int solve() {
    int ans = 0;
    REP (i, N) ans += B[i];
    REP (i, N-1) if (A[i+1] == A[i]+1){
        ans += C[A[i]-1];
    }
    return ans;
}

int main() {
    cin >> N;
    REP (i, N) cin >> A[i];
    REP (i, N) cin >> B[i];
    REP (i, N-1) cin >> C[i];
    cout << solve() << endl;
}

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

int main(void){
    int n; cin >> n;
    int s[400], l[400], p[400];
    for(int i = 0; i < n; i++) cin >> s[i] >> l[i] >> p[i];
    int m; cin >> m;
    int w[400];
    for(int i = 0; i < m; i++) cin >> w[i];

    int dp[400] = {0}; // dp[i]: 長さiのうち最大の得点
    for(int i = 0; i < n; i++){ // i番目までのフレーズを使う
        for(int j = s[i]; j <= 393; j++){ // dp[j]を更新する
            for(int k = s[i]; k <= l[i]; k++){
                if(j >= k) dp[j] = max(dp[j], dp[j-k]+p[i]);
            }
        }
    }

    for(int i = 0; i < m; i++){
        if(dp[w[i]] == 0){
            cout << "-1\n";
            return 0;
        }
    }

    for(int i = 0; i < m; i++) cout << dp[w[i]] << '\n';
    return 0;
}



Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
namespace FAST_IO
{
	template<typename T> void read(T &a)
	{
		a=0;
		int f=1;
		char c=getchar();
		while(!isdigit(c))
		{
			if(c=='-')
			{
				f=-1;
			}
			c=getchar();
		}
		while(isdigit(c))
		{
			a=a*10+c-'0';
			c=getchar();
		}
		a=a*f;
	}
	template <typename T> void write(T a)
	{
		if(a<0)
		{
			a=-a;
			putchar('-');
		}
		if(a>9)
		{
			write(a/10);
		}
		putchar(a%10+'0');
	}
	template <typename T> void writeln(T a)
	{
		write(a);
		puts("");
	}
}
int n,t,a,v;
double mint=1000000;
int main()
{
	cin>>n>>t>>a;
	for(int i=1;i<=n;i++)
	{
		int tmp;
		double du;
		cin>>tmp;
		du=t-tmp*0.006;
		if(abs(a-du)<mint)
		{
			mint=abs(a-du);
			v=i;
		}
	}
	cout<<v;
}

Measured memory_bytes: 256
from fractions import gcd
# from datetime import date, timedelta
from heapq import*
import math
from collections import defaultdict, Counter, deque
from bisect import *
import itertools
import fractions
import sys
sys.setrecursionlimit(10 ** 7)
MOD = 10 ** 9 + 7
# input = sys.stdin.readline


def lcm(a, b):
    return a * b / fractions.gcd(a, b)

def main():
    a, b = map(int, input().split())
    print(int(lcm(a,b)))

    
    

        


if __name__ == '__main__':
    main()


Measured memory_bytes: 64196
#include <stdio.h>

int main(void)
{	int X, N;
	int num[102] = {0};
	int i, tmp, left, right, ans;

	scanf("%d %d", &X, &N);

	if (N == 0)
	{
		printf("%d\n", X);
		return (0);
	}

	for (i = 0; i < N; i++)
	{
		scanf("%d", &tmp);
		num[tmp]++;
	}

	if (num[X] == 0)
	{
		printf("%d\n", X);
		return (0);
	}

	left = X - 1;
	while (left != 0)
	{
		if (num[left] == 0)
			break;
		left--;
	}
	right = X + 1;
	while (right != 101)
	{
		if (num[right] == 0)
			break;
		right++;
	}

	if (right - X < X - left)
		ans = right;
	else
		ans = left;
	printf("%d\n", ans);

	return (0);
}


Measured memory_bytes: 1732
#define _CRT_SECURE_NO_DEPRECATE
#pragma comment(linker, "/STACK:102400000,102400000")
#include<iostream>  
#include<cstdio>  
#include<fstream>  
#include<iomanip>
#include<algorithm>  
#include<cmath>  
#include<deque>  
#include<vector>  
#include<assert.h>
#include<bitset>
#include<queue>  
#include<string>  
#include<cstring>  
#include<map>  
#include<stack>  
#include<set>
#include<functional>
#define pii pair<int, int>
#define mod 1000000007
#define mp make_pair
#define pi acos(-1)
#define eps 0.00000001
#define mst(a,i) memset(a,i,sizeof(a))
#define all(n) n.begin(),n.end()
#define lson(x) ((x<<1))  
#define rson(x) ((x<<1)|1) 
#define inf 0x3f3f3f3f
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
const int maxn = 1e4 + 5;
int a[maxn];
int s[8];
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int i, j, k, m, n, T;
	cin >> n;
	int temp = 0;
	for (int i = 1; i <= n; ++i)
		cin >> a[i];
	for (int i = 1; i <= n; ++i)
	{
		if (a[i] <= 399)s[0]++;
		else if (a[i] <= 799)s[1]++;
		else if (a[i] <= 1199)s[2]++;
		else if (a[i] <= 1599)s[3]++;
		else if (a[i] <= 1999)s[4]++;
		else if (a[i] <= 2399)s[5]++;
		else if (a[i] <= 2799)s[6]++;
		else if (a[i] <= 3199)s[7]++;
		else temp++;
	}
	int cas = 0;
	for (int i = 0; i <= 7; ++i)
		if (s[i])cas++;
	if (!cas)cout << "1 " << temp << endl;
	else cout << cas << " " << cas + temp << endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
h = [ num for num in map(int, input().split(' '))]

dp = [float('inf')] * n

# print(n, h, dp)

def chmin(arr, index_a, val):
  if arr[index_a] > val:
    arr[index_a] = val
    return True
  return False

def chmax(arr, index_a, val):
  if arr[index_a] < val:
    arr[index_a] = val
    return True
  return False

dp[0] = 0
dp[1] = abs(h[1] - h[0])
for i in range(2, n):
  chmin(dp, i, dp[i-1] + abs(h[i] - h[i-1]))
  chmin(dp, i, dp[i-2] + abs(h[i] - h[i-2]))

print(dp[n-1])

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

using namespace std;

int main() {
  int M, D;
  cin >> M >> D;

  int result = 0;
  for (int m = 1; m <= M; m++) {
    for (int d1 = 2; d1 < 10; d1++) {
      for (int d2 = 2; d2 < 10; d2++) {
	int d = d2 * 10 + d1;
	if (d <= D && ((d1 * d2) == m)) {
	  result++;
	}
      }
    }
  }
  cout << result << endl;

  return 0;
}


Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
# include <bitset>
# include <random>
# include <chrono>
# include <cstdlib>
# include <tuple>
# include <array>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2147483647;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr double HDINF = 50000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define RALL(qpqpq)           (qpqpq).rbegin(),(qpqpq).rend()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define RFOR(i,tptpt,ypypy)  for(LL i=(tptpt);i>=(ypypy);i--)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

int a, b;

int main() {
	cin >> a >> b;
	b -= (b-a+1)*(b-a) / 2;
	cout << abs(b) << endl;
}

Measured memory_bytes: 256
MOD = 10**9 + 7

class Combinatorics:
    def __init__(self, N, mod):
        '''
        Preprocess for calculating binomial coefficients nCr (0 <= r <= n, 0 <= n <= N)
        over the finite field Z/(mod)Z.
        Input:
            N (int): maximum n
            mod (int): a prime number. The order of the field Z/(mod)Z over which nCr is calculated.
        '''
        self.mod = mod
        self.fact = [0] * (N+1)           # n!
        self.inverse = [None] + [0] * N   # inverse of n in the field Z/(MOD)Z
        self.fact_inverse = [0] * (N+1)   # inverse of n! in the field Z/(MOD)Z
        
        # preprocess
        self.fact[0] = self.fact[1] = 1
        self.fact_inverse[0] = self.fact_inverse[1] = 1
        self.inverse[1] = 1
        for i in range(2, N+1):
            self.fact[i] = i * self.fact[i-1] % self.mod
            q, r = divmod(self.mod, i)
            self.inverse[i] = (- (q % self.mod) * self.inverse[r]) % self.mod
            self.fact_inverse[i] = self.inverse[i] * self.fact_inverse[i-1] % self.mod
    
    def perm(self, n, r):
        '''
        Calculate nPr = n! / (n-r)! % mod
        '''
        if n < r or n < 0 or r < 0: return 0
        else: return (self.fact[n] * self.fact_inverse[n-r]) % self.mod
    
    def binom(self, n, r):
        '''
        Calculate nCr = n! /(r! (n-r)!) % mod
        '''
        if n < r or n < 0 or r < 0: return 0
        else: return self.fact[n] * (self.fact_inverse[r] * self.fact_inverse[n-r] % self.mod) % self.mod
        
    def hom(self, n, r):
        '''
        Calculate nHr = {n+r-1}Cr % mod.
        Assign r objects to one of n classes.
        Arrangement of r circles and n-1 partitions:
            o o o | o o | | | o | | | o o | | o
        '''
        if n == 0 and r > 0: return 0
        if n >= 0 and r == 0: return 1
        return self.binom(n + r - 1, r)

N, M = map(int, input().split())
com = Combinatorics(M, MOD)
ans = 0
for i in range(N+1):
    temp = com.perm(M, N)
    temp *= com.binom(N, i); temp %= MOD
    temp *= com.perm(M-i, N-i); temp %= MOD
    ans += ((-1)**i) * temp; ans %= MOD
print(ans)

Measured memory_bytes: 68092
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

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

    string s;

    cin >> s;

    int a[512345];
    memset(a, -1, sizeof(a));

    int i = 0;
    while (i < s.size())
    {
        if (s[i] == '<')
        {
            a[i] = 0;
            while (s[i] == '<')
            {
                i++;
                a[i] = a[i - 1] + 1;
            }
        }
        else
        {
            i++;
            continue;
        }
    }

    i = s.size() - 1;

    int b[512345];
    memset(b, -1, sizeof(b));

    while (i >= 0)
    {
        if (s[i] == '>')
        {
            b[i + 1] = 0;
            while (s[i] == '>')
            {
                i--;
                b[i + 1] = b[i + 2] + 1;
            }
        }
        else
        {
            i--;
            continue;
        }
    }

    ll res = 0;

    REP(i, s.size() + 1)
    {
        //cout << max(a[i], b[i]) << " ";
        res += max(a[i], b[i]);
    }

    //cout << endl;

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 4892
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>

using namespace std;



long long int gcd(long long int x, long long int y){
	
	long long int tmp;
	while(x%y!=0){
		tmp=y;
		y=x%y;
		x=tmp;
	}
	return y;
}

long long int lcm(long long int x, long long int y){
	return x*y/gcd(x,y);
}

long long int v_gcd(vector<long long int> v){
	
	if(v.size() <= 1){
		return v[0];
	}
	
	long long int tmp=v[0];
	
	for(int i=1;i<v.size();i++){
		tmp=gcd(tmp,v[i]);
	}
	return tmp;
}

long long int v_lcm(vector<long long int> v){
	
	if(v.size()<=1){
		return v[0];
	}
	
	long long int tmp=v[0];
	for(int i=1;i<v.size();i++){
		tmp = tmp*v[i]/gcd(tmp, v[i]);
	}
	return tmp;
}

int main(){
	int N;
	cin>>N;
	vector<long long int> A(N); 
	for(int i=0;i<N;i++){
		cin>>A[i];
	}
	
	cout<<v_gcd(A)<<endl;
	
	return 0;
}

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

typedef int64_t Int;
#define all(x) (x).begin(), (x).end()
 
const double EPS = 1e-10;
const Int INF = 1e18;
const int inf = 1e9;
const Int mod = 1e9+7;

bool print_space_enable = false;
void print() { 
    cout << '\n'; 
    print_space_enable = false;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    if (print_space_enable) std::cout << " ";
    cout << fixed << setprecision(15) << head;
    print_space_enable = true;
    print(std::forward<Tail>(tail)...);
}

template<typename T>
void print(vector<T> v) {
    for (size_t i = 0; i < v.size(); i++) {
        if (i > 0) std::cout << " ";
        std::cout << v[i];
    }
    std::cout << '\n';
}

void solve() {
    Int r;
    cin >> r;
    if (r < 1200) {
        print("ABC");
    } else if (r < 2800) {
        print("ARC");
    } else {
        print("AGC");
    }
}

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


Measured memory_bytes: 3572
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cctype>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <stdio.h>
#include <string.h>
#include <cstdlib>
#include <math.h>
#include <bitset>
#include <iterator>
#include <iomanip>
#include <sstream>
#define INF 2000000000
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
#define sym cout<<"-----------"<<endl;
#define ll long long
#define P pair<int,int>
#define mk make_pair
#define en endl
#define RE return 0
#define int ll

char c[105];

signed main(){
  int k;
  cin>>c;
  cin>>k;
  for(int i=0; i<strlen(c); i++){
    int num=c[i]-'0';
    if(num==1){
      k--;
      if(k==0){
        cout<<1<<en;
        RE;
      }
      continue;
    }else{
      cout<<num<<en;
      RE;
    }
  }
  cout<<1<<en;
  RE;
}



Measured memory_bytes: 256
# coding: utf-8
# Your code here!

ct = int(input())
card_list = [False for x in range(1,54)]

# 絵柄を数字に変換
def mark_num(m):
    if m == "S":
        return 0
    elif m == "H":
        return 13
    elif m == "C":
        return 26
    elif m == "D":
        return 39

def num_mark(n):
    ret = n % 13
    if ret == 0:
        ret = 13

    if n <= 13:
        return "S " + str(n)
    elif n <= 26:
        return "H " + str(ret)
    elif n <= 39:
        return "C " + str(ret)
    else:
        return "D " + str(ret)


for i in range(ct):
    mark,num = map(str,input().split())
    num = int(num)
    card_list[mark_num(mark) + num] = True
    
for i in range(1,53):
    if card_list[i] == False:
        print(num_mark(i))



Measured memory_bytes: 5608
def dfs(A):
    global ans
    if len(A) == N:
        score = 0
        for a, b, c, d in buff:
            if A[b - 1] - A[a - 1] == c:
                score += d
        ans = max(ans, score)
        return

    A.append(A[-1])
    while A[-1] <= M:
        dfs(A[:])
        A[-1] += 1


N, M, Q = map(int, input().split())
buff = [list(map(int, input().split())) for _ in range(Q)]
ans = 0
dfs([1])
print(ans)


Measured memory_bytes: 9092
#include <bits/stdc++.h>
#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++)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using pii = pair<int, int>;

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

	int A, B, M;
	cin >> A >> B >> M;
	vector<int> a(A);
	vector<int> b(B);
	map<int, vector<pii>, greater<int>> m;
	rep(i, A) cin >> a.at(i);
	rep(i, B) cin >> b.at(i);
	while (M--) {
		int x, y, c;
		cin >> x >> y >> c;
		x--;
		y--;
		m[c].push_back(make_pair(x, y));
	}
	auto smallest_A = min_element(all(a));
	auto smallest_B = min_element(all(b));
	int min_A_dist = distance(a.begin(), smallest_A);
	int min_B_dist = distance(b.begin(), smallest_B);
	int min_value = INT_MAX;
	for (auto d : m) {
		for (auto p : d.second) {
			min_value = min(min_value, a.at(p.first) + b.at(p.second) - d.first);
		}
	}
	min_value = min(min_value, a.at(min_A_dist) + b.at(min_B_dist));
	cout << min_value << endl;
}


Measured memory_bytes: 7936
#include <bits/stdc++.h>
using namespace std;
int a[100];

int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int flag = 1, cnt = 0;
  while (flag) {
    flag = 0;
    int i = 0;
    for (int j = n - 1; j >= i + 1; j--) {
      if (a[j] < a[j - 1]) {
        swap(a[j], a[j - 1]);
        flag = 1;
        cnt++;
      }
    }
    i++;
  }
  for (int i = 0; i < n; i++) {
    cout << (i ? " " : "") << a[i];
  }
  cout << "\n" << cnt << "\n";
}


Measured memory_bytes: 3084
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>

using namespace std;
using lli = long long int;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (lli i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (lli i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

lli n, m, d;
int main() {
  cin >> n >> m >> d;
  lli a = d == 0 ? n : min(n, 2 * d),
      b = max(0ll, 2 * d - n),
      c = min(n, a + b);
  double e = double(m - 1) 
    * (double(a - b) / n / n + 2 * double(n - c) / n / n);
  printf("%.10f\n", e);
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <vector>

const int mod = 1e9 + 7;
const int kmax = 510000;

long long fact[kmax], fact_inv[kmax], inv[kmax];

void init_comb()
{
    fact[0] = fact[1] = 1;
    fact_inv[0] = fact_inv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < kmax; i++) {
        fact[i] = fact[i - 1] * i % mod;
        inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        fact_inv[i] = fact_inv[i - 1] * inv[i] % mod;
    }
}

long long comb(int n, int r)
{
    if (n < r) {
        return 0;
    }

    if (n < 0 || r < 0) {
        return 0;
    }

    return fact[n] * (fact_inv[r] * fact_inv[n - r] % mod) % mod;
}

template <typename T, T N>
class UnionFind {
    T parent_[N];
    T rank_[N];
    T size_[N];

public:
    UnionFind();
    T Root(T idx);
    bool IsSame(T x, T y);
    void Unite(T x, T y);
    T GetSize(T idx);
};

template <typename T, T N>
UnionFind<T, N>::UnionFind()
{
    for (T i = 0; i < N; i++) {
        parent_[i] = i;
        rank_[i] = 0;
        size_[i] = 1;
    }
}

template <typename T, T N>
T UnionFind<T, N>::Root(T idx)
{
    return parent_[idx] == idx ? idx : parent_[idx] = Root(parent_[idx]);
}

template <typename T, T N>
bool UnionFind<T, N>::IsSame(T x, T y)
{
    return Root(x) == Root(y);
}

template <typename T, T N>
void UnionFind<T, N>::Unite(T x, T y)
{
    x = Root(x);
    y = Root(y);
    if (x == y) {
        return;
    }

    if (rank_[x] < rank_[y]) {
        parent_[x] = y;
        size_[y] += size_[x];
    } else {
        parent_[y] = x;
        size_[x] += size_[y];
        if (rank_[x] == rank_[y]) {
            rank_[x]++;
        }
    }
}

template <typename T, T N>
T UnionFind<T, N>::GetSize(T idx)
{
    return size_[Root(idx)];
}

long long pow_mod(long long n, long long p, long long m)
{
    if (p == 0) {
        return 1;
    }

    if (p % 2 == 0) {
        long long t = pow_mod(n, p / 2, m);
        return t * t % m;
    }
    return n * pow_mod(n, p - 1, m) % mod;
}

long long nCr_mod(long long n, long long r)
{
    long long x = 1;
    for (long long i = n - r + 1; i <= n; i++) {
        x *= i;
        x %= mod;
    }

    long long a = 1;
    for (long long i = 1; i <= r; i++) {
        a *= i;
        a %= mod;
    }

    long long y = pow_mod(a, mod - 2, mod) % mod;

    return x * y % mod;
}

bool is_prime(long long n)
{
    if (n == 1) {
        return false;
    }

    for (long long i = 2; i * i <= n; i++) {
        if (n % i == 0) {
            return false;
        }
    }

    return true;
}

int main()
{
    long long n, k;
    std::cin >> n >> k;

    std::priority_queue<long long, std::vector<long long>, std::greater<long long>> q;

    for (int i = 0; i < n; i++) {
        long long temp;
        std::cin >> temp;

        q.push(temp);
    }

    long long ans = 0;
    for (int i = 0; i < n - k; i++) {
        ans += q.top();
        q.pop();
    }

    std::cout << ans << std::endl;
}


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

int main() {
  	long long int N, M, K;
  	cin >> N >> M >> K;
  	long long int A[N], B[M];
  	for (int i = 0; i < N; i++) cin >> A[i];
  	for (int i = 0; i < M; i++) cin >> B[i];
  
  	long long int sum_B = 0;
  	long long int count = 0;
  	for (int i = 0; i < M; i++) {
      	if (sum_B + B[i] > K) break;
      	sum_B += B[i];
      	count++;
    }
  
  	long long int count_ = count;
  	long long int res = 0;
    if (sum_B <= K) res = max(res, count_);
  	for (int i = 0; i < N; i++){
      	sum_B += A[i];
      	count_++;
      	while (sum_B > K){
          	if (count == 0) break;
          	sum_B -= B[count - 1];
          	count--;
          	count_--;
        }
      	if (sum_B <= K) res = max(res, count_);
    }
  
  	cout << res << endl;
}

Measured memory_bytes: 6748
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define Graph vector< vector<int> >
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1000000007;

const double EPS = 1e-10;
#define equals(a, b) (fabs((a) - (b)) < EPS)

struct Point{
    double x, y;
    Point(){}
    Point(double x0, double y0){
        x = x0; y = y0;
    }

    Point operator +(const Point &p){
        return Point(x + p.x, y + p.y);
    }
    Point operator -(const Point &p){
        return Point(x - p.x, y - p.y);
    }
    Point operator *(const double &a){
        return Point(a * x, a * y);
    }
    Point operator /(const double &a){
        return Point(x / a, y / a);
    }

    bool operator == (const Point &p){
        return equals(x, p.x) && equals(y, p.y);
    }

    bool operator < (const Point &p){
        return x != p.x ? x < p.x : y < p.y ;
    }

};

double norm(Point p){
    return p.x * p.x + p.y * p.y;
}

double v_abs(Point p){
    return sqrt(norm(p));
}

typedef Point Vector;

double dot(Vector a, Vector b){
    return a.x * b.x + a.y * b.y;
}

double cross(Vector a, Vector b){
    return a.x * b.y - a.y * b.x;
}

struct Circle{
    Point c;
    double r;
    Circle(){}
    Circle(Point c0, double r0){
        c.x = c0.x;
        c.y = c0.y;
        r = r0;
    }
    Circle(double x0, double y0, double r0){
        c.x = x0;
        c.y = y0;
        r = r0;
    }
};

int ccw(Point p0, Point p1, Point p2){
    int COUNTER_CLOCKWISE = 1;
    int CLOCKWISE = -1;
    int ON_SEGMENT = 0;
    int ONLINE_FRONT = 2;
    int ONLINE_BACK = -2;
    Vector a = p1 - p0, b = p2 - p0;
    if(cross(a, b) > EPS) return COUNTER_CLOCKWISE;
    else if(cross(a, b) < -EPS) return CLOCKWISE;
    else if(dot(a, b) < -EPS) return ONLINE_BACK;
    else if(norm(a) < norm(b)) return ONLINE_FRONT;
    else return ON_SEGMENT;
}

int main(){
    int Q;
    cin >> Q;
    rep(i, Q){
        Point p0, p1, p2, p3;
        cin >> p0.x >> p0.y;
        cin >> p1.x >> p1.y;
        cin >> p2.x >> p2.y;
        cin >> p3.x >> p3.y;
        if(ccw(p0, p1, p2) * ccw(p0, p1, p3) <= 0 && ccw(p2, p3, p0) * ccw(p2, p3, p1) <= 0 ){
            cout << 1 << endl;
        }
        else cout << 0 << endl;
    }
}


Measured memory_bytes: 3224
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        var N = int.Parse(ReadLine());

        IEnumerable<int> GetNum(int a, int b)
        {
            var q = new Queue<int>();

            var v = 0;

            if (a == b)
            {
                v = a;
                yield return v;
            }

            v = a * 10 + b;
            q.Enqueue(v);
            yield return v;

            while(true)
            {
                v = q.Dequeue();
                v -= b;
                v *= 10;
                for (int i = 0; i <= 9; i++)
                {
                    var _v = v + (i * 10) + b;
                    q.Enqueue(_v);
                    yield return _v;
                }
            }
        }

        var pairCount = new int[10, 10];

        for (int i = 1; i <= 9; i++)
        {
            for (int j = 1; j <= 9; j++)
            {
                pairCount[i, j] = GetNum(i, j).TakeWhile(x => x <= N).Count();
            }
        }

        var ans = 0;

        for (int i = 1; i <= N; i++)
        {
            var iStr = i.ToString();
            var a = iStr[0] - '0';
            var b = iStr[iStr.Length - 1] - '0';

            ans += pairCount[b, a];
        }

        WriteLine(ans);
    }
}


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

int main(void){
    int n;
    cin>>n;
    if(n%1000==0) puts("0");
    else cout<<1000-n%1000<<endl;
    return 0;
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
	priority_queue<int> que;
	int n,a[1000];
	int i,j,k;
	int M[4],sum,cnt;
	double Max;
	cin>>n;
	for(i=0;i<n;i++){
		cin>>a[i];
		que.push(a[i]);
	}
	for(i=0;i<4;i++){
		M[i]=que.top();
		que.pop();
	}
	Max=-1;
	for(i=0;i<n;i++){
		for(j=0;j<n;j++){
			if(i==j||a[i]<a[j]) continue;
			cnt=0; sum=0;
			for(k=0;k<4;k++){
				if(M[k]!=a[i]&&M[k]!=a[j]){
					cnt++;
					sum+=M[k];
				}
				if(cnt==2) break;
			}
			if(Max<(double)sum/(a[i]-a[j])) Max=(double)sum/(a[i]-a[j]);
		}
	}
	printf("%lf\n",Max);
	return 0;
}
	


Measured memory_bytes: 3308
#include <bits/stdc++.h>
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<class T>using numr=std::numeric_limits<T>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1e9;
const ll LLINF = 1e16;
const int MOD = 1000000007;
const int MOD2 = 998244353;

ll dp[100010];
int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    int n,k;
    cin >>n >> k; 
    vector<int> h(n);
    for(int i=0;i<n;i++) cin >> h[i];

    dp[0] = 0;
    for(int i = 1;i < n; i++){
        dp[i] = LLINF;
        for(int j = 1; j <= k;j++){
            if(i - j >= 0) dp[i] = min(dp[i], dp[i-j] + abs(h[i] - h[i-j]));
        }
    }
    cout << dp[n - 1] << endl;
    return 0;
}

Measured memory_bytes: 4516
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
using namespace std;

int main(){
    string S, T;
    set<char> v;
    cin >> S >> T;

 /*   for(int i = 0; i  < S.size(); i++){
        char tmp = S[i];
        if(S[i] != T[i]){
            bool flag = 1;
            for(auto x: v ){
     //           cout << x << endl;
                if(x == S[i]){
                    flag = 0;
                    break;
                }
            }
            if(flag){
              //  cout << i <<  "yes\n";
                replace(S.begin(), S.end(), T[i], '-');
                replace(S.begin(), S.end(), tmp, T[i]);
                replace(S.begin(), S.end(), '-', tmp);
                v.insert(T[i]);
                v.insert(tmp);
            }
        }
      cout << S <<endl;
    }
    if(S == T) cout << "Yes\n";
    else cout << "No\n";*/
    int R[26], R2[26];
    for(int i = 0; i < 26; i++){
        R[i] = -1;
        R2[i] = -1;
    }
    bool flag  = 1;
    for(int i = 0; i < S.size(); i++){
        if(R[(int)(S[i] - 'a')] < 0){
            R[(int)(S[i] - 'a')] = T[i] - 'a';
            //R[(int)(T[i] - 'a')] = S[i] - 'a';
           // cout << S[i] - 'a' << R[S[i] - 'a'] << endl;
        }else{
            if(R[(int)(S[i]- 'a')] != (int)(T[i] - 'a')){
                flag = 0;
                break;
            } 
        }
        if(R2[(int)(T[i] - 'a')] < 0){
            R2[(int)(T[i] - 'a')] = S[i] - 'a';
            //R[(int)(T[i] - 'a')] = S[i] - 'a';
            //cout << S[i] - 'a' << R[S[i] - 'a'] << endl;
        }else{
            if(R2[(int)(T[i]- 'a')] != (int)(S[i] - 'a')){
                flag = 0;
                break;
            } 
        }
    }
    if(flag) cout << "Yes\n";
    else cout << "No\n";
}

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

int main(){
  int a[3],k;
  cin>>a[0]>>a[1]>>a[2]>>k;
  int maxi(max(a[0],max(a[1],a[2])));
  for (int i(0);i<k;i++){
    maxi*=2;
  }
  cout << a[0]+a[1]+a[2]+maxi-max(a[0],max(a[1],a[2])) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iterator>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <numeric>
#include <iomanip>
#include <limits>

using namespace std;

int main(){

   bool ans=true;

   string s;
   cin>>s;

   if((s.size()-1)%4==0){
        for(int i=0;i<(s.size()-1)/4;i++){
            if(!(s[i]==s[(s.size()-1)/2-1-i] && s[i]==s[(s.size()+3)/2-1+i] && s[i]==s[s.size()-1-i])){
                ans=false;
                break;
            }
        }
   }
   else{
       for(int i=0;i<(s.size()-1)/4;i++){
            if(!(s[i]==s[(s.size()-1)/2-1-i] && s[i]==s[(s.size()+3)/2-1+i] && s[i]==s[s.size()-1-i])){
                ans=false;
                break;
            }
        }
        if(s[(s.size()-1)/4]!=s[s.size()-(s.size()-1)/4-1]){
            ans=false;
        }
   }

   if(ans){
       cout<<"Yes"<<endl;
   }
   else{
       cout<<"No"<<endl;
   }
   
    return 0;
}


Measured memory_bytes: 256
object Main{
  def main(args: Array[String]){
    if (sys.env.getOrElse("TEST", "")=="1"){
      println(test());
    }else{
      val input=io.Source.stdin.getLines().mkString("\n");
      println(solve(input).trim());
    }
  }

  def solve(input:String):String={
    input.split("\n").drop(1).toSet.size.toString()
  }

  val tests=List("""4
10
8
8
6""" -> """3""",
    """3
15
15
15""" -> """1""",
"""7
50
30
50
100
50
80
30"""->"""4""");

  def test():String= {
    return tests.map{case (i,o)=>(i.trim(),o.trim())}.zipWithIndex.map{case ((input,outputExpect),i)=>{
      val output=solve(input).trim();
      s"test${i+1}:"+(if(output==outputExpect){
        "Passed"
      }else{
        s"Failed\nexpect:\n${outputExpect}\noutput:\n${output}"
      })
    }}.mkString("\n");
  }
}

Measured memory_bytes: 25412
///
#include <stdio.h>
int main(void)
{
  int a, b, c;

  // スペース区切りの整数の入力 入力 123
  scanf("%d %d %d", &a, &b, &c);

  // 出力する312
  printf("%d %d %d\n", c, a, b );

  return 0;
}

Measured memory_bytes: 128
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {       
        
        Scanner sr = new Scanner(System.in);
		String s = sr.next().substring(0,4);
		int takashi_eat = 0;
		
		for(int i = 0; i < s.length(); i++){
			if(s.substring(i, i + 1).equals("+")){
				takashi_eat++;
			}else{
				takashi_eat--;
			}
		}
		System.out.println(takashi_eat);
    }
}

Measured memory_bytes: 23124
#include<iostream>

#include<stdio.h>

#include<algorithm>

#include<string.h>

#include<vector>

#include<stack>

using namespace std;

const int maxn = 100000+55;

const int inf = 0x3f3f3f3f;

#define LL long long

 

int pos[2][2020];

int num[4020];

int dp[2020][2020];

 

int w;

void add(int x,int p) { for(int i=x;i<=w;i+=i&-i) num[i]+=p;}

 

int sum(int x){int ans=0; for(int i=x;i>=1;i-=i&-i) ans+=num[i]; return ans;}

 

 

int main()

{

	int n;

	scanf("%d",&n);

	w=2*n;

	for(int i=1;i<=w;i++){

		char c;int x;

		cin>>c>>x;

		pos[c=='W'][x]=i;

		add(i,1);

	}

	pos[0][0]=pos[1][0]=w+1;

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

		add(pos[0][i],-1);

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

			add(pos[1][j],-1);

			if(i||j){

				dp[i][j]=inf;

				if(i)

					dp[i][j]=min(dp[i][j],dp[i-1][j]+sum(pos[0][i]-1));

				if(j)

					dp[i][j]=min(dp[i][j],dp[i][j-1]+sum(pos[1][j]-1));

			}

		}

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

			add(pos[1][j],1);

		}

	}

	printf("%d\n",dp[n][n]);

	return 0;

}

Measured memory_bytes: 19652
#include<iostream>
using namespace std; // 575

int main() {
	int N;
	cin >> N;
	int M = N * (N - 1) / 2 - N / 2;
	cout << M << endl;
	for (int i = 1;i <= N;++ i) {
		for (int j = i + 1;j <= N;++ j) {
			if (i + j != N / 2 * 2 + 1) cout << i << " " << j << endl;
		}
	}
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり
また、コンテスト後に https://31536000.hatenablog.com/ で解説していると思うので、良かったら読んでねー

やるだけ
*/

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const int N = 200100;

ll f[N], finv[N];

ll mod_pow(ll x, ll e){
  ll v = 1;
  for(;e;e>>=1){
    if(e & 1)v = (v * x) % MOD;
    x = (x * x) % MOD;
  }
  return v;
}

void init(){
  f[0] = 1;
  for(int i=1;i<N;i++)f[i] = f[i-1] * i % MOD;
  finv[N-1] = mod_pow(f[N-1], MOD - 2);
  for(int i=N-2;i>=0;i--)finv[i] = finv[i+1] * (i + 1) % MOD;
}

ll C(int n, int k){
  ll res = f[n];
  res = (res * finv[k]) % MOD;
  res = (res * finv[n-k]) % MOD;
  return res;
}

int main(){
  init();

  int H, W, A, B;
  cin >> H >> W >> A >> B;

  ll res = 0;
  for(int x = B + 1; x <= W; x++){
    int sy = H - A - 1, sx = x - 1;
    ll tmp = C(sy + sx, sx);
    int ry = A - 1, rx = W - x;
    tmp = (tmp * C(ry + rx, rx)) % MOD;
    res = (res + tmp) % MOD;
  }
  cout << res << endl;
	return 0;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pb push_back
#define lowbit(x) ((x)&(-x))
#define inf 0x3f3f3f3f
#define endl "\n"
#define MP(x,y) (make_pair(x,y))
#define pll pair<int,int>
#define pi 3.1415926535
using namespace std;
int main(){
    int n;
    cin>>n;
        bool f=0;
    while(n){
        if(n%10==7) f=1;
        n/=10;
    }
    puts(f?"Yes":"No");
    return 0;
}


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

using namespace std;
typedef long long ll;

int N, M;
ll K;
ll x[100000];
ll d[100000];
int a[100000];

vector<int> manip;

void init(){
    for(int i = 0; i < N; i++) manip.push_back(i);
}

/**
 * 置換操作 
 */
vector<int> replace(vector<int> prev, vector<int> operation){
    int n = operation.size();
    vector<int> ans(n);
    for(int i = 0; i < n; i++){
        ans[i] = prev[operation[i]];
    }
    return ans;
}

vector<int> pow(vector<int> a, ll n) {
	vector<int> ans;
    for(int i = 0; i < a.size(); i++) ans.push_back(i);
	vector<int> tmp = a;
	for (int i = 0; i <= 60; i++) {
		ll m = (ll)1 << i;
		if (m & n) {
		ans = replace(ans, tmp);
		}
		tmp = replace(tmp, tmp);
	}
	return ans;
}

ll ans[100000];

int main(){
    cin >> N;
    for(int i = 0; i < N; i++) cin >> x[i];
    for(int i = 0; i < N-1; i++) d[i] = x[i+1]-x[i];
    cin >> M >> K;
    for(int i = 0; i < M; i++) {
        cin >> a[i];
        a[i]-=2;
    }
    init();
    for(int i = 0; i < M; i++){
        swap(manip[a[i]], manip[a[i]+1]);
    }
    vector<int> last = pow(manip, K);
    ans[0] = x[0];
    for(int i = 0; i < N-1; i++){
        ans[i+1] = ans[i]+d[last[i]];
    }
    for(int i = 0; i < N; i++) cout << ans[i] << endl;
}

Measured memory_bytes: 6344
#include <stdio.h>

int main(){
  int n,i;
  scanf("%d",&n);
  for(i=1;i<=9;i++){
    if((n%i==0)&(n/i<=9)) break;
  }
  if(i==10){
    printf("No");
  }else{
    printf("Yes");
  }
  return(0);
}

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

int main(){
  int n,tmp;
  vector<int> r;
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> tmp;
    r.push_back(tmp);
  }
  int mini = r[0];
  long prof = -10000000000;
  for(int i=1;i<n;i++){
    prof = max(prof,long(r[i]-mini));
    mini = min(mini,r[i]);
  }

  cout << prof << endl;
  return 0;
}

Measured memory_bytes: 3868
#include <iostream>
#define REP(i, a, n) for(int i = ((int) a); i < ((int) n); i++)
using namespace std;

int N;
char C[2000];
int cnt[256];

int main(void) {
  while(cin >> N, N) {
    REP(i, 0, N) cin >> C[i];

    REP(i, 0, 256) cnt[i] = 0;
    REP(i, 0, N) {
      cnt[C[i]]++;
      char ans = '#';
      REP(j, 'A', 'Z' + 1) {
        bool g = true;
        REP(k, 'A', 'Z' + 1) {
          if(j == k) continue;
          if(cnt[j] <= cnt[k] + (N - i - 1)) g = false;
        }
        if(g) {
          if(ans == '#') ans = j;
          else ans = '.';
        }
      }
      if(ans != '#' && ans != '.') {
        cout << ans << " " << i + 1 << endl;
        break;
      }
      if(i == N - 1) {
        cout << "TIE" << endl;
      }
    }
  }
}

Measured memory_bytes: 3032
# 0028
array = []
while True:
    try:
        a = input()
        array.append(int(a))
    except EOFError:
        break
count = list(map(lambda a: array.count(a), set(array)))
modes = list(filter(lambda a: array.count(a) == max(count), set(array)))
print(*modes, sep = '\n')

Measured memory_bytes: 7692
#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>
#include <cctype>
using namespace std;
int main() {
	string s;
	cin >> s;
	int n = s.size();
	long long sum = 0, ans = 0;
	for (int i = 0; i < n; i++) {
		if (s[i] == 'W') {
			ans += sum;
		}
		else {
			sum++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
#define fout cout << fixed << setprecision(20)
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main() {
    ll n, k;
    cin >> n >> k;
    cout << min(n % k, k - n % k) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<(n);i++)
#define rep2(i,a,n) for(int i=a;i<n;i++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
const ll INFL = 1e18;
const int INF = 1001001001; 
typedef pair<int,int> P;
#define foreach(ix,i) for(auto& (ix) : (i))
typedef long double ld;
const int mod =1000000007;

int main(){

   string s ;cin>>s;
   int n =s.length();
   if(s[n-1]=='2'||s[n-1]=='4'||s[n-1]=='5'||s[n-1]=='7'||s[n-1]=='9'){
       cout<<"hon"<<endl;
   } 
   else if(s[n-1]=='3'){
       cout<<"bon"<<endl;
   }
   else cout<<"pon"<<endl;
}

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

using namespace std;

int N;
vector<int> X;
vector<int> X_sorted;

int main(){
	cin >> N;
	X.resize(N);
	X_sorted.resize(N);
	for(int i = 0; i < N; ++i) cin >> X[i];
	X_sorted = X;
	sort(X_sorted.begin(), X_sorted.end());
	
	int median = X_sorted[N/2-1];
	
	for(int i = 0; i < N; ++i){
		if(X[i] <= median){
			cout << X_sorted[N/2] << endl;
		}else{
			cout << X_sorted[N/2-1] << endl;
		}
	}
}

Measured memory_bytes: 3712