akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

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


ll MOD = pow(10, 9) + 7;
vector<ll> ff, vff;

ll powmod(ll a, ll p, ll MOD) {
	ll ans = 1;
	ll mul = a;
	for (; p > 0; p >>= 1, mul = (mul * mul) % MOD) {
		if ((p & 1) == 1)ans = (ans * mul) % MOD;
	}
	return ans;
}

ll combmod(ll n, ll r, ll MOD){
  if(n < r) return 0LL;
  if (n < 0 || r < 0) return 0LL;

  
  // n combination r
  ll comb = (((ff[n] * vff[r]) % MOD) * vff[n - r]) % MOD;

  return comb;
}

// initialize fact(n), inv-fact(n)
void init(ll n, ll MOD){
  n++;
  ff.resize(n+1);
  vff.resize(n+1);
  // 1! ~ n!
  ff[0] = 1;
  for(ll i = 1; i < n + 1; i++) {
    ff[i] = ff[i - 1] * i % MOD;
  }
  // n!^(MOD-2) (= n!^(-1))
  ll inv = powmod(ff[n], MOD - 2, MOD);

  // n!^(-1) ~ 1!^(-1)
  vff[n] = inv;
  for(ll i = n - 1; i >= 0; i--) {
    vff[i] = vff[i + 1] * (i + 1) % MOD;
  }
}

int main() {
    ll n;
    cin >> n;
    vector<ll> A(n+1);
    ll a = 0, b = 0, c = 0;
    ll t, cnt = 0;
    set<ll> s;
    REP(i, n+1){
        cin >> A[i];
        if (s.find(A[i]) != s.end()) t = A[i];
        else s.insert(A[i]);
    }
    REP(i, n+1){
        if (cnt == 0 && A[i] != t) a++;
        else if (cnt == 1 && A[i] != t) b++;
        else if (cnt == 2 && A[i] != t) c++;
        else cnt++;
    }
    init(n, MOD);

    rep(i, 1, n+2){
        ll ans = (combmod(n + 1, i, MOD) - combmod(a + c, i - 1, MOD) + MOD) % MOD;
        cout << ans << endl;
    }


    return 0;
}

Measured memory_bytes: 8824
#define STOPIT
#include<bits/stdc++.h>
#define rep(i,n,m) for(int i = (n); i <(m); i++)
#define rrep(i,n,m) for(int i = (n) - 1; i >=(m); i--)
using namespace std;
using ll = long long;

void debug_impl() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail) { cerr << " " << head; debug_impl(tail...); }
#ifndef STOPIT
    #define debug(...)\
    do {\
        cerr << boolalpha << "[" << #__VA_ARGS__ << "]:";\
        debug_impl(__VA_ARGS__);\
        cerr << std::noboolalpha;\
    } while (false)
#else
    #define debug(...) {}
#endif

template < typename Container, typename Value = typename Container::value_type, enable_if_t<!is_same< Container, string >::value, nullptr_t> = nullptr>
istream& operator>> (istream& is, Container& v)
  { for (auto & x : v) { is >> x; } return is; }

template < typename Container, typename Value = typename Container::value_type, enable_if_t<!is_same< Container, string >::value, nullptr_t> = nullptr >
ostream& operator<< (ostream& os, Container const& v) {
  os << "{";
  for (auto it = v.begin(); it != v.end(); it++)
    {os << (it != v.begin() ? "," : "") << *it;}
  return os << "}";
}
using ll = long long;
int const MOD = 1000000007;

vector<ll> factorials;
void init_factorial(int N)
{
    factorials.assign(N+1, 1);
    rep(i, 2, N+1)
    {
        factorials[i] = factorials[i-1] *i;
        factorials[i] %= MOD;
    }
}

ll power_mod(ll n, ll m)
{
    ll res = 1;
    ll base = n;
    while (m > 0)
    {
        if (m&1) res = (res * base) % MOD;
        base = (base * base) % MOD;
        m >>= 1;
    }
    return res;
}

ll inv_mod(ll n)
{
    return power_mod(n, MOD-2);
}

ll comb(ll n, ll m)
{
    m = min(m, n-m);
    ll res = factorials[n];
    res *= inv_mod(factorials[n-m]);
    res %= MOD;
    res *= inv_mod(factorials[m]);
    res %= MOD;
    return res;
}

ll dup_comb(ll n, ll m)
{
    return comb(n+m-1, n-1);
}

int main()
{
    init_factorial(1000000);

    int n, k;
    cin >> n >> k;

    ll res = 0;
    rep(i, 0, min(k, n-1)+1)
    {
        ll now = comb(n, i)*dup_comb(n-i, i);
        now %= MOD;
        res += now;
        res %= MOD;
        debug(i, comb(n, i), dup_comb(n-i, i), now);
    }
    cout << res << endl;
    return 0;
}


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

#define PI 3.14159265359
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define descSort(a) sort(a.begin(),a.end(),std::greater<int>())
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;

int main(void)
{
    ll n;
    cin>>n;
    string ans;
    while(n){
        n--;
        ans=char('a'+(n%26))+ans;
        n/=26;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <set>
using namespace std;

int main()
{
    // 整数の入力
    long long N,D,i;
    cin >> D >> N;
    if (N== 100){
        cout << 101;
    }else {
        cout << N;
    }

    if (D == 0){
    }else if (D == 1){
        cout << "00";
    }else {
        cout << "0000";
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <utility>
#include <vector>

int main()
{
    long long n, product = 1;
    bool higher = false;
    bool zero = false;
    std::cin >> n;
    long long c = 1;
    for (size_t i = 0; i < 18; i++) {
        c *= 10;
    }
    for (size_t i = 0; i < n; i++) {
        long long input;
        std::cin >> input;
        long double digit = (log10l(input == 0 ? 1 : input) + log10l(product));
        product *= input;
        if (digit > 18.0 || ((int)digit >= 18 && product % c > 0)) {
            higher = true;
        }
        if (input == 0) {
            zero = true;
        }
    }
    if (higher && !zero) {
        std::cout << -1 << "\n";
    } else {
        std::cout << product << "\n";
    }
    return 0;
}


Measured memory_bytes: 3220
#include <bits/stdc++.h>
#define l_ength size
const int mod = 1000000007; // 998244353
using ll = long long;
using namespace std;
const ll inf = (1ll<<60);

ll dp[1010][30000];

int main(){
	int h, n; cin >> h >> n;
	vector<ll> value(n);
	vector<ll> weight(n);
	for( int i = 0; i < n; ++i ) cin >> weight[i] >> value[i];
	for( int i = 0; i < 1010; ++i ){
		for ( int j = 0; j < 30000; ++j ){
			dp[i][j] = inf;
		}
    }
	for( int i = 0; i <= n; ++i ) dp[i][0] = 0ll;
	ll candy = inf;
	for( int i = 0; i < n; ++i ){
        for( int w = 0; w < h; ++w){
            dp[i+1][w] = min( dp[i+1][w], dp[i][w] );
            if ( w >= weight[i] ){
				dp[i+1][w] = min( dp[i+1][w], dp[i+1][w-weight[i]] + value[i] );
			}
        }
		for( int w = h; w < 10100; ++w ){
			if( w >= weight[i] && dp[i+1][w-weight[i]] < inf ){
				candy = min( candy, dp[i+1][w-weight[i]]+value[i] );
			}
		}
    }
	cout << candy << endl;
}

Measured memory_bytes: 237056
#include <stdio.h>

#define MAX_NAME_LENGTH 10+1
#define MAX_PROCESS 100000

typedef struct{
    char name[MAX_NAME_LENGTH];
    int time;
}Process;

Process Q[MAX_PROCESS];
int head=0,tail=0;

//?????\??????????´?x?????????????????¢??°
void enqueue(Process x){
    Q[tail]=x;
    if(tail+1 == MAX_PROCESS){//????????°?????????????????¨??????
        tail=0;
    }else{
        tail++;
    }
}

//?????\??????????????????????´??????????????????¢??°
Process dequeue(){
    Process x = Q[head];
    if(head+1 == MAX_PROCESS){//????????°?????????????????¨??????
        head=0;
    }else{
        head++;
    }
    return x;
}

int main(){
    int n,q,i,count=0;
    Process x;
    scanf("%d %d",&n,&q);   //??????????????°n??¨???????????????n?????\???
    
    for(i=0;i<n;i++){
        scanf("%s %d",x.name,&x.time);
        enqueue(x);         //?????\??????????´?x???????????????
    }
    
    while(1){
        x=dequeue();    //?????\????????????????´????????????????
        if(x.time<=q){  //???????????????????????????????????????????????\????????£?????´???
            count+=x.time;
            printf("%s %d\n",x.name,count);
        }else {         //?????????????????????????????????????????????????????§????????£?????´???
            count+=q;
            x.time-=q;
            enqueue(x); //???????????\?????´???
        }
        if(tail==head)break;//?????\??????head??¨tail????????´??????????????\??????????????????????????£????????´???break
    }
}

Measured memory_bytes: 3356
N = int(input())
R = [list(map(int, input().split())) for i in range(N)]
B = [list(map(int, input().split())) for i in range(N)]
B = sorted(B, key = lambda x:x[0])
ans = 0
for b in B:
    tmp = -1
    rp = -1
    for i, r in enumerate(R):
        if b[0] > r[0] and b[1] > r[1]:
            if r[1] > tmp:
                tmp = r[1]
                rp = i
    if rp >= 0:
        R.pop(rp)
        ans += 1
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#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 IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;


signed main() {
  int A, B, C;
  cin >> A >> B >> C;

  bool ok = true;
  if(A != B) ok = false;
  if(B != C) ok = false;
  if(C != A) ok = false;

  ok? Yes: No;

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<set>
#include<algorithm>
using namespace std;
typedef long long int ll;
static const int MOD = 1000000007;
int main(){
	int N;
	pair<int, int> p[200000];
	cin >> N;
	for(int i = 0; i < N; i++){
		int a;
		cin >> a;
		p[i] = make_pair(a, 1);
	}
	for(int i = 0; i < N; i++){
		int b;
		cin >> b;
		p[N + i] = make_pair(b, 2);
	}
	sort(p, p + 2 * N);
	ll cnt_a = 0, cnt_b = 0, ans = 1;
	for(int i = 0; i < 2 * N; i++){
		if(p[i].second == 1){
			if(cnt_b == 0) cnt_a++;
			else{
				ans *= cnt_b;
				ans %= MOD;
				cnt_b--;
			}
		}else if(p[i].second == 2){
			if(cnt_a == 0) cnt_b++;
			else{
				ans *= cnt_a;
				ans %= MOD;
				cnt_a--;
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 1792
#include "bits/stdc++.h"

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin >> n;
    if(n>=400 && n<=599)
        cout << 8;
    if(n>=600 && n<=799)
        cout << 7;
    if(n>=800 && n<=999)
        cout << 6;
    if(n>=1000 && n<=1199)
        cout << 5;
    if(n>=1200 && n<=1399)
        cout << 4;
    if(n>=1400 && n<=1599)
        cout << 3;
    if(n>=1600 && n<=1799)
        cout << 2;
    if(n>=1800)
        cout << 1;
    cout << endl;

    return 0;
}


Measured memory_bytes: 3680
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define NDEBUG
#define eprintf(...) do {} while (0)
#endif
#include<cassert>

using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

int N;
char S[5011], T[5011];

void MAIN() {
    scanf("%d", &N);
    scanf("%s%s", S, T);

    LL ans = 1<<29;
    REP (t, 2) {
	int x = (S[0] != T[0]);
	for (int a=x; a<=N; a+=2) {
	    int pos = -1, pool = a;
	    LL tmp = 0;
	    REP (i, N-1) {
		if (S[i] == S[i+1]) {
		    while (pos < N-1 && pool == 0) {
			pos++;
			if (pos < N-1 && T[pos] == T[pos+1]) pool = 1;
		    }

		    tmp += abs(i - pos);
		    pool--;
		}
	    }
	    while (pos < N-1) {
		while (pool) {
		    tmp += abs(N-1 - pos);
		    pool--;
		}
		pos++;
		if (pos < N-1 && T[pos] == T[pos+1]) pool = 1;
	    }
	    amin(ans, tmp);
	}
	REP (i, N) swap(S[i], T[i]);
    }
    printf("%lld\n", ans);
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <climits>
#include <cmath>
#include <cstdlib>  // abs() for integer
#include <stdio.h>
#include <string>
#include <stdlib.h>

using namespace std;

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

    string s;
    cin >> s;
    int min = 60000;
    for(int i=0; i<(int)s.size() - 2; i++){
        int tmp;
        tmp = (s[i]-'0') * 100 + (s[i+1]-'0')*10 + (s[i+2]-'0');
        if(min > abs(tmp - 753)){
            min = abs(tmp - 753);
        }
    }
    cout << min;
}


Measured memory_bytes: 256
#pragma GCC optimze("Ofast")
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define mod 1000000007
#define md 998244353
#define trace(...)
#define ll long long int
#define ld long double
#define fi first
#define se second
#define fr(i,a,b) for(ll i=a;i<=b;i++)
#define frr(i,b,a) for(ll i=b;i>=a;i--)
#define mem(a) memset(a, 0, sizeof(a))
#define vpi std::vector<pair<int,int>>
#define pii pair<int,int>
#define pb push_back
#define sall(v) sort(v.begin(),v.end())
#define all(v) (v.begin(),v.end())
#define minf -10000000
const ll infl=0x3f3f3f3f3f3f3f3fLL;
const int infi=0x3f3f3f3f;
typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> oset;
auto clk=clock();
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
    uniform_int_distribution<int> uid(0,lim-1);
    return uid(rang);
}
ll power(ll x, ll y,ll p) { 
    ll res = 1;      // Initialize result 
    x = x % p;  // Update x if it is more than or equal to p 
    while (y > 0) {  
        if (y & 1) // If y is odd, multiply x with result
            res = (res*x) % p;  
        y = y>>1; // y = y/2 // y must be even now
        x = (x*x) % p;   
    } 
    return res; 
}
ll power(ll x, ll y) { 
    ll res = 1;      // Initialize result 
    while (y > 0) {    
        if (y & 1)// If y is odd, multiply x with result 
            res = (res*x) ;  
        y = y>>1; // y = y/2 // y must be even now 
        x = (x*x);   
    } 
    return res; 
}
 
ll max3(ll a,ll b,ll c){
    return max(a,max(b,c));
}
ll min3(ll a,ll b,ll c){
    return min(a,min(b,c));
}
bool isPrime(ll n) { // Corner cases 
    if (n <= 1) 
        return false; 
    if (n <= 3) 
        return true; 
    if (n % 2 == 0 || n % 3 == 0) 
        return false; 
    for (ll i = 5; i * i <= n; i = i + 6) 
        if (n % i == 0 || n % (i + 2) == 0) 
            return false; 
    return true; 
}

void solve() {
    int r;cin>>r;
    cout<<2*M_PI*r<<endl;
    return ;
}

int main(){
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());
    cout<<fixed<<setprecision(8);
    #ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    #endif
    int t;
    // cin>>t;
    t=1;
    while(t--){
        solve();
    }
    #ifndef ONLINE_JUDGE
    //cout<<endl<<endl<<endl<<endl<<"Time elapsed: "<<(double)(clock()-clk)/CLOCKS_PER_SEC<<endl;
    #endif
    return 0;
}

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

using namespace std;

int main(){
int n=0;
string str="";
map<string ,int>mp;
cin>>n;
while(n--){
cin>>str;
mp[str]++;
}
cout<<"AC x "<<mp["AC"]<<"\n";
cout<<"WA x "<<mp["WA"]<<"\n";
cout<<"TLE x "<<mp["TLE"]<<"\n";
cout<<"RE x "<<mp["RE"]<<"\n";





    return 0;
}


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

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

Measured memory_bytes: 256
import java.util.*;

class Main{
	public static void main(String[] args){
      Scanner scn = new Scanner(System.in);
      int n = scn.nextInt();
      int sum = 0;
      int[] value = new int[n];
      int[] cost = new int[n];
      for(int j = 0;j<n;j++){
        value[j] = scn.nextInt();
      }
      for(int k = 0;k<n;k++){
        cost[k] = scn.nextInt();
      }
      for(int i = 0; i<n;i++){
        if(value[i]-cost[i]>0){
          sum += value[i]-cost[i];
        }
      }
      System.out.println(sum);
	}
}

Measured memory_bytes: 22740
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c,d;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	int x=(a+d-1)/d;
	int y=(c+b-1)/b;
	if(x>=y)printf("Yes\n");
	else printf("No\n");
}

Measured memory_bytes: 3636
#include <iostream>

using namespace std;

#define Max 100000

typedef long long llong;

int n, k;
llong T[Max];

int check(llong p) {
    int i = 0;
    for (int j = 0; j < k; j++) {
        long s = 0;
        while (s + T[i] <= p) {
            s += T[i];
            i++;
            if (i == n) {
                return n;
            }
        }
    }
    return i;
}

int slove() {
    llong left = 0;
    llong right = 100000 * 10000;

    int mid;
    while (right - left > 1) {
        mid = left + (right - left) / 2;
        int v = check(mid);
        if (v >= n) {
            right = mid;
        } else left = mid;
    }

    return right;
}

int main() {
    cin >> n >> k;
    for (int i = 0; i < n; i++) {
        cin >> T[i];
    }

    llong ans = slove();
    cout << ans << endl;
}


Measured memory_bytes: 3880
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1e11
int main(){
    ll n;
    cin>>n;
    vector<pair<ll,ll>>s(n);//1->W,2->E
    for(ll i=0;i<n;i++){
        if(i!=0){
            s[i].first=s[i-1].first;
            s[i].second=s[i-1].second;
        }
        char hoge; cin>>hoge;
        if(hoge=='W')s[i].first++;
        else s[i].second++;
    }
    ll mini=s[n-1].second-s[0].second;
    for(ll i=1;i<n-1;i++){    
        mini=min(mini,s[i-1].first+s[n-1].second-s[i].second);
    }
    mini=min(mini,s[n-1].first);
    cout<<mini<<endl;
}

Measured memory_bytes: 4992
#include<stdio.h>
#include<string.h>
#include<math.h>
int main(void)
{
	int a,s[41],d[41][22],f[41],g,h[41],i,j,z,x;
	while(1){
		scanf("%d",&a);
		if(a==0) break;
		for(i=0;i<a;i++){
			scanf("%d",&s[i]);
			f[i]=0;
			g=1;
			h[i]=0;
			while(1){
				scanf("%d",&d[i][f[i]]);
				h[i]+=d[i][f[i]];
				if(d[i][f[i]]==10&&g%2==1){
					g++;
				}
				g++;
				f[i]++;
				if(g==19) break;
			}
			scanf("%d %d",&d[i][f[i]],&d[i][f[i]+1]);
			h[i]+=d[i][f[i]]+d[i][f[i]+1];
			if(d[i][f[i]]+d[i][f[i]+1]>=10){
				scanf("%d",&d[i][f[i]+2]);
				h[i]+=d[i][f[i]+2];
			}
			z=0;
			for(j=0;j<f[i];j++){
				if(d[i][j]==10&&z==0){
					h[i]+=d[i][j+1]+d[i][j+2];
				}
				else if(z==0) z=1;
				else if(d[i][j-1]+d[i][j]==10&&z==1){
					h[i]+=d[i][j+1];
					z=0;
				}
				else if(z==1) z=0;
			}
		}
		x=0;
		for(i=0;i<a-1;i++){
			for(j=i+1;j<a;j++){
				if(h[i]<h[j]){
					x=h[i];
					h[i]=h[j];
					h[j]=x;
					x=s[i];
					s[i]=s[j];
					s[j]=x;
				}
				if(h[i]==h[j]){
					if(s[i]>s[j]){
						x=h[i];
						h[i]=h[j];
						h[j]=x;
						x=s[i];
						s[i]=s[j];
						s[j]=x;
					}
				}
			}
		}
		for(i=0;i<a;i++) printf("%d %d\n",s[i],h[i]);
	}
	return 0;
}

Measured memory_bytes: 2612
#include<iostream>
#include<vector>
#define mp make_pair
using namespace std;
typedef pair<int,int> pii;

const int w=5;
int puzzle[w][10];

int del(vector<pii> stone){
  int res=0;
  for(int i=0;i<stone.size();i++){
    int x,y;
    x=stone[i].first;
    y=stone[i].second;
    res+=puzzle[x][y];
    puzzle[x][y]=0;
  }
  return res;
}

vector<pii> check(int h){
  vector<pii> stone;
  for(int i=0;i<h;i++){
    int cnt=0;
    for(int j=0;j<w;j++){
      while(j<w && puzzle[j][i] == puzzle[j+1][i] && puzzle[j][i]!=0){
	cnt++;j++;
      }
      if(cnt>=2){
	for(int k=j-cnt;k<=j;k++){
	  stone.push_back(mp(k,i));
	}
      }
      cnt=0;
    }
  }
  return stone;
}

bool drop(int h){
  bool res=false;
  for(int i=0;i<w;i++){
    for(int j=0;j<h;j++){
      for(int k=h-1;k>j;k--){
	if(puzzle[i][k]==0){
	  res=true;
	  int tmp=puzzle[i][k];
	  puzzle[i][k]=puzzle[i][k-1];
	  puzzle[i][k-1]=tmp;
	}
      }
    }
  }
  return res;
}

void printPuzzle(int h){
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cout << puzzle[j][i] << " ";
    }
    cout << endl;
  }
}

int main(){
  int h;
  while(cin>>h,h){
    for(int i=0;i<h;i++)
      for(int j=0;j<w;j++)
	cin>>puzzle[j][i];
    int ans=0;
    vector<pii>stone=check(h);
    while(!stone.empty()){
      ans+=del(stone);
      //out << "del end" << endl;
      drop(h);
      //cout << "drop end" << endl;
      //printPuzzle(h);
      stone=check(h);
    }
    cout << ans << endl;
  }
  return 0;
}

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

#define SORT(c) sort((c).begin(), (c).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
#define ANS(ans) cout << (ans) << endl;
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
typedef vector<int> VI;
typedef pair<int, int> P;

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

ll gcd(ll a, ll b) {
  if (a % b == 0) {
    return (b);
  } else {
    return (gcd(b, a % b));
  }
}

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

  ll ans = 0;
  ll tmp;
  FOR(a, 1, k) {
    FOR(b, 1, k) {
      FOR(c, 1, k) {
        tmp = gcd(a, b);
        ans += gcd(tmp, c);
      }
    }
  }

  ANS(ans);
  return 0;
}


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

const int N = 2005, mo = 924844033;
int n, k, cnt, tmp, ans, fac[N << 1], f[N << 1][N][2];
bool term[N << 1];

int main () {
	cin >> n >> k;
	fac[0] = 1;
	for (int i = 1; i <= n; ++i) fac[i] = 1ll * fac[i - 1] * i % mo;
	for (int i = 1; i <= k; ++i) {
		for (int j = (i - 1) % k + 1; j <= n; j += k) ++cnt;
		term[cnt] = 1;
		for (int j = (i - 1) % k + 1; j <= n; j += k) ++cnt;
		term[cnt] = 1;
	}
	f[1][0][0] = 1;
	for (int i = 1; i <= cnt; ++i) {
		for (int j = 0; j <= n; ++j) {
			f[i + 1][j][0] += (f[i][j][0] + f[i][j][1]) % mo;
			if (!term[i]) f[i + 1][j + 1][1] += f[i][j][0];
			f[i + 1][j][0] %= mo;
			f[i + 1][j + 1][1] %= mo;
		}
	}
	for (int i = 0, j = 1; i <= n; ++i, j = -j) {
		tmp = 1ll * (f[cnt][i][0] + f[cnt][i][1]) * fac[n - i] % mo;
		ans = (1ll * ans + tmp * j + mo) % mo;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 62976
n = int(input())
a = list(map(int, input().split()))
mod = 10**9+7
x = [sum(a)]
for i in a:
    x.append((x[-1]-i)%mod)
r = 0
for i in range(len(a)-1):
    r = (r+a[i]*x[i+1])%mod
print(r)

Measured memory_bytes: 31432
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
const int MN = 110;
const ll M = 1e9+7;
inline ll mul(ll a, ll b) {return (a*b)%M;}
ll bp(ll b, ll p) {
	ll ac = 1;
	while(p) {
		if(p&1) {
			ac = mul(b,ac);
		}
		b = mul(b,b);
		p >>= 1;
	}
	return ac;
}
inline ll norm(ll val) {
	return (val<0)?val%M+M:val%M;
}
ll dp[MN][MN];
ll hc[MN][MN];
ll va[MN];
ll w[MN],wa[MN];
ll lim[MN],rs[MN][MN];
ll n;
ll ds(ll r, ll h) {
	if(r >= n-1) {return 1;}
	if(dp[r][h] != -1) {
		return dp[r][h];
	}
	if(h > wa[r]) {
		return dp[r][h] = ds(r,wa[r]);
	}
	if(wa[r] == 0) {
		return dp[r][h] = ds(r+1,0);
	}
	ll hv = 0;
	if(h == wa[r]) {
		hv = 0;
	} else {
		hv = 0;
		for(int i=h;i<wa[r];i++) {
			ll sz = va[i+1];
			ll ot = hc[r][i+1]-sz;
			hv += mul(mul(norm(bp(2,sz)-1),bp(2,ot)),ds(rs[r][i+1],wa[r]));
		}
	}
	ll vv = ds(r+1,max(wa[r],h));
	ll ev = ds(r+1,wa[r]);
	return dp[r][h] = norm(hv+vv+ev);
}
int main() {
	cin >> n;
	memset(lim,-1,sizeof(lim));
	memset(dp,-1,sizeof(dp));
	memset(hc,0,sizeof(hc));
	for(int i=0;i<n;i++) {
		cin >> w[i];
	}
	if(n == 1) {
		cout << bp(2,w[0]) << '\n';
		return 0;
	}
	ll los = 0;
	for(int i=0;i<n-1;i++) {
		wa[i] = min(w[i],w[i+1]);
		lim[i] = max(lim[i],wa[i]);
		lim[i+1] = max(lim[i+1],wa[i]);
		wa[i]--;
	}
	for(int i=0;i<n;i++) {
		if(lim[i] == 1) {lim[i] = 0;}
		los += w[i]-lim[i];
	}
	set<ll> bs;
	for(int i=0;i<n-1;i++) {
		bs.insert(wa[i]);
	}
	bs.insert(0);
	ll lst = 0;
	ll ctr = 0;
	map<ll,ll> mo;
	for(auto& it: bs) {
		mo[it] = ctr;
		va[ctr] = it-lst;
		ctr++;
		lst = it;
	}
	for(int i=0;i<n-1;i++) {
		wa[i] = mo[wa[i]];
	}
	for(int i=0;i<n;i++) {
		for(int j=0;j<n-1;j++) {
			int r = j;
			while(r < n-1 && wa[r] >= i) {
				r++;
			}
			rs[j][i] = r;
		}
	}
	for(int i=1;i<n;i++) {
		for(int j=0;j<n-1;j++) {
			for(int k=i;k<n;k++) {
				for(int l=j;l<rs[j][i];l++) {
					if((l <= j || wa[l-1] < k) && wa[l] >= k) {
						hc[j][i] += va[k];
					}
				}
			}
		}
	}
	ll res = ds(0,0);
	int x = 0;
	while(x < n-1) {
		if(rs[x][1] == x) {
			x++;
		} else {
			res = mul(res,2);
			x = rs[x][1];
		}
	}
	res = mul(res,bp(2,los));
	cout << res << '\n';
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,n,s) for(int i = s; i < (n); ++i)
#define rsrep(i,n,s) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;
    
int main() {
    int h, w;
    cin >> h >> w;
    vvint a(h, vint(w));
    rep(i, h) rep(j, w) cin >> a[i][j];
    
    vvint ans;
    vint ans_t(4);
    bool c;
    rep(i, h) rep(j, w) {
        if (a[i][j] % 2 == 0) continue;
        bool c = false;
        if (j < w-1) {
            a[i][j+1]++;
            ans_t = {i+1, j+1, i+1, j+2}; 
            c = true;
        }
        else if (i < h-1) {
            a[i+1][j]++; 
            ans_t = {i+1, j+1, i+2, j+1}; 
            c = true;
        }
        if (c) ans.push_back(ans_t);
    }
    
    int n = ans.size();
    cout << n << endl;
    rep(i, n) rep(j, 4) printf("%d%s", ans[i][j], j != 3 ? " " : "\n");
    
    return 0;
}

Measured memory_bytes: 9904
#lang racket

(define (solve K)
  (define (c-iter ab c)
    (if (> c K)
        0
        (+ (gcd ab c) (c-iter ab (+ c 1)))))
  (define (b-iter a b)
    (if (> b K)
        0
        (+ (c-iter (gcd a b) 1) (b-iter a (+ b 1)))))
  (define (a-iter a)
    (if (> a K)
        0
        (+ (b-iter a 1) (a-iter (+ a 1)))))
  (a-iter 1))

(let ([K (read)])
  (display (solve K)))


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

int ing,base,out,score;
char s[10];

int main(void){
	scanf("%d",&ing);
	while(ing>0){
		out=0;score=0;base=0;
		while(out<3){
			scanf("%s",s);
			if(strcmp(s,"HIT")==0){
				if(base<3)base++;
				else score++;
			}
			if(strcmp(s,"HOMERUN")==0){
				score+=base+1;
				base=0;
			}
			if(strcmp(s,"OUT")==0){
				out++;
			}
		}
		printf("%d\n",score);
		ing--;
	}
	return 0;
}

Measured memory_bytes: 592
n, m = map(int, input().split())
ps = list(map(int, input().split()))
ls = [list(map(int, input().split())) for _ in range(m)]


class UnionFind:
    def __init__(self, n):
        self.n = n
        self.parents = list(range(n + 1))
        self.ranks = [0 for _ in range(n + 1)]

    def get_root(self, x):
        if self.parents[x] == x:
            return x
        self.parents[x] = self.get_root(self.parents[x])
        return self.parents[x]

    def merge(self, x, y):
        x = self.get_root(x)
        y = self.get_root(y)
        if x != y:
            if self.ranks[x] < self.ranks[y]:
                self.parents[x] = y
            else:
                self.parents[y] = x
                if self.ranks[x] == self.ranks[y]:
                    self.ranks[x] += 1


uf = UnionFind(n)
for a, b in ls:
    uf.merge(a, b)
res = 0
for i in range(1, n + 1):
    p0 = uf.get_root(i)
    p1 = uf.get_root(ps[i - 1])
    if p0 == p1:
        res += 1
print(res)

Measured memory_bytes: 36072
n = int(input())

flg = 0
cnt = 0
cnt_max = 0
tmp = 0
out = 1

for i in range(1,n+1):
    tmp = i
    flg = 0
    cnt = 0
    while(flg==0):
        #余りあり
        if tmp % 2 == 1:
            flg = 1
        else:
            tmp /= 2
            cnt += 1            
    if cnt > cnt_max:
        cnt_max = cnt
        out = i

print(out)

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

using namespace std;

//State
//dp[i] The minimum cost to reach the i-th step from 1st step

//Initialization
//dp[1] = 0, dp[2] = abs(h[1] - h[0])

//Transitions
//dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]),	dp[i-2]+abs(h[i]-h[i-2]))

//Order of evaluation
// i = 1...N

//Answer
//return dp[N]

int dp[100005]; //Max value of N is 10^5
int h[100005]; //Max value of h is 10^5

int main(){
	int N;
	cin >> N;
	int h[N];
	for(int i=1; i<=N; i++){
		cin >> h[i];
	}
	dp[1] = 0;
	dp[2] = abs(h[1]-h[2]);
	for(int i=3; i<=N; i++){
		dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]));
	}
	cout << dp[N] << endl;
}

Measured memory_bytes: 4364
// ABC064-D
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define rep(i, n, m) for (int (i) = (n); (i) < (m); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debugB(x, y) cerr<<#x<<": "<<bitset<y>(x) << endl;
#define line() cerr << "---------------" << endl;

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

int main() {
   int n;
   string s;
   cin >> n >> s;
   int Min = 0, cnt = 0;
   for (char c : s) {
      if (c == '(') {
         cnt++;
      } else {
         cnt--;
      }
      Min = min(Min, cnt);
   }
   cout << string(-Min, '(') << s << string(cnt-Min, ')') << endl;

   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vp;
typedef pair<int,int> pii;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9+7;
const int MAX = 10000000;
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
//cout << 'H' << endl;
//next_permutation(ALL(p));
//typedef priority_queue<int> pque;//これは大きい順
//typedef priority_queue<int, vector<int>, greater<int>> pque;//これは小さい順
//factorizeは、素因数分解用の関数

int main(){
	int k,a,b;
  cin >> k >> a >>b;
  FOR(i,a,b+1){
    if(i%k == 0) {
      cout << "OK" << endl;
      return 0;
    }
  }
  cout << "NG" << endl;

  return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define ll long long int
#define pll pair<ll, ll>
#define pii pair<int, int>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll a, b, x;
    cin >> a >> b >> x;
    if (b - 1 <= x)
        cout << ((a * (b - 1)) / b);
    else
        cout << ((a * x) / b);

    return 0;
}

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

#define pb push_back
#define mp make_pair
#define ft first
#define sd second
#define snd sd.ft
#define td sd.sd
#define debug(x) cout<<"### x is: "<<x<<"###"<<endl
#define all(a) a.begin(),a.end()

#define ninf -1000000000
#define pinf 1000000000

typedef long long int ll;
const ll MOD= 1e9+7;
typedef vector<pair<ll,ll> > vecpair;
typedef vector<pair<ll, pair<ll,ll> > > vecpair3;
typedef pair<ll, ll> pi;

//double mei ye line cout << fixed << setprecision(10); kam mei le

ll power(ll a, ll b) {ll ret=1;while(b) {if(b&1) ret*=a;a*=a;if(ret>=MOD) ret%=MOD;if(a>=MOD) a%=MOD;b>>=1;}return ret;}

struct subset // disjoint set use subsets.claer and subsets.resize............
{
	int parent,sz;
};
vector< subset> subsets;
int find( int i)
{
    if (subsets[i].parent != i)
        subsets[i].parent = find(subsets[i].parent);

    return subsets[i].parent;
}
void uniona(int x, int y){
	if( x == y)
	return ;
    int xroot = find( x);
    int yroot = find( y);
    if (subsets[xroot].sz < subsets[yroot].sz){
        subsets[xroot].parent = yroot;
        subsets[yroot].sz += subsets[xroot].sz;
    }
    else{
        subsets[yroot].parent = xroot;
        subsets[xroot].sz += subsets[yroot].sz;
    }
}
//..............................
ll n,W;
ll w[105],v[105],dp[105][100005];
ll solve(ll i,ll a)
{
	if(i>n)
		return 0;
	if(dp[i][a]!=-1)
		return dp[i][a];
	if(a+w[i]<=W)
		dp[i][a]=max(solve(i+1,a),v[i]+solve(i+1,a+w[i]));
	else
		dp[i][a]=solve(i+1,a);
	return dp[i][a];
}

int main()
{
	std:ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	cin >> n >> W;
	for(int i=1;i<=n;i++)
	{
		cin >> w[i] >> v[i];
	}
	for(int i=0;i<=n;i++)
	{
		for(int j=0;j<100005;j++)
		 dp[i][j]=-1;
	}

	cout << solve(1,0);
	
	return 0;
}


Measured memory_bytes: 80128
#include<iostream>
#include<string>
using namespace std;
int main(){
    string str1,str2;
    int a,i,b=0,c=0,j;
    cin >> a;
    for(i=0;i<a;i++){
    cin >> str1 >>str2;
    if(str1>str2)b=b+3;
    if(str1<str2)c=c+3;
    if(str1==str2){
        b=b+1;
        c=c+1;
    }
    }
    cout << b <<  ' ' << c << endl;
}

Measured memory_bytes: 1204
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int h,w,f;
char a[10][10];
bool vis[10][10];
int main()
{
	scanf("%d%d",&h,&w);
	for(int i=0;i<h;i++)
	{
		scanf("%s",a[i]);
		for(int j=0;j<w;j++)
			f+=(a[i][j]=='#');
	}
	if(f==h+w-1)printf("Possible");
	else printf("Impossible");
}

Measured memory_bytes: 128
#from heqpq import heapify, heappop, heappush
N, M = map(int,input().split())

I = [10**10 for _ in range(N)]
for _ in range(M):
  a, b = map(int,input().split())
  I[a-1] = min(b-1,I[a-1])

i = 0
anti = 10**20
ans = 0
for i in range(N):
  if anti == i:
    ans += 1
    anti = 10**10
  anti = min(anti, I[i])
  
print(ans)
  



  

Measured memory_bytes: 78480
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#define dlog(str) cout << "====" << str << endl;
#else
#define dlog(str)
#endif
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(int i = 0, i##_l = (n); i < i##_l; i++)
#define FOR(i, s, e) for(int i = s, i##_l = (e); i < i##_l; i++)
#define LLI long long int
#define _min(a,b) ((a<b)?a:b)
#define _max(a,b) ((a<b)?b:a)
#define chmax(a, b) a = _max(a, b)
#define chmin(a, b) a = _min(a, b)
#define bit(a, shift) ((a>>shift)&1))
#define pm(a) ((a)?1:-1)
#define SORT(v) sort(v.begin(),v.end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
// int 2.14E±9    lli 9.2E±18    double 1.7E±380


int main()
{
    cout << fixed << setprecision(10);
    int n;
    string s;
    cin >> n >> s;
    int cnt = 0;
    REP(i, n - 2)
    {
        if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C')cnt++;
    }
    cout << cnt;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main(int argc, char** argv) {
    int N;
    scanf("%d", &N);

    int min = 1001; // Larger than max of ai.
    int max = -1;
    int n;
    for (int i = 0; i < N; ++i) {
        scanf("%d", &n);
        if (n > max) {
            max = n;
        }

        if (n < min) {
            min = n;
        }
    }

    std::cout << (max - min) << std::endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <math.h>
#include <string>
#include <string.h>
#include <stack>
#include <queue>
#include <vector>
#include <utility>
#include <set>
#include <map>
#include <stdlib.h>
#include <iomanip>

using namespace std;

#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define pi 3.14159265359
#define shosu(X) fixed << setprecision(X)
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }


\
int main() {
	ll N;
	cin >> N;
	if (1200 > N) {
		cout << "ABC";
	}
	else {
		cout << "ARC";
	}

	return 0;
}

Measured memory_bytes: 256
import numpy as np

n = int(input())

a = []
b = []


for i in range(n):
    ae, be = map(int, input().split())
    a.append(ae)
    b.append(be)

a_med = np.median(a)
b_med = np.median(b)

if n % 2 == 0:
    print(int(2*b_med - 2*a_med + 1))
else:
    print(int(b_med - a_med + 1))


Measured memory_bytes: 45820
#!/usr/bin/env python3
def main():
    n = int(input())

    count = 0
    t = 0
    ans = "No"
    for i in range(n):
        a, b = list(map(int, input().split()))

        if a == b:
            count += 1
            t += 1
        else:
            t = 0

        if t == 3 and count >= 3:
            ans = "Yes"

    print(ans)


main()


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

using namespace std;

#define rep(i, a, b)  for(int i = (a); i < (b); i++)
#define rrep(i, a, b) for(int i = (a); i > (b); i--)
#define sq(x) ((x) * (x))
#define bit(x) bitset<32>(x)
#define vsort(v)  sort(v.begin(), v.end())
#define rvsort(v) sort(v.begin(), v.end(), greater<llint>())
#define debug(x) cout << #x << " " << (x) << endl
#define ci cin
#define co cout
#define en endl
#define ln cout<< '\n'
#define pb push_back
#define fi first
#define se second
#define MOD 1000000007
#define M 1000000000

typedef long long int llint;
typedef pair<int, int> pii;
typedef pair<llint, llint> pll;
typedef vector<int> vi;
typedef vector<llint> vl;
typedef vector<pii> vii;
typedef vector<pll> vll;


template<typename Tn> Tn __lcm(Tn a, Tn b)
{
    return a / __gcd(a, b) * b;
}

struct XY
{
    llint x, y;
    XY() {}
    XY(llint x, llint y) : x(x), y(y) {}

    bool operator < (const XY &a) const {
	return (x + y + M + M) < (a.x + a.y + M + M);
    }
};

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

int main()
{
    int n, cnt = 0;
    vector<XY> xy;
    map<llint, map<llint, int>> mp;

    ci >> n;
    rep(i, 0, n) {
	XY a;
	ci >> a.x >> a.y;
	xy.pb(a);
    }

    vsort(xy);

    rep(i, 0, n) {
	rep(j, i + 1, n) {
	    llint a = xy[i].x - xy[j].x;
	    llint b = xy[i].y - xy[j].y;

	    
	    if(mp[a][b]) mp[a][b]++;
	    else mp[a][b] = 1;
	}
    }

    rep(i, 0, n) {
	rep(j, i + 1, n) {
	    llint a = xy[i].x - xy[j].x;
	    llint b = xy[i].y - xy[j].y;
	    
	    cnt = max(cnt, mp[a][b]);
	    cnt = max(cnt, mp[b][a]);
	}
    }

    co << n - cnt << en;
    
    return 0;
}


Measured memory_bytes: 640
n,m=map(int,input().split())
lb=0
ub=n
for i in range(m):
  l,r=map(int,input().split())
  lb=max(lb,l)
  ub=min(ub,r)
  
if ub>=lb:
  print(ub-lb+1)
else:
  print(0)

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

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

signed main(){
    int N;cin>>N;
    N*=2;
    vint P(N);
    rep(i,N)cin>>P[i];
    sort(all(P));reverse(all(P));
    double ans=0;
    rep(i,N){
        ans+=1.0*P[i]*(N-1-i)/(N-1);
    }

    printf("%.20f\n",ans);
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int a[100000 + 500],num[100000 + 500];
int main()
{
    int N;
    scanf("%d",&N);
    for(int i=1;i<=N;i++)
    {
        scanf("%d",&a[i]);
        a[i]++;//最小的数字是1
        num[a[i]-1]++;
        num[a[i]]++;
        num[a[i]+1]++;
    }
    int res = 0;
    for(int i=0;i<=100000;i++)
        if(num[i]>res)res = num[i];
    printf("%d\n",res);
    return 0;
}


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

int N;
vector<int> A, B;

void solve() {
  ll res = 0;
  for (int i = 0; i < N; i++) {
    if (A[i] >= B[i]) {
      A[i] -= B[i];
      res += B[i];
      B[i] = 0;
    } else {
      res += A[i];
      B[i] -= A[i];
      A[i] = 0;
      if (A[i + 1] >= B[i]) {
        A[i + 1] -= B[i];
        res += B[i];
        B[i] = 0;
      } else {
        res += A[i + 1];
        B[i] -= A[i + 1];
        A[i + 1] = 0;
      }
    }
  }
  cout << res << '\n';
}

int main() {
  cin >> N;
  A.resize(N + 1);
  B.resize(N);
  for (int i = 0; i < N + 1; i++) {
    cin >> A[i];
  }
  for (int i = 0; i < N; i++) {
    cin >> B[i];
  }
  solve();
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	map<ll,ll>a;
	bool ch=false;
	for(ll i=0;i<3;i++){
		ll x;
		cin>>x;
		a[x]++;
		if(a[x]==2){
			ch=true;
		}
		if(a[x]==3){
			ch=false;
		}
	}
	if(ch){
		cout << "Yes";
	}
	else{
		cout << "No";
	}
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define exrep(i, a, b) for(long long i = a; i <= b; i++)
#define rep(i,n)for(long long i=0;i<(long long)(n);i++)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
ll modpow(ll a, ll n){
  if(n==0)return 1;
  if(n%2==0){
    ll t=modpow(a,n/2);
    return t*t%MOD;
  }
  return a*modpow(a,n-1)%MOD;
}
ll modinv(ll a){
  return modpow(a,MOD-2);
}
long long fac[MAX], finv[MAX], inv[MAX];

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

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
struct UnionFind {
    vector<int> par; // 親ノード
    vector<int> rank; // ランク

    UnionFind(int n = 1) {
        init(n);
    }

    void init(int n = 1) {
        par.resize(n); rank.resize(n);
        for (int i = 0; i < n; ++i) par[i] = i, rank[i] = 0;
    }

    int root(int x) {
        if (par[x] == x) {
            return x;
        }
        else {
            int r = root(par[x]);
            return par[x] = r;
        }
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y);
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        return true;
    }
};
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  
  COMinit();
  int a,b,c;
  cin >> a >> b >> c;
  int d,e,f;
  d=max({a,b,c});
  f=min({a,b,c});
  e=a+b+c-d-f;
  int ans=0;
  
  ans+=d-e;
  e+=ans;
  f+=ans;
  if((f+d)%2==0)ans+=(d-f)/2;
  else ans+=(d-f)/2+2;
  cout << ans << endl;
  
}


Measured memory_bytes: 12160
DICT = {
  'C' => 0, 'C#' => 1, 'D' => 2, 'D#' => 3, 'E' => 4, 'F' => 5,
  'F#' => 6, 'G' => 7, 'G#' => 8, 'A' => 9, 'A#' => 10, 'B' => 11,
}

def check(stairs, music, k)
  (music.size - 1).downto(0) do |i|
    tone = music[i]
    stair = stairs[k]
    case tone
    when (stair + 1) % 12
      k -= 2
    when stair
      k -= 1
    when (stair - 1) % 12
      k += 1
    else
      return false
    end
    return false unless k >= -1 && k < stairs.size && k < i * 2
  end
  true
end

def work(stairs, music)
  (stairs.size >= 2 && check(stairs, music, stairs.size - 2)) ||
      check(stairs, music, stairs.size - 1)
end

s = STDIN.gets.to_i
s.times do
  STDIN.gets
  stairs = STDIN.gets.split.map{|x| DICT[x]}
  music = STDIN.gets.split.map{|x| DICT[x]}
  puts work(stairs, music) ? 'Yes' : 'No'
end

Measured memory_bytes: 18300
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

Int digits(Int n) {
    return floor(log10l((long double)n)) + 1;
}

int main() {
    int n, ans = 0;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        if (digits(i) % 2 == 1) {
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 512