akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
string s;
int k;
const int N = 110;
int f[N][4];
void init() {
    for(int i = 0; i < N; i ++) {
        for(int j = 0; j <= i && j < 4; j ++) {
            if(j == 0) f[i][j] = 1;
            else {
                f[i][j] = f[i-1][j] + f[i-1][j-1];
            }
        }
    }
}

int dp() {
    int res = 0;
    int last = 0;
    vector<int> bits;
    for (int i = s.size() - 1; i >= 0; i --) {
        bits.push_back(s[i] - '0');
    }
    for (int i = s.size() - 1; i >= 0; i --) {
        int bit = bits[i];
        if(bit > 0) {
            res += f[i][k-last]*pow(9,k-last);
            if(bit > 1) {
                if(k > last) res += (bit - 1)*f[i][k-1-last]*pow(9, k-1-last);
            }
            last ++;
            if(last > k) break;
        }
        if(i == 0 && last == k) res ++;
    }
    return res;
}

int main(){
    cin >> s >> k;
    init();
    cout << dp() << endl;
    return 0;
}

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

class Program
{
    static void Main(string[] args)
    {
        var N = long.Parse(ReadLine());
        var array = ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
        var cum = CumulativeSum(array).GroupBy(x=>x);
        long sum = 0;
        foreach (var item in cum)
        {
            sum += (long)item.Count() * (item.Count() - 1) / 2;
        }
        WriteLine(sum);
    }
    public static IEnumerable<long> CumulativeSum(IEnumerable<long> array)
    {
        yield return 0;
        long tmp = 0;
        foreach (var num in array)
            yield return tmp += num;
    }
}

Measured memory_bytes: 43516
use std::io::{ stdin, stdout, Write, BufRead };

fn main() {
  let mut buf = Vec::with_capacity(4);
  let len = {
    let stdin  = stdin();
    let mut reader = stdin.lock();
    reader.read_until(b'\n', &mut buf).unwrap()
  };

  let mut i = 0;
  while i < len - 1 {
    if buf[i] == b'1' {
      buf[i] = b'9';
    } else {
      buf[i] = b'1';
    }
    i += 1;
  }

  let stdout = stdout();
  let mut writer = stdout.lock();
  writer.write(&buf).unwrap();
  writer.flush().unwrap();
}


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

int main()
{
	ll n,a,b,c,d,e;
	cin >> n >> a >> b >> c >> d >> e;
	ll m = min(a,min(b,min(c,min(d,e))));
	ll ans = (n + m -1) / m + 4;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
//============================================================================
// Name        : e.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include<vector>
using namespace std;

int main() {
	int n,k;cin>>n>>k;
	vector<int> a(n-1),b(n-1);
	vector<vector<int>> e(n);
	for(int i=0;i<n-1;i++){
		cin>>a[i]>>b[i];
		a[i]--;
		b[i]--;
		e[a[i]].push_back(b[i]);
		e[b[i]].push_back(a[i]);
	}
	vector<long long> c(n,-1),f(n,0);

	vector<pair<int,int>> s;
	for(int i=0;i<e[0].size();i++){
		s.push_back(make_pair(0,e[0][i]));
	}
	c[0]=k;
	while(s.size()){
		auto tempe=s.back();
		s.pop_back();
		if(c[tempe.second]!=-1)continue;
		c[tempe.second]=k-1-f[tempe.first];
		f[tempe.first]++;
		f[tempe.second]++;
//		cout<<tempe.first<<' '<<tempe.second<<' '<<c[tempe.second]<<endl;
		for(int i=0;i<e[tempe.second].size();i++){
			s.push_back(make_pair(tempe.second,e[tempe.second][i]));
		}
	}
	long long def=1;
	for(int i=0;i<9;i++)def*=10;
	def+=7;
	long long ans=1;
	for(int i=0;i<n;i++){
		ans*=c[i];
		ans%=def;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 9592
//BISMILLAHIR RAHMANIR RAHIM
//RHYTHM_086_NS_01
//ALAN_IS_ON....

#include <bits/stdc++.h>

#define                boost_                         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define                iter_(i,n)                     for (int i = 0; i < int(n); i++)
#define                for_n(i, n)                    for (int i = 1; i <= int(n); i++)
#define                pb                             push_back
#define                mp                             make_pair
#define                itr                            ::iterator
#define                s_sort(s)                      sort(s.begin(),s.end())
#define                n_sort(a)                      sort(a,a+n)
#define                thank_you                      return 0
#define                precise_impact                 cout<<setprecision(10)<<fixed;

using namespace std;

typedef long long int ll;
typedef double db;
#define MOD 1000000007

ll bigmod(ll a,ll b){
    if(b==0){
        return 1;
    }
    ll tm=bigmod(a,b/2);
    tm=(tm*tm)%MOD;
    if(b%2==1)
        tm=(tm*a)%MOD;
    return tm;

}
void solve();


int main()
{
    boost_;
    precise_impact;
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    //Here we go...
    solve();

    thank_you;
}


void solve()
{

        int a,b,c;
        cin>>a>>b>>c;
        int tm=(b-a)/c;
        if(a%c==0||b%c==0){
            tm++;
        }
        cout<<tm<<endl;


}



Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define PI 3.1415926535897932384626
#define boost ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define MOD 1000000007
#define N 100101
#define forn(i,n) for(int i=0;i<n;i++)
#define all(x) x.begin(),x.end()
#define F first
#define S second
int main()
{
         boost;
         string s,t;
         cin>>s>>t;
         
         string temp=s+s;
         if(temp.find(t)!=string::npos)
         cout<<"Yes"<<endl;
         else
         cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
using ll = long long;

int main() {
  ll N, A, B;
  std::cin >> N >> A >> B;
  ll min{A * (N - 1) + B};
  ll max{B * (N - 1) + A};
  ll res = max - min + 1;
  std::cout << ((res >= 0ll) ? res : 0ll) << std::endl;
  return 0;
}

Measured memory_bytes: 256
#include "stdio.h"


int main(void){

	int N, A, B;

	scanf("%d%d%d", &N, &A, &B);

	if(N*A<B)
	{
		printf("%d", N*A);
	}
	else
	{
		printf("%d", B);
	}


	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0;i<n;++i)

typedef long long ll;
using namespace std;
int main(){
    cin.tie(0);
   	ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    vector<int> k = {};
    vector<int> sw(n, 0);
    int s[10][10] = {};
    REP(i, m){
        int x;
        cin >> x;
        k.push_back(x);
        REP(j, x){
            int y;
            cin >> y;
            --y;
            s[i][j] = y;
        }
    }
    int p[10] = {};
    REP(i, m){
        cin >> p[i];
    }

    int ans = 0;
    REP(i, pow(2, n)){
        bool flg = true;
        REP(j, m){
            int cnt = 0;
            REP(l, k[j]){
                //cout << s[j][l] << "\n";
                if((i & (1<<s[j][l]))==(1<<s[j][l]))++cnt;
            }
            if(cnt%2==p[j]){
            } else {
                flg = false;
            }
        }
        if(flg)++ans;
    }

    cout << ans << "\n";
    return 0;
}

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

using namespace std;

template<typename T>
struct Dijkstra {
    explicit Dijkstra(size_t size) : size(size), G(size) {}

    struct edge {
        edge(int to, T cost) : to(to), cost(cost) {}

        int to;
        T cost;
    };

    using P = pair<T, int>;
    const T inf = numeric_limits<T>::max();

    size_t size;
    vector<vector<edge>> G;
    vector<T> d;

    void add_edge(int u, int v, T c) {
        G[u].push_back(edge(v, c));
    }

    void build(int s) {
        d.assign(size, inf);
        priority_queue<P, vector<P>, greater<>> q;

        d[s] = 0;
        q.push(P(0, s));

        while (!q.empty()) {
            P p = q.top();
            q.pop();
            int v = p.second;
            if (d[v] < p.first) continue;
            for (auto &e : G[v])
                if (d[e.to] > p.first + e.cost) {
                    d[e.to] = p.first + e.cost;
                    q.push(P(d[e.to], e.to));
                }
        }
    }

    T operator[](int v) {
        return d[v];
    }
};

int main() {
    int V, E, r;
    cin >> V >> E >> r;

    auto g = Dijkstra<int>(V);
    for (int i = 0; i < E; ++i) {
        int s, t, c;
        cin >> s >> t >> c;
        g.add_edge(s, t, c);
    }

    g.build(r);
    for (int i = 0; i < V; ++i) {
        if (g[i] != g.inf) {
            cout << g[i] << endl;
        } else {
            cout << "INF" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 12928
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size)
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
using namespace std;
using lint = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main()
{
  string o,e,pass; cin >> o >> e;
  int i = 0;
  while(true){
    if(o[i] != false) cout << o[i];
    else break;
    if(e[i] != false) cout << e[i];
    else break;
    i++;
  }
    return 0;
}

Measured memory_bytes: 256
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

// You cant store primitive types in queue?

public class Main{
    public static void main(String[] args) {
        Queue<String> q = new LinkedList<>();

        Scanner input1 = new Scanner(System.in);
        int length = input1.nextInt();
        int QUANTUM = input1.nextInt();
        int totalTime=0;
        int result; // This is the time of each item
        String name;

        input1.nextLine();
        // Takes all the inputs and put into the queue
        for(int i=0;i<length;i++){
            q.add(input1.nextLine());
        }

        while (q.size()!=0){
            String removed = q.remove();
            String[] removeItem = removed.split(" ");

            name =removeItem[0];
            result = Integer.valueOf(removeItem[1])-QUANTUM;
            if (result >0){
                q.add(name+" "+result);
                totalTime += QUANTUM;
            }
            else{
                totalTime += result+QUANTUM;
                System.out.println(name+" "+totalTime);
            }

        }
    }
}



Measured memory_bytes: 104828
def d_cake_123_sort_modified(X, Y, Z, K, A, B, C):
    # editionalの解法1
    ab = sorted([a + b for b in B for a in A], reverse=True)[:K]
    ans = sorted([e + c for e in ab for c in C], reverse=True)[:K]
    return ' '.join(map(str, ans))

X, Y, Z, K = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
C = [int(i) for i in input().split()]
print(d_cake_123_sort_modified(X, Y, Z, K, A, B, C))

Measured memory_bytes: 138736
#include <iostream>
#include <cstdio>
#include <cmath>
#include <climits>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <queue>
#include <bitset>
#include <stack>

typedef long long ll;

const ll MAX_N = 1e3;
bool is_prime[MAX_N+1];
ll count[MAX_N+1];

int main(int argc, char* argv[])
{
  ll N;
  std::cin >> N;

  ll ans = 1;
  ll mod = 1e9 + 7;

  for (ll i = 2; i <= N; i++) {
    is_prime[i] = true;
    count[i] = 0;
  }
  for (ll i = 2; i <= N; i++) {
    if (is_prime[i]) {
      for (ll j = 2 * i; j <= N; j += i) {
	is_prime[j] = false;
      }
    }
  }

  //for (ll i = 2; i <= N; i++) {
  //  std::cout << "is_prime " << i << " " << is_prime[i] << std::endl;
  //}

  for (ll i = 2; i <= N; i++) {
    for (ll j = 2; j <= N; j++) {
      ll tmp = i;
      while (is_prime[j] && tmp % j == 0) {
	tmp /= j;
	count[j]++;
	//std::cout << i << " " << tmp << " " << j << " " << count[j] << std::endl;
      }
      if (tmp == 1) {
	break;
      }
    }
  }

  for (ll i = 2; i <= N; i++) {
    ans *= count[i] + 1;
    ans %= mod;
  }

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


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);
		while (true) {
			int n = scanner.nextInt();
			int m = scanner.nextInt();
			if (n == 0 && m == 0)
				break;
			int[][] map = new int[m][3];
			for (int i = 0; i < m; i++) {
				map[i][0] = scanner.nextInt();
				map[i][1] = scanner.nextInt();
				map[i][2] = scanner.nextInt();
			}
			Arrays.sort(map, new Comparator<int[]>() {
				@Override
				public int compare(int[] o1, int[] o2) {
					return o1[2] - o2[2];
				}
			});
			int[] p = new int[n];
			for (int i = 0; i < n; i++) {
				p[i] = i;
			}
			int ans = 0;
			for (int i = 0; i < m; i++) {
				int a = root(map[i][0], p);
				int b = root(map[i][1], p);
				if (a != b) {
					ans += map[i][2];
					p[a] = b;
				}
			}
			System.out.println(ans);
		}
	}

	private static int root(int a, int[] p) {
		if (a == p[a]) {
			return a;
		} else {
			return root(p[a], p);
		}
	}
}

Measured memory_bytes: 23272
N, K, *P = map(int, open(0).read().split())

A = [0]
for i in range(1, 1001):
    A.append(A[-1] + i)
B = [0] + [A[i] / i for i in range(1, 1001)]

Q = [B[p] for p in P]
ans = [sum(Q[:K])]
for i in range(N - K):
    ans.append(ans[-1] - Q[i] + Q[i + K])
    
print(max(ans))


Measured memory_bytes: 78876
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;


int main(){
    string S;
    cin >> S;
    long long int K;
    cin >> K;
    int ans,i=0;

    while(S[i]=='1'){
        i++;
    }
    if(K<=i){
        ans=1;
    }else{
        ans=S[i]-'0';
    }

    cout << ans << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define SIZE 1005

struct LOC{
	LOC(int arg_row,int arg_col){
		row = arg_row;
		col = arg_col;
	}
	bool operator<(const struct LOC &arg)const{

		if(row != arg.row){

			return row < arg.row;
		}else{
			return col < arg.col;
		}
	}
	bool operator==(const struct LOC &arg) const{

		return row == arg.row && col == arg.col;
	}
	int row,col;
};

int H,W;
int min_row[SIZE],max_row[SIZE],min_col[SIZE],max_col[SIZE];
char table[SIZE][SIZE];
vector<LOC> V;

int main(){

	scanf("%d %d",&H,&W);

	for(int row = 0; row < H; row++){

		min_col[row] = BIG_NUM;
		max_col[row] = -BIG_NUM;
	}

	for(int col = 0; col < W; col++){

		min_row[col] = BIG_NUM;
		max_row[col] = -BIG_NUM;
	}

	for(int row = 0; row < H; row++){

		scanf("%s",table[row]);

		for(int col = 0; col < W; col++){

			if(table[row][col] == 'B'){

				min_col[row] = min(min_col[row],col);
				max_col[row] = max(max_col[row],col);

				min_row[col] = min(min_row[col],row);
				max_row[col] = max(max_row[col],row);
			}
		}
	}

	for(int row = 0; row < H; row++){

		if(abs(min_col[row]) != BIG_NUM){

			V.push_back(LOC(row,min_col[row]));
		}
		if(abs(max_col[row]) != BIG_NUM){

			V.push_back(LOC(row,max_col[row]));
		}
	}

	for(int col = 0; col < W; col++){

		if(abs(min_row[col]) != BIG_NUM){

			V.push_back(LOC(min_row[col],col));
		}
		if(abs(max_row[col]) != BIG_NUM){

			V.push_back(LOC(max_row[col],col));
		}
	}

	sort(V.begin(),V.end());
	V.erase(unique(V.begin(),V.end()),V.end());

	int ans = 0;

	for(int i = 0; i < V.size()-1; i++){
		for(int k = i+1; k < V.size(); k++){

			ans = max(ans,abs(V[i].row-V[k].row)+abs(V[i].col-V[k].col));
		}
	}

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

	return 0;
}



Measured memory_bytes: 4196
// g++ .cpp && ./a.out
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;

typedef pair<int, int> p;
typedef long long ll;

const int mod = 1000000007;
const int inf = 1000000007;

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  vector<ll> cnt(n + 1);
  rep(i, n) cnt[a[i]]++;
  ll sum = 0;
  rep(i, n + 1) sum += (cnt[i] * (cnt[i] - 1) / 2);
  rep(i, n) cout << sum - (cnt[a[i]] - 1) << endl;
}


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

int main() {
  int X, c5, c500;
  cin >> X;

  // ここにプログラムを追記
  c500 = X/500;
  X -= c500 * 500;
  c5 = X/5;
  X -= c5 * 5;
  cout << c500 * 1000 + c5 * 5 << endl;
    
}


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

int main(){
  long long int a;
  cin>>a;
  long long int b=0;
  if(a%2==1){
    cout<<0<<endl;
    return 0;
    }
  a/=2;
  long long int t=1;
  for(long long int i=1;i<26;i++){
    for(long long int j=0;j<i;j++){
      t*=5;
      }
    b+=a/t;
    t=1;
    }
  cout<<b<<endl;
}

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

void bfs(vector<int>adj[],int v,int src){
    bool *visited=new bool[v+1]{0};
    int *dist=new int[v+1]{0};
    int *parent=new int[v+1];
    for(int i=0;i<v;i++)
    parent[i]=-1;
    queue<int>q;
    q.push(src);
    visited[src]=true;
    int node;
    while(!q.empty()){
        node=q.front();
        q.pop();
        for(auto neighbour:adj[node]){
            if(!visited[neighbour]){
            q.push(neighbour);
            visited[neighbour]=true;
            dist[neighbour]=dist[node]+1;
            parent[neighbour]=node;
            }
        }
    }
    int temp;
    bool ok=true;
        for(int i=1;i<v;i++){
            if(!dist[i]){
                ok=false;
                break;
            }
        }
        if(!ok) cout<<"No"<<endl;
        else{
            cout<<"Yes"<<endl;
            for(int i=1;i<v;i++) cout<<parent[i]+1<<endl;
        }
}
int main(){
    int n,m;
    cin>>n>>m;
    int u,v;
    vector<int>adj[n];
    for(int i=1;i<=m;i++){
        cin>>u>>v;
        u--,v--;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    bfs(adj,n,0);
    
    return 0;
}




Measured memory_bytes: 10984
#include<queue>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include <map>
#define key 2333
#define maxn 100005
#define ll  long long
using namespace std;
ll hsh[maxn],bas[maxn];
map<ll,int>h;
char s[maxn];
int n;
priority_queue<int> hep;
inline int read(){
	int ret=0,f=1;char ch=getchar();
	while (ch<'0'||ch>'9'){if (ch=='-') f=-1;ch=getchar();}
	while (ch>='0'&&ch<='9') ret=ret*10+ch-'0',ch=getchar();
	return ret*f;
}
ll gethashcode(int i,int p){
    return hsh[i+p-1]-hsh[i-1]*bas[p];
}
inline bool check(int p){
	h.clear();
	for(int i=1;i+p-1<=n;i++){
        ll num = gethashcode(i,p);
        if(h[num]){
            if(h[num]+p<=i){
                return 1;
            }
        }
        else
            h[num]=i;
	}
	return 0;
}
int main(){
	n=read();
	scanf("%s",s+1);
	bas[0]=1;
	for (int i=1;i<=n;i++) hsh[i]=hsh[i-1]*key+s[i]-'a',bas[i]=bas[i-1]*key;
	int L=0,R=n/2,ret=0;
	while (L<=R){
		int mid=(L+R)>>1;
		if (check(mid)) ret=mid,L=mid+1;
		else R=mid-1;
	}
	printf("%d\n",ret);
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main() {
    int a, b;   cin >> a >> b;

    if (a < b) {
        for (int i = 0; i < b; i++)
            cout << a ;

        cout << endl;
    }

    else {
        for (int i = 0; i < a; i++)
            cout << b;
        cout << endl;
    }
    return 0;
}

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

using namespace std;
typedef long long ll;
#define int ll

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

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
const int MAX_N = 100010;

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

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

    int ans = LLINF;
    // A で A, B で B
    int cand = A * X + B * Y;
    chmin(ans, cand);

    // AB で A, 残りを B
    cand = C * X * 2;
    if(X < Y) {
        cand += (Y - X) * B;
    }
    chmin(ans, cand);

    // AB で B, 残りを A
    cand = C * Y * 2;
    if(Y < X) {
        cand += (X - Y) * A;
    }
    chmin(ans, cand);

    // 全部 AB
    cand = max(X, Y) * C * 2;
    chmin(ans, cand);

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

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int a,b,c,d;
    scanf("%d %d %d",&a,&b,&c);
    if(a>b){d=a;a=b;b=d;}
    if(b>c){d=b;b=c;c=d;}
    if(a>b){d=a;a=b;b=d;}
    printf("%d %d %d\n",a,b,c);
    return 0;
}


Measured memory_bytes: 2100
import math
N = int(input())
ans_list = [0 for i in range(N+1)]
for x in range(1,int(math.sqrt(N))+1):
    for y in range(1,int(math.sqrt(N))+1):
        for z in range(1,int(math.sqrt(N))+1):
            f = x**2 +y**2 +z**2 +x*y +y*z + z*x
            if(f<=N):
                ans_list[f] += 1

for i in range(1,N+1):
    print(ans_list[i])


Measured memory_bytes: 9176
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>
#include <utility>
#include <vector>
#include <map>

#define div1 1000000007

using namespace std;

int main(void)
{
    long long N, a[100001], i, count2=0, count4=0, countodd=0;

    cin >> N;

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

        if(a[i] % 4 == 0){
            count4++;
        }

        else if(a[i] % 2 == 0){
            count2++;
        }

        else{
            countodd++;
        }
    }

    if(countodd == 0){
        cout << "Yes" << endl;
    }

    else{
        if(count4 >= countodd){
            cout << "Yes" << endl;
        }

        else if(count4 == countodd-1 && count2==0){
            cout << "Yes" << endl;
        }

        else{
            cout << "No" << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 1024
/**
*    author:  Dooloper
*    created: 11.08.2020 23:26:10
**/

#pragma region Macros
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
using P = pair<int,int>;
using ll = long long;

#define rep(i,n) for(int i = 0; i < (n); i++)
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
   cout << H << " ";
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

const double PI = acos(-1);
const int mod = 1000000007;
class mint {
    long long x;
public:
    mint(long long x=0) : x((x%mod+mod)%mod) {}
    mint operator-() const {
      return mint(-x);
    }
    mint& operator+=(const mint& a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint& a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const  mint& a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint& a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint& a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint& a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        return a;
    }
    // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint& a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint& a) const {
        mint res(*this);
        return res/=a;
    }

    friend ostream& operator<<(ostream& os, const mint& m){
        os << m.x;
        return os;
    }
};
#pragma endregion

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int D,G,p[11],c[11];
  cin >> D >> G;
  for(int i = 0; i < D; i++){
    cin >> p[i] >> c[i];
  }

  int ans = 1e9;
  for(int mask = 0; mask < (1<<D); ++mask){
    int s = 0, num = 0, rest_max = -1;
    for(int i = 0; i < D; ++i){
      if(mask >> i & 1){
        s += 100 * (i+1) * p[i] + c[i];
        num += p[i];
      }else{
        rest_max = i;
      }
    }
    if(s < G){
      int s1 = 100*(rest_max + 1);
      int need = (G-s+s1-1)/s1;
      if(need >= p[rest_max]){
        continue;
      }
      num += need;
    }
    ans = min(ans, num);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define N 1005
using namespace std;
typedef pair<int,int> P;
int n,w,d,x,y,ans;
vector<P> v;
char f;

void add_point(){
  int s,t;
  if(f=='N'){
    s=(x+y<d?x+y+w*2+d:x+y-d);
    t=(w+y-x<d?d-(w+y-x)+w:d-(y-x));
  }
  if(f=='E'){
    s=(d-(y-x)<w?d-(y-x):d-(w+(y-x))+w);
    t=(y+x<w?w-(y+x)+w+d:d-(-w+y+x)+w);
  }
  if(f=='S'){
    s=(0<=-w+y+x?d-(-w+y+x)+w:w-(y+x)+w+d);
    t=(0<=y-x?y-x+w*2+d:w-(-(y-x))+w+d);
  }
  if(f=='W'){
    s=(0<=-(y-x)?w-(-(y-x))+w+d:y-x+w*2+d);
    t=(0<=y+x-d?y+x-d:y+x+w*2+d);
  }
  v.push_back(P(t,s));
}

void solve(){
  int len=v.size();
  for(int i=0;i<len;i++){
    int cnt=1,clock=v[i].first;
    for(int j=i;j<len+i;j++){
      int idx=j%len,c=clock;
      int l=v[idx].second,r=v[idx].first;
      if(l>r)r+=w*2+d*2;
      if(l>c)c+=w*2+d*2;
      if(!(l<=c&&c<=r)){
	clock=v[j].first;
	cnt++;
      }
    }
    ans=min(ans,cnt);
  }
}

int main(){
  cin>>n>>w>>d;
  for(int i=0;i<n;i++){
    cin>>x>>y>>f;
    add_point();
  }
  sort(v.begin(),v.end());
  ans=(1e9);
  solve();
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3108
#include<cstdio>
using namespace std;
typedef long long ll;
ll a[55];

int main(){
    ll n;
    scanf("%lld",&n);
    for(int i=1;i<=50;i++)
        a[i]=n/50+i-1;
    n%=50;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=50;j++)
            a[j]--;
        a[i]+=51;
    }
    printf("50\n");
    for(int i=1;i<=50;i++){
        if(i!=1)
            printf(" ");
        printf("%lld",a[i]);
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

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


Measured memory_bytes: 2104
#include<iostream>

class Select{
	int count = 0;
public:
	void trace(int *A, int N){
		for(int i = 0; i < N; ++i){
			if(i > 0) std::cout << " ";
			std::cout << A[i];
		}
		std::cout << std::endl;
		return;
	}
	void select_sort(int *A, int N){
		for(int i = 0; i < N - 1; ++i){
			int minj = i;
			for(int j = i+1; j < N; ++j){
				if(A[minj] > A[j]){
					minj = j;
				}
			}
			if(i != minj){
				int tmp = A[i];
				A[i] = A[minj];
				A[minj] = tmp;
				++count;
			}
		}
		trace(A, N);
		std::cout << count << std::endl;
		return;
	}
};

int main(){
	Select s;
	int A[100];
	int N;

	std::cin >> N;
	for(int i = 0; i < N; ++i){
		std::cin >> A[i];
	}
	s.select_sort(A, N);

	return 0;
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)

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; }
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cout << a[i] << " "; cout << "\n"; }
ll dbgt = 1; void err() { cout << "passed " << dbgt++ << "\n"; }
template<class H, class... T> void err(H&& h,T&&... t){ cout<< h << (sizeof...(t)?" ":"\n"); if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 5e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//
ll A[200005], dp[200005][3], amax[3];
int main() {
    init();
    ll N;
    cin >> N;
    rep(i, N) cin >> A[i];

    if(N%2==0){
        rep(i,N/2){
            ll a = 2 * i;
            dp[i + 1][1] = max(dp[i][0], dp[i][1]) + A[a + 1];
            dp[i + 1][0] = dp[i][0] + A[a];
        }
        cout << max(dp[N/2][0], dp[N/2][1]) << endl;
    }
    else{
        rep(i,N/2){
            ll a = 2 * i;
            amax[0] = dp[i][0];
            rep(j, 2) amax[j + 1] = max(amax[j], dp[i][j + 1]);
            rep(j, 3) dp[i + 1][j] = amax[j] + A[a + j];
        }
        cout << *max_element(dp[N / 2], dp[N / 2] + 3) << endl;
    }
}


Measured memory_bytes: 7560
#include <stdio.h>
 
class Dice3{
public:
    Dice3(){
        number = new int[6];
        checkTable = new int[101];
        for(int i = 0; i < 101; i++) checkTable[i] = -1;
    };
    ~Dice3(){
        delete[] number;
        delete[] checkTable;
    };
 
    void setLabel(int index,int num){
        number[index] = num;
        checkTable[num] = index;
    };
 
    void roll(char dst){
        switch(dst){
        case 'E':
            setNumber(number[3],number[1],number[0],number[5],number[4],number[2]);
            break;
        case 'N':
            setNumber(number[1],number[5],number[2],number[3],number[0],number[4]);
            break;
        case 'S':
            setNumber(number[4],number[0],number[2],number[3],number[5],number[1]);
            break;
        case 'W':
            setNumber(number[2],number[1],number[5],number[0],number[4],number[3]);
            break;
        }
    };
 
    bool isValidMember(int inputed[]){
        for(int i = 0; i < 6; i++)
        {
            if(checkTable[inputed[i]] == -1)
                return false;
        }
        return true;
    }
    bool isSameDice(int inputed[]){
        char order[25] = "NNNNWNNNWNNNENNNENNNWNNN";
        for(int i = 0; i < 24; i++){
            roll(order[i]);
            for(int j = 0; j < 6; j++){
                if(inputed[j] != number[j])
                    break;
                if(j == 5)
                    return true;
            }
        }
        return false;
    }
 
private:
    void setNumber(int n0,int n1,int n2,int n3,int n4,int n5){
        number[0] = n0;
        number[1] = n1;
        number[2] = n2;
        number[3] = n3;
        number[4] = n4;
        number[5] = n5;
    }
 
private:
    int* number;
    int* checkTable;
};
 
int main(){
    Dice3 dice3;
    int tmp,inputed[6];
    for(int i = 0; i < 6; i++){
        scanf("%d",&tmp);
        dice3.setLabel(i,tmp);
    }
    for(int i = 0; i < 6; i++) scanf("%d",&inputed[i]);
 
    if(dice3.isValidMember(inputed) && dice3.isSameDice(inputed))
        printf("Yes\n");
    else{
        printf("No\n");
    }
}




Measured memory_bytes: 2652
#include"bits/stdc++.h"
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second

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

void Main()
{
	int n;
	cin >> n;
	vll a(n);
  	ll sum = 0;
  	rep(i,n) {
		cin >> a[i];
      	a[i] -= i+1;
      	sum += a[i];
    }
	sort(all(a));
  
  	auto f = [&](ll x){
    	ll res = 0;
      	rep(i,n) res += abs(a[i]-x);
      	return res;
    };
  	
  	ll ans;
  	if(n%2) ans = f(a[n/2]);
	else ans = min(f(a[n/2]), f(a[n/2+1]));	
  	cout << ans << endl;
	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for(int i=(0);i<(n);i++)

using namespace std;

typedef long long ll;

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

	int n;
	cin >> n;

	vector<int> a(n);
	rep(i, n - 1){
		int x;
		cin >> x;
		x--;

		a[x]++;
	}

	rep(i, n){
		cout << a[i] << "\n";
	}

}


Measured memory_bytes: 3976
#include<iostream>
#include<iomanip>
#include<cstdio>

#include<vector>
#include<queue>
#include<set>
#include<map>
#include<string>

#include<algorithm>
#include<cmath>

using namespace std;
typedef long long ll;
const int INF = 1e9+1;
template <class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template <class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}

int n;
map<int,int> ma, mb;

int main() {
    cin >> n;
    vector<int> a(n/2), b(n/2);
    
    for (int i = 0; i < n/2; i++) {
        cin >> a[i] >> b[i];
        ma[a[i]] += 1;
        mb[b[i]] += 1;
    } 
    int k = n / 2;

    int amax = 0,amaxs = 0, bmax = 0, bmaxs = 0;
    int aarg = -1, aargs = -1, barg = -1, bargs = -1;
    for (auto itr = ma.begin(); itr != ma.end(); ++itr) {
        if (itr->second >= amax) {
            amaxs = amax; aargs = aarg;
            amax = itr->second; aarg = itr->first;
        } else if (itr->second >= amaxs) {
            amaxs = itr->second; aargs = itr->first;
        } 
    }
    for (auto itr = mb.begin(); itr != mb.end(); ++itr) {
        if (itr->second >= bmax) {
            bmaxs = bmax; bargs = barg;
            bmax = itr->second; barg = itr->first;
        } else if (itr->second >= bmaxs) {
            bmaxs = itr->second; bargs = itr->first;
        } 
    }

    if (aarg != barg) {
        cout << n - amax - bmax << endl;
    } else {
        int res = min(n - amax - bmaxs, n - bmax - amaxs);
        cout << res << endl;
    }




}


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

// #define int ll
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using si = set<int>;
using ii = pair<int, int>;
using vii = vector<ii>;

#define rep(i, n) for (int i = 0; i < n; i++)
#define dotc()    int tcs; if (cin >> tcs) rep(tc, tcs)
#define sz(x)     (int)x.size()
#define eb        emplace_back
#define pb        push_back
#define mp        make_pair
#define all(x)    x.begin(), x.end()
#define rall(x)   x.rbegin(), x.rend()
#define fi        first
#define se        second

ll mod(1000000007);
double pi(acos(-1.0));

int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
#ifdef LOCAL
  freopen("io\\in.txt", "r", stdin);
  freopen("io\\out.txt", "w", stdout);
#endif

  ll x;
  cin >> x;
  ll cur = 100;
  rep(i, 1 << 30) {
    cur = (double)cur * 101 / 100;
    if (cur >= x) {
      cout << i + 1;
      return 0;
    }
  }

  return 0;
}


Measured memory_bytes: 3656
#include<stdio.h>
#include<stdlib.h>
 
int main(void)
{
  int n,q;
  scanf("%d %d", &n, &q);
  //printf("%d %d", n, q);
 
  int i,j;
	
  char S[100000+1];
  scanf("%s", S);

  // for(i=0;i<n;i++) printf("%c", S[i]);
  //printf("\n");
 
 
  int m[100000+1][2];
  for(i=0;i<q;i++){
    //for(j=0;j<2;j++){
    scanf("%d %d", &m[i][0], &m[i][1]);
    //printf("%d, %d ", m[i][0], m[i][1]);
  }

  //for(i=0;i<q;i++) printf("%d, %d\n", m[i][0], m[i][1]);

  int count[n];
  count[0]=0;
  int temp=0;

  // int x;


  for(i=1;i<n;i++){
    // for(x=0;x<q;x++) printf("%d, %d\n", m[x][0], m[x][1]);
    if(S[i-1]=='A' && S[i]=='C'){
      temp++;
      count[i]=temp;
    }else{
      count[i]=temp;
    }

  }
  
 
  for(i=0;i<q;i++){
    printf("%d\n", count[m[i][1]-1]-count[m[i][0]-1]);
  }
 
}


Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
static const int MAX = 100; 
int n,M[MAX][MAX];
void dij(){
	int minv;
	int d[MAX],color[MAX];
	for(int i = 0;i < n;i++){
		d[i] = INT_MAX;
		color[i] = 0;
	}
	d[0] = 0;
	color[0] = 1;
	while(1){
		minv = INT_MAX;
		int u = -1;
		for(int i = 0;i < n;i++){
			if(minv > d[i] && color[i] != 2){
				u = i;
				minv = d[i];
			}
		}
		if(u == -1)break;
		color[u] = 2;
		for(int v = 0; v < n; v++){
			if(color[v] != 2 && M[u][v] != INT_MAX){
				if(d[v] > d[u] + M[u][v]){
					d[v] = d[u] + M[u][v];
					color[v] = 1;
				}
			}
		}
	}
	for(int i = 0;i < n;i++){
		cout << i << " " << (d[i] == INT_MAX ? -1 : d[i]) << endl;
	}
}
int main(){
	cin >> n;
	for(int i = 0;i < n;i++){
		for(int k = 0;k < n;k++){
			M[i][k] = INT_MAX;
		}
	}
	int k, c, u,v;
	for(int i = 0;i < n;i++){
		cin >> u >> k;
		for(int j = 0;j < k;j++){
			cin >> v >> c;
			M[u][v] = c;
		}
	}
	dij();
}


Measured memory_bytes: 3160
import itertools
from collections import Counter

N=int(input())
a=[input() for i in range(N)]

a = sorted(a)
#print(a)


counter = Counter(a)

mode_v = counter.most_common()[0][-1]
cmc= counter.most_common()
#print(cmc)
it = itertools.takewhile(
    lambda kv: kv[-1] == mode_v, cmc
)

#sorted(it)
f=list(it)
#print(f)
f = sorted(f)
#print(f)
for k in range(len(f)):
	print(f[k][0])

Measured memory_bytes: 49428
#include<stdio.h>

int main()
{
    int ans = 700, i;
    char str[4];

    for(i=0; i<3; i++)
    {
        scanf("%c",&str[i]);
    }

    for(i=0; i<3; i++)
    {
        if(str[i] == 'o')
            ans = ans+100;
    }

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

    return 0;
}


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

int main() {
	string a;
	cin >> a;
	string s = a.substr(0, a.size() - 1);
	for (int i = 0; i < s.size(); i++) {
		if ((s.size() - i) % 2 == 0) {
			string t = s.substr(0, (s.size() - i) / 2 - 1);
			string u = s.substr((s.size() - i) / 2, (s.size() - i) / 2 - 1);
			if (t == u) {
				cout << t.size() + u.size() + 2 << endl;
				return 0;
			}
		}
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
	int n,k;cin>>n>>k;
	int a[n];
	for(int i=0;i<n;i++) cin>>a[i];
	sort(a,a+n);
	int ans=0;
	for(int i=0;i<k;i++){
		ans+=a[i];
	}
	cout<<ans;
}


Measured memory_bytes: 3636
#include<iostream>
#include<complex>
int main() {
	int N;
	std::cin >> N;
	double temperature, best;
	std::cin >> temperature >> best;
	double height;
	double good = 10000000;
	int index;
	for (int L1 = 0; L1 < N; L1++) {
		std::cin >> height;
		if (std::abs(best - (temperature - height * 0.006f)) < good) {
			index = L1;
			good = std::abs(best - (temperature - height * 0.006f));
		}
	}
	std::cout << index+1 << std::endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <iomanip>
#include <utility>
#define ll long long
#define ld long double
using namespace std;

int main() {
	ll N, sum=0, cnt=0;
	cin >> N;
	vector<ll> a(N), ans(N, 0);
	for(int i=0; i<N; ++i){
	    cin >> a[i];
	    sum += a[i];
	    if(i%2==1) cnt += a[i];
	}
	ans[0]=sum-cnt*2;
	cout << ans[0];
	for(int i=1; i<N; ++i){
	    ans[i]=a[i-1]*2-ans[i-1];
	    cout << ' ' << ans[i];
	}
	cout << endl;
	return 0;
}


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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))

using namespace std;

using i32 = int;
using i64 = long long;
using u64 = unsigned long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
inline u64 xorshift() { static u64 x = 88172645463325252ull; x = x ^ (x << 7); return x = x ^ (x >> 9); }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T power(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
template <typename T, typename S> istream& operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
template <typename T, typename S> ostream& operator<<(ostream &os, pair<T, S> &p) { os << p.first << ' ' << p.second; return os; }

void solve() {
  int n; cin >> n;
  rep(i, n) {
    string s; cin >> s;
    int n = s.size();

    string ans = "";
    vstr memo = {
      ".,!? ",
      "abc",
      "def",
      "ghi",
      "jkl",
      "mno",
      "pqrs",
      "tuv",
      "wxyz",
    };
    int prev = -1, x = -1;
    rep(i, n) {
      if (s[i] == '0') {
        if (x != -1) ans += memo[prev][x];
        x = -1, prev = -1;
      } else {
        int y = s[i] - '1';
        prev = y, x++;
        if (x >= memo[prev].size()) x = 0;
      }
    }
    cout << ans << '\n';
  }
}



Measured memory_bytes: 3128
#include<iostream>
#include<cstdio>
using namespace std;
#define ll long long
#define MAX 200200
inline int read()
{
    int x=0;bool t=false;char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-')ch=getchar();
    if(ch=='-')t=true,ch=getchar();
    while(ch<='9'&&ch>='0')x=x*10+ch-48,ch=getchar();
    return t?-x:x;
}
int n,a[MAX],Q[MAX],top;
int l[MAX],r[MAX];
ll ans;
int main()
{
    n=read();
    for(int i=1;i<=n;++i)a[i]=read(),l[i]=1,r[i]=n;
    top=0;
    for(int i=1;i<=n;++i)
    {
        while(top&&a[Q[top]]>a[i])--top;
        if(top)l[i]=Q[top]+1;
        Q[++top]=i;
    }
    top=0;
    for(int i=n;i>=1;--i)
    {
        while(top&&a[Q[top]]>a[i])--top;
        if(top)r[i]=Q[top]-1;
        Q[++top]=i;
    }
    for(int i=1;i<=n;++i)ans+=1ll*(i-l[i]+1)*(r[i]-i+1)*a[i];
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3328
// V solo
#include <bits/stdc++.h>

#define forn(i, a, b) for (int i = a; i <= b; ++i)
#define forr(i, a, b) for (int i = a; i >= b; --i)

using namespace std;

const int N = (int)2e5 + 7;
const long long INF = 1e15 + 7;

typedef long long ll;
typedef long double ld;

typedef pair < int, int > pii;
typedef pair < ll, ll > pll;


int n;
deque < int > dq;
int main (){
  scanf ("%d", &n);
  forn (i, 1, n){
    int x;
    scanf ("%d", &x);
    if (i & 1) dq.push_front(x);
    else dq.push_back(x);
  }
  if (n % 2 == 0){
    while (!dq.empty()){
      printf ("%d ", dq.back());
      dq.pop_back();
    }
  } else {
    while (!dq.empty()){
      printf ("%d ", dq.front());
      dq.pop_front();
    }
  }
  return 0;
}


Measured memory_bytes: 2944
#include <stdio.h>

int checkcode(char *bango){
    int suuchi[4], i;

    for(i = 0; i < 4; i++){
        suuchi[i] = bango[i] - 48;
        if(i != 0)
            if(suuchi[i-1] == suuchi[i])
                return -1;
    }
    return 0;
    
}

int main(){
    char str[64];
    scanf("%s", str);
    int res = checkcode(str);
    switch(res){
        case -1:
            printf("Bad");
            break;
        case 0:
            printf("Good");
            break;
    }
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
int main() {
    int h,w,a,b;
    cin >> h >> w >> a >> b;
    rep(i, h){
        rep(j,w){
            putchar((i < b && j < a) || (i >= b && j >= a) ? '1' : '0');
        }
        puts("");
    }
}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
#define int         long long
#define ull 	    unsigned long long
#define ll 	    long long
#define N	    100005
#define M 	    1000000007
#define pb 	    push_back
#define p_q 	    priority_queue
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define all(a)      (a).begin(),(a).end()
#define sz(x)       (ll)x.size()
#define endl        '\n'
#define gcd(a,b)    __gcd((a),(b))
#define lcm(a,b)    ((a)*(b)) / gcd((a),(b))
#define ios	    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mp 	    make_pair
#define lb 	    lower_bound
#define ub	    upper_bound
#define F           first
#define S           second
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define ini(a,n,b)	for(ll int i=0;i<n;i++) a[i]=0;
#define cset(a)		__builtin_popcountll(a)
#define hell 		(ull)1e9
#define re 		resize
int n,m;
vi adj[N];
bool visited[N];
int dp[N];
void dfs(int v)
{
	visited[v]=1;
	for(auto i:adj[v])
	{
		if(!visited[i])
			dfs(i);
		dp[v]=max(dp[v],1+dp[i]);
	}
}
signed main(void)
{ios
	int TESTS=1;
	//cin>>TESTS;
	while(TESTS--)
	{
		rep(i,0,N) {dp[i]=0;visited[i]=0;}
		cin>>n>>m;
		rep(i,0,m)
		{
			int x,y;
			cin>>x>>y;
			adj[x].pb(y);
		}
		rep(i,1,n+1) if(!visited[i]) dfs(i);
		int max=0;
		rep(i,1,n+1) if(dp[i]>max) max=dp[i];
		cout<<max;
	}
	
}

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

public class Main {
    static StringTokenizer st;
    static BufferedReader br;  
    static PrintWriter out;
 
    static int parent[]; 

    public static void main(String[] args) throws IOException {
        br = new BufferedReader(new InputStreamReader(System.in));
 
        int N = nextInt();
        
        int[] A = new int[N];

        for (int x=0; x<N; x++) {
            A[x] = nextInt();
        }

        Arrays.sort(A);

        int[] cnt = new int[A[N-1]+1];
        boolean[] dp = new boolean[A[N-1]+1];
        Arrays.fill(dp, true); //true mean not contain

        for (int x=0; x<N; x++) {
            cnt[A[x]] ++;
            if( cnt[A[x]] >1 ){
                dp[A[x]] = false;
            }
        }
 
    
        //Sieve of Eratosthenes
        for (int x=0; x<N; x++) {
            int curr = A[x];
            if(dp[curr] || cnt[curr]>1) {
                for (int z = 2; z *curr <=A[N-1]; z++) 
                {
                    dp[z * curr] = false;
                }
            }
        }

        int ans = 0;
        for (int x=0; x<N; x++) {
            if(dp[A[x]]==false){
                ans ++;
            }
        }

        System.out.println(N-ans);
        
    
    }
 
    public static int nextInt() throws IOException {
        return Integer.parseInt(next());
    }
    public static long nextLong() throws IOException {
        return Long.parseLong(next());
    }

    public static double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }

    static String next() throws IOException {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine().trim());
        return st.nextToken();
    }
}

Measured memory_bytes: 54840