akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<queue>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<cstdlib>
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; }

int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 }, h, w, ans[51][51], cnt, black = 0;
char maze[51][51];

queue<pair<int, int>> q;







int main() {
	cin >> h >> w;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cin >> maze[i][j];
			ans[i][j] = 100000;
			if (maze[i][j] == '#')black++;
			
		}
	}
	ans[0][0] = 1;
	q.push(make_pair(0, 0));
	while (!q.empty()) {
		pair<int, int>p = q.front();
		q.pop();
		if (p.first == h - 1 && p.second == w - 1) {
			cnt = ans[p.first][p.second];
		}
		for (int i = 0; i < 4; i++) {
			int ny = p.first + dy[i];
			int nx = p.second + dx[i];
			if (nx >= 0 && nx < w &&ny >= 0 && ny < h &&maze[ny][nx] == '.'&&ans[ny][nx] == 100000) {
				q.push(make_pair(ny, nx));
				ans[ny][nx] = ans[p.first][p.second] + 1;
			}
		}
	}
	if(ans[h-1][w-1]!=100000)cout <<  h*w-cnt - black << endl;
	else cout << -1 << endl;

	return 0;
}


Measured memory_bytes: 256
using System;
using CompLib.Util;

public class Program
{
    public void Solve()
    {
        var sc = new Scanner();
        int x = sc.NextInt();
        int y = sc.NextInt();

        for (int k = 0; k <= x; k++)
        {
            int t = x - k;
            int l = k * 4 + t * 2;
            if (l == y)
            {
                Console.WriteLine("Yes");
                return;
            }
        }

        Console.WriteLine("No");
    }

    public static void Main(string[] args) => new Program().Solve();
}

namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 27552
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long a, v, b, w, t, i, j, c = 0;
    cin >> a >> v >> b >> w >> t;
    if (a == b)
    {
        cout << "YES" << endl;
        return 0;
    }
    if (a <=b) {
        for (i = 1; i <= t; i++)
        {
            a += v;
            b += w;
            if (a >= b)
            {
                cout << "YES" << endl;
                return 0;
            }

        }
        cout << "NO" << endl;
        return 0;
    }else
    {
         for (i = 1; i <= t; i++)
        {
            a -= v;
            b -= w;
            if (a <= b)
            {
                cout << "YES" << endl;
                return 0;
            }

        }
        cout << "NO" << endl;
        return 0; 
    }
}


Measured memory_bytes: 3596
process.stdin.resume();
process.stdin.setEncoding('utf8');
 
var input_string = "";
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
reader.on('line', (line) => {
  input_string = line;
});
reader.on('close', () => {
  const array = input_string.split(/\s/);
  const a = Number(array[0]);
  const b = Number(array[1]);

  if(a < b){
    console.log('a < b');
  } else if(a > b){
    console.log('a > b');
  } else {
    console.log('a == b');
  }
});




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

int main(){
	int a, b;
	char op[2];
	while(true) {
		scanf("%d%s%d", &a, op, &b);
		if(op[0] == '?') break;
		if(op[0] == '+')
			printf("%d\n", a + b);
		else if(op[0] == '-')
			printf("%d\n", a - b);
		else if(op[0] == '*')
			printf("%d\n", a * b);
		else
			printf("%d\n", a / b);
	}
}



Measured memory_bytes: 3204
#include <bits/stdc++.h>
using namespace std;
#define ll long long
void solve(){
	ll n,B,a,b,count=0,sum=0,f=0;cin>>n>>B;
	vector<ll> vc;
	ll mx=-1;
    for(ll i=1;i<=n;i++)
    {
    	cin>>a>>b;
    	vc.push_back(b);
    	mx=max(a,mx);
    }
    sort(vc.begin(),vc.end(),greater<ll>());
    for(ll i=0;i<vc.size();i++)
    {
    	if(vc[i]>mx)++count,sum+=vc[i];
    	else
    	{
    		ll left=B-sum;// 276=46
    		if(left%mx==0)count+=((left/mx));
    		else count+=(left/mx)+1;
    		f=2;
    		break;
    	}
    	if(sum>=B){f=1;break;}
    	
      }
      
      if(f==0)
      {
      		ll left=B-sum;// 276=46
    		if(left%mx==0)count+=((left/mx));
    		else count+=(left/mx)+1;
    		f=2;
    	    cout<<count<<endl;

      }
      else cout<<count<<endl;
}
 
int32_t main() {
ll t=1;
    while (t--)
        solve();
    return 0;
}

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

using namespace std;

#define debug(x) '[' << #x << " is: " << x << "] "
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.precision(10);
	cout << fixed;
	string s;
	cin>>s;
	sort(all(s));
	cout << (s[0] == s[2] ? "No\n" : "Yes\n");
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int n = Integer.parseInt(br.readLine());
		int even = n / 2;

		if (n % 2 != 0) {
			even++;
		}

		double ans = (double) even / n;

		System.out.println(ans);
	}
}

Measured memory_bytes: 33336
N = int(input())
S = [input() for i in range(N)]
CA= 0
CW= 0
CT=0
CR=0
for i in S:
  if i == "AC":
    CA += 1
  elif i == "WA":
    CW += 1
  elif i == "TLE":
    CT += 1
  elif i == "RE":
    CR += 1
  else:
    pass
  
print("AC x %d" % (CA))
print("WA x %d" % (CW))
print("TLE x %d" % (CT))
print("RE x %d" % (CR))


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

int main() {
  int N;
  cin >> N;
  vector<int> d(N);
  for(int i=0;i<N;i++){
    cin>> d[i];
  }
  sort(d.begin(),d.end());
  int arc = N/2;
  int abc = arc-1;
  cout<<max(0,d[arc] -d[abc])<<endl;


}


Measured memory_bytes: 640
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <cmath>
#include <chrono>
using namespace std;

int main(int argc, const char * argv[]) {
    
    int N, K;
    cin >> N >> K;
    vector<int> v(200000, 0);
    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;
        v[a - 1]++;
    }
    sort(v.begin(), v.end(), greater<int>());
    
    int ans = 0;
    for (int i = 0; i < K; i++) {
        ans += v.at(i);
    }
    
    cout << N - ans << endl;

    return 0;
}


Measured memory_bytes: 1024
package main

import (
	"fmt"
)

func main() {
	var N int //読み込む数
	var sum int
	var L [100]int
	fmt.Scan(&N)
	for a := 0; a < N; a++ {
		fmt.Scan(&L[a])
	}
	//辺の読み取り
	for i := 0; i < N; i++ {
		for k := i + 1; k < N; k++ {
			for j := k + 1; j < N; j++ {
				if L[i] < L[k]+L[j] && L[k] < L[j]+L[i] && L[j] < L[i]+L[k] && L[i] != L[j] && L[j] != L[k] && L[k] != L[i] {
					sum++
				}
			}
		}
	}
	fmt.Printf("%d", sum)
}


Measured memory_bytes: 1840
def solve(inputstr):
  list=inputstr.split(" ")
  n = int(list[0]+list[1])
  ans = "No"
  i = 1
  while i < 330:
    if n == i**2:
      ans = "Yes"
      break
    i = i + 1
  return ans
 
if __name__ == '__main__':
  inputstr = input()
  ans = solve(inputstr)
  print(ans, flush=True)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
typedef long long LL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;

int main(void)
{
  int n;
  cin >> n;
  vector<LL> value(1<<18), weight(1<<18);
  FOR(i,1,n+1) cin >> value[i] >> weight[i];
  vector<vector<pair<LL, LL>>> hanzen(1<<9); // weight, value
  hanzen[0].emplace_back(0,0);
  FOR(bits,1,1<<9) {
    for(pair<LL,LL> p:hanzen[bits/2]) {
      pair<LL,LL> added = make_pair(p.first+weight[bits], p.second+value[bits]);
      hanzen[bits].push_back(p);
      hanzen[bits].push_back(added);
    }
    vector<pair<LL,LL>> tmp(hanzen[bits].begin(),hanzen[bits].end());
    sort(tmp.begin(),tmp.end());
    hanzen[bits].clear();
    hanzen[bits].emplace_back(0,0);
    for(pair<LL,LL> p:tmp) {
      if(hanzen[bits].back().second < p.second) hanzen[bits].push_back(p);
    }
  }
  int q;
  cin >> q;
  while(q--) {
    LL v, l;
    cin >> v >> l;
    vector<pair<LL,LL>> comb;
    comb.emplace_back(0,0);
    while(v>=(1<<9)) {
      vector<pair<LL,LL>> tmp(comb.begin(), comb.end());
      for(pair<LL,LL> p:tmp) {
        pair<LL,LL> added = make_pair(p.first+weight[v], p.second+value[v]);
        comb.push_back(added);
      }
      v/=2;
    }
    LL answer = 0;
    for(pair<LL,LL> p: comb) {
      LL cw,cv;
      tie(cw,cv) = p;
      if(cw>l) continue;
      auto ite = lower_bound(hanzen[v].begin(),hanzen[v].end(), make_pair(l-cw+1,0ll));
      --ite;
      answer=max(answer, cv+ite->second);
    }
    cout << answer << endl;
  }

  return 0;
}


Measured memory_bytes: 10220
N = int(input())
h = list(map(int, input().split()))
L = [0] * N
L[0] = 0
L[1] = abs(h[1] - h[0])
for i in range(2, N):
  L[i] = min(L[i-1] + abs(h[i-1] - h[i]), L[i-2] + abs(h[i-2] - h[i]))
else:
  print(L[-1])

Measured memory_bytes: 13928
#include <iostream>
#include <string>
#include <queue>
#include <utility>
#include <algorithm>
#include <numeric>
#include <set>
#include <climits>
#include <map>

using namespace std;

long long A[100000];
int main(){
  int N;
  cin >> N;
  for(int i = 0; i < N; i++){
    cin >> A[i];
  }

  bool decresing = false;
  bool undecided = true;

  int ans = 0;
  for(int i = 1; i < N; i++){
    if(undecided){
      if(A[i - 1] < A[i]){
        decresing = false;
        undecided = false;
        ans ++;
      }
      if(A[i - 1] > A[i]){
        decresing = true;
        undecided = false;
        ans ++;
      }
    } else {
      if(decresing){
        if(A[i - 1] < A[i]){
          undecided = true;
        }
      } else {
        if(A[i - 1] > A[i]){
          undecided = true;
        }
      }
    }
  }
  if(undecided){
    ans ++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
#include "bits/stdc++.h"

using namespace std;

void solve(void)
{
	int a, b, c;
	cin >> a >> b >> c;
	if (a > b) swap(a, b);
	bool ok = a <= c && c <= b;
	cout << (ok ? "Yes" : "No") << endl;
}

int main()
{
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


Measured memory_bytes: 256
import sys

MOD = 10 ** 9 + 7

def make_table(size=10**6, p=MOD):
    fac = [None] * (size + 1)
    fac[0] = 1
    for i in range(size):
        fac[i+1] = fac[i] * (i + 1) % p
    ifac = [None] * (size + 1)
    ifac[size] = pow(fac[size], p-2, p)
    for i in range(size, 0, -1):
        ifac[i-1] = ifac[i] * i % p
    return fac, ifac

fac, ifac = make_table(10**5)

def comb(n, r, mod=MOD):
    if r > n or r < 0:
        return 0
    return fac[n] * ifac[r] % mod * ifac[n-r] % mod

n, *x = map(int, sys.stdin.read().split())

def main():
    d = [x[i+1] - x[i] for i in range(n-1)]
    table = [pow(i, MOD-2, MOD) for i in range(1, n+1)]
    for i in range(n-1):
        table[i+1] += table[i]
        table[i+1] %= MOD

    res = 0
    for i in range(n-1):
        res += d[i] * table[i]
        res %= MOD

    return res * fac[n-1] % MOD

if __name__ == '__main__':
    ans = main()
    print(ans)

Measured memory_bytes: 23316
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
typedef long double lf;
int n;
lf x,d;
int main(){
	scanf("%d%Lf%Lf",&n,&x,&d);
	lf ans=0;
	for(int i=n;i;i--){
		lf N=i;
		ans+=(x+x+d*(N+N-1))*0.5;
		x=(4*x+5*d+x*(N+N-2))/(N+N);
		d=(6*d+d*(N+N-2))/(N+N);
	}
	printf("%.12Lf",ans);
	return 0;
}

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

int main() {
  int n;
  scanf("%d", &n);
  
  if (n % 10 == 3)
    printf("bon\n");
  else if (n % 10 == 0 || n % 10 == 1 || n % 10 == 6 || n % 10 == 8)
    printf("pon\n");
  else
    printf("hon\n");

  return 0;
}

Measured memory_bytes: 3688
#define ll long long
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int arr[n];
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    int dp[n];
    for(int i=0;i<n;i++)
    {
        dp[i]=0;
    }
    for(int i=1;i<n;i++)
    {
        if(arr[i]<=arr[i-1])
        {
            dp[i]=1+dp[i-1];
        }
        //cout<<dp[i]<<endl;
    }
    int m=0;
    for(int i=0;i<n;i++)
    {
        if(dp[i]>=m)
        {
            m=dp[i];
        }
    }
    cout<<m<<endl;
}


Measured memory_bytes: 1024
#include "bits/stdc++.h"
#define ll long long
#define rep2(i,a,b) for(int i=a;i<=b;++i)
#define rep(i,n) for(int i=0;i<n;i++)
#define pii pair<int,int>
#define tii tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
ll MOD=1000000007;
#define INF 2*1e9
#define N_MAX 4000
using namespace std;
string alphabet("abcdefghijklmnopqrstuvwxyz");
void upd(ll &a,ll b){
    a=(a+b)%MOD;}
main(){
    int n,m;
    cin>>n>>m;
    ll dp[4000][4000][2]={};
    dp[0][0][1]=1;
    rep2(i,1,n){
        dp[0][i][0]=1;
    }
    rep(i,m){
        rep2(j,0,n){
            rep(k,2){
                ll t=dp[i][j][k];
                if(j==0){
                    upd(dp[i+1][0][1],t);
                    upd(dp[i+1][1][1],t);
                }
                else if(j==1&&j==n){
                    upd(dp[i+1][0][1],t);
                    upd(dp[i+1][1][1],t);
                }
                else if(j==1){
                    upd(dp[i+1][0][1],t);
                    upd(dp[i+1][1][1],t);
                    upd(dp[i+1][1][k],t);
                    upd(dp[i+1][2][k],t);
                }
                else if(j==n){
                    upd(dp[i+1][n-1][k],t);
                    upd(dp[i+1][n][k],t);
                }
                else{
                    upd(dp[i+1][j-1][k],t);
                    upd(dp[i+1][j][k],t*2);
                    upd(dp[i+1][j+1][k],t);
                }
            }
        }
    }
    ll ans=0;
    rep2(i,0,n){
        upd(ans,dp[m][i][1]);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 250368
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define ll long long
using namespace std;
int main()
{
    int a, b;
    cin >> a >> b;
    vector<string> ans;
    string tmp1, tmp2;
    rep(i,b){
        tmp1 += (a + '0');
    }
    rep(i,a){
        tmp2 += (b + '0');
    }
    ans.push_back(tmp2);
    ans.push_back(tmp1);
    sort(ans.begin(), ans.end());
    cout << ans[0] << endl;
}


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

int p, q, a, b, c;
long x[100000];
long y[100000];
long z[100000];
int main() {
  cin >> p >> q >> a >> b >> c;
  for (int i = 0; i < a; ++i) cin >> x[i];
  for (int i = 0; i < b; ++i) cin >> y[i];
  for (int i = 0; i < c; ++i) cin >> z[i];
  sort(x, x + a, greater<long>());
  sort(y, y + b, greater<long>());
  sort(z, z + c, greater<long>());
  
  long sum = 0;
  priority_queue<long, vector<long>, greater<long>> que;
  for (int i = 0; i < p; ++i) { sum += x[i]; que.push(x[i]); }
  for (int i = 0; i < q; ++i) { sum += y[i]; que.push(y[i]); }
  
  long mx = sum;
  for (int i = 0; i < min(p + q, c); ++i) {
    long d = que.top(); que.pop();
    sum -= d;
    sum += z[i];
    mx = max(mx, sum);
  }
  cout << mx << endl;
}

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

using namespace std;

const int N = 393;

int n, s[N], l[N], p[N], m, ans[N], f, dp[N+1], w;

main(){
  cin >> n;
  for(int i=0;i<n;i++) cin >> s[i] >> l[i] >> p[i];
  fill(dp, dp+N+1, -1);
  dp[0] = 0;
  for(int k=0;k<=N;k++){
    if(dp[k] == -1) continue;
    for(int i=0;i<n;i++){
      for(int j=s[i];j<=l[i]&&k+j<=N;j++){
        dp[k+j] = max(dp[k+j], dp[k] + p[i]);
      }
    }
  }
  f = 1;
  cin >> m;
  for(int i=0;i<m;i++){
    cin >> w;
    ans[i] = dp[w];
    if(ans[i] < 0) f = 0;
  }
  if(!f) cout << -1 << endl;
  else for(int i=0;i<m;i++) cout << ans[i] << endl;
}

Measured memory_bytes: 1168
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 998244353
eps = 10**-7
def inp(): return int(input())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())

K,N = inpl()
MAX = K+N+10
fac = [1]*(MAX+1)
for i in range(1,MAX+1):
	fac[i] = (fac[i-1]*i)%mod

gyakugen = [1]*(MAX+1)
gyakugen[MAX] = pow(fac[MAX],mod-2,mod)
for i in range(MAX,0,-1):
	gyakugen[i-1] = (gyakugen[i]*i)%mod

def Comb(n,k):#nCk
	return (fac[n]*gyakugen[k]*gyakugen[n-k])%mod

#K=k,N=n,0pair = 0
def calc(k,n,i):
	#i=2に帰着させる
	pairs = (i-2)//2
	k -= pairs
	n -= pairs

	#色々と例外処理
	if n < 0 or k <= 0:
		return 0
	elif k == 1 and n >= 2:
		return 0

	if n == 0: 	 #球が0個なら1通り
		ans = 1
	else:
		ans = 0
		#i=2の時の数え上げ
		for x in range(2):
			ball = n-x	#球
			box = k-1	#箱
			ans += Comb(box-1+ball,ball)%mod

	ans *= pow(2,pairs,mod)	#0pairの選び方
	return ans % mod

ans = []
for i in range(2,K+2):
	if i%2 == 0:
		pairs = (i-2)//2
		tmp = 0
		for p0 in range(pairs+1): #p0 = 0pairの数
			tmp += calc(K-p0*2 , N , i-p0*2) * Comb(pairs,p0)%mod
			tmp %= mod
	ans.append(tmp)
	print(tmp)

ans = ans[::-1]
for i in range(1,K):
	print(ans[i])


Measured memory_bytes: 62808
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	int n;
	ll ans = 0;
	string s; cin >> n >> s;
	
	unordered_map<pair<string,string>,int> m;
	rep(i, 1 << n){
		string r, b;
		rep(j, n) (i & 1 << j ? r : b) += s[j + n];
		++m[make_pair(r, b)];
	}
	rep(i, 1 << n){
		string r, b;
		rep(j, n) (i & 1 << j ? r : b) += s[n - j - 1];
		auto p = m.find(make_pair(r, b));
		if(p != m.end()) ans += p->second;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 47176
while True:
    n= int(input())
    if n==0:
        break

    a=[1,1,2,4]
    for i in range(4,n+1):
        a.append(a[i-1]+a[i-2]+a[i-3])
    if a[n] % 3650 ==0:
        print(a[n]/3650)
    else:
        print(a[n]//3650 +1 )



Measured memory_bytes: 5592
#include<bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define ll long long
#define MOD (ll)1e9+7
#define REP(i,b,e) for(int (i)=b;(i)<e;(i)++)
const ll INF= 1LL << 60;
 
class UnionFind {
	vector<int> data;
public:
	UnionFind(int size) : data(size, -1) { }
	bool unionSet(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};
 
 
//入力
ll A,B;

int main(){
  cin >> A>>B;
  if(B%A==0){
    cout<<A+B<<endl;
  }else{
    cout<<B-A<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll        = long long;
using ld        = long double;
using vl        = vector<ll>;
using vd        = vector<ld>;
using vs        = vector<string>;
using vb        = vector<bool>;
using vvl       = vector<vector<ll>>;
using vvd       = vector<vector<ld>>;
using vvs       = vector<vector<string>>;
using vvb       = vector<vector<bool>>;
using pll       = pair<ll, ll>;
constexpr ll mod= 1e9 + 7;
#define ALL(x) (x).begin(), (x).end()
#define REP(i, n) for(ll(i)= 0; (i) < (n); (i)++)
#define REPS(i, n) for(ll(i)= 1; (i) <= (n); (i)++)
#define RREP(i, n) for(ll(i)= (n - 1); (i) >= 0; (i)--)
#define RREPS(i, n) for(ll(i)= (n); (i) > 0; (i)--)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())
#define YES(n) ((n) ? "YES" : "NO")
#define Yes(n) ((n) ? "Yes" : "No")
#define yes(n) ((n) ? "yes" : "no")

template <class T>
inline void chmin(T& a, T b) {
    if(a > b) { a= b; }
}

template <class T>
inline void chmax(T& a, T b) {
    if(a < b) { a= b; }
}

/* modとる */
inline ll modu(ll a){
    return(a % mod + mod) % mod;
}

/* modつき二分累乗法 */
ll modpow(ll a, ll b) {
    ll res = 1;
    for (a = modu(a); b; a = modu(a * a) , b >>= 1){
        if (b & 1) res = modu(res * a);
    }
    return res;
}

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);
    ll N;
    cin >> N;
    ll ans = modu(modpow(10,N) - 2 * modpow(9,N) + modpow(8,N));
    cout << ans << "\n";
}

Measured memory_bytes: 3652
import java.util.*;
class Main{
public static void main (String[] args){
 Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = a / 2;
    int c = a % 2;
   if(c == 1){
     b = b + 1;
   }
   System.out.println(b);  
  
  }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい

#define ALL(x) x.begin(),x.end()
typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>
typedef vector<int> vi; //vector<int>
typedef vector<vector<int>> vvi; //vector<vector<int>>
typedef vector<ll> vll; //vector<long long>
typedef vector<vector<ll>> vvll; //vector<vector<long long>>
typedef priority_queue<int, vector<int>, greater<int> > gpq; //逆順priority_queue
typedef priority_queue<int> pq;

//const int MOD=998244353;
const int MOD=1000000007; //10^9+7
const long double PI=3.14159265358979323846264338327950288;

int main(){
    int N;
    cin>>N;
    vi A(N);
    vi B(N);
    for(int i=0;i<N;i++){
        cin>>A[i]>>B[i];
    }
    sort(ALL(A));
    sort(ALL(B));
    if(N%2){
        int med=N/2;
        cout<<B[med]-A[med]+1<<endl;
    }else{
        int m1=N/2-1,m2=N/2;
        cout<<((B[m2]+B[m1])-(A[m2]+A[m1]))+1<<endl;
    }
}


Measured memory_bytes: 4820
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
using ll =  long long;
#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)
int hoge(ll a){
    int num =0;
    while(a >0){
        a /= 10;
        num++;
    }
    return num;
}
ll MOD=1e9+7;
int main() {
    ll n;
    cin>>n;
    int ret = hoge(n);
    for(ll A=1LL;A*A<=n;++A){
        if(n%A == 0){
            ll B = n/A;
            int cur = max(hoge(B),hoge(A));
            ret = min(cur,ret);
        }
    }
    cout << ret << endl;
    return 0;
}



Measured memory_bytes: 256
N,M = map(int,input().split())


ans = []
s = 1
e = M+1
while e>s:
    ans.append([s,e])
    s += 1
    e -= 1

s = M+2
e = 2*M+1
while e>s:
    ans.append([s,e])
    s += 1
    e -= 1

for s,e in ans:
    print(s,e)
    


Measured memory_bytes: 81036
A=input()
B=input()

A=int(A)
B=int(B)

if A==1 and B==2:
	print(3)

elif A==1 and B==3:
	print(2)
    
elif A==2 and B==1:
	print(3)
    
elif A==2 and B==3:
	print(1)
    
elif A==3 and B==1:
	print(2)
    
else:
	print(1)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define ll long long int

using namespace std;

int main()
{
    ll n,val,f=0,i;
    map<ll,ll>m;
    cin>>n;
    for(i=1;i<=n;++i){

        cin>>val;
        ++m[val];
        if(m[val]>1)f=1;

    }
    if(f==1)cout<<"NO"<<endl;
    else cout<<"YES"<<endl;

    return 0;

}


Measured memory_bytes: 12800
#include <iostream>
#include <set>
#include <vector>

using namespace std;

int main() {
    long long n, mod = 998244353;
    int k;
    cin >> n >> k;
    set<long long> s, next;
    vector<long long> df(n + 1, 0);
    vector<long long> df_sum(n + 1, 0);
    vector<long long> left(k);
    vector<long long> right(k);

    for (int i = 0; i < k; i++) {
        long long tmp1, tmp2;
        cin >> tmp1 >> tmp2;
        for (long long j = tmp1; j < tmp2 + 1; j++) {
            s.insert(j);
        }
        left[i] = tmp1;
        right[i] = tmp2;
    }

    df[1] = 1;
    df_sum[0] = 0;
    df_sum[1] = 1;
    // next.insert(0);

    for (long long i = 2; i <= n; i++) {
        /*if (df[i] == 0) {
            continue;
        }*/

        // next.erase(next.begin());

        /*for (auto itr = s.begin(); itr != s.end(); itr++) {
            if (i + *itr < n) {
                df[i + *itr] += df[i];
                df[i + *itr] %= mod;
                // next.insert(i + *itr);
            } else {
                break;
            }
        }*/

        for (long long j = 0; j < k; j++) {
            int lefti = i - right[j];
            int righti = i - left[j];
            if (righti < 0) continue;
            lefti = max(lefti, 1);
            df[i] += df_sum[righti] - df_sum[lefti - 1];
            df[i] %= mod;
        }

        df_sum[i] = df_sum[i - 1] + df[i];
        // cout << df_sum[i] << endl;
    }

    /*for (auto itr = s.begin(); itr != s.end(); itr++) {
        int now=0
    }*/

    cout << df[n] << endl;
}


Measured memory_bytes: 15468
#include <bits/stdc++.h>
#include <cstring> 
using namespace std;
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define int long long int
#define mpp make_pair
#define F first
#define mem(a,b) memset(a,b,sizeof(a))
#define F first
#define S second
#define MOD 1000000007
#define in_range(x, y, r, c) (x < r && y < c && x >= 0 && y >= 0)
const int MAXN = 1e6+1;
#define MAXI 2e18+3
#define all(v) v.begin(), v.end()
#define endl "\n"
# define PI 3.14159265358979323846


signed main(){
 
    fast;
    
    #ifdef _DEBUG
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    
    int a, b, n;
    cin>>a>>b>>n;
    cout<<(a*min(n, b-1))/b<<endl;
}

Measured memory_bytes: 3608
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    def scorei(ti, i, last, minus):
        k = [i for i in last]
        mi = minus-(i+1-last[ti])*c[ti]
        v = s[i][ti]-mi
        mi += sum_
        k[ti] = i+1
        return v, k, mi

    def score(t):
        n = 26
        v = 0
        minus = sum_ = sum(c)
        last = [0]*n
        for i in range(d):
            ti = t[i]-1
            minus -= (i+1-last[ti])*c[ti]
            v += s[i][ti]-minus
            minus += sum_
            last[ti] = i+1
        return v
    d = I()
    c = LI()
    s = LIR(d)
    n = 26
    m = 1000
    sum_ = sum(c)
    q = [(0, 0, [0]*n, sum_)]
    pre = [[None]*n for i in range(d)]
    sc = [[float("inf")]*n for i in range(d)]
    argmax = 0
    for i in range(d):
        nq = []
        for _ in range(m):
            if not q:
                break
            v, x, last, minus = heappop(q)
            if i > 0 and v > sc[i-1][x]:
                continue
            for ti in range(n):
                vi,nl,nm = scorei(ti,i,last,minus)
                nv = v-vi
                heappush(nq,(nv,ti,nl,nm))
                if sc[i][ti] > nv:
                    sc[i][ti] = nv
                    pre[i][ti] = x
        q = [i for i in nq]
    t = []
    argmax = 0
    m = sc[-1][0]
    for i in range(1,n):
        sci = sc[-1][i]
        if m > sci:
            m = sci
            argmax = i
    t.append(argmax)
    x = argmax
    for i in range(1,d)[::-1]:
        y = pre[i][x]
        t.append(y)
        x = y
    t = [i+1 for i in t[::-1]]
    v = score(t)
    for i in t:
        print(i)
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 104488
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, a, b) for(int i = a; i < b; i++)
#define rrep(i, a, b) for(int i = b - 1; i >= a; i--)
#define ALL(a) a.begin(), a.end()
#define pii pair<int,int>
#pragma GCC optimize("Ofast")
#define pcnt __builtin_popcount
#define buli(x) __builtin_popcountll(x)
#define pb push_back
#define mp make_pair
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
template<class T>bool chmax(T &a, const T &b) {if(a<b){a = b; return 1;} return 0; };
template<class T>bool chmin(T &a, const T &b) {if(a>b){a = b; return 1;} return 0; };
inline void IN(void){return;}
template <typename First, typename... Rest> void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
inline void OUT(void){cout << "\n";return;}
template <typename First, typename... Rest> void OUT(First first, Rest... rest){cout << first << " ";OUT(rest...);return;}
const double EPS = 1e-9;
const int mod = 1e9 + 7;
const int INF = 1e9;
const long long LLINF = 1e18;
long long lcm(ll a, ll b){return a * b / __gcd(a,b);}
struct IoSetup { IoSetup() {
    cin.tie(nullptr);ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
} } iosetup;
template< int mod > struct ModInt {
    int x; ModInt() : x(0) {}
    ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
    ModInt &operator+=(const ModInt &p) {if((x += p.x) >= mod) x -= mod;return *this;}
    ModInt &operator-=(const ModInt &p) {if((x += mod - p.x) >= mod) x -= mod;return *this;}
    ModInt &operator*=(const ModInt &p) {x = (int) (1LL * x * p.x % mod);return *this;}
    ModInt &operator/=(const ModInt &p) {*this *= p.inverse();return *this;}
    ModInt operator-() const { return ModInt(-x); }
    ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
    ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
    ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
    ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
    bool operator==(const ModInt &p) const { return x == p.x; }
    bool operator!=(const ModInt &p) const { return x != p.x; }
    ModInt inverse() const {int a = x, b = mod, u = 1, v = 0, t;
    while(b > 0) { t = a / b; swap(a -= t * b, b); swap(u -= t * v, v); }return ModInt(u);}
    ModInt pow(int64_t n) const {ModInt ret(1), mul(x); while(n > 0) {if(n & 1) ret *= mul;mul *= mul;n >>= 1;}return ret;}
    friend ostream &operator<<(ostream &os, const ModInt &p) { return os << p.x;}
    friend istream &operator>>(istream &is, ModInt &a) { int64_t t; is >> t; a = ModInt< mod >(t); return (is); }
    static int get_mod() { return mod; }
}; using modint = ModInt< mod >;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main(){
    iosetup;
    string S; cin >> S;
    vector<int> v(26, 0);
    rep(i, 0, S.size()) v[S[i] - 'a']++;
    rep(i, 0, 26) if(v[i] == 0){
        char t = 'a' + i;
        cout << t << endl;
        return 0;
    }
    cout << "None" << endl;
    return 0;
}

Measured memory_bytes: 512
class in{struct It{int it;const bool rev;explicit constexpr It(int it_, bool rev=false):it(it_),rev(rev){}int operator*(){return it;}bool operator!=(It& r){return it!=r.it;}void operator++(){rev?--it:++it;}};const It i,n;public:explicit constexpr in(int n):i(0),n(n<0?0:n){}explicit constexpr in(int i,int n):i(i,n<i),n(n){}const It& begin(){return i;}const It& end(){return n;}};
     
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
using i64 = long long;
const i64 MOD = 1e9 + 7;
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n), b(n), c(n + 1, -2);
    for(auto& x : a) cin >> x;
    for(auto& x : b) cin >> x;
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    i64 ans = 1LL;
    for(int _ : in(2)) {
        i64 j = 0;
        for(i64 i : in(n - 1)) {
            while(j < n && b[j] < a[i])
                ++j;
            if(j > i)
                (ans *= (j - i)) %= MOD;
        }
        swap(a, b);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> p(n), q(n), temp(n);
  for(int i = 0; i < n; i++){
    cin >> p[i];
    temp[i] = i + 1;
  }
  
  int a = 1; 
  do{
     if(p == temp) break;
     a++;
  }while(next_permutation(temp.begin(), temp.end()));
         
  for(int i = 0; i < n; i++){
    cin >> q[i];
    temp[i] = i + 1;
  }
  
  int b = 1; 
  do{
     if(q == temp) break;
     b++;
  }while(next_permutation(temp.begin(), temp.end()));
  
  cout << abs(a - b);
  return 0;
}


Measured memory_bytes: 3636
use std::{io, process};
use std::error::Error;

fn main() {
    if let Err(e) = run() {}
}


fn run() -> Result<(), Box<Error>> {
    let mut buffer = String::new();
    io::stdin().read_line(&mut buffer)?;
    let n = buffer.trim().parse::<usize>()?;
    let mut i = 0;
    let mut j = 0;
    let mut k = 0;
    buffer.clear();
    io::stdin().read_line(&mut buffer)?;
    for x in buffer.trim().split_whitespace().into_iter() {
        let num = x.trim().parse::<i32>()?;
        match num {
            1 => i += 1,
            2 => j += 1,
            3 => k += 1,
            _ => {
                panic!("error")
            }
        }
    }
    let mut dp = vec![vec![vec![-1.0; n + 1]; n + 1]; n + 1];
    println!("{}", calculate(&mut dp, i, j, k, n as f64));
    Ok(())
}

fn calculate(dp: &mut Vec<Vec<Vec<f64>>>, i: usize, j: usize, k: usize, n: f64) -> f64 {
    if i == 0 && j == 0 && k == 0 {
        return 0.0;
    }
    if dp[i][j][k] != -1.0 {
        return dp[i][j][k];
    }
    let mut result = 1.0;
    if i > 0 {
        result = result + calculate(dp, i - 1, j, k, n) * i as f64 / n;
    }
    if j > 0 {
        result = result + calculate(dp, i + 1, j - 1, k, n) * j as f64 / n;
    }
    if k > 0 {
        result = result + calculate(dp, i, j + 1, k - 1, n) * k as f64 / n;
    }

    result = result * n as f64 / (i + j + k) as f64;
    dp[i][j][k] = result;
    return result;
}



Measured memory_bytes: 237820
local inp = io.read()
local n,k
for i=1,string.len(inp),1 do
  if inp:sub(i,i)==' ' then
    n = tonumber(inp:sub(1,i-1))
    k = tonumber(inp:sub(i+1,string.len(inp)))
  end
end
local h = {}
for i=1,n,1 do
  h[i] = tonumber(io.read())
end
table.sort(h)
local ans=1000000000
for i=1,n-k+1,1 do
  if ans>h[i+k-1]-h[i] then
    ans = h[i+k-1]-h[i]
  end
end
print(ans)

Measured memory_bytes: 4536
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

int n, m;

int solve(vector<int>& x) {
  sort(x.begin(), x.end());
  vector<int> t(m);
  // for (auto e : x) {
  //   cout << e << " ";
  // }
  // cout << endl;
  for (int i = 0; i < (int)x.size() - 1; ++i) {
    t[i] = x[i + 1] - x[i];
    // cout << t[i] << " ";
  }
  // cout << endl;
  sort(t.begin(), t.end(), greater<int>());
  int sum{};
  FOR(i, n - 1, m) {
    sum += t[i];
  }
  // cout << sum << endl;
  return sum;
}

int main() {
  cin >> n >> m;
  vector<int> x(m);
  REP(i, m) cin >> x[i];
  cout << solve(x) << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <utility>
#define inf 10000000000

using namespace std;
typedef pair<double, double> P;

int N, M, L;
double p[105], T[105], V[105];
P table[105][55];

double pow(double a, int n)
{
	if(n == 0) return 1.0;
	if(n % 2) return a * pow(a, n-1);
	else{
		double t = pow(a, n/2);
		return t * t;
	}
}

double comb(double n, double k)
{
	double ret = 1.0;
	for(int i = 0; i < k; i++){
		ret *= (n-i)/(k-i);
	}
	return ret;
}

int main(void)
{
	cin >> N >> M >> L;
	
	int pp;
	for(int i = 0; i < N; i++){
		cin >> pp >> T[i] >> V[i];
		p[i] = pp / 100.0;
	}
	
	for(int i = 0; i < N; i++){
		for(int j = 0; j <= M; j++){
			table[i][j] = make_pair( L/V[i] + j*T[i], comb(M, j) * pow(p[i],j) * pow(1.0-p[i],M-j) );
			if(j != 0) table[i][j].second += table[i][j-1].second;
		}
	}
	
	P *ix;
	double ans, prob;
	for(int i = 0; i < N; i++){
		ans = 0.0;
		for(int j = 0; j <= M; j++){
			
			prob = table[i][j].second;
			if(j != 0) prob -= table[i][j-1].second;
			
			for(int k = 0; k < N; k++){
				if(i == k) continue;
				ix = lower_bound(table[k], table[k] + M+1, make_pair(table[i][j].first, 1.1));
				if(ix != table[k]){
					prob *= 1.0 - ix[-1].second;
				}
			}
			ans += prob;
		}
		printf("%.8f\n", ans);
	}
	
	return 0;
}

Measured memory_bytes: 3352
#include <cstdio>
using namespace std;
int N, K, Q, A[100001];
int main() {
    scanf("%d %d %d", &N, &K, &Q);
    for(int i = 1, t; i <= Q; ++i) {
        scanf("%d", &t);
        ++A[t];
    }
    for(int i = 1, t; i <= N; ++i) {
        printf("%s\n", Q-A[i]<K?"Yes":"No");
    }
}

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

using namespace std;

#define all(v) (v).begin(), (v).end()
#define sz(v) (int)(v).size()

typedef long long ll;
typedef pair<int, int> pii;
typedef unsigned long long ull;


struct Q {
    int a, b, c, d;

    void scan() {
        scanf("%d %d %d %d", &a, &b, &c, &d);
        --a; --b;
    }
    int score(vector<int>& v) {
        return (v[b] - v[a] == c) ? d : 0;
    }
};


int main()
{
    //freopen("input.txt", "r", stdin);


    int n, m;
    scanf("%d %d", &n, &m);
    vector<pii> out;
    if (n & 1) {
        for (int i = 0; i < m; ++i)
            out.push_back({i, n - i - 1});
    } else {
        for (int i = 0; i < n / 4; ++i)
            out.push_back({i, n - i - 1});
        for (int i = n / 4; i < n / 2 - 1; ++i)
            out.push_back({i, n - i - 2});
    }

    /*
    for (auto& [i, j] : out)
        printf("%d %d\n", i, j);
    printf("\n");
    */

    for (int i = 0; i < m; ++i)
        printf("%d %d\n", out[i].first + 1, out[i].second + 1);
    printf("\n");

}


Measured memory_bytes: 4220
#include <iostream>
#include <algorithm>
#include <functional>
#include <list>
#include <vector>
#include <iterator>
#include <ctime>
#include <iomanip>
#include <cstdlib>
#include <random>
#include <cstdio>
#include <sstream>
#include <map>
#include <set>
#include <unordered_map> 
#include <unordered_set>
#include <chrono> 
#include <numeric> 

using llong = long long;
using ullong = unsigned long long;
#define FOR(i, s, n) for (int i = (s); i < (n); i++)
#define FORD(i, s, n) for (int i = (s); i > (n); i--)
#define FORW(i, s, n, p) for (int i = (s); i < (n); i += p)
#define FORDW(i, s, n, p) for (int i = (s); i > (n); i -= p)

using namespace std;

int main()
{

	ios_base::sync_with_stdio(0);
	cin.tie(0);

	llong n, k;
	cin >> n >> k;
	vector <llong> nums(n);
	for (int i = 0; i < n; i++)
		cin >> nums[i];
	sort(nums.begin(), nums.end());

	llong l = min(nums[0] * nums[1], nums[0] * nums.back()) - 1;
	llong r = max(nums[0] * nums[1], nums.back() * nums[nums.size() - 2]) + 1;

	llong maxAns = l;

	while (l + 1 < r) {

		llong mid = (l + r) / 2;
		llong cnt = 0;
		
		for (int i = 0; i < n; i++) {

			if (nums[i] > 0) {

				int lt = -1, rt = n;

				while (lt + 1 < rt) {

					int mt = (lt + rt) / 2;
					if (nums[i] * nums[mt] < mid)
						lt = mt;
					else
						rt = mt;

				}

				cnt += (lt + 1);

			}
			else {

				int lt = -1, rt = n;

				while (lt + 1 < rt) {

					int mt = (lt + rt) / 2;

					if (nums[i] * nums[mt] < mid)
						rt = mt;
					else
						lt = mt;

				}

				cnt += (n - rt);

			}

		}

		for (int i = 0; i < n; i++)
			if (nums[i] * nums[i] < mid)
				cnt--;

		cnt /= 2; 

		if (cnt >= k)
			r = mid;
		else
			l = mid;

	}

	cout << l;

}


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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long n, sum = 0, tmp;
  cin >> n;
  for (int i = 1; i < n; i++) {
    sum += i;
  }
  cout << sum << '\n';
}


Measured memory_bytes: 256
N, M = map(int, input().split())
a = [0] * M
b = [0] * M

for i in range(M):
    a[i] , b[i] = map(int, input().split())

count = [0] * N
for i in range(M):
    for j in range(N):
        if a[i] == (j+1) or b[i] == (j+1):
            count[j] += 1

for i in range(N):
    print(count[i])


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

int main() {
    string number;
    cin >> number;

    int counter = 0;
    if (number[0] == '1') {
        ++counter;
    }
    if (number[1] == '1') {
        ++counter;
    }
    if (number[2] == '1') {
        ++counter;
    }

    cout << counter << endl;
}

Measured memory_bytes: 256
import java.util.*;

/**
 * @author masayamatu
 * 
 */
public class Main {
  
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    String s = sc.next();
    if( a >= 3200) {
      System.out.println(s);
      }else {
        System.out.println("red");
  
    }
  }
}

Measured memory_bytes: 22612
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] a = new int[N];
		for(int i = 0 ; i < N ; i++) {
			a[i] = sc.nextInt();
		}
		int point = 1;
		for(int i = 0 ; i < N ; i++) {
			point = a[point - 1];
			if(point == 2) {
				System.out.println(i + 1);
				return;
			}
		}
		System.out.println(-1);
	}
}


Measured memory_bytes: 52700
#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <utility>
#include <string>
#include <cmath>
#include <set>
#include <functional>
#include <map>
#include <queue>
#include <cstring>
#include <stack>
#include <iomanip>
#include <climits>
#include <numeric>
#include <cassert>
#include <unordered_map>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define show(x) cout << #x << " = " << x << endl;
typedef long long ll;
typedef pair<int,int> pii;
int main(){
    string s;
    cin >> s;
    if(s[0] == s[2]){
        cout << "Yes" << endl;
    }else cout << "No" << endl;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.buffer.readline

def main():
    n, w = map(int,input().split())
    wei = []
    val = []
    for i in range(n):
        a, b = map(int,input().split())
        wei.append(a)
        val.append(b)

    dp = [[0 for i in range(w+1)] for j in range(n+1)]

    for i in range(n):
        for sum_w in range(w+1):
            
            if sum_w - wei[i] >= 0:
                dp[i+1][sum_w] = max(dp[i+1][sum_w], dp[i][sum_w - wei[i]] + val[i])

            
            dp[i+1][sum_w] = max(dp[i+1][sum_w], dp[i][sum_w])

    print(dp[n][w])


if __name__ == '__main__':
    main()

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

typedef long long ll;

const int maxn = 3005;
int N;
double p[maxn], dp[maxn][maxn];
bool vis[maxn][maxn];

double rec(int coin, int heads) {
    if (coin == N) {
        if (heads >= (N + 1) / 2) {
            return 1;
        }
        return 0;
    }
    double& ret = dp[coin][heads];
    if (vis[coin][heads]) {
        return ret;
    }
    vis[coin][heads] = true;
    ret = p[coin] * rec(coin + 1, heads + 1) + (1.0 - p[coin]) * rec(coin + 1, heads);
    return ret;
}

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

    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> p[i];
    }
    memset(vis, false, sizeof(vis));
    double answer = rec(0, 0);
    cout << fixed << setprecision(12) << answer;

    return 0;
}

Measured memory_bytes: 58964
#include <stdio.h>
#include <string.h>
int l[1000][2];
int memo[1001][1001][3];
int N,W;
void rec(int i,int w,int *pv,int *pw)
{
  int va,wa,vb,wb;
  if(i==N) {
    *pv = 0; *pw = 0;
    return;
  }
  if(memo[i][w][0] == 1){
    *pv = memo[i][w][1]; *pw = memo[i][w][2];
    return;
  }

  if(l[i][1] > w) {
    rec(i+1,w,pv,pw);
  }else{
    rec(i+1,w,&va,&wa);
    rec(i+1,w-l[i][1],&vb,&wb);
    vb += l[i][0]; wb += l[i][1];
    if(va > vb){
      *pv = va; *pw = wa;
    }else if(vb > va){
      *pv = vb; *pw = wb;
    }else if(wa < wb){
      *pv = va; *pw = wa;
    }else{
      *pv = vb; *pw = wb;
    }
  }
  memo[i][w][0] = 1;
  memo[i][w][1] = *pv;
  memo[i][w][2] = *pw;
  return;
}
int main()
{
  int i,v,w,c=1;
  for(;;){
    scanf("%d",&W);
    if(W == 0) break;
    memset(memo,0,sizeof(memo));
    scanf("%d",&N);
    for(i=0;i<N;i++){
      scanf("%d,%d",&l[i][0],&l[i][1]);
    }
    rec(0,W,&v,&w);
    printf("Case %d:\n",c++);
    printf("%d\n%d\n",v,w);
  }
  return 0;
}

Measured memory_bytes: 11000
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		int H,W;

		Scanner sc = new Scanner(System.in);

		while(true) {
			H = sc.nextInt();
			W = sc.nextInt();

			if(H==0 && W==0) break;

			for ( int i = 0; i < H; i++ ){
				for ( int j = 0; j < W; j++ ){
					System.out.print("#");
				}
				System.out.println();
			}
			System.out.println();
		}
	}

}


Measured memory_bytes: 33136
N, K = map(int, input().split())
A = list(map(int, input().split()))
P = pow(1 / 6, K)

now = sum(map(lambda a: a * (a + 1) // 2 / a, A[:K - 1]))
ans = 0
for left, right in zip(A, A[K - 1:]):
    now += right * (right + 1) // 2 / right
    ans = max(ans, now)
    now -= left * (left + 1) // 2 / left

print('{:.10f}'.format(ans))


Measured memory_bytes: 24804