akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <numeric>
#include <climits>
#define LIM 1000007
#define ll long long
using namespace std;
int main() {
  ll n, w, h, right, left, top, down;
  cin >> right;
  cin >> top;
  cin >> n;
  left = down = 0;
  while (n--) {
    ll a, b, c;
    cin >> a >> b >> c;
    if (c == 1) {
      left = max(left, a);
    } else if (c == 2) {
      right = min(right, a);
    } else if (c == 3) {
      down = max(down, b);
    } else if (c == 4) {
      top = min(top, b);
    }
  }
  h = (top - down);
  w = (right - left);
  if (h > 0 && w > 0) {
    cout << h * w << endl;
  } else {
    cout << 0 << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,ans=0;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		if(n%i==0) ans+=n/i-1;
		else ans+=n/i;
	}
	cout<<ans;
}

Measured memory_bytes: 3608
import sys, os

if __name__=='__main__':
    if 'local' in os.environ :
        sys.stdin = open('./input.txt', 'r')
    
    ans = 0
    min_mod = 10
    for i in range(5):
        x = int(input())
        ans += x//10 * 10 + (0 if x%10 == 0 else 10);
        if x%10 != 0:
            min_mod = min(min_mod, x%10);
        
    
    if min_mod == 10:
        print(ans)
    else:
        print(ans - 10 + min_mod)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long int
#define fast  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(t)            int t; cin>>t; while(t--)
const int mod = 1000000007;
bool comp(pair<ll,ll>& a, pair<ll,ll>& b)
{
    if(a.second == b.second)
    return a.first > b.first;
    else
    return b.second < a.second;
}
int main()
{
    fast
    int n;
    cin>>n;
    map<string,int> mp;
    while(n--)
    {
        string s;
        cin>>s;
        mp[s]++;
    }

    cout<<"AC "<<"x "<<mp["AC"]<<endl;
    cout<<"WA "<<"x "<<mp["WA"]<<endl;
    cout<<"TLE "<<"x "<<mp["TLE"]<<endl;
    cout<<"RE "<<"x "<<mp["RE"]<<endl;

    return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
int main() {
    map<string, int> m;
    int mmax = 0, n;
    cin >> n;
    while(n--) {
        string str;
        cin >> str;
        ++m[str];
        mmax = max(m[str], mmax);
    }
    for(map<string, int>::iterator it = m.begin(); it != m.end(); ++it){
        if(it -> second == mmax)
            cout << it -> first << "\n";
    }
    return 0;
}

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

const int64_t MOD = 1000000007;
typedef int64_t ll;
typedef uint64_t ull;

#define FOR(i, start, end) for(uint64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

// vector<vector<uint64_t> > v(n+1, vector<uint64_t>(n+1, 0))
// v[n][k]に組み合わせ数が入る。
void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

// フェルマーの小定理
// mod. m での a の逆元 a^{-1} を計算する
// (a/b)%m = a*movinv(b,m)%m  
int64_t modinv(int64_t a, int64_t m) {
    int64_t b = m, u = 1, v = 0;
    while (b) {
        int64_t t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

/* 
  //エラトステネスのふるい
  int maxNum = 100000;
  char isNotPrime[maxNum+1] = {};
  isNotPrime[0]=isNotPrime[1]=1;
  for(int i=2;i<maxNum;i++){
    if(isNotPrime[i]==1) continue;
    int num = i+i;
    while(num<=maxNum){
      isNotPrime[num]=1;
      num += i;
    }
  }
*/
// 円周率
// M_PI

// #include <iomanip> // setprecisionを使用するのに必要
// cout << std::fixed << std::setprecision(15) << y << endl;

// 昇順
// priority_queue<int, vector<int>, greater<int> > queue;

// 降順ソート vector<int> v;
// sort(v.begin(),v.end(),greater<int>());

signed main() {
  int n;
  cin >> n;
  
  vector< vector<int> > f(n, vector<int>(10));

  for(int i=0;i<n;i++){
    for(int j=0;j<10;j++){
      cin >> f[i][j];
    }
  }

  vector< vector<int> > p(n, vector<int>(11));
  for(int i=0;i<n;i++){
    for(int j=0;j<11;j++){
      cin >> p[i][j];
    }
  }

  int countMax = pow(2,10)+1;
  int maxProfit = -1000000000;
  for(int i=1;i<countMax;i++){
    int c[n] = {};
    int openCount = 0;
    for(int j=0;j<10;j++){
      if((i>>j)%2==0) continue;
      openCount++;
      for(int k=0;k<n;k++){
        if(1==f[k][j]) c[k]++;
      }
    }
    if(0==openCount) continue;
    int profit = 0;
    for(int k=0;k<n;k++){
      profit += p[k][c[k]];
    }
    maxProfit = max(maxProfit,profit);
  }
  
  cout << maxProfit << endl;
  return 0;
}



Measured memory_bytes: 3704
#include <bits/stdc++.h>
using namespace std;
#define debug(...) { printf("#  "); printf(__VA_ARGS__); puts(""); }
#define fi first
#define se second
#define endl "\n" 
using ll = long long;
using pII = pair <int, int>;
using pLL = pair <ll, ll>;
using VI = vector <int>;
using VL = vector <ll>;
constexpr int mod = 1e9 + 7;
template <class T1, class T2> inline void chadd(T1 &x, T2 y) { x += y; if (x >= mod) x -= mod; else if (x < 0) x += mod; } 
template <class T1, class T2> inline void chmax(T1 &x, T2 y) { if (x < y) x = y; }
template <class T1, class T2> inline void chmin(T1 &x, T2 y) { if (x > y) x = y; }
inline int rd() { int x; cin >> x; return x; }
template <class T> inline void rd(T &x) { cin >> x; }
template <class T> inline void rd(vector <T> &vec) { for (auto &it : vec) cin >> it; }
template <class T> inline void out(T s) { cout << s << "\n"; }
template <class T> inline void out(vector <T> &vec) { for (auto &it : vec) cout << it << " "; cout << endl; } 
inline ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
inline ll qpow(ll base, ll n) { ll res = 1; while (n) { if (n & 1) res = res * base % mod; base = base * base % mod; n >>= 1; } return res; }
constexpr int N = 1e5 + 10;
int n, k; char s[N];
void run() {
	int res = 0;
	cin >> s;
	for (int i = 1; s[i]; ++i) res += (s[i] == s[i - 1]);
	cout << min(res + 2 * k, n - 1) << endl;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr); cout.tie(nullptr);
	cout << fixed << setprecision(20);
	while (cin >> n >> k) run();
	return 0;
}


Measured memory_bytes: 384
package main

import "fmt"

func main() {
	var H, W int
	fmt.Scan(&H, &W)
	pic := make([][]bool, H+2)
	for i := 0; i < H+2; i++ {
		pic[i] = make([]bool, W+2)
		if i == 0 || i == H+1 {
			continue
		} else {
			var tmp string
			fmt.Scan(&tmp)
			for j, r := range tmp {
				switch r {
				case '#':
					pic[i][j+1] = true
				case '.':
					pic[i][j+1] = false
				}
			}
		}
	}
	isOK := true
	for i := 1; i < H+1; i++ {
		for j := 1; j < W+1; j++ {
			if pic[i][j] {
				if pic[i-1][j] || pic[i+1][j] || pic[i][j-1] || pic[i][j+1] {
					continue
				} else {
					isOK = false
					break
				}
			}
		}
	}
	if isOK {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define pi 3.14159
using namespace std;

int main()
 {
 	int n,i;
 	string s[3],s1;
 	s1.erase();
 	for(i=0;i<3;i++)
 		cin>>s[i];
 	s1+=s[0][0];
 	s1+=s[1][0];
 	s1+=s[2][0];
 	
 	cout<<s1<<endl;
 }

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n, a, b;
  cin >> n >> a >> b;
 
  int p1 = a * n;

  if (p1 < b){
    cout << p1 << endl;
  }
  else cout << b << endl;
  // ここにプログラムを追記
}

Measured memory_bytes: 3608
import sys
from collections import defaultdict
from math import gcd

def input(): return sys.stdin.readline().strip()

K = 10**9
L = 10**18
D = defaultdict(int)
for _ in range(int(input())):
    D[gcd(round(float(input()) * K), L)] += 1

D = tuple(D.items())
ans = 0
for i, (k1, v1) in enumerate(D):
    if k1*k1 % L == 0:
        ans += v1*(v1-1) // 2
    for k2, v2 in D[i+1:]:
        if k1*k2 % L == 0:
            ans += v1 * v2
print(ans)


Measured memory_bytes: 74720
import java.io.*;
 
class Main {
 
   public static void main(String[] args) {
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      try {
         String str;
         int[] alphabet = new int[26];
         while ((str = br.readLine()) != null) {
            if (str.equals(""))
               break;
            str = str.toLowerCase();
            char[] ch = str.toCharArray();
            for (char c: ch) {
               if ('a' <= c && c <= 'z'){
                  alphabet[c - 'a']++;
               }
            }
         }
 
         for (int i = 0; i < alphabet.length; i++) {
            System.out.println((char)('a' + i) + " : " + alphabet[i]);
         }
      }
 
      catch (Exception e) {
         System.err.println(e);
      }
   }
}

Measured memory_bytes: 24312
#include<bits/stdc++.h>
#define L long long
#define pb push_back
using namespace std;
int t,a,b,c,d,e;
vector<int> x,y,z;
inline bool chk(int x,int k)
{
    if(k==1)
      return (L)(a-x*e+1)*e-1>=b-x;
    if(k==2)
      return (L)(a-x+1)*e>=b;
}
inline int ef(int l,int r,int k)
{
    while(l<r)
      if(chk(l+r+1>>1,k))
        l=(l+r+1>>1);
      else
        r=(l+r+1>>1)-1;
    return l;
}
inline void orz(int u,int v,int w)
{
    x.pb(u);
    y.pb(v);
    z.pb(w);
    a-=u*w;
    b-=v*w;
}
inline void pri(int c,int d)
{
    int i,j,l,k=0;
    for(i=0;i<x.size();i++)
      if(k+(x[i]+y[i])*z[i]<c)
        k+=(x[i]+y[i])*z[i];
      else if(k>c)
        {
         for(j=1;j<=z[i];j++)
           for(l=1;l<=x[i]+y[i];l++,k++)
             if(k>d)
               return;
             else if(l<=x[i])
               printf("A");
             else
               printf("B");
        }
      else
        {
         j=(c-k-1)/(x[i]+y[i]);
         k+=(x[i]+y[i])*j;
         l=c-k;
         k=c;
         for(j++;j<=z[i];j++,l=1)
           for(;l<=x[i]+y[i];l++,k++)
             if(k>d)
               return;
             else if(l<=x[i])
               printf("A");
             else
               printf("B");
        }
}
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int i,j;
	scanf("%d",&t);
	while(t--)
	  {
       scanf("%d%d%d%d",&a,&b,&c,&d);
         {
          if(a>b)       
            e=(a-1)/(b+1)+1;
          else
            e=(b-1)/(a+1)+1;
          i=ef(0,min(a/e,b),1);
          //cout<<e<<" "<<i<<"!!\n";
          orz(e,1,i);
          i=ef(0,min(a,e),2);
          //cout<<i<<"!!\n";
          orz(i,0,1);
          //cout<<a<<" "<<b<<"!!\n";
          orz(0,b-a*e,1);
          orz(1,e,a);
          pri(c,d);
          printf("\n");
         }
       x.clear();
       y.clear();
       z.clear();
      }
	return 0;
}


Measured memory_bytes: 384
N,M = map(int,input().split())
A = list(map(int,input().split()))
A = sorted(A)
B = [list(map(int,input().split())) for _ in range(M)]
B = sorted(B,key=lambda x:x[1],reverse=True)
cur = 0
cnt = 0
for i in range(N):
    if cnt==B[cur][0]:
        cur +=1
        if cur==M:break
        cnt = 0
    if B[cur][1]<=A[i]:
        break
    A[i] = B[cur][1]
    cnt += 1
print(sum(A))

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

using namespace std;
typedef long long ll;
const int N = 1e5+50;
const int oo = 1e9;
float a[6];
int main(){
	int n,m;
	cin>>n>>m;
	a[1] = 2;
	a[2] = 4;
	a[3] = 8;
	a[4] = 16;
	a[5] = 32;
	int ans = a[m] * (1900*m + (n-m)*100);
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <limits>
#include <string>
#include <vector>

using namespace std;

const long long INF = 1LL << 60;

//各桁の和を出力
long long Sum(long long n) {
  long long m = 0;
  while (n) {
    m += n % 10;
    n /= 10;
  }
  return m;
}

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

void Comuse() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

#define comuse Comuse()
// nCk(comuseを使え)
long long combi(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// pCk(comuseを使え)
long long perm(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] % MOD) % MOD;
}

//最小公倍数(aとbの)
long long lcm(long long a, long long b) {
  long long n;
  n = a / __gcd(a, b) * b;
  return n;
}

// auto A = div(n)
vector<long long> div(long long n) {
  vector<long long> ret;
  for (long long i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) {
        ret.push_back(n / i);
      }
    }
  }
  sort(ret.begin(), ret.end());
  return ret;
}

//(aのn乗をmodで割ったあまり)
long long modpow(long long a, long long n, long long mod) {
  long long ans = 1;
  while (n > 0) {
    if (n & 1) {
      ans = ans * a % mod;
    }

    a = a * a % mod;

    n >>= 1;
  }

  return ans;
}

void solve();

const int MAX_N = 131072;
// segment tree
int NN;
int seg[MAX_N * 2 - 1];
void seguse() {
  for (int i = 0; i < 2 * NN - 1; i++) {
    seg[i] = INT_MAX;
  }
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(20) << fixed;
  solve();
}

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

long long N;
vector<long long> ball(2000000);
vector<long long> kosuu(2000000);
long long ans = 0;
void solve() {
  cin >> N;
  for(int i = 0; i < N; i++){
    cin >> ball.at(i);
    ball.at(i)--;
    kosuu.at(ball.at(i))++;
  }
  for(int i = 0; i < N; i++){
    ans += kosuu.at(i) * (kosuu.at(i) - 1) / 2;
  }
  for(int i = 0; i < N; i++){
    cout << ans - (kosuu.at(ball.at(i)) - 1) <<endl;
  }
}


Measured memory_bytes: 33920
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

a, b = na()
ans = "No"
for c in range(1,4):
    if a * b * c % 2 == 1:
        ans = 'Yes'
        break
print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <set>
#include <stack>
using ll = long long;
using uint = unsigned int;
using graph = std::vector<std::vector<ll>>;
using wGraph = std::vector<std::vector<std::pair<ll,ll>>>;
#define rep(i,n) for (int i=0; i < int(n); i++)

using namespace std;
ll MOD7 = 1000000007;
ll MOD9 = 1000000009;
vector<ll> InputVec(ll N){
    vector<ll> A(N);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }
    return A;
}
void OutputVec(vector<ll> A){
    for (int i = 0; i < A.size(); ++i) {
        cout << A[i] << ",";
    }
    cout << endl;
}
vector<vector<ll>> InputVec2d(ll H,ll W){
    vector<vector<ll>> A(H);
    for (int yi = 0; yi < H; ++yi) {
        A[yi] = vector<ll>(W);
    }
    for (int yi = 0; yi < H; ++yi) {
        for (int xi = 0; xi < W; ++xi) {
            cin >> A[yi][xi];
        }
    }
    return A;
}
vector<vector<char>> InputVec2dStr(ll H,ll W){
    vector<vector<char>> A(H);
    for (int yi = 0; yi < H; ++yi) {
        A[yi] = vector<char>(W);
    }
    for (int yi = 0; yi < H; ++yi) {
        string S;
        cin >> S;
        for (int xi = 0; xi < W; ++xi) {
            A[yi][xi] = S[xi];
        }
    }
    return A;
}
void OutputVec2d(vector<vector<ll>> A){
    for (int yi = 0; yi < A.size(); ++yi) {
        for (int xi = 0; xi < A[yi].size(); ++xi) {
            cout << A[yi][xi] << ",";
        }
        cout << endl;
    }
}
graph InputGraph(ll N,ll M){
    graph G(N);
    for (int i = 0; i < M; ++i) {
        ll a,b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    return G;
}
graph InputDGraph(ll N,ll M){
    graph G(N);
    for (int i = 0; i < M; ++i) {
        ll a,b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
    }
    return G;
}
void OutputGraph(graph G){
    for (int i = 0; i < G.size(); ++i) {
        cout << i << ":";
        for (int j = 0; j < G[i].size(); ++j) {
            cout << G[i][j]<< ",";
        }
        cout << endl;
    }
}
void OutputAnswerBool(bool b,bool isUpperCase = false){
    if(b){
        if(isUpperCase){
            cout << "YES" << endl;
        }else{
            cout << "Yes" << endl;
        }
    }else{
        if(isUpperCase){
            cout << "NO" << endl;
        }else{
            cout << "No" << endl;
        }
    }
}

int main() {
    string S;
    cin >> S;
    bool isS,isW,isN,isE;
    isS = false;
    isW = false;
    isN = false;
    isE = false;
    for (int i = 0; i < S.size(); ++i) {
        switch (S[i]){
            case 'S':
                isS = true;
                break;
            case 'W':
                isW = true;
                break;
            case 'N':
                isN = true;
                break;
            case 'E':
                isE = true;
                break;
        }
    }
    if(isN == isS && isE == isW){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
  long long int n, a, a_max, a_min, a_sum;

  cin >> n;
  cin >> a;
  a_max = a_min = a_sum = a;
  for (int i = 1; i < n; ++i) {
    cin >> a;
    if (a_max < a) a_max = a;
    if (a < a_min) a_min = a;
    a_sum += a;
  }
  cout << a_min << ' ' << a_max << ' ' << a_sum << endl;
  return 0;
} 



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

int h,n;
long long dp[20010];

void solve(){
    int i,j,x,y;
    
    cin>>h>>n;
    
    for(i=0;i<20001;++i)
      dp[i]=1ll<<60;
      
    dp[0]=0;
    
    for(i=0;i<n;++i){
        cin>>x>>y;
        for(j=0;j<h;++j)
          dp[j+x]=min(dp[j+x],dp[j]+y);
    }
    
    long long minv=1ll<<60;
    
    for(i=h;i<=20000;i++)
      minv=min(minv,dp[i]);
      
    cout<<minv<<endl;
}

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

Measured memory_bytes: 384
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main{
        public static void main(String[] args){
                BufferedReader bfr=new BufferedReader(new InputStreamReader(System.in));
                String str="";
                String[] tango;
                int tangosu=0;
                int max_length=0;
                try{
                        str=bfr.readLine();
                        tango=str.split(" ");
                        tangosu=tango.length;
                        for(int i=0; i<tangosu; i++){
                                if(tango[max_length].length()<tango[i].length()){
                                        max_length=i;
                                }
                        }
                        int[] toujyoukaisu=new int[tangosu];
                        for(int i=0; i<tangosu; i++){
                                toujyoukaisu[i]=0;
                                for(int j=0; j<tangosu; j++){
                                        if(i!=j){
                                                if((tango[i].toLowerCase()).equals((tango[j]).toLowerCase())){
                                                        toujyoukaisu[i]++;
                                                }
                                        }
                                }
                        }
                        int max=0;
                        for(int i=0; i<tangosu; i++){
                                if(toujyoukaisu[max]<toujyoukaisu[i]){
                                        max=i;
                                }
                        }
                        System.out.println(tango[max]+" "+tango[max_length]);
                }catch(IOException e){
                        System.exit(0);
                }
        }
}


Measured memory_bytes: 25188
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <climits>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
//typedef pair<ll, ll> P;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define revrep(i, n) for(int i = (n)-1; i >= 0; i--)
#define pb push_back
#define f first
#define s second
#define chmin(x, y) x = min(x, y);
#define chmax(x, y) x = max(x, y);

//const ll INFL = LLONG_MAX;//10^18 = 2^60
const ll INFL = 1LL<<60;
//const int INF = INT_MAX;
const int INF = 1 << 30;//10^9
ll MOD = 1000000007;
//ll MOD = 998244353;
double EPS = 1e-11;

vector<ll> dy = {0, 1, 0, -1, 1, 1, -1, -1, 0};
vector<ll> dx = {1, 0, -1, 0, 1, -1, 1, -1, 0};

void pres(double A){printf("%.12lf\n", A);}
void BinarySay(ll x, ll y = 60){rep(i, y) cout << (x>>(y-1-i) & 1); cout << endl;}
ll cnt_bit(ll x){return __builtin_popcountll(x);}

ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x; k /= 2;
  }
  return res;
}

ll pow_mod(ll x, ll k){
  x %= MOD;
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}

ll inverse(ll x){return pow_mod(x, MOD - 2);};

ll gcd(ll a, ll b){
    if(b == 0) return a;
    return gcd(b, a % b);
}

ll lcm(ll x, ll y){
  ll res = x / gcd(x, y);
  res *= y;
  return res;
};


//コンビネーション
const int MAXcomb = 2000010;
ll fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
//facはn!,finvは1/n!
//invは逆元
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAXcomb; i++){
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
ll comb(int n, int k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * finv[k] % MOD * finv[n-k] % MOD;
}

const int MAXkai = 200010;
ll kai_memo[MAXkai];
ll kai(ll N){
  if(kai_memo[N] != 0) return kai_memo[N];
  if(N <= 1) return 1;
  return kai_memo[N] = N * kai(N-1) % MOD;
}

ll disit(ll s, ll base = 10){
  ll res = 0;
  while(s){
    res++;
    s /= base;
  }
  return res;
}


void solve(){
  ll N, K;
  cin >> N >> K;
  if(K > (N-1) * (N-2) / 2){
    cout << -1 << endl;
    return;
  }
  set<pair<ll, ll>> ans;
  for(ll i = 2; i <= N; i++){
    ans.insert({1, i});
  }
  set<pair<ll, ll>> rest;
  for(ll i = 2; i < N; i++)for(ll j = i + 1; j <= N; j++){
    rest.insert({i, j});
  }
  ll now = (N-1) * (N-2) / 2;
  while(now > K){
    pair<ll, ll> p = *rest.begin();
    rest.erase(p);
    ans.insert(p);
    now--;
  }
  cout << ans.size() << endl;
  for(auto itr = ans.begin(); itr != ans.end(); itr++){
    cout << itr->f << " " << itr->s << endl;
  }

}



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


Measured memory_bytes: 640
#include<cstdio>
#include<iostream>
#include<cctype>
#include<cstring>
#include<algorithm>
using namespace std;

#define ll long long
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define MD 1000000007

char sep[3] = " \n";
int i, j, k, n, m, l;


void shuffle(string s) {
  char buf[20010];
  l = s.size();
  rep(i,l) buf[i] = s[i];
  int h = 0;
  cin >> n;
  rep(i,n) {
    cin >> m;
    rep(j,m) buf[h+l+j] = buf[h+j];
    h+=m;
  }
  REP(i,h,h+l) printf("%c", buf[i]);
  printf("\n");
}

int main() {
  string s;
  while(true) {
    cin >> s;
    if (s == "-") break;
    shuffle(s);
  }

  return 0;
}
  

Measured memory_bytes: 1196
#include <stdio.h>
#include <stdlib.h>

#include <iostream>
#include <iomanip>
#include <sstream>
#include <stdint.h>
#include <string.h>

#define _USE_MATH_DEFINES
#include <math.h>

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

#include <algorithm>
#include <functional>
#include <bitset>
#include <functional>
#include <chrono>
#include <random>

#define sqr(x) (x) * (x)

typedef unsigned int u32;
typedef int i32;
typedef unsigned long long int u64;
typedef long long int i64;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

using namespace std;
using namespace std::chrono;

const i64 mod = 1000000007ll;
const i64 smod = 998244353ll;
const i64 inf = 10000000000000007ll;

const double eps = 1e-10;

// del

const i64 MAXN = 100005;


multiset<i64, greater<i64>> a;

i64 n, m;

int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout.precision(15); cout.setf(ios::fixed);

    cin >> n >> m;

    for (i64 i = 0; i < n; i++) {
        i64 t;
        cin >> t;
        a.insert(t);
    }

    while (m > 0 && !a.empty()) {
        auto it = a.begin();
        i64 c = *it;
        a.erase(it);
        if (c > 1) {
            a.insert(c / 2);
        }
        m--;
    }

    i64 S = 0;
    for (auto c : a) {
        S += c;
    }
    cout << S << endl;

    return 0;
}


Measured memory_bytes: 7040
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
using ll = long long;
int main()
{
	ll n;
    cin >> n;
    ll arr[n];
    map<ll,ll> mp;
    ll sum = 0;
    for(ll i=0;i < n;i++) 
    {
        cin >> arr[i] ;
     ++mp[arr[i]] ; 
     sum += arr[i];
    }
    ll q;
    cin >> q;
    while(q--)
    {
        ll old , neww;
        cin >> old >> neww;
        if(mp.find(old)!=mp.end())
        {
            
            sum = sum + mp[old] *( neww - old);
            mp[neww] = mp[neww] + mp[old];
            mp[old] = 0;
        }
        cout << sum << endl;
    }
    
	return 0;
}

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

int main(){
  int N;
  int M;
  cin >> N >> M;
  vector<int> ans(N);
  vector<vector<int>> Q(M, vector<int>(2));
  for(int i=0; i<M; i++){
    for(int j=0; j<2; j++){
      cin >> Q.at(i).at(j);
    }
  }
  
  for(int i=0; i<M; i++){
    ans.at(Q.at(i).at(0)-1)=Q.at(i).at(1);
  }
  
  
  if(N>1 && ans.at(0)==0){
    ans.at(0)=1;
  }
  
  
  bool check=true;
  
  /*
  if(N>1 && ans.at(0)==0){
    check=false;
  }
  */
  
  for(int i=0; i<M; i++){
    if(ans.at(Q.at(i).at(0)-1) != Q.at(i).at(1)){
      check=false;
      break;
    }
  }
  
  /*
  if(N==1 && ans.at(0)==0){
    check=true;
  }
  */
  
  if(check){
    for(int i=0; i<N; i++){
      cout << ans.at(i);
    }
  }
  
  else{
    cout << "-1" << endl;
  }
  
  
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
using namespace std;
namespace adaptor = boost::adaptors;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
typedef long long ll;

bool cmp(pair<int,int> x, pair<int,int> y){
	return x.first < y.first;
}

void Main()
{
	int N;
  	cin >> N;
  	vector<int> A(N);
  	rep(i,N) cin >> A[i];
  
  	vector<int> B(N);
  	iota(B.begin(), B.end(), 1);
  	// rep(i,N) cout << A[i] << " " << B[i] << endl;
  	
  	vector<pair<int,int>> C(N);
  	rep(i,N) C[i] = make_pair(A[i],B[i]);
  	
  	sort(C.begin(), C.end(), cmp);
  	rep(i,N) cout << C[i].second << " ";
  	cout << endl;
	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}

Measured memory_bytes: 2432
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <iterator>
using namespace std;

const int MAX_H=16+1,MAX_W=16+1;
int dp[MAX_H][MAX_W];

int dfs(int h,int w,int nowh,int noww){
	if(nowh>h || noww>w) return 0;
	if(dp[nowh][noww]==-1) return 0;
	if(nowh==h && noww==w) return 1;
	if(dp[nowh][noww] != 0) return dp[nowh][noww];
	return dp[nowh][noww]=dfs(h,w,nowh+1,noww)+dfs(h,w,nowh,noww+1);
}

int main(){
	int a,b,n;
	while(cin >> a >> b && a!=0 && b!=0){
		cin >> n;
		for(int i=0; i<MAX_H; ++i){
			for(int j=0; j<MAX_W; ++j){
				dp[i][j]=0;
			}
		}
		for(int i=0; i<n; ++i){
			int x,y;
			cin >> x >> y;
			dp[x][y]=-1;
		}
		cout << dfs(a,b,1,1) << "\n";
	}
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define ll long long
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;

//定数
//円周率
const double pi = 3.141592653589793238462643383279;
//天井
const int INF = 1000000000; // = 10^9
const ll LINF = 100000000000000000; // = 10^17
//ABC文字列
const string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZABC";
const string abc = "abcdefghijklmnopqrstuvwxyzabc";
//よくあるmodくん
const ll MOD = 1000000007; // = 10^9 + 7

//データ構造
//隣接リスト用構造体（有向グラフ向け）
struct edge {
  ll to; // E.toでその辺の終点へアクセスできる
  ll cost; // e.costでその辺の重みにアクセスできる
};
//Union_Find木
struct UnionFind {
  vector<int> UF; // UF.at(i) : iの親の番号
  vector<int> SIZE; // SIZE.at(root(i)) : iと連結されてる要素の数
  UnionFind(int N) : UF(N), SIZE(N, 1) { // 最初は全てが根であるとして初期化
    for(int i = 0; i < N; i++) {
      UF.at(i) = i;
    }
  }
  int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
    if (UF.at(x) == x) {
      return x;
    }
    return UF.at(x) = root(UF.at(x));
  }
  void unite(int x, int y) { // xとyの木を併合
    int rx = root(x); // xの根をrx
    int ry = root(y); // yの根をry
    if (rx == ry) {
      return; // xとyの根が同じ(=同じ木にある)時はそのまま
    }
    // xとyの根が同じでない(=同じ木にない)時：小さい方の根を大きい方の根につける
    if (SIZE.at(rx) < SIZE.at(ry)) {
      UF.at(rx) = ry;
      SIZE.at(ry) += SIZE.at(rx);
      SIZE.at(rx) = 0;
    }
    else {
      UF.at(ry) = rx;
      SIZE.at(rx) += SIZE.at(ry);
      SIZE.at(ry) = 0;
    }
  }
  bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
    int rx = root(x);
    int ry = root(y);
    return rx == ry;
  }
  int size(int x) { // xと連結されてる要素の数を返す
    return SIZE.at(root(x));
  }
};

//関数 (計算量)
//ctoi (O(1))
int ctoi(char c){
  if (c == '0') return 0;
  if (c == '1') return 1;
  if (c == '2') return 2;
  if (c == '3') return 3;
  if (c == '4') return 4;
  if (c == '5') return 5; 
  if (c == '6') return 6;
  if (c == '7') return 7;
  if (c == '8') return 8;
  if (c == '9') return 9;
  return -1;  
}
//to_char (O(1))
char to_char(int i){
  if (i == 0) return '0';
  if (i == 1) return '1';
  if (i == 2) return '2';
  if (i == 3) return '3';
  if (i == 4) return '4';
  if (i == 5) return '5';
  if (i == 6) return '6';
  if (i == 7) return '7';
  if (i == 8) return '8'; 
  if (i == 9) return '9';
  return ' ';  
}
//素数判定 
//一つ一つの判定ではこっちの方が速い(一つ当たりO(√N))
//一方100までに何個あるかなどはEratosthenesの篩の方が良い（O(NlogN))
bool PN(int x) {
  if (x <= 1) return false; // 1や0,-1は素数ではない
  if (x == 2) return true; // √2 + 1 > 2 なので下でやると 2 ％ 2 = 0 となり判定できない
  for (int i = 2; i < sqrt(x) + 1; i++) {
    if (x % i == 0) return false; // 割れたら素数じゃない
  }
  return true;
}
// A^N mod M を計算する。modしたくなかったらM = LINFとかにすればよい。(O(√N))
ll modpow(ll A, ll N, ll M) {
  ll ans = 1;
  while (N > 0) {
    if (N & 1) ans = ans * A % M;
      A = A * A % M;
      N >>= 1;
   }
  return ans;
}
  
//メイン処理
int main() {
  cout << fixed << setprecision(16); //精度向上
  //ここまでテンプレ
  ll A, B, X;
  cin >> A >> B >> X;
  ll ans = B / X - A / X;
  if (A % X == 0) {
    ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3688
#include<iostream>
#include<cstdio>
#include<queue>
#include<vector>
#include<string.h>
#include<algorithm>
#include<cmath>
#include<map>

using namespace std;

int A,B,H,M,i,j,k;

double x,th;

int main()
{
  cin>>A>>B>>H>>M;
  
  th=-1./6.*3.14159265358979323846*H+3.14159265358979323846/30.*M*11./12.;
  x=sqrt(1.0*A*A+1.0*B*B-2.0*A*B*cos(th));
  
  printf("%.16f",x);
  
  
}


Measured memory_bytes: 4196
l = int(input())
i = input()
result = 0

match = ""
for r in range(l):
  if i[r] == "A" and match == "":
    match += i[r]
  elif i[r] == "B" and match == "A":
    match += i[r]
  elif i[r] == "C" and match == "AB":
    match = ""
    result += 1
  else:
    match = i[r]

print(result)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
//g++ -std=c++11 

using namespace std;
typedef long long ll;

#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define DIV 1000000007 //10^9+7

int main(){
	string S, T;
	cin >> S >> T;
	ll num = 0;
	rep(i, 3) {
		if(S[i] == T[i])
			num++;
	}
	cout << num << endl;

}



Measured memory_bytes: 3568
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int mod = 1e9 + 7;
ll modpow(ll A, ll B) {
	ll kotae = 1;
	while (B > 0) {
		if (B & 1) kotae = kotae * A % mod;
		A = A * A % mod;
		B >>= 1;
	}
	return kotae;
}
const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}
const int n = 100000;
class nanika {
	int fac[100001], inv[100001];
public:
	constexpr nanika() : fac(), inv() {
		fac[0] = 1;
		rep1(i, n) fac[i] = ll(fac[i - 1]) * i % mod;
		ll ifac = 1;
		ll A = fac[n];
		ll B = mod - 2;
		while (B > 0) {
			if (B & 1) ifac = ifac * A % mod;
			A = A * A % mod;
			B >>= 1;
		}
		for (int i = n; i > 0; i--) {
			inv[i] = fac[i - 1] * ifac % mod;
			ifac = ifac * i % mod;
		}
	}
	int operator[](int n) {
		return inv[n];
	}
	int getfac(int n) {
		return fac[n];
	}
} test;

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


	int N = getint();
	int kei = 0;
	ll kotae = 0;
	int mae = getint();
	rep1(i, N - 1) {
		int tugi = getint();
		ll X = tugi - mae;
		kei = (kei + test[i]) % mod;
		kotae += kei * X % mod;
		mae = tugi;
	}

	printf("%lld\n", kotae % mod * test.getfac(N - 1) % mod);


	Would you please return 0;
}


Measured memory_bytes: 256
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {
    private static ArrayList<Integer> list;

    public static void main(String args[]) throws FileNotFoundException {
        list = new ArrayList<Integer>();
        Scanner stdIn = new Scanner(System.in);
        while (stdIn.hasNext()) {
            list.add(stdIn.nextInt());
        }
        algorith(list.get(0), list.get(1), 2);
    }

    private static void algorith(Integer A, Integer B, int index) {
        int SumA = 0;
        int SumAB = 0;
        List<Integer> listA = new ArrayList<>();
        List<Integer> listB = new ArrayList<>();
        List<Integer> listAB = new ArrayList<>();
        if (list.size() < (A + B + index + 2)) {
            return;
        }
        for (int i = index; i < (A + B + index); i++) {
            SumAB += list.get(i);
            listAB.add(list.get(i));
        }
        if (SumAB % 2 == 0) {
            for (int j = 0; j < A; j++) {
                listA.add(listAB.get(j));
                SumA += listA.get(j);
            }
            for (int k = A; k < listAB.size(); k++) {
                listB.add(listAB.get(k));
            }
            Collections.sort(listA);
            Collections.sort(listB);
            int tb = SumAB / 2;
            int freg = 0;
            boolean brkFlg = false;
            if (SumA <= tb) {
                freg = tb - SumA;
                for (int i = 0; i < listA.size(); i++) {
                    for (int j = 0; j < listB.size(); j++) {
                        if (listA.get(i) + freg == listB.get(j)) {
                            System.out.println(listA.get(i) + " " + listB.get(j));
                            algorith(list.get(A + B + index), list.get(A + B + index + 1), (A + B + index + 2));
                            return;
                        }
                    }
                }

                System.out.println(-1);
                algorith(list.get(A + B + index), list.get(A + B + index + 1), (A + B + index + 2));
            } else {
                freg = SumA - tb;
                for (int i = 0; i < listA.size(); i++) {
                    for (int j = 0; j < listB.size(); j++) {
                        if (listA.get(i) - freg == listB.get(j)) {
                            System.out.println(listA.get(i) + " " + listB.get(j));
                            algorith(list.get(A + B + index), list.get(A + B + index + 1), (A + B + index + 2));
                            return;
                        }
                    }
                }
                System.out.println(-1);
                algorith(list.get(A + B + index), list.get(A + B + index + 1), (A + B + index + 2));
            }
        } else {
            System.out.println(-1);
            algorith(list.get(A + B + index), list.get(A + B + index + 1), (A + B + index + 2));
        }
    }
}



Measured memory_bytes: 29720
N, K = [int(_c) for _c in input().split(" ")]
S_orig = input()
point_list = []
for target, non_target in zip(["L", "R"], ["R", "L"]):
    S = list(S_orig)

    start_idx_list = []
    before_char = None
    for i, c in enumerate(S):
        if i == 0:
            start_idx_list.append(i)
            before_char = c
        else:
            if before_char == non_target and c == target:
                start_idx_list.append(i)
            before_char = c
    start_idx_list.append(len(start_idx_list) - 1)
    if len(start_idx_list) - 1 <= K:
        point_list.append(len(S) - 1)
        continue

    longest = 0
    start_idx = -1
    end_idx = -1
    for i in range(len(start_idx_list) - K):
        cur_length = start_idx_list[i + K] - start_idx_list[i] + 1
        if cur_length > longest:
            start_idx = start_idx_list[i]
            end_idx = start_idx_list[i + K]
            longest = cur_length

    for _idx in range(start_idx, end_idx):
        S[_idx] = target
    S = ["N"] + S + ["N"]

    point = 0
    for idx in range(1, N + 1):
        if S[idx] == "L":
            if S[idx + 1] == "L":
                point += 1
        if S[idx] == "R":
            if S[idx - 1] == "R":
                point += 1

    point_list.append(point)

print(max(point_list))

Measured memory_bytes: 7612
#include <iostream>
#include <queue>
#include <algorithm>
#include <set>
#include <vector>
#include <string>

using namespace std; using ll=long long; const int INF=1e9; using P=pair<ll,ll>;

int main() {
  int n; cin>>n;
  set<string> s;
  for(int i=0;i<n;i++) {
    string t; cin>>t; s.insert(t);
  }
  cout<<s.size()<<endl;
}

Measured memory_bytes: 19260
N=int(input())
T,A=(int(i) for i in input().split())
Hlist=[int(i) for i in input().split()]
Temp=[T-0.006*Hlist[i] for i in range(N)]
dif=[abs(A-Temp[j]) for j in range (N)]
print(dif.index(min(dif))+1)

Measured memory_bytes: 3060
#include <stdio.h>

int main(void)
{

	int w, n;
	int i;
	int ans[33];
	int a, b;
	int temp;

	scanf("%d", &w);
	scanf("%d", &n);

	for (i = 1; i <= w; i++){
		ans[i] = i;
	}


	for (i = 0; i < n; i++){
		scanf("%d,%d", &a, &b);
		temp = ans[a];
		ans[a] = ans[b];
		ans[b] = temp;
	}

	for (i = 1; i <= w; i++){
		printf("%d\n", ans[i]);
	}

	return (0);
}


			

Measured memory_bytes: 596
// url: http://tenka1-2017-beginner.contest.atcoder.jp/tasks/tenka1_2017_b

import std.algorithm, std.conv, std.range, std.stdio, std.string;

void main()
{
  auto n = readln.chomp.to!size_t;

  auto maxA = 0, maxB = 0;
  foreach (_; 0..n) {
    auto rd = readln.split.to!(int[]), a = rd[0], b = rd[1];
    if (a > maxA) {
      maxA = a;
      maxB = b;
    }
  }

  writeln(maxA + maxB);
}


Measured memory_bytes: 1276
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int price = b;
		if(a <13){
			price = b / 2;
		}
		if(a < 6){
			price = 0;
		}
		System.out.println(price);
	}
	
}


Measured memory_bytes: 23124
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <limits.h>
#include <stdbool.h>

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

//qsort(str, n, sizeof(int), up_comp);
int up_comp(const void *a, const void *b){return *(int*)a - *(int*)b;}
int down_comp(const void *a, const void *b){return *(int*)b - *(int*)a;}
int int_sort( const void * a , const void * b ) {return strcmp(( char * )a , ( char * )b );}
int count_digit(int a){int i=0;while(a!=0){a=a/10;i++;}return i;}
int euclid( int a, int b ){int temp;if(a<b){temp=a;a=b;b=temp;}if(b<1)return -1;if(a%b==0) return b;return euclid(b,a%b);}

int main(void){
 
    int a, b, ans;
    
    scanf("%d%d", &a, &b);
    
    if ((a+b)%2==0) {
        ans=(a+b)/2;
    } else {
        ans=1+(a+b)/2;
    }
    
    printf("%d", ans);
    
    return 0;
}



Measured memory_bytes: 1724
#include<iostream>
using namespace std;
int main() {
  int a,b,c;
  cin >> a >> b >> c;
  if(a + b == c || b + c == a || c + a == b){
    cout << "Yes" << endl;
  }else {
    cout << "No" <<endl;
  }
  return 0;
}

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

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

  vector<ll> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }

  int zero = 0;
  for (int i = 0; i < N; i++) {
    if (A.at(i) == 0) {
      zero++;
    }
  }
  // N個の正数の中に 0 が含まれる
  if (zero > 0) {
    cout << 0 << endl;
    return 0;
  }

  // 64bit
  // 10**19 < 2**64 < 10**20
  ll prod = 1;
  for (int i = 0; i < N; i++) {
    // prod * A.at(i) <= 10**18 で比較を行う場合、
    // 左辺の prod * A.at(i) の計算結果が long long 型の扱える範囲を
    // 超える可能性がある。
    //
    // A.at(i) <= 10**18 / prod の除算で比較を行うことにより、
    // オーバーフローを回避する。
    //
    // prod * A.at(i) の計算結果がオーバフローするような入力例の場合、
    // 事前に if 文の A.at(i) <= 10**18 / prod の判定が false となり、
    // -1 が出力される
    if (A.at(i) <= 1000000000000000000 / prod) {
      prod = prod * A.at(i);
    } else {
      cout << -1 << endl;
      return 0;
    }
  }

  cout << prod << endl;
  return 0;
}

Measured memory_bytes: 4052
#include<bits/stdc++.h>
#include <iostream>
#include <list>
#define ll long long int
using namespace std;
int main()
{
    int t,m,i,cnt=0;
    while(1)
    {
        cin>>t;cnt++;if(t==0)break;
    }
    cout<<cnt<<"\n";
}



Measured memory_bytes: 3596
#include "bits/stdc++.h"
using namespace std;
#define dup(x,y) (((x)+(y)-1)/(y))//result of div + 1
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
	int N;
	int ans = 0;
	int val = 0;
	cin >> N;
	vector<int> H(N);

	rep(i,N)
		cin >> H[i];

	reverse(H.begin(), H.end());

	for (int i = 1; i < N; i++) {
		if (H[i - 1] <= H[i]) {
			val++;
		} else {
			val = 0;
		}
		ans = max(ans, val);
	}
	cout << ans << endl;
}


Measured memory_bytes: 640
#include <cstdio>
#include <cstring>
 
#define BASE (1000000)
typedef long long lint;
 
int main()
{
    int n, m, r;
    int head, tail;
    int i, j;
    static lint ans[20000], temp[20000];
    lint carry;
     
    tail = sizeof(ans) / sizeof(lint) - 1;
     
    scanf("%d%d%d", &n, &m, &r);
     
    if (r - m * n < 0 || n + r - m * n - 1 < 0){
        printf("0\n");
    }
    else {
        head = tail;
        ans[tail] = 1;
         
        //nCkを求める. n!
        for (i = n; i <= n + r - m * n - 1; i++){
            carry = 0;
            for (j = tail; j >= head; j--){
                carry += i * ans[j];
                ans[j] = carry % BASE;
                carry /= BASE;
            }
            while (carry != 0){
                ans[--head] = carry % BASE;
                carry /= BASE;
            }
        }
         
         
        //k!
        for (i = r - m * n; i >= 2; i--){
            memcpy(temp, ans, sizeof(ans));
            carry = 0;
            for (j = head; j <= tail; j++){
                carry = carry * BASE + temp[j];
                ans[j] = carry / i;
                carry %= i;
            }
        }

        while (ans[head] == 0){
            head++;
        }
         
         
        for (i = head; i <= tail; i++){
            if (i != head){
                printf("%06lld", ans[i]);
            }
            else {
                printf("%lld", ans[i]);
            }
        }
        printf("\n");
    }
     
    return (0);
}

Measured memory_bytes: 1268
import java.io.*;
import java.util.*;

public class Main
{
	public static void main(String[] args) throws IOException
	{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
		StringTokenizer st = new StringTokenizer(br.readLine());
		long x = Long.parseLong(st.nextToken()), y = Long.parseLong(st.nextToken());
		int ans = -1;
		if(y >= 0 && y <= x-2)
			ans = 1;
		else if(y >= x-1 && y <= x+1)
			ans = 0;
		else if(y >= x+2)
			ans = 1;
		pw.println(ans == 1 ? "Alice" : "Brown");
		br.close();
		pw.close();
		System.exit(0);
	}
}

Measured memory_bytes: 24788
#include<bits/stdc++.h>
using namespace std;
int main()
{
   string s;
   cin>>s;
   int m=s.size();
   if(m==1&&s=="?")
   {
       cout<<'D'<<endl;
   }
   else
   {
            if(s[0]=='?')
   {
       if(s[1]=='P')
        s[0]='D';
       else
        s[0]='P';
   }

   for(int i=0;i<m;i++)
   {
       if(s[i]=='?')
       {
           if(s[i+1]=='P')
           {
               s[i]='D';

           }
           if(s[i+1]=='D'&&s[i-1]=='D')
           {
               s[i]='P';
           }
           else if(s[i+1]=='D'&&s[i-1]=='P')
           {
               s[i]='D';
           }
           else if(s[i+1]=='?'&&s[i-1]=='D')
              {
                  s[i]='P';
               s[i+1]='D';
              }
           else if(s[i+1]=='?'&&s[i-1]=='P')
           {
               s[i]='D';
               s[i+1]='D';
           }
           else if(s[i+1]=='?'&&s[i-1]=='?')
           {
               s[i-1]='P';
               s[i]='D';
               s[i+1]='D';
           }

       }
   }

   if(s[m-1]=='?')
    s[m-1]='D';
   for(int i=0;i<m;i++)
   {
       cout<<s[i];
   }
   cout<<endl;
   }

}



Measured memory_bytes: 3740
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,x;
  cin >> n >> x;
  int D;
  vector<int> vec(n,0);
  for(int i = 0;i<n;i++){
    cin >> vec[i];
  }
  int count = 0;
  for(int i = 0;i<n;i++){
    D += vec[i];
    if (D > x){
      break;
    }
    if(D <= x){
      count++;
    }
  }
  cout << count+1;
}

Measured memory_bytes: 256