akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<string>
#include<math.h>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<map>
#include<numeric>
#include<stack>
#include<queue>
#include<functional>
#include<cassert>
#include<set>
#define rep(a,b) for(ll a=0;a<b;++a)
#define REP(a,b,c,d) for(ll a=b;a<c;a+=d)
#define yes cout<<"Yes"<<endl
#define no cout<<"No"<<endl
#define mod 1000000007
using namespace std;
using ll = long long;
using p_i = pair<int, int>;
int main() {
	int N, M, K, A, ans = 0; cin >> N >> M;
	vector<int> food(30, 0);
	rep(i, N) {
		cin >> K;
		rep(j, K) {
			cin >> A;
			++food[A - 1];
		}
	}
	rep(i, M) {
		if (food[i] == N)++ans;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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

const ll mod=1e9+7;

int main(){
    ll Q;
    cin >> Q;
    vector<ll> p(100001),q(100001),sum(100001);
    for(ll i=2;i<=100000;i++){
        if(p[i]==0){
            q[i]=1;
            for(ll j=i;j<=100000;j+=i){
                p[j]=1;
            }
        }
    }
    for(ll i=3;i<=100000;i++){
        if(q[i]==1 && q[(i+1)/2]==1){
            sum[i]=1;
        }
    }
    rep(i,100000){
        sum[i+1]+=sum[i];
    }
    rep(i,Q){
        ll l,r;
        cin >> l >> r;
        l--;
        cout << sum[r]-sum[l] << endl;
    }
}


Measured memory_bytes: 5544
import numpy as np
n,m = map(int,input().split())
x = []
for _ in range(m):
  k = list(map(int,input().split()))
  x.append(k[1:])
p = list(map(int,input().split()))
count = 0
for i in range(2**n):
  code = "0"*(n-len(bin(i))+3) + bin(i)[2:]
  c = np.array([])
  for j in range(n+1):
    c = np.append(c,int(code[j]))
  for i in range(m):
    if int(sum(c[x[i]]))%2 != p[i]:
      count += 1
      break
print(2**n - count)

Measured memory_bytes: 12684
A = []
for i in range(3):
    l = list(map(int, input().split()))
    A.extend(l)
N = int(input())
B = [int(input()) for i in range(N)]

bingo = [False for i in range(9)]

for i in range(N):
    if B[i] in A:
        a_index = A.index(B[i])
        bingo[a_index] = True

ans = False

#横３pattern
#if all([A[i*3], A[i*3 + 1], A[i//3 + 2] for i in range(3)]):
for i in range(3):
    if all([bingo[i*3], bingo[i*3 + 1], bingo[i*3 + 2]]):
        ans = True
#縦３pattern
#if all([A[i*3 + i], A[(i+1)*3 + i], A[(i+1)*3 + i] for i in range(3)]):
for i in range(3):
    if all([bingo[i], bingo[3 + i], bingo[6 + i]]):
        ans = True
#斜め2pattern
if all([bingo[0], bingo[4], bingo[8]]) or all([bingo[2], bingo[4], bingo[6]]):
    ans = True
print("Yes") if ans else print("No")


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair <int, int>;
const double PI = acos(-1);
const ll MOD = 1000000007;

int main() {
  vector<char> alpha = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
  ll N;
  cin >> N;
  vector<char> m(10);
  ll now = N;

  rep(i, 15){
    int r = now % 26;
    //cout << now << endl;
    if(now > 0) {
      if(r != 0){
        m[i] = alpha[r-1];
        now /= 26;
      }
      else{
        m[i] = 'z';
        now =  now / 26 -1;
      }
    }
    else m[i] = '1';
  }

  rep(i,15) {
    if(m[14-i] != '1' )cout << m[14-i];
  }
  cout << endl;


}


Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
int main(){
  int A,B,C,D;
  cin>>A>>B>>C>>D;
  int sum=0;

  for(int i=C;i<=D;i++){
    for(int j=A;j<=B;j++){
      if(i==j){
sum++;
      }
    }
  }
  if(sum==0){
cout<<sum<<endl;
  }
  else{
    cout<<sum-1<<endl;
  }

}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.TreeMap;
import java.util.StringTokenizer;
import java.util.Map;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
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);
        EThisMessageWillSelfDestructIn5s solver = new EThisMessageWillSelfDestructIn5s();
        solver.solve(1, in, out);
        out.close();
    }

    static class EThisMessageWillSelfDestructIn5s {
        public void solve(int testNumber, Scanner sc, PrintWriter pw) {
            int n = sc.nextInt();
            int[] arr = new int[n];
            for (int i = 0; i < n; i++) {
                arr[i] = sc.nextInt();
            }
            TreeMap<Integer, Integer> tm = new TreeMap<>();
            long ans = 0;
            for (int i = 0; i < n; i++) {
                if (tm.containsKey(i - arr[i])) {
                    ans += 1l * tm.get(i - arr[i]);
                }
                tm.put(i + arr[i], tm.getOrDefault(i + arr[i], 0) + 1);
            }
            pw.println(ans);
        }

    }

    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(FileReader r) {
            br = new BufferedReader(r);
        }

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 59068
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
using namespace std;
ll power(ll a,ll n)
{
          ll result=1;
          while(n>0)
          {
               if(n&1)
                    result=result*a;
               a=a*a;
               n=n>>1;
          }
          return result;
}
ll lcm(ll a,ll b)
{
          return ((a*b)/__gcd(a,b));
}
bool ispow2(ll n)
{
          return (ceil(log2(n))==floor(log2(n)));
}
bool isprime(ll n)
{
          if(n==1)
               return false;
          else if(n==2)
               return true;
          else
          {
               for(ll i=2;i*i<=n;++i)
               {
                    if(n%i==0)
                         return false;
               }
               return true;
          }
}

ll ncr(ll n,ll r)
{
    if(r > n - r)
          r = n - r;
    ll ans = 1;
    ll i;

    for(i = 1; i <= r; i++)
     {
        ans *= n - r + i;
        ans /= i;
    }

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

          int t=1;
          //cin>>t;
          while(t--)
          {
                    int n;
                    cin>>n;
                    int a[n];
                    for(int  i=0;i<n;++i)
                         cin>>a[i];
                    set<pair<pair<int,int>,int>>s;
                    ll ans=0;
                    for(int i=0;i<n-2;++i)
                    {
                         for(int j=i+1;j<n-1;++j)
                         {
                              for(int k=j+1;k<n;++k)
                              {
                                        int b[3];
                                        b[0]=a[i];
                                        b[1]=a[j];
                                        b[2]=a[k];
                                        sort(b,b+3);
                                        if(b[0]+b[1]>b[2] && b[0]!=b[1] && b[1]!=b[2] && b[0]!=b[2])
                                             ans++;

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


Measured memory_bytes: 3668
#include <vector>
#include<stdio.h>
#include<string.h>
#include <cstring>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <set>
#include<cstring>
#define Max 0x3F3F3F

#define ll long long
#define MODD 1000000007
#define  pii  pair<int,int>

#include<stdio.h>
#include<queue>
//#include<bits/stdc++.h>
using namespace std;
char ch[10000]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};

int main() {
   int n;cin >>n;
    string s ;cin>>s;
    int len  = s.length();
    for(int i=0;i<len;i++){
        cout<<ch[(s[i]-'A'+n)%26];
    }
    cout<<endl;
    return 0;
}
/*
5 300
4 200
4 100
3 156
3 44
2 100
*/


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

int main(){
    int n; cin >> n;
    vector<int> a(n);
    rep(i ,n) cin >> a[i];
    a.erase(unique(a.begin(),a.end()),a.end());
    rep(i ,a.size() - 1) cout << a[i] << " ";
    cout << a[a.size() - 1] << endl;
}


Measured memory_bytes: 3084
#include<bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define Yes cout<<"Yes"<<endl 
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl 
#define no cout<<"no"<<endl
#define vec(a,y,x)  vector<vector<char>> a (y,vector<char>(x))
const vector<int> dx={1,0,-1,0};
const vector<int> dy={0,1,0,-1};

in kansu(in x,in k){
  if(x%k==0) return 0;
  if(x>k) return kansu(x%k,k);
  in next_x = k-x;
  if(next_x>x) return x;
  return kansu(next_x,k);
}



int main(){
  int64_t n;
  int64_t k;
  cin>>n>>k;
  cout<<kansu(n,k)<<endl;
  
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}

func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	n := iScan()
	d := iScan()
	x := iScan()
	a := iSScan(n)
	for _, v := range a {
		x += (d-1)/v + 1
	}
	fmt.Println(x)
}


Measured memory_bytes: 1776
// This file is a "Hello, world!" in C++ language by GCC for wandbox.
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>

//this code is fake. I should have devided the arrays like two buffering. 

using namespace std;

int func(int x, int y, int h, int w, string *s){
    if(s[x][y]=='#')
        return 0;
    
    bool diff=true;
    int cnt=-1;
    s[x][y]='0';
    while(diff){
        diff = false;
        cnt ++;
        for(int i=0; i<h;i++){
            for(int j=0; j<w; j++){
                if(s[i][j]==char('0'+cnt)){
                    if(i-1>=0)
                    if(s[i-1][j]=='.'){
                        s[i-1][j]=('0'+cnt+1);
                        diff = true;
                    }
                    if(i+1<=h-1)
                    if(s[i+1][j]=='.'){
                        s[i+1][j]=('0'+cnt+1);
                        diff = true;
                    }
                    if(j-1>=0)
                    if(s[i][j-1]=='.'){
                        s[i][j-1]=char('0'+cnt+1);
                        diff = true;
                    }
                    if(j+1<=w-1)
                    if(s[i][j+1]=='.'){
                        s[i][j+1]=char('0'+cnt+1);
                        diff = true;
                    }
                }
            }
        }  
    }

    return cnt;
}


int main()
{
    int h,w;
    char c;
    string str;
    cin >> h >> w;

    string s[h];

    for(int i=0; i<h;i++){
        cin >> str;
        s[i]=str;
    }

    string aaa[h];

    int ans=0;

    for(int i=0; i<h;i++){
        for(int j=0; j<w; j++){
            //copy s to aaa
            for(int l=0; l<h; l++){
                aaa[l]=s[l];
            }        
            
            //start is (i,j). if it is '#', break
            int longest = func(i,j,h,w,aaa);
            //cout << longest << endl;
            ans = max(ans, longest);
        }
    }


    cout << ans <<  endl;
}

// GCC reference:
//   https://gcc.gnu.org/

// C++ language references:
//   https://cppreference.com/
//   https://isocpp.org/
//   http://www.open-std.org/jtc1/sc22/wg21/

// Boost libraries references:
//   https://www.boost.org/doc/


Measured memory_bytes: 256
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;

class Solution {
public:
    int solve(int n, int K) {
        const long long MOD = 1000000007;

        int N = n * (n + 1);
        int M = (n + 1) / 2;
        vector<vector<long long>> dp(M + 1, vector<long long>(N + N + 1, 0));
        dp[0][N] = 1;
        auto ndp = dp;
        for (int i = 1; i <= n; ++i) {
            for (auto& V : ndp) {
                fill(V.begin(), V.end(), 0);
            }
            for (int j = 0; j < i && j <= M; ++j) {
                for (int k = 0; k <= N * 2; ++k) {
                    if (j > 0) {
                        int nj = j - 1;
                        int nk = k + i + i;
                      
                        if (nk <= 2 * N) {
                            (ndp[nj][nk] += dp[j][k] * j % MOD * j % MOD) %= MOD;
                        }

                        nj = j;
                        nk = k;
     
                        (ndp[nj][nk] += dp[j][k] * 2 * j % MOD) %= MOD;
                    }

                    (ndp[j][k] += dp[j][k]) %= MOD;

                    {
                        int nj = j + 1;
                        int nk = k - 2 * i;
                        if (nj <= M && nk >= 0) {
                            (ndp[nj][nk] += dp[j][k]) %= MOD;
                        }
                    }                    
                }
            }
            swap(ndp, dp);
        }

        return dp[0][N + K];
    }

    int test (int n, int k) {
        vector<int> P(n, 0);
        iota(P.begin(), P.end(), 1);

        int res = 0;
        do {
            int sum = 0;
            for (int i = 0; i < n; ++i) {
                sum += abs(P[i] - i - 1);
            }
            if (sum == k) {
                ++res;
                for (int i = 0; i < n; ++i) {
                    cout << (i + 1) << ":" << P[i] << " ";
                }
                cout << endl;
            }
        } while (next_permutation(P.begin(), P.end()));
        return res;
    }
};

int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin >> n;
    int k;
    cin >> k;
    Solution sol;
    cout << sol.solve(n, k) << "\n";

    return 0;
}

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

#define rep(i, a) for (int i = 0; i < (a); i++ )
#define FOR(i, m, n) for(int i = m; i < n; i++)
 
typedef pair<int,int> P;
typedef long long ll;
 
const int INF = 1001001001;
const int MOD = 1000000007;
const double PI=acos(-1);

int main(){
    ll A,B,N;
    cin >> A >> B >> N;

    if (B>N) {
        ll ans = (A*N)/B - A*(N/B);
        cout << ans << endl;
    }
    else {
        ll ans = (A*(B-1))/B-A*((B-1)/B);
        cout << ans << endl;
    }
}


Measured memory_bytes: 3588
#include<stdio.h>

#define M 100
#define W 0
#define G 1
#define B 2
#define I 2097152


int main(){
	int d[M],color[M],MIMI[M][M];
	int n,i,j,e;
	int min,u,v,sum;
	int k,c,s,t;

	//nyu
	scanf("%d",&n);

	//nyu
	for(i=0;i<n;i++){
		for(j=0;j<n;j++){
			MIMI[i][j]=I;
		}
	}

	for(i=0;i<n;i++){
		scanf("%d %d",&s,&k);
		for(j=0;j<k;j++){
			scanf("%d %d",&t,&c);
			MIMI[s][t]=c;
		}
	}




		//kansu
	for(i=0;i<n;i++){
		color[i]=W;
		d[i]=I;
	}
	d[0]=0;

	while(1){
		min=I;
		u=-1;

		for(i=0;i<n;i++){
			if(min>d[i]&&color[i]!=B){
				u=i;
				min=d[i];
			}
		}

		if(u==-1)
			break;

		color[u]=B;

		for(v=0;v<n;v++){
			if(color[v]!=B&&MIMI[u][v]!=I){
				if(d[v]>d[u]+MIMI[u][v]){
					d[v]=d[u]+MIMI[u][v];
					color[v]=G;
				}
			}
		}
	}

	for(i=0;i<n;i++){
		printf("%d %d\n",i,d[i]==I?-1:d[i]);
	}

	return 0;
}




Measured memory_bytes: 2040
H, W = map(int, input().split())
N = int(input())
a = list(map(int, input().split()))
 
i = 0

for x in range(H):
    c = []
    for y in range(W):
        c.append(i + 1)
        a[i] -= 1
        if a[i] == 0:
            i += 1
            
    if x % 2 == 0:
        print(*c)
        print()
    else:
        print(*c[::-1])
        print()

Measured memory_bytes: 3700
class Dice:
    def __init__(self):
        self.u=1
        self.w=2
        self.s=3
        self.e=4
        self.n=5
        self.d=6
        self.dic={"W":0,"S":1,"E":2,"N":3}
     
    def __init__(self,u,w,s,e,n,d):
        self.u=u
        self.w=w
        self.s=s
        self.e=e
        self.n=n
        self.d=d
        self.dic={"W":0,"S":1,"E":2,"N":3}
 
    def rot(self,way):
        if isinstance(way,str):
            way=self.dic[way]
 
        if(way==0):
            c=self.u
            self.u=self.e
            self.e=self.d
            self.d=self.w
            self.w=c
        elif way==1:
            c=self.u
            self.u=self.n
            self.n=self.d
            self.d=self.s
            self.s=c
        elif way==2:
            c=self.u
            self.u=self.w
            self.w=self.d
            self.d=self.e
            self.e=c
        else :
            c=self.u
            self.u=self.s
            self.s=self.d
            self.d=self.n
            self.n=c
 
import random
u,s,e,w,n,d=map(int,input().split())
dice=Dice(u,w,s,e,n,d)
q=int(input())
for i in range(q):
    a,b=map(int,input().split())
    while True:
        dice.rot(random.randint(0,3))
        if(dice.u==a and dice.s==b):
            print(dice.e)
            break


Measured memory_bytes: 8188
import std.stdio, std.algorithm, std.conv, std.array;

auto readLine(T=int)() {
    return readln().split.map!(to!T).array;
}

auto lowerBound_(R, T)(R sorted, T value) {
    size_t left = 0;
    size_t right = sorted.length;
    while(right - left != 0) {
        auto mid = (right + left) / 2;
        if (sorted[mid] < value) {
            left = mid + 1;
        } else {
            right = mid;
        }
    }
    return sorted[0 .. right];
}

unittest {
    assert([1, 2, 3, 5].lowerBound_(4) == [1, 2, 3]);
    assert([1, 2, 3, 5].lowerBound_(3) == [1, 2]);
    assert([1, 2, 3, 5].lowerBound_(1) == []);
    assert([1, 2, 3, 5].lowerBound_(6) == [1, 2, 3, 5]);
}

void main() {
    int n;
    readf("%d\n", &n);
    auto L = readLine().sort;
    int ans = 0;
    foreach (ai; 0 .. n) {
        foreach (bi; ai + 1 .. n) {
            // find a list of c that satisfies c < a + b
            auto lb = L[bi + 1 .. $].lowerBound_(L[ai] + L[bi]);
            ans += lb.length;
        }
    }
    writeln(ans);
}


Measured memory_bytes: 380
use std::io::*;
use std::str::FromStr;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::cmp::{min, max};

struct Scanner<R: Read> {
    reader: R,
    buffer: String,
}

#[allow(dead_code)]
impl<R: Read> Scanner<R> {
    fn new(reader: R) -> Scanner<R> {
        Scanner { reader: reader, buffer: String::new() }
    }

    // fn line(&mut self) -> String {
    //     self.buffer = self.reader.by_ref().bytes().map(|c| c.unwrap() as char)
    //         .skip_while(|&c| c == '\n' || c == '\r')
    //         .take_while(|&c| !(c == '\n' || c == '\r'))
    //         .collect::<String>();
    //     self.buffer.clone()
    // }

    fn read_buffer(&mut self) {
        self.buffer = self.reader.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
    }

    fn safe_read<T: FromStr>(&mut self) -> Option<T> {
        self.read_buffer();
        if self.buffer.is_empty() {
            None
        } else {
            self.buffer.parse::<T>().ok()
        }
    }

    fn read<T: FromStr>(&mut self) -> T {
        if let Some(s) = self.safe_read() {
            s
        } else {
            writeln!(std::io::stderr(), "Terminated with EOF").unwrap();
            std::process::exit(0);
        }
    }

    fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.read()).collect()
    }

    fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }
}

trait Joinable {
    fn join(self, sep: &str) -> String;
}

impl<U: ToString, T: Iterator<Item=U>> Joinable for T {
    fn join(self, sep: &str) -> String {
        self.map(|x| x.to_string()).collect::<Vec<_>>().join(sep)
    }
}

fn main() {
    std::thread::Builder::new()
        .stack_size(104_857_600)
        .spawn(solve)
        .unwrap()
        .join()
        .unwrap();
}

fn solve() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    let n = sc.read();
    let mut list: VecDeque<u32> = VecDeque::with_capacity(n);

    for _ in 0..n {
        let com: String = sc.read();
        match com.as_str() {
            "insert" => {
                let x = sc.read();
                list.push_front(x);
            },
            "delete" => {
                let x: u32 = sc.read();
                let pos = list.iter().position(|&e| e == x).unwrap_or(list.len());
                let mut tail = list.split_off(pos);
                tail.pop_front();
                list.append(&mut tail);
            },
            "deleteFirst" => {
                list.pop_front();
            },
            "deleteLast" => {
                list.pop_back();
            },
            _ => panic!(),
        }
    }

    println!("{}", list.iter().join(" "));
}



Measured memory_bytes: 21304
#include <stdio.h>

int main(void)
{
	int n;
	int debt;

	scanf("%d", &n);
	debt = 100000;
	while (n--){
		debt *= 1.05;
		debt = ((debt + 999) / 1000) * 1000;
	}
	printf("%d\n", debt);

	return (0);
}

Measured memory_bytes: 588
#include<iostream>
using namespace std;
int main() {
	int face_a[6] = {}, face_b[6] = {}, dice[6][7] = { {1,2,4,3,1,2,4},{0,3,5,2,0,3,5,},{0,1,5,4,0,1,5},{0,4,5,1,0,4,5},{0,2,5,3,0,2,5},{1,3,4,2,1,3,4} };
	for (int i = 0; i < 6; i++) {
		cin >> face_a[i];
	}
	for (int i = 0; i < 6; i++) {
		cin >> face_b[i];
	}
	int a = 0;
	while (true) {
		if (face_b[0] == face_a[a]) break;
		a += 1;
	}
	int b = 0;
	while (true) {
		if (face_b[1] == face_a[b]) break;
		b += 1;
	}
	int c = 0;
	while (true) {
		if (dice[a][c] == b) break;
		c += 1;
	}
	if (face_a[dice[a][c + 1]] == face_b[2] && face_a[dice[a][c + 3]] == face_b[3] && face_a[dice[a][c + 2]] == face_b[4]) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 3096
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size1,init=nil,size2=-1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

N,M=get_i
A=get_i
sum=A.inject(:+)
if N<sum
    puts -1
else
    puts N-sum
end

Measured memory_bytes: 14816
//07, 07, 2018, 09:30:31 Rafaelcs cpp
#include <bits/stdc++.h>

using namespace std;
typedef pair<int, int> pii;
typedef long double ld;
typedef long long ll;

typedef unsigned long long ull;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    
    ld n, m, d;

    cin >> n >> m >> d;

    ld h = n - d;
    ld mean = ((h * (m - 1LL)) / n) / n;
    
    if(d != 0LL){
        cout << fixed << setprecision(10) << (2.0L * mean) << endl;
    }else{
        cout << fixed << setprecision(10) << mean << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce
#from fractions import gcd
#from math import gcd
import sys
def I(): return int(input())
def Is(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(input())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = float('inf')


n, k = Is()
s = S()

contl = 0
contr = 0
sandl = 0
sandr = 0


for i in range(1, n):
    if s[i-1] == s[i] == "L":
        contl += 1
    if s[i-1] == s[i] == "R":
        contr += 1

ans = min(n-1, contl+contr+k*2)
print(ans)

Measured memory_bytes: 39792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E17;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
///////////////////////////////////////



int main(){fastio
    ll n,m;cin>>n>>m;
    if(n>m)swap(n,m);
    if(n==1){
        if(m==1)cout<<1<<endl;
        else cout<<m-2<<endl;
        return 0;
    }
    cout<<(n-2)*(m-2)<<endl;
    
    return 0;
}



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

const int N = 300005, mod = 1000000007;

const std::vector<int> trans[2] = {
	{1, 2, 1, 4, 5, 4, 6, },
	{3, 0, 1, 6, 3, 4, 6, },
};

void reduce(int &x) { x += x >> 31 & mod; }

int dp[7], g[7];

int main() {
	std::ios::sync_with_stdio(0), std::cin.tie(0);
	std::string s; std::cin >> s, dp[0] = 1;
	for (char ch : s) {
		for (int i = 0; i < 7; ++i) g[i] = 0;
		for (int i = 0; i < 7; ++i) {
			if (ch != '1') reduce(g[trans[0][i]] += dp[i] - mod);
			if (ch != '0') reduce(g[trans[1][i]] += dp[i] - mod);
		}
		for (int i = 0; i < 7; ++i) dp[i] = g[i];
	}
	std::cout << (dp[3] + dp[6]) % mod;
	return 0;
}

Measured memory_bytes: 720
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
# ifdef __GNUC__
# if __cplusplus > 199711L
# include <unordered_set>
# include <unordered_map>
# else
# include <tr1/unordered_map>
# include <tr1/unordered_set>
using namespace tr1;
# endif
# else
# include <unordered_map>
# include <unordered_set>
# endif
using namespace std;

#define fi first
#define se second
#define FO(x, n) for (int x = 0; x < n; ++x)
#define FOR(x, a, b) for (int x = a; x < b; ++x)
#define RFO(x, n) for (int x = n - 1; x >= 0; --x)
#define RFOR(x, a, b) for (int x = b - 1; x >= a; --x)
typedef unsigned char byte;
typedef unsigned int uint;
typedef long long llong;
typedef unsigned long long ullong;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<llong, llong> pll;
inline bool feq(const double& a, const double& b) { return fabs(a - b) < 1e-10; }

const int MAXN = 200200;
int N;

int main()
{
	while (cin >> N)
	{
		deque<int> res;
		FO(i, N)
		{
			int val;
			cin >> val;
			if (i & 1)
				res.push_front(val);
			else
				res.push_back(val);
		}
		if (N & 1)
			reverse(res.begin(), res.end());
		auto it = res.begin();
		cout << *it;
		++it;
		for (; it != res.end(); ++it)
			cout << " " << *it;
	}
	return 0;
}

Measured memory_bytes: 2944
N = int(input())
L = sorted([int(i) for i in input().split()])
count = 0

from bisect import bisect_left as bi

for j in range(N):
    for k in range(j + 1,N - 1):
        right = L[j] + L[k]
        ite_right = bi(L,right)
        count = count + (ite_right - k - 1)

print(count) 

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

using namespace std;

const int mod = 1000 * 1000 * 1000 + 7;

int main() {
    int h, w;
    cin >> h >> w;
    vector<string> a(h);
    for (int i = 0; i < h; ++i) {
        cin >> a[i];
    }
    vector<vector<int>> dp(h, vector<int>(w));
    dp[0][0] = 1;
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            if ((i == 0 && j == 0) || a[i][j] == '#')continue;
            if (i - 1 >= 0)dp[i][j] += dp[i - 1][j];
            dp[i][j] %= mod;
            if (j - 1 >= 0)dp[i][j] += dp[i][j - 1];
            dp[i][j] %= mod;
        }
    }
    cout << dp[h - 1][w - 1] << endl;
}

Measured memory_bytes: 5248
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;int p[10001],M=10001,i,j,c;vector<int>s(1,0);main(){for(i=1;++i<M;)for(j=i+i;j<M;j+=i)p[j]=1;for(i=1;++i<M;)if(!p[i])s.push_back(i+s.back());for(;cin>>j,j;cout<<c<<endl){vector<int>::iterator t=s.begin();for(c=0;t!=s.end();t++)c+=binary_search(t,s.end(),*t+j);}}

Measured memory_bytes: 1272
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
 
#include<bits/stdc++.h>
 
using namespace std;
#define ll long long
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define ins insert
#define ull unsigned long long
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define ff first
#define ss second
#define fast ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0); 
#define nl "\n"
#define sz(a) (int)(a).size() 
#define all(a) (a).begin(),(a).end()
#define fl(a,x) memset(a,x,sizeof(a));
#define pt(a,x) cout << get<x>(a) << " " ;  
#define mt make_tuple 
 
#define int long long 
 
const int mod = (int) 1e9 + 7 ;
const int MOD = (int) 998244353 ;
const int INF = (int) 1e18 ;
 
typedef vector<int> vii;
typedef pair<int,int> pii;
typedef vector<pii> vpi;
typedef vector<vector<int> > vv;
 
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
 
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

const int N = 1e5 + 5;
int dp[105][N];
int a[105];

void solve() {
	
	int n,k; cin >> n >> k;

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

	dp[0][0] = 1; 
	// for(int i = 0 ; i <= min(a[0] , k) ; ++i) dp[0][i] = 1;

	rep(i,1,n+1) {
		int ps[k+1] = {} ;
		rep(j,0,k+1) {
			ps[j] = dp[i-1][j] % mod; 
			if(j) ps[j] = (ps[j] + ps[j-1] ) % mod;
		}
		rep(j,0,k+1) {
			int t = j - a[i] - 1;
			if( t >= 0 ) dp[i][j] = (ps[j] - ps[t] + mod) % mod;
			else dp[i][j] = ps[j] % mod ;
		}
	}

	// rep(i,0,n) {
	// 	rep(j,0,k+1) cout <<dp[i][j] << " " ; cout << nl ;
	// }

	cout << dp[n][k] % mod ;
}
 
int32_t main() {
   
 
    fast; 
	int t=1;
	// cin>>t;
	rep(i,0,t) {
		solve() ;
	}
 
	// cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}

Measured memory_bytes: 80128
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#include <bits/stdc++.h>
using namespace std;
template<class t> inline t read(t &x){
	char c=getchar();bool f=0;x=0;
	while(!isdigit(c)) f|=c=='-',c=getchar();
	while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
	if(f) x=-x;return x;
}
template<class t,class ...A> inline void read(t &x,A &...a){
	read(x);read(a...);
}
template<class t> inline void write(t x){
	if(x<0) putchar('-'),write(-x);
	else{if(x>9) write(x/10);putchar('0'+x%10);}
}

#define int long long

const int mod=1e9+7,N=5e5+5,M=(1<<20)+5;
int a[N],f[M][2],ans,n,pre[M],cnt0,cnt;

int fpow(int x,int y){
	int res=1;
	for(;y;y>>=1,x=x*x%mod) if(y&1) res=res*x%mod;
	return res;
}

signed main(){
	read(n);
	for(int i=1;i<=n;i++) read(a[i]),a[i]^=a[i-1],a[i]?1:cnt0++;
	for(int i=1;i<=n;i++) f[a[i]][0]=1;
	for(int i=1;i<n;i++){
		int x=a[i];
		if(x){
			f[x][0]=(f[x][0]+f[x][1]*(cnt-pre[x]))%mod;
			f[x][1]=(f[x][1]+f[x][0])%mod;
			pre[x]=cnt;
		}
		else cnt++;
	}
	if(a[n]) ans=(f[a[n]][0]+f[a[n]][1]*(cnt-pre[a[n]]))%mod;
	else{
		ans=fpow(2,cnt0-1);
		for(int i=1;i<(1<<20);i++) ans=(ans+f[i][1])%mod;
	}
	write(ans);
}

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

int main() {
	int n;
	scanf("%d", &n);
	
	int ans = 0;
	for (int i=1; i<=n; i++) {
		int num = i;
		int res = 0;
		while(num) res++, num/=10;
		ans += res&1;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll inf =1LL << 62;
const ll mod=1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b,const ll &mod) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b,const ll &mod) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b,const ll &mod) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> dice(1,6);
uniform_real_distribution<double> score(0.0,10.0);

int main(void){
    string in; cin >> in;
    int cpos = in.find('C');
    int fpos = in.find('F', cpos);

    if(cpos != -1 and fpos != -1){
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }

    return 0;
}


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

using namespace std;

int main() {
	int n;
	cin >> n;
	string a;
	cin >> a;
	int counter = 0;
	for (int i = 0; i < n; i++) {
		string b;
		cin >> b;
		bool hantei = false;
		while (b.find(a[0]) != string::npos) {
			int p = b.find(a[0]);
			for (int j = 1; ; j++) {
				if (p+(a.size()-1)*j > b.size()-1) {
					break;
				}
				string c = "";
				c += b[p];
				for (int k = 1; k < a.size(); k++) {
					c += b[p+j*k];
				}
				if (a == c) {
					hantei = true;
					counter++;
					break;
				}
			}
			if (hantei) {
				break;
			}
			b = b.substr(p+1);
		} 
	}
	cout << counter << endl;
	return 0;
}

Measured memory_bytes: 1224
#include<iostream>
#include<algorithm>
using namespace std;
int n,a[1<<17],L[1<<17],R[1<<17];
main()
{
	cin>>n;
	for(int i=0;i<n;i++)cin>>a[i];
	L[0]=a[0]==0?1e9:0;
	for(int i=1;i<n;i++)
	{
		L[i]=a[i]==0?1e9:a[i]<0?min(-a[i],max(L[i-1]-1,0)):max(L[i-1]-1,0);
	}
	R[n-1]=a[n-1]==0?1e9:0;
	for(int i=n-1;i--;)
	{
		R[i]=a[i]==0?1e9:a[i]<0?min(-a[i],max(R[i+1]-1,0)):max(R[i+1]-1,0);
	}
	int ans=0;
	for(int i=0;i<n;i++)
	{
		if(a[i]>0)
		{
			ans+=min(a[i],max(L[i],R[i]));
		}
	}
	cout<<ans<<endl;
}



Measured memory_bytes: 4280
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(i=0;i<n;i++)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
int main()
{
    ///"In the name of Allah,most gracious and most merciful"///

    ll i,j,y,count=1,sum=0,n,ans=0;
    string s;
    cin>>s;

    for(i=s.size()-3; i>=0; i-=2)
    {
        string w,q;
        ll x;
        x=i/2;
        w=s.substr(0,x);
        q=s.substr(x+1,x);
        if(w==q)
        {
            y=x+x;
            break;
        }

    }
    cout<<y+2<<endl;

    return 0;
}






Measured memory_bytes: 3488
#include<stdio.h>
#define MAX 300000
char S[MAX+1];
int main(){
	int N,anwx=0,anwy=0,ANW=0;
	scanf("%d",&N);
	scanf("%s",S);
	for(int i=1;i<N;++i)if(S[i]!='W')++anwy;
	for(int i=0;i<N;++i){
		if(i!=0){
			if(S[i-1]!='E')++anwx;
			if(S[i]!='W')--anwy;
		}
		if(i==0)ANW=anwx+anwy;
		if(ANW>anwx+anwy) ANW=anwx+anwy;
	}
	printf("%d",ANW);
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B;
  string op;
  cin >> A; 
  cin >> B;

  if ( A % 2 == 0 ){
    cout << "Even" << endl;
  } else if ( B % 2 == 0 ){
	cout << "Even" << endl;
  } else {
    cout << "Odd" << endl;    
  }
}

Measured memory_bytes: 3632
#include <iostream>
using namespace std;
  
int main()
{
	int H, W, i, j;
	while(1){
    cin >> H >> W;
		if ( W == 0 & H == 0)
			break;
		for (i=0; i<H; i++) {
			for(j=0; j<W; j++) {
				cout <<'#';
			}
			cout << endl;
		}
		cout << endl;
	}
	return 0;
}
	

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

int main(){
    ll N;
    cin >> N;
    vector<ll> a,b;
    if(N%2==0){
        vector<Pll> v;
        rep(i,N/2){
            v.push_back(Pll(i+1,N-i));
        }
        ll n;
        if(N != 4){
            n = 4*v.size();
        }else{
            n = 4*(v.size()-1);
        }
        cout << n << endl;
        rep(i,N/2 - 1){
            cout << v[i%(N/2)].first << " " << v[(i+1)%(N/2)].first << endl;
            cout << v[i%(N/2)].first << " " << v[(i+1)%(N/2)].second << endl;
            cout << v[i%(N/2)].second << " " << v[(i+1)%(N/2)].first << endl;
            cout << v[i%(N/2)].second << " " << v[(i+1)%(N/2)].second << endl;
        }
        if(N != 4){
            cout << v[0].first << " " << v[N/2-1].first << endl;
            cout << v[0].first << " " << v[N/2-1].second << endl;
            cout << v[0].second << " " << v[N/2-1].first << endl;
            cout << v[0].second << " " << v[N/2-1].second << endl;
        }
        /*
        rep(i,N/2){
            if(i%2==0){
                a.push_back(i);
                a.push_back(N-1-i);
            }else{
                b.push_back(i);
                b.push_back(N-1-i);
            }
        }
        cout << a.size()*b.size() << endl;
        rep(i,a.size()){
            rep(j,b.size()){
                cout << a[i]+1 << " " << b[j]+1 << endl;
            }
        }*/
        return 0;
    }else{
        N--;
        vector<Pll> v;
        rep(i,N/2){
            v.push_back(Pll(i+1,N-i));
        }
        ll n;
        if(N != 2){
            n = 4*(v.size());
        }else{
            n = 2;
        }
        cout << n << endl;
        rep(i,N/2 - 1){
            cout << v[i%(N/2)].first << " " << v[(i+1)%(N/2)].first << endl;
            cout << v[i%(N/2)].first << " " << v[(i+1)%(N/2)].second << endl;
            cout << v[i%(N/2)].second << " " << v[(i+1)%(N/2)].first << endl;
            cout << v[i%(N/2)].second << " " << v[(i+1)%(N/2)].second << endl;
        }
            cout << N+1 << " " << v[N/2-1].first << endl;
            cout << N+1 << " " << v[N/2-1].second << endl;
        if(0 != N/2-1){
            cout << N+1 << " " << v[0].first << endl;
            cout << N+1 << " " << v[0].second << endl;
        }
        /*
        rep(i,a.size()){
            cout << N+1 << " " << a[i]+1 << endl;
        }
        rep(i,b.size()){
            cout << N+1 << " " << b[i]+1 << endl;
        }*/
        return 0;
    }
}

Measured memory_bytes: 3644
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "iomanip"
#include "random"

using namespace std;

const long long int MOD = 1000000007;
const long double EPS = 0.00000001;
const long double PI = 3.1415926535897932384626433;

long long int N, M, K, H, W, L, R;

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

	cin >> N >> M;
	while (N) {
		long double dis = 1000;
		for (int i = 0; i <= N; i++) {
			dis = min(dis, abs(sqrt((long double)i*i + (N - i)*(N - i)) - M));
		}
		cout << setprecision(15) << dis << endl;
		cin >> N >> M;
	}
	return 0;
}

Measured memory_bytes: 3200
import java.util.Scanner;


public class Main {
    public static void main(String[] args) {
        Scanner scanner=new Scanner(System.in);
        int a=scanner.nextInt();
        int b=scanner.nextInt();
        int c=scanner.nextInt();
        if(a<=b&&b<=c){
            System.out.println(a+" "+b+" "+c);
        }
        else if(a<=c&&c<=b){
            System.out.println(a+" "+c+" "+b);
        }
        else if(b<=a&&a<=c){
            System.out.println(b+" "+a+" "+c);
        }
         else if(b<=c&&c<=a){
            System.out.println(b+" "+c+" "+a);
        }
         else if(c<=a&&a<=b){
            System.out.println(c+" "+a+" "+b);
        }
         else{
            System.out.println(c+" "+b+" "+a);
        }

}
}

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

int N;
int main(){
  cin >> N;
  vector<int> a(3*N+1, 0);
  for(int i=0; i<3*N; ++i){
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  long long sum =0;
  for(int i=0; i<N; ++i){
    sum += a[2*i+1];
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 1408
#include <stdio.h>
int main(void){
    long long ans = 0;
    long long N;
    int i;
    
    scanf("%lld", &N);
    
    for(i = 1; i <= N; i++){
        //printf("%d\n", i);
        if(i%3 == 0 && i%5 == 0){
            //printf("FizzBuzz\n");
        }else if(i%3 == 0){
            //printf("Fizz\n");
        }else if(i%5 == 0){
            //printf("Buzz\n");
        }else{
            //printf("%d\n", i);
            ans = ans + i;
        }
    }
    printf("%lld\n", ans);
}


Measured memory_bytes: 1716
n,m=map(int,input().split())

#Union-Find木
#par[i]:iの親　deep[i]:iの深さ　size[i]:iの大きさ
par=[i for i in range(n)]
deep=[1]*n
size=[1]*n

#親を見つける
def find(x):
  if par[x]==x:
    return x
  else:
    return find(par[x])

#二つのグループを統合する
def unite(x,y):
  x=find(x)
  y=find(y)
  if x==y:
    return
  if deep[x]<deep[y]:
    par[x]=y
    size[y]+=size[x]
  else:
    par[y]=x
    size[x]+=size[y]
    if deep[x]==deep[y]:
      deep[x]+=1

#xとyが同じグループに属するかどうか
def same(x,y):
  return find(x)==find(y)


for i in range(m):
  a,b=map(int,input().split())
  unite(a-1,b-1)
print(max(size))


  
  



      

Measured memory_bytes: 20112
#include <bits/stdc++.h>
#define rep(i, n) for (ll(i) = 0; (i) < (n); (i)++)
#define all(x) (x).begin(), (x).end()
#define print(x) cout << (x) << endl;

typedef long long ll;
const ll INF = 99999999999999;
const ll MOD = 1000000007;

ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
ll lcm(ll number1, ll number2)
{
    return number1 * number2 / gcd(number1, number2);
}
template <class T>
bool contain(const std::string &s, const T &v)
{
    // contain(to_string(N), '3')
    return s.find(v) != std::string::npos;
}

int ctoi(char c)
{
    if (c >= '0' && c <= '9')
        return c - '0';
    return 0;
}
using namespace std;

int main()
{
    string s;
    char ans = '1';
    ll k;
    cin >> s >> k;

    rep(i, s.size())
    {
        if (s[i] != '1')
        {
            ans = s[i];
            break;
        }
        if (i + 1 == k)
        {
            ans = s[i];
            break;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256