akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdlib>
#include <math.h>
#define INF 1000000000

using namespace std;

int n, sum;

struct rIndices
{
    int val;
    int ind;
    int leftS;
} A[200001], sA[200001];

int compar(const void * a, const void * b)
{
  return ( (*(struct rIndices*)a).val - (*(struct rIndices*)b).val);
}

int main()
{
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        cin >> A[i].val;
        sA[i].val = A[i].val;
        A[i].ind = i;
    }

    qsort(A, n + 1, sizeof(struct rIndices), compar);

    for (int i = 1; i <= n; i++) sA[A[i].ind].leftS = (i <= n/2);

    int half = n / 2;
    for (int i = 1; i <= n; i++)
    {
        cout << A[half + sA[i].leftS].val << endl;
    }

    return 0;
}

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

using namespace std;

int main()
{
    int r,d,x;
    cin>>r>>d>>x;
    int prev=x;
    for(int i=1;i<=10;i++){
        int ans=r*prev-d;
        cout<<ans<<endl;
        prev=ans;
    }
    return 0;
}


Measured memory_bytes: 3584
#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#define REP(i,n) for(int i=0;i<n;i++)
typedef long long ll;

using namespace std;
int kaijo(int n){
	int ans = 1;
	if (n != 0){
		for (int i = 0; i < n; i++){
			ans *= (n - i);
		}
	}
	else{
		ans = 1;
	}
	return ans;
}

int main(){
	int a, b;
	cin >> a >> b;
	int x;
	x = (a + b) / 2;
	if (x * 2 == a + b){
		cout << x << endl;
	}
	else{
		cout << x + 1 << endl;
	}
	return 0;
}

Measured memory_bytes: 768
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;

int main(){
  
  char s1[20],s2[20],s3[20];
  char set='A'-'a';
  scanf(" %s",s1);
  scanf(" %s",s2);
  scanf(" %s",s3);
  
  printf("%c%c%c\n",s1[0]+set,s2[0]+set,s3[0]+set);
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <string>
#include <cmath>
#include <algorithm>

using namespace std;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pii;
typedef vector<pii> vii;
typedef priority_queue<ll> pq;

const ll MOD = 1e9+7;

ll pow3(ll x) {
  ll res = 1, b = 3;
  while (x > 0) {
    if (x&1) {
      res *= b; res %= MOD;
    }
    x >>= 1;
    b *= b; b %= MOD;
  }
  return res;
}

int main() {
  string str; cin >> str;
  int len = str.length();
  ll ans = 0;
  vvi ABC(4, vi(len, 0));
  for (int i = 0; i < len; i++) {
    if (str[i] == 'A') {
      ABC[0][i]++;
    } else if (str[i] == 'B') {
      ABC[1][i]++;
    } else if (str[i] == 'C') {
      ABC[2][i]++;
    } else {
      ABC[1][i]++;
      ABC[3][i]++;
    }
  }
  
  for (int i = 1; i < len; i++) {
    ABC[0][i] += ABC[0][i-1];
    ABC[2][i] += ABC[2][i-1];
    ABC[3][i] += ABC[3][i-1];
  }

  for (int i = 1; i < len-1; i++) {
    if (ABC[1][i]) {
      ll a = ABC[0][i-1], d1 = ABC[3][i-1], c = ABC[2][len-1]-ABC[2][i], d2 = ABC[3][len-1]-ABC[3][i];
      // printf("(A, D1) = (%lld, %lld), (C, D2) = (%lld, %lld)\n", a, d1, c, d2);
      ans += ((a*pow3(d1)%MOD + d1*pow3(d1-1)%MOD)%MOD * (c*pow3(d2)%MOD + d2*pow3(d2-1)%MOD)%MOD)%MOD;
      ans %= MOD;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4352
#include<stdio.h>
#define N 2000001
#define K 20001

/*
How to test
% diff <(./a.out < b1in.txt) <(cat b1out.txt) 

  for( i=0 ; i < n ; i++){
    fprintf(stderr, "%d: C2[%d] = %c%c \n" ,__LINE__ ,i ,C2[i].suit ,C2[i].value );
  }

 */

void csort(short* a_p, short* b_p, const int n){
  int i, j;
  int c[K] = {0};
  
  for( j = 1 ; j <= n ; j++){
    // fprintf(stderr, "%d: a_p[%d] = %d \n" ,__LINE__ ,j ,a_p[j] );
    c[a_p[j]]++;
  }

  
  for( i = 1 ; i < K ; i++){
    // fprintf(stderr, "%d: c[%d] = %d  c[%d] = %d \n" ,__LINE__ ,i ,c[i] ,i-1 ,c[i-1] );
    c[i] = c[i] + c[i-1];
    //  fprintf(stderr, "%d: c[%d] = %d  c[%d] = %d \n" ,__LINE__ ,i ,c[i] ,i-1 ,c[i-1] );
  }

  for( j = n ; j > 0 ; j-- ){
    b_p[c[a_p[j]]] = a_p[j];
    c[a_p[j]]--;
    // fprintf(stderr, "%d: a_p[%d] = %d  b_p[%d] = %d  c[%d] = %d \n" 
    //    ,__LINE__        ,j ,a_p[j]    ,j ,b_p[j]  ,j ,c[j] );

  }

  return;
}

int main(){
  int n, i, j, k;
  short a[N];
  short b[N];
  
  scanf("%d", &n);
  for ( i = 1; i <= n; i++ ) scanf("%d", &a[i]);

  csort(a,b,n);  
  for( i = 1 ; i <= n ; i++ ){
    printf("%d" ,b[i]);
    if( i != (n) ){
      printf(" ");
    }
  }
  printf("\n");

  return 0; // Don't forget return 0
}

Measured memory_bytes: 8500
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <vector>

typedef long long ll;
using namespace std;

ll Mod = 1e9 + 7;
int MAX = 100000000;
int main()
{
    string S;
    int cnt = 0;
    cin >> S;

    for (int i = S.size() - 2; i >= 0; i-=2) {
        int h = i/2;
        bool iseven = true;
        for (int j = 0; j < h; j++) {
            if(S[j] != S[j+h]) iseven = false;
        }
        if (iseven) {
            cout << i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector> 
#include <math.h> 
using namespace std;
int main(void) {
    int N; cin >> N;
    int i = 1;
    int ans = 0;
    while(i <= N) {
        int tmp;
        cin >> tmp;
        if (tmp % 2 == 1 && i % 2 == 1) ans++;
        i++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3632
import heapq

n=int(input())
a=list(map(int,input().split()))

a1 = a[:n]
s1 = []
ts = sum(a1)
s1.append(ts)

heapq.heapify(a1)
for i in range(n,n*2):
    ts += a[i]
    heapq.heappush(a1,a[i])
    ts -= heapq.heappop(a1)
    s1.append(ts)

a2 = a[(n*2):]
a2 = list(map(lambda x: x*(-1), a2)) 
s2 = []
ts = sum(a2)
s2.append(ts)

heapq.heapify(a2)
for i in range(n*2-1,n-1,-1):
    ts -= a[i]
    heapq.heappush(a2,a[i] * -1)
    ts -= heapq.heappop(a2)
    s2.append(ts)

res = -10**20
for i in range(n+1):
    res = max(res,s1[i]+s2[n-i])
print(res)

Measured memory_bytes: 122640
# -*- coding: utf-8 -*-
n = int(input())
t = list(map(int,input().split()))
m = int(input())
p = [0] * m
x = [0] * m
for i in range(m):
    p[i],x[i] = map(int,input().split())

all_time = sum(t)

for i in range(m):
    print(all_time - t[p[i]-1] + x[i])


Measured memory_bytes: 3060
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int main(){
  	int sx, sy, tx, ty;
  	cin >> sx >> sy >> tx >> ty;

  	int width = tx - sx;
  	int height = ty - sy;

  	for(int i=0;i<width;i++) cout << 'R';

  	for(int i=0;i<height;i++) cout << 'U';

  	for(int i=0;i<width;i++) cout << 'L';

  	for(int i=0;i<height+1;i++) cout << 'D';

  	for(int i=0;i<width+1;i++) cout << 'R';

  	for(int i=0;i<height+1;i++) cout << 'U';

  	cout << 'L';
  	cout << 'U';

  	for(int i=0;i<width+1;i++) cout << 'L';

  	for(int i=0;i<height+1;i++) cout << 'D';

  	cout << 'R' <<endl;


    
  	return 0;
}













Measured memory_bytes: 256
n, k = map(int, input().split())
X = list(map(int, input().split()))

ans = 1e9

for i in range(n-k+1):
    ans = min(ans, abs(X[i]) + abs(X[i+k-1]-X[i]),
              abs(X[i+k-1]) + abs(X[i+k-1]-X[i]))

print(ans)


Measured memory_bytes: 14388
using System;
using System.Linq;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            long[] Array = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
            long A = Array[0];
            long B = Array[1];
            long C = Array[2];
            long D = Array[3];

            long ABC = B / C - A / C;
            if (A % C == 0)
                ABC++;
            long ABD = B / D - A / D;
            if (A % D == 0)
                ABD++;
            long lcm = Lcm(C, D);
            long ABL = B / lcm - A / lcm;
            if (A % lcm == 0)
                ABL++;
            long num = B - A + 1;

            Console.WriteLine(num - (ABC + ABD - ABL));
            Console.ReadKey();

        }

        public static long Lcm(long a, long b)
        {
            return a * b / Gcd(a, b);
        }

        // ユークリッドの互除法 
        public static long Gcd(long a, long b)
        {
            if (a < b)
                // 引数を入替えて自分を呼び出す
                return Gcd(b, a);
            while (b != 0)
            {
                var remainder = a % b;
                a = b;
                b = remainder;
            }
            return a;
        }
    }
}


Measured memory_bytes: 13396
// $%D%$.$%M%$.$%Y%$
// $%h%$:$%m%$:$%s%$

#pragma GCC optimize("O3")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define IOS ios::sync_with_stdio(false); cin.tie(0)
#define ll long long
#define ld long double
#define rep(i,a,n) for (int i=(int)(a);i<(int)(n);i++)
#define per(i,a,n) for (int i=(int)(n-1);i>=(int)(a);i--)
#define mp(a, b) make_pair(a, b)
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pil pair<int, ll>
#define pli pair<ll, int>
#define fi first
#define se second


const int MOD = 1e9+7; // 998244353; // = (119<<23)+1
const int MX = 2e5+5;
const ll INF = 1e18;
const ld PI = 4*atan((ld)1);
const int xd[4] = {1,0,-1,0}, yd[4] = {0,1,0,-1};


template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;


int main() {
    IOS;
    ll n, x, m;
    cin >> n >> x >> m;
    vector<ll> used(m);
    vector<ll> timer(m);

    ll t = 0;
    ll res = 0;
    for (ll i = 0; i < n; ++i) {
        res += x;
        used[x] = 1;
        timer[x] = t;
        ++t;
        x = 1ll * x * x % m;

        if (used[x] == 1) {
            ll cnt = n - i - 1;
            ll len = t - timer[x];
            ll cur = x;
            ll j = 0;
            while(1) {
                res += (cnt / len) * cur;
                if (j < cnt % len) {
                    res += cur;
                }
                cur = 1ll * cur * cur % m;
                ++j;
                if (cur == x) {
                    break;
                }
            }
            break;
        }
    }
    cout << res << '\n';
}

Measured memory_bytes: 4780
<?php
$n = trim(fgets(STDIN));
$length = strlen($n);
$res = substr($n, ($length - 1), 1);

if ($res == 3) {
    echo 'bon';
    return;
}
if ($res == 0 || $res == 1 || $res == 6 || $res == 8) {
    echo 'pon';
    return;
}
echo 'hon';



Measured memory_bytes: 16088
#pragma GCC optimize(2)
#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const int mod = 1000000007;
#define pb push_back
#define mp make_pair
using ll = long long;
using vi = vector <int>;
using pii = pair <int, int>;
#define rep(i,n) for (int i = 0; i < (int) (n); ++ i)
#define foreach(it,c) for (auto it = c.begin(); it != c.end(); ++ it)

inline int read() {
	int x = 0, f = 1, c = getchar();
	for (;!isdigit(c);c = getchar()) if (c == 45) f ^= 1;
	for (; isdigit(c);c = getchar()) x = x * 10 + c - 48;
	return f ? x : -x;
}

int n;
char s[100005];
int dp[2][2];
int main() {
	scanf("%s", s);
	n = strlen(s);
	dp[0][0] = 1;
	int p = 0, q = 1;
	rep(i, n) {
		(dp[q][0] += 1LL * dp[p][0] * (s[i] - 48 + 1) % mod) %= mod;
		(dp[q][1] += 1LL * dp[p][1] * 3 % mod) %= mod;
		(dp[q][1] += 1LL * dp[p][0] * (s[i] - 48) % mod) %= mod;
		p ^= 1, q ^= 1;
		dp[q][0] = dp[q][1] = 0;
	}
	printf("%d\n", (dp[p][0] + dp[p][1]) % mod);
	return 0;
}


Measured memory_bytes: 384
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  ll N;
  cin >> N;
  vector<ll> f(N + 1, 2);
  f[1] = 1;
  for (int i = 2; i < N / 2 + 1; i++) {
    for (int j = 2; j * i <= N; j++) {
      f[i * j]++;
    }
  }
  ll ans = 0;
  for (int i = 1; i <= N; i++) {
    ans += i * f[i];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 81324
#include <bits/stdc++.h>
#define ll  long long int
#define ull unsigned long long int 
#define pb  push_back
#define mp  make_pair
#define pii pair<int, int>
using namespace std;

const ll mod = 1e9+7;

struct line{
	ll a, b;

	ll eval(ll x){
		return a*x + b;
	}

	pair<ll, ll> poi(line l1){
		ll x = b - l1.b;
		ll y = l1.a - a;

		return {x, y};  
	}
};

void solve(){
    //solve here//
	ll n, c;
	cin >> n >> c;

	ll h[n] = {0};

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

	deque<line> hull;

	line l;
	l.a = -2*h[n-1];
	l.b = h[n-1]*h[n-1];

	hull.pb(l);

	ll ans = 0;

	for(int i=n-2;i>=0;i--){
		while( hull.size()>=2 ){
			line l1 = hull.end()[-1];
			line l2 = hull.end()[-2];
			if( l1.eval(h[i]) >= l2.eval(h[i])){
				hull.pop_back();
			}
			else{
				break;
			}
		}

		line end = hull.end()[-1];
		
		ans = end.eval(h[i]) + h[i]*h[i] + c;
		
		line new_line;
		new_line.a = -2*h[i];
		new_line.b = ans + h[i]*h[i];

		while( hull.size()>=2 ){
			line l1 = hull[0];
			line l2 = hull[1];

			pair<ll, ll> p1 = l1.poi(new_line);
			pair<ll, ll> p2 = l2.poi(new_line);

			if((__int128) p1.first*p2.second >= (__int128)p2.first*p1.second){
				hull.pop_front();
			}
			else{
				break;
			}
		}

		hull.push_front(new_line);

	}

	cout << ans << endl;
}


int main(){
    ll t=1;
    //cin >> t;
    while(t--){
        solve();
    }
}



Measured memory_bytes: 3456
#include<stdio.h>

int main(void){
	int n,i,j;
	scanf("%d",&n);
	for(i = 3;i <= n;i++){
		j = i;
		if(j % 3 == 0){
			printf(" %d",i);
		} else {
			while(j){
				if(j % 10 == 3){
					printf(" %d",i);
					break;
				} else {
					j /= 10;
				}
			}
		}
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <algorithm>

#define CH(N,A,B) (A<=N&&N<B)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define RREP(i,a,b) for(int i=(b-1);a<=i;i--)

using namespace std;

int main() {

  int X;
  cin>>X;

  int cnt = 0, ans = 0;
  REP(i,1,1000000000){
    cnt += i;
    ans++;
    if(X <= cnt) break;
  }

  cout<<ans<<endl;

  return 0;
}


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

int main(){
  int N;
  cin >> N;
  vector<double> a(N);
  vector<double> b(N);
  for(int i = 0; i < N; i++){
    cin >> a.at(i);
  }
  sort(a.begin(), a.end());
  b.at(0) = a.at(0);
  for(int i = 1; i < N; i++){
    b.at(i) = (b.at(i - 1) + a.at(i)) / 2;
  }
  cout << b.at(N - 1) << endl;
}

Measured memory_bytes: 256
// コンパイラオプション

// インクルード
#include <iostream>
#include <string>

// 名前空間省略
using namespace std;

// メイン関数
int main()
{
    // 標準入出力　高速化
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    long a,b,c,k;
    long sum = 0;

    cin >> a >> b >> c >> k;

    if(k < a) sum+=k;
    else{
        sum += a;
        k -= a;
        k -= b;
        if(k > 0){
            if(k < c) sum -= k;
            else sum -= c;
        }
    }
    cout << sum << "\n";
}


Measured memory_bytes: 3656
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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

const ll INF=1e18;

int main(){
    string a,b;
    cin >> a >> b;
    if(a.length()>b.length()){
        cout << "GREATER" << endl;
        return 0;
    }
    if(a.length()<b.length()){
        cout << "LESS" << endl;
        return 0;
    }
    ll n=a.length();
    rep(i,n){
        ll p=a[i]-'0';
        ll q=b[i]-'0';
        if(p>q){
            cout << "GREATER" << endl;
            return 0;
        }
        if(p<q){
            cout << "LESS" << endl;
            return 0;
        }
    }
    cout << "EQUAL" << endl;
    
    return 0;
}


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

using ll = long long;
using ull = unsigned long long;

const double PI = acos(-1);
const int inf = 2e9;
const ll INF = 2e18;
const ll MOD = 1e9+7;

#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
#define REP(i,n) for (int i = 0; i<n; i++)
#define ALL(a) begin(a), end(a)

int main (void) {
    int N;
    cin>>N;
    vector<int> A;
    A.pb(0);
    REP(i,N) {
        int t;
        cin>>t;
        A.pb(t);
    }
    A.pb(0);
    int all = 0;
    for (int i=1;i<A.size();i++) {
        all += abs(A[i]-A[i-1]);
    }
    REP(i,N) {
        int a = i;
        int b = i+1;
        int c = i+2;
        int sub = abs(A[b] - A[a]) + abs(A[c] - A[b]) - abs(A[c] - A[a]);
        cout<<all - sub<<endl;
    }
    return 0;
}

Measured memory_bytes: 1784
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k,i,j;
  double ans=0.0;
  cin>>n>>k;
  j=1;
  for(i=n;i>0;i--){
    while(j*i<k) j*=2;
    ans+=1.0/j;
  }
  ans*=1.0/n;
  cout<<fixed<<setprecision(12)<<ans<<endl;
}

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

int main(){
	int i,j,n;
	int answer;
	int *PrimeArr;
	while(scanf("%d",&n)!=EOF){
		answer=0;
		PrimeArr = (int *)calloc(n+1, sizeof(int));
		for(i=2;i<=n;i++) PrimeArr[i]=1;
		for(i=2;i<=n;i++){
			if(PrimeArr[i]==0) continue;
			else answer++;
			for(j=i*2;j<=n;j+=i){
				PrimeArr[j]=0;
			}
		}
		printf("%d\n",answer);
	}
	return 0;
}

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

void solve()
{
  int total=0;
  string s;
  cin >> s;
  rep(i,s.length())
    if(s[i] == '1')
      total++;

  cout << total << endl;
}

int main(){cin.tie(0);ios_base::sync_with_stdio(false);solve();return 0;}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define REP2(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(v) (v).begin(),(v).end()
#define INF 2e9
typedef long long ll;

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

  cout<<x/11*2+((x%11)? ((x%11>6)? 2:1):0)<<endl;

	return 0;
}

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

typedef long long ll;

#define FOR(i,a,b) for(ll i=(a);i<(b);i++) // no semicoron
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>0;i--)
#define FORD(i,a,b) for(ll i=(a);i>(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく

using namespace std;

int main(){
    ll N, M;

    cin >> N >> M;

    ll ans;
    ans = N * (N - 1) / 2 + M * (M - 1) / 2;

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define incls(s,c) s.find(c)!=string::npos
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bit(n,k) ((n>>k)&1) // nのk bit目
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using vp = vector<P>;
using vt = vector<T>;
const int mod = 1000000007;
const double EPS = 1e-9;
//const long double EPS = 1e-14;
const int INF = (1<<30)-1;
const ll LINF = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
//template<class T = int> inline T in() { T x; cin >> x; return (x);}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
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; }
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 () {
  int h, a;
  cin >> h >> a;
  cout << dup(h,a) << endl;
  return 0;
}

Measured memory_bytes: 256
//! ----------------------------------------------
//! Framework <https://github.com/vain0x/procon>
//!
//! See the bottom of file for solution.
//! ----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Display, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

/// Print values to standard error if debug mode.
#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

/// Read from standard input and parse each word.
/// - `read!(T, U, ..)` parses a line as a tuple of words.
/// - `read![[T]]` parses a line as an array of words.
/// - `read![..; N]` parses `N` lines, using `read!(..)` repeatedly.
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

/// Read a line from standard input.
#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();

    #[allow(deprecated)]
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

fn main() {
    let r = read!(i64);
    println!("{}", 3 * r * r)
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define int long long 
#define f(i,x,n) for(int i=x;i<n;i++) 
#define all(c) c.begin(),c.end()
const int MOD = 1e9 + 7, N = 5e5 + 10;
const int LINF = LLONG_MAX;

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    vector<int>v(n);
    f(i,0,n){
        cin >> v[i];
    }
    int ans = 0;
    f(i,1,n){
        if(v[i] < v[i-1]){
            ans += abs(v[i] - v[i-1]);
            v[i] = v[i-1];
        }
    }
    cout << ans << "\n";
    return 0;
}
 


Measured memory_bytes: 4696
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<bitset>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pII;
#define pb push_back
#define X first
#define Y second
#define mp make_pair
#define clr(x,y) memset(x,y,sizeof(x))
#define FOR(i, x, y) for (decay<decltype(y)>::type i = (x), _##i = (y); i < _##i; ++i)
#define FORD(i, x, y) for (decay<decltype(x)>::type i = (x), _##i = (y); i > _##i; --i)
const int inf=0x3f3f3f3f;
const ll mod=1e9+7;
const int maxn=1e6+5;
//ll fmod(ll x,ll y){ll res=1;while(y){if(y&1)res=res*x%mod;y>>=1;x=x*x%mod;}return res;}
//ll gcd(ll x,ll y){return y==0?x:gcd(y,x%y);}
map<int,int>g;
vector<int>ans[10005];
int k;
void init()
{
    for(int i = 1; i*i <= 200000; ++i)
        g[i*(i-1)] = i-1;
}
void gouzao(int start,int x,int sz)
{
    //cout<<start<<"  "<<x<<"  "<<sz<<endl;
    if(sz == 0)return;

    int now = start;

    for(int i = x; i < k; ++i)
        {
            //cout<<i<<endl;
            ans[x].pb(now);
            now++;
        }
    now = start;
    for(int i = x + 1; i < k + 1; ++i)
        {
            ans[i].pb(now);
            now++;
        }
    gouzao(start + sz,x + 1,sz - 1);
}
int main()
{
   int n;
   init();
   while(cin>>n)
   {
       if(!g.count(2*n))
        printf("No\n");
       else
       {
           printf("Yes\n");
           k = g[2*n];
           printf("%d\n",k + 1);
           for(int i = 0; i < k + 1; ++i)
            ans[i].clear();
           gouzao(1,0,k);
           for(int i = 0; i < k + 1; ++i)
           {
               printf("%d ",k);
               for(int j = 0; j < k; ++j)
                printf("%d%c",ans[i][j],(j == k-1)?'\n':' ');
           }
       }
   }
}












Measured memory_bytes: 2560
import sys
import  math
import fractions
from collections import defaultdict
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()))


N=int(input())
L=nl()
L.sort()
ans=0
for i in range(N-2):
    for j in range(i+1,N-1):
        for k in range(j+1,N):
            if(L[i]==L[j] or L[j]==L[k] or L[i]==L[k]):
                continue 
            if((L[i]+L[j])>L[k]):
                ans+=1

print(ans)




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

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = GetLongNum();
            var en = 1000;
            while (en - N < 0)
            {
                en += 1000;
            }

            Console.WriteLine(en - N);
        }

        private static long[] GetLongNumArray()
        {
            var input = Console.ReadLine().Split(' ');
            return input.Select(x => long.Parse(x)).ToArray();
        }

        private static long GetLongNum()
        {
            return long.Parse(Console.ReadLine());
        }

        private static string[] GetStringArray()
        {
            return Console.ReadLine().Split(' ');
        }

        private static string GetString()
        {
            return Console.ReadLine();
        }
    }
}


Measured memory_bytes: 27476
#include <stdio.h>
#include <stdio.h>

int main(){
  char aaa[37], tc, a2[37];
  int n, i, j, bbb[37], b2[37], tn, flag=0, min, k;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf(" %c",&aaa[i]);
    scanf(" %c",&tc);
    bbb[i] = tc-'0';
  }

  for(i=0;i<n;i++){
    a2[i]=aaa[i];
    b2[i]=bbb[i];
  }

  for(i=0;i<n;i++){
    for(j=n-1;i<j;j--){
      if(bbb[j-1]>bbb[j]){
	tn=bbb[j-1];
	bbb[j-1]=bbb[j];
	bbb[j]=tn;
	tc=aaa[j-1];
	aaa[j-1]=aaa[j];
	aaa[j]=tc;
      }
    }
  }

  for(i=0;i<n-1;i++){
    printf("%c%d ",aaa[i],bbb[i]);
  }
  printf("%c%d\nStable\n",aaa[n-1],bbb[n-1]);

  for(i=0;i<n;i++){
    min=10;
    for(j=i;j<n;j++){
      if(b2[j]<min){
	min=b2[j];
	k=j;
      }
    }
    if(k!=i){
      tn=b2[k];
      b2[k]=b2[i];
      b2[i]=tn;
      tc=a2[k];
      a2[k]=a2[i];
      a2[i]=tc;
    }
  }
  for(i=0;i<n-1;i++){
    printf("%c%d ",a2[i],b2[i]);
  }
  printf("%c%d\n",a2[n-1],b2[n-1]);
  for(i=0;i<n;i++){
    if(aaa[i]!=a2[i]){
      flag=1;
      break;
    }
  }
  if(flag==0)printf("Stable\n");
  else if(flag==1) printf("Not stable\n");

  return 0;
}



Measured memory_bytes: 2040
N = int(input())
S = ['-1' for _ in range(N+1)]
cases = ['AC', 'WA', 'TLE', 'RE']
C = dict(zip(cases, [0]*len(cases)))
for i in range(N):
  S[i+1] = input()
  C[S[i+1]] += 1
for case in cases:
  print('{} x {}'.format(case,str(C[case])))

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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n)cin >> a[i];
    vector<int> x;
    rep(i,n){
        auto it = upper_bound(x.begin(),x.end(),-a[i]);
        if(it==x.end())x.insert(it,-a[i]);
        else *it = -a[i];
    }
    cout << x.size() << endl;
    return 0;
}


Measured memory_bytes: 1276
#include <iostream>

using namespace std;

char Field[14][14];
int dx[4] = {-1, 0, 0, 1};
int dy[4] = {0, -1, 1, 0};

void DFS(int y, int x)
{
	Field[y][x] = '0';
	int nx, ny;
	for(int i = 0; i < 4; ++i)
	{
		nx = x + dx[i];
		ny = y + dy[i];
		if(Field[ny][nx] == '1')
		{
			DFS(ny, nx);
		}
	}
}

void solve()
{
	char F11;
	while(cin >> F11)
	{
		for(int i = 0; i < 14; ++i)
		{
			for(int j = 0; j < 14; ++j)
			{
				Field[i][j] = '0';
			}
		}
		Field[1][1] = F11;
		for(int i = 2; i < 13; ++i)
		{
			cin >> Field[1][i];
		}
		for(int i = 2; i < 13; ++i)
		{
			for(int j = 1; j < 13; ++j)
			{
				cin >> Field[i][j];
			}
		}
		int count = 0;
		for(int i = 1; i < 13; ++i)
		{
			for(int j = 1; j < 13; ++j)
			{
				if(Field[i][j] == '1')
				{
					++count;
					DFS(i, j);
				}
			}
		}
		cout << count << endl;
	}
}

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

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5+7;
typedef long long ll;
int a[maxn];
int main()
{
	int n,k;scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
	}
	int i=2;ll ans=n-k+1;ll now=0;ll res=0;
	for(int i=2;i<=n;i++)
	{
		int tmp=1;
		while(i<=n&&a[i]>a[i-1])
		{
			tmp++;i++;
		}
		if(tmp>=k)
		{
			res++;
		}
	}	
	set<int> se;
	for(int i=1;i<=k;i++) se.insert(a[i]);
	for(int i=k+1;i<=n;i++)
	{
		se.insert(a[i]);
		int mn=(*se.begin());int mx=(*se.rbegin());
		if(a[i]==mx && a[i-k]==mn)
		{
			ans--;
		}
		se.erase(a[i-k]);
	}
	if(!res)
	cout<<ans<<endl;
	else cout<<ans-res+1<<endl;
 } 

Measured memory_bytes: 10368
//omajinai c++ atcoder
#include <iostream> 
#include <string> 
#include <vector> 
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include<cmath>
#include<iomanip>
#include<type_traits>
//#include<numbers>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define itn int
#define yes() printf("Yes\n")
#define no() printf("No\n")
typedef long long ll;
constexpr auto mod = 1000000007;
using namespace std;

int main() {
   int x;
   cin>>x;
   if(x>=400&&x<600)
    cout<<8;
    else if(x<800)
    cout<<7;
    else if(x<1000)
    cout<<6;
    else if(x<1200)
    cout<<5;
    else if(x<1400)
    cout<<4;
    else if(x<1600)
    cout<<3;
    else if(x<1800)
    cout<<2;
    else if(x<2000)
    cout<<1;
}


Measured memory_bytes: 3632
// :(((
// g & h for subtitle
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define ld long double
const int maxn = 2e5 + 10 , mod = 1e9 + 7;

ll h, w, k;
char mat[10][10];
ll hb, wb, res;

bool ok (ll a, ll b)
{
	ll cnt = 0;
	//cout << a << ' ' << b << endl;
	for (ll i = 0; i < h; i++)
	{
		if ( (a >> i) & 1) continue;
		for (ll j = 0; j < w; j++)
		{
			if ( (b >> j) & 1) continue;
			if (mat[i][j] == '#')
				cnt ++;
		}
	}
	return (cnt == k);
}

		
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cin >> h >> w >> k;
	for (int i = 0; i < h; i++)
		for (int j = 0; j < w; j++)
			cin >> mat[i][j];
	for (; hb < (1 << h); hb++)
		for (wb = 0; wb < (1 << w); wb++)
			res += ok (hb, wb);
	cout << res << endl;
	return 0;	
}


Measured memory_bytes: 3632
#!/usr/bin/env python3
import sys
import collections

def solve(N: int, A: "List[int]"):
    dictionary = collections.defaultdict(int)
    for a in A:
        dictionary[a] += 1

    counted = collections.defaultdict(int)
    for k, v in dictionary.items():
        counted[k] = v*(v-1)//2
    summarized = sum(counted.values())

    for a in A:
        v = dictionary[a]
        result = summarized - v*(v-1)//2 + (v-1)*(v-2)//2
        print(result)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 43628
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<stack>
#include<functional>
#include<string>
#include<cstring>
#include<time.h>
#include<array>
#include<iomanip>
#include<list>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<random>
#include<bitset>
#include <queue>
#include <map>


using namespace std;
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldouble = long double;


//BDD,ZDD,kdtree, bdtree,bicalc, bolonoy, doloney, tree, chinesemod,segmenttree,daikusutora, saidairyuu, 2bugurahu, heirokenshutu, topologicalsort, kyourenketuseibun

#define REP(i,a,b) for(int i = a; i < b; ++i)
#define PRI(s) cout << s << endl
#define PRIY PRI("Yes")
#define PRIN PRI("No")

set<int> s[26];
int N, Q;
string str;

int main() {
	cin >> N;
	cin >> str;
	cin >> Q;
	REP(i, 0, N) {
		s[str[i] - 'a'].insert(i);
	}
	vector<int> ans;
	REP(i, 0, Q) {
		int t;
		cin >> t;
		if (t == 1) {
			int ind;
			char c;
			cin >> ind >> c;
			--ind;
			s[str[ind] - 'a'].erase(ind);
			str[ind] = c;
			s[str[ind] - 'a'].insert(ind);
		}
		else {
			int l, r;
			cin >> l >> r;
			--l; --r;
			int cnt = 0;
			REP(j, 0, 26) {
				auto itr = s[j].lower_bound(l);
				if (itr != s[j].end() && *itr <= r) ++cnt;
			}
			ans.push_back(cnt);
		}
	}
	for (int& i: ans)PRI(i);
	return 0;
}




Measured memory_bytes: 27496
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define mod 1000000007
#define INF2 9999999999
#define INF (1 << 30)
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)

using namespace std;
using ll = __int64_t;

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

void solve(){
    ll a, b, c, a2, b2, c2;
    ll res = 0;

    cin >> a >> b >> c;
    if(a == b && b == c && c == a && a%2 == 0){
        cout << -1 << endl;
        return ;
    }else{
        while(a%2 == 0 && b%2 == 0 && c%2 == 0){
            a2 = b/2 + c/2;
            b2 = a/2 + c/2;
            c2 = a/2 + b/2;
            a = a2;
            b = b2;
            c = c2;
            res++;
        }
    }
    cout << res << endl;
}

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

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <cmath>
#include <limits.h>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
#include <algorithm>
#include <functional>
#include <stdio.h>
using namespace std;

long long MOD = 1000000007;

int main() {
    int H,W,N;
    cin >> H >> W >> N;
    int a = max(H,W);
    cout << ( ( N%a == 0 ) ? N/a : N/a+1 ) << endl;
    return 0;
}

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

ll INF = 1LL<<60;

const int n = 26;
int main(){
	ll d;
	cin >> d;
	vector<vector<ll>> s(d+1, vector<ll>(n+1,0));
	vector<ll> c(n+1); //満足度低下
	REP(i,n) cin >> c[i];
	REP(i,d){
		REP(j,n){
			cin >> s[i][j];
		}
	}
	vector<ll> schedule(d+1);
	vector<ll> score(d+1);
	vector<ll> last(n+1,0);
	ll total_score = 0;
	REP(i,d){
		int id = 1;
		ll score_d = -INF;
		rep(j,n){
			if(s[i][j] > score_d){
				score_d = s[i][j];
				id = j;
			}
		}
		schedule[i] = id;
		last[schedule[i]] = id;
		
	}
	REP(i,d){
		cout << schedule[i] << endl;
	}
    return 0;
}



Measured memory_bytes: 3716
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pi 3.1415926535897932
int main(){
	int k;
	cin>>k;
	string s;
	cin>>s;
	if (s.length()<=k)
		cout<<s<<endl;
	else{
		for (int i=0;i<k;i++)
			cout<<s[i];
		cout<<"..."<<endl;
	}
}

Measured memory_bytes: 3600
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int S(int d, int k){
    int ans = 1;
    if(k != 0){
        ans *= pow(9, k);
    }
    if(k == 1){
        ans *= d;
    }else if(k == 2){
        ans *= d*(d-1)/2;
    }else if(k == 3){
        ans *= d*(d-1)*(d-2)/6;
    }
    if(d < 0){
        ans = 0;
    }
    return ans;
}

int main(void){
    string N;
    int K;
    cin >> N >> K;
    int d = N.size();
    int a[K], D[K];
    for(int i = 0; i < K; i++){
        a[i] = -1;
        D[i] = -1;
    }
    int count = 0;
    for(int i = 0; i < d; i++){
        if(N.substr(i, 1) != "0"){
            a[count] = stoi(N.substr(i, 1));
            D[count] = d-1-i;
            count++;
            if(count >= K){break;}
        }
    }
    
    int ans = 0;
    for(int i = 0; i < K; i++){
        ans += S(D[i], K-i) + (a[i]-1)*S(D[i], K-1-i);
    }
    if(D[K-1] != -1){
        ans++;
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; ++i)

int main() {

	int n, m, p;
	string s;
	cin >> n >> m;

	vector<bool> ac(n + 1);
	vector<int> wa(n + 1);
	int a = 0, b = 0;
	REP(i, m) {
		cin >> p >> s;
		if (s == "AC") {
			if (!ac[p]) {
				++a;
				b += wa[p];
			}
			ac[p] = true;
		}
		else {
			if (!ac[p]) wa[p]++;
		}
	}
	cout << a << " " << b;
	return 0;
}

Measured memory_bytes: 3724
import java.io.*;
import java.util.*;

public class Main
{
	public static void main(String[] args)
	{
		int[] num = new int[3];
		Scanner sc = new Scanner(System.in);
		int i,temp,sorted,count=0,minimum;
		for(i=0;i<3;i++)
		{
			num[i] = sc.nextInt();
			count++;
		}

		for(sorted=0;sorted<count;sorted++)
		{
			minimum = sorted;
			for(i=sorted+1;i<count;i++)
			{
				if(num[i]<num[minimum])
				{
					minimum = i;
				}
			}
			temp = num[minimum];
			num[minimum] = num[sorted];
			num[sorted] = temp;
		}

		for(i=0;i<count;i++)
		{
			System.out.printf("%d",num[i]);
			if(i<count-1)System.out.printf(" ");
		}
		System.out.printf("\n");
	}
}

Measured memory_bytes: 26100
#include <cstdio>

typedef long long i64;

const int N = 4000 + 10, MOD = 1000000007;

int n, m, k;

int f[N][N];

int main() {
  scanf("%d%d%d", &n, &m, &k);
  f[0][0] = 1;
  for (int i = 0; i < n + m; ++i) {
    for (int j = 0; j <= n + m; ++j) {
      (f[i + 1][j] += f[i][j]) %= MOD;
      (f[i + 1][j + k] -= f[i][j]) %= MOD;
    }
    for (int j = 0; j <= n + m; ++j) (f[i + 1][j] += f[i + 1][j - 1]) %= MOD;
  }
  int ans = 0;
  for (int i = 1; i <= n + m; ++i) {
    for (int x = m % (k - 1); x <= m && x <= i * (k - 1); x += k - 1) {
      if (!x) continue;
      int y = (k - 1) * i - x + 1;
      if (!(y <= n && y % (k - 1) == n % (k - 1))) continue;
      ans = ((i64)ans + f[i][x] - f[i - 1][x]) % MOD;
    }
  }
  printf("%d\n", (ans + MOD) % MOD);
  return 0;
}


Measured memory_bytes: 62848
#include<bits/stdc++.h>
using namespace std;
int combi(int n, int k) {
  if (n == k || k == 0){
    return 1;
  }else {
    return combi(n - 1, k - 1) + combi(n - 1, k);
  }
}

int main(){
  int N,M,sum=0;
  cin >> N >> M;
  if(N > 1){
  	sum = combi(N,2);
  }else{
  	sum = 0;
  }
  
  if(M > 1){
  	sum += combi(M,2);
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
from collections import deque
S = deque(list(input()))
Q = int(input())
t = 0
for i in range(Q):
    query = input().split()
    if int(query[0]) == 1:
        t += 1
    else:
        query[1] = int(query[1])
        if t % 2 == 1:
            if query[1] == 1:
                query[1] = 2
            else:
                query[1] = 1
        if query[1] == 1:
            S.appendleft(query[2])
        else:
            S.append(query[2])
if t % 2 == 1:
    S.reverse()
print("".join(S))


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

int main() {
	// your code goes here
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
	int n;
  cin>>n;
  cout<<(n-1)/2;
	
	
	return 0;
}


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

int main(){
    int n;
    ll d;
    cin >> n >> d;
    int ans = 0;
    for(int i = 0; i < n; i++){
        ll x, y;
        cin >> x >> y;
        if(x*x + y*y <= d*d) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3600
import java.util.*;
import java.io.*;
public class Main {
    public static void main(String[] args) throws Exception {
        InputStreamReader r = new InputStreamReader(System.in);
        int N = nextInt(r);
        int a[] = new int[N];
        int b[] = new int[N];
        int c[] = new int[N];
        for (int i = 0; i < N; i++) {
            a[i] = nextInt(r);
            b[i] = nextInt(r);
            c[i] = nextInt(r);
        }

        int sumA = 0;
        int sumB = 0;
        int sumC = 0;
        for (int i = 0; i < N; i++) {
            int tmpA = sumA;
            int tmpB = sumB;
            int tmpC = sumC;
            sumA = tmpB+a[i] > tmpC+a[i] ? tmpB+a[i] : tmpC+a[i];
            sumB = tmpA+b[i] > tmpC+b[i] ? tmpA+b[i] : tmpC+b[i];
            sumC = tmpA+c[i] > tmpB+c[i] ? tmpA+c[i] : tmpB+c[i];
        }
        int ans = Math.max(sumA, Math.max(sumB, sumC));
        System.out.println(ans);
    }

    public static String nextString(InputStreamReader r) throws Exception {
        String res = "";
        while (true) {
            int c = r.read();
            if (c == 32 || c == 10 || c == -1) {
                break;
            }
            res += (char)c;
        }
        return res;
    }

    public static int nextInt(InputStreamReader r) throws Exception {
        return Integer.parseInt(nextString(r));
    }

    public static long nextLong(InputStreamReader r) throws Exception {
        return Long.parseLong(nextString(r));
    }
}


Measured memory_bytes: 76352
#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 all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
template <class T>
void get_unique(vector<T>& x) {
    x.erase(unique(x.begin(), x.end()), x.end());
}
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (int i = 0; i < sz(v); i++) {
        os << v[i];
        if (i < sz(v) - 1) os << " ";
    }
    return os;
}
int main() {
    int n;
    cin >> n;
    vector<ll> x(n), y(n);
    rep(i, n) cin >> x[i] >> y[i];
    vector<ll> f0(n), f1(n);
    rep(i, n) f0[i] = x[i] - y[i];
    rep(i, n) f1[i] = x[i] + y[i];
    ll ans = 0;
    chmax(ans, *max_element(all(f0)) - *min_element(all(f0)));
    chmax(ans, *max_element(all(f1)) - *min_element(all(f1)));
    cout << ans << endl;
}

Measured memory_bytes: 9596
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, n) for (int i = (n); i >= 0; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 25;
const int MOD = 1e9+7;

struct UnionFind{
  vector<int> par;
  UnionFind(int N) : par(N) {
    rep(i,N) par[i] = i;
  }

  int root(int x) {
    if (par[x] == x) return x;
    return par[x] = root(par[x]);
  }
  void unite(int x, int y) {
    int rx = root(x), ry = root(y);
    if (rx == ry) return;

    par[rx] = ry;
  }
  bool same(int x, int y) {
    return root(x) == root(y);
  }
};

int n, m;
int main() {
  cin >> n >> m;
  vector<P> edge(m);
  rep(i,m) {
    int a,b; cin >> a >> b;
    edge[i] = {a-1,b-1};
  }

  int ans = 0;
  rep(i,m) {
    UnionFind uf(n);
    int a = edge[i].first, b = edge[i].second;
    rep(j,m) {
      if (j == i) continue;
      uf.unite(edge[j].first, edge[j].second);
    }
    if (!uf.same(a,b)) ans++;
  }

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

Measured memory_bytes: 3612
#include<iostream>
#include<string>

using namespace std;

int main(void) {
	int a, b, c;
	cin >> a >> b >> c;
	if (a == 7) {
		if ((b == 5) && (c == 5)) {
			cout << "YES" << endl;
		}
		else {
			cout << "NO" << endl;
		}
	}else if (b == 7) {
		if ((a == 5) && (c == 5)) {
			cout << "YES" << endl;
		}
		else {
			cout << "NO" << endl;
		}
	}
	else if (c == 7) {
		if ((a == 5) && (b == 5)) {
			cout << "YES" << endl;
		}
		else {
			cout << "NO" << endl;
		}
	}
	else {
		cout << "NO" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
def gcd(a,b):
    if not b:
        return a
    else:
        return gcd(b, a%b)

n = int(input())

ans = 0

for i in range(1,n-1):
    for j in range(i+1, n):
        tmp = gcd(i,j)
        for k in range(j+1, n + 1):
            ans += gcd(tmp,k) * 6

for i in range(1,n):
    for j in range(i+1,n+1):
        ans += 6*gcd(i,j)
# print(ans)
ans += (n*(n+1))//2

print(ans)

Measured memory_bytes: 9212