akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;

const int MOD = 1000000007;
using Data = pair<long long, vector<ll> >;

int main() {
  ll n,x;
  cin >> n >> x;
  ll ans=0;
  vector<ll>vec(n);
  rep(i,n) cin >> vec[i];
  
  if(vec[0]>x){
    ans+=vec[0]-x;
    vec[0]=x;
  }
  rep(i,n-1){
    if(vec[i]+vec[i+1]>x){
      ans+=vec[i]+vec[i+1]-x;
      vec[i+1]=max((ll)0,x-vec[i]);
    }
  }
  cout << ans << endl;
  
}


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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define ASC(x) sort(ALL((x)))
#define DESC(x) sort(ALL((x)),greater<ll>())
#define pb push_back

int main()
{
    ll N, M;
    cin >> N >> M;
    priority_queue<ll> A;
    ll a;
    REP(i,0,N) {
        cin >> a;
        A.push(a);
    }

    REP(i,0,M) {
        a = A.top(); A.pop();
        A.push(a/2);
    }

    ll sum = 0;
    while(!A.empty()) {
        a = A.top(); A.pop();
        sum += a;
    }
    PR(sum);

    return 0;
}

/*



*/

Measured memory_bytes: 1400
#include <iostream>
#include <cmath>
#include <iomanip>


using namespace std;

int p[9];
int temp[9];
int N;
double x[9], y[9];
long double ans=0;

void perm(int *s, int n){
  int i, j, k, judge = 0;
  if(n == N+1){
    for(j=1; j<=N-1; j++){
      //printf("(%lf, %lf) (%lf, %lf)", x[*(temp+j)], x[*(temp+j)], x[*(temp+j+1)], x[*(temp+j+1)]);
      ans += sqrt((x[*(temp+j)]-x[*(temp+j+1)])*(x[*(temp+j)]-x[*(temp+j+1)]) + (y[*(temp+j)]-y[*(temp+j+1)])*(y[*(temp+j)]-y[*(temp+j+1)]));
      //cout << ans << endl;
    }
    //printf("\n");
  }else{
    for(i=1; i<=N; i++){
      temp[n] = i;
      for(k=1; k<n; k++){
	if(temp[n] == temp[k]){
	  judge = 1;
	  break;
	}
      }
      if(judge == 1){
	judge = 0;
	continue;
      }
      perm(p+i, n+1);
    }
  }
}

int main(){
  cin >> N;
  for(int i=1; i<=N; i++){
    p[i] = i;
    temp[i] = p[i];
  }
  for(int i=1; i<=N; i++) cin >> x[i] >> y[i];
  perm(p+1, 1);
  for(double i=1; i<=N; i++) ans /= i;
  cout << setprecision(20) << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb(x) push_back(x)
#define f(i,st,n) for(i=st;i<n;i++)
#define qu queue
#define ps(x) push(x)
#define vec vector
#define ft() front()
#define mst(a,b) memset(a,b,sizeof(a))
#define mod 1000000007
#define sfl(x) scanf("%lld",&x)
#define pfl(x) printf("%lld\n",x)
#define pf(x) printf("%lld",x)
#define mpr make_pair
#define fs first
#define se second
#define inf LLONG_MAX
 
 
 
ll gcd(ll a,ll b){
    if(a==0){
        return b;
    }                     
    return gcd(b%a,a);
}
ll power(ll x,ll y){            
    ll res=1;
    while(y>0){
        if(y%2==1){
            res=(res*x);
        }
        x=(x*x);
        y=y/2;
    }
    return res;
}
 
 vec<ll>v[100005];
 ll dp[100005],vis[100005],ans=LLONG_MIN;


ll dfs(ll u){
  vis[u]=1;

  for(auto z:v[u]){
     if(!vis[z]){

      ll x=dfs(z);

       dp[u]=max(dp[u],x);    


        }

        else{

           dp[u]=max(dp[u],1+dp[z]);
        }

     }


     


  
  ans=max(ans,1+dp[u]);
  return 1+dp[u];



}

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

ll n,m,i,j,x,y;
sfl(n);sfl(m);

f(i,0,m){

sfl(x);sfl(y);
v[x].pb(y);
}

f(i,1,n+1){
if(!vis[i]){
dfs(i);
}

}
cout<<ans-1;


   return 0;
 }

Measured memory_bytes: 8576
/*
* Welcome to my code!
*---------------------------------------------*
* author : lynmisakura(twitter : @andoreiji11)
*/
#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <cassert>

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define repn for(int i = 0;i < n;i++)
#define ain(a) for(auto& i : a)cin >> i;
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x.size()) 
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define cont continue

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using pi = pair<int,int>;
using vpi = vector<pi>;
using pl = pair<ll,ll>;
using vpl = vector<pl>;

template<class T> bool chmin(T& a,T b){if(a > b){a = b;return true;}else return false;}
template<class T> bool chmax(T& a,T b){if(a < b){a = b;return true;}else return false;}
template<class T> void print(std::vector<T> a)
{ int sz = a.size(); for(int i=0;i<a.size();i++)cout << a[i] << (i < sz-1 ? ' ' : '\n'); }
void ioboost(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}
///////////////////////////////////////////////////////////
int a[200020];

int _next[200020][64];
int main(void){
  int n;
  cin >> n;
  ll x;cin >> x;
  rep(i,n)cin >> a[i];
  rep(i,n)a[i]--;

  for(int i = 1;i <= 63;i++){
    for(int j = 0;j < n;j++){
      if(i == 1)_next[j][i] = a[j];
      else _next[j][i] = _next[_next[j][i-1]][i-1];
    }
  }

  ll now = 0;
  rep(i,64){
    if(x >> i & 1)now = _next[now][i + 1];
  }
  cout << now + 1 << '\n';
}

Measured memory_bytes: 54420
#include <stdio.h>
#include <stdlib.h>

int count;

void insertionSort(int A[], int n, int g)
{
    int i;
    int j;
    int v;

    for(i = g; i < n; i++) {
        v = A[i];
        j = i - g;
        while(j >= 0 && A[j] > v) {
            A[j+g] = A[j];
            j = j - g;
            count++;
        }
        A[j+g] = v;
    }
}

void shellSort(int A[], int n)
{
    int m;
    int *G;
    int i;
    int c;

    count = 0;
    m = 1;
    for(c = n; (c/9) != 0; c /= 9) {
        m += 1;
    }
    //m = n / 2;
    G = (int *)malloc(sizeof(int) * m);
    G[m-0-1] = 1;
    for(i = 1; i < m; i++) {
        G[m-i-1] = 3*G[m-i] + 1;
    }
    for(i = 0; i < m; i++) {
        insertionSort(A, n, G[i]);
    }

    printf("%d\n", m);
    for(i = 0; i < m-1; i++) {
        printf("%d ", G[i]);
    }
    printf("%d\n", G[i]);
    printf("%d\n", count);

    free((void *)G);
}

int main()
{
    int n;
    int *A;
    int i;

    scanf("%d", &n);
    A = (int *)malloc(sizeof(int) * n);
    for(i = 0; i < n; i++) {
        scanf("%d", &A[i]);
    }

    shellSort(A, n);

    for(i = 0; i < n; i++) {
        printf("%d\n", A[i]);
    }

    return 0;
}


Measured memory_bytes: 5700
n = int(input())
s = input()

r = 0
g = 0
b = 0
for c in s:
    if c == 'R':
        r += 1
    if c == 'G':
        g += 1
    if c == 'B':
        b += 1

total = r*g*b

for i in range(0, n-2):
    for j in range(i+1, n-1):
        k = j - i + j
        if k >= n:
            break
        elif s[i] != s[j] and s[j] != s[k] and s[k] != s[i]:
            total -= 1
print(total)

Measured memory_bytes: 9220
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

using ll = long long;

struct Data {
    ll h, a, d, s;
    
    Data() {}
    Data(ll h, ll a, ll d, ll s) :
        h{h}, a{a}, d{d}, s{s} {}

    bool operator < (const Data& d) const {
        return s < d.s;
    }
};

istream& operator >> (istream& is, Data& d)
{
    return is >> d.h >> d.a >> d.d >> d.s;
}

ll solve(Data& M, vector<Data>& ene)
{
    vector<pair<double, Data>> v;
    for (const Data& e : ene) {
        if (M.a <= e.d && M.d < e.a) return -1;
        ll turn = ceil((double)e.h / (M.a - e.d));
        if (e.a - M.d <= 0) continue;
        v.emplace_back((double)turn / (e.a - M.d), e);
    }

    sort(v.begin(), v.end());
    
    ll res = 0, total_turn = 0;
    for (const auto& d : v) {
        Data e = d.second;
        ll turn = ceil((double)e.h / (M.a - e.d));
        total_turn += turn;
        
        ll damage = (total_turn - (M.s > e.s)) * max(0LL, e.a - M.d);
        M.h -= damage;
        if (M.h <= 0) return -1;
        res += damage;
    }        
    return res;
}

int main()
{
    int N;
    cin >> N;
    Data M;
    cin >> M;
    vector<Data> ene(N);
    for (int i = 0; i < N; i++) {
        cin >> ene[i];        
    }
    cout << solve(M, ene) << endl;
    return 0;
}

Measured memory_bytes: 6668
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

vector<vector<P>> G;
vl color;  // color[i] : 辺iの色

void dfs(ll v, ll p = -1, ll c = -1) {  // v : いまいる頂点, p : vの親, c : 辺p-vの色
    // 行きの処理はこのへんに書く
    ll num = 1;  // いまから辺を塗る色
    for(auto p1 : G[v]) {
        ll u = p1.first;
        ll id = p1.second;  // vとuは辺idでつながっている
        if(u == p) {
            continue;
        }
        if(num == c) {  // 辺v-uをnumで塗りたいが、numとcが同じとき
            num++;
        }
        color[id] = num;  // 辺v-uをnumで塗る
        num++;
        dfs(u, v, color[id]);
        // 帰りの処理はこのへんに書く
    }
}

int main() {
    ll n;
    cin >> n;    

    G.resize(n);
    rep(i, n-1) {
        ll a, b;
        cin >> a >> b;
        a--;  b--;
        G[a].pb(make_pair(b, i));
        G[b].pb(make_pair(a, i));
    }

    ll K = 0;
    rep(v, n) {
        chmax(K, (ll)G[v].size());
    }
    out(K);

    color.resize(n-1);
    const ll root = 0;
    dfs(root);

    rep(i, n-1) {
        out(color[i]);
    }

    re0;
}

Measured memory_bytes: 9728
import sys
import math
import heapq
import bisect
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
DVSR = 1000000007
def POW(x, y): return pow(x, y, DVSR)
def INV(x, m=DVSR): return pow(x, m - 2, m)
def DIV(x, y, m=DVSR): return (x * INV(y, m)) % m
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def FLIST(n):
    res = [1]
    for i in range(1, n+1): res.append(res[i-1]*i%DVSR)
    return res

N,K = LI()
AS=LI()
AS.sort(reverse=True)
res = 1
if AS[0] >= 0 and AS[N-1] >= 0:
    for i in range(K):
        res *= AS[i]
        res %= DVSR
elif AS[0] > 0:
    if N != K:
        PS = []
        NS = []
        for i in AS:
            if i >= 0:
                PS.append(i)
            else:
                NS.append(-i)
        PS.sort(reverse=True)
        NS.sort(reverse=True)
        i = 0
        j = 0

        for k in range(K):
            if i < len(PS) and j < len(NS):
                if PS[i] > NS[j]:
                    res *= PS[i]
                    i += 1
                else:
                    res *= NS[j]
                    j += 1
            else:
                if i < len(PS):
                    res *= PS[i]
                    i += 1
                else:
                    res *= NS[j]
                    j += 1
            res %= DVSR
            # print(res)
        # print("i:{} j:{}".format(i, j))
        if j % 2:
            if j < len(NS) and i < len(PS) and i > 0 and j > 0:
                if NS[j]*NS[j-1] > PS[i-1]*PS[i]:
                    res *= INV(PS[i-1])
                    res %= DVSR
                    res *= NS[j]
                    j += 1
                else:
                    res *= INV(NS[j-1])
                    res %= DVSR
                    res *= PS[i]
                    i += 1
            else:
                if j < len(NS) and i > 0:
                    res *= INV(PS[i-1])
                    res %= DVSR
                    res *= NS[j]
                    j += 1
                else:
                    res *= INV(NS[j-1])
                    res %= DVSR
                    res *= PS[i]
                    i += 1
            res %= DVSR
            # print(res)
    else:
        for i in range(N):
            res *= AS[i]
            res %= DVSR
else: # AS[0] <= 0
    if K % 2:
        v1 = 1
        v2 = 1
        for i in range(K):
            v1 *= AS[i]
            v1 %= DVSR
        res = v1
    else:
        res = 1
        for i in range(N-K, N):
            res *= AS[i]
            res %= DVSR

print(res%DVSR)


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

#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))

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


Measured memory_bytes: 128
l=[0]*(10**5)
for i in range(1,10**5+1):
  for j in range(2,int(i**0.5)+1):
    if i%j==0:
      break
  else:
    l[i-1]=1
  
d=[0]*(10**5)
t=3
while t<=10**5:
  if l[t-1]==1 and l[(t-1)//2]==1:
    d[t-1]=1
  t+=2

r=[0]*(10**5+1)
for i in range(10**5):
  r[i+1]=r[i]+d[i]
  

q=int(input())
for i in range(q):
  a,b=map(int,input().split())
  print(r[b]-r[a-1])


Measured memory_bytes: 13712
N, M = map(int, input().split())
st = 1 * 10 ** (N-1)
en = st * 10
if N == 1:
    st = 0
SC = []
for i in range(M):
    sc = list(map(int,input().split()))
    SC.append(sc)
    
for i in range(st,en):
    t = str(i)
    judge = True
    for j in range(M):
        if t[SC[j][0]-1] != str(SC[j][1]):
            judge = False
    if judge:
        print(i)
        exit()
print("-1")


Measured memory_bytes: 9028
#[allow(unused_imports)]
use std::cmp;
use std::io::Write;

// Input macro from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
  (source = $s:expr, $($r:tt)*) => {
    let mut iter = $s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
  ($($r:tt)*) => {
    let s = {
      use std::io::Read;
      let mut s = String::new();
      std::io::stdin().read_to_string(&mut s).unwrap();
      s
    };
    let mut iter = s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
}

macro_rules! input_inner {
  ($iter:expr) => {};
  ($iter:expr, ) => {};

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

macro_rules! read_value {
  ($iter:expr, ( $($t:tt),* )) => {
    ( $(read_value!($iter, $t)),* )
  };

  ($iter:expr, [ $t:tt ; $len:expr ]) => {
    (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
  };

  ($iter:expr, chars) => {
    read_value!($iter, String).chars().collect::<Vec<char>>()
  };

  ($iter:expr, usize1) => {
    read_value!($iter, usize) - 1
  };

  ($iter:expr, [ $t:tt ]) => {{
    let len = read_value!($iter, usize);
    (0..len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
  }};

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

fn main() {
  let out = std::io::stdout();
  let mut out = std::io::BufWriter::new(out.lock());
  macro_rules! puts {
    ($($format:tt)*) => (write!(out,$($format)*).unwrap());
  }
  input! {
    n: usize,
    d: [i32; n],
  }
  let mut ans = 0;
  for i in 0 .. n {
    for j in 0 .. i {
      ans += d[i] * d[j];
    }
  }

  puts!("{}\n", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#include <time.h>
#include <stdlib.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define ull unsigned long long
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/__gcd((a),(b))
#define clr(x) x.clear()
#define vi vector<int>
#define vll vector<long long>
#define vvi vector<vi>
#define mp make_pair
#define hell 1000000007
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vpii vector<pii>
#define vpll vector<pll>
#define all(a) a.begin(),a.end()
#define ign cin.ignore();

#define o_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define o_setll tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
//member functions :
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set

using namespace std;
using namespace __gnu_pbds;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifdef MY_PROJECT
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

int main()
{
    IOS
    ll n,k;
    cin>>n>>k;
    if(n>k){
    ll a=k-n%k;
    ll b=k-a;
    cout<<min(a,b);
    }
    else{
        cout<<min(n,k-n);
    }

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int n,m,pc,count;
  while(cin>>n>>m){ 
    if(n==0&&m==0) break;
    int p[n+1];
    p[0] = 0;
    pc = n;
    count = 0;
    for(int i=1;i<=n;i++) p[i] = 1;
    while(pc!=1){
      for(int i=1;i<=n;i++){
	if(p[i]==1) count++;
	if(count==m){
	  p[i] = 0;
	  pc--;
	  if(pc==1) break;
	  count = 0;
	}
      } 
    }
    for(int i=1;i<=n;i++){
      if(p[i]==1) cout << i << endl;
    }
  }
    return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>
#define M 1000000007
#define N 200016

unsigned long ulget();
inline unsigned long ulget()
{
    register unsigned long t = 0;
    register char c;
    while((c = getchar() - '0') >= 0)
    {
        t = t * 10 + c;
    }
    return t;
}

unsigned int colorlastdp[N];
int main()
{
    unsigned int dp[N];
    unsigned int n = ulget();
    dp[0] = 0; dp[1] = 1;
    register unsigned int color, lastcolor = 0;
    for (register unsigned int i = 1; i <= n;)
    {
        color = ulget();
        if (color != lastcolor)
            dp[i] = (dp[i] + colorlastdp[color]) % M;
        dp[++i] = colorlastdp[color] = dp[i];
        lastcolor = color;
        //printf("%d %d %d\n", i, color, dp[i]);
    }
    printf("%u", dp[n]);
}


Measured memory_bytes: 3152
n,k = gets.chomp.split(" ").map{|i|i = i.to_i}

shou = (10**9)+7

a = gets.chomp.split(" ").map{|i|i = i.to_i}
#pp n
#pp a
count = 0

n.times do |j|
  j.times do|i|
    if a[i]>a[j] then
      count += 1
    end
  end
end
#puts count
count =( count * k )%shou

j_count = 0
n.times do |i|
  n.times do|j|
    if a[i]>a[j] then
      j_count += 1
    end
  end
end
#puts "j_count = #{j_count}"
new_k = ( ((k-1) *k) / 2)%shou
#puts "new_k = #{new_k}"
j_count = (new_k * (j_count%shou) ) %shou
count =( count + j_count ) % shou
puts count

Measured memory_bytes: 3836
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll=long long;
using vec=vector<ll>;
using Graph = vector<vector<ll>>;
#define loop(i,n) for(ll i=0;i<n;i++)
#define Loop(i, m, n) for(ll i = m;i < n;i++)
#define pool(i,n) for(ll i=n-1;i>=0;i--)
#define Pool(i, m, n) for(ll i=n-1;i>=m;i--)
#define MAX 99999999999ll
#define MIN -99999999999ll
#define setbit bitset<8>
#define flagcount __builtin_popcount
#define flag(x) (1<<x)
#define flagadd(bit,x) bit|=flag(x)
#define flagpop(bit,x) bit&=~flag(x) 
#define flagon(bit,i) bit&flag(i)
#define flagoff(bit,i) !(bit & (1<<i))
#define all(v) v.begin(),v.end()
#define low2way(v,x) lower_bound(all(v),x)
#define high2way(v,x) upper_bound(all(v),x)
#define count2way(v,x) high2way(v,x)-low2way(v,x)
#define lower(v,x) low2way(v,x)-v.begin() //1番左が0、もし見つから無いならｎを出力
#define higher(v,x) high2way(v,x)-v.begin()-1 //1番左が0、もし見つからないならn-1を出力（注意）
#define putout(x) cout<<x<<endl
#define Gput(a,b) G[a].push_back(b)
ll ctoi(char c){
	if(c>='0'&&c<='9'){
		return c-'0';
	}
	return 0;
}
int main() {
  string s;
  cin>>s;
  ll ans=false;
  if(s=="AKIHABARA")ans=true;
  
  if(s=="AKIHABAR")ans=true;
  if(s=="AKIHABRA")ans=true;
  if(s=="AKIHBARA")ans=true;
  if(s=="KIHABARA")ans=true;
  
  if(s=="AKIHABR")ans=true;
  if(s=="AKIHBRA")ans=true;
  if(s=="KIHBARA")ans=true;
  
  if(s=="AKIHBAR")ans=true;
  if(s=="KIHABRA")ans=true;
  if(s=="KIHABAR")ans=true;
  
  if(s=="KIHBRA")ans=true;
  if(s=="KIHBAR")ans=true;
  if(s=="KIHABR")ans=true;
  if(s=="AKIHBR")ans=true;
  
  if(s=="KIHBR")ans=true;
  
  
  
  
  
  if(ans)putout("YES");
  else putout("NO");
}


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

typedef long long ll;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const ll INF = 1<<21;
// static const ll MOD = 1e9 + 7;

bool compPair(const pair<int, int>& arg1, const pair<int, int>& arg2) {
    return arg1.first < arg2.first;
}

int main(void) {
    ll n, m;
    cin >> n >> m;

    vector<pair<ll, ll>> ab(n);

    for(ll in=0;in<n;in++) {
        cin >> ab.at(in).first >> ab.at(in).second;
    }

    sort(ab.begin(), ab.end(), compPair);

    ll ans=0, cnt=0;
    for(ll in=0;in<n;in++) {
        if(cnt+ab.at(in).second<=m) {
            ans += ab.at(in).first * ab.at(in).second;
            cnt += ab.at(in).second;
        }
        else {
            ans += ab.at(in).first * (m - cnt);
            break;
        }
    }

    cout << ans << endl;

    return 0;
}


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

int main(){
    int D,G,p[MAX],c[MAX];
    cin >> D >> G;
    for(int i=0;i<D;i++) cin >> p[i] >> c[i];

    int ans = 1e9;
    for(int mask=0;mask<(1<<D);mask++){
        int s = 0,num = 0,rest_max = -1;
        for(int i=0;i<D;i++){
            if(mask & (1<<i)){
                s += 100*(i+1)*p[i]+c[i];
                num += p[i];
            }
            else{
                rest_max = i;
            }
        }
        if(s < G){
            int s1 = 100*(rest_max+1);
            int need = (G-s+s1-1)/s1;
            if(need >= p[rest_max]){
                continue;
            }
            num += need;
        }
        ans = min(ans,num);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import sys
stdin = sys.stdin
     
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))


K=int(input())
A,B=nm()
flag=False
for i in range(A,B+1):
    if(i%K==0):
        flag=True

print('OK' if flag==True else 'NG')



Measured memory_bytes: 9064
int compare_int(const void *a, const void *b){
    return *(int*)a - *(int*)b;
}
int dif(int a, int b){return a<b?b-a:a-b;}
int n, a[200000], m, i;
long long int ans;
int main(){
  scanf("%d", &n);
  for(i=0; i<n; i++){
    scanf("%d", a+i);
    a[i]-=i+1;
  }
  qsort(a, n, sizeof(int), compare_int);
  m=a[n/2];
  for(i=0; i<n; i++){
    ans+=dif(a[i],m);
  }
  printf("%lld\n", ans);
}


Measured memory_bytes: 1788
x,y=map(int,input().split())
if (x+y)%3!=0:
  print(0)
else:
  z=(x+y)//3
  if x<z or y<z:
    print(0)
  else:
    def modinv(a, mod=10**9+7):
      return pow(a, mod-2, mod)
    def comb(n, r, mod=10**9+7):
      r = min(r, n-r)
      res = 1
      if n==r:
        return 1
      for i in range(r):
        res = res * (n - i) * modinv(i+1, mod) % mod
      return res 
    print(comb(z,x-z)%(10**9+7))

Measured memory_bytes: 41816
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
constexpr int MOD=1000000007;
//constexpr int MOD=998244353;
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};
const int MAX_N=2e5+5;

int main(void){
    int N,K;
    cin >> N >> K;
    lint A[N];
    rep(i,N) cin >> A[i];
    for(int i=K;i<N;i++){
        if(A[i]>A[i-K]) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
}

Measured memory_bytes: 5216
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main(void) {
  long int p, tp, c, tc, count;
  p = tp = c = tc = count = 0;
  while (1) {
    if (2 != scanf("%ld,%ld\n", &p, &c)) break;
    tp += p * c;
    tc += c;
    count++;
  }
  printf("%ld\n%ld\n", tp, lround((double)tc/count));
  return 0;
}

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

namespace ABC_Training
{



    public class Program
    {
        static void Main(string[] args)
        {
            var a = int.Parse(Console.ReadLine());
            var b = int.Parse(Console.ReadLine());
            Console.WriteLine(6 - a - b);

        }
    }
}


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

int main() {
    int n;
    cin >> n;
    vector<string> s(n);
    rep(i, n) cin >> s.at(i);
    rep(i, n-1) {
        if(s.at(i)[s.at(i).size()-1] != s.at(i+1)[0]) {
            cout << "No" << endl;
            return 0;
        }
    }
    rep(i, n-1) {
        for(int j = i+1; j < n; j++) {
            if(s.at(i) == s.at(j)) {
                cout << "No" << endl;
                return 0;
            }
        }
    }

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

Measured memory_bytes: 256
#include <stdio.h>

#define MAX 25

typedef struct {
	int parent;
	int left;
	int right;
	int s;
	int deg;
	int dep;
	int h;
} node;

int dep(int);
int h(int);
int max(int, int);

node u[MAX];

int main(void)
{
	int i, n, id, left, right;
	
	scanf("%d",&n);
	for (id=0; id<n; id++) {
		u[id].parent = u[id].s = u[id].dep = u[id].h = -1;
		u[id].deg = 0;
	}
	for (i=0; i<n; i++) {
		scanf("%d %d %d", &id, &left, &right);
		u[id].left = left;
		u[id].right = right;
		if(left != -1) {
			u[left].parent = id;
			u[left].s = right;
			u[id].deg++;
		}
		if(right != -1) {
			u[right].parent = id;
			u[right].s = left;
			u[id].deg++;
		}
	}
	
	for (id=0; id<n; id++) {
		printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ",
			id, u[id].parent, u[id].s, u[id].deg, dep(id), h(id) );
		if(u[id].parent == -1) {
			printf("root\n");
		} else if(u[id].deg == 0) {
			printf("leaf\n");
		} else {
			printf("internal node\n");
		}
	}
	 
	return 0;
}

int dep(int id)
{
	if(u[id].dep!=-1) {
		return u[id].dep;
	}
	if(u[id].parent == -1) {
		u[id].dep = 0;
		return 0;
	}
	u[id].dep = dep(u[id].parent) + 1;
	return u[id].dep;
}

int h(int id)
{
	if(u[id].h!=-1) {
		return u[id].h;
	}
	if(u[id].left == -1 && u[id].right == -1) {
		u[id].h = 0;
	} else if(u[id].left == -1) {
		u[id].h = h(u[id].right) + 1;
	} else if(u[id].right == -1) {
		u[id].h = h(u[id].left) + 1;
	} else {
		u[id].h = max( h(u[id].left), h(u[id].right) ) + 1;
	}
	return u[id].h;
}

int max(int a, int b)
{
	if(a>b) return a;
	else return b;
}

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

int main(){
    string S;
    cin >> S;
    vector<int> Sint(S.size());
    for (int i = 0; i < S.size(); i++) {
        Sint.at(i) = S.at(i) - '0';
    }
    int keta = 0;
    for (int i = 0; i < S.size(); i++) keta += Sint.at(i);
    vector<int> Smod(S.size());
    int m = 1;
    for (int i = S.size() - 1; i >= 0; i--) {
        Smod.at(i) = m;
        m = (m * 10) % keta;
    }
    ll sum = 0;
    for (int i = 0; i < S.size(); i++) {
        sum += (Sint.at(i) * Smod.at(i)) % keta;
        sum %= keta;
    }
    if (sum % keta == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3600
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <numeric>

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

int main() {
    ll s;
    
    ll x = 0, y = 0;

    cin >> s;

    const int t = 1000000000;

    x = (t - s % t) % t;
    y = (s + x) / t;

    cout << "0 0 1000000000 1 " << x << " " << y << endl;
}



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

#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 reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repi(i, a, b) for (int i = (a); i < int(b); i++)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ull << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())

using namespace std;
using i32 = int;
using i64 = long long;
using f64 = double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf64 = vector<f64>;
using vstr = vector<string>;

template<typename T, typename S> void amax(T &x, S y) { if (x < y) x = y; }
template<typename T, typename S> void amin(T &x, S y) { if (y < x) x = y; }

i32 b[2010][2010];

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(16);
  i64 n, k;
  cin >> n >> k;
  rep(i, n) {
    i64 x, y;
    char c;
    cin >> x >> y >> c;
    x = x % (2 * k) + 1;
    y = y % (2 * k) + 1;
    if (c == 'W') {
      y = (y - 1 + k) % (2 * k) + 1;
    }
    b[x][y]++;
  }
  reps(i, 2005) reps(j, 2005) b[i][j] += b[i - 1][j];
  reps(i, 2005) reps(j, 2005) b[i][j] += b[i][j - 1];
  i64 ans = 0;
  rep(i, k + 1) rep(j, k + 1) {
    i64 sum1 = 0, sum2 = 0;
    rep(l, 3) rep(m, 3) {
      int x0 = min(2 * k, max(0ll, i + (l - 1) * k));
      int x1 = min(2 * k, max(0ll, i + (l + 0) * k));
      int y0 = min(2 * k, max(0ll, j + (m - 1) * k));
      int y1 = min(2 * k, max(0ll, j + (m + 0) * k));
      if ((l + m) % 2 == 0) {
        sum1 += b[x1][y1] - b[x0][y1] - b[x1][y0] + b[x0][y0];
      } else {
        sum2 += b[x1][y1] - b[x0][y1] - b[x1][y0] + b[x0][y0];
      }
    }
    amax(ans, sum1);
    amax(ans, sum2);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 16000
W, H, N = gets.split.map(&:to_i)
 
x_max = W
x_min = 0
y_max = H
y_min = 0
 
N.times do
	x, y, a = gets.split.map(&:to_i)
	case a
	when 1
		x_min = [x_min,x].max
	when 2
		x_max = [x_max,x].min
	when 3
		y_min = [y_min,y].max
	when 4
		y_max = [y_max,y].min
	end
end
 
area = (x_max - x_min)*(y_max - y_min)
 
if (x_max - x_min) <= 0 or (y_max - y_min) <= 0
	puts 0
else
	puts area
end

Measured memory_bytes: 1788
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<double> VD;
typedef vector<VD> VVD;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    int n;
    cin >> n;
    vector<pair<pair<string, int>, int>> p(n);
    REP(i,n){
        string s;
        int x;
        cin >> s >> x;
        p[i].first = make_pair(s, -x);
        p[i].second = i;
    }
    sort(ALL(p));
    REP(i,n) cout << p[i].second + 1 << endl;
    return 0;
}


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

typedef std::int_fast32_t  s32;
typedef std::uint_fast32_t u32;
typedef std::int_fast64_t  s64;
typedef std::uint_fast64_t u64;

const unsigned long mod = 1000000007;
const double EPS = 0.00000001;
const int INF = (1 << 29);

typedef std::pair<int, int> P;

template<typename T>
void print_array(T *A_, s32 size) {
  printf("%d\n", size);
  if( size != 0 ) {
    for(int i = 0; i < size - 1; ++i) {
      printf("%d ", A_[i]);
    }
    printf("%d\n", A_[size - 1]);
  }
}

int main() {

  long N;
  std::cin >> N;

  int res = 0;
  while( N != 0 ) {
    N /= 2;
    res += 1;
  }

  std::cout << res << std::endl;
  
  return 0;
}

Measured memory_bytes: 1160
n = int(input())
cards =[ [s + " " + str(i) for i in range(1,14)] for s in ["S","H","C","D"]]
for _ in range(n):
    suit, num = input().split(" ")
    if suit == "S":
        cards[0][int(num) - 1] = 0
    elif suit == "H":
        cards[1][int(num) - 1] = 0
    elif suit == "C":
        cards[2][int(num) - 1] = 0
    elif suit == "D":
        cards[3][int(num) - 1] = 0
for s in cards:
    for i in s:
        if i != 0:
            print(i)

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

using namespace std;
//first : cost ,second : index
using P = pair<long long,int>;

using graph = vector<vector<P>>;

vector<long long> dijkstra(const graph &g , int n, int start,long long inf){
  vector<long long> dist(n,inf);
  priority_queue<P,vector<P>,greater<P>> queue;
  
  queue.push(make_pair(0,start));

  while(queue.size() > 0){
    P now = queue.top() ; queue.pop();

    long long cost = now.first;
    int v = now.second;

    if(cost >= dist[v])continue;

    dist[v] = cost;

    for(auto e : g[v]){
      if(cost + e.first < dist[e.second]){
        queue.push(make_pair(cost + e.first,e.second));
      }
    }
  }

  return dist;
}

int main() {
  int n,m,s,t;
  cin >> n >> m >> s >> t;
  s--;t--;
  vector<vector<P>> yen(n,vector<P>(0));
  vector<vector<P>> snuuk(n,vector<P>(0));
  int u,v,a,b;
  for(int i=0;i<m;i++){
    cin >> u >> v >> a >> b;
    u--;v--;
    yen[u].emplace_back(make_pair(a,v));
    yen[v].emplace_back(make_pair(a,u));
    snuuk[v].emplace_back(make_pair(b,u));
    snuuk[u].emplace_back(make_pair(b,v));
  }

  long long inf = 1'000'000'000'000'000LL;
  vector<long long> yen_val = dijkstra(yen,n,s,inf);
  vector<long long> snuuk_val = dijkstra(snuuk,n,t,inf);
  vector<pair<long long , int>> total(n);
  for(int i=0;i<n;i++){
    total[i] = make_pair(yen_val[i] + snuuk_val[i],i);
  }

  sort(total.begin(),total.end());
  int idx = 0;

  for(int i=0;i<n;i++){
    while(total[idx].second <= i-1){
      idx++;
    }
    cout << inf - total[idx].first << endl;
  }
  
  return 0;
}


Measured memory_bytes: 21308
#include <bits/stdc++.h> 
using namespace std;
int main(){
	int n,k;
  	cin >> n >> k;
  	int arr[n];
  	for(int i=0;i<n;i++){
    	cin >> arr[i];
    }
    int flag=0,min;
  	for(int i=0;i<k;i++){
  	    min = *min_element(arr,arr+n);
  	    for(int j=0;i<n;j++){
        if(min == arr[j]){
            arr[j] = 1001;
            flag+=min;
            break;
        	}
        }
  	}
  	cout << flag;
  return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e18;
typedef long long ll;
typedef vector<ll> vl;
#define rp(i, f, t) for (long long int i = f; i < t; i++)
#define pr(i, f, t) for (long long int i = t - 1; i >= f; i--)
#define ca(n, a) rp(ca_i, 0, n) cout << a[ca_i] << ((ca_i == n - 1) ? "\n" : " ")
#define ia(n, a) rp(ia_i, 0, n) cin >> a[ia_i]
#define za(n, a) rp(za_i, 0, n) a[za_i] = 0
#define be(a) a.begin(), a.end()
#define ce(a) cout << (a) << endl
int main()
{
    double pi = 3.141592653589793;
    double a, b, h, m;
    cin >> a >> b >> h >> m;
    double kaku = abs(2 * pi * (h / 12 + m / 60 / 12) - 2 * pi * (m / 60));
    kaku = min(2 * pi - kaku, kaku);
    //cout << kaku << endl;
    double ans2 = a * a + b * b - 2 * a * b * cos(kaku);
    cout << fixed << setprecision(100) << (pow(ans2, 0.5)) << endl;
}

Measured memory_bytes: 4356
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cctype>
#include <climits>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <memory>
#include <functional>
 
using namespace std;

int main(int argc, char const *argv[]) {
	int n;
	cin >> n;
	vector<int> A;
	deque<int> d;
	for(int i = 0; i < n; i++) {
		int a;
		cin >> a;
		A.push_back(a);
	}
	for (int i = 0; i < n; i++) {
		if (i % 2 == 0) {
			d.push_back(A[i]);
		} else {
			d.push_front(A[i]);
		}
	}

	if (n % 2 == 0) {
		for (int i = 0; i < n; i++) {
			cout << d[i] << " ";
		}
		cout << endl;
	} else {
		for (int i = n - 1; i >= 0; i--) {
			cout << d[i] << " ";
		}
		cout << endl;
	}

	return 0;
}

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

int main(){
  int N,T;
  cin >> N >> T;
  
  int ans = 100000;
  for (int i = 0; i < N; i++)
  {
    int c,t;
    cin >> c >> t;
    if(t<=T) ans = min(ans,c);
  }

  if(ans==100000) puts("TLE");
  else cout << ans << endl;
}

Measured memory_bytes: 256
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")
    };
}

fn main() {
    input! {
        x:usize,
    }
    if x < 1200 {
        println!("ABC");
    } else {
        println!("ARC");
    }
}


Measured memory_bytes: 4352
# 改行またはスペース区切りの入力をすべて読み込んでイテレータを返します。
def get_all_int():
    return map(int, open(0).read().split())

n,*A = get_all_int()

# dp[i][j] = 活発度高い順のi人目まで処理し、左にjに置いた場合のうれしさの最大
dp = [ [0] * (n+1) for _ in range(n+1) ]

AA = list(enumerate(A))
AA.sort(key=(lambda t: t[1]), reverse=True)

for i, t in enumerate(AA):
    # k 移動前の位置
    # a 活発度
    k,a = t
    for j in range(i+1):
        # 左に置く (すでに左端にj人居る)
        move = abs(k - j)
        dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j] + a*move)

        # 右に置く (すでに右端にi-j人居る)
        move = abs(k - (n-(i-j)-1))
        dp[i+1][j] =   max(dp[i+1][j],   dp[i][j] + a*move)

ans = 0

for j in range(n+1):
    ans = max(ans, dp[n][j])

print(ans)


Measured memory_bytes: 105972
#include <bits/stdc++.h>
using namespace std;
#define REP(i,N) for(i=0;i<N;i++)
typedef long long ll;
typedef struct{
  int from,to,cost;
}edge;

int main(void){
  int i,n_node=1,n_2=1,L;
  cin >> L;
  vector<edge> v;
  while(2*n_2<=L&&n_node<20){
    v.push_back({n_node,n_node+1,n_2});
    n_2*=2;
    n_node++;
  }
  int N_2=n_2;
  for(i=n_node-1;i>0;i--){
    n_2/=2;
    if(L-n_2>=N_2){
      v.push_back({i,n_node,L-n_2});
      L-=n_2;
    }
  }
  REP(i,n_node-1){
    v.push_back({i+1,i+2,0});
  }
  cout << n_node << " " << v.size() << endl;
  REP(i,v.size()){
    cout << v[i].from << " " << v[i].to << " " << v[i].cost << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
const  int INF = 1001001001;
using Graph = vector<vector<int>>;


int main(){

    string t;
    cin >> t;

    rep(i, t.size()){
        if(t[i]=='?'){
            cout << 'D';
        }else{
            cout << t[i];
        }
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 3724
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String res = "Yes";
        int n = sc.nextInt();
        Map<Integer, List<Integer>> map = new TreeMap<>();
        for(int i = 0; i < n; i++) {
            int a = sc.nextInt(), b = sc.nextInt();
            if(map.containsKey(b)) map.get(b).add(a);
            else map.put(b, new ArrayList<>(Arrays.asList(a)));
        }
        long suma = 0;
        for(int b : map.keySet()) {
            List<Integer> list = map.get(b);
            Collections.sort(list);
            for(int a : list) {
                suma += a;
            }
            if(suma > b) {
                res = "No";
                break;
            }
        }
        System.out.println(res);
    }
}


Measured memory_bytes: 82788
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
struct Stack {
	int p;
	int a[10000];
	Stack() :p(0) {}
	void push(int x) {
		a[p++] = x;
	}
	int pop() {
		return a[--p];
	}
};
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	Stack p;
	for (string s; cin >> s;) {
		if (s == "+") {
			int a = p.pop(), b = p.pop();
			p.push(a + b);
		}
		else if (s == "*") {
			int a = p.pop(), b = p.pop();
			p.push(a*b);
		}
		else if (s == "-") {
			int a = p.pop(), b = p.pop();
			p.push(b - a);
		}
		else p.push(stoi(s));
	}
	cout << p.pop() << endl;
	return 0;
}

Measured memory_bytes: 3156
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<stack>
#include<queue>
#include<tuple>
#include<cassert>
#include<set>
#define int long long
#define mod(int)(1000000007)
using namespace std;
int keta(int x) {
	int ans = 0;
	while (x) {
		x /= 10;
		ans++;
	}
	return ans;
}
int test[10];
signed main() {
	int n, k, a; cin >> n >> k;
	for (int h = 0; h < k; h++) {
		cin >> a; test[a] = 1;
	}
	for (int h = n; h < n + 100000; h++) {
		if (keta(h) >= 7) { if (test[h % 10000000 / 1000000] == 1) { continue; } }
		if (keta(h) >= 6) { if (test[h % 1000000 / 100000] == 1) { continue; } }
		if (keta(h) >= 5) { if (test[h % 100000 / 10000] == 1) { continue; } }
		if (keta(h) >= 4) { if (test[h % 10000 / 1000] == 1) { continue; } }
		if (keta(h) >= 3) { if (test[h % 1000 / 100] == 1) { continue; } }
		if (keta(h) >= 2) { if (test[h % 100 / 10] == 1) { continue; } }
		if (keta(h) >= 1) { if (test[h % 10] == 1) { continue; } }
		cout << h << endl; break;
	}
}

Measured memory_bytes: 256
class UnionFind():
    # コンストラクタ
    def __init__(self, n):
        # 要素数
        self.n = n
        # parents[i]: 要素iの親要素の番号
        # 要素iが根の場合、parents[i] = -(そのグループの要素数)
        self.parents = [-1] * n
 
    # 要素xが属するグループの根を返す
    # 経路圧縮
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
 
    # 要素xが属するグループと要素yが属するグループとを併合する
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
 
        if x == y:
            return
 
        if self.parents[x] > self.parents[y]:
            x, y = y, x
 
        self.parents[x] += self.parents[y]
        self.parents[y] = x
 
    # 要素xが属するグループの要素数を返す
    def size(self, x):
        return -self.parents[self.find(x)]
 
    # 要素x,yが同じグループに属するかどうかを返す
    def same(self, x, y):
        return self.find(x) == self.find(y)
 
    # 要素xが属するグループに属する要素をリストで返す
    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]
 
    # 全ての根の要素をリストで返す
    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]
 
    # グループの数を返す
    def group_count(self):
        return len(self.roots())

def main():
    N,M,K = map(int,input().split())

    best_friend = [0] * N
    friend = UnionFind(N)
    for _ in range(M):
        A,B = map(int,input().split())
        best_friend[A-1] += 1
        best_friend[B-1] += 1
        friend.union(A-1, B-1)

    blocked = [[] for _ in range(N)]
    for _ in range(K):
        C,D = map(int,input().split())
        blocked[C-1].append(D-1)
        blocked[D-1].append(C-1)

    ans = [0] * N
    for i in range(N):
        # 友達候補 - 友達 - 自分
        ans[i] = friend.size(i) - best_friend[i] - 1
        # 嫌いな人は友達になれない
        for bad in blocked[i]:
            if friend.same(i, bad):
                ans[i] -= 1

    print(*ans, sep=" ")

if __name__ == "__main__":
    main()

Measured memory_bytes: 31776
#include "bits/stdc++.h"
#define rep(i,n) for(int i=0;i<n;i++)
#define ALL(v) (v).begin(),(v).end()
typedef long long LL;
const int INF = 1 << 25;
const LL MOD = 1000000007LL;
using namespace std;
typedef pair<int, int> P;
bool red[100000];
int num[100000];
int main() {
	int N, M;
	cin >> N >> M;
	rep(i, N) num[i] = 1;
	red[0] = 1;
	rep(i, M) {
		int x, y;
		cin >> x >> y;
		x--; y--;
		if (red[x]) red[y] = 1;
		if (num[x] == 1) red[x] = 0;
		num[x]--;
		num[y]++;
	}
	int ans = 0;
	rep(i, N) ans += red[i];
	cout << ans << endl;
}

Measured memory_bytes: 768