akhauriyash/Code-Regression huggingface dataset:
N = int(input())

def harshad(n):
    str_n = list(str(n))
    sum_str_n = 0
    for i in str_n:
        sum_str_n += int(i)

    if n % sum_str_n == 0:
        print("Yes")
    else:
        print("No")

harshad(N)

Measured memory_bytes: 2940
#include<bits/stdc++.h>
    using namespace std;
    long long int n,i;
    int main(){
	cin>>n;
	string s;
	cin>>s;
      if(n%2){cout<<"No";return 0;}
	for(i=0;i<n/2;i++){
		if(s[i]!=s[i+n/2]){
			cout<<"No";
			return 0;
		}
	}
	cout<<"Yes";
    }


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

void solve(){

	int n ,k ;
	cin>>n>>k ;

	unordered_map<int,int> mp ;

	rep(i,n){
		int x ;
		cin>>x ;
		mp[x]++ ;
	}

	priority_queue<pair<int,int> , vector<pair<int,int>> , greater<pair<int,int>>> pq ; 

	for(auto x:mp){

		pair<int,int> p ;
		p.first=x.second ;
		p.second=x.first ;
		pq.push(p) ;

	}

	int count=0 ;
	
	while(pq.size()>k){

		//cout<<pq.top().first<<" "<<pq.top().second<<"\n" ;
		count+=pq.top().first ;
		pq.pop() ;
	
	}

	cout<<count ;

}

int main(){
	
	int y ;

	y=1 ;
	//cin>>y ;

	while(y--)
	{	
		solve() ;
	}

}

Measured memory_bytes: 14352
N = input()
A = list(input())
B = list(input())
C = list(input())
count = 0
for i in range(int(N)):

  a = A[i]
  b = B[i]
  c  =C[i]
  if a != b and a != c and c != b:
    a = b = c = "a"
    count += 2
  elif a == b and a != c:
    count += 1
  elif a != b and a == c:
    count+=1
  elif c != a and b == c:
    count +=1
print(count)

Measured memory_bytes: 3064
import java.util.*

fun main(args: Array<String>) {
    val sc = java.util.Scanner(System.`in`)
    val n = sc.nextInt()

    println(sc.asSequence().take(n).map { it.toInt() }.withIndex().sortedBy { it.value }.map { it.index + 1 }.joinToString(" "))
}



Measured memory_bytes: 75924
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int ll;

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

ll gcd(ll x,ll y){
  if(y == (ll)0) return x;
  else return gcd(y,x%y);
}

int main()
{
  ll n,m;
  cin >> n >> m;
  string s,t;
  cin >> s >> t;

  ll g = gcd(n,m);
  ll l = n*m/g;

  ll ss = n/g, tt = m/g;
  for(ll i = 0; i < g; i++){
    if(s[ss*i] != t[tt*i]){
      cout << -1 << endl;
      return 0;
    }
  }


  cout << l << endl;

  return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <stdio.h>
#include <cmath>

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

typedef long long ll;

using namespace std;

const int INF = 1e9;
const double PI=3.14159265358979323846;

int main(){
  double x1,y1,x2,y2,d;
  cin >> x1 >> y1 >> x2 >> y2;
  d=sqrt(pow(x1-x2,2)+pow(y1-y2,2));
  printf("%.10f\n",d);
}



Measured memory_bytes: 3196
#include<cstdio>
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
using pii=std::pair<int,int>;
using piii=std::pair<int,pii>;
class UnionFind{
private:
    int length, numComponent;
    //parent[x]=xの親の番号 ............. xに親が存在する場合,
    //parent[x]=-(xを含む集合の要素数) ... xが親である場合
    int *parent;
    int *rank;
public:
    UnionFind(int l);
    ~UnionFind();
    int root(int x);
    void unite(int x,int y);
    bool isSameTree(int x,int y);
    int sizeOf(int x);
    int component();
};
UnionFind::UnionFind(int l){
    length=l;
    numComponent=l;
    parent=new int[l];
    for(int i=0;i<l;i++)parent[i]=-1;
    rank=new int[l];
    for(int i=0;i<l;i++)rank[i]=0;
}
UnionFind::~UnionFind(){
    delete[] parent;
    delete[] rank;
}
int UnionFind::root(int x){
    if(parent[x]<0)return x;
    return parent[x]=root(parent[x]);
}
void UnionFind::unite(int x,int y){
    int rx=root(x),ry=root(y);
    if(rx!=ry){
        numComponent--;
        if(rank[rx]>rank[ry]){
            parent[rx]+=parent[ry];
            parent[ry]=rx;
        }
        else{
            if(rank[rx]==rank[ry])rank[ry]++;
            parent[ry]+=parent[rx];
            parent[rx]=ry;
        }
    }
}
bool UnionFind::isSameTree(int x,int y){
    return root(x)==root(y);
}
int UnionFind::component(){
    return numComponent;
}
int UnionFind::sizeOf(int x){
    return -parent[root(x)];
}
int main(){
    int n;
    scanf("%d",&n);
    std::vector<piii> vp;
    for(int i=0;i<n;i++){
        int x,y;
        scanf("%d%d",&x,&y);
        vp.push_back({i,{x,y}});
    }
    UnionFind uf_all(n);
    //union about x
    std::sort(vp.begin(),vp.end(),[](piii a,piii b){return a.second.first<b.second.first;});
    for(int i=1;i<n;i++){
        if(vp[i].second.first==vp[i-1].second.first){
            uf_all.unite(vp[i].first,vp[i-1].first);
        }
    }
    //union about y
    std::sort(vp.begin(),vp.end(),[](piii a,piii b){return a.second.second<b.second.second;});
    for(int i=1;i<n;i++){
        if(vp[i].second.second==vp[i-1].second.second){
            uf_all.unite(vp[i].first,vp[i-1].first);
        }
    }
    //count x_size and y_size
    std::sort(vp.begin(),vp.end(),[](piii a,piii b){return a.first<b.first;});
    std::vector<std::set<int>> x_sets(n),y_sets(n);
    for(int i=0;i<n;i++){
        x_sets[uf_all.root(i)].emplace(vp[i].second.first);
        y_sets[uf_all.root(i)].emplace(vp[i].second.second);
    }
    //count y_size
    long long ans=0;
    for(int i=0;i<n;i++){
        if(uf_all.root(i)==i){
            long long point_num=uf_all.sizeOf(i), x_size=x_sets[i].size(), y_size=y_sets[i].size();

            //std::cout << x_size << "," << y_size << "," << point_num << "\n";
            if(x_size>=2&&y_size>=2){
                ans+=x_size*y_size-point_num;
            }
        }
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 16244
/**
 * author: dannysmyda
 */ 
#include <bits/stdc++.h>

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string contest;
    cin >> contest;
    if(contest == "ABC") {
        cout << "ARC" << endl;
    } else {
        cout << "ABC" << endl;
    }
    return 0;    
}


Measured memory_bytes: 3632
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <string>
#include <list>
using namespace std;
int main() {
	int a;
	cin >> a;
	if (a < 30) {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}
}

Measured memory_bytes: 3640
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <stdio.h>
#include <stdlib.h>

using namespace std;
//DP用
template<class T> inline bool chmin(T& a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
const long long INF = 1LL << 60;

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



Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void){
    int N, p, sw=0, already=false;
    cin >> N;
    for(int i = 1; i <= N; i++){
        cin >> p;
        if(i != p){
            if(sw==0){
                sw = p;
            } else{
            if(i!=sw){
                cout << "NO" << endl;
                return 0;
            }
            }
        }
    }
    cout << "YES" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <vector>
#include <numeric>
#include <algorithm>
#include <iostream>
#include <string>
#include <cstring>
#include <sstream>
#include <functional>
#include <queue>
#include <deque>
#include <stack>
#include <cassert>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <cassert>

using namespace std;

using int64 = long long;

/////////////////////
// Code starts here//
/////////////////////


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

    int N;
    cin >> N;
    N %= 10;

    if (N == 2 or N == 4 or N == 5 or N == 7 or N == 9)
        cout << "hon\n";
    else if (N == 0 or N == 1 or N == 6 or N == 8)
        cout << "pon\n";
    else
        cout << "bon\n";

    return 0;
}


Measured memory_bytes: 3608
// #includes {{{
#ifdef MY_DEBUG
#include "header/header.hpp"
#else
#include <bits/stdc++.h>
#endif

using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define RREP(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();++i)
#define LET(x,a) __typeof(a) x(a)
//#define IFOR(i,it,c) for(__typeof((c).begin())it=(c).begin();it!=(c).end();++it,++i)
#define ALL(c) (c).begin(), (c).end()
#define MP make_pair

#define EXIST(e,s) ((s).find(e)!=(s).end())

#define RESET(a) memset((a),0,sizeof(a))
#define SET(a) memset((a),-1,sizeof(a))
#define PB push_back
#define DEC(it,command) __typeof(command) it=command

//debug

#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)

typedef long long Int;
typedef unsigned long long uInt;
typedef long double rn;

template<class T>
constexpr T inf = numeric_limits<T>::has_infinity ? numeric_limits<T>::infinity():(numeric_limits<T>::max()/2);

int __inf_ignore(){
	int t = inf<int>;
	return t;
}

typedef pair<int,int> pii;

#ifdef MY_DEBUG
#include"print.hpp"
#include"debug.hpp"
#endif
// }}}

Int N;
Int A;
Int B;

void solve(){
	cout<<min(N*A,B)<<endl;
}
//{{{ main fucnction
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin >> N;
    cin >> A;
    cin >> B;
	solve();
	return 0;
}
//}}}


Measured memory_bytes: 256
/**
 *    author:  tourist
 *    created: 27.01.2020 05:38:34       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int x, y;
  cin >> x >> y;
  int ans = (x < y ? y - x : x - y + 2);
  ans = min(ans, abs(-x - y) + 1);
  cout << ans << '\n';
  return 0;
}


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

bool cmp(pair<int,int> a, pair<int,int> b){
	return a.second<b.second;
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
    string s,t;
    cin >>s>>t;
    int n= s.length();
    int m= t.length();
    int ans[n+1][m+1];
    for(int i=0;i<=n;i++){
    	for(int j=0;j<=m;j++){
    		if(i==0||j==0)  ans[i][j]=0;
    		
    		else if(s[i-1]==t[j-1]){
    			ans[i][j]= ans[i-1][j-1]+1;
			}
			else{
				ans[i][j]= max(ans[i-1][j],ans[i][j-1]);
			}
		}
	}
	int index=ans[n][m];

	char lcs[index+1]; 
	lcs[index]='\0';
   
   int i = n, j = m; 
   while (i > 0 && j > 0) 
   { 
      if (s[i-1] == t[j-1]) 
      { 
          lcs[index-1] = s[i-1];  
          i--; j--; index--;     
      }  
      else if (ans[i-1][j] > ans[i][j-1]) 
         i--; 
      else
         j--; 
   } 
      cout << lcs<<"\n"; 
      
}


Measured memory_bytes: 35456
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

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

		int rectangle = 0;//長方形
		int diamond = 0;//菱形
		List<String> dataList = new ArrayList<String>();
		while(stdIn.hasNext()){
			dataList.add(stdIn.next());
		}
		for(String i:dataList){
			String[] dataString = i.split(",");
			int dataInt0 = Integer.valueOf(dataString[0]);
			int dataInt1 = Integer.valueOf(dataString[1]);
			int dataInt2 = Integer.valueOf(dataString[2]);
			if(dataInt0 == dataInt1){
				diamond++;
			}else if(dataInt0 * dataInt0 + dataInt1 * dataInt1 == dataInt2 * dataInt2){
				rectangle++;
			}
		}
		System.out.println(rectangle + "\n" + diamond);
	}
}

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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

int main()
{
    cout << fixed << setprecision(15);
    ll N, M;
    cin >> N >> M;

    vector<ll> X(M);
    REP(i, M){
        cin >> X[i];
    }
    sort(X.begin(), X.end());

    vector<ll> L(M-1);
    REP(i, M-1){
        L[i] = X[i+1] - X[i];
    }

    ll ans = 0;
    
    sort(L.begin(), L.end());
    REP(i, M-N){
        ans += L[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

static int stack[101],p;

void push(int);
int pop();

void push(int x){
  stack[p++]=x;
}

int pop(){
  return stack[--p];
}


int main(){
  int x,p=0,a=0,b=0;
  char s[100];
  
  while(scanf("%s",s) != EOF){
    
    if(s[0] == '+'){
      push(pop()+pop());
    } 

    else if(s[0] == '-'){
      a=pop();
      b=pop();
      push(b-a);
    } 

    else if(s[0] == '*'){
      push(pop()*pop());
    }

    else {
      x = atoi(s);
      push(x);
    }
  }

  printf("%d\n",stack[p]);  
  
  return 0;
}

Measured memory_bytes: 548
a = input()
b = input()
c = input()
a_cnt = 0
b_cnt = 0
c_cnt = 0
next_player = "a"
while True:
    if next_player == "a":
        if a_cnt == len(a):
            print("A")
            exit()
        next_player = a[a_cnt]
        a_cnt += 1
    elif next_player == "b":
        if b_cnt == len(b):
            print("B")
            exit()
        next_player = b[b_cnt]
        b_cnt += 1
    else:
        if c_cnt == len(c):
            print("C")
            exit()
        next_player = c[c_cnt]
        c_cnt += 1


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

public static class Program
{
    public static void Main(string[] args)
    {
        var s = Console.ReadLine();
        var cnt = 0;
        if (s.Length % 2 == 0)
        {
            var c = s.Length / 2;
            var s1 = s.Substring(0, c);
            var s2 = s.Substring(c, c);
            for (int i = 0; i < c; i++)
            {
                if (s1[i] != s2[(c - 1) - i])
                {
                    cnt++;
                }
            }
        }
        else
        {
            var c = (s.Length - 1) / 2;
            var s1 = s.Substring(0, c);
            var s2 = s.Substring(c + 1, c);
            for (int i = 0; i < c; i++)
            {
                if (s1[i] != s2[(c - 1) - i])
                {
                    cnt++;
                }
            }
        }
        Console.WriteLine(cnt);
    }
}

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

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define dbg(x) cout<<#x<<"="<<x<<endl

int N;
vector<bool> vis;

void dfs(int v){
  vis[v]=true;
  rep(i,N){
    if(!((v>>i)&1)){
      int nv=v^(1<<i);
      if(vis[nv])continue;
      dfs(nv);
    }
  }
}

int main(){
  cin>>N;
  vis.resize(1<<N,false);
  vector<int> A(1<<N);
  int S=1<<N;
  rep(i,S){
    cin>>A[i];
  }

  vector<int> ls;
  rep(i,S){
    if(A[i]==0)continue;
    bool last=true;
    rep(j,N){
      if((i>>j)&1){
        int k=(i^(1<<j));
        if(A[k])last=false;
      }
    }
    if(last){
      ls.push_back(i);
    }
  }

  rep(i,ls.size()){
    if(vis[ls[i]])continue;
    dfs(ls[i]);
  }
  rep(i,S){
    if(vis[i]&&A[i]==0){
      cout<<-1<<endl;
      return 0;
    }
  }
  cout<<ls.size()<<endl;

  return 0;
}



Measured memory_bytes: 8048
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

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

/*
    freopen("input","r",stdin);
    freopen("output","w",stdout);
*/

int N;

vector<vector<int> > G;
vector<vector<int> > T;
vector<int> sol;

void build(int a, int p) {
	for (int i = 0;i < G[a].size();i++) {
		if (G[a][i] != p) {
			T[a].push_back(G[a][i]);
			build(G[a][i], a);
		}
	}
	return;
}

vector<int> root;
vector<int> can;
bool fail = 0;

void check() {
	for (int i = 0;i < N;i++) {
		int n = 0;
		int q = -1;
		for (int j = 0;j < G[i].size();j++) {
			if (G[G[i][j]].size() > 1) n++;
			else q = G[i][j];
		}
		if (n <= 1 && q != -1) {
			root.push_back(i);
			can.push_back(q);
		}
		if (n > 2) fail = 1;
	}
	return;
}

vector<int> ans;
int crt;

void solve(int n) {
	int nex = -1;
	int now = 0;
	for (int i = 0;i < T[n].size();i++) {
		if (T[T[n][i]].size() != 0) {
			nex = T[n][i];
		}
		else now++;
	}
	for (int j = 0;j < now;j++) {
		int num = crt + 1 + j;
		if (num != N) ans.push_back(num);
	}
	ans.push_back(crt);
	crt += (now + 1);
	if (nex != -1) solve(nex);
	return;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> N;
    G.resize(N);
    for (int i = 1;i < N;i++) {
    	int a, b;
    	cin >> a >> b;
    	a--;
    	b--;
    	G[a].push_back(b);
    	G[b].push_back(a);
    }
    check();
    if (root.size() == 0 || fail) {
    	cout << -1 << endl;
    	return 0;
    }
    for (int i = 0;i < can.size();i++) {
    	T.clear();
    	T.resize(N);
    	build(can[i], -1);
    	ans.clear();
    	crt = 1;
    	solve(can[i]);
    	ans.push_back(N);
    	if (sol.size() == 0 || ans < sol) sol = ans;
    }
    for (int i = 0;i < sol.size();i++) {
    	if (i != 0) cout << ' ';
    	cout << sol[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 17404
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>

#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>

#define int long long
#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 FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class CAntsOnACircle {
public:
    static constexpr int kStressIterations = 0;

    static void generateTest(std::ostream& test) {
    }

    void solve(std::istream& cin, std::ostream& cout) {
        int N, L, T;
        cin >> N >> L >> T;
        vector<int> X(N), W(N);

        vector<int> cond;
        REP(i, N) {
            cin >> X[i] >> W[i];

            if (W[i] != W[0]) {
                cond.push_back(X[i]);
            }
        }

        int t = T % L;
        int n = T / L;
        int cnt = 0;
        REP(i, N) {
            if (W[i] == 1) {
                cnt -= n + (t >= L - X[i]);
                //cnt -= (T - (L - X[i]) + L) / L;
            } else {
                cnt += n + (t >= (X[i] + 1) % L);
                //cnt += (T - (X[i] + 1) + L) / L;
            }
        }
        cnt = ((cnt % N) + N) % N;

        vector<int> v;
        REP(i, N) {
            int x = X[i];
            int w = W[i];

            if (w == 1) {
                x += t;
                x %= L;
            } else {
                x -= t;
                if (x < 0) x += L;
            }
            v.push_back(x);
        }
        sort(v.begin(), v.end());

        vector<int> ans(N);
        REP(i, N) ans[(i + cnt) % N] = v[i];

        REP(i, N) cout << ans[i] << endl;
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    CAntsOnACircle solver;
    solver.solve(in, out);
    return 0;
}


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

// int n; cin >> n;
// cout << n << endl;
int main() {
  int n; cin >> n;
  int m; cin >> m;
  string ans;
  if (n < m) {
    rep(i, m) {
      ans += to_string(n);
    }
  } else {
    rep(i, n) {
      ans += to_string(m);
    }
  }
  cout << ans << endl;
}

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;

const int mod = 1000000007;
constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0};
const int dx[] = {0,-1,0,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}
unsigned int hexToUInt(const std::string &str)
{
  unsigned int val = 0;
  unsigned int v;
  for(size_t ix = 0; ix != str.size(); ++ix) {
    char ch = str[ix];
    if( ch >= '0' && ch <= '9' )
      v = ch - '0';
    else if( ch >= 'A' && ch <= 'F' )
      v = ch - 'A' + 10;
    else if( ch >= 'a' && ch <= 'f' )
      v = ch - 'a' + 10;
    else
      continue;    // 16?????°????????§???????????´???
    val = val * 16 + v;
  }
  return val;
}
void Ans(bool f){
  if(f) cout << "YES"<<endl;
  else cout << "NO"<<endl;
}

const string li[8] = {"#000000","#0000ff","#00ff00","#00ffff","#ff0000","#ff00ff","#ffff00","#ffffff"};
const string name[8] = {"black","blue","lime","aqua","red","fuchsia","yellow","white"};
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  int cola[3],colb[8][3];
  rep(k,8){
    string str = "";
    REP(i,1,li[k].size()){
      if(i % 2){
        str += li[k][i];
      }
      else{
        str += li[k][i];
        colb[k][i/2-1] = hexToUInt(str);
        str.clear();
      }
    }
  }
  while(cin >> s && s != "0"){
    string str="";
    REP(i,1,s.size()){
      if(i % 2){
        str += s[i];
      }
      else{
        str += s[i];
        cola[i/2-1] = hexToUInt(str) ;
        str.clear();
      }
    }
    int mi = inf;
    int suf = 0;
    rep(i,8){
      int d = pow((cola[0] - colb[i][0]),2) + pow((cola[1] - colb[i][1]),2)+pow((cola[2] - colb[i][2]),2);
      if(mi > d){
        suf = i;
        mi = d;
      }
    }
    cout << name[suf]<<endl;
  }
  return 0;
}

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

typedef string::const_iterator Iter;

map<string, int> mp;

int molecule(Iter &);
int atom(Iter &);
int number(Iter &);

int molecule(Iter &it)
{
	int res = 0;
	while (*it){
		if (isalpha(*it)){
			int t = atom(it);
			if (isdigit(*it)){
				t *= number(it);
			}
			res += t;
		}
		else if (*it == '('){
			++it;
			int t = molecule(it);
			++it;
			t *= number(it);
			res += t;
		}
		else break;
	}
	return res;
}

int atom(Iter &it)
{
	string s;
	s += *it;
	++it;
	while ('a' <= *it && *it <= 'z'){
		s += *it;
		++it;
	}
	if (!mp.count(s)) throw -1;
	return mp[s];
}

int number(Iter &it)
{
	int res = 0;
	while (isdigit(*it)){
		res = res * 10 + (*it - '0');
		++it;
	}
	return res;
}

int eval(const string &s)
{
	Iter it = s.begin();
	return molecule(it);
}

int main()
{
	string s;
	while (cin >> s, s != "END_OF_FIRST_PART"){
		int n;
		cin >> n;
		mp[s] = n;
	}

	while (cin >> s, s != "0"){
		try {
			cout << eval(s) << endl;
		}
		catch (int e){
			cout << "UNKNOWN\n";
		}
	}
}

Measured memory_bytes: 3044
import java.util.Scanner;

public class Main{
    public static void main(String[]args){
        Scanner sc = new Scanner(System.in);
        while(true){
            int x = sc.nextInt();
            int y = sc.nextInt();
            if(x == 0 && y == 0) break;
            if(x <y){
                System.out.println(x+ " " +y);
            }else{
                System.out.println(y+ " " +x);
            }
        }
    }
}


Measured memory_bytes: 35360
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <vector>

using namespace std;

class Disjointset {
private:
	vector<int> p, rank;
	void makeset(int x) {
		p[x] = x;
		rank[x] = x;
	}
	void link(int x, int y) {
		if (rank[x] > rank[y]) {
			p[y] = x;
		} else {
			p[x] = y;
			if (rank[x] == rank[y]) {
				++rank[y];
			}
		}
	}
public:
	Disjointset(int size) {
		p.resize(size, 0);
		rank.resize(size, 0);
		for (int i = 0; i < size; ++i)
			makeset(i);
	}
	bool same(int x, int y) {
		return findSet(x) == findSet(y);
	}
	int findSet(int x) {
		if (p[x] != x) {
			p[x] = findSet(p[x]);
		}
		return p[x];
	}
	void unite(int x, int y) {
		link(findSet(x), findSet(y));
	}

};

class Edge {
public:
	int s, t, w;

	Edge(int s, int t, int w) {
		this->s = s;
		this->t = t;
		this->w = w;
	}

	bool operator <(const Edge& edge) const {
		return this->w < edge.w;
	}
};
int main() {

	int v, e;
	scanf("%d %d", &v, &e);

	Disjointset disjointset(v);

	vector<Edge> E;

	for (int i = 0; i < e; ++i) {
		int s, t, w;
		scanf("%d %d %d", &s, &t, &w);
		Edge edge(s, t, w);
		E.push_back(edge);
	}

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

	vector<int> G;
	int total = 0;
	for (int i = 0; i < (int) E.size(); ++i) {
		Edge e = E[i];
		if (!disjointset.same(e.s, e.t)) {
			total += e.w;
			disjointset.unite(e.s, e.t);
		}
	}
	cout << total << endl;

	return 0;
}

Measured memory_bytes: 4580
#include<stdio.h>
#include<stdlib.h>
#define INF 0xAAAAAAAALLU
struct goods {
  int profit;
  long long int weight;
};
long long int **C;
struct goods *item;
int knapsack2(int size, int limit, int wlimit);
int main(void)
{
  int i, n, sumprofit = 0;
  long long int w;
  scanf("%d%lld", &n, &w);
  C = (long long int**)malloc(sizeof(long long int*) * (n + 1));
  item = (struct goods*)malloc(sizeof(struct goods) * (n + 1));
  for (i = 1; i <= n; i++) {
    scanf("%d%lld", &item[i].profit, &item[i].weight);
    sumprofit += item[i].profit;
  }
  for (i = 0; i <= n; i++) {
    C[i] = (long long int*)malloc(sizeof(long long int) * (sumprofit + 1));
    C[i][0] = 0;
  }
  for (i = 0; i <= sumprofit; i++) C[0][i] = INF;
  C[0][0] = 0;
  printf("%d\n", knapsack2(n, sumprofit, w));
  for (i = 0; i <= n; i++) free(C[i]);
  free(C);
  free(item);
}
int knapsack2(int size, int limit, int wlimit)
{
  int i, j;
  long long int res = 0;
  for (i = 1; i <= size; i++) {
    for (j = 1; j <= limit; j++) {
      C[i][j] = C[i-1][j];
      if (item[i].profit > j) continue;
      if (item[i].weight + C[i-1][j-item[i].profit] < C[i-1][j]) {
        C[i][j] = item[i].weight + C[i-1][j-item[i].profit];
      }
    }
  }
  for (i = 0; i <= limit; i++) {
    if (C[size][i] <= wlimit) res = i;
  }
  return res;
}


Measured memory_bytes: 9408
def resolve():
  K = int(input())

  # K が偶数だったら存在しない
  if K % 2 == 0 or K % 5 == 0:
    print(-1)
    return True

  L = 9 * K
  if K % 7 == 0:
    L = int(K / 7 * 9)

  target = 10
  for i in range(1, L+1):
    mod_L = target % L
    # print(mod_L)
    if mod_L == 1:
      print(i)
      return True
    target = mod_L*10

  print(-1)

if __name__ == "__main__":
  resolve()

Measured memory_bytes: 62920
#include<iostream>
#include<cmath>
#include<iomanip>

using namespace std;

int main(){
	int n;
  	cin>>n;
  	long double x=0,t;string s;
  	for(int i=0;i<n;i++){
    	cin>>t>>s;
    	if(s[0]=='J') x+=t;
      	else x+=380000.0*t;
    }
  	cout<<fixed<<setprecision(12)<<x;
}

Measured memory_bytes: 256
#include <cstdio>

int main(){
	while(true){
		int N;
		scanf("%d", &N);
		if(N == 0){ break; }
		bool field[21][21] = { { false } };
		for(int i = 0; i < N; i++){
			int x, y;
			scanf("%d%d", &x, &y);
			field[x][y] = true;
		}
		int M, rx = 10, ry = 10, count = 0;
		scanf("%d", &M);
		for(int i = 0; i < M; i++){
			char d[2] = "";
			int l;
			scanf("%1s%d", d, &l);
			for(int j = 0; j < l; j++){
				switch(d[0]){
					case 'N': ry++; break;
					case 'E': rx++; break;
					case 'W': rx--; break;
					case 'S': ry--; break;
				}
				if(field[rx][ry]){
					count++;
					field[rx][ry] = false;
				}
			}
		}
		puts((count == N) ? "Yes" : "No");
	}
	return 0;
}

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

using namespace std ;

const int maxn = 1e5 + 5;
int n, h;
int a[maxn];
int b[maxn];
int cmp(int x, int y) {
    return x > y;
}
int main() {
    cin >> n >> h;
    int mx = 0;
    for(int i = 0; i < n; i++) {
        scanf("%d%d", &a[i], &b[i]);
        mx = max(a[i], mx);
    }
    sort(b, b + n, cmp);
    int ans = 0;
    for(int i = 0; i < n; i++) {
        if(b[i] < mx || h <= 0) break;
        ans++;
        h -= b[i];
    }
    if(h > 0) ans += (h / mx);
    if(h > 0 && h % mx) ans++;
    cout << ans << endl;
    return 0;
}


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

using lint = long long;

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int p, n;
    cin >> p >> n;
    map<int, pair<int,int>> problems;
    for (int i = 0; i < n; ++i) {
    	int x; string s;
    	cin >> x >> s;
    	if (s == "AC" && !problems[x].second) 
    		problems[x].second = 1;
    	else if (!problems[x].second) ++problems[x].first;
    }
    int done = 0, tried = 0;
    for (auto u : problems) {
    	done += u.second.second;
    	tried += (u.second.second ? u.second.first : 0);
    }
    cout << done <<' ' << tried << '\n';
}

Measured memory_bytes: 6528
#include <iostream>
#define ll long long
using namespace std;

ll mod=1000003;
const int arm=1000050;
ll fac[arm], finv[arm], inv[arm];
void COMinit(ll m){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for (int i=2; i<arm; ++i){
        fac[i]=(fac[i-1]*i)%m;
        inv[i]=m-(inv[m%i]*(m/i))%m;
        finv[i]=(finv[i-1]*inv[i])%m;
    }
}

ll modpow(ll a, ll b, ll m){
    ll res=1, p=0, now=a;
    b %= (m-1);
    for(int i=0; b>p; ++i){
        if(b&((ll) 1<<i)){
            res=(res*now)%m;
            p |= ((ll) 1<<i);
        }
        now=(now*now)%mod;
    }
    return res;
}
ll modinv(ll a, ll m){
    return modpow(a, m-2, m);
}
ll moddiv(ll a, ll b, ll m){
    return (a*modinv(b, m))%m;
}

ll solve(ll X, ll D, ll N){
    if(D==0) return modpow(X, N, mod);
    if(X==0) return 0;
    ll t=moddiv(X, D, mod), u=modpow(D, N, mod);
    if(t+N>mod) return 0;
    ll v=(fac[t+N-1]*finv[t-1])%mod;
    return (v*u)%mod;
}

int main() {
	int Q;
	cin >> Q;
	COMinit(mod);
	for(int i=0; i<Q; ++i){
	    ll x, d, n;
	    cin >> x >> d >> n;
	    cout << solve(x, d, n) << endl;
	}
	return 0;
}


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

int main()
{
    int N;
    cin >> N;
    string c;
    cin >> c;
    int i;
    vector<int> red_from_left(N + 1), white_from_right(N + 1);
    red_from_left[0] = 0;
    white_from_right[N] = 0;
    for (i = 1; i < N + 1; i++)
    {
        if (c[i - 1] == 'W')
        {
            red_from_left[i] = red_from_left[i - 1] + 1;
        }
        else
        {
            red_from_left[i] = red_from_left[i - 1];
        }
        if (c[N - i] == 'R')
        {
            white_from_right[N - i] = white_from_right[N - i + 1] + 1;
        }
        else
        {
            white_from_right[N - i] = white_from_right[N - i + 1];
        }
    }
    int count = N;
    for (i = 0; i < N + 1; i++)
    {
        if (red_from_left[i] >= white_from_right[i])
        {
            if (count > red_from_left[i])
            {
                count = red_from_left[i];
            }
        }
        else
        {
            if (count > white_from_right[i])
            {
                count = white_from_right[i];
            }
        }
    }
    cout << count << endl;
    return 0;
}

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

short ss[90061];
short ee[90061];
int ans[10000];
int c = 0;

int ch2int(char c){
    return (int)c - (int)'0';
}

int st2int(string s){
    return (ch2int(s[0]) * 10 + ch2int(s[1])) * 3600 + (ch2int(s[3]) * 10 + ch2int(s[4])) * 60 + ch2int(s[6]) * 10 + ch2int(s[7]);
}

int main()
{
    while(true){
        int n;
        cin >> n;
        if(n == 0) break;
        c++;
        int maxi = 0;
        vector<string> s(n, ""), e(n, "");
        for (int j = 0; j <= 90060; j++)
        {
            ss[j] = 0;
            ee[j] = 0;
        }
        for (int i = 0; i < n; i++)
        {
            cin >> s[i] >> e[i];
            ss[st2int(s[i])] = ss[st2int(s[i])] + 1;
            ee[st2int(e[i])] = ee[st2int(e[i])] + 1;
        }
        int count = 0;
        for (int j = 0; j <= 90060; j++)
        {
            count = count + ss[j];
            count = count - ee[j];
            if (maxi < count)
            {
                maxi = count;
            }
        }
        ans[c - 1] = maxi;
    }

    for(int k = 0; k < c; k++) cout << ans[k] << endl;

    return 0;
}


Measured memory_bytes: 4140
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<string,ll> P;
typedef pair<P,ll> PP;

void Main() {
  ll n;
  R n;
  PP a[n];
  rep(i,n) {
    cin >> a[i].F.F >> a[i].F.S;
    a[i].F.S*=-1;
    a[i].S=i+1;
  }
  sort(a,a+n);  
  rep(i,n) pr(a[i].S);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 256
#include <cstdio>
#include <climits>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <cstdio>
#include <climits>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <cstring>
#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
long long MOD = 1000000007;
long long INF = 1000000000000000;

typedef long long ll;
typedef unsigned long long ull;

ull powMod(ull x, ull n) {
  if (n == 0) return 1;
  if (n == 1) return x;
  ull tmp = powMod(x, n / 2);
  if (n % 2 == 0) return (tmp * tmp) % MOD;
  return ((ull)2) * (tmp * tmp) % MOD;
}

int main(void) {
  ll n; cin >> n;
  ll loop = ((ll)1) << n;

  ll a[20];
  ll x[20][20], y[20][20];
  rep(i, n) {
    cin >> a[i];
    rep(j, a[i]) {
      cin >> x[i][j] >> y[i][j];
      x[i][j]--;
    }
  }

  ll ans = 0;

  rep(i, loop) {
    ll flag = 0;
    rep(j, n) {
      ll f = ((i >> j) & 1);
      rep(k, a[j]) {
	if (f == 1) {
	  if (((i >> x[j][k]) & ((ll)1)) != y[j][k]) flag++;
	} 
	if (flag > 0) break;
      }
      if (flag > 0) break;
    }
    if (flag == 0) {
      ll cnt = 0;
      rep(j, n) cnt += ((i >> j) & ((ll)1));
      ans = max(ans, cnt);
    }
  }

  cout << ans << endl;

  return 0;
}
	


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

int main()
{
    int a, b, c;

    cin >> a >> b >> c;

    int res = 0;

    for (int i = a; i <= b; ++i)
    {
        if (c % i == 0)
            ++res;
    }
    cout << res << endl;
}


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

vector<long> prob,nd;

int main(){
  long n,m;
  long tmp;
  cin>>n;

  for(int i=0;i<n;i++){
    cin>>tmp;
    prob.push_back(tmp);
  }

  sort(prob.begin(), prob.end());
  cin>>m;
  for(int i=0;i<m;i++){
    cin>>tmp;
    nd.push_back(tmp);
  }
  sort(nd.begin(), nd.end());
  if(includes(prob.begin(), prob.end(), nd.begin(), nd.end())){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }



  return 0;
}


Measured memory_bytes: 4848
#include <iostream>
#include <vector>

using namespace std;

int main() {

	long long N = 1, Q;
	cin >> N;

	vector<long long> v(100001);
	v.resize(100001);

	for (long long i = 0; i < N; i++) {
		int a;
		cin >> a;
		v[a]++;
	}
	cin >> Q;

	long long sum = 0;
	for (int i = 1; i < 100001; i++) {
		sum += i * v[i];
	}

	for (int i = 0; i < Q; i++) {
		int b, c;
		cin >> b;
		cin >> c;

		sum -= v[b] * b;
		sum += v[b] * c;
		v[c] += v[b];
		v[b] = 0;
		cout << sum << endl;
	}

	return 0;
}

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

int main() {
    int N;
    cin >> N;
    vector<int> ans(10000);
    for (int i = 1; i < 150; ++i) {
        for (int j = 1; j < 150; ++j) {
            for (int k = 1; k < 150; ++k) {
                int num = i*i + j*j + k*k + i*j + j*k + k*i;
                if (num <= 10000) ++ans.at(num-1);
            }
        }
    }
    rep(i,N) cout << ans.at(i) << endl;
}


Measured memory_bytes: 3604
#include <iostream>
#include <algorithm>
using namespace std;
 
int main() {
    int n, a[100000], x, y, k;
    cin >> n;
    for(int i = 0; i < n; i++) cin >> a[i];
    sort(a, a + n, greater<>());
    for(k = 0; k < n && x != a[k]; x = a[k++]) ;
    for(k++; k < n && y != a[k]; y = a[k++]) ;
    if (k == n) y = 0;
    cout << (long long)x * y << endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
using ll = long long;
using P = pair<int,int>;
using PP = pair<int,pair<int,int>>;
using T = tuple<string,int,int>;
const ll INF = 1LL<<60;
const int ny[4] = {-1,1,0,0}, nx[4] = {0,0,-1,1};
int sy,sx,gy,gx;

int main(){
  int n,k; cin >> n >> k;
  vector<int> x(n);
  rep(i,n) cin >> x[i];
  int ans = 0;
  for(int i = 0; i < n; i++){
    if(abs(0-x[i]) < abs(k-x[i])){
      ans += abs(0-x[i]);
    }else{
      ans += abs(k-x[i]);
    }
  }
  cout << ans * 2 << endl;
  return 0;
}


Measured memory_bytes: 256
N,M=map(int,input().split())
List=[[int(i) for i in input().split()] for i in range(M)]
for i in range(M):
  List[i].append(i)
List.sort(key=lambda x:[x[0],x[1]])
x=0
pre_p=1
ID=[""]*M
for i in List:
  if pre_p==i[0]:
    x+=1
  else:
    x=1
  ID[i[2]]+="0"*(6-len(str(i[0])))
  ID[i[2]]+=str(i[0])
  ID[i[2]]+="0"*(6-len(str(x)))
  ID[i[2]]+=str(x)
  pre_p=i[0]
for i in ID:
  print(i)

Measured memory_bytes: 35492
#include <bits/stdc++.h>
#define rep(i,a,n) for(int i =a; i<n; i++) 
#define ll long long
#define MOD 1000000007
using namespace std;
  
int N, C[3];
ll sum = 1;

int main() {
  cin >> N; 
  ll A[N]; rep(i,1,N+1) cin >> A[i];
  
  rep(i,1,N+1) {
    ll cnt = 0, id = -1;
    if (A[i] == C[0]) { cnt++; id = 0; }
	if (A[i] == C[1]) { cnt++; id = 1; }
    if (A[i] == C[2]) { cnt++; id = 2; }
    if (id == -1) {
      cout << "0" << endl;
      return 0;
    }
    sum *= cnt; C[id]++;
    sum %= 1000000007;
  }
  cout << sum << endl;
}

Measured memory_bytes: 4336
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define int long long
#define endl "\n"
#define pii pair<int,int> 
#define ff first
#define ss second
#define mii map<int,int>
#define si set<int>
#define sti stack<int>
#define qi queue<int>
#define vi vector<int>
#define pq priority_queue<int>
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const int M=1e9+7;

int32_t main(){
	IOS;
	int n,m;
	cin>>n>>m;
	int ans=0;
	while(1){
		n/=m;
		ans++;
		if(n==0) break;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<ll,ll> P;
#define M 998244353
#define F first
#define S second
#define PB push_back
#define INF 100000000000000000
struct PQ{
	priority_queue<ll>d;
	priority_queue<ll,vector<ll>,greater<ll>>u;
	ll ds,dn;
	PQ(void){
		ds=0,dn=0;
	}
	void psd(ll x){
		d.push(x);
		ds+=x;
		dn++;
	}
	ll ppd(void){
		ll res=d.top();
		ds-=res;
		dn--;
		d.pop();
		return res;
	}
	void psu(ll x){
		u.push(x);
	}
	ll ppu(void){
		ll res=u.top();
		u.pop();
		return res;
	}
};
ll gcd(ll x,ll y){
	if(x<y)swap(x,y);
	if(y==0)return 1;
	if(x%y==0)return y;
	return gcd(y,x%y);
}
ll n,s,ansx,ansy=1;
P x[100005];
PQ pq;
int main(void){
	cin>>n;
    for(int i=0;i<n;i++)cin>>x[i].S>>x[i].F;
    sort(x,x+n);
    for(int i=0;i<n;i++)s+=max(0LL,x[i].F-x[i].S);
    for(int i=0;i<n;i++){
		s-=max(0LL,x[i].F-x[i].S);
		while(!pq.u.empty()&&pq.ds+x[i].S+pq.u.top()<=s+x[i].F)pq.psd(pq.ppu());
		ll nx=0,ny=1;
		if(pq.ds+x[i].S<=s+x[i].F&&s<=pq.ds+x[i].S)ny=x[i].F,nx=pq.dn*ny+x[i].F-x[i].S+s-pq.ds;
		if(D(ansx)/D(ansy)<D(nx)/D(ny))ansx=nx,ansy=ny;
		pq.psd(x[i].S);
		pq.psu(pq.ppd());
	}
	ansy*=n;
	ll g=gcd(ansx,ansy);
	if(ansx==0)ansy=1;
	ansx/=g,ansy/=g;
	cout<<ansx<<' '<<ansy<<endl;
}


Measured memory_bytes: 3192
a,b=map(int,input().split())
if b-a<=3:
  ans=0
  for i in range(a,b+1):
    ans=ans^i
  print(ans)
else:
  ans=0
  if a%4!=0:
    for i in range(a,(1+a//4)*4):
      ans=ans^i
  ans2=0
  for i in range((b//4)*4,b+1):
    ans2=ans2^i
  print(ans^ans2)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef set<int> si;
typedef map<string, int> msi;
typedef long long ll;
const ll INF = 1e18L + 1;

int main()
{
  ll x, y;
  cin >> x >> y;
  int ans = 1;
  while (x < y)
  {
    x <<= 1;
    if (x <= y)
      ans++;
  }
  std::cout << ans << std::endl;
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCode
{
    class Program
    {
        static void Main(string[] args)
        {
            string InputNum = Console.ReadLine();
            string[] DivNum = InputNum.Split(' ');
            int Num = int.Parse(DivNum[0]);
            int Length = int.Parse(DivNum[1]);
            string[] S = new string[Num];
            string SList = null;
            for (int i = 0; i < Num; i++)
            {
                S[i] = Console.ReadLine();   //a=96
            }
            Array.Sort(S);

            for (int i = 0; i < S.Length; i++)
            {
                SList += S[i] ;
            }
            Console.WriteLine(SList);
        }
            
    }
}


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

int main() {
  int n;
  cin>>n;
  vector<string> s(n);
  for (int i=0;i<n;++i) {
    cin>>s[i];
    sort(s[i].begin(),s[i].end());
  }
  sort(s.begin(),s.end());
  long long int ans=0;
  int i=0;
  for (int j=1;j<n;++j) {
  	if (s[i]==s[j]) {
      ans+=(j-i);
    } else {
      i=j;
    }
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 7296
from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson, minimum_spanning_tree
from scipy.sparse import csr_matrix, coo_matrix, lil_matrix
import numpy as np
from functools import reduce

from collections import deque, Counter, defaultdict
from itertools import product, permutations,combinations
from operator import itemgetter
from heapq import heappop, heappush
from bisect import bisect_left, bisect_right, bisect
from fractions import gcd
from math import ceil,floor, sqrt, cos, sin, pi, factorial
import statistics
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**8)
INF = float('inf')
MOD = 10**9+7
def lcm(a, b):
  return a*b//gcd(a, b)

def main():
  N, K = map(int, readline().split())
  A = list(map(int, readline().split()))
  print(ceil((N-1)/(K-1)))
  
  
  
  
  
if __name__ == '__main__':
  main()

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

using namespace std;

int main() {
    string s;
//    cin >> noskipws >> s; 
    getline(cin, s);
    std::for_each(s.begin(), s.end(), [](char & c) {
        if (c >= 'A' && c <= 'Z') {
            c = ::tolower(c);
        } else if (c >= 'a' && c <= 'z') {
            c = ::toupper(c);
        }
    });
    cout << s << endl;
    return 0;
}



Measured memory_bytes: 3136
import sys
from collections import defaultdict

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_nl = lambda: list(map(int, readline().split()))
in_na = lambda: map(int, read().split())
in_s = lambda: readline().rstrip().decode('utf-8')


def main():
    N, M = in_nn()
    t = in_na()
    PY = list(zip(t, t))

    d = defaultdict(list)

    for i in range(M):
        p, y = PY[i]
        d[p].append(y)

    ans = dict()
    for k, v in d.items():
        v.sort()
        for i, y in enumerate(v):
            ans[(k, y)] = '{:0>6}{:0>6}'.format(k, i + 1)

    for i in range(M):
        p, y = PY[i]
        print(ans[(p, y)])


if __name__ == '__main__':
    main()


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

int main(){
	ll n,d;
	cin>>n>>d;
	pair<ll,ll>  arr[n];
	for(int i=0;i<=n-1;i++){
		cin>>arr[i].first>>arr[i].second;;
		

	}

	ll ans = 0;

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

	cout<<ans;

}

Measured memory_bytes: 6716
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let line = read_as_vec::<usize>();
    let (n, m, k) = (line[0], line[1], line[2]);
    if k%n == 0 || k%m == 0{
        println!("Yes");
        return;
    }

    for i in 1..n{
        for j in 1..m{
            if k == i*j + (n-i) * (m-j){
                println!("Yes");
                return;
            }
        }
    }
    println!("No");
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
using namespace std;
int main(){
  int N, M, X;
  cin >> N >> M >> X;
  vector<int> A(M);
  for(int i = 0; i < M; ++i) cin >> A[i];
  for(int i = 0; i < M; ++i){
	if(A[i] <= X) continue;
	cout << min(i,M-i) << endl;
    return 0;
  }
  cout << 0 << endl;
}

Measured memory_bytes: 256