akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

using namespace std;

typedef long long int lli;
typedef pair<int, int> ii;

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;}

#ifdef LOCAL
    #define eprintf(...) printf(__VA_ARGS__)
#else
    #define eprintf(...) 1
#endif

#define ROUNDUP(a, b)         ( ((a) + ((b) - 1) ) / (b))
#define SET_ZERO(a)             ( memset((a), 0, sizeof(a)))
#define SET_NUM_ARRAY(a,b)    ( memset((a), b, sizeof(a)))
//#define int long long int //dont forget to change int to signed

int main() {
    int H, W;
    cin >> H >> W;
    char a[109][109];
    for (int i = 1; i <= H; i++) {
        char s[109];
        cin >> s;
        for (int j = 1; j <= W; j++) {
            a[i][j] = s[j-1];
        }
    }
    int r[109] = {}, c[109] = {};

    for (int i = 1; i <= H; i++) {
        char icolor = a[i][1];
        if (icolor == '#') continue;
        int flag = 1;
        for (int j = 2; j <= W; j++) {
            if (a[i][j] != icolor) {
                flag = -1;
                break;
            }
        }
        if (flag==1) r[i] = 1;
    }

    for (int i = 1; i <= W; i++) {
        char icolor = a[1][i];
        if (icolor == '#') continue;
        int flag = 1;
        for (int j = 2; j <= H; j++) {
            if (a[j][i] != icolor) {
                flag = -1;
                break;
            }
        }
        if (flag==1) c[i] = 1;
    }

    for (int i = 1; i <= H; i++) {
        if (r[i] == 0) {
            for (int j = 1; j <= W; j++) {
                if (c[j] == 0)cout << a[i][j];
            }
            cout << "\n";
        }
    }
    cout << endl;
}


Measured memory_bytes: 256
def main():
    H, W = map(int, input().split())
    a = [list(input()) for _ in range(H)]

    row = [False] * H
    col = [False] * W
    for i in range(H):
        for j in range(W):
            if a[i][j] == "#":
                row[i] = True
                col[j] = True

    for i in range(H):
        if row[i]:
            for j in range(W):
                if col[j]:
                    print(a[i][j], end="")
            print()


if __name__ == "__main__":
    main()


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

int main(void){
  char s1[10], s2[10], s3[10];
  char ans[4] = {'\0'};
  cin >> s1 >> s2 >> s3;
  ans[0] = s1[0] - 32;
  ans[1] = s2[0] - 32;
  ans[2] = s3[0] - 32;
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 3488
#include <iostream>
#include <vector>
#include <stack>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    int n, m;
    cin >> n >> m;
    vector< vector<int> > G(n);
    for (int i = 0; i < m; ++i)
    {
        int a, b, c;
        cin >> a >> b >> c;
        --a;
        --b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    int odp = 0;
    vector<bool> odw(n, false);
    stack<int> S;
    for (int i = 0; i < n; ++i)
    {
        if (!odw[i])
        {
            ++odp;
            odw[i] = true;
            S.push(i);
            while (!S.empty())
            {
                int akt = S.top();
                S.pop();
                for (int j = 0; j < G[akt].size(); ++j)
                {
                    if (!odw[G[akt][j]])
                    {
                        odw[G[akt][j]] = true;
                        S.push(G[akt][j]);
                    }
                }
            }
        }
    }
    cout << odp;
    return 0;
}


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

int main() {
  long long num,b,r;
  long long tmpRoop = 0;
  long long tmpAmari = 0;
  long long kekka = 0;
  
  cin >> num >> b >> r;
  
  tmpRoop = num / (b + r);
  tmpAmari = num % (b + r);
  
  if(tmpAmari == 0){
    kekka = tmpRoop * b;
  }else if(tmpAmari > 0){
    if(b - tmpAmari >= 0){
      kekka = tmpRoop * b + tmpAmari;
    }else{
      kekka = tmpRoop * b + b;
    }    
  }
  
  cout << kekka;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
//#include <stdio.h>
//#include <stack>
//#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
//#include <fstream>
//#include <list>
//#include <iomanip>
#include <cctype>

using namespace std;

#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define ssort(z) sort(z.begin(),z.end())
#define eerase(z) z.erase(unique(z.begin(),z.end()),z.end())


void printVec(std::vector<int> & vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec1(std::vector<string>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
	vector.erase(vector.begin() + index);
}

int vector_finder(std::vector<string> vec, string number) {
	auto itr = std::find(vec.begin(), vec.end(), number);
	size_t index = std::distance(vec.begin(), itr);
	if (index != vec.size()) { // 発見できたとき
		return 1;
	}
	else { // 発見できなかったとき
		return 0;
	}
}

#include <sstream> 
std::vector<std::string> StringSplit(const std::string& str, char sep)
{
	std::vector<std::string> v;
	std::stringstream ss(str);
	std::string buffer;
	while (std::getline(ss, buffer, sep)) {
		v.push_back(buffer);
	}
	return v;
}

Int gcd(Int a, Int b) {
	return b != 0 ? gcd(b, a % b) : a;
}
Int lcm(Int a, Int b) {
	return a * b / gcd(a, b);
}

bool comp(const string a, const string b) {
	return a.length() < b.length();
}

bool integer(double num) {
	return floor(num) == num;
}

string gen(int num) {
	string str = "";
	for (int i = 0; i < num; i++) str += ".";
	return str;
}
Int fact(int num) {
	if (num == 0) return 1;
	else return num * fact(num - 1);
}

int main() {
	int n; cin >> n;
	//vector<int>l(n);
	int cnt = 0;
	string a;
	for (int i = 1; i <= n; i++) {
		a = to_string(i);
		if (a.size() % 2 == 1) cnt++;
	}
	cout << cnt;

	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main () {
  int r, g, b;
  cin >> r >> g >> b;
  int rgb = 100*r + 10* g + b;
  
  if(rgb %4 == 0){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int X,Y,Z,K;
  cin >> X >> Y >> Z >> K;
  long long int A[X];
  long long int B[Y];
  long long int C[Z];
  for (int i=0;i<X;i++) cin >> A[i];
  for (int i=0;i<Y;i++) cin >> B[i];
  for (int i=0;i<Z;i++) cin >> C[i];
  vector<long long int> V;
  vector<long long int> V2;
  int count=0;
  for (int i=0;i<X;i++){
    for (int j=0;j<Y;j++){
      V.push_back(A[i]+B[j]);
    }
  }
  sort(V.begin(),V.end(),greater<long long int>());

  for(int i=0;i<min(K,X*Y);i++){
    for(int j=0;j<Z;j++){
      V2.push_back(*(V.begin()+i)+C[j]);
    }
  }
  sort(V2.begin(),V2.end(),greater<long long int>());
  for(int i=0;i<K;i++){
    cout << *(V2.begin()+i) << endl;
  }
}


Measured memory_bytes: 43364
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int,int>;

ll solve() {
    ll H, W, Ch, Cw, Dh, Dw;
    cin >> H >> W >> Ch >> Cw >> Dh >> Dw;
    Ch--, Cw--, Dh--, Dw--;
    vector<string> S(H);
    for ( int i = 0; i < H; i++ ) cin >> S[i];
    vector<int> dh = {0, 1, 0, -1}, dw = {1, 0, -1, 0};
    ll INF = 1LL<<60;
    vector<vector<ll>> d(H, vector<ll>(W,INF));

    queue<pii> q;
    q.push(pii(Ch,Cw));
    d[Ch][Cw] = 0;
    queue<pii> q2, qt;
    qt.push(pii(Ch,Cw));
    while ( !qt.empty() ) {
        while ( !qt.empty() ) {
            q.push(qt.front());
            q2.push(qt.front());
            qt.pop();
        }
        while ( !q.empty() ) {
            pii v = q.front();
            q.pop();
            int h0 = v.first, w0 = v.second;
            for ( int ii = 0; ii < 4; ii++ ) {
                int h = h0 + dh[ii];
                int w = w0 + dw[ii];
                if ( h < 0 || h >= H || w < 0 || w >= W ) continue;
                if ( S[h][w] == '#' ) continue;
                if ( d[h][w] > d[h0][w0] ) {
                    d[h][w] = d[h0][w0];
                    q.push(pii(h,w));
                    q2.push(pii(h,w));
                }
            }
        }
        while ( !q2.empty() ) {
            pii v = q2.front();
            q2.pop();
            int h0 = v.first, w0 = v.second;
            for ( int i1 = -2; i1 <= 2; i1++ ) {
                for ( int j1 = -2; j1 <= 2; j1++ ) {
                    int h = h0 + i1;
                    int w = w0 + j1;
                    if ( h < 0 || h >= H || w < 0 || w >= W ) continue;
                    if ( S[h][w] == '#' ) continue;
                    if ( d[h][w] > d[h0][w0] + 1 ) {
                        d[h][w] = d[h0][w0] + 1;
                        qt.push(pii(h,w));
                    }
                }
            }
        }
    }
    ll ans = d[Dh][Dw];
    if ( ans >= INF ) ans = -1;
    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

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

using namespace std;

int main() 
{
    int n, x, y;
    scanf("%d", &n);
    
    vector<int> v;
    
    for(int i = 0; i < n; i++)
    {
        scanf("%d", &x);
        
        if(x == 2)
            v.pop_back();
        else
        {
            scanf("%d", &y);
            
            if(x == 0)
                v.push_back(y);
            else if(x == 1)
                if(v.size() > 0)
                    printf("%d\n", v[y]);
        }
    }
    
    return 0;
}


Measured memory_bytes: 3940
N = int(input())
P = list(map(int,input().split()))

count = 0
for i in range(N):
  if(i == 0):
    min_tmp = P[i]
    count += 1
  else:
    if(P[i]<=min_tmp):
      count += 1
      min_tmp = P[i]

print(count)

Measured memory_bytes: 24744
#include <stdio.h>
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))

int a[1500][1500];
int dp[1500][1500];
int main(){
	int h,w;
	scanf("%d%d",&h,&w);
	for(int i=0;i<h;i++)for(int j=0;j<w;j++)scanf("%d",&a[i+1][j+1]);
	int ans=0;
	for(int i=1;i<=h;i++)for(int j=1;j<=w;j++)if(!a[i][j]){
		dp[i][j]=min(dp[i-1][j-1],min(dp[i-1][j],dp[i][j-1]))+1;
		ans=max(ans,dp[i][j]);
	}
	printf("%d\n",ans*ans);
}


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

int main() {
  int N;
  cin >> N;
  vector<int> H(N);
  for (int i = 0; i < N; i++) cin >> H.at(i);
  vector<int> DP(N, 2e9);
  DP.at(0) = 0;
  for (int i = 0; i < N; i++) {
    if (i + 1 < N) DP.at(i + 1) = min(DP.at(i + 1), DP.at(i) + abs(H.at(i) - H.at(i + 1)));
    if (i + 2 < N) DP.at(i + 2) = min(DP.at(i + 2), DP.at(i) + abs(H.at(i) - H.at(i + 2)));
  }
  cout << DP.at(N - 1) << "\n";
}

Measured memory_bytes: 1024
s = gets.chomp
t = gets.chomp

s_arr = []
t_arr = []

s.each_char do |x|
  s_arr << x
end
t.each_char do |y|
  t_arr << y
end

s_new = s_arr.sort.join
t_new = t_arr.sort {|a, b| b <=> a}.join

if (s_new <=> t_new) == -1
  puts 'Yes'
else
  puts 'No'
end


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

int main() {
 int A,B;
 string S;
 cin >> A >> B >> S;
  bool flag = false;
  int c = 0; 
 if(S.at(A) == '-'){
   for(int i = 0;i<A+B+1;i++){
     if(i==A) continue;
     if(S.at(i) >= '0' && S.at(i) <= '9') c++;
   }
   if(c == A+B) flag = true;
 }
  if(flag) cout << "Yes" << endl;
  else cout << "No" << endl;


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()
#ifdef _DEBUG_
  #define debug(...) printf(__VA_ARGS__)
#else
  #define debug(...) (void)0
#endif
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;

bool check(string S) {
  if (SZ(S) % 2 != 0)
    return false;
  for (int i = 0; i < SZ(S); i += 2)
    if (S[i] != 'h')
      return false;
  for (int i = 1; i < SZ(S); i += 2)
    if (S[i] != 'i')
      return false;
  return true;
}

int main() {
  string S;
  cin >> S;
  if (check(S))
    puts("Yes");
  else
    puts("No");
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  int l,a,b,c,i,j,k,r,sum=0;
  scanf("%d",&l);
  for(i=1;i<=l;i++){
    for(j=1;j<=l;j++){
      for(k=1;k<=l;k++){
        a=k;
        b=j;
        c=i;
        r=a%b;
        while(r!=0){
          a=b;
          b=r;
          r=a%b;
        }
        
        r=c%b;
        while(r!=0){
          c=b;
          b=r;
          r=c%b;
        }
        sum+=b;
      }
    }
  }
  printf("%d",sum);
  return 0;
}

Measured memory_bytes: 1732
unittest
{
	assert( [ "3", "1", "4", "3" ].parse.expand.solve == "4\n3\n4" );
	assert( [ "2", "5", "5" ].parse.expand.solve == "5\n5" );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.to!( long );
	auto as = new long[ n ];
	foreach( ref a; as )
	{
		input.popFront;
		a = input.front.to!( long );
	}
	return tuple( as );
}

auto solve( long[] as )
{
	auto ls = new long[ as.length ];
	auto lm = 0L;
	for( auto i = 0L; i < as.length; i++ )
	{
		lm = max( lm, as[ i ] );
		ls[ i ] = lm;
	}
	
	auto rs = new long[ as.length ];
	auto rm = 0L;
	for( auto i = as.length.signed - 1; 0 <= i; i-- )
	{
		rm = max( rm, as[ i ] );
		rs[ i ] = rm;
	}
	
	auto anss = new long[ as.length ];
	foreach( i, ref ans; anss )
	{
		if(      i == 0               ) ans = rs[ 1 ];
		else if( i == anss.length - 1 ) ans = ls[ $ - 2 ];
		else                            ans = max( ls[ i - 1 ], rs[ i + 1 ] );
	}
	return anss.to!( string[] ).join( "\n" );
}


Measured memory_bytes: 18428
#include<stdio.h>
int main(void)
{
	int N, M, C;
	int A[20][20], B[20];
	scanf("%d", &N); scanf("%d", &M); scanf("%d", &C);

	for (int j = 0; j < M; j++) {
		scanf("%d", &B[j]);
	}
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++) {
			scanf("%d", &A[i][j]);
		}
	}

	int sum = 0;
	int count = 0;


	for (int i = 0; i < N; i++) {
		sum = 0;
		for (int j = 0; j < M; j++) {
			sum = sum + A[i][j] * B[j];
			//printf("sum=%d ", sum);

		}
		if (sum + C > 0)
			count++;
	}

	printf("%d", count);

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>

typedef unsigned long long ULL;
typedef long long LL;

using namespace std;

typedef struct{
    char id[13];
    int num;
    int year;
    int prefecture;

}CITY;
bool sort_yaer( CITY a, CITY b){
    if( a.year < b.year){
        return true;
    }else{
        return false;
    }
}
bool sort_prefectre( CITY a, CITY b){
    if( a.prefecture < b.prefecture){
        return true;
    }else{
        return false;
    }
}
bool sort_num(CITY a, CITY b){
    if( a.num < b.num){
        return true;
    }else{
        return false;
    }
}
int main(){
    int i;
    int N,M;
    int p,y;

    int id_pre, id_num;
    CITY *city;

    cin >> N >> M;

    city = new CITY[M];

    for(i=0;i<M;i++){
        cin >> p >> y;
        city[i].num = i;
        city[i].prefecture = p;
        city[i].year = y;
    }
    stable_sort(city,city+M,sort_yaer);
    stable_sort(city,city+M,sort_prefectre);
    /*
    for(i=0;i<M;i++){
        cout << city[i].prefecture << " " << city[i].year << endl;
    }
    */
    id_pre = -1;
    id_num = -1;
    for(i=0;i<M;i++){
        if( id_pre !=  city[i].prefecture ){
            id_pre = city[i].prefecture;
            id_num = 1;
        }else{
            id_num++;
        }
        sprintf(city[i].id,"%06d%06d",id_pre,id_num);
    }
    sort(city,city+M,sort_num);
    for(i=0;i<M;i++){
        cout << city[i].id << endl;
    }
    
    return 0;
}


Measured memory_bytes: 6952
#include<iostream>
#include<algorithm>
#include<functional>

int main(){

	int num[5];

	for (int i = 0; i < 5; i++)std::cin >> num[i];

	std::sort(num, num + 5, std::greater<int>());

	for (int i = 0; i < 5; i++){
		if (i == 0)std::cout << num[i];
		else std::cout << " " << num[i];
	}
	std::cout << std::endl;

	return 0;
}

Measured memory_bytes: 1176
package main

import (
	"bufio"
	"os"
	"sort"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	iv, _ := strconv.Atoi(scanString())
	return iv
}

func scanString() string {
	sc.Scan()
	return sc.Text()
}

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 100001), 100001*100)
}

func main() {
	n := scanInt()
	xm := make(map[string]int, n)
	for i := 0; i < n; i++ {
		s := scanString()
		xm[s]++
	}

	type poll struct {
		s string
		c int
	}
	ps := make([]poll, 0, len(xm))
	for s, c := range xm {
		ps = append(ps, poll{s, c})
	}
	sort.Slice(ps, func(i, j int) bool { return ps[i].c > ps[j].c })

	ans := make([]string, 0, len(xm))
	pmx := ps[0]
	ans = append(ans, pmx.s)
	for _, p := range ps[1:] {
		if p.c != pmx.c {
			break
		}
		ans = append(ans, p.s)
	}
	sort.Strings(ans)

	var wr = bufio.NewWriter(os.Stdout)
	for _, s := range ans {
		wr.WriteString(s + "\n")
	}
	wr.Flush()
}


Measured memory_bytes: 20868
#include "bits/stdc++.h"
using namespace std;
#define Rep(i, n) for (int i = 0; i < (int)(n); i++)
#define BitRep(i, n) for (int i = 0; i < (int)(1 << n); i++)
#define All(vec) vec.begin(), vec.end()
#define Sum(vec) accumulate(vec.begin(), vec.end(), 0)
#define Sort(vec) sort(vec.begin(), vec.end())
#define Reverse(vec) reverse(vec.begin(), vec.end())
#define Next_permutation(vec) next_permutation(vec.begin(), vec.end())
#define PI acos(-1)
typedef long long ll;

int main() {
    string S, T;
    cin >> S >> T;
    int ans = 0;
    Rep(i, S.size()) {
        if (S[i] != T[i]) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3912
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define f first
#define s second
using namespace std;
int h, w, m, mx, my;
unordered_map<string, int> mp;
vector<pair<int,int>> vecx, vecy;
int x[300001], y[300001];
int main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> h >> w >> m;
    for(int i = 1; i <= m; i++){
        int a, b; cin >> a >> b; string str = ""; str += to_string(a); str+= " "; str += to_string(b);
        mp[str] = 1; x[a]++; y[b]++; mx = max(mx, x[a]); my = max(my, y[b]);
    }
    for(int i = 1; i <= h; i++)if(x[i] == mx)vecx.pb({x[i], i});
    for(int i = 1; i <= w; i++)if(y[i] == my)vecy.pb({y[i], i});
    //sort(vecx.begin(), vecx.end()); sort(vecy.begin(), vecy.end());
    for(int i = 0; i < vecx.size(); i++){
        for(int j = 0; j < vecy.size(); j++){
            string temp =""; temp += to_string(vecx[i].s); temp += " "; temp += to_string(vecy[j].s);
            if(mp.find(temp) == mp.end()){
                cout << mx+my << endl; return 0;
            }
            else continue;
        }
    }
    cout << mx+my-1 << endl;
    return 0;
}


Measured memory_bytes: 36940
#include <stdio.h>
typedef long long ll;
int main() {
	int n, a[100000], b[100000];
	ll botCnt = 0;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d%d", &a[i], &b[i]);
	}
	for (int i = n - 1; i >= 0; i--) {
		if ((a[i] + botCnt) % b[i] == 0)
			botCnt += 0;
		else
			botCnt += b[i] - ((a[i] + botCnt) % b[i]);
	}
	printf("%lld\n", botCnt);
	return 0;
}

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

int main() {
  int n,a=0,b=0,ans;
  cin >> n;
  vector<int> w(n);
  for(int i=0;i<n;i++) cin >> w.at(i);
  for(int i=0;i<n;i++) {
    a+=w.at(i);
  };
  for(int i=0;i<n;i++) {
    b+=w.at(i);
    if(a<=b*2) {
      ans=min(b*2-a,a-(b-w.at(i))*2);
      cout << ans << endl;
      break;
    };
  };
}

Measured memory_bytes: 256
import math
while True:
    n = int(input())
    if n == 0:
        break
    s = list(map(int, input().split()))
    m = sum(s) / len(s)
    sig = 0
    for i in range(len(s)):
        sig += (s[i]-m)**2
    a = math.sqrt(sig/n)
    print('{:.8f}'.format(a))


Measured memory_bytes: 5700
require 'prime'
n = gets.to_i
kaijo = (1..n).to_a.inject(:*)
mod = (10 ** 9) + 7
if n == 1
  puts 1 % mod
  exit
end
factors = Prime.prime_division(kaijo)
array = []
factors.each do |f|
  array << (f[1] + 1)
end

puts array.inject(:*) % mod

Measured memory_bytes: 4604
n = int(input())
a = "abcdefghijklmnopqrstuvwxyz"
s = []
while n > 0:
    s.append(a[n%26 - 1])
    if (n % 26 == 0):
        n = n // 26 -1
    else:
        n //= 26
print(''.join(s[::-1]))


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

int main()
{
    int N;
    cin >> N;
    int a;
    int min = 1000, max = 0;

    for (int i = 0; i < N; i++) {
        cin >> a;
        min = (a < min) ? a : min;
        max = (a > max) ? a : max;
    }

    cout << (max - min) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <numeric>
#include <algorithm>
using namespace std;
int N;
string ans = "No";
int main() {
	cin >> N;
	for (int i = 1;i < 10;i++) {
		for (int j = 1;j < 10;j++) {
			if (N == i * j) {
				 ans = "Yes";
				break;
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
import sys
from collections import *
import heapq
import math
import bisect
from itertools import permutations,accumulate,combinations,product
from fractions import gcd
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7

n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))

a.sort()
alst=[0]*n
b.sort()
blst=[0]*n
c.sort()

# print(a)
# print(b)
# print(c)

for i in range(n):
    alst[i]=n-bisect.bisect_right(b,a[i])
    blst[i]=n-bisect.bisect_right(c,b[i])
# print(alst)
# print(blst)
blst.reverse()
acc=ruiseki(blst)
# print(acc)
ans=0
for i in range(n):
    ans+=acc[alst[i]]
print(ans)

Measured memory_bytes: 126772
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <stdio.h>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <tuple>
#include <math.h>
#include <set>
#include <map>
using namespace std ;
using ll = long long ;
using ld = long double ;
using vll = vector<ll> ;
using vvll = vector<vll> ;
using vc = vector<char> ;
using vvc = vector<vc> ;
using vb = vector<bool> ;
using vvb = vector<vb> ;
using pll = pair<ll,ll> ;
#define all(v) v.begin(),v.end() 
const ll INF = 1e18 ;
const ll mod = 1e9+7 ;
const double pie = acos(-1); 
vll dx4 = {-1,0,1,0} ;
vll dy4 = {0,-1,0,1} ;
vll dx8 = {-1,0,1,1,1,0,-1,-1} ;
vll dy8 = {-1,-1,-1,0,1,1,1,0} ; 

void fix_cout(){cout << fixed << setprecision(20) ; }
ll gcd(ll a,ll b){if(b==0) return a ; return gcd(b,a%b) ; }
ll lcm(ll a,ll b){return a/gcd(a,b)*b ; }
void chmax(ll &a,ll b){if(a<b) a = b ; }
void chmin(ll &a,ll b){if(a>b) a = b ; }

int main(){
	string s,t ;
	cin >> s >> t ;
	ll ans = 0 ;
	for(int i=0;i<s.size();i++){
		if(s.at(i)!=t.at(i)) ans++ ;
	}
	cout << ans << endl ;
}

Measured memory_bytes: 3924
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i, n) for(int i=0;i<(int)n;i++)
#define PI acos(-1)
#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);
ll mod=1e9+7;

int main(){
    fast_io

    int n;
    cin>>n;

    map<int, int> mpe, mpo;
    rep(i,n){
        int x; cin>>x;
        if(i%2==0){
            mpe[x]++;
        }else{
            mpo[x]++;
        }
    }

    int maxe=0;
    int key=0;
    for(auto m:mpe){
        if(m.second > maxe){
            maxe = m.second;
            key = m.first;
        }
    }
    int maxo = 0;
    for(auto m:mpo){
        if(m.second>maxo && m.first != key){
            maxo=m.second;
        }
    }
    int ans=n-maxo-maxe;

    maxe=0, key=0;
    for(auto m:mpo){
        if(m.second>maxo){
            maxo=m.second;
            key=m.first;
        }
    }
    maxe=0;
    for(auto m:mpe){
        if(m.second>maxe && m.first != key){
            maxe = m.second;
        }
    }
    int ans2=n-maxe-maxo;
    cout<<min(ans, ans2)<<endl;
    return 0;

}


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

#define EPS (1e-10)
#define equals(a, b) (fabs((a) - (b)) < EPS)

class Point {
public:
	double x, y;
	Point(double x = 0.0, double y = 0.0) :
			x(x), y(y) {
	}

	Point operator +(Point p) {
		return Point(x + p.x, y + p.y);
	}
	Point operator -(Point p) {
		return Point(x - p.x, y - p.y);
	}
	Point operator *(double k) {
		return Point(x * k, y * k);
	}
	Point operator /(double k) {
		return Point(x / k, y / k);
	}

	double norm() {
		return x * x + y * y;
	}
	double abs() {
		return sqrt(norm());
	}

	bool operator <(Point p) {
		return x != p.x ? x < p.x : y < p.y;
	}
	bool operator ==(Point p) {
		return equals(x, p.x) && equals(y, p.y);
	}
};
typedef Point Vector;

class Segment {
public:
	Point p1, p2;
	Segment(Point p1 = Point(), Point p2 = Point()) :
			p1(p1), p2(p2) {
	}
};
typedef Segment Line;

double dot(Vector v1, Vector v2) {
	return v1.x * v2.x + v1.y * v2.y;
}
double cross(Vector v1, Vector v2) {
	return v1.x * v2.y - v1.y * v2.x;
}
bool isOrthogonal(Vector v1, Vector v2) {
	return equals(dot(v1, v2), 0.0);
}
bool isOrthogonal(Segment s1, Segment s2) {
	return equals(dot(s1.p2 - s1.p1, s2.p2 - s2.p1), 0.0);
}
bool isOrthogonal(Point l1, Point l2, Point m1, Point m2) {
	return isOrthogonal(l2 - l1, m2 - m1);
}
bool isParallel(Vector v1, Vector v2) {
	return equals(cross(v1, v2), 0.0);
}
bool isParallel(Segment s1, Segment s2) {
	return equals(cross(s1.p2 - s1.p1, s2.p2 - s2.p1), 0.0);
}
bool isParallel(Point l1, Point l2, Point m1, Point m2) {
	return isParallel(l1 - l2, m1 - m2);
}

Point projection(Segment s, Point p) {
	Vector base = s.p2 - s.p1;
	double r = dot(p - s.p1, base) / base.norm();
	return s.p1 + base * r;
}

int main() {
	Line l;
	cin >> l.p1.x >> l.p1.y;
	cin >> l.p2.x >> l.p2.y;
	int q;
	cin >> q;
	for (int i = 0; i < q; i++) {
		int x, y;
		cin >> x >> y;
		Point p = projection(l, Point(x, y));
		cout << fixed << setprecision(10) << p.x << " " << p.y << endl;
	}
	return 0;
}



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

#define show(x) cerr << #x << " = " << x << endl

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;

template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v)
{
    os << "sz:" << v.size() << "\n[";
    for (const auto& p : v) {
        os << p << ",";
    }
    os << "]\n";
    return os;
}

template <typename S, typename T>
ostream& operator<<(ostream& os, const pair<S, T>& p)
{
    os << "(" << p.first << "," << p.second
       << ")";
    return os;
}


constexpr ll MOD = (ll)1e9 + 7LL;

template <typename T>
constexpr T INF = numeric_limits<T>::max() / 100;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    for (int i = 0; i < s.size() - 8; i++) {
        cout << s[i];
    }
    cout << endl;
    return 0;
}


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

int main() {
  int n, a, s = 0;
  cin >> n;
  for(int i = 0;i < n;i++) {
    cin >> a;
    if(a == s + 1) s++;
  }
  cout << ((s == 0) ? -1 : n - s) << endl;
}

Measured memory_bytes: 3604
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <map>
#include <set>

#define MIN_INT -2147483648
#define MAX_INT 2147483647
#define MIN_LONG -9223372036854775808L
#define MAX_LONG 9223372036854775807L
#define PI 3.141592653589793238462643383279502884L

#define long long long int

using std::vector;
using std::map;
using std::set;
using std::string;
using std::pair;
using std::cin;
using std::cout;
using std::cerr;

// @author: pashka

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

    long a, b, c, k;
    cin >> a >> b >> c >> k;
    if (k % 2 == 0) {
        cout << a - b;
    } else {
        cout << b - a;
    }
    return 0;
}

Measured memory_bytes: 256
from numpy import zeros

N = int(input())
P = map(float, input().split())

dp = zeros(N + 1)
dp[0] = 1.0

for p in P:
    T = dp
    dp = T * (1 - p)
    dp[1:] += T[:-1] * p

print(dp[-(-N // 2):].sum())

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



int main() {
	int count;
	cin >> count;
	//random_device rd;
	//mt19937 mt;
	//mt.seed(rd());
	//uniform_int_distribution<> numDis(0,20);

	int* numList = new int[count];
	for (int i = 0; i < count; i++) {
		cin >> numList[i];
		//numList[i] = numDis(mt);
	}

	int swapCount = 0;

	for (int i = 0; i < count; i++) {
		int minIndex = i;
		for (int j = i; j < count; j++) {
			if (numList[j] < numList[minIndex]) {
				minIndex = j;
			}
		}
		if (minIndex!=i) {
			int temp = numList[i];
			numList[i] = numList[minIndex];
			numList[minIndex] = temp;
			swapCount++;
		}	
	}

	for (int k = 0; k < count; k++) {
		cout << numList[k];
		if (k != (count - 1)) {
			cout << ' ';
		}
	}
	cout << endl;
	cout << swapCount << endl;

	delete[] numList;
	return 0;
}

Measured memory_bytes: 3096
#include <iostream>
#include <string>
#include <vector>

using namespace std;
typedef long long ll;

int main() {
    string s;
    cin >> s;
    ll n[26] = {};
    for(ll i=0;i<s.size();i++) {
        n[s[i]-'a']++;
    }

    vector<ll> v;
    for(ll i=0;i<26;i++) {
        if(n[i] != 0)
            v.push_back(n[i]);
    }
    ll ans = 0;
    if(v.size() <= 1) {
        ans = 1;
    } else {
        for(ll i=0;i<v.size()-1;i++) {
            for(ll j=i+1;j<v.size();j++) {
                ans += v[i] * v[j];
            }
        }
        ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
const int N=233,big=0x3f3f3f3f;
int dp[N][N][N];

int dfs(int a,int b,int c)
{
	if(a>111 || b>111 || c>111)return big;
	if(a==b && b==c)return 0;
	if(dp[a][b][c])return dp[a][b][c];
	return dp[a][b][c]=min(min(min(dfs(a+1,b+1,c),dfs(a+1,b,c+1)),dfs(a,b+1,c+1)),min(dfs(a+2,b,c),min(dfs(a,b+2,c),dfs(a,b,c+2))))+1;
}

int main()
{
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	printf("%d\n",dfs(a,b,c));
	return 0;
}

Measured memory_bytes: 23808
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <sstream>
#include <map>
#include <set>
#include <cmath>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<30
#define pb push_back
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int main() {
	double l, a, b, c, d;
	cin >> l >> a >> b >> c >> d;

	cout << l - max(ceil(a / c), ceil(b / d)) << endl;

	return 0;
}

Measured memory_bytes: 1280
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<list>
#include<bitset>
#include<stack>
#include<memory>
#include<numeric>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define REP(i, n) for(int i = 0;i < (n);i++)
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const llint mod=998244353;
const llint inf=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-10;
template <class T,class U>bool chmin(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool chmax(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(const vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(const vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}

int main(void){
	int n,x,y,z,i;cin>>n;
	vector<int>ans(n+1);
	for(x=1;x*x<=n;x++){
		for(y=1;x*x+y*y+x*y<=n;y++){
			for(z=1;x*x+y*y+z*z+x*y+y*z+x*z<=n;z++){
				ans[x*x+y*y+z*z+x*y+y*z+x*z]++;
			}
		}
	}
	for(i=1;i<=n;i++){cout<<ans[i]<<endl;}
	return 0;
}


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

int main() {
  int n;
  cin >> n;
  for(int i=1;i<=9;i++)if(n % i == 0 && n / i <= 9 && n / i >= 1) {
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
using namespace std;
int x,ans=1;
int main(){
    cin>>x;
    for(int i=2;i<=sqrt(x);i++){
        for(int k=1;k<=x;k*=i){
            ans=max(ans,k);
        }
    }
    cout<<ans;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String str = sc.nextLine();
		int sub = 1000;
		
		for(int i=0; i < str.length()-2;i++) {
			int temp = Integer.parseInt(str.substring(i, i+3));
			sub = Math.min(sub, Math.abs(temp-753));
		}
		System.out.println(sub);
		sc.close();
	}

}


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

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            List<int> resultList = new List<int>();

            string input;
            while ((input = Console.ReadLine()) != "0")
            {
                int n = int.Parse(input);
                int[] inputArray = new int[n];
                int sumMax = 0;

                for (int i = 0; i < n; i++)
                {
                    inputArray[i] = int.Parse(Console.ReadLine());
                    if (i == 0 || sumMax < inputArray[i])
                    {
                        sumMax = inputArray[i];
                    }
                }

                for (int j = 0; j < n; j++)
                {
                    int tmpSum = inputArray[j];
                    for (int k = j + 1; k < n; k++)
                    {
                        tmpSum += inputArray[k];
                        if (tmpSum > sumMax)
                        {
                            sumMax = tmpSum;
                        }
                    }

                }

                resultList.Add(sumMax);
            }

            foreach (int a in resultList)
            {
                Console.WriteLine(a);
            }


        }


    }
}

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

// Type alias
using ll=long long;
using ld=double;

using pi=pair<int,int>;
using pll=pair<ll,ll>;
using pld=pair<ld,ld>;
using ti3=tuple<int, int, int>;

using vi=vector<int>;
using vll=vector<ll>;
using vld=vector<ld>;
using vpi=vector<pi>;
using vpll=vector<ll>;
using vpld=vector<ld>;
using vti3=vector<ti3>;

// Constants
const double EPS = 1e-9;
const int inf = numeric_limits<int>::max();

// Macro
#define rep(i,n) for(int i=0;i<int(n);++i)
#define rrep(i,n) for(int i=int(n-1);i>=0;--i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define RREP(i,a,b) for(int i=int(b-1);i>=int(a);--i)
#define SHOW(a) cout << #a << " = " << a << endl
#define ARR(a,n) for(int i=0;i<int(n);++i) cout << #a << "[" << i << "]" << " = " << a[i] << endl

#define ALL(a) a.begin(),a.end()

// Funtcions
ll pow(ll base, ll i, ll mod){
  ll a = 1;
  while(i){
    if (i & 1) {
      a *= base;
      a %= mod;
    }
    base *= base;
    base %= mod;
    i >>= 1;
  }
  return a;
}
ll gcd(ll a, ll b){
  while(b){
    ll c = a % b;
    a = b;
    b = c;
  }
  return a;
}
ll lcm(ll a, ll b){
  return a / gcd(a, b) * b;
}


void solve(){
  int n, k, q;
  int t[100000 + 5] = {0};
  cin >> n >> k >> q;
  rep(i,q){
    int j;
    cin >> j;
    j--;
    t[j]++;
  }

  rep(i, n){
    if(k - q + t[i] <= 0){
      cout << "No" << endl;
    }else{
      cout << "Yes" << endl;
    }
  }
}

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

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <algorithm>
using namespace std;
int main(){
    long long n;
    cin >> n;
    if (n%2 == 0){
        cout << n << endl;
    } else {
        cout << n*2 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
// ######      ###      #######    #######    ##     #     #####        ###     ##### //
// #     #    #   #          #        #       # #    #    #     #      #   #     ###  //
// #     #   #     #        #         #       #  #   #   #       #    #     #    ###  //
// ######   #########      #          #       #   #  #   #           #########    #   //
// #     #  #       #     #           #       #    # #   #    ####   #       #    #   //
// #     #  #       #    #            #       #     ##   #    #  #   #       #        //
// ######   #       #   #######    #######    #      #    #####  #   #       #    #   //

// #pragma GCC optimize(2)
// #pragma GCC optimize(3)
// #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
// #pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double lld;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> ppl;
#define ain(a,n) for(ll i=0;i<(n);++i)	cin>>(a)[i];
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define loop(i,n) for(ll i=0;i<(n);++i)
#define FOR(i,a,b) for(ll i=(a);i<=(b);++i)
#define FORD(i,a,b) for(ll i=(a);i>=(b);--i)
#define cases ll T=0;cin>>T;while(T--)
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define END "\n"
#define pb push_back
#define mp make_pair
#define go(c,itr) for(auto itr=(c).begin(); itr!=(c).end(); ++itr)
#define back(c,itr) for(auto itr=(c).rbegin(); itr!=(c).rend(); ++itr)
#define PI 3.14159265359
#define inf 9e18
#define MOD 1000000007
#define MODU 998244353
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define MAXN 100005
const string alpha = "abcdefghijklmnopqrstuvwxyz";
const ll N = 200005;
const long double epsilon = 1e-9;
ll binexp(ll a, ll b, ll m) {
	a %= m;
	ll res = 1;
	while (b > 0) {
		if (b & 1)
			res = res * a % m;
		a = a * a % m;
		b >>= 1;
	}
	return res;
}
ll modinvfermat(ll a, ll m)
{
	return binexp(a, m - 2, m);
}
void task(bool flag)
{
	if (flag)
		cout << "YES\n";
	else
		cout << "NO\n";
}
ll lcm(ll a, ll b)
{
	return ((1LL * a * b) / (__gcd(a, b)));
}

signed main() {

	fast
	ll a, b, v, w, t;
	cin >> a >> v >> b >> w >> t;
	if (v <= w)
		task(0);
	else
	{
		task((v - w)*t * 1LL >= abs(a - b));
	}


// #ifndef ONLINE_JUDGE
// 	cout << "\nTime Elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " sec\n";
// #endif
	return 0;
}


Measured memory_bytes: 3612
#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>;
#define MAX 100000
#define SENTINEL 2000000000
struct Card {
    char suit;
    int value;
};

struct Card L[MAX / 2 + 2], R[MAX / 2 + 2];

void merge(struct Card A[], int n, int left, int mid, int right) {
    int i, j, k;
    int n1 = mid - left;
    int n2 = right - mid;
    for (i = 0; i < n1; i++) L[i] = A[left+i];
    for (i = 0; i < n2; i++) R[i] = A[mid+i];
    L[n1].value = R[n2].value = SENTINEL;
    i = 0, j = 0;
    for (k = left; k < right; k++) {
        if (L[i].value <= R[j].value) {
            A[k] = L[i++];
        } else {
            A[k] = R[j++];
        }
    }
}

void mergeSort(struct Card A[], int n, int left, int right) {
    int mid;
    if (left+1 < right) {
        mid = (left + right) / 2;
        mergeSort(A, n, left, mid);
        mergeSort(A, n, mid, right);
        merge(A, n, left, mid, right);
    }
}

int partition(struct Card A[], int n, int p, int r) {
    int i, j;
    struct Card t, x;
    x = A[r];
    i = p - 1;
    for(j = p; j < r; j++) {
        if (A[j].value <= x.value) {
            i++;
            t = A[i]; A[i] = A[j]; A[j] = t;
        }
    }
    t = A[i+1]; A[i+1] = A[r];; A[r] = t;
    return i+1;
}


void quickSort(struct Card A[], int n, int p, int r) {
    int q;
    if (p < r) {
        q = partition(A, n, p, r);
        quickSort(A, n, p, q - 1);
        quickSort(A, n, q + 1, r);
    }
}

int main() {
    int n, i, v;
    struct Card A[MAX], B[MAX];
    char S[10];
    int stable = 1;

    scanf("%d", &n);

    for (i = 0; i < n; i++)  {
        scanf("%s %d", S, &v);
        A[i].suit = B[i].suit = S[0];
        A[i].value = B[i].value = v;
    }

    mergeSort(A, n, 0, n);
    quickSort(B, n, 0, n-1);

    for (i = 0; i < n; i++) {
        //マージソートとクイックソートの結果を比べる
        if (A[i].suit != B[i].suit) stable = 0;
    }

    if (stable) printf("Stable\n");
    else printf("Not stable\n");
    for (i = 0; i < n; i++) {
        printf("%c %d\n", B[i].suit, B[i].value);
    }

    return 0;
}


Measured memory_bytes: 5528
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int n,k;
int head[5010],nxt[5010],bian[5010],tot;
int ans=2147483600,mn;
inline void add(int x,int y){
	tot++;
	bian[tot]=y;
	nxt[tot]=head[x];
	head[x]=tot;
}
void dfs(int rt,int f,int dep){
	if(dep>k/2)mn++;
	for(int i=head[rt];i;i=nxt[i]){
		if(bian[i]==f)continue;
		dfs(bian[i],rt,dep+1);
	}
}
int main()
{
	cin>>n>>k;
	for(int i=1;i<n;++i){
		int x,y;
		scanf("%d%d",&x,&y);
		add(x,y);
		add(y,x);
	}
	if(k&1){
		for(int i=1;i<=n;++i){
			for(int j=head[i];j;j=nxt[j]){
				int y=bian[j];
				mn=0;
				dfs(i,y,0);
				dfs(y,i,0);
				ans=min(ans,mn);
			}
		}
	}else{
		for(int i=1;i<=n;++i){
			mn=0;
			dfs(i,0,0);
			ans=min(mn,ans);
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main()
{
	long long a,ans=0,minn=-1;
	int n,cnt=0,i;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
		scanf("%lld",&a);
		if(a<=0)
		{
			cnt++;
			a=-a;
		}
		ans+=a;
		if(minn==-1)
			minn=a;
		else
			minn=min(minn,a);
	}
	if(cnt%2==0)
		printf("%lld",ans);
	else
		printf("%lld",ans-2*minn);
    return 0;
}

Measured memory_bytes: 256
ip = input().split()
N = int(ip[0])

K = int(ip[1])
Dinput = input().split()
Ds = []#嫌いな数
for i in range(K):
    Ds.append(Dinput[i])#文字列

boolean = False
n = N
while boolean == False:
    str_n = list(str(n))
    for d in range(K):
        if Ds[d] in str_n:#嫌いな文字がある場合
            boolean = False
            break
        else:
            boolean = True
    if boolean == False:
        n += 1
    
print(n)

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

int main() {
    int n;
    cin >> n;
    vector<pair<int, int>> a;
    for (int e, i = 0; i < n; i++) {
        cin >> e;
        a.emplace_back(e, i);
    }
    sort(a.begin(), a.end());
    reverse(a.begin(), a.end());
    
    set<int> index;
    long long ans = 0;
    for (const auto& e : a) {
        int v, i; tie(v, i) = e;
        vector<int> l(2, -1), r(2, n);
        const auto itr = index.lower_bound(i);
        auto it = itr;
        for (int j = 0; j < 2; j++) {
            if (it != index.end()) r[j] = *(it++);
        }
        it = itr;
        for (int j = 0; j < 2; j++) {
            if (it != index.begin()) l[j] = *(--it);
        }
        long long v1 = (i - l[0]) * (r[1] - r[0]);
        long long v2 = (r[0] - i) * (l[0] - l[1]);
        ans += (v1 + v2) * v;
        index.insert(i);
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5748
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, n) for(int i = 1; i <= (int)(n); i++)
const long long INF = 1LL << 60;

const long long M=1000000007;
int modPow(long long a, long long n, long long p) {
  if (n == 1) return a % p;
  if (n % 2 == 1) return (a * modPow(a, n - 1, p)) % p;
  long long t = modPow(a, n / 2, p);
  return (t * t) % p;
}
int main() 
{
    long long n,a,b,combi_n,combi_a,combi_b;
    cin >> n >> a >> b;

    combi_n=(modPow(2,n,M)-1)%M;

    long long x=1,y=1;
    long long i=a;
    while(i){
        y=(y*i)%M;
        i--;
    }
    i=n;
    while(i>n-a){
        x=(x*i)%M;
        i--;
    }
    combi_a=(x*modPow(y,M-2,M))%M;

    x=1,y=1;
  	i=b;
    while(i){
        y=(y*i)%M;
        i--;
    }
    i=n;
    while(i>n-b){
        x=(x*i)%M;
        i--;
    }
    combi_b=(x*modPow(y,M-2,M))%M;

  
  	if(combi_n-combi_a-combi_b>=0){
    cout << (combi_n-combi_a-combi_b) << endl;
    }else if(combi_n-combi_a-combi_b+M>0){
      cout << combi_n-combi_a-combi_b+M << endl;
    }else{
      cout << combi_n-combi_a-combi_b+2*M << endl;
    }
}

Measured memory_bytes: 256
N,X,M = map(int,input().split())
id = [-1] * M
lis = []
tot = 0
le = 0
while id[X] == -1:
    id[X] = le
    le += 1
    lis.append(X)
    tot += X
    X = (X**2) % M

c = le - id[X]
sm = 0
for i in range(id[X],le):
    sm += lis[i]
if (N <= le):
    ans = 0
    for i in range(N):
        ans += lis[i]
    print(ans)
    exit()

ans = tot
N -= le
ans += N // c * sm
N %= c
for i in range(id[X],id[X]+N):
    ans += lis[i]
print(ans)


Measured memory_bytes: 69672
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>

using namespace std;

#define mod 1000000007

int getgcd(int m, int n)
{
	if(n == 0) return m;
	return getgcd(n, m % n);
}

int main()
{
	int n, k;
	cin >> n >> k;
	int gcd;
	int maxnum;
	for(int i = 0; i < n; i++){
		int a;
		cin >> a;
		if(i == 0){
			gcd = a;
			maxnum = a;
		} else {
			gcd = getgcd(max(gcd, a), min(gcd, a));
			maxnum = max(maxnum, a);
		}
	}
	if(k % gcd == 0 && k <= maxnum) cout << "POSSIBLE" << endl;
	else cout << "IMPOSSIBLE" << endl;

}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll=long long;
#define print(n) cout<<n<<endl
#define rep(i,a,n) for(int i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
#define P pair<ll,ll>
#define vl vector<ll>
#define vi vector<int>
#define vvl vector<vector<ll>>
#define vvi vector<vector<int>>
const int M=100111;
const int inf=1000000007;
const long long INF=1e18;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
int ddx[8]={1,-1,0,0,1,-1,-1,1},ddy[8]={0,0,1,-1,1,-1,1,-1};


int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n,a;
	cin>>n;
	map<int,int> cnt;
	rep(i,0,n)cin>>a,cnt[a]++;
	if(cnt[0]==n){
		print("Yes");
		return 0;
	}
	if(n%3!=0){
		print("No");
		return 0;
	}
	vector<int> all;
	for(auto& v:cnt){
		rep(i,0,v.second/(n/3)){
			all.push_back(v.first);
		}
	}
	if(all.size()==3&&(all[0]^all[1]^all[2])==0){
		print("Yes");
	}else{
		print("No");
	}
	return 0;
}             

Measured memory_bytes: 3840