akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
 
void output( int A[], int N )
{
    int i;
 
    for( i = 0; i < N; i++ ) {
    printf( "%d", A[i] );
    if(i!=N-1)printf(" ");
    }
    printf( "\n" );
};
 
void bubbleSort( int A[], int N )
{
    int i, j, temp,change;
    change=0;
    for( i = 0; i < N-1; i++ ) {
        for( j = N-1; j > i; j-- ) {
            if( A[j-1] > A[j] ) {
                 
                temp = A[j];
                A[j] = A[j-1];
                A[j-1] = temp;
                change=change+1;
                
            }
        }
     
    }
    output( A, N );
    printf("%d\n",change);
};
 
int main(void)
{
    int A[100], N, i;
    scanf("%d",&N);
    for(i=0;i<N;i++){
        scanf("%d",&(A[i]));
         
    }
   
 
  
    bubbleSort(A, N);
  
     
}

Measured memory_bytes: 2760
n, m = map(int, input().split())
h = [int(x) for x in input().split()]
res_list = [1] * n
for i in range(m):
    ai, bi = map(int, input().split())
    if h[ai-1] < h[bi-1]:
        res_list[ai-1] = 0
    elif h[ai-1] == h[bi-1]:
        res_list[ai-1] = 0
        res_list[bi-1] = 0
    else:
        res_list[bi-1] = 0
print(sum(res_list))

Measured memory_bytes: 20112
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using vb = vector<bool>;
using mll = map<ll, ll>;
using sll = stack<ll>;
#define REP(i,n) for(ll i(0);(i)<(n);(i)++)
#define rep(i,n) for(ll i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
#define enld endl //* missspell check
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
const string YES = "Yes";
const string NO = "No";

void solve(std::string S){
    
    ll N = S.length();
    
    ll cnt = 0;
    REP(i, N) {
        cnt += S[i] - '0';
    }
    if(cnt % 9 == 0) cout<<YES<<endl;
    else cout<<NO<<endl;
}
int main(){
    std::string N;
    std::cin >> N;
    solve(N);
    return 0;
}


Measured memory_bytes: 3492
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<map>
#include<set>
#include<queue>

using namespace std;

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(a) (a).begin(),(a).end()
#define PI 3.141592653589793238
#define INF 1050000000
#define INFL (long long)(4e18)

using vi = vector<int>;

template<class T>
struct Edge {
	int to;
	T cost;
	Edge() {};
	Edge(int to, T cost) : to(to), cost(cost) {};
};

template<class T>
class Graph {
	int n;
	bool directed;
	vector<vector<Edge<T>>> edges;
public:

	Graph(int n, bool directed) :n(n), directed(directed), edges(vector<vector<Edge<T>>>(n)) {};
	Graph() {};

	void add(int to, T cost) {
		emplace_back(to, cost);
	}

	int size() {
		return n;
	}
};


int main() {


	long long int N, M, K;

	cin >> N >> M >> K;

	vector<long long> A(N), B(M);


	REP(i,N){
		cin >> A[i];
	}

	REP(i, M) {
		cin >> B[i];
	}

	vector<long long> a, b;

	a.push_back(0);
	b.push_back(0);

	REP(i, N) {
		a.push_back(A[i] + a[i]);
	}

	REP(i, M) {
		b.push_back(B[i] + b[i]);
	}
	
	long long ans = 0,j = M;

	REP(i, N + 1) {
		if (a[i] > K)break;
		while (a[i] + b[j] > K) {
			j--;
		}
		ans = max(ans, i + j);
	}


	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 11044
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,o,n) for(long long i = o;i<n;i++)
#define oneforall ios::sync_with_stdio(false);cin.tie(0);
#define all(v) (v).begin(),(v).end()
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
const long long INF=1e18;
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
typedef vector<int> vi;
typedef vector<long long> vl;
typedef long long ll;
typedef vector<pair<long,long>> vpll;
typedef vector<pair<int,int>> vpii;
int main() {
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	ini(n);
	int a[10000010] = {};
	int bit[10000010] = {};
	vi x;
	FOR(i,0,n){
		in(a[i + 1]);
	}
	for(int i = n;i>=1;i--){
		int tmp = 0;
		for(int i1 = i;i1<=n;i1+=i){
			tmp^=bit[i1];
		}
		if(tmp != a[i]){
			bit[i] = 1;
			x.push_back(i);
		}
	}
	reverse(all(x));
	out(x.size());
	for(auto x1:x){cout<<x1<<" ";}
	return 0;
}

Measured memory_bytes: 79864
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = numeric_limits<int>::max() /4;
const ll linf = numeric_limits<ll>::max() /4;
const ull ulinf = numeric_limits<ull>::max()/4;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.end(), v.begin());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////



int main(){

    string s;
    cin >> s;
    rep(i,0,sz(s)){
        cout << s[i];
        i++;
    }
    cout << endl;
	return  0;
}

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

int main(void){
    int N;
    cin >> N;
    vector<int> a(N);
    int count = 0;
    for (int i = 0; i < N; i++) cin >> a[i];
    for (int i = 0; i < N; i+=2) {
        if (a[i] % 2 == 1) count++;
    }
    cout << count << endl;
}


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

#define pb push_back
#define ll long long int
#define f(i,g,n) for(int i=g;i<=n;i++)

void dfs(vector<ll> V[],int i,ll curr,ll A[],ll B[],bool C[])
{
	C[i] = true;
	A[i] = curr+B[i];
	curr = A[i];
	for(auto x:V[i])
	{
		if(C[x] == false)
			dfs(V,x,curr,A,B,C);
	}
}

int main()
{
	ios::sync_with_stdio(false);

	ll n,q;
	cin>>n>>q;
	ll A[n+1]={0},B[n+1]={0};
	bool C[n+1]={0};
	vector<ll> V[n+1];
	f(i,0,n-2)
	{
		ll a,b;
		cin>>a>>b;
		V[a].pb(b);
		V[b].pb(a);
	}
	while(q--)
	{
		ll p,x;
		cin>>p>>x;
		B[p] += x;
	}
	dfs(V,1,(ll)0,A,B,C);
	f(i,1,n)
		cout<<A[i]<<" ";
	cout<<"\n";

	return 0;
}

Measured memory_bytes: 32256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <assert.h>
#include <map>
#include <memory.h>
#include <queue>
#include <string.h>
#include <set>
#include <bitset>
using namespace std;

#define ll long long
#define N 300005
#define mod 1000003
#define M 40

int dp[mod][M];

int mul(int x,int y) {
  return (ll)x*y%mod;
}

int mypow(int x,int c) {
  int ret = 1;
  while(c>0) {
    if(c&1) {
      ret = mul(ret,x);
    }
    x = mul(x,x);
    c/=2;
  }
  return ret;
}

void solve() {
  for(int i=1;i<=mod-1;++i) {
    dp[i][0] = i;
  }
  for(int j=1;j<M;++j) {
    for(int i=1;i<=mod-2;++i) {
      dp[i][j] = mul(dp[i][j-1], dp[ (i+ (1LL<<(j-1) )  )%mod][j-1]);
    }
  }
  int Q;scanf("%d",&Q);
  while(Q--) {
    int x,d,n;scanf("%d %d %d ", &x,&d,&n);
    if(d==0) {
      printf("%d\n", mypow(x,n));
    }
    else {
      int cur = x,ret = 1;
      cur = mul(cur, mypow(d,mod-2));
      int u = mypow(d,n);
      for(int i=M-1;i>=0;--i) {
        if(n&(1LL<<i)) {
          ret = mul(ret, dp[cur][i]);
          cur = (cur + (1LL<<i))%mod;
        }
      }
      ret = mul(ret,u);
      printf("%d\n", ret);
    }
  }
}

int main() {
  //freopen("input.txt","r",stdin);
  solve();
  return 0;
}


Measured memory_bytes: 157184
# 入力
x1,y1,x2,y2=map(int,input().split())

x3=x2-(y2-y1)
y3=y2+(x2-x1)
x4=x3-(y3-y2)
y4=y3+(x3-x2)

# 出力
print(x3,y3,x4,y4)

Measured memory_bytes: 3316
import java.util.Scanner;


// 152_b
public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        String s = sc.next();

        int count = 0;

        for (int i = 0; i < n - 2; i++) {
            if (s.charAt(i) == 'A' && s.charAt(i + 1) == 'B' && s.charAt(i + 2) == 'C') {
                count++;
            }
        }

        out(count);
    }

    /*
     * 以下メソッド集
     */

    static long gcd(long a, long b) {

        return (b == 0) ? a : gcd(b, a % b);
    }

    static int gcd(int a, int b) {

        return (b == 0) ? a : gcd(b, a % b);
    }

    static void out(String info) {

        System.out.println(info);
    }

    static void out(int info) {

        System.out.println(info);
    }

    static void out(double info) {

        System.out.println(info);
    }

    static void out(long info) {

        System.out.println(info);
    }

}


Measured memory_bytes: 23636
#include<bits//stdc++.h>
#define rep(i, a) for(int i=0; i<(int)(a); i++)
using namespace std;
long long int d[300][300];int v, n, c, e,u;
const  long long int INF = (1LL<<32);
void warshall_floyd(int n) { // nは頂点数
    rep(k, n) {  // 経由する頂点
        rep(i, n) {// 開始頂点
            rep(j, n) {// 終端
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }
}
int main()
{
    int h, w;cin >> h >> w;
    
    rep(i, 10) {
        rep(j, 10) {
            cin >> d[i][j];
        }
    }
    warshall_floyd(10);
    int sum = 0;
    rep(i, h) {
        rep(j, w) {
            cin >> n;
            if (n == -1)
                continue;
            sum += d[n][1];
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<set>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<string>
#include<stack>
#include<map>
#include<queue>
#include<iomanip>
#define INF 1e9
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using ll = long long;
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << "\t";
  }
  return s;
}

template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
  s << vv[i] << endl;
  }
  return s;
}

int n;
vector<int> v;
vector<int> counter1(200000,0);
vector<int> counter2(200000,0);
vector<int> counter3(200000,0);
vector<int> counter4(200000,0);
signed main(){
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  cin >> n;
  v.resize(n);
  rep(i,n){
    cin >> v[i];
  }

  for(int i = 0 ; i < n ; i = i + 2){
    counter1[v[i]]++;
  }
  int max_itm1 = *max_element(counter1.begin(),counter1.end());
  int max_itm_idx = max_element(counter1.begin(),counter1.end()) - counter1.begin();
  for(int i = 1 ; i < n ; i = i + 2){
    if(v[i] == max_itm_idx){
      continue;
    }
    counter2[v[i]]++;
  }
  int max_itm2 = *max_element(counter2.begin(),counter2.end());
  int cand1 = n - max_itm1 - max_itm2;


  for(int i = 1 ; i < n ; i = i + 2){
    counter3[v[i]]++;
  }
  int max_itm3 = *max_element(counter3.begin(),counter3.end());
  int max_itm_idx3 = max_element(counter3.begin(),counter3.end()) - counter3.begin();
  for(int i = 0 ; i < n ; i = i + 2){
    if(v[i] == max_itm_idx3){
      continue;
    }
    counter4[v[i]]++;
  }
  int max_itm4 = *max_element(counter4.begin(),counter4.end());

  int cand2 = n - max_itm3 - max_itm4;

  cout << min(cand1,cand2) << endl;


  return 0;
}


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

int main()
{
    
    string s1,s2;
    cin >> s1 >> s2;
    s2.pop_back();
    if (s1 == s2)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3616
N = int(input())
L = list(map(int, input().split()))

L.sort()

# a<b<c and a+b > c
ans = 0
for i in range(N):
  for j in range(i+1,N):
    for k in range(j+1,N):
      a,b,c = L[i], L[j], L[k]
      if a==b or b == c or c == a:
        continue
      if a+b > c:
        ans += 1
        
print(ans)

Measured memory_bytes: 67924
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<deque>
#include<cmath>
#define rep(i,n) for(int i = 0;i<n;i++)
#define _GLIBCXX_DEBUG
using ll = long long; 
using namespace std;

int main() {
   string s;
   cin >> s;
   vector<string>divide = {"dream","dreamer","erase","eraser"};
   reverse(s.begin(),s.end());
   for(int i = 0;i<4;i++) reverse(divide[i].begin(),divide[i].end()); 
   bool can = true;
   for(int i = 0;i<s.size();) {
       bool can2 = false;
       for(int j = 0;j<4;j++) {
           if(s.substr(i,divide[j].size()) == divide[j]) {
               can2 = true;
               i +=divide[j].size();
           }
       }
       if(!can2) {
           can = false;
           break;
       }
   }
   if(can) cout << "YES" << endl;
   else cout << "NO" << endl;
}

Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _0004
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = "";
            double[] term = new double[6];
            List<string> answer = new List<string>();
            while ((s = Console.ReadLine()) != null)
            {
                term = s.Split(' ').Select(double.Parse).ToArray();
                //0=a 1=b 2=c 3=d 4=e 5=f
                double x = 0;
                double y = 0;

                x = Math.Round((term[2] * term[4] - term[5] * term[1]) / (term[0] * term[4] - term[3] * term[1]),3,MidpointRounding.AwayFromZero);//c * e - f * b / a * e - d * b
                y = Math.Round((term[2] * term[3] - term[5] * term[0]) / (term[1] * term[3] - term[4] * term[0]),3,MidpointRounding.AwayFromZero);//c * d - f * a / b * d - e * a

                Console.WriteLine("{0:f3} {1:f3}",x,y);
            }
        }
    }
}



Measured memory_bytes: 16368
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template < typename T > string tost( const T& n ) { ostringstream stm; stm << n; return stm.str();}
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 const INF = 1001001001;


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

int N,X;
cin >> N >> X;
vi m(N);
rep(i,N) {
    cin >> m[i];
    X -= m[i];
}
sort(all(m));
int ans = N;
ans += X / m[0];
cout << ans << endl;

return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    ll a, b, c; cin >> a >> b >> c;
    ll cab = c - a - b;
    if (cab > 0 && 4 * a * b < cab * cab) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000000
#define INF 1000000000000000
#define ll long long
#define ull unsigned long long
#define M 1000000007
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define int ll

vector<int> sosu;

void f(int m){
  for(int i=2;i*i<=m;i++){
    if(m%i==0) return;
  }

  sosu.PB(m);
}


signed main(){
  int m,a,b;

  FOR(i,2,10000){
    f(i);
  }
  

  while(1){
    cin>>m>>a>>b;
    if(m==0) break;
    int ap=0,aq=0,am=0;
    rep(i,sosu.size()){
      FOR(j,i,sosu.size()){
        int p=sosu[i];
        int q=sosu[j];
        if(p*q>m) break;
        
        if(p*q<=m&&a*q<=b*p&&am<p*q){ 
        ap=p;
        aq=q;
        am=p*q;
        }
      }
    }
    cout<<ap<<' '<<aq<<endl;
  }
}


Measured memory_bytes: 3080
def main():
  from itertools import product
  import sys
  sys.setrecursionlimit(10**6)
  readline = sys.stdin.readline
  ints = lambda: map(int, readline().split())
  floats = lambda: map(float, readline().split())
  lli = lambda I, J: [[0] * J for _ in range(I)]
  mod = 10**9+7

  h, w, k = ints()
  ans = h + w
  s = [list(map(int, input())) for _ in range(h)]
  for comb in product([False, True], repeat=h - 1):
    divs = 0
    a = [s[0][:]]
    for row, isd in zip(s[1:], comb):
      if isd:
        a += [row[:]]
        divs += 1
      else:
        for i in range(w):
          a[divs][i] += row[i]
    dh = divs + 1
    ta = [list(i) for i in zip(*a)]
    currow = ta[0]
    imp = False
    for row in ta[1:]:
      if any([i > k for i in currow]):
        imp = True
        break
      else:
        temp = [i + j for i, j in zip(currow, row)]
        if any([i > k for i in temp]):
          currow = row
          divs += 1
        else:
          currow = temp
    if not imp:
      ans = min(ans, divs)
  print(ans)

if __name__ == '__main__':
  main()

Measured memory_bytes: 3676
N = int(input())

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    # divisors.sort()
    return divisors

K = []
# N = K**n*(K*m+1)
# n >= 1

K1 = make_divisors(N)
K1.pop(0)
# print(K1)

for k in K1:
    # print("k=",k)
    n=0
    while N-k**n >= 0:
        # print((N-k**n)%(k**(n+1)))
        # print("n=",n)
        if (N-k**n)%(k**(n+1))==0:
            K.append(k)
        n += 1
# print(K)

# n == 0
K2 = make_divisors(N-1)
K2.pop(0)
K += K2

# print(K)

print(len(K))



Measured memory_bytes: 3316
#include<stdio.h>
int main(void){
  int a[200];
  int len=0;
  int i;
  char b;
  int flag=0;

  while((scanf("%c",&b))!=EOF ){
    a[len]=b;
    if(a[len]!=' ' && flag==0){
      len++;
      if(a[len-1]=='+' || a[len-1]=='-' || a[len-1]=='*'){
        if(a[len-1]=='+') a[len-3]=a[len-3]+a[len-2];
        else if(a[len-1]=='-') a[len-3]=a[len-3]-a[len-2];
        else a[len-3]=a[len-3]*a[len-2];
        len-=2;
      }
      else{
        a[len-1]-='0';
        flag=1;
      }
    }
    else if(a[len]!=' ' && flag==1){
      a[len-1]=a[len-1]*10+a[len]-'0';
      flag=1;
    }
    else flag=0;
  }

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

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

typedef long long ll;
typedef pair<int,int> P;
typedef map<int,int> M;
typedef vector<int> V;
#define push_back pb;
#define INF (int)(1e9)
#define EPS (1e-7)
#define MOD ((ll)1e9+7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  (a.begin(),a.end())
#define RALL(a) (a.begin(),a.end(),greater<int>())
#define SHIFT(a) (a.begin(),a.begin()+1,a.end())

/*--------------------------------------------*/
/*
int dx[4]={-1,0,1,0};//四方に移動
int dy[4]={0,-1,0,1};
*/
/*--------------------------------------------*/
/*--------------------------------------------*/
/*
ll factorial(ll n){
    if(n==1)return 1;
    return n*factorial(n-1);
}
ll lcm(ll A, ll B) {//最小公倍数
    ll a=A;
    ll b=B;
    if (a==0 || b==0) {return 0;}
    if (a<0) {a=-a;}
    if (b<0) {b=-b;}
    while(b>0) {
        ll c=a%b;
        a=b;
        b=c;
    }
    return A/a*B;
}

ll gcd(ll a,ll b){
    while(b!=0) {
        int t=b;
        b=a%b;
        a=t;
    }
    return a;
}

//入力はすべて正とする
bool is_prime(int n) {//素数判定o(√n)
    for (int i=2;i*i<=n;i++){
        if(n%i==0)return false;
    }
    return n!=1;//1の場合は例外
}

vector<ll> divisor(ll n){//約数の列挙o(√n)
    vector<ll> res;
    for(ll i=1;i*i<=n;i++) {
        if(n%i == 0){
        res.push_back(i);
        if(i!=n/i)res.push_back(n/i);
        }
    }
    return res;
}//vector<ll>k=divisor(n);rep(i,k.size())cout<<k[i]<<endl;//のように使う

map<ll,ll> prime_factor(ll n){//素因数分解o(√n)
    map<ll,ll>res;    
    for(ll i=2;i*i<=n;i++) {
        while (n%i==0) { 
            ++res[i];
            n/=i;
        }
    }
    if (n!=1)res[n]=1;
    return res;
}//map<ll,ll> k=prime_factor(n);for(auto i=k.begin();i!=k.end();i++){cout<<i->first<<" "<<i->second<<endl;}//みたいに使う

vector<ll> prime_list(ll n){//n以下の素数を全て見つける
    vector<ll> is_prime(n);//is_prime[i]が1ならiは素数
    for(ll i=2;i<=n;i++)is_prime[i]=1;//最初はみんな素数かも
    for(ll i=2;i*i<=n;i++){//素数の整数倍を消していく(√nまで)
        if(is_prime[i]){
            for(ll j=2*i;j<=n;j++){
                if(j%i==0){
                    is_prime[j]=0;                
                }
            }
        }
    }return is_prime;
}vector<ll>k=prime_list(n);REP(i,n){if(k[i])cout<<i<<endl;}のように使う
*/
/*--------------------------------------------*/


int main(){
    string s,t;cin>>s>>t;
    int flag=0;
    rep(i,s.size()){
        //cout<<s<<endl;
        if(s==t){flag=1;break;}
        rotate(s.begin(),s.end()-1,s.end());
        //cout<<s<<endl;
    }
    cout<<(flag?"Yes":"No")<<endl;
}




Measured memory_bytes: 256
#include <iostream>

int main() {
	int in, hour, min, sec;
	std::cin >> in;
	sec = in % 60;
	min = (in - sec) % 3600;
	hour = (in - sec - min) / 3600;
	std::cout << hour << ":" << min / 60 << ":" << sec << std::endl;
	return 0;
}


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

int n, h[100002], dp[100002];

int main(){
	cin >> n;
	for (int i=0;i<n;i++) cin >> h[i];
	dp[0]=0;
	dp[1]=abs(h[0]-h[1]);
	for (int i=2;i<n;i++) dp[i]=min(abs(h[i]-h[i-1])+dp[i-1],abs(h[i]-h[i-2])+dp[i-2]);
	cout << dp[n-1] << "\n";
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> t(n), a(n);
    rep(i, 0, n){
        cin >> t[i] >> a[i];
    }
    int pt = t[0], pa = a[0];
    rep(i, 1, n){
        pt = (pt + t[i] - 1) / t[i] * t[i];
        pa = (pa + a[i] - 1) / a[i] * a[i];
        int q = max(pt / t[i], pa / a[i]);
        pt = q * t[i];
        pa = q * a[i];
    }
    cout << pt + pa << endl;
}

Measured memory_bytes: 256
#define P(x) cout << #x " = " << x << endl
#define PP(x, y) cout << "(" #x ", " #y ") = (" << x << ", " << y << ")" << endl
#define PPP(x, y, z) cout << "(" #x ", " #y ", " #z ") = (" << x << ", " << y << ", " << z << ")" << endl

#include <iostream>
#include <vector>

using namespace std;

const long long MOD = 1000000007;

long long mod(long long a, long long m = MOD)
{
    long long q = a % m;
    if (q < 0)
        q += m;
    return q;
}

long long modadd(long long a, long long b, long long m = MOD)
{
    return (a + b) % m;
}

long long modsub(long long a, long long b, long long m = MOD)
{
    return mod((a % m) - (b % m));
}

long long modmul(long long a, long long b, long long m = MOD)
{
    return (a * b) % m;
}

long long modpow(long long a, long long b, long long m = MOD)
{
    long long c = 1;
    while (b > 0)
    {
        if (b & 1)
            c = modmul(c, a, m);
        a = modmul(a, a, m);
        b >>= 1;
    }
    return c;
}

long long modinv(long long a, long long m = MOD)
{
    long long b = m, u = 1, v = 0;
    while (b)
    {
        long long t = a / b;
        long long tmp;
        a -= t * b;
        tmp = a;
        a = b;
        b = tmp;
        u -= t * v;
        tmp = u;
        u = v;
        v = tmp;
    }
    u %= m;
    if (u < 0)
        u += m;
    return u;
}

long long moddiv(long long a, long long b, long long m = MOD)
{
    return modmul(a, modinv(b, m), m);
}

template <int MAX, int MOD>
class ModCombination
{
  public:
    ModCombination()
    {
        fac[0] = fac[1] = 1;
        facinv[0] = facinv[1] = 1;
        inv[1] = 1;
        for (int i = 2; i < MAX; i++)
        {
            fac[i] = fac[i - 1] * i % MOD;
            inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
            facinv[i] = facinv[i - 1] * inv[i] % MOD;
            // cout << fac[i] << " " << inv[i] << " " << facinv[i] << endl;
        }
    }

    long long get(int n, int k)
    {
        if (n < k)
            return 0;
        if (n < 0 || k < 0)
            return 0;
        return fac[n] * (facinv[k] * facinv[n - k] % MOD) % MOD;
    }

  private:
    long long fac[MAX];
    long long facinv[MAX];
    long long inv[MAX];
};
using ll = long long;

int n;
int a[100001];
int buf[100001];

int main()
{
    cin >> n;
    fill(buf, buf + n + 1, -1);
    int left = -1;
    int right = -1;
    for (int i = 0; i <= n; ++i)
    {
        cin >> a[i];
        if (buf[a[i]] != -1) {
            // P(a[i]);
            left = buf[a[i]];
            right = n - i;
        }
        buf[a[i]] = i;
    }
    // PP(left, right);
    cout << n << endl;
    ModCombination<100002, 1000000007> comb;
    for (int k = 2; k <= n + 1; ++k) {
        // PP(left + right, k - 1);
        cout << modsub(comb.get(n + 1, k), comb.get(left + right, k - 1)) << endl;
    }
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <climits>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <string>
#include <list>
#include <ctime>
#include <complex>
#include <bitset>
#include <tuple>
using namespace std;

typedef long long int lli;

int K, A, B;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> K >> A >> B;
    bool pos = false;
    for(int j = K; j <= B; j += K){
        if(j >= A){
            pos = true;
            break;
        }
    }
    if(pos)
        cout << "OK";
    else
        cout << "NG";
    return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
//#define INF 1145141919810893364
#define INF 810114514
#define PI 3.141592653589
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "No" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl

signed main(void){
    int N,Q;
    vector<int> A;int a;
    int X[114514];
    
    cin >> N >> Q;
    REP(i,N){
        cin >> a;
        A.push_back(a);
    }
    reverse(A.begin(),A.end());
    
    int sum[114514]={},evsum[114514]={};
    REP(i,N){
        sum[i+1]=sum[i]+A[i];
        evsum[i+1]=evsum[i]+(i%2==0?A[i]:0);
    }
    
    vector<int> T,V;
    REP(i,(N-1)/2){//高橋君は後ろからi個を取る //青木君はその後ろからi個を取る
    //残りはよしなに分ける
        int t=0,v=0;
        t=(A[i+1]+A[2*i+2])/2 + 1;
        v+=sum[i+1];
        v+=evsum[N]-evsum[2*i+2];
        T.push_back(t);
        V.push_back(v);
        //cout <<t MM v << endl;
    }
    
    REP(i,Q){
        cin >> X[i];
    }
    
    reverse(T.begin(),T.end());
    reverse(V.begin(),V.end());
    REP(j,Q){
        decltype(T)::iterator it = std::upper_bound(T.begin(), T.end(), X[j]);
        int y=it-T.begin();
        if(y==0){
            cout << sum[(N+1)/2] << endl;
        }else{
            cout << V[y-1] << endl;
        }
        
        
    }
    
    
    return 0;
}



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


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

class CGacha {
public:
	void solve(std::istream& in, std::ostream& out) {
        int n;
        in >> n;
        set<string> s;
        rep(i,n){
            string t;
            in >> t;
            s.insert(t);
        }
        out <<s.size() << endl;
	}
};


int main() {
	CGacha solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 19180
N = int(input())
A = list(map(int, input().split()))

import numpy as np
A_np = np.array(A)

ans = 0

while True:
    A_np = A_np / 2
    if len(np.nonzero(A_np%1)[0]) > 0:
        break
    else:
        ans += 1
        
print(ans)

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

int main()
{
  string S;
  cin >> S;
  size_t N = S.size();
  
  // 一致度
  int count1 = 0;
  int count2 = 0;
  for(int i=0; i<N; i++){
    // 010101010101...
  	// 偶数番目（０番目，２番目，４番目・・・）：0
  	// 奇数番目（１番目，３番目，５番目・・・）：1
	if(i % 2 == 0 && S[i] % 2 == 0){count1 += 1;}
    else if(i % 2 == 1 && S[i] % 2 == 1){count1 += 1;}
    
    // 101010101010...
  	// 偶数番目（０番目，２番目，４番目・・・）：1
  	// 奇数番目（１番目，３番目，５番目・・・）：0
    if(i % 2 == 0 && S[i] % 2 == 1){count2 += 1;}
    else if(i % 2 == 1 && S[i] % 2 == 0){count2 += 1;}
  }
  
  // ひっくり返すと効率の良い方を求める
  int ans = min({N, N - count1, N - count2});
  cout << ans;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <cmath>
#include <stdio.h>
#include <sstream>
#define int_inf 1000000000 //1e9
#define ll_inf  1000000000000000000 //1e18
using namespace std;
template <typename T> std::string to_string(const T& t){
	std::ostringstream os; os<<t; return os.str();
}




int main(){
	int m;
	cin >> m;
	cout << 48-m << endl;
	
	return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;cin>>N;int V=0;
  for(int X=0;X<N;X++){
    int A,B;cin>>A>>B;
    if(A==B)V+=1;
    else V=0;
    if(V>=3){
      cout<<"Yes"<<endl;return 0;
    }
  }
  cout<<"No"<<endl;
}

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


int main(){
    string s,t;
    cin >> s >> t;
    
    sort(s.begin(),s.end());
    sort(t.begin(),t.end());
    reverse(t.begin(),t.end());
    
    if(s<t) cout << "Yes";
    else cout << "No";
    
}


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

int main() {
	int N, K, d;
	bool D[10];
  	for (int i = 0; i < 10; i++) {
		D[i] = true;
    }
	cin >> N >> K;
	for (int i = 0; i < K; i++) {
		cin >> d;
		D[d] = false;
	}
	for (int i = N; i <= 99999; i++) {
		bool check = true;
		int j = i;
		while (j != 0) {
			if (!D[j % 10]) {
				check = false;
			}
			j -= j % 10;
			j /= 10;
		}
		if (check) {
			cout << i;
			break;
		}
	}
}

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

    //printf("%d:%d:%d",a/3600,(a%3600)/60,(a%3600)%60);
}



Measured memory_bytes: 2592
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;cin >> n;vector<int>  x(n),num;
    for(int i=0; i<n; i++) cin >> x[i];
    num=x;
    sort(x.begin(),x.end());
    for(int i=0; i<n; i++){
        if(num[i]<=x[n/2-1])cout << x[n/2] << endl;
        else cout << x[n/2-1] << endl;
    }
}

Measured memory_bytes: 3712
#include<bits/stdc++.h>
#include <fstream>
using namespace std;
typedef long long ll;
int F[200003];
int Find(int a)
{
    if(F[a]<0)return a;
    return F[a]=Find(F[a]);
}
int main()
{
  /*  string s,s1;
    cin>>s>>s1;
    int Max=0;
    int len=s.size();
    int len1=s1.size();
    for(int i=0;i<len;i++)
        for(int j=len-i-1;j>=1;j--)
    {  int z=s1.find(s.substr(i,j));
        if(len1>=j&&z!=string::npos)
        {
            if(i>=z&&len-(i+j-1)>=len1-(z+j-1))
            Max=max(Max,j);
        }
    }
    cout<<len1-Max;*/
    int n,m;
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++)
        F[i]=-1;
    while(m--)
    {
        int a,b;
        scanf("%d %d",&a,&b);
        int x,y;
        x=Find(a);
        y=Find(b);
        if(x==y)continue;
        F[x]+=F[y];
        F[y]=x;
    }
    int Max=0;
    for(int i=1;i<=n;i++)
        Max=max(Max,-F[i]);;
    cout<<Max;

}


Measured memory_bytes: 4528
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<int,int>;
/* ちゃんと考えてわかって実装 */

int main(void){
    string s;
    cin >> s;
    for(int i=0; i<s.length(); i++){
        s[i] = 'x';
    }
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
ans=set()
ans.add(0)
l=[1 for i in range(n)]
for i in range(m):
    x,y=[int(j)-1 for j in input().split()]
    l[x]-=1
    l[y]+=1
    if x in ans:
        ans.add(y)
        if l[x]==0:
            ans.remove(x)
print(len(ans))

Measured memory_bytes: 12808
#include <bits/stdc++.h>
#include <numeric>
typedef long long ll;
#define vstroku() to_string()
#define vchislo() to_ulong()
#define numberof1(x) __builtin_popcount(x)
#define povsemelementam(i,mnozh) for(auto i: mnozh)
#define podotrezok(i,j) substr(i-1,j) // like prefix sum, (i,j)=s[j]-s[i-1]
#define pb push_back
#define pf push_front
#define popf pop_front
#define popb pop_back 
#define pii pair <int, int>
#define F first
#define S second
#define mipletsplay ios_base::sync_with_stdio(0); cin.tie(0); 


using namespace std;
const ll INFLL = 1e18;
const int MAXN = 3e5;
const ll INF = 1e9;
const ll kek = 998244353;

int main() {
	mipletsplay;
ll a,b,c,d;
cin>>a>>b>>c>>d;
ll f=c*d;
ll k= __gcd(c, d);
f/=k;
ll ans=(b/c)-((a+c-1)/c) +(b/d)-((a+d-1)/d)-(b/f - ((a+f-1)/f));
//cout<<(b/c)-((a+c-1)/c)<<endl;
cout<<b-a-ans;}

Measured memory_bytes: 256
def f(n):
    table = [False, False] + [True for _ in range(2, n+1)]
    p = 2
    while p**2 <= n:
        if table[p]:
            j = p + p
            while j <= n:
                table[j] = False
                j += p
        p += 1
    return sum(table)


while True:
    try:
        n = int(input())
    except:
        break
    print(f(n))



Measured memory_bytes: 25576
#include<stdio.h>
int main(void)
{
	int a,b,flg=0,i;
	scanf("%d%d",&a,&b);
	for(i=1;i<=3;i++){
		if(a*b*i%2==1) flg=1;
	}
	if(flg==1) printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
inline int rd() {int r;scanf("%d",&r);return r;}
int main() {
	int a = rd(), b = rd();
	if (1LL * a * b <= 0) {
		puts("Zero");
		return 0;
	}
	if (a>0) {
		puts("Positive");
		return 0;
	}
	a = abs(a);
	if (b < 0) a -= abs(b+1);
	puts(a&1 ? "Negative" : "Positive");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <cmath>

using namespace std;

int main(void)
{
	map <int, int> m;
	m[1] = 1;
	m[3] = 1;
	m[5] = 1;
	m[7] = 1;
	m[8] = 1;
	m[10] = 1;
	m[12] = 1;
	m[4] = 2;
	m[6] = 2;
	m[9] = 2;
	m[11] = 2;
	m[12] = 3;
	int x, y;

	cin >> x >> y;
	if (m[x] == m[y])
	{
		cout << " Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
# D - Factorization

import math, collections

N, M = map(int, input().split())
MOD = 10**9 + 7

# n以下の全ての素数のセットを返す関数
def prime_set(n):
    primes = set(range(2, n+1))
    for i in range(2, int(n**0.5) + 1):
        primes.difference_update(range(i*2, n+1, i))
    return primes

# nを素因数分解して素因数の全リストを返す関数
def prime_factors_duplicating_list(n):
    f = []
    for i in prime_set(int(n**0.5) + 1):
        while n % i == 0:
            f.append(i)
            n //= i
    if n > 1:
        f.append(n)
    return f

def comb(n, r):
    if n < r:
        return 0
    else:
        tmp, tmp2 = 1, n
        for _ in range(r):
            tmp *= tmp2
            tmp2 -= 1
        return tmp // math.factorial(r)
    
M_pf_dict = collections.Counter(prime_factors_duplicating_list(M))

ans = 1
for value in M_pf_dict.values():
    ans *= comb(N-1+value, value)
    ans %= MOD

print(ans)

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

int main()
{
    int n;
    cin >> n;
    int ans = 0;
    for (int i = 1; i <= n; i += 2) {
        int d = 0;
        for (int j = 1; j <= n; j++) {
            if (i % j == 0) {
                d++;
            }
        }
        if (d == 8) {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
string process(int x, int y){
  //1000000にx,yを足してあげて、文字列に変換して部分文字列をとる。
  x = 1000000 + x;
  y = 1000000 + y;
  string xx = to_string(x);
  string yy = to_string(y);
  return xx.substr(1,6) + yy.substr(1,6);
}
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> p(m), y(m);
  vector<pair<int, int>> pr(m);
  //pairは誕生年と配列の番号をくっつける
  for(int i=0; i<m; i++){
    cin >> p[i] >> y[i];
    pr[i] = make_pair(y[i], i);
  }
  //numは県のナンバー
  vector<int> num(n+1);
  string ans[100010];
  sort(pr.begin(), pr.end());
  for(int i=0; i<m; i++){
    int t1 = pr[i].first;
    int t2 = pr[i].second;
    num[p[t2]]++;
    ans[t2] = process(p[t2], num[p[t2]]);
  }
  for(int i=0; i<m; i++) {
    cout << ans[i] << endl;
  }
}


Measured memory_bytes: 8960
#include<stdio.h>
#include<stdlib.h>
#define MAX 10000
#define NIL -1



struct Node{
  int p, l, r;
};

struct Node T[MAX];
int n;

void preO(int );
void inO(int );
void postO(int );

void preO(int u){
  if( u == NIL ) return;
  printf(" %d", u);
  preO(T[u].l);
  preO(T[u].r);
}

void inO(int u){
  if( u == NIL) return;
  inO(T[u].l);
  printf(" %d", u);
  inO(T[u].r);
}

void postO(int u){
  if( u == NIL ) return;
  postO(T[u].l);
  postO(T[u].r);
  printf(" %d", u);
}

int main(){
  int i, d, a, l, r;
  scanf("%d", &n);
  for(i = 0 ; i < n ; i++) T[i].p = NIL;

  for( i = 0 ; i < n ; i++){
    scanf("%d", &a);
    scanf("%d", &l);
    scanf("%d", &r);
    T[a].l = l;
    T[a].r = r;

    if(l != NIL ) T[l].p = a;
    if(r != NIL ) T[r].p = a;
  }
for( i = 0 ; i < n ; i++){
    if( T[i].p == NIL ) d = i;
  }

  printf("Preorder\n");
  preO(d);
  printf("\n");
  printf("Inorder\n");
  inO(d);
  printf("\n");
  printf("Postorder\n");
  postO(d);
  printf("\n");

  return 0;
}



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

int main() {
	int n, m, x;
	cin >> n >> m >> x;
	
	vector<vector<int>> as(n, vector<int>(m+1));
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < m + 1; ++j) {
			cin >> as[i][j];
		}
	}

	int answer = 2147483647;

	for (int bit = 0; bit < (1 << n); ++bit) {
		vector<int> rikai(m);
		int gokei = 0;
		for (int i = 0; i < n; ++i) {
			if (bit & (1 << i)) {
				gokei += as[i][0];
				for (int j = 1; j < m + 1; ++j) {
					rikai[j - 1] += as[i][j];
				}
			}
		}

		auto count = count_if(rikai.begin(), rikai.end(), [&](int r) {return r >= x; });
		if (count == m) {
			answer = min(gokei, answer);
		}
	}

	if (answer == 2147483647) {
		cout << -1 << endl;
	}
	else {
		cout << answer << endl;
	}
}

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

using namespace std;

int main() {

   string str;
   while(1){
   int sum=0;

   cin>>str;
   if(str.size()==1 && str[0]=='0')return 0;
   for(int i=0;i<str.size();i++){
    sum=sum+str[i]-'0';
   }
   cout<<sum<<endl;
   }


}



Measured memory_bytes: 3224
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def main():
    N, K = map(int, input().split())
    if K % 2 == 0:
        even = N // K
        odd = N // (K // 2) - even
        print(odd ** 3 + even ** 3)
    else:
        print((N // K) ** 3)


if __name__ == "__main__":
    main()


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

using namespace std;
typedef long long ll;
typedef long double ld;
const double pi = 3.141592654;
void solve()
{
   string s;
   char c;
   cin>>c;
   s[0]=c+1;
   cout<<s[0]<<endl;


}
int main()
{
#ifndef oj
    //freopen("input", "r", stdin);
    //freopen("output.txt","w",stdout);
#endif
    // system("cls");
    //getchar();
    // cout<<adj[1][0];

    int t;
   // cin>>t;
     t=1;
    while(t--)
    {
        solve();

    }


}




Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

ss=[SI() for _ in range(3)]
ii=[0,0,0]
t=0
while 1:
    if ii[t]==len(ss[t]):
        print("ABC"[t])
        break
    nt="abc".index(ss[t][ii[t]])
    ii[t]+=1
    t=nt


Measured memory_bytes: 9016
#include <bits/stdc++.h>
using namespace std;
#define INF 1<<30
#define endl '\n'
#define maxn 100005
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
typedef long long ll;
typedef long double ld;
const double PI = acos(-1.0);
#define dbg(x) cerr << #x << " = " << x << endl;
#define dbg2(x, y) cerr << #x << " = " << x << ", " << #y << " = " << y << endl;
#define dbg3(x, y, z) cerr << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl;

const ll mod = 1e9 + 7;
ld X[maxn], Y[maxn];
char dir[maxn];
int n;

ld solve(ld t)
{
    ld x_mn = INT_MAX, x_mx  = INT_MIN, y_mn = INT_MAX, y_mx = INT_MIN;
    for(int i = 0; i < n; i++){
        ld cx = X[i], cy = Y[i];
        if(dir[i] == 'U') cy +=  t;
        else if(dir[i] == 'D') cy -= t;
        else if(dir[i] == 'R') cx += t;
        else if(dir[i] == 'L') cx -= t;

        x_mn = min(x_mn, cx);
        x_mx = max(x_mx, cx);

        y_mn = min(y_mn, cy);
        y_mx = max(y_mx, cy); 
    }
    return (y_mx - y_mn) * (x_mx - x_mn);
}

int main()
{
    FASTIO
    /*
    //double start_time = clock();
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
#endif
//*/
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> X[i] >> Y[i] >> dir[i];
    }

    ld l = 0.0, r = 1e9;
    for(int i = 0; i < 300; i++){
        ld m1 = l + (r -l)/3.0;
        ld m2 = r - (r - l)/3.0;

        if(solve(m1) < solve(m2)) r  = m2;
        else l = m1;
    }
    cout << fixed << setprecision(9) << solve(l)<<endl;
    //double end_time = clock();
    //printf( "Time = %lf ms\n", ( (end_time - start_time) / CLOCKS_PER_SEC)*1000);

    return 0;
}


Measured memory_bytes: 3456
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<algorithm> // sort
#include<map> // pair
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<set>
#include<queue>
// #include<stack>
using namespace std;
typedef long long ll;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll tmp1,tmp2;
const ll mod = 1e9+7;
const int INF = 1e9;
const ll INFLONG = 1e18;
//vector<vector<ll>> vec(1000,vector<ll>(1000));
vector<pair<long double,long double>> vec1(100);
int main(){
  ll n;
  cin >> n;
  vector<pair<long double,long double>> radi(n);
  long double ans = 0.0;
  rep(i,n){
    cin >> tmp1 >> tmp2;
    vec1[i] = make_pair(tmp1,tmp2);
    radi[i] = make_pair(atan2(tmp1,tmp2),i);
  }
  sort(all(radi));
  long double tmpx,tmpy;
  rep(i,n){//size
    rep(j,n){//start
      tmpx = 0.0;tmpy=0.0;
      REP(k,j,j+i+1){
        tmpx += vec1[radi[k%n].second].first;
        tmpy += vec1[radi[k%n].second].second;
      }
      //cout << tmpx << " " << tmpy << endl;
      long double tmp = sqrt((long double)(tmpx*tmpx+tmpy*tmpy));
      // if(tmp > 18){
      //   cout << tmp << " " << i << " " << j << " " << endl;
      // }
      chmax(ans,tmp);
    }
  }
  printf("%.20Lf",ans);
}


Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <deque>
using namespace std;

struct s { int x, step; };

int main() {
        int k;
        scanf("%d", &k);
        deque
 dq;
        dq.push_back((s){1, 1});
        vector<bool> used(k);
        for (;;) {
                s now = dq.front();
                used[now.x] = true;
                dq.pop_front();
                if (now.x == 0) return !printf("%d\n", now.step);
                if (!used[(now.x + 1) % k]) dq.push_back({(now.x + 1) % k, now.step + 1});
                if (!used[(now.x * 10) % k]) dq.push_front({(now.x * 10) % k, now.step});
        }
}


Measured memory_bytes: 768