akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;

int main(){
	set<int> Prime;
	bool Find[100000] = {};

	for(int i = 2; i < 320; i++){
		if(Find[i]) continue; 
		for(int j = i * 2; j < 100000; j += i){
			if(!Find[j]) Find[j] = true;
		}
	}

	// 2の倍数の素数は2だけなので奇数のみを判定
	Prime.insert(2);
	for(int i = 3; i < 100000; i += 2){
		if(!Find[i]) Prime.insert(i);
	}

	vector<int> like;
	for(int i = 1; i < 100000; i += 2){
		if(Prime.count(i) && Prime.count((i + 1) / 2)){
			like.push_back(i);
		}
	}
	int end = like.size();

	int q;
	cin >> q;
	for(int i = 0; i < q; i++){
		int l,r,out=0;
		cin >> l >> r;
		int c = 0;
		while(like[c] < l&&c <end)c++;
		int d = c;
		while(like[d] <= r&&d <end)d++;
		cout << d-c<<endl;
	}

	return 0;
}


Measured memory_bytes: 1152
s = input()
p = input()
flg = False

for i in range(len(s)):
    if s.find(p) != -1:
        flg = True
        break
    else:
        s += s[0]
        s = s[1:len(s)+1]

if flg:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 5560
#include <iostream>
#include <vector>
#include <algorithm>
typedef long long ll;
using namespace std;
int main(){
    int n,m;
    cin>>n>>m;
    vector<pair<ll,ll>> p(n);
    for(int i=0;i<n;i++){
        ll a,b;
        cin>>a>>b;
        p[i] = pair<ll,ll>(a,b);
    }

    sort(p.begin(),p.end());

    ll ans=0;
    for(int i=0;i<n;i++){
        if(p[i].second < m){
            ans += p[i].first * p[i].second;
            m -= p[i].second;
        }else{
            ans += p[i].first * m;
            m = 0;
        }
        if(m==0) break;
    }

    cout << ans <<endl;
}


Measured memory_bytes: 1792
#include <algorithm>
#include <iostream>
#include <map>
#include <vector>
using namespace std;

map<long long, int> counter(vector<long long> vec){
    map<long long, int> c;
    for (auto &v : vec){
        c[v]++;
    }
    return c;
}
vector<pair<long long, int>> sort_map(map<long long, int> mapOfPlanets)
{
    vector <pair<long long, int> > planets(mapOfPlanets.begin(), mapOfPlanets.end());
    sort(planets.begin(), planets.end(), [](auto lhs, auto rhs) {return lhs.first > rhs.first; });
    return planets;
}

int main(){
    int n;
    cin >> n;
    vector<long long> sticks(n);
    for (int i=0;i<n;i++){
        cin >> sticks[i];
    }
    auto c = counter(sticks);
    auto freq = sort_map(c);

    long long first = 0;
    long long second = 0;
    for (auto &item : freq){
        if (item.second >= 4 && first == 0){
            cout << item.first * item.first << endl;
            return 0;
        } else if (item.second >= 2){
            if (first == 0){
                first = item.first;
            } else{
                second = item.first;
                break;
            }
        }
    }
    cout << first * second << endl;
}

Measured memory_bytes: 15088
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum inf3 = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;


void main() {
    int a, b, c, d, e;
    scan(a);scan(b);scan(c);scan(d);scan(e);
    int x = 10;
    if (a % 10) x = min(x, a % 10);
    if (b % 10) x = min(x, b % 10);
    if (c % 10) x = min(x, c % 10);
    if (d % 10) x = min(x, d % 10);
    if (e % 10) x = min(x, e % 10);
    int ans = (a + 9) / 10 * 10
                + (b + 9) / 10 * 10
                + (c + 9) / 10 * 10
                + (d + 9) / 10 * 10
                + (e + 9) / 10 * 10
                - 10 + x;

    writeln(ans);
}

























int[][] readGraph(int n, int m, bool isUndirected = true, bool is1indexed = true) {
    auto adj = new int[][](n, 0);

    foreach (i; 0 .. m) {
        int u, v;
        scan(u, v);
        if (is1indexed) {
            u--, v--;
        }
        adj[u] ~= v;
        if (isUndirected) {
            adj[v] ~= u;
        }
    }

    return adj;
}

alias Edge = Tuple!(int, "to", int, "cost");

Edge[][] readWeightedGraph(int n, int m, bool isUndirected = true, bool is1indexed = true) {
    auto adj = new Edge[][](n, 0);

    foreach (i; 0 .. m) {
        int u, v, c;
        scan(u, v, c);
        if (is1indexed) {
            u--, v--;
        }
        adj[u] ~= Edge(v, c);
        if (isUndirected) {
            adj[v] ~= Edge(u, c);
        }
    }

    return adj;
}

void yes(bool b) {
    writeln(b ? "Yes" : "No");
}

void YES(bool b) {
    writeln(b ? "YES" : "NO");
}

T[] readArr(T)() {
    return readln.split.to!(T[]);
}

T[] readArrByLines(T)(int n) {
    return iota(n).map!(i => readln.chomp.to!T).array;
}

void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    double l;
    cin >> l;
    double ans = l * l * l / 27;
    cout << fixed << setprecision(10);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <ctime>
#include <cassert>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define fs first
#define sc second
#define INF 1000000000
#define MOD 1000000007
#define EPS 0.00000001



int main() {
    int A, B; cin >> A >> B;
    vector<vector<char>> V(100, vector<char>(100, '#'));
    for(int i=0; i<50; i++){
        for(int j=0; j<100; j++){
            V[i][j] = '.';
        }
    }
    
    
    
    int b=0;
    for(int i=0; i<49; i++){
        if(i%2==1) continue;
        for(int j=0; j<100; j++){
            if(b==B-1) break;
            if(j%2==0){
                V[i][j] = '#';
                b++;
            }
        }
    }
    
    int w=0;
    for(int i=51; i<100; i++){
        if(i%2==0) continue;
        for(int j=0; j<100; j++){
            if(w==A-1) break;
            if(j%2==0){
                V[i][j] = '.';
                w++;
            }
        }
    }
    
//    ofstream ofs;
//    ofs.open("output.txt");
    
    cout << 100 << " " << 100 << endl;
    for(int i=0; i<100; i++){
        for(int j=0; j<100; j++){
            cout << V[i][j];
        }
        cout << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;

int main(){
	string s; cin >> s;
	int N = s.size();
	int l,r;
	rep(i,N){
		if(s[i] == 'A'){
			l = i;
			break;
		}
	}
	for(int i = N-1; i >= 0; i--){
		if(s[i] == 'Z'){
			r = i;
			break;
		}
	}
	cout << r-l+1 << endl;
}

Measured memory_bytes: 640
from fractions import gcd

def lcm(a,b): 
    return int(abs(a * b) / gcd(a,b) if a and b else 0)

N,M = map(int,input().split())
S = input()
T = input()

g = gcd(N,M)
n = N // g
m = M // g

for k in range(g):
    if S[k * n] != T[k * m]:
        print(-1)
        quit()
print(lcm(N,M))

Measured memory_bytes: 5432
#include<bits/stdc++.h>
#define ll long long
using namespace std;
#define N 200010
struct node
{
    int s,t,x;
   bool  operator < (const node &b) const
    {
        return x>b.x;
    }
}a[N];
priority_queue<node>Q;
bool cmp(node a,node b)
{
    return a.s<b.s;
}
int d[N];
int main()
{
    int n,q;
    scanf("%d%d",&n,&q);
    for(int i=1;i<=n;i++)
    {
        scanf("%d%d%d",&a[i].s,&a[i].t,&a[i].x);
        a[i].s-=a[i].x;
        a[i].t-=a[i].x;
    }
    sort(a+1,a+1+n,cmp);
    for(int i=1;i<=q;i++)
        scanf("%d",&d[i]);
    int t=1;
    for(int i=1;i<=q;i++)
    {
        while(a[t].s<=d[i] && t<=n){Q.push(a[t]),t++;}

        bool flag=0;
        while(Q.size())
        {
            node now=Q.top();
            if(d[i]>=now.t){Q.pop();continue;}
            flag=1;
            printf("%d\n",now.x);
            break;
        }
        if(!flag)printf("-1\n");
    }
    return 0;
}


Measured memory_bytes: 6896
s = gets.chomp
a = s[0..1]
b = s[2..4]

m_arr = []
(1..12).to_a.each do |v|
 m_arr << v.to_s.rjust(2,"0")
end

if m_arr.include?(a) && m_arr.include?(b)
  puts "AMBIGUOUS"
elsif  (m_arr.include?(a)==false) && (m_arr.include?(b)==false)
  puts "NA"
elsif m_arr.include?(a)
  puts "MMYY"
elsif m_arr.include?(b)
  puts "YYMM"
end


Measured memory_bytes: 1788
#include<stdio.h>

#define N 200000

int big  (int,int);
int small (int,int);

int main(){
  int R[N];
  int maxv,minv;
  int i,num;

  scanf("%d",&num);

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

  maxv = R[1] - R[0];
  minv = R[0];

  for(i=1;i<=num-1;i++){
    maxv = big(maxv,R[i]-minv);
    minv = small(minv,R[i]);
  }

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

  return 0;
}


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


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

 


  
  
  



Measured memory_bytes: 3508
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;

/*
<url:https://arc064.contest.atcoder.jp/tasks/arc064_b>
問題文============================================================
 長さ 3 以上の文字列 s があります。 s の中に同一の文字が隣り合う箇所はありません。
 
 高橋君と青木君がゲームで勝負します。 二人は交互に次の操作を行います。 高橋君が先手です。
 
 s から両端以外の文字をひとつ取り除く。
 ただし、その文字を取り除くことで、s の中に同一の文字が隣り合う箇所ができる場合、その文字を取り除くことはできない。
 先に操作を行えなくなった人が負けです。 二人が最適に行動したとき、どちらが勝つかを判定してください。
=================================================================

解説=============================================================

================================================================
*/
void solve(){
    string s; cin >> s;
    cout << ((s.length()%2 == 0)^(s.front() == s.back())?"Second":"First") << endl;
    return;
}
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
    solve();
	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
	int r, g, b, n;
	cin >> r >> g >> b >> n;
	int ans = 0;
	rep(i, n+1){
		if(i % r != 0) continue;
		int adr = i / r;
		rep(j, n+1){
			if(j % g != 0) continue;
			int adg = j / g;
			int adb = n - i - j;
			if(adb < 0) continue;
			if(adb % b == 0){
				ans++;
				// cerr << adr << " " << adg << " " << adb << endl;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

const int OO = 1e9;
const double EPS = 1e-9;

#define ndl cout << '\n'
#define sz(v) int(v.size())
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define present(a, x) (a.find(x) != a.end())
#ifdef LOCAL
#define db(...) ({cout << "> Line " << __LINE__  \
		<< ": "; _db(#__VA_ARGS__, __VA_ARGS__);})
#define RNG() rng()
#else
#define db(...) true
#define RNG() true
#endif

template<class T>
void _db(const char *dbStr, T e) {
	cout << dbStr << " = " << e << endl;
}
template<class T, class... L>
void _db(const char *dbStr, T e, L... r) {
  while(*dbStr != ',') cout << *dbStr++;
  cout << " = " << e << ','; _db(dbStr + 1, r...);
}
template<class S, class T>
ostream& operator<<(ostream& o, const map<S, T>& v) {
	o << "["; int i = 0;
	for (const pair<S, T>& pr : v) o << (!i++ ? "" : ", ") << "{"
	<< pr.fs << " : " << pr.sc << "}"; return o << "]";
}
template<template <class, class...> class S, class T, class... L>
ostream& operator<<(ostream& o, const S<T, L...>& v) {
	o << "["; int i = 0;
	for (const auto& e : v) o << (!i++ ? "" : ", ") << e;
	return o << "]";
}
template<class S, class T>
ostream& operator<<(ostream& o, const pair<S, T>& pr) {
	return o << "(" << pr.fs << ", " << pr.sc << ")";
}
ostream& operator<<(ostream& o, const string& s) {
	for (const char& c : s) o << c;
	return o;
}

template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;
template<class T> using VVV = VV<V<T>>;
using ll = long long;
using pii = pair<int, int>;
using vi = V<int>;
using vii = V<pii>;
using vvi = VV<int>;
using mii = map<int, int>;
using umii = unordered_map<int, int>;
using si = set<int>;
using usi = unordered_set<int>;


int N, M, v, P;
vi a;

bool good(int x) {
	vi b(1);
	ll left = (v - 1) * 1LL * M;
	for (int i = 1; i <= N; ++i) {
		if (i != x)
			b.pb(a[i]);
	}

	db(x, b);


	if (b[N - P] > a[x] + M)
		return false;

	left -= (P - 1) * 1LL * M;

	db(left);

	if (left <= 0)
		return true;



	for (int i = 1; i <= N - P; ++i) {
		if (b[i] > a[x] + M)
			return false;
		left -= min(M, a[x] + M - b[i]);
	}

	if (left <= 0)
		return true;
	return false;
}


int main() {
	#ifdef LOCAL
	auto stTime = clock();
//	freopen("in.txt", "r", stdin);
	mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
	#endif
	ios::sync_with_stdio(false);
	cout.precision(10);
	cin.tie(0);

	cin >> N >> M >> v >> P;

	a.assign(N + 1, 0);

	for (int i = 1; i <= N; ++i) {
		cin >> a[i];
	}

	sort(a.begin() + 1, a.end());

	db(a);

	int lo = 1, hi = N;

	while (lo < hi) {
		int mid = (lo + hi) / 2;

		if (good(mid))
			hi = mid;
		else
			lo = mid + 1;
	}

	db(lo);

	cout << N - lo + 1 << '\n';



	#ifdef LOCAL
	cout << "\n\n\nExecution time: " <<
		(clock() - stTime) * 1e3 / CLOCKS_PER_SEC << " ms" << endl;
	#endif
    return 0;
}


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

int main() {
    int A,B;
    cin >> A >> B;
    if(A>=13) cout << B << endl;
    else if(A<=12 && A>=6) cout << B/2 << endl;
    else cout << "0" << endl;
    return 0;
}


Measured memory_bytes: 256
import sys

def main():
    line = sys.stdin.readline()
    lst = line.split()
    a = int(lst[0])
    b = int(lst[1])
    c = int(lst[2])

    if a == 1:
        print("YES")
        return 0

    mod = a % b
    sys.stderr.write(str(mod) + "\n")
    mod_lst = [mod]
    tmp_num = a + a

    while True:
        mod = tmp_num % b
        if mod in mod_lst:
            # sys.stderr.write("--\n")
            # sys.stderr.write(str(mod) + "\n")
            # sys.stderr.write(str(mod_lst) + "\n")
            break
        else:
            # sys.stderr.write(str(mod) + "\n")
            mod_lst.append(mod)
            tmp_num += a

    if c in mod_lst:
        print("YES")
    else:
        print("NO")

    return 0

if __name__ == '__main__':
    sys.exit(main())


Measured memory_bytes: 3064
#!/usr/bin/python

import sys

def main(argv):
    line = sys.stdin.readline()
    while line:
        N, K = line.rstrip("\n").split(" ", 2)
        N = int(N)
        K = int(K)
        A = map(
          lambda a: int(a), sys.stdin.readline().rstrip("\n").split(" "))
        
        histogram = {}
        for a in A:
            if a not in histogram:
                histogram[a] = 0
            histogram[a] += 1

        if K >= len(histogram):
            print 0
        else:
            diff = len(histogram) - K
            print sum(sorted(histogram.values())[0:diff])

        line = sys.stdin.readline()

if __name__ == "__main__":
    main(sys.argv)

Measured memory_bytes: 28988
#include<stdio.h>
int main(void)
{
	int K,c,x;
	int sum=0;

	while(1){
		scanf("%d",&K);
		if( K==0 )
			break;
		else{
			c=K*(K-1)/2;

			while(c--){
				scanf("%d",&x);
				sum+=x;
			}
			printf("%d\n",sum/(K-1));
			sum=0;
		}
	}
	return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <array>

std::array<int, 100005> p;
std::array<int, 100005> fa;

int find(int x){return fa[x]^x?fa[x]=find(fa[x]):x;}

int main()
{
    int n, m;
    std::cin >> n >> m;
    for (int i = 0; i < n; ++i)
    {
        int temp;
        std::cin >> temp;
        p[i] = temp;
        fa[i] = i;
    }

    for (int i = 0; i < m; ++i)
    {
        int u, v;
        std::cin >> u >> v;

        fa[find(u)] = find(v);
    }

    int count = 0;
    for (int i = 1; i <= n; ++i)
    {
        if (find(p[i - 1]) == find(i))
        {
            count++;
        }
    }
    std::cout << count << std::endl;
}


Measured memory_bytes: 1024
def main():
    H, W, M = [int(s) for s in input().split()]
    cols = [0] * W
    rows = [0] * H
    bombs = set()
    for _ in range(M):
        x, y = [int(s)-1 for s in input().split()]
        bombs.add((x, y))
        cols[y] += 1
        rows[x] += 1

    sc = sorted([(c, i) for i, c in enumerate(cols)], reverse=True)
    sr = sorted([(c, i) for i, c in enumerate(rows)], reverse=True)
    best = 0
    for v1, c in sc:
        for v2, r in sr:
            if v1 + v2 <= best:
                break
            score = v1 + v2
            if (r, c) in bombs:
                score -= 1
            best = max(best, score)
    print(best)

main()

Measured memory_bytes: 179752
class Dice :
    def __init__(self,num):
        self.num = num

    def move_E(self):
        self.copy = self.num.copy() 
        for i,j in zip([0,2,5,3],[3,0,2,5]):
            self.num[i] = self.copy[j]

    def move_W(self):
        self.copy = self.num.copy()
        for i,j in zip([0,3,5,2],[2,0,3,5]):
            self.num[i] = self.copy[j]

    def move_N(self):
        self.copy = self.num.copy()
        for i,j in zip([0,1,5,4],[1,5,4,0]):
            self.num[i] = self.copy[j]

    def move_S(self):
        self.copy = self.num.copy()
        for i,j in zip([0,1,5,4],[4,0,1,5]):
            self.num[i] = self.copy[j]



number = list(map(int,input().split()))
#number = [1,2,4,8,16,32]
#print("1 2 3 4 5 6")
# ?????????????????????
dice = Dice(number)

for order in input():
    if order == 'S':
        dice.move_S()
    elif order == 'N':
        dice.move_N()
    elif order == 'W':
        dice.move_W()
    else:
        dice.move_E()

# ?????????????????¶????????????
#print(dice.num)

print(dice.num[0])

Measured memory_bytes: 7816
#include<bits/stdc++.h>
#define fo(i, x, y) for(int i = x, B = y; i <= B; i ++)
#define ff(i, x, y) for(int i = x, B = y; i <  B; i ++)
#define fd(i, x, y) for(int i = x, B = y; i >= B; i --)
#define ll long long
#define pp printf
#define hh pp("\n")
using namespace std;

const int N = 3e5 + 5;

int n, L;
int a[N], b[N], c[N], l[N], r[N];
int ans;

int main() {
	scanf("%d %d", &n, &L);
	fo(i, 1, n) scanf("%d", &a[i]);
	fo(i, 1, n) {
		scanf("%d", &b[i]);
		ans += b[i] / (2 * L);
		b[i] %= 2 * L;
		if(!b[i]) c[i] = 1; else {
			ans ++;
			l[i] = 2 * a[i] >= b[i];
			r[i] = 2 * (L - a[i]) >= b[i];
			if(!l[i] && !r[i]) c[i] = 1;
		}  
	}
	int t = 1;
	while(t < n && !(l[t] == 1 && r[t] == 0)) t ++;
	int z = 0, tt = 0;
	fo(i, 1, t - 1) if(!c[i]) {
		if(l[i] == 0) {
			if(z) z --, ans --; 
		} else z ++;
	}
	tt += z, z = 0;
	fd(i, n - 1, t) if(!c[i]) {
		if(r[i] == 0) {
			if(z) z --, ans --;
		} else z ++;
	}
	ans -= (tt + z) / 2;
	if(!r[n]) ans ++;
	pp("%lld\n", (ll) ans * 2 * L);
}

Measured memory_bytes: 6144
#pragma GCC optimize ("O2")
    #pragma GCC diagnostic ignored "-Wunused-variable"
    #pragma GCC diagnostic ignored "-Wunused-result"
    #pragma GCC diagnostic ignored "-Wunused-label"
    #pragma GCC diagnostic ignored "-Wsign-compare"
     
    #include <bits/stdc++.h>
    using namespace std;
     
    #define trav(a, A) for (auto & a : A)
    #define f first
    #define s second
     
    typedef long long ll;
     
    const ll MOD = 1e+9+7;
    const ll INFLL = 0x3f3f3f3f3f3f3f3f;
    const int INF = 0x3f3f3f3f;
    const ll MAXN = 1e+5+7;
     
    int main ()
    {
    	ios_base::sync_with_stdio (0);
    	cin.tie (0);
    	int tc = 1; //cin >> tc;
    	while (tc--)
    	{
    		ll i, j, n, p;
    		string s;
    		cin >> n >> p >> s;
    		vector <ll> dp (p, 0);
    		ll sum = 0, ans = 0, pot = 1;
    		if (p == 2 || p == 5)
    		{
    			for (i = 0; i < s.size (); ++i)
    				if ((s[i] - '0')%p == 0) ans += i + 1;
    		}
    		else
    		{
    			for (i = s.size () - 1; i >= 0; --i)
    			{
    				sum = (sum + pot*(ll)(s[i] - '0')) % p;
    				if (sum == 0) ++ans;
    				ans += dp[sum]++;
    				pot = pot*10LL%p;
    			}
    		}
    		cout << ans << '\n';
    	}
     
    	return 0;
    }
     

Measured memory_bytes: 720
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define ll long long
#define rep(i,n) for(int i = 0; i < int(n); i++)
#define vi vector<int>
using namespace std;
const int INF = 1001001001;
const int MOD = 1e9+7;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }

int main(){
  cin.tie(0), ios::sync_with_stdio(false);
  int n; cin >> n;
  set<pair<int,int>,greater<pair<int,int>>> red;
  set<pair<int,int>> blue;
  rep(i,n){
    int a,b; cin >> a >> b;
    red.insert({a,b});
  }
  rep(i,n){
    int c,d; cin >> c >> d;
    blue.insert({c,d});
  }
  set<pair<int,int>> used;
  for(auto r : red){
    int x = INF, y = INF;
    for(auto b : blue){
      if(used.count({b.first,b.second})) continue;
      if(r.first < b.first && r.second < b.second){
        if(chmin(y,b.second)) x = b.first;
      }
    }
    if(x != INF) used.insert({x,y});
  }
  cout << used.size();
  cout << "\n";
  return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,A,B;
  cin >> N >> A >> B;
  int p1 = A * N;
  if (p1 < B) {
    cout << p1 << endl;
  }
  else{
    cout << B << endl;
}
}

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

import static java.lang.Math.*;

public class Main {


    public static void main(String[] args) {
        try (CustomReader in = new CustomReader()) {
            new Main().execute(in);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }


    public void execute(CustomReader in) throws IOException {
        final String S = in.readLine();
        final long K = Long.parseLong(in.readLine());
        char ans = '1';

        for (int i = 0; i < K && i< S.length(); i++) {
            if(S.charAt(i) != '1'){
                ans = S.charAt(i);
                break;
            }
        }
        System.out.println(ans);
    }


    static class CustomReader extends BufferedReader {
        public CustomReader() throws IOException {
            super(new InputStreamReader(System.in));
        }

        public int readLineAsInt() throws IOException {
            return Integer.parseInt(readLine());
        }

        public int[] readLineAsIntArray() throws IOException {
            String[] strArray = this.readLine().split(" ");
            int[] intArray = new int[strArray.length];
            for (int i = 0, n = strArray.length; i < n; i++) {
                intArray[i] = Integer.parseInt(strArray[i]);
            }
            return intArray;
        }

        public int[][] readAsIntMatrix(int rows, int columns) throws IOException {
            int[][] matrix = new int[rows][columns];
            for (int i = 0; i < rows; i++) {
                String[] r = this.readLine().split(" ");
                for (int j = 0; j < columns; j++) {
                    matrix[i][j] = Integer.parseInt(r[j]);
                }
            }
            return matrix;
        }

        public char[][] readAsCharMatrix(int rows) throws IOException {
            char[][] matrix = new char[rows][];
            for (int i = 0; i < rows; i++) {
                matrix[i] = this.readLine().toCharArray();
            }
            return matrix;
        }

    }

}

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

int main()
{
	ll a,b,c,k;cin>>a>>b>>c>>k;
	ll sum=0;
	if(k>=a)
	{
		sum+=a;
		k-=a;
	}
	else if(k<a)
	{
		sum+=k;
		cout << sum <<"\n";
		return 0;
	}
	if(k)
	{
		k-=b;
	}
	if(k>0)
	{
		sum-=k;
	}
	cout << sum <<"\n";
}

Measured memory_bytes: 3632
//author:satwik_bhv1
#include<bits/stdc++.h>
//datatypes
#define ll long long 
#define ld long double
//loops
#define fr(i,z,n) for(ll i=z;i<n;i++)
#define br(i,z,n) for(ll i=z;i>n;i--)
//operations
#define mp  make_pair
#define ff  first
#define ss  second
#define pub push_back
#define all(v) v.begin(),v.end()
//map
#define mi map<ll,ll>
//vectors
#define vi vector<ll>
#define vpi vector<pair<ll,ll> >
//constants
#define pi 3.1415926535897932384626
#define mod 1000000007 
#define MAXN 100001
/*notes
    Don't use inbuilt fun for power
    Range of longlong=(-9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 )
    INT_MAX = 2147483647(aprox 2*10^10)
    INT_MIN = -2147483648
    LLONG_MAX = 9223372036854775807 
    LLONG_MIN = -9223372036854775808
    __gcd is the function in built for hcf
    priority queue is max heap by default
    topological sort -> khan's algo use bfs and indegree of node  
    sssp(positive weighted edges) -> Dijkstras
    apsp -> Floydwarshall
    MST -> kruskal(DSU)
*/
using namespace std;
//functions
ll power(ll x,ll y){ll res=1;while(y){if(y%2){res*=x;}y/=2;x*=x;} return res;}
ll power(ll x,ll y,ll z){ll res=1;while(y){if(y%2){res=(res*x)%z;}y/=2;x=(x*x)%z;} return res;}
void fast() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); }
bool sortbysec(const pair<ll, ll>& a, const pair<ll, ll>& b) { return (a.second > b.second); }
ll ceil(ll x,ll y){return (x/y)+(x%y!=0);}
vi dp;
ll n;
vi v;
ll fun(ll ind)
{
    if(ind==n-1)
    {
        return dp[ind]=0;
    }
    if(ind>n-1)
    {
        return -1;
    }
    if(dp[ind]!=-1)
    {
        return dp[ind];
    }
    ll l=LLONG_MAX,r=LLONG_MAX;
    if(fun(ind+1)!=-1)
    {
        l=abs(v[ind]-v[ind+1])+dp[ind+1];
    }
    if(fun(ind+2)!=-1)
    {
        r=abs(v[ind]-v[ind+2])+dp[ind+2];
    }
    return dp[ind]=min(l,r);
}
void solve()
{
    cin>>n;
    fr(i,0,n)
    {
        ll o;
        cin>>o;
        v.pub(o);
        dp.pub(-1);
    }
    cout<<fun(0);
}
int main()
{
    fast();
    ll t;
    t=1;
    //cin>>t;
    fr(i,0,t)
    {
        solve();
    }
}
/*





























*/


Measured memory_bytes: 8048
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE Rank2Types #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE BangPatterns #-}

-- Default Imports

import Control.Monad
import Control.Monad.ST
import Control.Monad.Trans.Class

import qualified Control.Monad.Reader as Reader
import Control.Monad.Reader (Reader, ReaderT, runReader, runReaderT)

import qualified Data.Array.MArray as MArray
import qualified Data.Array.ST as STArray
import Data.Array.ST (STArray, STUArray, runSTArray, runSTUArray)
import Data.Ix (Ix)

import qualified Data.Bits as Bits
import Data.Bits ((.&.), (.|.))

import qualified Data.ByteString.Char8 as BS
import Data.ByteString.Char8 (ByteString)

import qualified Data.Char as Char
import qualified Data.List as List
import qualified Data.Map as Map
import Data.Map (Map)
import qualified Data.Maybe as Maybe
import qualified Data.Set as Set
import Data.Set (Set)

import qualified Data.Vector as Vector
import qualified Data.Vector.Generic as GVector
import qualified Data.Vector.Mutable as MVector
import Data.Vector.Mutable (STVector)
import qualified Data.Vector.Unboxed as UVector

import Numeric

import Debug.Trace
-- ----------

-- Custom Import Here


-- ----------

-- Default Definitions

type Vector = Vector.Vector
-- type GVector = GVector.Vector
type UVector = UVector.Vector

readIntToList :: ByteString -> [Int]
readIntToList = List.unfoldr (fmap (second $ BS.dropWhile Char.isSpace) . BS.readInt)

readToList :: Read a => ByteString -> [a]
readToList = List.unfoldr $ fmap (mapTaken . mapRemain) . span' (not . Char.isSpace)
	where
		mapTaken  = first $ read . BS.unpack
		mapRemain = second $ BS.dropWhile Char.isSpace
		span' pred s
			| BS.null taken = Nothing
			| otherwise     = Just (taken, remain')
			where
				(taken, remain) = BS.span pred s
				remain' = BS.dropWhile Char.isSpace remain

readToListN :: Read a => Int -> ByteString -> [a]
readToListN n = take n . readToList

readIntToVector :: ByteString -> Vector Int
readIntToVector = Vector.unfoldr (fmap stripRemain . BS.readInt)
	where stripRemain = second $ BS.dropWhile Char.isSpace

readIntToUVector :: ByteString -> UVector.Vector Int
readIntToUVector = UVector.unfoldr (fmap stripRemain . BS.readInt)
	where stripRemain = second $ BS.dropWhile Char.isSpace

readIntToVectorN :: Int -> ByteString -> Vector.Vector Int
readIntToVectorN n = Vector.unfoldrN n (fmap stripRemain . BS.readInt)
	where stripRemain = second $ BS.dropWhile Char.isSpace

readIntToUVectorN :: Int -> ByteString -> UVector.Vector Int
readIntToUVectorN n = UVector.unfoldrN n (fmap stripRemain . BS.readInt)
	where stripRemain = second $ BS.dropWhile Char.isSpace


first :: (a -> a') -> (a, b) -> (a', b)
first f (a, b) = (f a, b)

second :: (b -> b') -> (a, b) -> (a, b')
second f (a, b) = (a, f b)

average :: Fractional a => [a] -> a
average xs = sum xs / (fromIntegral . length) xs

-- ----------

main :: IO ()
main = do
	[a, b] <- readIntToList <$> BS.getLine
	putStrLn $ if a == b then "Yes" else "No"


Measured memory_bytes: 380
#![allow(non_snake_case)]
#![allow(unused_imports)]

use proconio::{input, fastout};
use proconio::marker::*;
use whiteread::parse_line;
use std::collections::*;
use num::*;

use itertools::Itertools;
use itertools_num::ItertoolsNum;

#[fastout]
fn main() {
    input!{
        n: usize,
        k: usize,
        mut a_vec: [isize; n],
    }
    let mut ans_vec;
    for _ in 0..k {
        ans_vec = vec![0; n+1];
        for i in 0..n {
            let tmp = a_vec[i];
            let start = if i as isize - tmp <= 0 {
                0
            } else {
                i as isize - tmp
            };
            let end = if (n - i) as isize - tmp <= 0 {
                n as isize
            } else {
                i as isize + tmp + 1
            };
            // dbg!(&start, &end);
            ans_vec[start as usize] += 1;
            ans_vec[end as usize] -= 1;
            // dbg!(&ans_vec);
        }
        a_vec = ans_vec.iter().cumsum().collect::<Vec<isize>>()[..n].to_vec();
        if a_vec.iter().all(|&x| x == n as isize) { break; }
    }



    for a in a_vec.iter() {
        println!("{}", a);
    }
}


Measured memory_bytes: 9500
*a,=sorted(map(int,input().split()))
a1=abs(a[1]-a[0])+abs(a[2]-a[1])
a2=abs(a[2]-a[0])+abs(a[1]-a[2])
a3=abs(a[0]-a[1])+abs(a[2]-a[0])
a4=abs(a[2]-a[1])+abs(a[0]-a[2])
a5=abs(a[0]-a[2])+abs(a[1]-a[0])
a6=abs(a[1]-a[2])+abs(a[0]-a[1])
print(min([a1,a2,a3,a4,a5,a6]))

Measured memory_bytes: 3064
#include<stdio.h>

int main(){
    int a,b;
    scanf("%d %d",&a,&b);
    if (a<b)
    {
        printf("a < b");
    }
    else if (a > b){
        printf("a > b");
    }
    else if (a == b)
    {
        printf("a == b");
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 2076
N = int(input())
A_lst  = list(map(int, input().split()))
                                                                                                                                                                                                                                              
count = 0
while True:
    A_lst = [a//2 for a in A_lst if a%2 == 0]
    if len(A_lst) != N:
        break
    count += 1
print(count)

Measured memory_bytes: 3060
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#include <algorithm>
#include <functional>
#include <string>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstring>
using namespace std;
#define U(v) \
cerr << #v << ": " << (v) << endl

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    for (int& i : A)
        cin >> i;
    long long ct = 0;
    for (int i = 0; i < N; ++i) {
        ct += A[i] / 2;
        A[i] %= 2;
        if (i < N - 1) {
            int mn = min(A[i], A[i + 1]);
            ct += mn;
            A[i] -= mn;
            A[i + 1] -= mn;
        }
    }
    cout << ct << endl;
    return 0;
}


Measured memory_bytes: 768
#include<stdio.h>
#include<stdlib.h>
#include<string>
#include<math.h>
#include<iostream>
using namespace std;
string s;
long long times[50]={0};
int main()
{
	cin>> s;
	long long len=s.size();
	long long sum=(len*(len-1)/2);
	for(int i=0;i<len;i++)
		times[s[i]-'a']++;
	for(int i=0;i<=40;i++)
		sum-=((times[i]-1)*times[i]/2);
	printf("%lld\n",1+sum);
	return 0;
 } 

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

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
const long long LINF = 1LL<<60;
long long MOD;

long long mod_pow(long long x_, long long y_){
    if(y_ == 0) return 1;
    long long res = mod_pow(x_ * x_ % MOD, y_ / 2);
    if(y_ & 1) res =  x_ * res % MOD;
    return res;
}

int main(){
    ll n, p, ans = 0;
    string s;
    cin >> n >> p >> s;
    MOD = p;
    if(p == 2 || p == 5){
        for(int i = 0; i < n; i++){
            if((s[i] - '0') % p == 0){
                ans += i + 1;
            }
        }
    }else{
        s += "0";
        map<ll, int> mp;
        mp[0]++;
        vector<ll> r(n + 1);
        int cnt = 0;
        for(int i = n - 1; i >= 0; i--){
            r[i] = (s[i] - '0') * mod_pow(10, cnt++) + r[i + 1];
            r[i] %= MOD;
            ans += mp[r[i]];
            mp[r[i]]++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2564
#include<bits/stdc++.h>
#define ll long long int
#define mk make_pair
#define pb push_back
#define INF (ll)1e18
#define pii pair<ll,ll>
#define mod 1000000007 //998244353
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fb(i,a,b) for(ll i=a;i>b;i--)
#define ff first
#define ss second
#define srt(v)  if(!v.empty())sort(v.begin(),v.end())
#define PI 3.141592653589793238
#define pq priority_queue<ll>
#define pqr priority_queue<ll,vector<ll>,greater<ll>()>
using namespace std;
ll pow_mod(ll a,ll b)
{
	ll res=1;
	while(b!=0)
	{
		if(b&1)
		{
			res=(res*a)%mod;
		}
		a=(a*a)%mod;
		b/=2;
	}
	return res;
}
void solve()
{
  ll n;
  cin>>n;
  
  pii p[n];
  
  for(ll i=0;i<n;i++)
  cin>>p[i].ff>>p[i].ss;
  
  bool f=false;
  
  for(ll i=0;i+2<n;i++){
      if(p[i].ff==p[i].ss&&p[i+1].ff==p[i+1].ss&&p[i+2].ff==p[i+2].ss){
          f=true;
      }
  }
  if(f)
  cout<<"Yes\n";
  else
  cout<<"No\n";
  
}
int32_t main()
{    ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     cout.tie(NULL);
     
//Start from Here.

  ll t;
  t=1;
 // cin>>t;
  while(t--)
  solve();
  
//Good Bye!
    return 0;
}

Measured memory_bytes: 3648
/**
 * Created by hiroqn on 13/10/14.
 */
var fs = require('fs'),
    length = fs.fstatSync(process.stdin.fd).size,
    buffer = new Buffer(length),
    bytesRead = fs.readSync(process.stdin.fd, buffer, 0, length, 0),
    input = buffer.toString('utf8', 0, bytesRead).split('\n');
main();
function main() {
  var sum,
      coins,
      fa = [10, 50, 100, 500],
      amount,
      t,
      i,
      f = true;
  while (true) {
    sum = +input.shift();
    if (sum === 0) {
      break;
    } else {
      if (!f) {
        console.log('');
      }
    }
    coins = input.shift().split(' ').map(Number);
    amount = 0;
    for (i = 0; i < 4; i++) {
      amount += coins[i] * fa[i];
    }
    amount -= sum;
    for (i = 3; i >= 0; i--) {
      t = ~~(amount / fa[i]);
//      console.log(coins, t, amount);
      t = coins[i] < t ? coins[i] : t;
      coins[i] = coins[i] - t;
      amount %= fa[i];
    }

    for (i = 0; i < 4; i++) {
      if (coins[i] > 0) {
        console.log(fa[i] + ' ' + coins[i]);
      }
    }
    f = false;
  }
}

Measured memory_bytes: 12068
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
#define all(x) (x).begin(), (x).end()
#define fsp(x) fixed << setprecision(x)
const ll inf = LLONG_MAX;
const long double pi = acos(-1);
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
	//ios::sync_with_stdio(false);
	//cin.tie(nullptr);
	//const ll p = 1e9 + 7;
	//const ll p = 998244353;

	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	string ans;
	for (ll i = 0; i < c - a; i++) ans.push_back('R');
	for (ll i = 0; i < d - b; i++) ans.push_back('U');
	for (ll i = 0; i < c - a; i++) ans.push_back('L');
	for (ll i = 0; i < d - b; i++) ans.push_back('D');
	ans.push_back('D');
	for (ll i = 0; i < c - a + 1; i++) ans.push_back('R');
	for (ll i = 0; i < d - b + 1; i++) ans.push_back('U');
	ans.push_back('L');
	ans.push_back('U');
	for (ll i = 0; i < c - a + 1; i++) ans.push_back('L');
	for (ll i = 0; i < d - b + 1; i++) ans.push_back('D');
	ans.push_back('R');
	cout << ans << endl;
}


Measured memory_bytes: 256
# Input Candidates

def compare(x, y):
    if x[1] == y[1]:
        return cmp(x[0], y[0])
    else:
        return cmp(x[1], y[1]) * -1


while True:
    n = int(raw_input())
    if n == 0:
        break

    dic = {}
    for i in range(n):
        words = raw_input().strip().split()
        for word in words:
            dic[word] = dic.setdefault(word, 0) + 1

    candidate = []
    key = raw_input().strip()
    for k, v in dic.items():
        if k.startswith(key):
            candidate.append((k, v))

    candidate.sort(compare)

    if candidate:
        print ' '.join([word[0] for word in candidate[:5]])
    else:
        print 'NA'

Measured memory_bytes: 4272
#include <bits/stdc++.h>
#define int long long
const int INF = 1e18L + 5;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using namespace std;

signed main() {

    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n, d;
    cin >> n >> d;
    vector<vector<int>> a(n,vector<int>(d));
    rep(i,n) rep(j,d) cin >> a[i][j];

    int cnt = 0;
    rep(i,n) rep(j,i) {
        int sum = 0;
        rep(k,d) sum += (a[i][k]-a[j][k])*(a[i][k]-a[j][k]);
        //sumが平方数になるか調べる
        bool ok = false;
        rep(i,sqrtl(sum)+1){
            if (i * i == sum) ok = true;
        }
        if (ok) cnt++;
    }
    cout << cnt << endl;
    
    return 0;
}

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

int main(){
    int N;
    cin >> N;
    int d = 2;
    while ((N >> d) != 0) d++;
    vector<pair<pair<int, int>, int>> ans;
    for (int i = 1; i <= 19; i++) ans.push_back({{i, i+1}, 0});
    for (int i = 1; i < d; i++) ans.push_back({{i, i+1}, (1 << (i-1))});
    int t = (1 << (d-1));
    for (int i = 19; i >= 1; i--) {
        if (t + ((1 << (i-1)) - 1) < N) {
            ans.push_back({{i, 20}, t});
            t += (1 << (i-1));
        }
    }
    cout << 20 << " " << ans.size() << endl;
    for (auto p : ans) {
        cout << p.first.first << " " << p.first.second << " " << p.second << endl;
    }
    return 0;
}

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

ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a, ll b){
    ll g=gcd(a,b);
    return a/g*b;
}
ll rep_jijo(ll n,ll x){
    if(x==0) return 1;
    if(x%2==0){
        ll t =rep_jijo(n,x/2);
        return t*t%mod;
  }
  return n*rep_jijo(n,x-1)%mod;
}
ll c2(ll n){
    return n*(n-1)/2;
}

int main(){
ll n;
cin>>n;
ll m=n;
ll k=0;
while(m>=26){
    m/=26;
    k++;
}
vcl a(k+1);
stack<char> q;
rep(i,k+1){
    a[i]=n%26;
    if(a[i]==0 && i!=k){
        a[i]=26;
    }
    n-=a[i];
    n/=26;
        if (a[i]==1) q.push('a');
   else if (a[i]==2) q.push('b');
   else if (a[i]==3) q.push('c');
   else if (a[i]==4) q.push('d');
   else if (a[i]==5) q.push('e');
   else if (a[i]==6) q.push('f');
   else if (a[i]==7) q.push('g');
   else if (a[i]==8) q.push('h');
   else if (a[i]==9) q.push('i');
   else if (a[i]==10) q.push('j');
   else if (a[i]==11) q.push('k');
   else if (a[i]==12) q.push('l');
   else if (a[i]==13) q.push('m');
   else if (a[i]==14) q.push('n');
   else if (a[i]==15) q.push('o');
   else if (a[i]==16) q.push('p');
   else if (a[i]==17) q.push('q');
   else if (a[i]==18) q.push('r');
   else if (a[i]==19) q.push('s');
   else if (a[i]==20) q.push('t');
   else if (a[i]==21) q.push('u');
   else if (a[i]==22) q.push('v');
   else if (a[i]==23) q.push('w');
   else if (a[i]==24) q.push('x');
   else if (a[i]==25) q.push('y');
   else if (a[i]==26) q.push('z');

}
 while (!q.empty()) {
    cout << q.top() ;  
    q.pop();  
  }
  cout<<endl;
}

Measured memory_bytes: 3636
def main():
    import sys
    input = sys.stdin.readline
    n = int(input())
    a = list(map(int, input().split()))
    a.reverse()
    mod = 7 + 10**9
    leng = len(format(max(a), 'b'))
    bit_acc = [0 for i in range(leng)]
    for i in range(n):
        #先頭から二進数を0埋めした
        bit_data = format(a[i], 'b').zfill(leng)
        for j in range(leng):
            if bit_data[j] == '1':
                bit_acc[j] += 1
    ans = 0
    p = [pow(2,leng - 1 - j, mod) for j in range(leng)]
    for i in range(n):
        bit_data = format(a[i], 'b').zfill(leng)
        for j in range(leng):
            if bit_data[j] == '1':
                ans += (n - bit_acc[j]) * p[j]
            else:
                ans += bit_acc[j] * p[j]
            ans %= mod
    print((ans * 500000004) % mod)
if __name__ == "__main__":
    main()   




Measured memory_bytes: 123084
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue>
#include <algorithm>
#include<iostream>
#include<vector>
#include<map>
#include<string>
#include <iomanip>
#include<deque>
#include<stack>
#include<set>
#include <numeric>

using namespace std;
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;
const int INF = 111111111;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const int DIV = 1000000007; //10^9 + 7
const double PI = 3.14159265358979323846264338327950288;



int main() {

	//==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	//==================================

	ll N, M;
	vector<ll> A;
	vector<pair <ll, ll>> change;

	cin >> N >> M;
	for (ll i = 0; i < N; i++) {
		ll a;
		cin >> a;
		A.emplace_back(a);
	}
	sort(A.begin(), A.end());

	for (ll i = 0; i < M; i++) {
		ll b, c;
		cin >> b >> c;
		change.emplace_back(c, b);
	}
	
	sort(change.begin(), change.end(),greater<pair<ll,ll>>());
	
	vector<ll> ruiseki;
	ruiseki.emplace_back(change[0].second);
	for (ll i = 1; i < M; i++) {
		ruiseki.emplace_back(ruiseki[i - 1] + change[i].second);
	}


	ll idx = 0;
	for (ll i = 0; i < N; i++) {
		if (ruiseki[idx] <= i) {
			idx++;
			if (idx >= M) {
				break;
			}
		}

		if (change[idx].first > A[i]) {
			A[i] = change[idx].first;
		}
	}

	ll ans = 0;
	for (ll i = 0; i < N; i++) {
		ans += A[i];
	}

	cout << ans;

}





Measured memory_bytes: 4464
object methods {
  def solver: Unit = {

    val tempList: Seq[Seq[String]] = {
      for(line <- io.Source.stdin.getLines()) yield {
        line.split(' ').toSeq
      }
    }.toSeq

    val N: Int = tempList(0)(0).toInt
    val K: Int = tempList(0)(1).toInt
    val priceSeqSorted: Seq[Int] = tempList(1).map(_.toInt).sorted

    val kTakePrice: Seq[Int] = priceSeqSorted.take(K)
    val kTakePriceSum: Int = kTakePrice.sum 
    
    println(kTakePriceSum)
  }
}

object Main extends App {
  methods.solver
}

Measured memory_bytes: 55108
//If you are reading this then you are at wrong place.
#include<bits/stdc++.h>
#define mod 1000000007
#define lli long long int
using namespace std;
bool prime [1000001];
void debug(lli a){cout<<a<<endl;}
lli sieve(lli a){memset(prime,true,sizeof(prime));lli p,i;for(p=2;p*p<=a;p++){if(prime[p]==true){for(i=p*2;i<=a;i+=p)prime[i]=false;}}return 0;}
lli powermod(lli _a,lli _b,lli _m){lli _r=1;while(_b){if(_b%2==1)_r=(_r*_a)%_m;_b/=2;_a=(_a*_a)%_m;}return _r;}
lli find_max(lli __a,lli __b){return __a^((__a^__b) & -(__a<__b));}
lli add(lli __a,lli __b,lli MOD){lli x = (__a+__b)%MOD; return x; }
lli mul(lli a,lli b,lli MOD){lli x = (a*b)%MOD; return x; }
lli sub(lli a,lli b,lli MOD){lli x = (a-b+MOD)%MOD; return x; }
lli div(lli a,lli b,lli MOD){lli x = a;lli y = powermod(b,MOD-2,MOD);lli res = (x*y)%MOD;return res;}
//97->a 122->z
//65-A
int main()
{
	//freopen("testcase.txt", "r", stdin);
 	//freopen("output.txt", "w", stdout);
	
	ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);	
	cout.precision(20);
	lli t,i,j;
	//cin>>t;
	//memset(dp, -1, sizeof dp);
	t=1;
	lli counter1=0;
	while(t--)
	{
		counter1++;
		int n,m;
		cin>>n>>m;
		n++;
		m++;
		cout<<n*m-2*(n-1)-2*(m-1)<<endl;
		
		//cout<<"Case #"<<counter1<<" ";
		//cout<<endl;	
	}	
}


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

#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(obj) (obj).begin(), (obj).end()
#define INF 1e9
#define LINF 1e18
typedef long long ll;


int main() {
    string N; cin >> N;
    int sum = 0;
    REP(i,N.size()){
        sum += N[i]-'0';
        sum %= 9;
    }

    cout << (sum==0?"Yes":"No") << endl;

    return 0;
}

Measured memory_bytes: 3724
import java.io.*;

class Main{
    
        public static int prime(int x){
            int k = 0;
            if(x == 1){
                k = 1;
            }else if(x % 2 == 0){
                k = 1;
            }
            for(int i = 3; i <= Math.sqrt(x); i += 2){
                if (x % i == 0){
                    k = 1;
                    break;
                }
            }
            if(x == 2){
                k = 0;
            }
                return k;
        }

    public static void main(String[] args){

        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        try {       
                    int N = Integer.parseInt(reader.readLine());;
                    

                    int[] a = new int[N];

                    for(int i = 0; i < N; i ++){
                        a[i] = Integer.parseInt(reader.readLine());
                    }

                    int count = 0;

                    for(int i = 0; i < a.length; i++){
                        if(prime(a[i]) == 0){
                            count += 1;
                        }
                    }

                    System.out.println(count);
                            
        } catch (IOException e) {
            //TODO: handle exception
            System.out.println(e);
        }
    }
}

Measured memory_bytes: 30408