akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define chmax(a, b) a = max(a, b);
#define chmin(a, b) a = min(a, b);
using namespace std;
using ll = long long;
using P = pair<int,int>;
using VI = vector<int>;
using VVI = vector<VI>;

int m;
// T has to implement 'operator+' and 'add_parent' method
struct C {
    ll x;
    C(ll x=1): x(x) {}
    C operator+(C x) {
        return C(this->x * x.x % m);
    }
    C add_parent(int i) {
        return C(x+1);
    }
};

template<class T>
class RTDP {
	class Node {
		public:
		int k; // k_th node
		RTDP& nodes; // owner object holding all nodes
		const std::vector<int>& children; // children indices
		const int csize;
		std::vector<T> dp; // stores dps of children
		std::vector<T> lmerged;
		std::vector<T> rmerged;

		Node(RTDP& ns, int i) : k(i), nodes(ns), children(ns.v[i]), csize(children.size()), dp(csize), lmerged(csize + 1), rmerged(csize + 1) {}

		T fc(int parent = -1) {
			const int csize = children.size();
			T m;
			for(int i = 0; i < csize; i++) {
				int ci = children[i];
				if (ci == parent) continue;
				dp[i] = nodes.ns[ci].fc(k);
				m = m + dp[i];
			}
			return m.add_parent(k);
		}

		void fp(int parent = -1) {
			const int csize = children.size();
			// assume that dp is already filled in
			// left merge
			for(int i = 0; i < csize; i++) {
				lmerged[i + 1] = lmerged[i] + dp[i];
			}
			// right merge
			for(int i = csize; i > 0; i--) {
				rmerged[i - 1] = rmerged[i] + dp[i - 1];
			}
			for(int i = 0; i < csize; i++) {
				int  ci = children[i];
				if (ci == parent) continue;
				Node& cnode = nodes.ns[ci];
				for(int j = 0; j < cnode.csize; j++) {
					if (cnode.children[j] == k) {
						cnode.dp[j] = (lmerged[i] + rmerged[i + 1]).add_parent(k);
						break;
					}
				}
				cnode.fp(k);
			}
			return;
		}
	};

	std::vector<std::vector<int>>& v;
	int size;
	std::vector<Node> ns;
	std::vector<T> root_dp;

	public:
	RTDP(std::vector<std::vector<int>>& v) : v(v), size(v.size()), root_dp(size) {
		for(int i = 0; i < size; i++) {
			ns.push_back(Node(*this, i));
		}
	}

	void exec_dp(int root = 0) {
		fill_in_children(root);
		fill_in_parent(root);
	}

	void fill_in_children(int root) {
		ns[root].fc();
	}

	void fill_in_parent(int root) {
		ns[root].fp();
	}

	T get_root_dp(int i) {
		Node& r = ns[i];
		return r.lmerged[r.csize].add_parent(i);
	}

};



int main() {
    int n;
    cin >> n >> m;
    VVI to(n);
    rep(i, n-1) {
        int u, v;
        cin >> u >> v;
        u--; v--;
        to[u].push_back(v);
        to[v].push_back(u);
    }
    RTDP<C> dp(to);
    dp.exec_dp();
    rep(i, n) cout << dp.get_root_dp(i).x - 1 << endl;
}


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

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

typedef long long ll;

ll INF = 100000000000000;
ll MOD = 1e9+7;

ll d(ll a){
    ll res = 0;
    while(a){
        a /= 10;
        res++;
    }
    return res;
}

int main(){
    ll N;cin >> N;
    ll ans = INF;
    for(ll i = 1;i <= pow(N,0.5);i++){
        if(N % i == 0){
            ans = min(ans,max(d(N / i),d(i)));
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#ifdef _WIN32
#include "stdc++.h"
#else
#include<bits/stdc++.h>
#endif

#define REP(i,j,k) for(int (i)=(j); (i) < (k); (i)++)
using namespace std;

bool solve()
{
	int h; cin >> h;
	if (h == 0)return false;

	vector<list<int>> ishi(5);
	int ans = 0;

	REP(j, 0, h)
	{
		REP(i, 0, 5)
		{
			int k = 0; cin >> k;
			ishi[i].push_front(k);
		}
	}
	bool atari = true;
	while (atari)
	{
		/*
		for (int i = 0; i < 5; ++i)
		{
			for (auto itr : ishi[i])
				cout << itr << " ";
			cout << endl;
		}
		*/
		atari = false;
		vector<list<int>> newIshi(5);

		while (true)
		{
			bool isEmpty = true;
			for (int i = 0; i < 5; ++i)
			{
				if (!ishi[i].empty())
				{
					isEmpty = false;
				}
			}
			if (isEmpty)
			{
				ishi = newIshi;
				break;
			}


			vector<int> check(5);
			for (int i = 0; i < 5; ++i)
			{
				if (ishi[i].empty())
				{
					check[i] = 0;
				}
				else
				{
					check[i] = ishi[i].front();
					ishi[i].pop_front();
				}
			}
			bool find = false;
			for (int count = 5; count >= 3; --count)
			{
				if (find)break;
				for (int s = 0; s <= 5 - count; ++s)
				{
					bool same = true;
					int n = check[s];
					if (n == 0)break;
					for (int i = s; i < s + count; ++i)
					{
						if (n != check[i]) {
							same = false;
						}
					}
					if (same)
					{
						/*
						cout << n << ":" << count << endl;
						*/
						ans += n * count;
						atari = true;
						find = true;
						REP(i, 0, 5)
						{
							if ((i < s || s + count <= i) && check[i]!=0)
							{
								newIshi[i].push_back(check[i]);
							}
						}

						break;
					}

				}
			}
			if (!find)
			{
				REP(i, 0, 5)
				{
					if (check[i] != 0)
					{
						newIshi[i].push_back(check[i]);
					}
				}
			}
		}
	}

	cout << ans << endl;
	return true;
}

int main()
{
	while (solve())
	{

	}
	return 0;
}


Measured memory_bytes: 3088
//encoding:utf-8
//#include <iostream> //c++
//#include<stack> //スタックに関して　最新のデータから捨てる
//#include<queue> //キューに関して　最古のデータから捨てる
//#include<math.h>
//#include<vector>
//#include<algorithm> //sort とかにいる
#include<bits/stdc++.h>//vector,algorithm,que
#include<time.h> //時間にかんして

#define ll long long
#define MOD 1000000007
#define INF (1<<29)
using namespace std;
int main(){
  int N;
  cin>>N;
  ll A[N][N];
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      cin>>A[i][j];
    }
  }
  ll ans = 0;
  bool exist = true;
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      for(int k=0;k<N;k++){
        if(A[j][k] > A[j][i]+A[i][k]){
          exist = false;
        }
      }
    }
  }
  if(exist){
    for(int i=0;i<N;i++){
      for(int j=0;j<N;j++){
        ll tmp = 100000000000;
        for(int k=0;k<N;k++){
          if(i==k||j==k){
          }
          else if(tmp>A[i][k]+A[k][j]){
            tmp = A[i][k]+A[k][j];
          }
        }
        if(A[i][j] < tmp){
          ans += A[i][j];
        }
      }
    }
    ans = ans/2;
  }
  if(exist){
  }
  else{
    ans = -1;
  }
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>

#define int long long

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPS(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)

#define INF (3e9)

using namespace std;

signed main()
{
    string s;
    string t;
    cin >> s >> t;

    int mIdx = -1;
    REP(i, s.size() - t.size()+1)
    {
        bool match = true;
        REP(j, t.size())
        {
            if (s[i+j] == t[j] || s[i+j] == '?') continue;
            match = false;
            break;
        }
        if (match) mIdx = max(mIdx, i);
    }
    if (mIdx == -1)
    {
        cout << "UNRESTORABLE" << endl;
        return 0;
    }

    REP(i, s.size())
    {
        if (i == mIdx)
        {
            REP(j, t.size())
            {
                s[i+j] = t[j];
            }
            i += t.size()-1;
        }
        if (s[i] == '?') s[i] = 'a';
    }

    cout << s << endl;

    return 0;
}

Measured memory_bytes: 256
/*
	AOJ_0052:Factorial II
*/
#include	<iostream>

using namespace std;

int main(){
	int n, sum;

	while (1) {
		cin >> n;
		if (n == 0) break;

		sum = 0;
		while (n >= 5) {
			n /= 5;
			sum += n;
		}
		cout << sum << endl;
	}

	return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
#include <assert.h>
using namespace std;
#define rep(a,b,c) for(int a=b;a<=c;a++)
#define repn(a,b,c) for(int a=b;a>=c;a--)
#define ll long long 
#define sum(a,b) a=a+b
#define mem(a, b) memset(a, (b), sizeof(a))
#define ctz(x) __builtin_ctz(x)
#define clz(x) __builtin_clz(x)
#define popcount(x) __builtin_popcount(x)
#define parity(x) __builtin_parity(x)

//=======binarysearch===========
int bs(vector<int>&a,int que){
 auto it=lower_bound(a.begin(),a.end(),que);
 if(*it==que){
    return it-a.begin();
 }
 return -1;
}
//========binarysearch=========


bool isprime(int x)
{
  if ( x == 2 ) return true;
  if ( x  < 2 ) return false;
  for ( int i = 2; i * i <= x; i++ )
    if ( x % i == 0 ) return false;


  if(x==0) return false;
  return true;
}

int main(){


int n;

cin>>n;

int a[101];

rep(i,1,n){
  cin>>a[i];
}


int dif=1;
int last_dif=0;
int ans=0;

a[n+1]=1001;

rep(i,1,n){

  if(a[i]==a[i+1]){
    dif++;
  }else if(a[i]!=a[i+1]){
    
    ans=ans+(dif/2);
    dif=1;
  }

}



cout<<ans<<endl;

}

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

int main(void){
  long long N;
  cin >>N;
  if (N%2==1){
    cout<<0<<endl;
    return 0;
  }
  long long cnt=0;
  long long i=10;
  
  while(i<=N){
    cnt=cnt+N/i;
    i=i*5;
  }
  cout<<cnt<<endl;
  return 0;
}

 
  
  

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long
int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int sx, sy, tx, ty;
	cin >> sx >> sy >> tx >> ty;
	for (int i = 1; i <= ty - sy; i++) {
		cout << "U";
	}
	for (int i = 1; i <= tx - sx; i++) {
		cout << "R";
	}
	for (int i = 1; i <= ty - sy; i++) {
		cout << "D";
	}
	for (int i = 1; i <= tx - sx; i++) {
		cout << "L";
	}
	cout << "L";
	for (int i = 1; i <= ty - sy + 1; i++) {
		cout << "U";
	}
	for (int i = 1; i <= tx - sx + 1; i++) {
		cout << "R";
	}
	cout << "D";
	cout << "R";
	for (int i = 1; i <= ty - sy + 1; i++) {
		cout << "D";
	}
	for (int i = 1; i <= tx - sx + 1; i++) {
		cout << "L";
	}
	cout << "U";

}

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

#define minv(v) *min_element(v.begin(),v.end())
#define maxv(v) *max_element(v.begin(),v.end())
#define unq(v) sort(v.begin(),v.end()),v.erase(unique(v.begin(),v.end()),v.end())
#define ll long long
#define pb push_back
#define fill(arr) memset(arr,0,sizeof(arr))
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define pi acos(-1.00)
#define _ios ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

int main()
{
    _ios;
    ll r;
    cin>>r;
    cout<<2*pi*r<<endl;
    return 0;
}



Measured memory_bytes: 3792
#include <bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))
#define POW(n) (1LL<<(n))
#define IN(i,a,b) (a <= i && i <= b)
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a>b) { a=b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a<b) { a=b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(ALL(a)); }
template <typename T> inline void REV(T& a) { reverse(ALL(a)); }
template <typename T> inline void UNI(T& a) { sort(ALL(a)); a.erase(unique(ALL(a)),a.end()); }
template <typename T> inline T LB(vector<T>& v, T a) { return *lower_bound(ALL(v),a); }
template <typename T> inline int LBP(vector<T>& v, T a) { return lower_bound(ALL(v),a) - v.begin(); }
template <typename T> inline T UB(vector<T>& v, T a) { return *upper_bound(ALL(v),a); }
template <typename T> inline int UBP(vector<T>& v, T a) { return upper_bound(ALL(v),a) - v.begin(); }
template <typename T1, typename T2> ostream& operator<< (ostream& os, const pair<T1,T2>& p) { os << p.first << " " << p.second; return os; }
template <typename T1, typename T2> istream& operator>> (istream& is, pair<T1,T2>& p) { is >> p.first >> p.second; return is; }
template <typename T> ostream& operator<< (ostream& os, const vector<T>& v) { REP(i,v.size()) { if (i) os << " "; os << v[i]; } return os; }
template <typename T> istream& operator>> (istream& is, vector<T>& v) { for(T& in : v) is >> in; return is; }
template <typename T = int> vector<T> make_v(size_t a) { return vector<T>(a); }
template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...)); }
template <typename T, typename V> typename enable_if<is_class<T>::value == 0>::type fill_v(T &t, const V &v) { t = v; }
template <typename T, typename V> typename enable_if<is_class<T>::value != 0>::type fill_v(T &t, const V &v) { for(auto &e : t) fill_v(e,v); }
const int MOD = 1000000007;
const int INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;

signed main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  int A,B;
  cin >> A >> B;
  if (A == 1) A = 14;
  if (B == 1) B = 14;
  cout << (A > B ? "Alice" : A < B ? "Bob" : "Draw") << endl;

  return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func getNextLine(scanner *bufio.Reader) string {
	var buffer string
	for {
		line, isPrefix, _ := scanner.ReadLine()
		buffer += string(line)
		if isPrefix == false {
			break
		}
	}
	return buffer
}

func getIntList(scanner *bufio.Reader) []int {
	list := strings.Split(getNextLine(scanner), " ")
	l := len(list)
	result := make([]int, l)
	for i := 0; i < l; i++ {
		result[i], _ = strconv.Atoi(list[i])
	}
	return result
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := bufio.NewReader(fp)
	writer := bufio.NewWriter(os.Stdout)

	s := getNextLine(scanner)
	l := len(s)

	stack := make([]int, l)
	waters := make([]Water, l)
	p := -1
	wp := -1
	for i := 0; i < l; i++ {
		if s[i] == '\\' {
			p++
			stack[p] = i
			continue
		}
		if p == -1 {
			continue
		}
		if s[i] == '/' {
			water := Water{
				left: stack[p],
				mm:   i - stack[p],
			}
			for wp >= 0 && waters[wp].left > water.left {
				water.mm += waters[wp].mm
				wp--
			}
			wp++
			waters[wp] = water
			p--
			continue
		}
	}
	total := 0
	for i := 0; i <= wp; i++ {
		total += waters[i].mm
	}
	fmt.Fprintln(writer, total)
	fmt.Fprint(writer, wp+1)
	for i := 0; i <= wp; i++ {
		fmt.Fprint(writer, " ")
		fmt.Fprint(writer, waters[i].mm)
	}
	fmt.Fprintln(writer, "")

	writer.Flush()
}

type Water struct {
	left int
	mm   int
}



Measured memory_bytes: 1332
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>

using namespace std;

int main() {
    int K;
    cin >> K;

    int A[32] = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5,
        1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };

    cout << A[K - 1] << endl;
}


Measured memory_bytes: 256
using System;

class Program
{
    static void Main()
    {
        while (true)
        {
            string[] a = Console.ReadLine().Split(' ');
            int x = int.Parse(a[0]);
            int y = int.Parse(a[1]);
            
            if (x == 0 && y == 0)
            {
                break;
            }
            else if (x <= y)
            {
                Console.WriteLine("{0} {1}", x, y);
            }
            else
            {
                Console.WriteLine("{0} {1}", y, x);
            }
        }
    }
}


Measured memory_bytes: 15908
#include <iostream>
#include <sstream>
#include <vector>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iomanip>
#include <vector>
#include <cstdio>
#include <float.h>
#include <queue>
#include <set>
#include <map>
#include <fstream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <stack>
#include <functional>
 
using namespace std;
 
#define endl '\n'
#define MOD 1000000007
#define INF 1ll<<30
#define MAX 100010
#define eps 1e-11
#define bit_max 1ll<<32
#define _USE_MATH_DEFINES

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    
    int a,b;
    cin>>a>>b;
    cout<<max(a+b,max(a+a-1,b+b-1));
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}




int main(){
	ll n;
	cin >> n;
	auto a = make_vec<ll>(n+1,5,5,5);

	a[0][0][0][0] = 1;
	for(int i = 0; i < n; i++) {
		for(int j = 0; j < 5; j++) {
			for(int k = 0; k < 5; k++) {
				for(int l = 0; l < 5; l++) {
					for(int m = 1; m < 5; m++) {//付け足すときに0(ダミー)はつけちゃだめよ
						if (k == 1 && l == 2 && m == 3)continue;//AGC
						if (j == 1 && k == 2 && m == 3)continue;//AGXC
						if (j == 1 && l == 2 && m == 3)continue;//AXGC
						if (k == 2 && l == 1 && m == 3)continue;//GAC
						if (k == 1 && l == 3 && m == 2)continue;//ACG
						a[i + 1][k][l][m] = (a[i + 1][k][l][m] + a[i][j][k][l]) % mod;
					}
				}
			}
		}
	}

	ll ans = 0;

	for(int i = 1; i < 5; i++) {
		for(int j = 1; j < 5; j++) {
			for(int k = 1; k < 5; k++) {
				ans = (ans + a[n][i][j][k]) % mod;
			}
		}
	}

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

Measured memory_bytes: 384
#include <iostream>
#include<cctype>
#include<cstdio>
using namespace std;
int main(void){
    // Your code here!
    char n;
    int number[26] = {};  //アルファベットの数
    
    while(cin >> n){
        n = tolower(n);
        if(isalpha(n)){   //アルファベットのとき数える
            //int num = n - 'a';   //文字ｎの番号
            number[n - 'a']++;  //カウント  
        }
        
    }
    
    for(int i = 0; i < 26;i++){
        printf("%c : %d\n", i + 'a' ,number[i]);
    
    }
}




Measured memory_bytes: 3216
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <deque>
#include <numeric>
#include <utility>
#define sign(a) ((a>0)-(a<0))
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define LL long long
#define INF (LL)(1LL<<60)

using namespace std;

void solve(long long N, std::string resp){
    bool sws[N]; // true->S
    vector<vector<bool>> inis={{true, true}, {false, false}, {true, false}, {false, true}};
    auto f = [](char r, bool curr, bool prev){
        if(curr && r=='o')return prev;
        if(curr && r=='x')return !prev;
        if(!curr && r=='o')return !prev;
        if(!curr && r=='x')return prev;
        throw "input invalid";
    };
    for(auto ini: inis){
        sws[0]=ini[0];
        sws[1]=ini[1];
        for(LL i=1; i<N-1; i++)sws[i+1]=f(resp[i], sws[i], sws[i-1]);

        if(f(resp[0], sws[0], sws[1]) == sws[N-1] && f(resp[N-1], sws[N-1], sws[N-2]) == sws[0]){
            for(LL i=0; i<N; i++)cout << (sws[i] ? 'S' : 'W');
            cout << endl;
            return;
        }
    }
    cout << -1 << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::string s;
    std::cin >> s;
    solve(N, s);
    return 0;
}


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

int main() {
  int a,b,c,d,e,k;
  cin >> a >> b >> c >> d >> e >> k;
  if(e-a>k){
    cout << ":(";
  }
  else{
    cout << "Yay!";
  }
}
      

Measured memory_bytes: 3604
import java.util.Scanner;


public class Main {

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

		Dice d = new Dice(sc.nextInt(), sc.nextInt(), sc.nextInt(), sc.nextInt(), sc.nextInt(), sc.nextInt());
		Dice d2 = new Dice(sc.nextInt(), sc.nextInt(), sc.nextInt(), sc.nextInt(), sc.nextInt(), sc.nextInt());

		char[] cmd = "EEEENEEEENEEEENEEEENWNEEEENNEEEE".toCharArray();
		boolean flag = false;
		out:
		for (int i = 0; i < cmd.length; i++) {
			if (cmd[i] == 'N') {
				d.N();
			} else if (cmd[i] == 'S') {
				d.S();
			} else if (cmd[i] == 'E') {
				d.E();
			} else if (cmd[i] == 'W') {
				d.W();
			}
			for (int j = 0; j < cmd.length; j++) {
				if (cmd[j] == 'N') {
					d2.N();
				} else if (cmd[j] == 'S') {
					d2.S();
				} else if (cmd[j] == 'E') {
					d2.E();
				} else if (cmd[j] == 'W') {
					d2.W();
				}
				if (d.isSame(d2)) {
					flag = true;
					break out;
				}
			}
		}

		if (flag) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

		sc.close();
	}
	
	private static class Dice {
		int[] s;
		int up;
		int north;
		int east;

		Dice(int s1, int s2, int s3, int s4, int s5, int s6) {
			s = new int[6];
			s[0] = s1;
			s[1] = s2;
			s[2] = s3;
			s[3] = s4;
			s[4] = s5;
			s[5] = s6;
			up = 1;
			north = 5;
			east = 3;
		}
		
		public boolean isSame(Dice d2) {
			boolean flag = true;
			for (int i = 0; i < 6; i++) {
				if (s[up - 1] != d2.s[d2.up - 1]
					|| s[7 - up - 1] != d2.s[7 - d2.up - 1]
					|| s[north - 1] != d2.s[d2.north - 1]
					|| s[7 - north - 1] != d2.s[7 - d2.north - 1]
					|| s[east - 1] != d2.s[d2.east - 1]
					|| s[7 - east - 1] != d2.s[7 - d2.east - 1]) {
					flag =false;
				}
			}
			
			return flag;
		}

		void N() {
			int temp = 7 - north;
			north = up;
			up = temp;
		}
		
		void S() {
			int temp = 7 - up;
			up = north;
			north = temp;
		}
		
		void E() {
			int temp = 7 - east;
			east = up;
			up = temp;
		}

		void W() {
			int temp = 7 - up;
			up = east;
			east = temp;
		}
		
//		int now() {
//			return s[up - 1];
//		}

		public int getEast(int upValue, int southValue) {
			int upNow;
			for (upNow = 1; upNow <= 6; upNow++) {
				if (s[upNow - 1] == upValue) {
					break;
				}
			}
			int northNow;
			for (northNow = 1; northNow <= 6; northNow++) {
				if (s[northNow - 1] == southValue) {
					northNow = 7 - northNow;
					break;
				}
			}
			
			char[] cmd = "EEEENEEEENEEEENEEEENWNEEEENNEEEE".toCharArray();
			for (int i = 0; i < cmd.length; i++) {
				if (cmd[i] == 'N') {
					N();
				} else if (cmd[i] == 'S') {
					S();
				} else if (cmd[i] == 'E') {
					E();
				} else if (cmd[i] == 'W') {
					W();
				}
				if (northNow == this.north && upNow == this.up) {
					return s[east - 1];
				} else if (northNow == 7 - this.north && upNow == this.up) {
					return s[7 - east - 1];
				} else if (northNow == this.north && upNow == 7 - this.up) {
					return s[7 - east - 1];
				}
			}
			
			return -1;
		}
	}
}

Measured memory_bytes: 17376
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner((os.Stdin))

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

func nextInt() int {
	l := nextLine()
	i, e := strconv.Atoi(l)
	if e != nil {
		panic(e)
	}
	return i
}

func abs(n int) int {
	if n < 0 {
		return -n
	}
	return n
}

func main() {
	sc.Split(bufio.ScanWords)
	N := nextInt()
	T, X, Y := []int{}, []int{}, []int{}
	for i := 0; i < N; i++ {
		T, X, Y = append(T, nextInt()), append(X, nextInt()), append(Y, nextInt())
	}

	fmt.Printf("%s\n", ABC086C(T, X, Y))
}

// ABC086C ...
func ABC086C(T, X, Y []int) string {
	ct, cx, cy := 0, 0, 0

	for i := 0; i < len(T); i++ {
		dt, dx, dy := T[i]-ct, abs(X[i]-cx), abs(Y[i]-cy)

		rt := dt - (dx + dy)
		if rt < 0 || rt%2 != 0 {
			return "No"
		}

		ct, cx, cy = T[i], X[i], Y[i]
	}

	return "Yes"
}


Measured memory_bytes: 9560
#include<iostream>
#include<string>
using namespace std;
int main() {
	int n;
	string str;
	cin >> n >> str;
	int i;
	for (i = 0; i < str.size(); i++) {
		str[i] += n;

		if(str[i]>=91)str[i] -= 26;

	}
	cout << str << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define pb push_back
#define mp make_pair
#define st first
#define nd second
#define all(a) begin(a),end(a)
#define fr(x) freopen(x,"r",stdin)
#define fw(x) freopen(x,"w",stdout)
#define sz(x) ((int)x.size())
#define ins insert
#define rep(i,l,u) for(int i=l;i<=u;++i)
#define reb(i,l,u) for(int i=l;i>=u;--i)
using namespace std;
const int maxn=2e5+10;
const int mod=1e9+7;
int gcd(int a,int b){
    return b==0?a:gcd(b,a%b);
}
int lcm(int a,int b){
    return a*b/gcd(a,b);
}
int dir[4][2]={{1,0},{-1,0},{0,1},{0,-1}};
main(){
    int n;
    cin>>n;
    string s;
    cin>>s;
    int w=0,r=0;
    for(int i=0;i<s.length();++i){
        if(s[i]=='W'){
            w++;
        }else r++;
    }
    int ans=0;
    for(int i=0;i<r;++i){
        if(s[i]=='W')ans++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3752
#include <stdio.h>
using namespace std;
int main()
{
	int n,m;
	scanf("%d%d",&n,&m);
	if(n%m==0)
	{
		printf("%d\n",n/m);
	}
	else
	{
		printf("%d\n",n/m+1);
	}
	return 0;
}

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

bool cmp(char a,char b)
{
	return a>b;
}

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

Measured memory_bytes: 256
import java.lang.reflect.Array;
import java.util.*;
public class Main{
    public static void main(String[] args)throws Exception{
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();

        if ((n / 100) * 111 >= n){
            System.out.println((n / 100 ) * 111);
        }else{
            System.out.println((n / 100 + 1) * 111);
        }

    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
int main()
  {int N, m(1e7); cin >> N;
  int X[N]; for (int &x: X) cin >> x;
  for (int P{}; P <= 100; ++P)
    {int s{}; for (int x: X) s += (x - P) * (x - P);
    m = min(m, s);}
  cout << m;}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef long double ld;

int main() {
	
	cin.tie(0); cout.tie(0);
	ll n, i, s = 0; cin >> n;
	ll tab[n], tab2[n];
	for(i = 0; i < n; i++) cin >> tab[i];
	for(i = 0; i < n; i++) cin >> tab2[i];
	for(i = 0 ; i < n; i++) {
		if(tab[i] - tab2[i] >= 0) s+=(tab[i] - tab2[i]);
	}
	cout << s;
 	return 0;                         
}

Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

from collections import deque
ans = 0
def main():
    N, M, Q = map(int, readline().split())
    query = []
    for _ in range(Q):
        a, b, c, d = map(int, readline().split())
        query.append((a, b, c, d))
    

    def getScore(A):
        res = 0
        for a, b, c, d in query:
            if A[b-1]-A[a-1] == c:
                res += d
        return res

    A = deque()
    def dfs():
        global ans
        n = len(A)
        if n == N:
            ans = max(getScore(A), ans)
        else:
            if n == 0:
                k = 1
            else:
                k = A[-1]
            for i in range(k, M+1):
                A.append(i)
                dfs()
                A.pop()
    dfs()
    print(ans)          
if __name__ == '__main__':
    main()

Measured memory_bytes: 9372
d, g = map(int, input().split())
pc = [list(map(int, input().split())) for _ in range(d)]
ans = float('Inf')

for i in range(2 ** d):
    count = 0
    sum = 0
    nokori = set(range(1, d + 1))
    
    for j in range(d):
        if ((i >> j) & 1):
            sum += pc[j][0] * (j + 1) * 100 + pc[j][1]
            count += pc[j][0]
            nokori.discard(j + 1)
            
    if sum < g:
        use = max(nokori)
        n = min(pc[use - 1][0], -(-(g - sum) // (use * 100)))
        count += n
        sum += n * use * 100
        
    if sum >= g:
        ans = min(ans, count)
print(ans)

Measured memory_bytes: 3064
N = int(input())
a = []
b = []
for i in range(N):
    x,y = (list(map(int,input().split())))
    a.append(x+y)
    b.append(x-y)
a.sort()
b.sort()
ans = max(a[-1]-a[0],b[-1]-b[0])
print(ans)


Measured memory_bytes: 100136
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <iterator>
#include <vector>


using namespace std;

int main()
{
    long n;
    cin >> n;

    vector<long> a;
    long x;
    for(long i=0;i<n;i++){
        cin >> x;
        a.push_back(x);
    }
    sort(a.begin(), a.end());
    long half = (a[n-1]+1)/2;
    long l = 0, r = n-1;
    while(l < r){
        
        if(abs(a[l]-half) <= abs(a[r]-half)){
            r--;
        } else if (abs(a[l]-half) > abs(a[r]-half)){
            l++;
        }
    }
    cout << a[n-1] << " " << a[l] << endl;
}



Measured memory_bytes: 1400
n = int(input())
a = list(map(int,input().split()))
q = int(input())

dict_a = {}
current_sum = 0
for i in range(n):
  dict_a[a[i]] = dict_a.get(a[i],0)+1
  current_sum += a[i]

for i in range(q):
  b,c = map(int,input().split())
  diff = c-b
  
  rep_num = dict_a.get(b,0)
  current_sum += diff*rep_num
  print(current_sum)
  
  dict_a[b] = 0
  dict_a[c] = dict_a.get(c,0) + rep_num

Measured memory_bytes: 93572
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,diff;
    cin>>a>>b>>c;
    if(a==b){
        diff=c;
        cout<<diff<<endl;
    }
    else if(a==c){
        diff=b;
        cout<<diff<<endl;
    }
    else{
        diff=a;
        cout<<diff<<endl;
    }
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
int H, W;
int ALL_STEP;

bool dfs(vector<vector<char>> &A, int y, int x, int step) {
  if (y == (H - 1) && x == (W - 1)) {
    return (step == ALL_STEP);
  }
  int ny = y + 1;
  int nx = x + 1;
  bool ret = false;
  if (ny < H && A[ny][x] == '#') ret |= dfs(A, ny, x, step + 1);
  if (nx < W && A[y][nx] == '#') ret |= dfs(A, y, nx, step + 1);
  return ret;
}

int main(void) {
  cin >> H >> W;
  vector<vector<char>> A(H, vector<char>(W));
  ALL_STEP = 0;
  rep(i, H) rep(j, W) {
    cin >> A[i][j];
    if (A[i][j] == '#') ALL_STEP++;
  }

  if (A[0][0] == '.') {
    cout << "Impossible" << endl;
    return 0;
  }

  if (dfs(A, 0, 0, 1)) {
    cout << "Possible" << endl;
  } else {
    cout << "Impossible" << endl;
  }
  return 0;
}

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

// #define ll long long
// #define pb push_back
// #define iter std::vector<int>::iterator

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

	int d, a, b;

	cin >> d >> a >> b;

	for (int i = a; i <= b; i++) {
		if (i % d == 0) {
			cout << "OK";
			return 0;
		}
	}

	cout << "NG";
	

	return 0;
}

Measured memory_bytes: 3588
#include<cstdio>
char S[100000];

int main()
{
scanf("%s",S);
bool app[26];

for(int i = 0;i < 26;i++){
app[i] = false;
}
for(int i = 0;S[i] != '\0';i++){
app[S[i] - 'a'] = true;
}
for(int i = 0; i < 26; i++){
if(!app[i]){
printf("%c\n",(char)(i + 'a'));
return 0;
}
}

printf("None\n");
return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pi 3.141592653589793238
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MOD 1000000007

void solve()
{
ll n,t;
	cin>>n>>t;
	ll arr[n];
	for(int i=0;i<n;i++)
		cin>>arr[i];
	ll buy=arr[0];
	ll maxProfit=0;
	ll ans=0;
	for(int i=1;i<n;i++)
	{
		if(arr[i]>buy)
		{
			if(arr[i]-buy>maxProfit)
				maxProfit=arr[i]-buy,ans=1;
			else if(arr[i]-buy==maxProfit)
				ans++;
		}
		else
			buy=arr[i];
	}
	cout<<ans;
	return;
}

int main()
{
	fast;
	ll q=1;
	// cin>>q;
	while(q--)
		solve();
	return 0;
}



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

string divide[4] = {"dream", "dreamer", "erase", "eraser"};

int main()
{
    int N, D;
    cin >> N >> D;

    int ans = 1;
    int pos = D + 1;
    while (1)
    {
        int range = pos + D;
        if (range >= N)
        {
            break;
        }
        else
        {
            pos = pos + D + D + 1;
            ++ans;
        }
    }
    cout << ans;
}


Measured memory_bytes: 256
#include<stdio.h>
//using namespace std;
//scanf("%d%d%d%d%d",&W,&H,&x,&y,&r);
//printf("Yes\n");
int main() {
  int a,b;
  
  while(1){
    scanf("%d%d",&a,&b);
     if(a == 0 && b == 0) break;    
     if(a <= b){
      printf("%d %d\n",a,b);
     }else{
      printf("%d %d\n",b,a);  
    }
}
}


Measured memory_bytes: 2668
# list[1]の数にlist[1]回100をかければよいはず
list = [int(i) for i in input().split(" ")]
fillzero = 0
plus = 0
if list[0] == 0:
    fillzero = 1
    plus = 1
elif list[0] == 1:
    fillzero = 100
    plus = 100
elif list[0] == 2:
    fillzero = 10000
    plus = 10000
if list[1] != 100:
    print(list[1] * fillzero)
else:
    print((list[1] * fillzero)+plus)
# max 2 100 -> 1000000 (intで表現可能)


Measured memory_bytes: 3060
import sys
input = sys.stdin.readline
N = int(input().strip())
A = list(map(int, input().split()))

h = {}
for a in A:
  if a not in h:
    h[a] = 0
  h[a] += 1

s = 0
for a, c in h.items():
  if c >= 2:
    s += c * (c-1) // 2

for a in A:
  c = h[a]
  if c == 1:
    print(s)
  else:
    comb = c * (c-1) // 2
    comb_minus = 0
    if c-1 >= 2:
      comb_minus = (c-1) * (c-2) // 2
    print(s - comb + comb_minus)

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

int main(){
  int n,m;
  string tnum[100];
  int tv[100];
  string num;
  
  while(cin>>n>>m){
    int sum=0;
    if(n==0 && m==0)
      break;
    
    for(int i=0;i<n;i++){
      cin>>tnum[i]>>tv[i];
    }

    for(int i=0;i<m;i++){
      cin>>num;
      for(int j=0;j<n;j++){
        bool hit=true;
        for(int k=0;k<8;k++){
          if(tnum[j][k]=='*')
            continue;
          if(num[k]!=tnum[j][k])
            hit=false;
        }
        if(hit==true)
          sum+=tv[j];
      }
    }

    cout<<sum<<endl;
  }
}



Measured memory_bytes: 3152
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(long long int i=a; i<b; i++ )
#define REP(i,n) rep(i,0,n)
 
vector<int> argsort(vector<int> v)
{
	int n = v.size();
	vector<int> indices(n);
	REP(i,n){ indices[i] = i; }
 
	sort(indices.begin(), indices.end(), [&v](size_t i1, size_t i2) {
        return v[i1] > v[i2];
  });
 
	return indices;
}
 
void displayVector(vector<int> v)
{
	int n = v.size();
	REP(i,n){
		cout << v[i] << " " ;
	}
	cout << endl;
}
 
int main(){
  int S, W; cin >> S >> W;
  if(S <= W){ cout << "unsafe" << endl;}
  else{ cout << "safe" << endl; }
  return 0;
}

Measured memory_bytes: 3596
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=2*asin(1);

ll comb[500005];
ll P1[500005];
ll P2[500005];

ll N, M;

void prepare(){
  ll factN[N+1];
  factN[0] = 1;
  for(ll i=1;i<=N;++i){
    factN[i] = factN[i-1] * i;
    factN[i] %= mod;
  }
  ll shita1, shita2, two;
  ll h;
  ll tmpshita1, tmpshita2;
  for(ll k=0;k<=N;++k){
    h = mod - 2;
    shita1 = 1;
    shita2 = 1;
    while(h>0){
      two = 1;
      tmpshita1 = factN[N-k];
      tmpshita2 = factN[k];
      while(2*two<=h){
        two *= 2;
        tmpshita1 *= tmpshita1;
        tmpshita2 *= tmpshita2;
        tmpshita1 %= mod;
        tmpshita2 %= mod;
      }
      h -= two;
      shita1 *= tmpshita1;
      shita2 *= tmpshita2;
      shita1 %= mod;
      shita2 %= mod;
    }
    comb[k] = factN[N]*shita1%mod*shita2%mod;
  }
  P1[1] = M;
  for(ll i=2;i<=N;++i){
    P1[i] = P1[i-1] * (M-i+1);
    P1[i] %= mod;
  }

  P2[N] = 1;
  for(ll i=1;i<N;++i){
    P2[N-i] = P2[N-(i-1)] * (M-N+i);
    P2[N-i] %= mod;
  }
}

int main() {
  cin>>N>>M;
  prepare();
  ll ans = 1;
  for(ll i=0;i<N;++i){
    ans *= (M-i);
    ans %= mod;
    ans *= (M-i);
    ans %= mod;
  }
  for(int i=1;i<=N;++i){
    if(i%2==0){
      ans += comb[i]*P1[i]%mod*P2[i]%mod*P2[i]%mod;
    }
    else{
      ans -= comb[i]*P1[i]%mod*P2[i]%mod*P2[i]%mod;
      ans = (ans+mod)%mod;
    }
  }
  cout<<ans<<endl;
}



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

typedef long long ll;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define INF 999999999

int n,m,hit,d;

void output(int a[31][20]){
    rep(i,d){
        rep(j,n-1){
            cout<<a[i][j]<<" ";
        }
        cout<<endl;
    }
    cout<<"----------------------"<<endl;
}


bool solve(int a[31][20]){
//    output(a);
    vector<int> x;
    rep(i,n){
        if(i==m-1)x.pb(1);
        else x.pb(0);
    }
    rep(i,d){
        rep(j,n-1){
            if(a[i][j]!=0){
                swap(x[j],x[j+1]);
            }
        }
    }
    if(x[hit-1])return true;
    else return false;
}


int main(){
    while(cin>>n){
        if(n==0)break;
        cin>>m>>hit>>d;
        char data[31][20];
        rep(i,d){
            rep(j,n-1){
                cin>>data[i][j];
            }
        }
        int a[31][20];
        rep(i,d)rep(j,n-1)a[i][j]=data[i][j]-'0';
        
        if(solve(a)){cout<<"0"<<endl;goto next;}
        
        rep(i,d){
            rep(j,n-1){
                if(a[i][j]!=0)continue;
                if( n<=2 || (j==0 && a[i][j+1]==0) ){
                    a[i][j]=2;
                    if(solve(a)){cout<<i+1<<" "<<j+1<<endl;goto next;}
                    a[i][j]=0;
                }
                else if( j==n-2 && a[i][j-1]==0 ){
                    a[i][j]=2;
                    if(solve(a)){cout<<i+1<<" "<<j+1<<endl;goto next;}
                    a[i][j]=0;
                }
                else if( j!=0 && j!=n-1 && a[i][j+1]==0 && a[i][j-1]==0 ){
                    a[i][j]=2;
                    if(solve(a)){cout<<i+1<<" "<<j+1<<endl;goto next;}
                    a[i][j]=0;
                }
            }
        }
        cout<<"1"<<endl;
        next:;
    }
}

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

int main() {
    int w, n, a[30], b[30], ans[30];
    char c;
    cin >> w >> n;
    for(int i=0; i<w; i++) ans[i] = i + 1;
    for(int i=0; i<n; i++) {
        cin >> a[i] >> c >> b[i];
        swap(ans[a[i]-1], ans[b[i]-1]);
    }
    for(int i=0; i<w; i++) cout << ans[i] << endl;
}


Measured memory_bytes: 3088
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<queue>
#include<stack>
#include<map>
#include<math.h>
#include<string>
#include <cctype>
#include <cstdlib>
#include<bitset>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = s; i < (int)(n); i++)
#define out(x) cout << x << endl;
#define INF 1ll<<60;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

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

int main(){
    int w, a, b; cin >> w >> a >> b;
    int c;
    if(a<=b){
        a += w;
        c = b-a;
        if(c<=0){
            out(0);
            return 0;
        }
        out(c);
    }
    else if(a>b){
        b += w;
        c = a-b;
        if(c<=0){
            out(0);
            return 0;
        }
        out(c);
    }
}

Measured memory_bytes: 3568
#include<stdio.h>
#include<math.h>
int main() {

	long long int max;
	long long int a, b, c, d;

	scanf("%lld%lld%lld%lld", &a, &b, &c, &d);
	
	max = a * c;
	if (max < a * d)
		max = a * d;
	if (max < b * c)
		max = b * c;
	if (max < b * d)
		max = b * d;

	printf("%lld", max);

	return 0;
}

Measured memory_bytes: 2140
#include<bits/stdc++.h>
using namespace std;
/// Macros ---------------------
#define ll long long
#define sz(a) (int)a.size()
#define int long long
#define pb push_back
#define vi vector<int>
#define f first
#define s second
#define ii pair<int,int>
#define lb lower_bound
#define up upper_bound
#define rep(i,x,y) for(int i=(x);i<=(y);i++)
#define ld long double
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
/// Constracts -----------------------------------------------
const int maxn=1e5;
const int INF=(1ll)<<(30ll);
const int inf=1000000000000000000;
const int eps=1e-9;
const int mod=1e9+7;
/// Quick Pow ------------------------------------------------
int qpow(int b,int e)
{
    if( !e ) return 1;
    if( e & 1 ) return qpow(b, e - 1) * b;
    int pwur = qpow(b, e >> 1);
    return pwur * pwur;
}

int lcm(int a,int b){
    return a*b/__gcd(a,b);
}

/// My Code ---------------------------------------------------

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

    int n,l;
    cin>>n>>l;
    string s[n];
    for(int i=0;i<n;i++)
        cin>>s[i];
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            if(s[i]>s[j])swap(s[i],s[j]);
        }
    }
    for(int i=0;i<n;i++){
        cout<<s[i];
    }

    return 0;
}


Measured memory_bytes: 3696
#include<bits/stdc++.h>
#define endl '\n'
#define eps 1e-6
#define oo 1e7+5

using namespace std;

typedef long long int ll;
typedef unsigned long long ull;
typedef vector<pair<int,pair<int,int>>> dirgraph;
typedef vector<vector<int>> graph;

const ll mod = 1e9 + 7;

ll mult(int a,int b)
{
	ll r=(ll)a*b % mod;
	return r;
}


ll fastPow(int a,int b)
{
	ll r=1;

	while(b)
	{
		if(b&1)
		{
			r=mult(r,a);
		}
		a=mult(a,a);
		b/=2;
	}
	return r;
}

ll modInv(int a)
{
	ll r=fastPow(a,mod-2);
	return r;
}

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

    map<int,int> ans;
	int n;
	cin>>n;
	vector<int> an;
	while(n--)
	{
		int a;
		cin>>a;
		an.push_back(a);

		//Descomponer en factores
		map<int,int> mp;
		for(int i=2;i*i<=a;i++)
		{
			while(a%i==0)
			{
				a/=i;
				mp[i]++;
			}
		}
		if(a!=1)mp[a]++;
		//Construir valor de Ai*Bi (valor constante)
		map<int,int>::iterator it=mp.begin();
		for(;it!=mp.end();it++)
		{
			ans[it->first]=max(ans[it->first],it->second);
		}

	}

	ll mcm=1;
	map<int,int>::iterator it=ans.begin();
	for(;it!=ans.end();it++)
	{
		int prime=it->first;
		int k=it->second;
		mcm=mult(mcm,fastPow(prime,k));
	}

	//mcm/a0 +mcm/a1 +...+mcm/an 

	ll r=0;
	for(int i=0;i<an.size();i++)
	{
		r=(r+mult(mcm,modInv(an[i])))% mod;
	}
	cout<<r<<endl;

	
	return 0;
}

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

int main(){
    int w,h,n;
    cin >> w >> h >> n;
    int s[w][h]={};
    for(int i=0;i<n;i++){
        int x,y,a;
        cin >> x >> y >> a;
        if(a==1){
            for(int i=0;i<x;i++){
                for(int j=0;j<h;j++){
                    s[i][j]=1;
                }
            }
        }else if(a==2){
            for(int i=x;i<w;i++){
                for(int j=0;j<h;j++){
                    s[i][j]=1;
                }
            }
        }else if(a==3){
            for(int i=0;i<w;i++){
                for(int j=0;j<y;j++){
                    s[i][j]=1;
                }
            }
        }else{
            for(int i=0;i<w;i++){
                for(int j=y;j<h;j++){
                    s[i][j]=1;
                }
            }
        }
    }
    int ans=0;
    for(int i=0;i<w;i++){
        for(int j=0;j<h;j++){
            if(s[i][j]==0) ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
S = list(input())
N = len(S)

# 先頭を1にする
ans1 = 0
for i in range(N):
    if i%2==0 and S[i] == '0':
        ans1 += 1
    elif i%2==1 and S[i] == '1':
        ans1 += 1

# 先頭を0にする
ans2 = 0
for i in range(N):
    if i%2==0 and S[i] == '1':
        ans2 += 1
    elif i%2==1 and S[i] == '0':
        ans2 += 1

print(min(ans1, ans2))


Measured memory_bytes: 9720
w_list = list(str(input()))
w_list.sort()
l = len(w_list)

if l == 1:
    print("No")
    exit()

for i,j in zip(range(0, l, 2) ,range(1, l, 2)):
    if w_list[i] != w_list[j]:
        print("No")
        break
else:
    print("Yes")


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define PI acos(-1.0)
#define mem(a,b) memset((a),b,sizeof(a))
#define TS printf("!!!\n")
#define pb push_back
#define inf 1e9
//std::ios::sync_with_stdio(false);
using namespace std;
//priority_queue<int,vector<int>,greater<int>> que; get min
const double eps = 1.0e-10;
const double EPS = 1.0e-4;
typedef pair<int, int> pairint;
typedef long long ll;
typedef unsigned long long ull;
const int turn[4][2] = {{1, 0}, { -1, 0}, {0, 1}, {0, -1}};
//priority_queue<int, vector<int>, less<int>> que;
//next_permutation
inline void read(int &jqk)
{
        jqk = 0;
        char c = 0;
        int p = 1;
        while (c < '0' || c > '9')
        {
                if (c == '-')
                {
                        p = -1;
                }
                c = getchar();
        }
        while (c >= '0' && c <= '9')
        {
                jqk = (jqk << 3) + (jqk << 1) + c - '0';
                c = getchar();
        }
        jqk *= p;
}
ll mod = 1e9 + 7;
int main()
{
        string a;
        while (cin >> a)
        {
                int sum1 = 0;
                int len = a.size();
                for (int i = 0; i < len; i++)
                {
                        sum1 += a[i] - '0';
                }
                //cout<<sum1<<endl;
                cout << max(sum1, a[0] - '0' - 1 + (len - 1) * 9) << endl;
        }

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i, n) for(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;

ll dp[200200];
int main(){
    fast_io

    int n;
    cin>>n;
    vector<int> a(n);
    int N=0;
    ll sum=0;
    rep(i,n) {
        cin>>a[i];
        a[i]--;
        dp[a[i]]++;
        N=max(N, a[i]);
    }

    for(int i=0;i<=N;i++){
        if(dp[i]==0) continue;
        //cout<<sum<<endl;
        sum+=dp[i]*(dp[i]-1)/2;
    }
    //cout<<sum<<endl;
    for(int i=0;i<n;i++){
        cout<<sum-(dp[a[i]]-1)<<endl;
    }



    return 0;

}


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

//C++14 (GCC 5.4.1)

#define LLINF (1LL<<60)
typedef long long ll;
#define mod 1000000007

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define rrepd(i,a,b) for(int i=(a);i>=(b);i--)

template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); }

#define dbg_v1(i,V) do{cout<<"-v1----\n";rep(i,V.size())cout<<" "<<i<<"\t:"<<V[i]<<endl;cout<<endl;}while(0)
#define dbg_v2(i,k,V) do{cout<<"-v2----\n";rep(i,V.size()){rep(k,V[0].size())cout<<" "<<V[i][k];cout<<endl;}}while(0)

int main() {
    ios::sync_with_stdio(false);//stdoutとcoutの同期解除
    cin.tie(nullptr);//cinとcoutの同期解除
    
    int A,B;
    cin >>A>>B;

    cout << ((1<=A && A<=9 && 1<=B &&B<=9) ? A*B : -1) <<endl;
    return (0);
}

Measured memory_bytes: 256