akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC086A
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b;

            var word = Console.ReadLine().Split(' ');

            a = int.Parse(word[0]);
            b = int.Parse(word[1]);

            if (a * b % 2 == 0)
                Console.WriteLine("Even");

            else
                Console.WriteLine("Odd");

            Console.ReadKey();

        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//余りを切り上げる =>  (a + b - 1) / b 

signed main(){
	int n,t,a; cin>>n>>t>>a;
	int ans;
	double now=MOD;
	rep(i,0,n){
		double h; cin>>h;
		double g=t-(h*0.006);
		if(now>abs(g-a)){
			now=abs(g-a);
			ans=i+1;
		}
	}
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
 
typedef pair<int,int> P;
struct edge{int to, id;};
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define mod 1000000007
#define INFTY 1 << 29


int main(){
    int n,m;
    cin >> n >> m;
    int c[m];
    rep(i,m){
        int temp;
        cin >> temp;
        c[i] = temp;
    }
    int dp[n+1];
    for(int i = 0; i <= n; i++){
        dp[i] = INFTY;
    }
  dp[0] = 0;
    for(int i = 0; i < m; i++){
        for(int j = 0; j <= n ; j++){
            if(c[i] <= j){
                dp[j] = min(dp[j-c[i]] + 1,dp[j]);
            }
            else{
                dp[j] = dp[j];
            }
        }
    }
    cout << dp[n] << endl;

}


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

using ll = long long;
using namespace std;

const int MAX = 1e7;
const int mod = 4;

ll fac[MAX];

void init() {
    fac[0] = 1;
    for (int i = 1; i < MAX; i++) {
        fac[i] = fac[i - 1] * i % mod;
    }
}

ll com_by_4(int n, int k) {
    int fact = 2;
    int c1 = 0;
    while (n / fact) {
        c1 += n/fact;
        fact *= 2;
    }
    fact = 2;
    int c2 = 0;
    while (k / fact) {
        c2 += k/fact;
        fact *= 2;
    }
    fact = 2;
    int c3 = 0;
    while ((n - k) / fact) {
        c3 += (n - k)/fact;
        fact *= 2;
    }
    return (c1 - c2 - c3 <= 0);
}

int main() {
    int n;
    cin >> n;
    init();
    string s;
    cin >> s;
    bool no2 = true;
    for (auto c: s) {
        if (c == '2') {
            no2 = false;
            break;
        }
    }

    if (no2) {
        vector<int> diff(n - 1);
        for (int i = 1; i < n; i++) {
            diff[i - 1] = abs(s[i] - s[i - 1]);
        }
        ll sum = 0;
        for (int i = 0; i < n - 1; i++) {
            sum += int(diff[i] - '0') * com_by_4(n - 2, i);
            sum %= mod;
        }
        if (sum == 0) {
            cout << 0 << endl;
        } else {
            cout << 2 << endl;
        }
    } else {
        ll sum = 0;
        for (int i = 0; i < n; i++) {
            sum += int(s[i] - '0') * com_by_4(n - 1, i);
            sum %= mod;
        }
        if (sum % 2 == 0) {
            cout << 0 << endl;
        } else {
            cout << 1 << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 83460
#include <bits/stdc++.h>
using namespace std;
#define INF 100100100100100
#define NMAX 100000
typedef long long llong;

llong d[NMAX];
vector<pair<llong, int>> g[NMAX];

void dijkstra(int s) {
    priority_queue<pair<llong, int>, vector<pair<llong, int>>, greater<pair<llong, int>>> que;
    fill(d, d + NMAX, INF);
    d[s] = 0;
    que.push({0, s});
    while (!que.empty()) {
        auto p = que.top(); que.pop();
        int v = p.second;
        if (d[v] < p.first)
            continue;
        for (int i = 0; i < g[v].size(); i++) {
            auto e = g[v][i];
            if (d[e.second] > d[v] + e.first) {
                d[e.second] = d[v] + e.first;
                que.push({d[e.second], e.second});
            }
        }
    }
}

int main(void) {
    int n;
    cin >> n;
    for (int i = 0; i < n - 1; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        a--, b--;
        g[a].push_back({c, b});
        g[b].push_back({c, a});
    }
    int q, k;
    cin >> q >> k;
    k--;
    dijkstra(k);
    for (int i = 0; i < q; i++) {
        int x, y;
        cin >> x >> y;
        x--, y--;
        cout << d[x] + d[y] << endl;
    }
}


Measured memory_bytes: 11120
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define INF 1000000000000000000
#define mod 1000000007

int main(){
	ll n,k;cin>>n>>k;
	vector<ll> a(n),smaller(n,0);
	for(ll i=0;i<n;i++){
		cin>>a[i];
	}

	ll ans=0;
	for(ll i=0;i<n-1;i++){
		for(ll j=i+1;j<n;j++){
			if(a[i]>a[j]){ans++;}
		}
	}

	ans=(ans*k)%mod;//一つの塊で転倒数はans個

	for(ll i=0;i<n;i++){
		for(ll j=0;j<n;j++){
			if(a[i]>a[j]){smaller[i]++;}//a[i]より小さい数の個数
		}
		ans+=(smaller[i]*((k*(k-1)/2)%mod))%mod;
		ans%=mod;
	}

	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 256
a = [1, 2, 3, 4, 5, 6, 7, 8, 9]
b = [1, 2, 3, 4, 5, 6, 7, 8, 9]

for x in a:
    for y in a:
        ans = x * y
        print(str(x)+'x'+str(y)+'='+str(ans))



Measured memory_bytes: 5536
A,B=map(int, input().split())
def fanc(n):
    if n<0:
        return 0
    if n%4==0:
        return n
    elif n%4==1:
        return 1
    elif n%4==2:
        return n+1
    else:
        return 0

print(fanc(A-1)^fanc(B))

Measured memory_bytes: 3060
using LIB;
using System;
using System.Linq;
using System.Text;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args)
    {
        int[] n = io.r<int>(' ');
        if ((n[0] < n[1]) && (n[1] < n[2])) { io.w("Yes"); }
        else { io.w("No"); }
        io.wflush();
    }
}

namespace LIB
{
    public class io
    {
        private const int WMAX = 1000;
        private static StringBuilder S = new StringBuilder();
        public static T r<T>() { return util.parse<T>(r()); }
        public static T[] r<T>(char s = ' ') { return r().Split(s).Select(util.parse<T>).ToArray(); }
        public static T[] r<T>(int l) { T[] r = new T[l]; for (int i = 0; i < l; i++) { r[i] = r<T>(); } return r; }
        public static T[][] r<T>(int l, char s = ' ') { T[][] r = new T[l][]; for (int i = 0; i < l; i++) { r[i] = r<T>(s); } return r; }
        private static string r() { return Console.ReadLine(); }
        public static void w(object v, bool lf = true) { S.Append(util.parse<string>(v)); if (lf == true) { S.Append('\n'); } if (S.Length >= WMAX) { wflush(); } }
        public static void wflush() { Console.Write(S.ToString()); S.Length = 0; }
    }
    public class util
    {
        public static T parse<T>(object value) { return (T)(Convert.ChangeType(value, typeof(T))); }
    }
    public class memo<Key, Result>
    {
        private Dictionary<Key, Result> R;
        public memo() { R = new Dictionary<Key, Result>(); }
        public Result exec(Key k, Func<Key, Result> f) { Result r; if (R.ContainsKey(k)) { r = R[k]; } else { r = f(k); R.Add(k, r); } return r; }
    }
}

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

#define hell                         1000000007
#define lcm(a,b)                     (a*b)/__gcd(a,b)
#define ll                           long long
#define vll                          vector<ll>
#define vi                           vector<int>
#define pll                          vector< pair<ll,ll> >
#define pb                           push_back
#define mp                           make_pair
#define all(v)                       v.begin(),v.end()
#define lbnd                         lower_bound
#define ubnd                         upper_bound
#define bs                           binary_search
#define F                            first
#define S                            second
#define rep(i,a,b)                   for(i=a;i<b;i++)
#define parr(a,n)                    for(ll it=0;it<n;it++) cout<<a[it]<<" ";cout<<endl;
#define pcont(a)                     for(auto it:a) cout<<it<<" ";cout<<endl;
#define ret(x)                       return cout<<x,0;
#define endl                           '\n'

/*constants*/
#define MAXN                         100005
#define PI                           3.14159265358979323846

/*debug*/
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>void __f(const char* name, Arg1&& arg1){ std::cout << name << " : " << arg1 << '\n';}
    template <typename Arg1, typename... Args>void __f(const char* names, Arg1&& arg1, Args&&... args){const char* comma = strchr(names + 1, ','); std::cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);}
#else
#define trace(...)
#endif

using namespace std;
pll adj[MAXN];
bool vis[MAXN];
ll c[MAXN];
void dfs(ll u,ll col){
    vis[u]=true;
    for(auto it:adj[u]){
        if(!vis[it.F]){
            if(it.S%2==1) c[it.F]=(!c[u]);
            else c[it.F]=c[u];
            dfs(it.F,c[it.F]);
        }
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    
    ll i,j,n,m,k,cnt=0,ans=0,t=1;
    cin>>n;
    pll e;
    rep(i,0,n-1){
        cin>>j>>k>>t;
        adj[j].pb(mp(k,t));
        adj[k].pb(mp(j,t));
        if(t%2==1) e.pb(mp(j,k));
    }    
    if(e.empty()){
        rep(i,0,n) cout<<0<<endl;
        return 0;
    }
    i=e[0].F;
    c[i]=0;
    dfs(i,c[i]);
    rep(i,1,n+1){
        cout<<c[i]<<endl;
    }
    return 0;
}

Measured memory_bytes: 11636
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int k, s, z, ans = 0;
    cin >> k >> s;
    for (int x = 0; x <= k; x++)
    {
        for (int y = 0; y <= k; y++)
        {
            z = s - x - y;
            if (0 <= z and z <= k)
            {
                ans++;
            }
        }
    }
    cout << ans << endl;
}

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

int main()
{
    int q, qh, qs, qd, h, hs, hd, s, sd, d, n;
    cin >> q >> h >> s >> d >> n;

    qh = q * 2;
    qs = q * 4;
    qd = q * 8;
    hs = h * 2;
    hd = h * 4;
    sd = s * 2;

    h = min(q, qh);
    s = min(s, min(qs, hs));
    d = min(min(d, sd), min(hd, qd));

    if (n % 2 == 0)
    {
        cout << (long long)(n / 2) * d << '\n';
    }
    else
    {
        cout << (long long)((n - 1) / 2) * d + s << '\n';
    }
}

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

const ll mod = 1e9 + 7;


int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int x;
	cin >> x;
	cout << !(x&1) << "\n";
	return 0;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vb = vector<bool>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define LINF 1E17
#define EPS 1E-9
#define MOD 1000000007
#define PI 3.1415926535897932384

template<class S, class T>ostream& operator<<(ostream&os, pair<S, T>p) { os << "[" << p.first << ", " << p.second << "]"; return os; };
template<class S>auto&operator<<(ostream&os, vector<S>t) { bool a = 1; for (auto s : t) { os << (a ? "" : " ") << s; a = 0; } return os; }

//int dx[]={1,1,1,0,-1,-1,-1,0},dy[8]={1,0,-1,-1,-1,0,1,1,1};
//
constexpr ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }


int main() {
	int n;
	cin >> n;
	ll x,in;
	cin >> x;
	vl vin,v;
	vin.push_back(x);
	rep(i, n) {
		cin >> in;
		vin.push_back(in);
	}
	sort(all(vin));
	rep(i, n) {
		v.push_back(vin[i+1]-vin[i]);
	}
	ll ans = v[0];
	rep(i, n) {
		ans = gcd(v[i], ans);
	}
	cout << ans<<endl;
}


Measured memory_bytes: 2548
r,g,b,n=gets.split.map(&:to_i)
count=0
for i in 0..n
    for j in 0..n
        if (n-r*i-g*j).div(b)<=n && (n-r*i-g*j)%b==0 && (n-r*i-g*j).div(b)>=0
            count+=1
            
        end
    end
end

p count

Measured memory_bytes: 14256
#include "bits/stdc++.h"
using namespace std;
typedef long long int lli;
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define ff first
#define ss second
#define pi pair<lli,lli>
#define pii pair<pi,lli>
#define endl "\n"
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int N = 1e6 + 5;

int main() {
	IOS
	int T = 1;
	// cin >> T;
	while(T--) 
	{
		lli n;
		cin >> n;
		vector<int> ans;
		while(n != 0)
		{
			int temp = 0;
			temp = n%26;
			ans.pb(temp);
			if(temp == 0) n--;
			n = n/26;
			
		}
		while(ans.size())
		{
			if(ans.back() == 0) ans[ans.size() - 1] = 26;
			cout << (char)(ans.back() + 96);
			ans.pop_back();
		}

	}	
	return 0;
}

Measured memory_bytes: 3600
import std.stdio, std.string, std.conv, std.range;
import std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, std.random, core.bitop;

void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}



enum inf = 1_001_001_001;
enum infl = 1_001_001_001_001_001_001L;


void main() {
    int N;
    scan(N);
    auto s = readln.chomp;
    int x;
    int ans;
    foreach (ch ; s) {
        if (ch == 'I') {
            x++;
            chmax(ans, x);
        }
        else {
            x--;
            chmax(ans, x);
        }
    }
    writeln(ans);
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>

using namespace std;

#define _USE_MATH_DEFINES

const int NMax = 150;
const double eps = 1e-8;
const double eps1 = 1e-6;
const double gravity = 9.8;
const double PI = 3.14159265;

int N, V, X, Y;
int L[NMax], B[NMax], R[NMax], T[NMax];

int main()
{
	cin >>N >>V >>X >>Y;

	for (int i = 1; i <= N; ++i)
		cin >>L[i] >>B[i] >>R[i] >>T[i];

	for (double alpha = -eps1; alpha <= PI/2; alpha += eps1)
	{
		double V_0x = V * cos(alpha);
		double V_0y = V * sin(alpha);
		double Time = X / V_0x;
		double LandY = V_0y * Time - 0.5*gravity*(Time*Time);

		if (Y - LandY <= eps)
		{
            bool intersect = 0;

            for (int i = 1; i <= N; ++i)
                if (X - L[i] >= eps && X - R[i] <= eps &&
					LandY - B[i] >= eps && LandY - T[i] <= eps)
					intersect = 1;

            for (int i = 1; i <= N; ++i)
				for (int j = L[i]; j <= R[i]; ++j)
				{
					double TimeToJ = j / V_0x;
					if (Time - TimeToJ >= eps)
					{
                        double newY = V_0y * TimeToJ - 0.5*gravity*(TimeToJ*TimeToJ);
                        if (newY - B[i] - eps >= 0 &&
							newY - T[i] - eps <= 0)
								intersect = 1;
					}

				}

			if (!intersect)
			{
                cout <<"Yes" <<'\n';
                return 0;
			}
		}
	}

	cout <<"No" <<'\n';
    return 0;
}



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

int main() {
  int K;
  cin >> K;
  string S;
  cin >> S;
  if(S.size() <= K){
    cout << S << endl;
  }
  else{
    for(int i = 0; i < K; i++){
      cout << S.at(i);
    }
    cout << "..." << endl;
  }
}

Measured memory_bytes: 3628
#!/usr/bin/env node
// https://onlinejudge.u-aizu.ac.jp/courses/lesson/1/ALDS1/2/ALDS1_2_B

"use strict";
(function (stdin) {
  const [n, a] = stdin.toString().trim().split("\n");
  const N = Number(n);
  const A = a.split(" ").map(Number);
  let minj;
  let count = 0;
  for (let i = 0; i < N; i++) {
    minj = i;
    for (let j = i; j < N; j++) {
      if (A[j] < A[minj]) {
        minj = j;
      }
    }
    if (A[minj] !== A[i]) {
      let prev = A[minj];
      A[minj] = A[i];
      A[i] = prev;
      count++;
    }
  }
  console.log(A.join(" "));
  console.log(count);
})(require("fs").readFileSync("/dev/stdin", "UTF-8"));



Measured memory_bytes: 15436
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;
import java.util.HashMap;
import java.util.ArrayList;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author silviase
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        DBannedK solver = new DBannedK();
        solver.solve(1, in, out);
        out.close();
    }

    static class DBannedK {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            HashMap<Integer, Integer> hm = new HashMap<>();
            int n = in.nextInt();
            int[] a = new int[n];

            for (int i = 0; i < n; i++) {
                a[i] = in.nextInt();
                hm.merge(a[i], 1, Integer::sum);
            }

            ArrayList<Integer> al = new ArrayList<>(hm.values());
            long sum = 0;
            for (int i = 0; i < al.size(); i++) {
                sum += (long)al.get(i) * (long)(al.get(i) - 1) / 2;
            }

            for (int i = 0; i < n; i++) {
                out.println(sum - hm.get(a[i]) + 1);
            }

        }

    }
}



Measured memory_bytes: 99464
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define show(x) cout << #x << " = " << (x) << endl;
using namespace std;
using ll = long long;
using pii = pair<int,int>;
int dp[123456];
int main(){
    int n;
    cin >> n;
    vector<int>h(n);
    rep(i,n)cin >> h[i];
    rep(i,n)dp[i] = INT_MAX;
    dp[0] = 0;
    dp[1] = abs(h[1]-h[0]);
    for(int i = 2; i < n; i++){
        dp[i] = min(dp[i-1] + abs(h[i]-h[i-1]), dp[i-2] + abs(h[i]-h[i-2]));
    }
    cout << dp[n-1] << endl;
}

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

using namespace std;

typedef long long lli;

const lli N = 100LL;

lli n, p[N+1], q[N+1], r[N+1], b[N+1];
bool vis[N+1];

lli lcm(lli x, lli y){
  return x * y / __gcd(x, y);
}

lli solve(lli pos){
  lli t1 = 1, t2 = 1;
  if(r[pos]) t1 = solve(r[pos]);
  if(b[pos]) t2 = solve(b[pos]);
  lli tmp = lcm(t1 * p[pos], t2 * q[pos]);
  return tmp / p[pos] + tmp / q[pos];
  /*lli tmp1 = p[pos];
  lli tmp2 = q[pos];
  if(r[pos] && b[pos]){
    tmp1 = lcm(t1, (lli)p[pos]);
    tmp2 = lcm(t2, (lli)q[pos]);
    tmp1 = lcm(tmp1, tmp2);
    tmp2 = tmp1;
  }else if(r[pos]){
    tmp1 = lcm(t1, (lli)p[pos]);
    tmp2 = (lli)q[pos] * (tmp1 / t1);
  }else if(b[pos]){
    tmp2 = lcm(t2, (lli)q[pos]);
    tmp1 = (lli)p[pos] * (tmp2 / t2);
  }
  //cout << pos << ' ' << tmp1 << ' ' << tmp2 << endl;
  return tmp1 + tmp2;*/
}

main(){
  while(cin >> n && n){
    fill(vis, vis+N+1, false);
    for(lli i=1;i<=n;i++){
      cin >> p[i] >> q[i] >> r[i] >> b[i];
      lli tmp = __gcd(p[i], q[i]);
      p[i] /= tmp;
      q[i] /= tmp;
      vis[r[i]] = vis[b[i]] = true;
    }
    for(lli i=1;i<=n;i++) if(!vis[i]) cout << solve(i) << endl;
  }
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
typedef long long ll;
typedef long long unsigned int llu;
ll MOD = 1000000007;
ll INF = 1000000009;

/*
こういう問題は実装より証明の方が大事なので、証明を追います

N頂点連結グラフには少なくともN-1本の辺が存在する(最低でも木なので).
これらの辺は距離1で頂点を結ぶため、最短距離が1である頂点対がN-1存在する.
頂点対は多くともNC2=N(N-1)/2で、そのうち最低でもN-1が最短距離1の頂点対であるから、
N(N-1)/2-(N-1) = (N-1)(N-2)/2 < K であるような場合、グラフは構成できない.

逆に (N-1)(N-2)/2 >= K であるような場合、そのようなグラフを常に構成できる.
１つの頂点とそれ以外の頂点のみを結ぶグラフを考えると、このグラフの頂点対で距離が2のものは (N-1)(N-2)/2.
(N-1)(N-2)/2 のうちから、頂点対同士を結んでいくことでデクリメントができる.
この操作を K - (N-1)(N-2)/2 回繰り返せばいい.
*/

void solve(){
    int n,k;
    cin >> n >> k;
    int thr = (n-1)*(n-2)/2;
    if(thr < k) cout << -1 << endl;
    else{
        cout << n-1+thr-k << endl;
        rep(i,n-1){
            cout << 1 << " " << i+2 << endl;
        }
        /*
        2 3  2 4  2 5  ...  2 n  3 4  3 5 ... ... n-1 n
        */
        vector<pair<int,int>> vp;
        for(int p=2; p<n; p++){
            for(int q=p+1; q<=n; q++){
                vp.emplace_back(make_pair(p,q));
            }
        }
        int pointer = 0;
        rep(i,thr-k){
            cout << vp[i].first << " " << vp[i].second << endl;
            pointer++;
        }
    }
}

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

Measured memory_bytes: 384
#ifdef BUILT_LOCAL

#include "niklib.h"

#endif

#include <iostream>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <string>
#include <cstdio>
#include <map>
#include <cmath>
#include <set>
#include <list>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef __int128 lll;
constexpr ll mod = 1000000007;

#define bs(n) (1ull<<(ull)(n))
#define rep(i, n) for(ll (i) = 0;(i) < (n);(i)++)

ll h, n, a[1000], b[1000], s[20000], t[20000];

ll rec(ll d) {
    if (d <= 0) return 0;
    if (t[d] == 0) {
        t[d] = 1;
        s[d] = INT64_MAX / 2;
        rep(i, n) s[d] = min(s[d], rec(d - a[i]) + b[i]);
    }
    return s[d];
}

int main() {
    cin >> h >> n;
    rep(i, n)cin >> a[i] >> b[i];
    cout << rec(h) << endl;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(long long i = 0; i < n; i++)
#define Rep(i, m, n) for(long long i = m; i < n; i++)
#define REP(i, m, n, p) for(long long i = m; i < n; i += p)
#define all(v) v.begin(), v.end()
#define pq priority_queue
#define bcnt(n) __builtin_popcountll(n)
using ll = long long;


int main() {
	// ll k;cin>>k;

	// rep(i,k){

	// 	ll g=(i+1)%9;
	// 	ll f=(i+1)/9;
	// 	if(g) cout<<g;
	// 	rep(i,f) cout<<9;
	// 	cout<<endl;
	// }

	ll p;
	cin >> p;

	ll d=1;//答えの最小間隔
	ll ans=1;
	Rep(j, 0, p) {
		ll n=ans;
		ll k=0;
		while(n){
			k+=n%10;
			n/=10;
		}
		ll l=0;
		n=ans+d;
		while(n){
			l+=n%10;
			n/=10;
		}
		if(ans*l<=(ans+d)*k) cout<<ans<<endl;
		else{
			j--;
			ans-=d;
			d*=10;
		}
		ans+=d;
	}
}

Measured memory_bytes: 256
/*********************************************JMD**********************************************/
//                                  |\  |     | |   |   /\                                   //
    //                              | \ |     | |---|  /--\                              //
        //                          |  \| |___| |   | /    \1999                     //
/*******************************************************************************************/
#include <bits/stdc++.h>
using namespace std;

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

#define mp make_pair
#define pb push_back
#define pf push_front
#define ss second
#define ff first
#define mem(x,val) memset(x,val,sizeof(x))
#define forr(i,a,b) for(ll i=a;i<b;i++)
#define f(i,n) forr(i,0,n)
#define sz(x) ll((x).size())
#define all(x) ((x).begin(),(x).end())
#define asc(x) ((int)(x))
#define precision(x) cout<<fixed<<setprecision((x));

const ll mod=1e9 + 7;
/*******************************************************************************************/

//container ostream...
inline void display(vector<ll> v)
{
    for(auto x:v) clog<<x<<"\n";
}

inline void display(vector<vector<ll> > v)
{
    for(auto x:v) for(auto xx:x) clog<<xx<<"\n";
}

//function to calculate a^b under mod...
ll powmod(ll a,ll b, ll modulo)
{
    if(b==0 || a==1) return 1;
    ll half=powmod(a,(b/2),modulo) % modulo;
    ll full = (half*half)%modulo;

    if(b%2) return (full*a)%modulo;
    return full%modulo;
}

//function to calculate inverse modulo under mod...assuming gcd is 1
ll invmod(ll a,ll modulo)
{
    ll check=powmod(a,modulo-2,modulo) %modulo;
    return check;
}

vector<ll> primes;
bool prime[10000001];

void sieve(int n=10000000)
{
    memset(prime, true, sizeof(prime));

    for (int p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
    for (int p=2; p<=n; p++)  if (prime[p]) primes.emplace_back(p);
}

/*******************************************************************************************/

void solve()
{
    ll a,b;
    cin>>a>>b;
    ll ans=1;
    for(auto x:primes)
    {
        if(x>min(a,b)) break;
        else if((a%x ==0) && (b%x)==0)
        {
            while(a%x==0) a/=x;
            while(b%x==0) b/=x;

            ans++;
        }
        else if(a%x==0)
        {
            while(a%x==0) a/=x;
        }
        else if(b%x==0)
        {
            while(b%x==0) b/=x;
        }
    }

    if(a!=1 && a==b) ans++;

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

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

    sieve();

    ll t=1;
    //cin>>t;
    clock_t launch=clock();

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

    clog<<((long double)(clock()-launch)/CLOCKS_PER_SEC)<<"\n";
}


Measured memory_bytes: 20332
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<functional>
#include<fstream>
#include<utility>
#include<bitset>
#include<map>
#include<deque>
#include<cmath>
#include<random>
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define rep(N) for (int i = 0; i < N; ++i)
#define Rep(a, b) for (int i = a; i < b; ++i)
#define For(i, N) for (int i = 0; i < N; ++i)
#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend()
#define makei(N) int N; cin >> N;
#define makel(N) ll N; cin >> N;
#define makes(s) string s; cin >> s;
#define maked(d) double d; cin >> d;
#define makev(v, N) vi v(N); rep(N)cin >> v[i];
#define mod 1000000007
#define re return 0

using namespace std;
using ll = long long int;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pii = pair<int, int>;
using pis = pair<int, string>;
using msi = map<string, int>;

template<typename T>
void say(T s) {
	cout << s << "\n";
}

template<typename T>
void say(vector<T> s) {
	auto itr = s.begin();
	cout << *(itr++);
	while (itr != s.end()) {
		cout << " " << *(itr++);
	}
	cout << "\n";
}

int main() {
  int ans=0;
  makes(s);
  for(char x:s){
    if(x=='1')++ans;
  }
  say(ans);
}

Measured memory_bytes: 256
package main

import "fmt"

var (
	n int
)

func main() {
	fmt.Scanln(&n)

	alist := make([]int64, n)
	for i := 0; i < n; i++ {
		var a int64
		fmt.Scan(&a)

		if a == 0 {
			fmt.Println(0)
			return
		}

		alist[i] = a
	}

	var result int64 = 1
	for _, v := range alist {
		if v > 1000000000000000000/result {
			fmt.Println(-1)
			return
		}

		result *= v
	}

	fmt.Println(result)
}


Measured memory_bytes: 6332
//17:14
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <map>

using namespace std;
typedef long long ll;
ll max(ll a, ll b){return(a>b)?a:b;}
ll min(ll a, ll b){return(a<b)?a:b;}
ll abs(ll a){return(a<0)?-a:a;}

ll gcd(ll a, ll b){
        if(b > a){
                ll tmp = b;
                b = a;
                a = tmp;
        }
        if(b == 0) return a;
        else return gcd(b, a%b);
}
ll lcm(ll a, ll b){
        ll gcdi = gcd(a,b);
        return a/gcdi*(b);
}

int main(){
        ll N,K;
        scanf("%lld %lld",&N,&K);

        map<ll,ll> dict;
        ll a,b;
        for(int i = 0; i < N; i++){
                scanf("%lld %lld",&a,&b);
                dict[a] += b;
        }

        map<ll,ll>::iterator it = dict.begin();

        while(it != dict.end()){
                K -= it->second;
                if(K <= 0) break;
                ++it;
        }
        printf("%lld\n",it->first);
}


Measured memory_bytes: 4224
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF 1e18L
#define INF 1e9L
#define EPS 1e-9
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define pb push_back
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
typedef long long ll;
typedef pair<int, int> pii;

int main(void)
{
    int a,b,c;
    cin >> a >> b >> c;
    Yes(a+b >= c);
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdint>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>

using Ps = std::vector<std::pair<std::int64_t, std::int64_t>>;

void solve(std::int64_t n, const std::vector<std::int64_t>& values, std::int64_t q, const Ps& ps)
{
  std::vector<std::int64_t> counts(100001, 0);
  std::int64_t sum = 0;
  for (auto v : values) {
    ++counts.at(v);
    sum += v;
  }

  for (auto& p : ps) {
    const auto src = p.first;
    const auto dst = p.second;
    const auto d = dst - src;
    const auto src_count = counts.at(src);
    sum += d * src_count;
    counts.at(dst) += src_count;
    counts.at(src) = 0;
    std::cout << sum << std::endl;
  }
}

int main()
{
  std::int64_t n;
  std::cin >> n;
  std::vector<std::int64_t> values(n);
  for (auto& v : values) {
    std::cin >> v;
  }

  std::int64_t q;
  std::cin >> q;
  Ps ps(q);
  for (auto& p : ps) {
    std::cin >> p.first >> p.second;
  }

  std::cout << std::setprecision(20);
  solve(n, values, q, ps);
}


Measured memory_bytes: 6432
#include <bits/stdc++.h>
#pragma GCC optimize ("O2")
#pragma GCC optimize ("unroll-loops")
//#pragma GCC optimize("no-stack-protector,fast-math")

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<pii, int> piii;
typedef pair<ll, ll> pll;
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define debugp(x) cerr<<#x<<"= {"<<(x.first)<<", "<<(x.second)<<"}"<<endl;
#define debug2(x, y) cerr<<"{"<<#x<<", "<<#y<<"} = {"<<(x)<<", "<<(y)<<"}"<<endl;
#define debugv(v) cerr<<#v<<" : ";for (auto x:v) cerr<<x<<' ';cerr<<endl;
#define all(x) x.begin(), x.end()
#define pb push_back
#define kill(x) return cout<<x<<'\n', 0;

const ld eps=1e-7;
const int inf=1000000010;
const ll INF=10000000000000010LL;
const int mod = 1000000007;
const int MAXN = 100010, LOG=20;

int n, m, k, u, v, x, y, t, a, b;

int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	cin>>n;
	while (n--){
		cin>>x;
		if (x&1) a++;
		else b++;
	}
	if (a&1) kill("NO")
	kill("YES")
	
	return 0;
}


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


int main(){
  string w[4]={"Sunny", "Cloudy", "Rainy", "Sunny"};
  string a;
  cin>>a;
  for(int i=0; i<3; i++){
    if(a==w[i]){
      cout<<w[i+1]<<endl;
      break;
    }
  }

}

Measured memory_bytes: 256
n,p=map(int,input().split())
ans=1
def factorize(n):
    fct = []  # prime factor
    b, e = 2, 0  # base, exponent
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append([b, e])
        b, e = b + 1, 0
    if n > 1:
        fct.append([n, 1])
    return fct
p=factorize(p)
for i in p:
  while i[1]>=n:
    i[1]-=n
    ans*=i[0]
print(ans)

Measured memory_bytes: 3064
// base: http://drken1215.hatenablog.com/entry/2019/09/16/014600

#include <algorithm>
#include <cassert>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <unordered_map>
#include <vector>
#include <string.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; ++i)
#define all(s) s.begin(), s.end()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> triple;
typedef double D;

const ll INF = 1e9;
const ll MOD = 1000000007;  // 1e9 + 7

ll powmod(ll x, ll y) {
  ll r = 1;
  while (y) {
    if (y & 1) {
      r = r * x % MOD;
    }
    x = x * x % MOD;
    y >>= 1;
  }
  return r;
}

// Rolling Hash
struct RollingHash {
  static const ull base1 = 1000000007;
  vector<ull> hash1, power1;

  RollingHash(const string& S) {
    int n = S.size();
    hash1.resize(n+1);
    power1.assign(n+1, 1);
    rep(i, n) {
      hash1[i+1] = hash1[i] * base1 + S[i];
      power1[i+1] = power1[i] * base1;
    }
  }

  // get hash of S[left:right]
  inline ull get(int l, int r) const {
    ull res1 = hash1[r] - hash1[l] * power1[r-l];
    return res1;
  }

  // get lcp of S[a:] and T[b:]
  inline int getLCP(int a, int b) const {
    int len = min((int)hash1.size()-a, (int)hash1.size()-b);
    int low = 0, high = len;
    while (high - low > 1) {
      int mid = (low + high) >> 1;
      if (get(a, a+mid) != get(b, b+mid)) high = mid;
      else low = mid;
    }
    return low;
  }
};

int main(int argc, char** argv) {
  int N;
  cin >> N;
  string S;
  cin >> S;

  RollingHash rh(S);

  int ans = 0;
  rep(i, N) {
    for (int j = i + 1; j < N; ++j) {
      int lcp = rh.getLCP(i, j);
      lcp = min(lcp, j - i);
      ans = max(ans, lcp);
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 512
#!/usr/bin/env python3
import collections
import itertools as it
import math
#import numpy as np
 
#  = input()
#  = int(input())
n, m  = map(int, input().split())
#  = list(map(int, input().split()))
#  = [int(input()) for i in range(N)]
#
# c = collections.Counter()

sc = [tuple(map(int, input().split())) for _ in range(m)]

#print(sc)

start = 0 if n == 1 else 10 ** (n-1)
for i in range(start, 10**(n)):
    ans = str(i)

    for s, c in sc:
        #print(s,c,ans)
        if ans[s-1] != str(c):
            break
    else:
        print(ans)
        break
else:
    print(-1)


Measured memory_bytes: 3316
import java.util.*;

public class Main {
    private static final Scanner scn = new Scanner(System.in);
    private static final List<IntegralRectangle> RECTANGLES;
    private static final int MAX = 150;

    static {
        RECTANGLES = new ArrayList<>();
        Main main = new Main();
        for(int y = 1; y < MAX; y++) {
            for(int x = -~y; x < -~MAX; x++) {
                RECTANGLES.add(main.new IntegralRectangle(y, x));
            }
        }
        Collections.sort(RECTANGLES);
    }

    public static void main(String[] args) {
        new Main().solve();
    }

    void solve() {
        int height;
        int width;
        while((height = scn.nextInt()) > 0 | (width = scn.nextInt()) > 0) {
            IntegralRectangle base = new IntegralRectangle(height, width);
            for(IntegralRectangle rectangle : RECTANGLES) {
                if(base.compareTo(rectangle) < 0) {
                    System.out.println(rectangle);
                    break;
                }
            }
        }
    }

    class IntegralRectangle implements Comparable<IntegralRectangle> {
        private int height;
        private int width;

        public IntegralRectangle(int height, int width) {
            this.height = height;
            this.width  = width;
        }

        private int squareDiagonal() {
            return height * height + width * width;
        }

        @Override
        public int compareTo(IntegralRectangle another) {
            if(this.squareDiagonal() > another.squareDiagonal()) {
                return 1;
            } else if(this.squareDiagonal() < another.squareDiagonal()) {
                return -1;
            } else {
                if(this.height != another.height) {
                    return this.height > another.height ? 1 : -1;
                } else {
                    return 0;
                }
            }
        }

        @Override
        public String toString() {
            return height + " " + width;
        }
    }
}

Measured memory_bytes: 27952
/*

*/
#include <bits/stdc++.h>
using namespace std;
#define pi acos(-1.0)
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);cout << setprecision(12)
#define rep(i,a,n) for (ll i=a;i<n;i++)
#define per(i,a,n) for (ll i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((ll)(x).size())
#define cin1(x) cin >> x
#define cin2(x, y) cin >> x >> y
#define cin3(x, y, z) cin >> x >> y >> z
#define cin4(x, y, z, _) cin >> x >> y >> z >> _
#define cin5(x, y, z, p, q) cin >> x >> y >> z >> p >> q
#define cou(x) cout << x
#define cous(x) cout << x << " "
#define coul(x) cout << x << "\n"
#define ret(x) return x
#define MAX 5000001
#define start int main() {   fastio
#define finish ret(0); }
#define Test ll _t; cin1(_t); rep(w, 0, _t)
#define minv(v) *min_element(v.begin(),v.end())
#define maxv(v) *max_element(v.begin(),v.end())
#define cntv(v,a) count(v.begin(),v.end(),a)
struct point{    int x, y, ind;   char ch;  };
typedef long long ll;
typedef vector<ll> VI;
typedef pair<ll,ll> PII;
typedef double db;
//mt19937 mrand(random_device{}());
const ll mod=1000000007;
//ll rnd(ll x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}ret(res);}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll fact[13];
void factorial() {   fact[0]=1;  rep(i, 1, 12) fact[i]=(fact[i-1]*i);  }
vector <ll> sie; //for sieve function
ll spf[MAX+7];  //for sieve function
void sieve() {    rep(i, 2, MAX)  {  if (spf[i] == 0) {  spf[i] = i;   sie.pb(i);  }    for (ll j=0; j<SZ(sie) && i*sie[j] <= MAX && sie[j] <= spf[i]; j++)   spf[i * sie[j]] = sie[j]; }   }
bool cmp(point A, point B){   if(A.x != B.x) ret(A.x < B.x);  ret(A.y < B.y);   }
// head collected
// Don't use variable name as --> prev, time, _t, w, y1

ll t, n, k, _, __,ans, re;
string str;
ll ara[100007];

start;

    cin3(t, n, k);

    _ = n / k + 1;

    if ( ! t ) __ = 0;
    else __ = ( t- 1) / k + 1;

    ans = _ - __;

    coul(ans);

finish


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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"

// イテレータ要素のインデックス
distance(A.begin(), itr);
*/

int main()
{
    int n; cin >> n;
    map<ll, ll> m;
    ll sum = 0;
    rep(i,n){
        int ai; cin >> ai;
        sum += ai;
        ++m[ai];
    }

    int q; cin >> q;
    rep(_,q){
        ll b, c; cin >> b >> c;
        sum -= m[b]*b;
        sum += m[b]*c;
        cout << sum << endl;
        m[c] += m[b];
        m[b] = 0;
    }


    // cout << ++m[10000] << endl;
        
}

Measured memory_bytes: 9416
import java.util.*;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		String a = scan.nextLine();
		int count = 0;
		
		for(int i = 0; i < 4; i++) {
			if(a.charAt(i) == '+') {
				count++;
			} else {
				count--;
			}
		}
		System.out.println(count);
	}

}

Measured memory_bytes: 21716
import math

a, b, x = map(int, input().split())

area_base = a ** 2
volum_bottle = area_base * b

k = (2 * (volum_bottle - x)) / a ** 2

if k <= b:
  K_t = k / a
  angle = math.degrees(math.atan(K_t))
else:
  L_t = a * (b ** 2) / (2 * x)
  angle = math.degrees(math.atan(L_t))
  
print(round(angle, 10))

Measured memory_bytes: 3064
import sys
from collections import defaultdict
def input(): return sys.stdin.readline().rstrip()

def main():
    S = list(input())
    T = list(input())

    memo = defaultdict(lambda: defaultdict(str))

    for s, t in zip(S, T):
        for key, (a, b) in {'s': (s, t), 't': (t, s)}.items():
            if memo[key][a] and memo[key][a] != b:
                print('No')
                exit()
            else:
                memo[key][a] = b
    print('Yes')

if __name__ == '__main__':
    main()


Measured memory_bytes: 6952
#include "bits/stdc++.h"
//#include "atcoder/all"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
//using namespace atcoder;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, l;
	cin >> n >> l;
	vector<string> s(n);
	rep(i,n) cin >> s[i];
	sort(s.begin(), s.end());
	rep(i,n) cout << s[i];
	cout << endl;
	return 0;
}


Measured memory_bytes: 3680
#include<bits/stdc++.h>
#include<cmath>
#include<string>
using namespace std;
int main(){
    int N;
    cin>>N;
    int X=N/1.08;
  
  	if(int(X*1.08)==N) cout<<X<<endl;
  	else if(int((X+1)*1.08)==N) cout<<X+1<<endl;
  	else cout<<":("<<endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define pb(a) push_back(a)
#define all(x) (x).begin(), (x).end()

#define FOR(i, a, n) for (int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(all(a))
#define REVERSE(a) reverse(all(a))

#define PRINT(str) printf(#str "\n")
#define yOUT PRINT(Yes)
#define nOUT PRINT(No)
#define YOUT PRINT(YES)
#define NOUT PRINT(NO)

//関数定義
//最大公約数
ll gcd(ll a, ll b);

//最小公倍数
ll lcm(ll a, ll b);

int main() {
  // ========================================================
  int a, b;
  cin >> a >> b;
  if (a == b)
    yOUT;
  else
    nOUT;
}

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

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


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

using namespace std;

#define int long long
#define double long double
#define mod 1000000007ll
#define INF 1000000000000000000ll

int tab[10000];

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

    int n;
    cin >> n;
    for (int i=0; i<n; i++) {
        char c;
        cin >> c;
        tab[c]++;
    }
    int res = 1;
    for (int i=0; i<1000; i++) {
        res = (res * (tab[i] + 1))%mod;
    }
    cout << res-1;

    return 0;
}/*

*/


Measured memory_bytes: 256
#include<stdio.h>
#define A 2000

int solve(int,int);
int a,b[A];

main(){
  int i,c,d;
  
  scanf("%d",&a);
  for(i=0;i<a;i++){
    scanf("%d",&b[i]);
  }
  scanf("%d",&c);
  for(i=0;i<c;i++){
    scanf("%d",&d);
    if(solve(0,d)!=0) printf("yes\n");
    else printf("no\n");
  }
  return 0;
}

int solve(int i,int data2){
  int ans;
  if(data2 == 0)return 1;
  if(i>=a)return 0;

  ans = solve(i+1,data2-b[i])||solve(i+1,data2);
  return ans;
}

Measured memory_bytes: 584
#include<iostream>
#include<cmath>
#include<vector>
#include<queue>
#include<algorithm>
#include <stack>
#include<set>
#include<cstring>
#include<iterator>
#include <map>
using namespace std;
// bool cmp(long long a, long long b){
//     return a > b;
// }
int main() {
    // ios_base::sync_with_stdio(false);
    long long t, ch, i, h, a, b, l, r, z, p = 1, x, y, weight, j, k = 0, n, m = 1, ch1, q, count, ans = 0;
    long long fl;
    string s, s1;
//    cin >> t;
    // long long d, g, w;
    // long long kol = 0, ch2;
//    for (long long test_case = 0; test_case < t; test_case++){
//        cin >> n;
//        for (i )
//        }
//    }
    cin >> s;
    ch = 0;
    ans = 0;
    for (i = 0; i < s.length(); i++){
        if (s[i] == 'R')
            ch++;
        else{
            ans = max(ch, ans);
            ch = 0;
        }
    }
    ans = max(ans, ch);
    cout << ans;
    return 0;
}


Measured memory_bytes: 3592
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<memory>
#include<functional>
#include<set>
 
using namespace std;
 
#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define F(i,j,k) fill(i[0],i[0]+j*j,k)
#define P(p) cout<<(p)<<endl;
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define INF 1<<25
#define pb push_back
 
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef pair<int,int> pii;
typedef pair<long,long> pll;
typedef long long ll;
int main(){
	int N,ans=0;
	vector<int>A;
	cin>>N;
	rep(i,N){
		int t;
		cin>>t;
		A.push_back(t);
	}
	ans=A.size();
	sort(A.begin(),A.end());
//	A.erase(unique(A.begin(),A.end()),A.end());
//	int ans2=A.size();
	//ans2-=(ans-ans2)
	int c=0;
	REP(i,1,N+1){
		if(A[i]==A[i-1])
			c++;
		else{
			if(c==0)continue;
			if(c%2==1)
				ans-=c+1;
			else
				ans-=(c);
			c=0;
		}
	}

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



Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
using ll= long long;
using vi= vector<int>;
using vvi= vector<vi>;
using vd= vector<double>;
using vvd= vector<vd>;
using vc= vector<char>;
using vb= vector<bool>;
using vl= vector<ll>;
#define rep(i,x,n) for(int i=x; i<n; i++)
#define all(x) x.begin(), x.end()

int dig1(int n){
  int ans;
  n*=10;
  ans= n%100;
  ans/=10;
  
  return ans;
}

int main(void){
  vi a(5);
  int tmp=10, ans=0;
  rep(i,0,5)cin >> a[i];
  rep(i,0,5){
    ans+= a[i]/10*10;
    if(dig1(a[i])){
      ans+= 10;
      tmp= min(tmp, dig1(a[i]));
    }
  }
  if(tmp<10){
    ans-= 10-tmp;
  }
  cout << ans;
  
  return 0;
}


Measured memory_bytes: 256
#coding: utf-8
from functools import reduce
def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a%b)
N, X = map(int, input().split())
x = list(map(int, input().split()))
x = [abs(X - x[i]) for i in range(N)]
l = reduce(gcd, x)
print(l)

Measured memory_bytes: 14596