akhauriyash/Code-Regression huggingface dataset:
//Badwaper gg
#include<bits/stdc++.h>
#define inf 1e9
#define eps 1e-6
#define mp make_pair
#define pb push_back
#define re register ll
#define fr first
#define sd second
#define FOR(i,a,b) for(re i=a;i<=b;i++)
#define REP(i,a,b) for(re i=a;i>=b;i--)
#define lowbit(x) (x&(-x))
#define Z(x) (x>=mod?x-mod:x)
#define N 200010
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
inline ll read()
{
	char ch=getchar();
	ll s=0,w=1;
	while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){s=s*10+ch-'0';ch=getchar();}
	return s*w;
}
const int mod=1e9+7;
int fac[N],inv[N];
int h,w,a,b;
inline int C(int n,int m){return 1LL*fac[n]*inv[m]%mod*inv[n-m]%mod;}
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	h=read(),w=read(),a=read(),b=read();int Maxn=N-10;
	fac[0]=1;FOR(i,1,Maxn)fac[i]=1LL*fac[i-1]*i%mod;
	inv[0]=inv[1]=1;FOR(i,2,Maxn)inv[i]=1LL*(mod-mod/i)*inv[mod%i]%mod;
	FOR(i,2,Maxn)inv[i]=1LL*inv[i]*inv[i-1]%mod;
	int ans=0;
	FOR(i,b,w)
	{
//		cout<<"WTF:"<<i<<" "<<C(h-a+i-1,h-a-1)<<" "<<C(a-1+(w-i-1),a-1)<<endl;
		ans=Z(ans+1LL*C(h-a+i-1,h-a-1)*C(a-1+(w-i-1),a-1)%mod);
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 5296
n = gets.to_i
task = n
sum = 0
waru = 100000000

while task > 0 do
        sum  = sum + task / waru
        task = task % waru
        waru = waru / 10
end

#sum = sum + task

if n % sum == 0
        puts "Yes"
else
        puts "No"
end

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

int main() {
  int N;
  cin >> N;
  int d[110];
  for(int i=0;i < N;i++){
    cin >> d[i];
  }
  int counter;
  counter = 0;
  
  sort(d, d + N, greater<int>());
  
  for(int i=0;i < N-2;i++){
    for(int j=i+1;j < N-1;j++){
      for(int k=j+1;k < N;k++){
          if((d[k] + d[j] > d[i])&&(d[i]!=d[j])&&(d[j]!=d[k])){
            counter = counter +1;
          }
          else{
          }
        
      }
    }
  }
  cout << counter << endl;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1000000007;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  vector<ll> a(n);
  REP(i,n) cin >> a[i];
  ll sum = 0;
  REP(i,60){
    ll zc = 0, oc = 0;
    ll idsum = 0;
    REP(j,n){
      if(a[j]%2==0){
        zc++;
        zc = zc % MOD;
      }else{ 
        oc++;
        oc = oc%MOD;
      }
      a[j]/=2;
    }
    idsum = zc*oc % MOD * ((1LL<<i) % MOD);
    sum += idsum % MOD;
    sum = sum % MOD;
  }
  cout << sum << '\n';
  return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define _USE_MATH_DEFINES
using namespace std;
// 型シノニム
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
// 定数
constexpr ll INF   = 1e16;
constexpr ll INM   = 114514;
constexpr ll MOD   = 1e9 + 7;
constexpr ld EPS   = 1e-12;
constexpr ll dx[4] = {1, 0, -1, 0};
constexpr ll dy[4] = {0, 1, 0, -1};
// 便利関数
void IOS() { ios::sync_with_stdio(false), cin.tie(0); }
template <typename T>
void dump(T x) { cout << x << endl; }
void dumpf(ld x, ll t) { cout << setprecision(t) << fixed << x << endl; }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}
inline ll mod(ll a, ll mod) {
	if (a > 0) return a % mod;
	if (a % mod == 0) return 0;
	ll x = -a / mod + 1;
	a += x * mod;
	return a % mod;
}
ll powm(ll a, ll b, ll m) {
	if (b == 0) {
		return 1;
	} else if (b % 2 == 0) {
		ll d = powm(a, b / 2, m);
		return (d * d) % m;
	} else {
		return (powm(a, b - 1, m) * a) % m;
	}
}
// 本体

int main() {
	IOS();
	char x;
	cin >> x;
	if(isupper(x)) {
		dump("A");
	}else {
		dump("a");
	}
}

Measured memory_bytes: 3692
import java.util.*;
 
public class Main {
    public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		long x = sc.nextLong();
		long yokin = 100L;
		for(int i=1; i<3761; i++){
			yokin = yokin+(yokin/100);
			if(yokin >= x) {
				System.out.println(i);
				break;
			}
		}
	}
}


Measured memory_bytes: 27048
#include <iostream>
#include <algorithm>

#define MAX 10000
#define NIL -1

using namespace std;


struct Node {
    int partent, left, right;
};

Node T[MAX];
int n, D[MAX], H[MAX];

void setDepth(int u, int d) {
    if (u == NIL) return;

    D[u] = d;

    setDepth(T[u].left, d + 1);
    setDepth(T[u].right, d + 1);
}

int setHight(int u) {
    int h1 = 0, h2 = 0;
    if (T[u].left != NIL) {
        h1 = setHight(T[u].left) + 1;
    }
    if (T[u].right != NIL) {
        h2 = setHight(T[u].right) + 1;
    }
    return H[u] = max(h1, h2);
}


//返回节点u的兄弟节点

int getBrother(int u) {
    if (T[u].partent == NIL) {
        return NIL;
    }
    if (T[T[u].partent].left != u && T[T[u].partent].left != NIL) {
        return T[T[u].partent].left;
    }
    if (T[T[u].partent].right != u && T[T[u].partent].right != NIL) {
        return T[T[u].partent].right;
    }

    return NIL;

}

void print(int u) {
    cout << "node " << u << ": " << "parent = "<<T[u].partent<<", "<<"sibling = "<<getBrother(u)<<", ";
    int deg=0;
    if(T[u].left!=NIL)
        deg++;
    if(T[u].right!=NIL)
        deg++;
    cout<<"degree = "<<deg<<", "<<"depth = "<<D[u]<<", height = "<<H[u]<<", ";
    if(T[u].partent==NIL){
        cout<<"root";
    }else if(T[u].left==NIL&&T[u].right==NIL){
        cout<<"leaf";
    }else{
        cout<<"internal node";
    }
    cout<<endl;
}

int main(){
    int v,l,r,root=0;
    cin>>n;
    for(int i=0;i<n;i++){
        T[i].partent=NIL;
    }
    for(int i=0;i<n;i++){
        cin>>v>>l>>r;
        T[v].left=l;
        T[v].right=r;
        if(l!=NIL) T[l].partent=v;
        if(r!=NIL) T[r].partent=v;
    }

    for(int i=0;i<n;i++){
        if(T[i].partent==NIL)
            root=i;
    }

    setDepth(root,0);
    setHight(root);

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


Measured memory_bytes: 3088
import copy
h,w,aa=map(int,input().split())
s=[input() for _ in range(h)]
t=copy.copy(s)
cnt=0
hs=['.' for _ in range(h)]
hw=['.' for _ in range(w)]
for i in range(2**h):
    b=bin(i)[2:]
    if len(b)<h:
        b=str("0"*(h-len(b)))+b
    # print(b)
    for j in range(2**w):
        c=bin(j)[2:]
        if len(c)<w:
            c=str("0"*(w-len(c)))+c
        # print(c)
        t=copy.copy(s)
        # print(t,s)
        for k in range(len(b)):


            if b[k]=="1":
                t[k]=hw
        # print(t,b)

        o=[]
        t= [list(x) for x in zip(*t)]
        # print(t)
        for l in range(len(c)):
            # print(c,t)
            if c[l]=="1":
                t[l]=hs
        for m in range(len(t)):
            o.extend(t[m])
        # print(o,b,c)

        on=o.count("#")
        if on==aa:
            cnt+=1
            # print("$")










print(cnt)

Measured memory_bytes: 9252
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;
import std.container;

alias sread = () => readln.chomp();
ulong MOD = 1_000_000_007;
ulong INF = 1_000_000_000_000;
alias Goods = Tuple!(long, "w", long, "v");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

auto dp = new long[][](110, 100_100);
void main()
{
    long N, W;
    scan(N, W);
    auto goods = new Goods[](N);
    foreach (ref e; dp)
        e[] = INF;

    foreach (i; iota(N))
    {
        long w, v;
        scan(w, v);
        goods[i] = Goods(w, v);
    }
    foreach (i; iota(N))
    {
        foreach (j; iota(100_100))
        {
            dp[i + 1][j] = min(dp[i][j], dp[i + 1][j]);
            if (j == 0)
                if (goods[i].w <= W)
                    dp[i + 1][j + goods[i].v] = goods[i].w;
            if (dp[i][j] != INF)
                if (dp[i][j] + goods[i].w <= W)
                    dp[i + 1][j + goods[i].v] = dp[i][j] + goods[i].w;
        }
        // dp[i + 1].take(20).writeln();
    }
    dp[N].maxidx.writeln();
}

auto maxidx(T)(T a)
{
    long ret;
    foreach (i, e; a)
        if (e != INF)
            ret = i;

    return ret;
}


Measured memory_bytes: 86268
s,t=input(),input()
S,T=len(s),len(t)

DP=[[0 for _ in range(T+1)] for _ in range(S+1)]
for i in range(1,S+1):
    for j in range(1,T+1):
        if s[i-1]==t[j-1]:DP[i][j]=DP[i-1][j-1]+1
        else:DP[i][j]=max(DP[i-1][j],DP[i][j-1])

ans=""
x,y=S,T
while DP[x][y]!=0:
    if DP[x][y]==DP[x-1][y]:x -=1
    elif DP[x][y]==DP[x][y-1]:y -=1
    else:
        ans +=s[x-1]
        x -=1
        y -=1

print(ans[::-1])

Measured memory_bytes: 119772
#include <stdlib.h>
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <bitset>
#include <stdio.h>

using namespace std;

typedef long long int ll;
typedef vector<int> vi;
typedef vector<string> vs;

#define MAX(a,b) ((a)>(b) ? (a) : (b))
#define MIN(a,b) ((a)<(b) ? (a) : (b))
#define ABS(a) ((a)>0 ? (a) : (a * -1))



int main(){
	int n, m;
	cin >> n;
	vs s(n);
	char buf, ans;
	int a[50][30];
	for (int i = 0; i < 50; i++) {
		for (int j = 0; j < 30; j++) {
			a[i][j] = 0;
		}
	}

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

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < s[i].length(); j++) {
			buf = s[i][j];
			a[i][buf-97]++;
		}
	}

	for (int i = 0; i < 30; i++) {
		m = 100;
		for (int j = 0; j < n; j++) {
			if ((m > a[j][i])) m = a[j][i];
		}
		if (m == 100) m = 0;

		for (int k = 0; k < m; k++) {
			ans = i + 97;
			cout << ans;
		}
	}

	cout << endl;

}


Measured memory_bytes: 764
s = list(input())
n = int(input())
head = []
tail = []

cnt = 0
for _ in range(n):
    li = list(input().split())
    if li[0] == '1':
        head, tail = tail, head
        cnt += 1
    else:
        if li[1] == '1':
            head += li[2]
        else:
            tail += li[2]

if cnt % 2 != 0:
    s = s[::-1]
    
ans = head[::-1] + s + tail
print(*ans , sep='')

Measured memory_bytes: 14056
#include <iostream>
#include <vector>
#include <sstream>
#include <map>
#include <set>
using namespace std;
int point(vector<int>& v)
{
  int id = 0,pt = 0;
  for(int i=0; i<9; i++){
    if(v[id] == 10){
      pt += 10 + v[id+1] + v[id+2];
      id++;
    }else if(v[id] + v[id+1] == 10){
      pt += 10 + v[id+2];
      id += 2;
    }else{
      pt += v[id] + v[id+1];
      id += 2;
    }
  }
  while(id < v.size()){
    pt += v[id++];
  }
  return pt;
}
int main()
{
  for(;;){
    int n;
    cin >> n;
    if(n==0) break;
    map<int,set<int> > ma;
    for(int i=0; i<n; i++){
      int num;
      cin >> num;
      string s;
      getline(cin,s);
      stringstream str(s);
      vector<int> v;
      while(!str.eof()){
        int j;
        str >> j;
        v.push_back(j);
        str.ignore();
      }
      ma[point(v)].insert(num);
    }
    for(map<int,set<int> >::reverse_iterator r=ma.rbegin(); r!=ma.rend(); r++){
      int pt = (*r).first;
      set<int> s = (*r).second;
      for(set<int>::iterator it=s.begin(); it!=s.end(); it++){
        cout << *it << " " << pt << endl;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 1252
/*
#pragma GCC optimize("O2")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2,sse,sse2,fma,tune=native")
//*/
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int  ,int > pii;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll maxn  = 2e5+100;
const ll mod =1e9+7;
const ld PI = acos((ld)-1);

#define pb push_back
#define endl '\n'
#define dokme(x) return(cout << x , 0);
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ms(x , y) memset(x , y , sizeof x);
#define file_init freopen("input.txt", "r+", stdin); freopen("output.txt", "w+", stdout);
ll pw(ll a, ll b, ll md = mod){ll res = 1;while(b){if(b&1){res=(a*res)%md;}a=(a*a)%md;b>>=1;}return(res);}

string s , ans;
int dp[maxn][27];

int32_t main(){
    migmig
    cin >> s;
    int n = s.size();
    for(int i = 0 ; i < 26 ; i ++)
        dp[n][i] = 1;
    for(int i = n-1 ; i >= 0 ; i --){
        int mn = n;
        for(int j = 0 ; j < 26 ; j ++) mn = min(mn , dp[i+1][j]);
        for(int j = 0 ; j < 26 ; j ++) dp[i][j] = min(mn + 1 , dp[i+1][j]);
        if(mn == dp[i + 1][s[i] - 'a'])dp[i][s[i] - 'a'] = mn + 1;
    }
    for(int i = 0 ; i <= n; i ++){
        int mn = n, anss = 0;
        for(int j = 0 ; j < 26 ; j ++)
            if(dp[i][j] < mn)
                mn = dp[i][j] , anss = j;
        ans += char(anss + 'a');
        if(mn == 1)
            break;
        while(s[i]!=char(anss + 'a'))i++;
    }
    cout << ans;
    return(0);
}

Measured memory_bytes: 24844
class Card:
    def __init__(self, suit, value):
        self.suit = suit
        self.value = value
    
def selection(ls):
    for i in range(len(ls)):
        minj = i
        
        for j in range(i, len(ls)):
            if ls[j].value < ls[minj].value:
                minj = j
        ls[i], ls[minj] = ls[minj], ls[i]

def bubblesort(ls):
    for i in range(1, len(ls)):
        for j in reversed(range(i, len(ls))):
            if ls[j].value < ls[j-1].value:
                ls[j], ls[j-1] = ls[j-1], ls[j]

def isStable(ls1, ls2):
    if ls1 == ls2:
        print("Stable")
    else:
        print("Not stable")

def printcards(cards):
    for x in range(len(cards)):
        if x == len(cards) - 1:
            print(cards[x].suit + cards[x].value)
        else:
            print(cards[x].suit + cards[x].value, ' ', sep='', end='')

def main():
    N = int(input().rstrip())

    cards = []
    for card in list(input().split(' ')):
        cards.append(Card(card[0], card[1]))

    a = [x for x in cards]
    b = [x for x in cards]
    

    bubblesort(a)
    selection(b)
    
    printcards(a)
    print("Stable")

    printcards(b)
    isStable(a,b)
    
if __name__ == '__main__':
    main()

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

typedef long long int ll;
typedef vector<int> vi;
typedef set<int> si;
typedef vector<ll> vll;

#define pvec(v) for(auto e: v) cout << e << " ";
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define rep(i, a, b) for(int i = a; i<b; ++i)
#define pb push_back
#define INF 1000000000
#define MOD 1000000007

vector<ll> primes;
void sieve(int n){
	bool p[n+5];
	rep(i, 0, n+5) p[i] = true;
	p[0] = p[1] = false;

	for(int i = 2; i*i <= n; ++i){
		if(p[i]){
			for(int j = 2*i; j<=n; j+=i)
				p[j] = false;
		}
	}

	rep(i, 2, n+1)
		if(p[i])
			primes.push_back((ll)i);
}

ll power(ll x, ll y, ll p = MOD)  {  
    ll res = 1LL;
    x = x % p;
    if (x == 0) return 0; 
  
    while (y > 0){         
        if (y & 1)  
            res = (res*x) % p;  
        y = y>>1;
        x = (x*x) % p;  
    }  
    return res;  
} 

int main(){
	IO
	//sieve(100000);

	ll n, k;
	cin >> n >> k;

	ll ans = 0LL, otherThanOne = power(k, n), term;
	ll dp[k+2] = {0};
	for(int i = k; i>=1; --i){
		dp[i] = power(k*1LL/i, n);
		term = 0LL;
		for(int j = 2*i; j<=k; j+=i){
			term = (term + dp[j]%MOD)%MOD;
		}
		dp[i] = (dp[i] - term)%MOD;
	}

	ll sum = 0LL;
	rep(i, 1, k+1){
		sum = (sum + i*dp[i]%MOD)%MOD;
		//cout << dp[i] << endl;
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 4428
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<deque>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const int INF = 1e11;
const long double PI = (acos(-1));


signed main() {
	int N;
	cin >> N;
	if (N == 0) {
		cout << 0;
		return 0;
	}
	vector<int>ans;
	while (N != 0) {
		if (N % 2) {
			ans.push_back(1);
			N--;
			N /= -2;
		}
		else {
			ans.push_back(0);
			N /= -2;
		}
	}
	rep(i, ans.size())cout << ans[ans.size() - 1 - i];
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  
	int a,b,i,c;
	char op;
	

	for(i=1;op!='?';i++){
	cin>>a>>op>>b;
		if(op!='?'){
			if(op=='+'){
				c=a+b;
				cout<<c<<endl;
			}
			if(op=='-'){
				c=a-b;
				cout<<c<<endl;
			}
			if(op=='*'){
				c=a*b;
				cout<<c<<endl;
			}
			if(op=='/'){
				c=a/b;
				cout<<c<<endl;
			}
		}	
	}
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdlib>
using namespace std;
typedef long long unsigned int ll;
 
int main() {
 
  int a,b,c;
  cin >> c;
  cin >>a;
  cin >>b;
  
  if(abs(c-a)<abs(c-b)){
    cout << "A" <<endl;
  }else{
	cout << "B" <<endl;
  }
   return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		String t = sc.next();
		int a = sc.nextInt();
		int b = sc.nextInt();
		String u = sc.next();
		
		if (u.equals(s)) {
			a--;
		} else {
			b--;
		}
		
		System.out.printf("%d %d\n", a, b);
		
		sc.close();
	}
}


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

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

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

	int A, B, C, X;
	cin >> A >> B >> C >> X;

	int ans = 0;

	for (int i = 0;i <= A;i++){
		if(i*500 > X) break;
		for (int j = 0;j <= B;j++){
			if(i*500+j*100 > X) break;
			if(X-i*500-j*100 <= C*50) ans++;
		}
	}

	cout << ans << endl;

	return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=1000000007;
constexpr double eps=1e-8;
const double pi=acos(-1);
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int Random(int mi,int ma){
    random_device rnd;
    mt19937 mt(rnd());//32bit
    //[mi,ma]
    uniform_int_distribution<int>engine(mi,ma);
    return engine(mt);
}
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
vector<int>kaijo,invkaijo;
void init_fact(int n){
    kaijo.resize(n+1);
    invkaijo.resize(n+1);
    kaijo[0]=1;
    for(int i=1;i<=n;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
    rep(i,n+1)invkaijo[i]=modpow(kaijo[i],mod-2);
}
int comb(int a,int b){
    if(a<b)return 0;
    if(a<0||b<0)return 0;
    return kaijo[a]*invkaijo[a-b]%mod*invkaijo[b]%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}

signed main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int n;
    map<string,int>mp;
    cin>>n;
    rep(i,n){
        string s;
        cin>>s;
        mp[s]++;
    }
    cout<<"AC x "<<mp["AC"]<<endl;
    cout<<"WA x "<<mp["WA"]<<endl;
    cout<<"TLE x "<<mp["TLE"]<<endl;
    cout<<"RE x "<<mp["RE"]<<endl;
    return 0;
}

Measured memory_bytes: 3664
#include <algorithm>
#include <climits>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map> //pair is also included in this library
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define REP(i, s, n) for(int i = (int)(s); i < (int)(n); i++)
#define fst first
#define snd second
#define MP make_pair //incase c++11 or later is not available

using namespace std;

typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PII;

//prefer define statement
//for reason that const int ver. of INF will raise a silly warning (unused variable)
#define INF (INT_MAX/3)
#define LIM_INF (INT_MAX)
//const int INF = INT_MAX/3;

/*------------------------------------------------------------------------------*/

int main(){
  VI v(3);
  REP(i, 0, 3){
    cin >> v[i];
  }

  sort(v.begin(), v.end(), greater<int>());
  if(v[0] == v[1] + v[2]){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;

class AtCoderCS {
    static void Main(string[] args) {
        int N = int.Parse(Console.ReadLine());
        IEnumerable<string> S = Enumerable.Range(0, N).Select(_ => Console.ReadLine());

        Console.WriteLine(S.GroupBy(i => i).Count());
    }
}

Measured memory_bytes: 60452
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <math.h>
#include <complex>
#include <cassert>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> p;
typedef complex<double> com;
const int mod = 1e9 + 7;
const int MOD = 998244353;
const ll INF = 1e18;


int main() {
	int n, m, d; cin >> n >> m >> d;
	vector<p> a(n*m);
	rep(i, 0, n) {
		rep(j, 0, m) {
			int p; cin >> p;
			p--; a[p] = { i,j };
		}
	}
	vector<int> b(n*m,0);
	rep(i, 0, d) {
		b[i] = a[i].first + a[i].second;
	}
	rep(i, d, n* m) {
		b[i] = b[i-d] + abs(a[i].first - a[i-d].first) + abs(a[i].second - a[i-d].second);
	}
	int q; cin >> q;
	rep(i, 0, q) {
		int p1, p2; cin >> p1 >> p2;
		p1--; p2--;
		cout << b[p2]-b[p1] << endl;
	}
	return 0;
}

Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#define local
//if you find any bug in my code, please tell me.
const int N=45,maxn=410,INF=0x3f3f3f3f;
int dp[N][maxn][maxn],a[N],b[N],c[N];
int main()
{
#ifdef local
    freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
#endif
    int n,ma,mb,i,j,k,ans=INF;
    cin>>n>>ma>>mb;
    for(i=0; i<n; i++) scanf("%d%d%d",&a[i],&b[i],&c[i]);
    for(i=0; i<=n; i++)
        for(j=0; j<=maxn; j++)
            for(k=0; k<=maxn; k++)
                dp[i][j][k]=INF;
    dp[0][0][0]=0;
    for(i=0; i<n; i++)
        for(j=0; j<=maxn; j++)
            for(k=0; k<=maxn; k++)
            {
                if(dp[i][j][k]==INF) continue;
                dp[i+1][j][k]=min(dp[i+1][j][k],dp[i][j][k]);
                dp[i+1][j+a[i]][k+b[i]]=min(dp[i+1][j+a[i]][k+b[i]],dp[i][j][k]+c[i]);
            }
    for(j=1; j<=maxn; j++)
        for(k=1; k<=maxn; k++)
        {
            if(dp[n][j][k]==INF) continue;
            else if(ma*k==mb*j) ans=min(ans,dp[n][j][k]);
        }
    if(ans==INF) cout<<-1<<endl;
    else cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 28928
import java.util.Scanner;

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

        int count = 0;
        for (int i = 0; i < 3; i++) {
            if (S.charAt(i) == T.charAt(i)) {
                count++;
            }
        }

        System.out.println(count);
    }
}

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

int main() {
    int N;
    cin >> N;
    int C[N], S[N], F[N];
    for (int i=0; i<N-1; i++){
        cin >> C[i] >> S[i] >> F[i];
    }

    for (int i=0; i<N; i++){
        int t = 0;
        for (int j=i; j<N-1; j++){
            if (t < S[j]) {
                t = S[j];
            } else if (t%F[j] != 0) {
                t += F[j] - t%F[j];
            }
            t += C[j];
            // cout << "i=" << i << " j=" << j << " t=" << t << endl;
        }
        cout << t << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
        int N,Q;
        int s[10000],t[500];
        cin >> N;
        for(int i=0 ; i<N ; i++ )
                cin >> s[i];
        cin >> Q;
        for(int i=0 ; i<Q  ; i++ )
                cin >> t[i];
        int counter=0;
        for(int i=0 ; i<Q ; i++ ){
                s[N]=t[i];
                int l=0;
                while(t[i]!=s[l]){
                        l++;
                }
                if(l<N)
                        counter++;
        }
        cout << counter << endl;
        return 0;
}

Measured memory_bytes: 3128
/*
lakshaygpt28
Lakshay Gupta
*/

#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;

using ll = long long;
using db = double;
using pii = pair < int, int >;
using pll = pair < ll, ll >;
using vll = vector < ll >;

template < typename T > using OrderedSet = tree < T, null_type, less < T >, rb_tree_tag, tree_order_statistics_node_update >;
template < typename T > using MinPriorityQueue = priority_queue < T, vector < T >, greater < T > >;


#ifndef ONLINE_JUDGE
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1) {
    cerr << name << " : " << arg1 << std :: endl;
}
template < typename Arg1, typename... Args >
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | ";
    __f(comma + 1, args...);
}
#else
#define debug(...)
#endif

#define fast_io() ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define eb emplace_back
#define mp make_pair
#define pb push_back
#define mt make_tuple
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

const db PI = acos(-1);
const ll LINF = LLONG_MAX;
const int INF = INT_MAX, MOD = 1e9 + 7, N = 1e5 + 10;

int main() {
    fast_io();
    ll a, b;
    cin >> a >> b;
    if ((a + b) & 1) {
        cout << "IMPOSSIBLE\n";
    } else {
        cout << (a + b) / 2;
    }
    return 0;
}


Measured memory_bytes: 256
/*
 * main.c
 *
 *  Created on: 2019/07/21
 *      Author: family
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main()
{
	char S[10] = {0};
	scanf("%s", S);
	if (S[0] == 'S') {
		printf("Cloudy\n");
	} else if (S[0] == 'C') {
		printf("Rainy\n");
	} else {
		printf("Sunny\n");
	}
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ULL;
typedef long long LL;
#define FOR(i, a, b) for(LL i=(LL)(a);i<(LL)(b);i++)
#define REP(i,x) for(LL i=0;i<(LL)(x);i++)

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    // cout << fixed << setprecision(10);
    LL k, n;
    cin >> k >> n;
    vector<LL> a_v;

    LL before = 0, max = 0;
    REP(i, n)
    {
        LL temp;
        cin >> temp;
        a_v.push_back(temp);
        if(i>0)
        {
            if((temp - before) > max)
            {
                max = temp - before;
            }
        }
        before = temp;
    }

    if(max < (k-a_v.at(n-1) + a_v.at(0)))
    {
        max = (k-a_v.at(n-1) + a_v.at(0));
    }

    cout << k - max << endl;
    return 0;
}

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

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() //sortなどの引数を省略したい
#define SIZE(x) ll(x.size()) //sizeをsize_tからllに直しておく
#define LEN(x) ll(x.length()) //lengthをsize_tからllに直しておく
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB emplace_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define Umap unordered_map
#define Uset unordered_set

int main(){
    ll n;
    cin >> n;
    ll all = 1, no_one_num = 1, no_two_num = 1;
    REP(i, n){
        all *= 10;
        all %= MOD;
        no_one_num *= 9;
        no_one_num %= MOD;
        no_two_num *= 8;
        no_two_num %= MOD;
    }
    ll ans = all;
    ans %= MOD;
    ans += no_two_num;
    ans %= MOD;
    ans -= 2 * no_one_num;
    ans %= MOD;
    while(ans < 0) ans += MOD;
    cout << ans;
    return 0;
}

Measured memory_bytes: 3632
#include <stdio.h>

#define NOT_FOUND -1

int binarysearch(int);

int S[100000],T[50000],n1,n2,kakunin[10000];

int main(){

  int i,j,count = 0;

  scanf("%d",&n1);

  for(i = 0; i < n1;i++) scanf("%d",&S[i]);

  scanf("%d",&n2);

  for(i = 0; i < n2 ; i++) scanf("%d",&T[i]);


  for(j = 0;j < n2;j++){
    i = binarysearch(T[j]);
    if(i != NOT_FOUND) count++;
  }


  printf("%d\n",count);

}

int binarysearch(int key){
  int left = 0,right = n1,mid;

  while(left < right){
    mid = (right + left) / 2;

    if(S[mid] == key) return mid;

    else if(key < S[mid]) right = mid;

    else left = mid + 1;

  }
  return NOT_FOUND;
}


Measured memory_bytes: 2292
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <tuple>
#include <utility>
using namespace std;

int main() {
    vector<tuple<long long int, long long int, long long int>> v;
    long long int n, m, p, y;
    long long int ans;
    cin >> n >> m;
    for(int i = 0; i < m; ++i) {
        cin >> p >> y;
        v.emplace_back(p, y, i);
    }
    sort(v.begin(), v.end());
    int c = 1, s = get<0>(v[0]);
    for(int i = 0; i < m; ++i) {
        if(s == get<0>(v[i])) {
            get<1>(v[i]) = c;
        } else {
            c = 1;
            s = get<0>(v[i]);
            get<1>(v[i]) = c;
        }
        swap(get<0>(v[i]), get<2>(v[i]));
        c++;
    }
    sort(v.begin(), v.end());
    for(int i = 0; i < m; ++i) {
        ans = get<2>(v[i])*1000000 + get<1>(v[i]);
        printf("%012lld\n", ans);
    }
}


Measured memory_bytes: 4852
import std.conv, std.stdio, std.string;
import std.algorithm, std.array, std.bigint, std.container, std.math, std.range, std.regex, std.typecons;
import core.bitop, core.thread;

class EOFException : Throwable { this() { super("EOF"); } }
string[] tokens;
string readToken() { for (; tokens.empty; ) { if (stdin.eof) throw new EOFException; tokens = readln.split; } auto token = tokens[0]; tokens.popFront; return token; }
int readInt() { return readToken().to!int; }
long readLong() { return readToken().to!long; }
real readReal() { return readToken().to!real; }

void chmin(T)(ref T t, in T f) { if (t > f) t = f; }
void chmax(T)(ref T t, in T f) { if (t < f) t = f; }

int binarySearch(T)(in T[] as, in bool delegate(T) test) { int low = -1, upp = cast(int)(as.length); for (; low + 1 < upp; ) { int mid = (low + upp) >> 1; (test(as[mid]) ? low : upp) = mid; } return upp; }
int lowerBound(T)(in T[] as, in T val) { return as.binarySearch((T a) => (a < val)); }
int upperBound(T)(in T[] as, in T val) { return as.binarySearch((T a) => (a <= val)); }


int N;
int[] A;

void main() {
  try {
    for (; ; ) {
      N = readInt();
      A = new int[N];
      foreach (i; 0 .. N) {
        A[i] = readInt();
      }
      const C3 = A.count(3);
      const C2 = A.count(2);
      const C1 = A.count(1);
      auto dp = new real[][][](N + 1, N + 1, N + 1);
      dp[0][0][0] = 0.0;
      foreach (x3; 0 .. N + 1) foreach (x2; 0 .. N + 1) foreach (x1; 0 .. N + 1) {
        if (0 < x3 + x2 + x1 && x3 + x2 + x1 <= N) {
          real nmr = 0.0;
          if (x3 > 0) nmr += (x3 / cast(real)(N)) * dp[x3 - 1][x2 + 1][x1];
          if (x2 > 0) nmr += (x2 / cast(real)(N)) * dp[x3][x2 - 1][x1 + 1];
          if (x1 > 0) nmr += (x1 / cast(real)(N)) * dp[x3][x2][x1 - 1];
          dp[x3][x2][x1] = (1.0 + nmr) / ((x3 + x2 + x1) / cast(real)(N));
        }
      }
      const ans = dp[A.count(3)][A.count(2)][A.count(1)];
      writefln("%.10f", ans);
    }
  } catch (EOFException e) {
  }
}


Measured memory_bytes: 729852
import sys

readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


def main():
    N = int(readline())
    S = list(map(lambda x: x.decode("UTF-8"), readlines()))
    S = list(map(lambda x: x.rstrip('\n'), S))
    march = list("MARCH")

    cnt = [0] * 5
    for i in range(N):
        for j in range(5):
            if S[i][0] == march[j]:
                cnt[j] += 1

    ans = 0

    if N < 3:
        print(0)
    else:
        for i in range(3):
            for j in range(i+1, 4):
                for k in range(j+1, 5):
                    ans += cnt[i] * cnt[j] * cnt[k]

        print(ans)


main()


Measured memory_bytes: 16532
#include<stdio.h>
int main(){

  int a,b,c,i,ans;
  scanf("%d %d %d", &a, &b, &c);

  ans = 0;
  
  for ( i = a ; i <= b ; i++ ){
    if ( c % i == 0 ) ans++;
  }

  printf("%d\n", ans);

  return 0;

}

Measured memory_bytes: 596
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstdio>
#define ll long long
#define INF 1e+9
#define MOD 1000000007
using namespace std;


int main(){
    int N;
    cin >> N;
    for(int i=2; i<=55555 && N>0; i++){
        int prime=1;
        for(int k=2; k*k<=i; k++){
            if(i%k==0){
                prime=0;
                break;
            }
        }
        if(prime==0){
            continue;
        }
        
        if(i%5==2){
            cout<<i;
            N--;
            if(N>0){
                cout<<" ";
            }else{
                cout<<endl;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <unordered_map> 
#include <unordered_set>
#include <functional>

using namespace std;

typedef pair<long long int, long long int> P;
typedef tuple<int, int, int> T;

long long int INF = 1e18;
long long int MOD = 1e9 + 7;

int const TREE_SIZE = (1 << 20);

class SegTree{
	public:
	// コンストラクタ
	SegTree(std::function<long long int(long long int, long long int)> monoidFunc_, long long int invalidValue_){
		monoidFunc = monoidFunc_;
		invalidValue = invalidValue_;
	}
	// 値の初期化
	void init(long long int initValue){
		for(int i = 0; i < TREE_SIZE; i++){
			segTree[i] = initValue;
		}
	}
	// a番目(0-indexed)をwに変更する O(log N)
	void change(int a, long long int w){
		change_(a + 1, w);
	}
	// 区間 [a, b] (0-indexed)の値を求める O(log N)
	long long int query(int a, int b){
		return query_(a + 1, b + 2, 1, 0, TREE_SIZE / 2);
	}
	private:
	function<long long int(long long int, long long int)> monoidFunc;
	long long int invalidValue;
	long long int segTree[TREE_SIZE]; // 1-indexed

	// a番目をwに変更する O(log N)
	void change_(int a, long long int w){
		a += TREE_SIZE / 2;
		segTree[a] = w;
		for(int x = a / 2; x > 0; x /= 2){
			segTree[x] = monoidFunc(segTree[2 * x], segTree[2 * x + 1]);
		}
	}
	// 区間 [a, b) の値を求める O(log N)
	// query(a, b, 1, 0, TREE_SIZE / 2) のように呼ぶ
	long long int query_(int a, int b, int index, int l, int r){
		if(r <= a || b <= l){
			return invalidValue;
		}
		if(a <= l && r <= b){
			return segTree[index];
		}
		return monoidFunc(query_(a, b, index * 2, l, (l + r) / 2), query_(a, b, index * 2 + 1, (l + r) / 2, r));
	}
};

long long int func(long long int a, long long int b){
	return a | b;
}
SegTree segTree(func, 0);

int main(){
	int N;
	cin >> N;
	segTree.init(0);
	string S;
	cin >> S;
	for(int i = 0; i < N; i++){
		segTree.change(i, 1LL << (S[i] - 'a'));
	}
	int Q;
	cin >> Q;
	for(int loop = 0; loop < Q; loop++){
		int tp;
		cin >> tp;
		if(tp == 1){
			int pos;
			char c;
			cin >> pos >> c;
			segTree.change(pos - 1, 1LL << (c - 'a'));
		}else{
			int l, r;
			cin >> l >> r;
			long long int ret = segTree.query(l - 1, r - 1);
			int ans = 0;
			for(int i = 0; i < 30; i++){
				if(ret & (1 << i)){
					ans += 1;
				}
			}
			cout << ans << endl;
		}
	}
	return 0;
}

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

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0LL,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,n) RFOR(i,0LL,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define COUNT(a,x,y) upper_bound(all(a), y) - lower_bound(all(a), x)
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end())
#define SUM(a) accumulate(all(a),0LL)
#define scan(x) scanf("%lld",&x)
#define print(x) printf("%lld\n",x)
#define print2(x) printf("%lld ",x)
#define pb push_back
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
const ll inf = 2222222222222222222LL;
const ll mod = 1000000007LL;

ll n = 0, m = 0, ans = 0, cnt = 0, tmp = 0, ma = -inf, mi = inf, cur = 0;
string s;
bool ok = true, flag = false;
ll dx[5] = { 1,-1,0,0,0 }, dy[5] = { 0,0,1,-1,0 };
ll ddx[9] = { 1,-1,0,0,1,1,-1,-1,0 }, ddy[9] = { 0,0,1,-1,1,-1,1,-1,0 };
#pragma endregion
#define MAX 333333


int main(void) {

  cin >> n >> m;
  vll a(n);
  rep(i, n) scan(a[i]);
  sort(all(a));
  
  rep(i, n) {
	m -= a[i];
	if (m >= 0) ans++;
  }
  if (m > 0) ans--;
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using intl = long long;
using itnl = long long;
using itn = int;
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define rrep(i, n) for(intl i = (intl)(n) - 1; i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define rrepi(i, a, b) for(intl i = (intl)(a); i > (intl)(b); i--)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define cin(i, a) rep(i, alength(a))cin >> a[i]
#define ccin(i, j, a) rep(i, alength(a))rep(j, alength(a[i]))cin >> a[i][j]
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl
#define sqrt sqrtl
#define itn int
#define double ld
#define pb push_back
#define mp make_pair
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld eps = 1.0e-14;//-9
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}
intl kai(intl k){
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl gcd(intl a, intl b){
    if(!b)return a;
    return gcd(b, a % b);
}
intl lcm(intl a,intl b){
    return a / gcd(a, b) * b;
}
intl digit10(intl a){
    intl b = 0;
    do{
        a /= 10;
        b++;
    }while(a);
    return b;
}
signed main(){
    cout << fixed << setprecision(10);
    intl n,m;
    cin >> n;
    intl a[n];
    cin(i,a);
    sort(a,a+n);
    cout << a[n-1] - a[0] << endl;
    return 0;
}

Measured memory_bytes: 764
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <cmath>
#include <tuple>
#include <bitset>
#include <utility>
#include <climits>
#include <iomanip>

#define push emplace_back
#define each(i, x) for (auto i=0; i < x; i++)
using ull = unsigned long long;
constexpr auto mod = 1000000007;
constexpr auto INF = ULLONG_MAX;

using namespace std;
template <typename T> inline void dump(const T& x) { cout << "[" << x << "]" << endl; }
template <typename T> inline void dump(const vector<T>& x) { for (const auto v : x) { cout << v << " "; } cout << endl; }
template <typename T> inline void sort_asc(vector<T>& x) { std::sort(x.begin(), x.end()); }
template <typename T> inline void sort_desc(vector<T>& x) { std::sort(x.begin(), x.end(), greater<T>()); }
template <typename T> inline T max_value(vector<T>& x) { return *max_element(x.begin(), x.end()); }
template <typename T> inline T min_value(vector<T>& x) { return *min_element(x.begin(), x.end()); }
template <typename T> inline T sum_value(vector<T>& x) { return accumulate(x.begin(), x.end(), 0ULL); }

int main() {
  ull n;
  vector<ull> p;

  cin >> n;
  each(i, n) {
    ull tmp;
    cin >> tmp;
    p.push(tmp);
  }

  ull tmp = 0;
  each(i, n) {
    ull v = i + 1;
    if (p[i] == v) {
      continue;
    } else {
      tmp++;
    }
  }

  if (tmp >= 3) {
    cout << "NO" << endl;
  } else {
    cout << "YES" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
n,m,l= map(int,input().split())
b=[]
A=[]
B=[]
for i in range(n):
        A1=list(map(int,input().split()))
        A.append(A1)
for i in range(m):
        B1=list(map(int,input().split()))
        B.append(B1)
C= [[0 for i in range(l)] for j in range(n)]
for i in range(n):
    for j in range(l):
       for k in range(m):
            C[i][j]+=(A[i][k]*B[k][j])
for i in range(n):
    c=map(str,C[i])
    print(" ".join(c))

Measured memory_bytes: 8800
import sys
import math
import itertools
import collections
from collections import deque
from collections import defaultdict

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
MOD2 = 998244353
INF = float('inf')
input = lambda: sys.stdin.readline().strip()

NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()

def main():
    N = NI()
    A = NLI()
    B = NLI()
    C = NLI()
    
    A = sorted(A)
    C = sorted(C)
    
    ans = 0
    
    for b in B:
        

        A_ng = -1       #ng:とり得る最小の値-1
        A_ok = len(A)  #ok:とり得る最大の値+1

        while (abs(A_ok - A_ng) > 1):
            A_mid = (A_ok + A_ng) // 2

            if A[A_mid] >= b:#計算の結果、midが条件を満たすならokにmidを代入。そうでなければngにmidを代入。
                A_ok = A_mid
            else:
                A_ng = A_mid
                
        C_ng = -1      #ng:とり得る最小の値-1
        C_ok = len(C)  #ok:とり得る最大の値+1

        while (abs(C_ok - C_ng) > 1):
            C_mid = (C_ok + C_ng) // 2

            if C[C_mid] > b:#計算の結果、midが条件を満たすならokにmidを代入。そうでなければngにmidを代入。
                C_ok = C_mid
            else:
                C_ng = C_mid
                
                
        len_C = len(C)
        
        ans += A_ok * (len_C-C_ok)
        
    print(ans)
if __name__ == '__main__':
    main()

Measured memory_bytes: 29284
n=int(input())
b=list(map(int,input().split()))
ans=[]
while True:
    l=len(b)
    temp=[]
    flag=0
    for i in range(l-1,-1,-1):
        if flag==1 or b[i]!=i+1: temp.append(b[i])
        else:
            ans.append(i+1)
            flag=1
    b=temp[::-1]
    if len(b)==l:
        print(-1)
        exit()
    elif len(b)==0: break
for val in ans[::-1]: print(val)

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

using namespace std;

#define LOG(...) fprintf(stderr, __VA_ARGS__)
//#define LOG(...)
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define RFOR(i, a, b) for (int i = (int)(b - 1); i >= (int)(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 ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SZ(a) ((int)(a).size())
#define BIT(x, i) (((x) >> (i)) & 1)
#define SQ(x) ((x) * (x))

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

class ParseError {};

map<string, int> atoms;

int number(string& s, int& idx) {
    int n = 0;
    while (isdigit(s[idx])) {
        n *= 10;
        n += s[idx] - '0';
        idx++;
    }
    return n;
}

string atom(string& s, int& idx) {
    stringstream sym;
    sym << s[idx];
    idx++;
    while (islower(s[idx])) {
        sym << s[idx];
        idx++;
    }
    return sym.str();
}

int molecule(string& s, int& idx) {
    int res = 0;
    for (; idx < s.length();) {
        if (s[idx] == '(') {
            idx++;
            int a = molecule(s, idx);
            int b = number(s, idx);
            res += a * b;
        } else if (s[idx] == ')') {
            idx++;
            return res;
        } else if (isalpha(s[idx])) {
            int n;
            while (1) {
                string sym = atom(s, idx);
                if (!EXIST(atoms, sym)) throw ParseError();
                if (isalpha(s[idx])) {
                    res += atoms[sym];
                } else {
                    n = atoms[sym];
                    break;
                }
            }
            if (isdigit(s[idx])) {
                n *= number(s, idx);
            }
            res += n;
        } else {
            assert(0);
        }
    }
    return res;
}

int main() {
    // H2C = 1*2+12
    // Cu(OH)2 = 64+(16+1)*2

    string sym;
    while (cin >> sym, sym != "END_OF_FIRST_PART") {
        int weight;
        cin >> weight;
        atoms[sym] = weight;
    }
    string s;
    while (cin >> s, s != "0") {
        try {
            int idx = 0;
            cout << molecule(s, idx) << endl;
        } catch (ParseError e) {
            cout << "UNKNOWN" << endl;
        }
    }
}

Measured memory_bytes: 3204
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
//const int INF = 1e8;
using namespace std;

int main(){
	string s;
	int k;
	cin >> s >> k;

	string ans;
	for(auto i : s){
		int cost = 'z' - i + 1;
		if(i == 'a' or k < cost){
			ans += i;
		}else{
			k -= cost;
			ans += 'a';
		}
	}

	k %= 26;
	rep(i,k) ans.back()++;
	cout << ans << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ll long long
#define pi 3.14159265358979
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;
const int INF = 1000100100;

int main(){
    ll n,cnt=0,sum=0,ans;
    string s;
    cin>>s;
    n=s.size();
    rep(i,n){
        if(s[i]=='B'){
            cnt++;
            sum+=n-i;
        }
    }
    ans=sum-cnt*(cnt+1)/2;
    cout<<ans;
}

Measured memory_bytes: 3704