akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T, class U> using Pa = pair<T, U>;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long double A,B;
    cin >> A >> B;
    ll ans = floor(A*B);
    cout << ans << "\n";
}

Measured memory_bytes: 3744
void main() {
	auto N = ri;
	if(N%2==1) writeln(N*2);
	else writeln(N);
}

// ===================================

import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

Measured memory_bytes: 256
S=input()
L=[0]*(len(S)+1)
for i in range(len(S)):
    if S[i]=='<':
        L[i+1]=L[i]+1

for i in range(len(S)-1,-1,-1):
    if S[i]=='>':
        L[i]=max(L[i],L[i+1]+1)
print(sum(L)) 

Measured memory_bytes: 28940
n = int(input())
a = [list(map(int, input().split())) for i in range(n)]
move = []
move.append([a[0][0], a[0][1], a[0][2]])
for i in range(1, n):
    move.append([a[i][0]-a[i-1][0], abs(a[i][1]-a[i-1][1]), abs(a[i][2]-a[i-1][2])])

for i in range(n):
    t = move[i][0]
    x = move[i][1]
    y = move[i][2]
    if x+y>t or (x+y)%2!=t%2:
        print('No')
        exit()

print('Yes')


Measured memory_bytes: 36236
import java.util.*;

public class Main {

    private long N;
    private long K;

    public void inputData() {
        Scanner sc = new Scanner(System.in);
        N = sc.nextLong();
        K = sc.nextLong();
    }

    public void printAnswer() {
        long count = 0;
        for (long b = K + 1; b <= N; b++) {
            long wide = b - K;
            long pattern = N / b;
            long remainder = N % b;
            long ans = 0;
            if (remainder >= K) {
                ans = wide * pattern + remainder - K + 1;
            } else {
                ans = wide * pattern;
            }
            count += ans;
        }
        if (K == 0) {
            count -= N;
        }
        System.out.println(count);
    }

    public void run() {
        inputData();
        printAnswer();
    }

    public static void main(String[] args) {
        (new Main()).run();
    }

}


Measured memory_bytes: 21972
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
 
int main(int argc, char* argv[])
{
    long n;
    scanf("%ld", &n);
 
    std::vector<long> a(n);
 
    long i;
    for(i=0; i<n; i++) {
        scanf("%ld", &(a[i]));
        a[i] -= (i+1);
    }
    std::sort( a.begin(), a.end());

    long k = (n-1) / 2;
    long tmp = a[k];

    long long sum0 = 0;
    for(i=0; i<n; i++) {
        sum0 += abs(a[i] - tmp);
    }
    printf("%lld\n", sum0);
 
    return 0;
}

Measured memory_bytes: 1792
from collections import defaultdict
N, M = map(int, input().split())
A = list(map(int, input().split()))
dic = defaultdict(int)
num, s = 0, 0
dic[0] = 1
for i in A:
    s += i
    num += dic[s % M]
    dic[s % M] += 1

print(num)

Measured memory_bytes: 14920
/* Name        : e
 * Creat       : Sat Jul 13 10:35:51 CST 2019
 * Accept      : Sat Jul 13 12:43:47 CST 2019
 * Author      : landcold7
 * Motto       : Action speaks louder more than words
 */
#include <bits/stdc++.h>
using namespace std;

#define x first
#define y second
#define sz(x) ((int)(x).size())
#ifndef _has_trace
#define trace(...)
#endif
typedef long long ll;

const int mod = 1e9 + 7;

struct mint {
  ll x;
  mint(ll _x = 0) : x(_x % mod) {}

  mint& operator+= (const mint a) {
    if ((x += a.x) >= mod) {
      x -= mod;
    }
    return *this;
  }

  mint& operator-=(const mint a) {
    if ((x -= a.x) < 0) {
      x += mod;
    }
    return *this;
  }

  mint& operator*=(const mint a) {
    x = ((x * a.x) % mod);
    return *this;
  }

  mint operator+(const mint a) const {
    mint ret(*this);
    return ret += a;
  }

  mint operator-(const mint a) const {
    mint ret(*this);
    return ret -= a;
  }

  mint operator*(const mint a) const {
    mint ret(*this);
    return ret *= a;
  }

  mint pow(ll t) const {
    if (t == 0) {
      return 1;
    }
    mint ret = pow(t >> 1);
    ret *= ret;
    if (t & 1) {
      ret *= *this;
    }
    return ret;
  }

  // For prime mod
  // TODO(landcold7): generic case
  mint inv() const {
    return pow(mod - 2);
  }

  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }

  mint operator/(const mint a) const {
    mint ret(*this);
    return ret /= a;
  }
  friend ostream& operator<< (ostream& os, mint& a) {
    os << a.x;
    return os;
  }
};

void solve() {
  int n, m;
  cin >> n >> m;
  vector<int> a(n), b(m);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  for (int i = 0; i < m; ++i) {
    cin >> b[i];
  }
  vector<vector<mint>> dp(n + 1, vector<mint>(m + 1));
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      dp[i][j] = dp[i - 1][j] + dp[i][j - 1] - dp[i - 1][j - 1];
      if (a[i - 1] == b[j - 1]) {
        dp[i][j] += dp[i - 1][j - 1] + 1;
      }
    }
  }
  trace(dp);
  cout << (dp[n][m].x + 1) % mod << "\n";
}

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


Measured memory_bytes: 31616
#include<iostream>
using namespace std;
int main(){
    int H,W;
    while (true){
        cin>>H>>W;
        if(H==0 && W==0) break;
        else{
            for(int i=0;i<H;i++){
                for(int j=0;j<W;j++){
                    cout<<'#';
                }cout<<endl;
            }cout<<endl;
        }
    }
    return 0;
}


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

class die{
private:
  int t,n,w,s,e,d;
public:
  die(){}
  die(int top,int north,int west){
    t=top;
    n=north;
    w=west;
    d=7-t;
    s=7-n;
    e=7-w;
  }
  void turn_north(){
    int tmp=n;
    n=t;
    t=s;
    s=d;
    d=tmp;
  }
  void turn_east(){
    int tmp=e;
    e=t;
    t=w;
    w=d;
    d=tmp;
  }
  void turn_south(){
    int tmp=s;
    s=t;
    t=n;
    n=d;
    d=tmp;
  }
  void turn_west(){
    int tmp=w;
    w=t;
    t=e;
    e=d;
    d=tmp;
  }
  void turn(string to){
    if(to=="north"){
      turn_north();
    }else if(to=="east"){
      turn_east();
    }else if(to=="south"){
      turn_south();
    }else if(to=="west"){
      turn_west();
    } 
  }
  int top(){
    return t;
  }
};

die D;
int n;
void init(){
  D=die(1,2,3);
}

bool input(){
  cin>>n;
  return n!=0;
}

int solve(){
  string in;
  for(int i=0;i<n;i++){
    cin>>in;
    D.turn(in);
  }
  return D.top();
}


int main(){
  while(init(),input()){
    cout<<solve()<<endl;
  }
}

Measured memory_bytes: 1220
N = int(input())
A = list(map(int, input().split()))
Q = int(input())
bc = [list(map(int, input().split())) for _ in range(Q)]

num_list = [0 for _ in range(100001)]

all_val = 0
for i in range(N):
    all_val += A[i]
    num_list[A[i]] += 1

for i in range(Q):
    before = bc[i][0]
    after = bc[i][1]
    
    all_val += (after-before) * num_list[before]
    num_list[after] += num_list[before]
    num_list[before] = 0
    
    print(all_val)

Measured memory_bytes: 97324
N = int(input())
src = [tuple(map(int,input().split())) for i in range(N)]

xs = []
ys = []
for i,(x,y) in enumerate(src):
    xs.append((x,i))
    ys.append((y,i))
xs.sort()
ys.sort()

es = []
for (x1,i1),(x2,i2) in zip(xs,xs[1:]):
    es.append((x2-x1, i1, i2))
for (y1,i1),(y2,i2) in zip(ys,ys[1:]):
    es.append((y2-y1, i1, i2))
es.sort()

class UnionFind:
    def __init__(self,N):
        self.parent = [i for i in range(N)]
        self.rank = [0] * N
        self.count = 0
    def root(self,a):
        if self.parent[a] == a:
            return a
        else:
            self.parent[a] = self.root(self.parent[a])
            return self.parent[a]
    def is_same(self,a,b):
        return self.root(a) == self.root(b)
    def unite(self,a,b):
        ra = self.root(a)
        rb = self.root(b)
        if ra == rb: return
        if self.rank[ra] < self.rank[rb]:
            self.parent[ra] = rb
        else:
            self.parent[rb] = ra
            if self.rank[ra] == self.rank[rb]: self.rank[ra] += 1
        self.count += 1

ans = 0
uf = UnionFind(N)
for d,a,b in es:
    if uf.is_same(a,b): continue
    uf.unite(a,b)
    ans += d
print(ans)

Measured memory_bytes: 61120
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<bits/stdc++.h>
#include<stack>
#include<queue>
#include<list>
#include<vector>
#include<bitset>
#include<unordered_map>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
// #include "boost/algorithm/string.hpp"
#define fio ios_base::sync_with_stdio(false)
#define mod 998244353
#define mod1 mod
#define mod2 1000000007
#define li long long int
#define ll li
#define readi(x) scanf("%d",&x)
#define  reads(x)  scanf("%s", x)
#define readl(x) scanf("%I64d",&x)
#define rep(i,n) for(i=0;i<n;i++)
#define revp(i,n) for(i=(n-1);i>=0;i--)
#define myrep1(i,a,b) for(i=a;i<=b;i++)
#define myrep2(i,a,b) for(i=b;i>=a;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define sec second
#define MAXN 1000000000010000005
#define MINN -1000000000000000000
#define INTMAX 1000001000
#define pii pair<ll,ll>
#define pdd pair<double,double>
#define pic pair<int,char>
#define N 3000105
#define lgn 20
#define ddouble long double
#define minus minu
#define PI 2*acos(0)
#define lgn 20
 
 
// #define INTMAX 200000000
 
// using namespace boost;
// #define si short int
 
using namespace std;
using namespace __gnu_pbds;
typedef priority_queue<pii, vector<pii > > max_pq;
typedef priority_queue<pii, vector<pii> , greater<pii>  > min_pq;
ll toint(const string &s) {stringstream ss; ss << s; ll x; ss >> x; return x;}
string tostring ( ll number ){stringstream ss; ss<< number; return ss.str();}
 
// using namespace __gnu_pbds;
// typedef priority_queue<pair<ll,char> , vector<pair<ll , char> > > max_pq;
// typedef priority_queue<pii , vector<pii > ,greater<pii > > min_pq;
typedef tree<pair<string,string> , null_type, less<pair<string,string> >, rb_tree_tag, tree_order_statistics_node_update> OST;
// typedef priority_queue<pair < ll , pair < pii , ll > >  , vector<pair < ll , pair < pii , ll > >  > ,greater<pair < ll , pair < pii , ll > >  > > min_pq;
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << std::endl;
        //use cerr if u want to display at the bottom
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif
#define nn 2000005
ll ar[ N ];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,k;;
    cin >> n >> k;
    for ( ll i = 1; i <= n; i ++){
        cin >> ar[i];
    }
    sort(ar+1,ar+n+1);
    ll ans = 0;
    for ( ll i = 1; i <= k; i ++){
        ans += ar[i];
    }
    cout << ans;
    
}


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

int main() {
  ll n;
  cin >> n;
  
  ll m = 0;
  while (m <= sqrt(n)) m++;
  
  ll x = 0, y = 0;
  for (ll i = m; i>=1; i--) {
    if (n%i==0) {
      x = i;
      y = n/i;
      break;
    }
  }
  
  cout << (x-1) + (y-1) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 using namespace std;
  int main()
  {
      
      int n;
       cin>>n;
        if(n>=400 && n<=599)
         cout<<"8"<<endl;
         if(n>=600 && n<=799)
         cout<<"7"<<endl;
         if(n>=800 && n<=999)
         cout<<"6"<<endl;
         if(n>=1000 && n<=1199)
         cout<<"5"<<endl;
         if(n>=1200 && n<=1399)
         cout<<"4"<<endl;
         if(n>=1400 && n<=1599)
         cout<<"3"<<endl;
         if(n>=1600 && n<=1799)
         cout<<"2"<<endl;
         if(n>=1800 && n<=1999)
         cout<<"1"<<endl;
     

  }

Measured memory_bytes: 3624
#include<bitset>
#include<math.h>
#include<limits.h>
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<sstream>
#include<list>
#include<queue>
#include<algorithm>
#include<functional>
#include<map>
#include<set>
#include<utility>
#include<initializer_list>
#include<tuple>
#include<regex>
using namespace std;
#define ull unsigned long long
#define ll long long
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define rep1n(i, n) for(int i=1;i<=(int)(n);i++)
#define repe(i, a, n) for(int i=(a);i<(int)(n);i++)
#define repi(i, a, n) for(int i=(a);i<=(int)(n);i++)
#define all(t) t.begin(), t.end()
#define rall(t) t.rbegin(), t.rend()
#define mat(type, row, col, init) vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout<<(cond? "Yes":"No")<<endl;
#define YES(cond) cout<<(cond? "YES":"NO")<<endl;
int main() {
	int n;
	cin >> n;
	vector<int>a(n);
	rep(i, n)cin >> a[i];
	int mm = 1e9 + 7;
	int init = n % 2;

	int ex = init + 1;
	sort(all(a));
	repe(i, init, n - 1) {
		if (a[i] != ex || a[i + 1] != ex) {
			cout << 0;
			return 0;
		}

		ex += 2;
		i++;
	}
	int k = n / 2;
	ll ans = 1;
	rep(i, k)ans = (ans * 2) % mm;
	cout << ans;

	return 0;
}

Measured memory_bytes: 640
# -*- coding: utf-8 -*-
import sys

def main():
	s_num, c_num = map(int, input().split(" "))
	
	counts = 0
	if c_num >= (s_num * 2):
		counts = counts + s_num
		c_num = c_num - (s_num * 2)
		s_num = 0
	elif s_num != 0:
		tmp = c_num // 2
		counts = counts + tmp
		s_num = s_num - tmp
		c_num = c_num - (tmp * 2)
		
	tmp = c_num // 4
	
	print(counts + tmp)
	
if __name__ == "__main__":
	main()
	

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main(){
    int n;
    int temp = 0;
    int ans = 0;
    cin >> n;
    for(int i=1;i<=n;i++){
        temp = 0;
        if(i%2 != 0){
        for(int j=1;j<=i;j++){
            if(i%j==0){
                temp++;
            }
            }
            if(temp==8){
                ans++;
        }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vint a(n),b(n);
    int m=0;
    REP(i,n){
        cin >> a[i];
    }
    bool f=true;
    int last;
    for(int i=n;i>=1;i--){
        int sum = 0;
        int tmp = 2;
        while(i*tmp<=n){
            sum+=b[i*tmp-1];
            tmp++;
        }
        if(sum%2!=a[i-1]){
            b[i-1]=1;
            m++;
            if(f){
                last = i-1;
                f=false;
            }
        }else{
            b[i-1]=0;
        }
    }
    cout << m << endl;
    REP(i,n){
        if(b[i]==1){
            if(i==last){
                cout << i+1 << endl;
            }else{
                cout << i+1 << " ";
            }
        }
    }

    return 0;
}

Measured memory_bytes: 2560
import math

n = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]

count_a = 0
count_b = 0

#必要最低限の操作数を調べる
for i in range(n):
  if a[i]<b[i]:
    count_a += math.ceil((b[i]-a[i])/2)
    if (b[i]-a[i])%2 == 1:
      count_b += 1
  elif a[i] > b[i]:
    count_b += a[i]-b[i]
    
if count_b <= count_a:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 4596
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
//#include <unistd.h>
//#include <stdio.h>
#define rep(i,x) for(ll i = 0;i<x;i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using namespace std;
using dou = double;
const ll INF = 1LL << 60;
const ll mod = 1000000007;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
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){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}
const int MAX = 510000;

long long fac[MAX], finv[MAX], inv[MAX];

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

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
/*
int main() {
    // 前処理
    COMinit();

    // 計算例
    cout << COM(100000, 50000) << endl;
}*/

//printf("%.10f\n", N);
/*
ll fibo(ll n){
    if(memo[n] != 0)return memo[n];
    if(n <= 1)return n;
    else return memo[n] = fibo(n - 1)+ fibo(n - 2);
}*/
/*  vector<ll> vec = {1,2,5,6,8,9,10};
    cout << binary_search(all(vec),5) << endl; -> true*/
/*
    vector<ll> vec = {1,2,5,6,8,9,10};
    auto n = upper_bound(all(vec),4);
    cout << *n << endl; -> 5*/
/*
    cout << fixed << setprecision(15);
*/
int main(){
    ll N;
    cin >>N;
    vector<ll> num(N);
    rep(i,N)cin >> num[i];
    vector<ll> n = num;
    sort(all(n));
    ll cnt = 0;
    rep(i,N){
        if(n[i] != num[i])cnt++;
    }
    if(cnt <= 2)cout << "YES" << endl;
    else cout << "NO" << endl;
}


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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;

const int INF = 1000000000;
const int MOD = 1000000007;
const double eps = 1e-9;

int main(int argc, char *argv[]) {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    string S;
    cin >> S;
    int cnt = 1;
    char pre = S[0];

    rep(i, S.size() - 1) {
        if (pre != S[i + 1]) {
            pre = S[i + 1];
            cnt++;
        }
    }

    cout << cnt - 1 << endl;
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <time.h>
#define int long long
#define endl '\n'
#define INF 1000000000000000000
#define all(a) a.begin(),a.end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define fi first
#define se second
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
template<class T, class S> bool chmax(T &a, const S &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T, class S> bool chmin(T &a, const S &b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll n, ll m) { return (m ? gcd(m, n%m) : n); }
ll lcm(ll n, ll m) { return n / gcd(n, m)*m; }

template<class T>
class segtree {
	int n;
	vector<T> data;
	T def;
	function<T(T, T)> operation;
	function<T(T, T)> update;
	T _query(int a, int b, int k, int l, int r) {
		if (r <= a || b <= l) return def;
		if (a <= l && r <= b) return data[k];
		T c1 = _query(a, b, 2 * k + 1, l, (l + r) / 2);
		T c2 = _query(a, b, 2 * k + 2, (l + r) / 2, r);
		return operation(c1, c2);
	}
public:
	segtree(size_t _n, T _def, function<T(T, T)> _operation, function<T(T, T)> _update)
		:def(_def), operation(_operation), update(_update) {
		n = 1;
		while (n < _n) {
			n *= 2;
		}
		data = vector<T>(2 * n - 1, def);
	}
	void change(int i, T x) {
		i += n - 1;
		data[i] = update(data[i], x);
		while (i > 0) {
			i = (i - 1) / 2;
			data[i] = operation(data[i * 2 + 1], data[i * 2 + 2]);
		}
	}
	T query(int a, int b) {
		return _query(a, b, 0, 0, n);
	}
	T operator[](int i) {
		return data[i + n - 1];
	}
};

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);
	//modcalc();

	int n;
	cin >> n;
	vector<vector<int>> a(3, vector<int>(n));
	rep(i, 3) rep(j, n) cin >> a[i][j];
	bool ans = true;
	vector<int> c(n);
	int evencnt = 0, oddcnt = 0;
	rep(i, n) {
		if (a[1][i] % 3 != 2) ans = false;
		if (a[0][i] != a[1][i] - 1 && a[0][i] != a[1][i] + 1) ans = false;
		if (a[2][i] != a[1][i] - 1 && a[2][i] != a[1][i] + 1) ans = false;
		c[i] = (a[1][i] - 2) / 3;
		if ((c[i] - i) % 2) ans = false;
		if (abs(c[i] - i) % 4 == 0 && a[0][i] - 1 == a[1][i] || abs(c[i] - i) % 4 == 2 && a[0][i] + 1 == a[1][i]) {
			if (i % 2 == 0) evencnt++;
			else oddcnt++;
		}
	}
	segtree<int> evenseg(n + 2, 0, [](int a, int b) {return a + b; }, [](int a, int b) {return a + b; });
	segtree<int> oddseg(n + 2, 0, [](int a, int b) {return a + b; }, [](int a, int b) {return a + b; });
	rep(i, n) {
		if (i % 2 == 0) {
			evenseg.change(c[i], 1);
			oddcnt -= evenseg.query(c[i] + 1, n);
		}
		if (i % 2 == 1) {
			oddseg.change(c[i], 1);
			evencnt -= oddseg.query(c[i] + 1, n);
		}
	}
	if (evencnt % 2 != 0 || oddcnt % 2 != 0) ans = false;
	cout << (ans ? "Yes" : "No") << endl;
}

Measured memory_bytes: 7540
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<P> Graph;

const int nmax = 8;
bool graph[8][8];

int dfs(int v, int n, bool visit[nmax]){

  bool check = true;
  
  REP(i,n){
    if(!visit[i]) check = false;
  }
  
  if(check) return 1;
  
  int sum = 0;
  
  REP(i,n){
    if(!graph[v][i]) continue;  //パスが存在して
    if(visit[i]) continue;      //未訪問ならば
    visit[i] = true;
    sum += dfs(i,n,visit);
    visit[i] = false;
  }
  
  return sum;
 
}
  


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

  int n,m;
  cin >> n >> m;
  
  REP(i,m){
    int a,b;
    cin >> a >> b;
    a--;b--;
    graph[a][b] = graph[b][a] = true;
  }
  
  bool visit[n];
  REP(i,n) visit[i] = false;
  visit[0] = true;

  cout << dfs(0,n,visit) << endl;
  
  return 0;
}

Measured memory_bytes: 256
n,m = map(int,input().split())
li = [[0,0] for _ in range(n)]
t1,t2 = 0,0
for i in range(m):
    a,b = input().split()
    if li[int(a)-1][0] != 1:
        if b == "WA":
            li[int(a)-1][1] += 1
        if b == "AC":
            li[int(a)-1][0] += 1
for i in range(n):
    t1 += li[i][0]
    t2 += li[i][1]*li[i][0]
print(t1,t2)

Measured memory_bytes: 14580
$_=<>;($x,$y)=glob<>;
s/^F*/$x-=length$&/e;
s#F+#push@{$`=~y/T//&1},length$&#ger;
@$_=sort{$b-$a}@$_ for 0,1;
$x>0?$x-=$_:($x+=$_)for@0;
$y>0?$y-=$_:($y+=$_)for@1;
print$x|$y?No:Yes

Measured memory_bytes: 1152
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        final Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int[] problems = new int[N];
        int[] was = new int[N];

        for (int i = 0; i < M; i++) {
            final int p = sc.nextInt() - 1;
            boolean isAC = sc.next().equals("AC");
            if (isAC) {
                problems[p] = 1;
            } else {
                if (problems[p] != 1) {
                    was[p]++;
                }
            }
        }
        int wa = 0;
        for (int i = 0; i < N; i++) {
            if (problems[i] == 1) {
                wa += was[i];
            }
        }
        System.out.println(Arrays.stream(problems).sum() + " " +wa);
    }
}



Measured memory_bytes: 64568
#include <stdio.h>
#include <math.h>

int main(void){
    int num, count=0;
    double distance;
    scanf("%d %lf", &num, &distance);

    double x[num], y[num], p_dis[num];
    for(int i=0; i<num; i++){
        scanf("%lf %lf", &x[i], &y[i]);
        p_dis[i] = sqrt(pow(x[i], 2) + pow(y[i], 2));
        if(p_dis[i] <= distance) count ++;
    }

    printf("%d\n", count);
    return 0;
}


Measured memory_bytes: 6904
#include <stdio.h>
#include <string.h>
 
int main(void){
  int i,n = 0;
  char w[11], t[1001];
 
  scanf("%s", w);
 
  do{
    scanf("%s",t);
    if(!strcmp(t,"END_OF_TEXT")) break;
      for(i=0;t[i]!='\0';i++)
        if(t[i]<91) t[i] += 32;
    if( !strcmp(w,t) ) n++;
  }while(1);
 
  printf("%d\n",n);
 
  return 0;
}


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

#define lli long long int
#define endl "\n"

int find_longest_path(int i, int n, vector<vector<int> > &graph, vector<int> &dp, vector<bool> &vis){
	vis[i] = true;
	
	if(graph[i].size() == 0){
	   // cout << i << " ";
		return 0;
	}

	if(dp[i] != -1)
		return dp[i];

	else{
		int q = -1;

		for(int x = 0; x < graph[i].size(); x++){
		  //  cout << graph[i][x] << " ";
			q = max(q, 1 + find_longest_path(graph[i][x], n, graph, dp, vis));
		}
// 		cout << endl;
		dp[i] = q;
		return q;

	}
}

int main(){

	int n, m;
	cin >> n >> m;

	vector<vector<int> > graph(n+1);

	int x, y;
	for(int i = 0 ; i < m; i++){
		cin >> x >> y;
		
// 		cout << x << " " << y << endl;
		graph[x].push_back(y);
		
	}
	
// 	for(int i =1 ;i <= n ; i++){
// 	    for(auto j : graph[i]){
// 	        cout << j << " ";
// 	    }
// 	    cout << endl;
// 	}

	vector<int> dp(n+1, -1);
    
    vector<bool> vis(n+1, false);
    
    for(int i = 1; i <= n ; i++){
        if(!vis[i])
	        find_longest_path(i, n, graph, dp, vis);
    }
    
    // for(int i = 0 ; i <= n ; i++)
    //     cout << dp[i] << " ";
    
    // cout << endl;
	int ans = -3;
	for(int i = 0; i < dp.size(); i++)
		ans = max(ans, dp[i]);

	cout << ans << endl;

	
}

Measured memory_bytes: 9472
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Competitive
{
    internal class Solution
    {
        public int N;
        public int[] A;
        public void Run()
        {
            N = Input.ReadInt();
            A = Input.ReadIntArray();
            var counter = new InversionCount();
            long ret = counter.Calc(A);
            Console.WriteLine(ret);
        }

    }

    // libs ----------
    class InversionCount
    {
        public int[] A;

        public long Calc(int[] A)
        {
            this.A = A;
            return dfs(0, A.Length);
        }


        long dfs(int L, int R)
        {
            // [L, M), [M, R) に分ける
            int n = R - L;
            if (n <= 1) return 0;
            int m = (L + R) / 2;

            long ret = 0;
            ret += dfs(L, m);
            ret += dfs(m, R);

            int r = m;
            for (int l = L; l < m; l++)
            {
                while (r < R && A[l] >= A[r])
                {
                    r++;
                }
                ret += (r - m);
            }

            // 対象範囲をソートする
            Array.Sort(A, L, R - L);

            // Console.WriteLine($"{L}, {R}, {ret}, -- {string.Join(", ", A)}");
            return ret;
        }
    }

    // common ----------

    internal static class Input
    {
        public static string ReadString()
        {
            string line = Console.ReadLine();
            return line;
        }

        public static int ReadInt()
        {
            string line = Console.ReadLine();
            return int.Parse(line);
        }

        public static int[] ReadIntArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(int.Parse).ToArray();            
        }

        public static long ReadLong()
        {
            string line = Console.ReadLine();
            return long.Parse(line);
        }

        public static long[] ReadLongArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(long.Parse).ToArray();
        }

        public static double[] ReadDoubleArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(double.Parse).ToArray();
        }
    }
    
    internal class Program
    {
        public static void Main(string[] args)
        {
            var s = new Solution();
            s.Run();
        }
    }
}


Measured memory_bytes: 26364
let N = stdin.ReadLine() |> int
let A = stdin.ReadLine().Split() |> Array.map int64
let B = stdin.ReadLine().Split() |> Array.map int64

let rec resolver s n =
    if n = N then s
    else
        let mutable t = 0L
        if B.[n] > A.[n] then
            B.[n] <- B.[n] - A.[n]
            t <- t + A.[n]
            A.[n] <- 0L
        else
            A.[n] <- A.[n] - B.[n]
            t <- t + B.[n]
            B.[n] <- 0L
        if B.[n] > A.[n + 1] then
            B.[n] <- B.[n] - A.[n + 1]
            t <- t + A.[n + 1]
            A.[n + 1] <- 0L
        else
            A.[n + 1] <- A.[n + 1] - B.[n]
            t <- t + B.[n]
            B.[n] <- 0L
        resolver (s + t) (n + 1)

resolver 0L 0 |> stdout.WriteLine


Measured memory_bytes: 35420
#include <bits/stdc++.h>
typedef long long ll;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
const int INF = 1 << 30;
const ll INFll = 1ll << 60;
template <typename T>
bool chmax(T& a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
template <typename T>
bool chmin(T& a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}

int main() {
  string N;
  cin >> N;
  string ans = (N[0] == N[1] && N[1] == N[2]) || (N[3] == N[1] && N[1] == N[2])
                   ? "Yes"
                   : "No";
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ; //何もしない文
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size()) //unsignedのサイズをint型に変換

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL; 

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;

//ここから書き始める
int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);	
    int X;
    cin >> X;

    if(X == 7 || X == 5 || X == 3) cout << "YES" << endl;
    else cout << "NO" << endl;

}


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

int main() {
    int R, G, B, N;
    int i, j, K, ans;
    cin >> R >> G >> B >> N;
    for(i=0;i<3001;i++) {
        for(j=0;j<3001;j++) {
            K = N-(R*i+G*j);
            if(K>-1 && K%B == 0){
                ans +=1;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdint>
#include <climits>
#include <string>

using namespace std;

int main(void)
{
  string S;
  S.reserve(100001);
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> S;
  int c[2] = {};
  for(int i = 0; i < S.size(); i++){
    int j;
    for(j = i + 1; j < S.size(); j++){
      if(S[j] == S[i]) continue;
      c[S[i] == 'B' ? 0 : 1]++;
      break;
    }
    i = j - 1;
  }

  cout << c[0] + c[1] << endl;

  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define pie 3.141592653589793238462643383279
#define int long long
#define mod 1000000007
#define INF LLONG_MAX/5
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define S second
#define F first
#define f(i,n) for(int i=0;i<n;i++)
int x[100000],y[100000];
signed main(){
	int a,b,ans=0;
	cin>>a>>b;
	y[0]=1;
	f(i,b){
		int c,d;
		cin>>c>>d;
		c--,d--;
		y[d]+=y[c];
		x[d]++;
		if(!x[c])y[c]=0;
		x[c]--;
	}
	f(i,a){
		if(y[i])ans++;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
 
using namespace std;
 
const int N = 1e6+5;
 
int dist[N];
vector < pair <int, int> > g[N];
vector <int> new_g[N], all[N];
int was[N];
int x[N];
int ptr[N];
int is[N];
 
template<typename Ty>
bool read1n(Ty &x)
{
    char ch; bool neg=false;
    for(ch=getchar();ch<'0'||'9'<ch;ch=getchar())
        if(ch=='-')
            neg=true;
        else if(ch==-1)return false;
    for(x=0;'0'<=ch&&ch<='9';ch=getchar())
        x=(x<<1)+(x<<3)+ch-'0';
    if(neg) x=-x;
    return true;
}
 
int main() {
  int n, m;
  while(1){
    if(!read1n(n))break;
    read1n(m);
    memset(dist,0,sizeof(dist));
    memset(x,0,sizeof(x));
    memset(is,0,sizeof(is));
    for(int i=0;i<n;i++)g[i].clear();
  for (int i = 0; i < m; i++) {
    int foo, bar, qwe;
    read1n(foo);
    read1n(bar);
    read1n(qwe);
    if(is[qwe]==0)all[qwe].clear();
    is[qwe]++;
    foo--; bar--;
    g[foo].push_back(make_pair(qwe, bar));
    g[bar].push_back(make_pair(qwe, foo));
    all[qwe].push_back(foo);
    all[qwe].push_back(bar);
  }
  for (int i = 0; i < n; i++) {
    sort(g[i].begin(), g[i].end());
    ptr[i] = 0;
  }
  for (int i = 0; i < n; i++) {
    was[i] = -1;
  }
  int new_n = n;
  for (int i = 0; i < N; i++) {
    new_g[i].clear();
  }
  for (int color = 0; color < N; color++) {
    if (all[color].empty()) {
      continue;
    }
    for (int it = 0; it < all[color].size(); it++) {
      int v = all[color][it];
      if (was[v] == color) {
        continue;
      }
      int b = 0, e = 1;
      x[0] = v;
      was[v] = color;
      while (b < e) {
        while (ptr[x[b]] <  g[x[b]].size()) {
          int c = g[x[b]][ptr[x[b]]].first;
          if (c != color) {
            break;
          }
          int u = g[x[b]][ptr[x[b]]].second;
          if (was[u] != color) {
            was[u] = color;
            x[e] = u;
            e++;
          }
          ptr[x[b]]++;
        }
        b++;
      }
      for (int i = 0; i < e; i++) {
        new_g[x[i]].push_back(new_n);
        new_g[new_n].push_back(x[i]);
      }
      new_n++;
    }
  }
  for (int i = 0; i < new_n; i++) {
    dist[i] = -2;
  }
  int b = 0, e = 1;
  x[0] = 0;
  dist[0] = 0;
  while (b < e) {
    for (int j = 0; j <  new_g[x[b]].size(); j++) {
      int u = new_g[x[b]][j];
      if (dist[u] == -2) {
        dist[u] = dist[x[b]] + 1;
        x[e] = u;
        e++;
      }
    }
    b++;
  }
  printf("%d\n", dist[n - 1] / 2);
  }
  return 0;
}

Measured memory_bytes: 109312
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N = 5005;
const int MOD = 1e9 + 7;

int n, k;
int fact[N], invfact[N];

int pow(int a, int b, int m)
{
	int ans = 1;
	while(b > 0)
	{
		if(b % 2)
		{
			ans *= a;
			ans %= m;
		}
		a *= a;
		a %= m;
		b /= 2;
	}
	return ans;
}

int modinv(int k)
{
	return pow(k, MOD - 2, MOD);
}

void preprocess()
{
	fact[0] = 1;
	invfact[0] = modinv(fact[0]);
	for(int i = 1; i < N; i++)
	{
		fact[i] = fact[i - 1] * i;
		fact[i] %= MOD;
		invfact[i] = modinv(fact[i]);
	}
}

int nCr(int n, int r)
{
	if(r > n)
		return 0;
	int ans = fact[n];
	ans *= invfact[n - r];
	ans %= MOD;
	ans *= invfact[r];
	ans %= MOD;
	return ans;
}

int32_t main()
{
	IOS;
	preprocess();
	cin >> n >> k;
	for(int i = 1; i <= k; i++)
	{
		int x = n - k - (i - 1) + i;
		int ans = nCr(x, i);
		int y = nCr(k - i + i - 1, i - 1);
		ans *= y;
		ans %= MOD;
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>
#include<set>
#include<cstdio>

using namespace std;

#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define P pair<int, int>

typedef vector<int> vec;
typedef vector<vec> mat;

int main(){
    string s, t;
    cin >> s >> t;
    int mx = 0;
    int n;
    int numt = t.size();
    int nums = s.size();
    for (int i = 0; i < s.size() - t.size() + 1; i++){
        n = 0;
        for (int j = 0; j < t.size(); j++){
            if(s[i+j] == t[j]) n++;
        }
        mx = max(mx, n);
    }
    cout << t.size() - mx << endl;
}

Measured memory_bytes: 3540
import collections
N,K=map(int,input().split())
li=list(map(int,input().split()))
li_count=collections.Counter(li)
li_count_most=li_count.most_common()[::-1]
change=0
S=max(len(li_count)-K,0)
for s in range(S):
    change+=li_count_most[s][1]
print(change)


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

#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define pb push_back

#define l first
#define r second

using pi = pair<int,int>;

int main(){
    int n,Q;
    cin >>n >>Q;

    vector<int> x(n);
    rep(i,n) cin >>x[i];

    int H = n+1, T = n+2;
    vector<pi> a(n+3);

    a[H].r = x[0];
    a[x[0]].l = H;
    for(int i=1; i<n; ++i){
        a[x[i-1]].r = x[i];
        a[x[i]].l = x[i-1];
    }
    a[x[n-1]].r = T;
    a[T].l = x[n-1];

    if(n==1){
        int q;
        rep(i,Q) cin >>q;
        cout << 1 << endl;
        return 0;
    }

    while(Q--){
        int q;
        cin >>q;

        int HR = a[H].r;
        int TL = a[T].l;
        int L = a[q].l;
        int R = a[q].r;

        // printf(" HR L R TL %d %d %d %d\n", HR,L,R,TL);

        if(L==H){
            a[H].r = R;
            a[R].l = H;

            a[TL].r = q;
            a[q].l = TL;

            a[q].r = T;
            a[T].l = q;
        }
        else if(R==T){
            a[H].r = q;
            a[q].l = H;

            a[q].r = HR;
            a[HR].l = q;

            a[L].r = T;
            a[T].l = L;
        }
        else{
            a[H].r = R;
            a[R].l = H;

            a[TL].r = q;
            a[q].l = TL;

            a[q].r = HR;
            a[HR].l = q;

            a[L].r = T;
            a[T].l = L;
        }

        // int now = H;
        // rep(i,n){
        //     now = a[now].r;
        //     cout << now << " \n"[i==n-1];
        // }
    }

    int now = H;
    rep(i,n){
        now = a[now].r;
        cout << now << " \n"[i==n-1];
    }

    return 0;
}



Measured memory_bytes: 3880
#include <stdio.h>

int main()
{
	int t,i;
	int ah, am, as, bh, bm, bs, h, m, s;
	for (i = 0;i < 3;i++) {
		scanf("%d %d %d %d %d %d", &ah, &am, &as, &bh, &bm, &bs);
		as = (3600 * ah + 60 * am + as);
		bs = (bh * 3600 + bm * 60 + bs);
		t = bs - as;
		h = t / 3600;
		m = (t % 3600) / 60;
		s = (t % 3600) % 60;
		printf("%d %d %d\n", h, m, s);
	}


	return 0;
}

Measured memory_bytes: 600
import math
ALPHABET = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
result = []

def alphabet_decimal(v):
    quotient = math.floor(v / len(ALPHABET))
    surplus = v % len(ALPHABET)
    quotient -= 1 if surplus == 0 else 0
    surplus = len(ALPHABET) if surplus == 0 else surplus
    result.append(surplus)
    if len(ALPHABET) < quotient:
        alphabet_decimal(quotient)
    elif len(ALPHABET) < v:
        result.append(quotient)
    return "".join([ALPHABET[i - 1] for i in reversed(result)])

n = int(input())
#s = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
print(alphabet_decimal(n))


Measured memory_bytes: 62136
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
from itertools import product
from collections import defaultdict
def resolve():
    h,w,n=map(int,input().split())
    D=defaultdict(int)
    for _ in range(n):
        a,b=map(int,input().split())
        for i,j in product(range(a-1,a+2),range(b-1,b+2)):
            if(2<=i<=h-1 and 2<=j<=w-1):
                D[(i,j)]+=1

    ans=[0]*10
    for v in D.values():
        ans[v]+=1
    ans[0]=(h-2)*(w-2)-sum(ans)
    print(*ans,sep='\n')
resolve()

Measured memory_bytes: 152184
# abc057 B
n, m = gets.split.map(&:to_i)
ab = n.times.map {
  gets.split.map(&:to_i)
}
cd = m.times.map {
  gets.split.map(&:to_i)
}

ab.each do |(a,b)|
  ind = 1
  min = (a - cd[0][0]).abs + (b - cd[0][1]).abs
  cd.each.with_index(1) do |(c,d), i|
    if min > ( r = ( (a - c).abs + (b - d).abs ) )
      min = r
      ind = i
    elsif min == r
      ind = i if i <= ind
    end
  end
  p ind
end



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

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

using namespace std;
using lint=long long;

int n[3];
lint a[3][1000];

struct state{
	int i,j,k;
	state(int i,int j,int k):i(i),j(j),k(k){}
	int &operator[](int l){
		if     (l==0) return i;
		else if(l==1) return j;
		else          return k;
	}
};

lint value(state x){
	lint res=0;
	rep(i,3) res+=a[i][x[i]];
	return res;
}

bool operator<(state x,state y){
	if(value(x)!=value(y)) return value(x)<value(y);
	return tie(x[0],x[1],x[2])<tie(y[0],y[1],y[2]);
}

int main(){
	rep(i,3) cin>>n[i];
	int k; cin>>k;
	rep(i,3){
		rep(j,n[i]) cin>>a[i][j];
		sort(a[i],a[i]+n[i],greater<lint>());
	}

	priority_queue<state> Q;
	Q.emplace(0,0,0);
	set<state> Vis;
	Vis.emplace(0,0,0);
	rep(_,k){
		auto x=Q.top(); Q.pop();
		cout<<value(x)<<endl;
		rep(i,3) if(x[i]<n[i]-1) {
			x[i]++;
			if(Vis.count(x)==0){
				Q.emplace(x);
				Vis.emplace(x);
			}
			x[i]--;
		}
	}

	return 0;
}


Measured memory_bytes: 896
#include<iostream>
#include<vector>
#include <queue>
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 pii pair<int,int>
int w,h;

int main(){
    while(1){
        w=h=0;
        cin>>w>>h;
        int ans=0;
        if(w==0&&h==0)break;
        vector<vector< int > > c(60,vector<int>(60));
        rep2(i,1,h)rep2(j,1,w){
            cin>>c[i][j];
        }
        vector< vector< int> > visited(60,vector<int>(60));
        rep2(i,1,h){
            rep2(j,1,w){
                if(visited[i][j]||!c[i][j])continue;
                queue<pii> q;
                q.push(pii(i,j));
                visited[i][j]=1;
                while(!q.empty()){
                    pii P=q.front();
                    //cout<<P.first<<" "<<P.second<<endl;
                    q.pop();
                    rep2(ii,-1,1){
                        rep2(jj,-1,1){
                            if(c[P.first+ii][P.second+jj]&&!visited[P.first+ii][P.second+jj]){
                                q.push(pii(P.first+ii,P.second+jj));
                                visited[P.first+ii][P.second+jj]=1;
                            }
                        }
                    }
                }
                if(c[i][j])ans++;
            }
        }
        cout<<ans<<endl;
    }

}


Measured memory_bytes: 3144
package main

import (
	"bufio"
	"fmt"
	"os"
	"strings"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)

	scanner.Scan()

	S := strings.Split(scanner.Text(), "")

	if S[0] != S[1] || S[1] != S[2] {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 1772
#include "math.h"
#include <algorithm>
#include <complex>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <vector>
#define ifor(i, a, b) for (int i = (a); i < (b); i++)
#define rfor(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
using namespace std;
typedef long double ld;
typedef long long int lli;
typedef complex<double> P;
const double eps = 1e-11;
int vex[4] = {1, 0, -1, 0};
int vey[4] = {0, 1, 0, -1};
typedef vector<double> Vec;
typedef vector<int> vec;
typedef vector<Vec> MAT;
typedef vector<vec> mat;
lli MOD = 1000000007;
int main()
{
    lli n, l;
    cin >> n >> l;
    lli a[100005];
    rep(i, n)
    {
        cin >> a[i];
    }
    bool flag = false;
    rep(i, n - 1)
    {
        flag |= (a[i] + a[i + 1] >= l);
    }
    if (flag) {
        int memo;
        rep(i, n - 1)
        {
            if (a[i] + a[i + 1] >= l) {
                memo = i;
            }
        }
        cout << "Possible" << endl;
        rep(i, memo)
        {
            cout << i + 1 << endl;
        }
        for (int i = n - 1; i > memo; i--) {
            cout << i << endl;
        }
        return 0;
    }
    cout << "Impossible" << endl;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
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; }
const ll INF = 1LL << 60;


int main() {
    int A[3][3];
    rep(i,3){
        rep(j,3){
            cin >> A[i][j];
        }
    }
    int N;
    cin >> N;
    int b[N];
    rep(i,N){
        cin >> b[i];
    }
    rep(i,3){
        rep(j,3){
            rep(k,N){
                if(A[i][j]==b[k]){
                    A[i][j] = -1;
                }
            }
        }
    }

    rep(i,3){
        if(A[i][0]!=-1){
            break;
        }
        if(i==2){
            cout << "Yes" << endl;
            return 0;
        }
    }

    rep(i,3){
        if(A[i][1]!=-1){
            break;
        }
        if(i==2){
            cout << "Yes" << endl;
            return 0;
        }
    }

    rep(i,3){
        if(A[i][2]!=-1){
            break;
        }
        if(i==2){
            cout << "Yes" << endl;
            return 0;
        }
    }

    rep(j,3){
        if(A[0][j]!=-1){
            break;
        }
        if(j==2){
            cout << "Yes" << endl;
            return 0;
        }
    }

    rep(j,3){
        if(A[1][j]!=-1){
            break;
        }
        if(j==2){
            cout << "Yes" << endl;
            return 0;
        }
    }

    rep(j,3){
        if(A[2][j]!=-1){
            break;
        }
        if(j==2){
            cout << "Yes" << endl;
            return 0;
        }
    }

    rep(j,3){
        if(A[j][j]!=-1){
            break;
        }
        if(j==2){
            cout << "Yes" << endl;
            return 0;
        }
    }

    rep(j,3){
        if(A[j][2-j]!=-1){
            break;
        }
        if(j==2){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256