akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

int n;
int cut[4010][4010];
// 4000*4000*8=128,000,000=128MB
ll dp[4010][4010];
ll w[4010];

int main(void){
	cin >> n;
	rep(i,n) cin >> w[i];

	rep(i,n) if(i-1>=0) w[i]+=w[i-1];

	clr(dp,-1);
	rep(i,n) dp[i][i]=0;
	rep(i,n) cut[i][i]=i;

	// dp[0][n-2] dp[1][n-1]
	// dp[0][n-1]
	for(int d=1;d<=n-1;++d){
		for(int i=0,j;j=i+d,j<=n-1;++i){
			for(int k=cut[i][j-1];k<=cut[i+1][j];++k){
				if(k+1>j) continue;
				ll cur=dp[i][k]+dp[k+1][j]+w[j];
				if(i-1>=0) cur-=w[i-1];
				if(dp[i][j]==-1||dp[i][j]>cur){
					dp[i][j]=cur;
					cut[i][j]=k;
				}
			}
		}
	}
	cout << dp[0][n-1] << endl;
	return 0;
}

Measured memory_bytes: 189588
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author LUCIANO.
 */
import java.util.*;

public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner in = new Scanner(System.in);
        int k = in.nextInt();
        int cur;
        List<String> list = new ArrayList<>();
        for(int i = 1; i < 10; i++) list.add(i + "");
        if(k <= 9) {
            System.out.println(list.get(k - 1));
        }else {
            int cnt = 9;
            int index = 0;
            while(cnt < k) {
                int len = list.get(index).length();
                int last = Integer.parseInt(String.valueOf(list.get(index).charAt(len - 1)));
                if(last != 0) {
                    list.add(list.get(index) + "" + (last - 1));
                    cnt += 1;
                }
                if(cnt < k) {
                    list.add(list.get(index) + "" + last);
                    cnt += 1;
                }
                if((cnt < k) && (last != 9)) {
                    list.add(list.get(index) + "" + (last + 1));
                    cnt += 1;
                }
                index += 1;
            }
            System.out.println(list.get(list.size() - 1));
        }
    }
}

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

long floor_sum(long n, long m, long a, long b) {
    long ans = 0;
    if (a >= m) {
        ans += (n - 1) * n * (a / m) / 2;
        a %= m;
    }
    if (b >= m) {
        ans += n * (b / m);
        b %= m;
    }
    long y_max = (a * n + b) / m, x_max = (y_max * m - b);
    if (y_max == 0) return ans;
    ans += (n - (x_max + a - 1) / a) * y_max;
    ans += floor_sum(y_max, a, m, (a - x_max % a) % a);
    return ans;
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t; scanf("%d", &t);
    while (t--) {
        long long n, m, a, b; scanf("%lld %lld %lld %lld", &n, &m, &a, &b);
        printf("%lld\n", floor_sum(n,m,a,b));
    }
    return 0;
}

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

int main(){
    int d,t,s;
    cin>>d>>t>>s;
    if(s*t>=d) cout<<"Yes";
    else cout<<"No";
}

Measured memory_bytes: 3632
n,k,s = map(int,input().split())
x = [0]*n
for i in range(k):
    x[i] = s
if s == 1000000000:
    for i in range(k,n):
        x[i] = s-1
else:
    for i in range(k,n):
        x[i] = s+1
for i in x:
    print(i,end = " ")

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

int main(){

   char a,b;
   int ans=1;
   cin>>a>>b;
   if(a=='D') ans*=-1;
   if(b=='D') ans*=-1;

    cout<<(ans==1?"H":"D")<<endl;




    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector> 
# include <cstdint>
#define FOR(i,l,r) for(int i=(l);i<(r);++i)
#define RFOR(i,l,r) for(int i=(l);i>=(int)(r);i--)
#define rep(i,n)  FOR(i,0,n)
#define rrep(i,n)  RFOR(i,n-1,0)

// #define int long long
using namespace std;
const int MX = 1e6;
const int inf = 1e9;
const int mod = 1e9+7;
#define ll long long


signed main() {
  int n;
  string s;
  int q;
  cin >> n>>s>>q;
vector<set<int>> aa(26);
  rep(i,n){
    char c = s[i]-'a';
    aa[c].insert(i);
  }
  rep(i,q){
    int x;
    cin>>x;
    if(x==1) {
      int y;
      char c;
      cin >>y>>c;
      y--;
      char cc = s[y]-'a';
      aa[cc].erase(y);
      s[y]=c;
      aa[c-'a'].insert(y);
    }else { //2
      int l,r;
      cin >> l>>r;
      l--;r--;
      int cnt = 0;
      rep(i,26) {
        auto p = aa[i].lower_bound(l);
        if(p==aa[i].end()) continue;
        //cout << l<<" "<< *p<<" "<<r << endl;
        if(*p<=r) cnt++;
      }
      cout << cnt << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 27184
#include<iostream>
#include<vector>

using namespace std;

int cnt=0;
vector<int> g;
vector<int> a;

void insertion_sort(int n,int g)
{
    for(int i=g;i<n;i++)
    {
        int v=a[i];
        int j=i-g;

        while(j>=0&&a[j]>v)
        {
            a[j+g]=a[j];
            j-=g;
            cnt++;
        }
        a[j+g]=v;
    }



}

void shell_sort(int n)
{
    cnt=0;
    for(int i=1;i<=n;i=i*3+1)
    {
        g.push_back(i);
    }
    int m=g.size();
    for(int i=m-1;i>=0;i--)
    {
     insertion_sort(n,g[i]);
    }
}

int main()
{

    int n;

    cin>>n;

    int b;
    for(int i=0;i<n;i++)
    {
        cin>>b;
        a.push_back(b);
    }

    shell_sort(n);

    cout<<g.size()<<endl;

    for(int i=g.size()-1;i>=0;i--)
    {
        if(i!=g.size()-1)
        {
            cout<<" ";
        }

        cout<<g[i];
    }

    cout<<endl<<cnt<<endl;

    for(int i=0;i<a.size();i++)
    {
        cout<<a[i]<<endl;
    }

    return 0;
}



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

using namespace std;

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)

typedef long long ll;
typedef vector<int> vi;

ll mod = 1e9+7;

string solve() {
    int arr[3][3];
    int a;
    rep(i, 9) {
        cin >> a;
        arr[i/3][i % 3] = a;
    }
    int n; cin >> n;
    unordered_set<int> nums;
    rep(i, n) {
        cin >> a;
        nums.insert(a);
    }

    int rows = 0, cols = 0, diags = 0, anti_diags = 0;
    rep(i, 3) {
        if (nums.count(arr[i][i])) {
            diags++;
        }
        if (nums.count(arr[i][3 - i - 1])) {
            anti_diags++;
        }
        int cnt = 0;
        rep (j, 3) {
            if (nums.count(arr[i][j])) {
                cnt++;
            }
        }
        rows = max(rows, cnt);
    }

    rep(j, 3) {
        int cnt = 0;
        rep(i, 3) {
            if (nums.count(arr[i][j])) {
                cnt++;
            }
        }
        cols = max(cols, cnt);
    }

    if (rows == 3 || cols == 3 || diags == 3 || anti_diags == 3) {
        return "Yes";
    } else {
        return "No";
    }
}

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

	cout << solve() << endl;
}


Measured memory_bytes: 3648
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace KCakes {
    class Program {
        static void Main(string[] args) {
            var input1 = Console.ReadLine().Split();
            var k = int.Parse(input1[0]);
            var t = int.Parse(input1[1]);
            var input2 = Console.ReadLine().Split().Select(int.Parse).ToArray();
            Array.Sort(input2);
            var ans = Math.Max(input2[t - 1] - 1 - (k - input2[t - 1]), 0);
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13396
N,x = map(int,input().split())
A = list(map(int,input().split()))
cost = 0

c = A[0] - x
if c > 0:
    cost += c
    A[0] -= c

for i in range(1,N):
    c = A[i-1] + A[i] - x
    if c > 0:
        cost += c
        A[i] -= c

print(cost)


Measured memory_bytes: 14252
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
		int n = int.Parse(Console.ReadLine());
    long[][] ends = new long[n][];
    long rightMemo = long.MinValue;
    int answer = 0;

    for(int i = 0; i < n; i++)
    {
      ends[i] = new long[4];
    
      string[] input = Console.ReadLine().Split(' ');
		  ends[i][0] = long.Parse(input[0]);
		  ends[i][1] = long.Parse(input[1]);
      ends[i][2] = ends[i][0]-ends[i][1];
      ends[i][3] = ends[i][0]+ends[i][1];
    }
    
		Array.Sort(ends, (a, b) => a[3].CompareTo(b[3]));

    for(int i = 0; i < n; i++)
    {
      //Console.WriteLine(ends[i][2] +" "+i);
      if(ends[i][2] >= rightMemo)
      {
        answer++;
        rightMemo = ends[i][3];
      }
    }

		Console.WriteLine(answer);
	}
}

Measured memory_bytes: 25920
s = input()
n = len(s)
ans = -1, -1
for i in range(n-1):
    if s[i] == s[i+1]:
        ans = [i+1, i+2]
    elif i < n -2 and s[i] == s[i+2]:
        ans = [i+1, i+3]

print(ans[0], ans[1])

Measured memory_bytes: 3188
# include <bits/stdc++.h>
using namespace std;
typedef long long i64;
typedef vector<int> Vi;
typedef pair<int, int> Pii;
# define pb push_back
# define mp make_pair
# define MOD 1000000007
# define bug puts("H");

const int N = 100000 + 5;

inline int Scan() {
    int x=0;int f=1; char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-') f=-1; ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
    return x*f;
}

struct Edge{
    int p, next;
}edge[N<<1];
int head[N], cnt = 1, dee[N];
bool vis[N];
map<Pii, bool> mark;
vector<Pii> ans;

void add_edge(int u, int v){
    edge[cnt].p = v; edge[cnt].next = head[u]; head[u] = cnt++;
}
void dfs(int x, int fa)
{
    vis[x] = true;
    for (int i = head[x]; i; i = edge[i].next) {
        int p = edge[i].p;
        if (p == fa) continue;
        if (vis[p] == true) {
            if (mark.find(mp(x, p)) != mark.end()) continue;
            mark[mp(x, p)] = mark[mp(p, x)] = true;
            ++dee[x];
            ans.pb(mp(x, p));
        }
        else {
            dfs(p, x);
            ++dee[x];
        }
    }
}
void dfs2(int x, int fa) {
    vis[x] = true;
    for (int i = head[x]; i; i = edge[i].next) {
        int p = edge[i].p;
        if (p == fa || vis[p]) continue;
        dfs2(p, x);
        if (dee[p]&1) ans.pb(mp(p, x));
        else ans.pb(mp(x, p));
        dee[x] += dee[p];
    }
}
int main ()
{
    int n = Scan(), m = Scan(), u, v;
    for (int i = 1; i <= m; ++i) {
        u = Scan(); v = Scan();
        add_edge(u, v);
        add_edge(v, u);
    }
    dfs(1, 0);
    int num = 0;
    for (int i = 1; i <= n; ++i) {
        if (dee[i]&1) ++num;
        dee[i] &= 1;
    }
    if (num&1) printf("-1\n");
    else {
        memset(vis, false, sizeof(vis));
        dfs2(1, 0);
        for (auto i: ans) {
            printf("%d %d\n", i.first, i.second);
        }
    }
    return 0;
}


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

int C;

void bubbleSort(int A[],int N){
	bool flag=true;
	while(flag){
		flag=false;
		for(int j=N-1;j>=1;j--){
			if(A[j]<A[j-1]){
				swap(A[j],A[j-1]);
				C++;
				flag=true;
			}
		}
	}
}

int main()
{
int N;
cin>>N;
int A[100];
for(int i=0;i<N;i++){
	cin>>A[i];
}
C=0;
bubbleSort(A,N);
for(int i=0;i<N;i++){
	cout<<A[i];
	if(i<N-1){
		cout<<' ';
	}
	else{
		cout<<endl;
	}
}
cout<<C<<endl;

return 0;
}

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

int main(){
	int a[3];
	int w;
	int count[3]={0};
	while(cin>>a[0]>>a[1]>>a[2]){
	
		sort(a,a+3);
		if(a[0]+a[1]<=a[2]){
			cout<<count[0]+count[1]+count[2]<<" "<<count[0]<<" "<<count[1]<<" "<<count[2]<<endl;
			return 0;
		}
		if(a[0]*a[0]+a[1]*a[1]==a[2]*a[2])count[0]++;
		if(a[0]*a[0]+a[1]*a[1]>a[2]*a[2])count[1]++;
		if(a[0]*a[0]+a[1]*a[1]<a[2]*a[2])count[2]++;
		
				
	}


}

Measured memory_bytes: 1180
#include <bits/stdc++.h>
#define ll long long
#define WMAX 100000000011
#define vmax 1003
#define sum_max 1003 * 100 + 1
using namespace std; 

ll dp[102][sum_max]; 
ll ww[102], vv[102]; 

int main(){
	int n, wmax; 
	cin >> n >> wmax; 

	for(int i = 0; i < n; i++){
		cin >> ww[i + 1] >> vv[i + 1]; 
	}

	int res = 0; 

	for(int i = 0; i <= n; i++){
		for(int j = 0; j < sum_max; j++){
			if(i == 0 || j == 0)
				dp[i][j] = WMAX; 
			else if(j == vv[i])
				dp[i][j] = min(ww[i], dp[i - 1][j]); 
			else if(j - vv[i] > 0)
				dp[i][j] = min(dp[i - 1][j - vv[i]] + ww[i], dp[i - 1][j]);
			else
				dp[i][j] = dp[i - 1][j]; 

			if(dp[i][j] <= wmax){
				res = max(res, j); 
			}
				
		}
	}

	cout << res << endl; 
}

Measured memory_bytes: 80128
total = []

N = int(input())

for i in range(1, N + 1):
    if i % 3 == 0 and i % 5 == 0:
        pass
    elif i % 3 == 0:
        pass
    elif i % 5 == 0:
        pass
    else:
        total.append(i)

print(sum(total))


Measured memory_bytes: 29844
Imports System

Class Sample
  Shared Sub Main()
    ' 以下の2つはどちらも同じ動作・同じ結果となる

    ' Consoleクラスのメソッドを使って標準入力から読み込む
    Dim line1 As String = Console.ReadLine()
    
    Dim num As Integer = Integer.Parse(line1) 
    
    Console.WriteLine(num * 3.14159 * 2)
  End Sub
End Class

Measured memory_bytes: 27588
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main(){
  string s;

  cin >> s;

  //初期値は大きい値
  int ans = s.size();

  //iは最初に使う色(0 or 1)
  //つまりiは偶数番目の数字と一緒
  for(int i = 0; i < 2; i++){
    //i色を最初に使った時に変えなければいけないタイルの数
    int cnt = 0;
    //ここで一番最初から数字(色)を見ていく
    for(int j = 0; j < s.size(); j++){
      //(char)(0 + '0') -> '0';
      //(char)(1 + '0') -> '1';

      //偶数番目で入っていて欲しい数字と違った時
      if(j % 2 == 0 && s[j] != (char)(i + '0')){
        cnt++;
      }
      //奇数番目で入っていて欲しい数字と一緒だった時
      if(j % 2 == 1 && s[j] == (char)(i + '0')){
        cnt++;
      }
    }
    //比べることで最初の数は絶対ansに入り、その後010101と101010を比べてくれる
    ans = min(ans, cnt);
  }

  cout << ans << endl;
}


Measured memory_bytes: 512
package main

import "fmt"

func main() {
	var sd, t string
	fmt.Scan(&sd, &t)

	tl := len(t)
	s := []byte(sd)

	find := false
	for i := len(sd) - tl; i >= 0; i-- {
		match := true
		for ii := 0; ii < tl; ii++ {
			if sd[i+ii] == '?' || sd[i+ii] == t[ii] {
				continue
			}
			match = false
		}
		if !match {
			continue
		}

		find = true
		for ii := 0; ii < tl; ii++ {
			s[i+ii] = t[ii]
		}
		break
	}

	if !find {
		fmt.Println("UNRESTORABLE")
		return
	}

	for i := range s {
		if s[i] == '?' {
			s[i] = 'a'
		}
	}

	fmt.Println(string(s))
}


Measured memory_bytes: 512
# coding: utf-8
# Your code here!
class Node:
    def __init__(self):
        self.parentId=-1
        self.depth=0
        self.children=[]
n=int(input())
u=[[int(i)for i in input().split()]for j in range(n)]

nodes=[Node() for i in range(n)]
for i in u:
    for j in range(i[1]):
        nodes[i[0]].children.append(i[2+j])
        nodes[i[2+j]].parentId=i[0]

def calcDepth(id,depth):
    global nodes
    nodes[id].depth=depth
    for i in nodes[id].children:
        calcDepth(i,depth+1)

for i in range(n):
    if nodes[i].parentId==-1:
        calcDepth(i,0)
        break

for i in range(n):
    a="node "+str(i)+": parent = "+str(nodes[i].parentId)+", depth = "+str(nodes[i].depth)
    if nodes[i].depth==0:
        a=a+", root, ["+", ".join(map(str,nodes[i].children))+"]"
    elif len(nodes[i].children)==0:
        a=a+", leaf, []"
    else:
        a=a+", internal node, ["+", ".join(map(str,nodes[i].children))+"]"
    print(a)


Measured memory_bytes: 54508
import numpy as np
from itertools import product

n = int(input())
a = list(map(int,input().split()))

a = np.array(a)

li = [-1,0,1]
cnt = 0
for v in product(li,repeat = n):
    v = np.array(v)
    L =a+v
    cum = L.cumprod()
    if cum[-1]%2 ==0 :
        cnt +=1
print(cnt)
        

Measured memory_bytes: 27248
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
int main(void){

	int a[200000];
	int c, d;
	int k;
	int n, m;
	int s, t;
	int x, y, z;


	scanf("%d", &n);

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



	for (k=n-1; k >=0; k=k-2)printf("%d ", a[k]);
	k = (k + 3) % 2;
	for (; k<n-2; k=k+2)printf("%d ", a[k]);
	if(k<n)printf("%d\n", a[k]);

	return 0;
}



Measured memory_bytes: 2816
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, M = lr()
ball = [1] * (N+1) # 1-indexed
red = [True if x == 1 else False for x in range(N+1)] # 1-indexed
for _ in range(M):
    x, y = lr()
    if red[x]: red[y] = True
    ball[x] -= 1
    ball[y] += 1
    if ball[x] == 0:
        red[x] = False

answer = sum(red)
print(answer)
# 37

Measured memory_bytes: 4760
# import math

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

# print(a * b // math.gcd(a, b))

def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a

def lcm(a,b):
    return a*b//gcd(a,b)

print(lcm(a,b))


Measured memory_bytes: 2940
#include<iostream>
#include<iomanip>
#include<vector>
using namespace std;

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

  vector<int> p(N);
  for(int i = 0; i < N; i++){
    cin >> p[i];
  }

  vector<long double> expected(N);
  for(int i = 0; i < N; i++){
    expected[i] = (static_cast<long double>(1) + p[i]) / 2;
  }

  long double sum = 0, sum_max = 0;
  for(int i = 0; i < K; i++){
    sum += expected[i];
  }
  sum_max = sum;
  for(int i = K; i < N; i++){
    sum += expected[i];
    sum -= expected[i - K];
    sum_max = max(sum_max, sum);
  }
  cout << setprecision(20) << sum_max << endl;
}



Measured memory_bytes: 4224
#include <iostream>

using namespace std;

int main(){
    int n;
    int x;
    cin >> n >> x;
    int l[n + 1];
    int sum = 0;
    int result = 1;
    for(int i = 0; i < n; i++){
        cin >> l[i];
    }
    for(int i = 0; i < n; i++){
        sum = sum + l[i];
        if(sum <= x){
            result++;
        }
    }
    cout << result << endl;
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <stdio.h>
#include <complex>
#include <cstdint>
#include <tuple>

#define M_PI       3.14159265358979323846

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 998244353

const int N = 300005;

LL fact[N], invfact[N];

LL mod_pow(LL a, LL p) {
	LL tmp = a, ret = 1LL;
	while (p) {
		if (p % 2)ret = (ret*tmp) % MOD;
		tmp = (tmp * tmp) % MOD;
		p >>= 1;
	}
	return ret;
}

LL comb(LL n, LL k) {
	return (((fact[n] * invfact[k]) % MOD) * invfact[n - k]) % MOD;
}

int main() {
	LL n, a, b, k, ret = 0;
	cin >> n >> a >> b >> k;
	fact[0] = invfact[0] = 1;
	FOR(i, 1, N) {
		fact[i] = (fact[i - 1] * i) % MOD;
	}
	FOR(i, 1, N) {
		invfact[i] = mod_pow(fact[i], MOD-2);
	}
	REP(i, n + 1) {
		if (k - i*a < 0)break;
		if ((k - i*a) % b != 0) continue;
		if ((k - i*a) / b > n)continue;
		ret = (ret + (comb(n, i) * comb(n, (k - i*a) / b)) % MOD) % MOD;
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 4992
n = int(input())
L = list(map(int, input().split()))
Ls = set(L)
Lslist = list(Ls)
LsSortlist = sorted(Lslist)
LSl = LsSortlist
tc = 0
for i in range(len(LSl)):
  L1 = LSl[i]
  for j in range(i + 1, len(LSl)):
    L2 = LSl[j]
    MinL = L2 - L1
    MaxL = L2 + L1
    for k in range(j + 1, len(LSl)):
      L3 = LSl[k]
      if MinL >= L3:
        continue
      elif L3 >= MaxL:
        break
      else:
        tc += L.count(L1) * L.count(L2) * L.count(L3)
if n < 3:
  print(0)
else:
  print(tc)

Measured memory_bytes: 9204
import sys
sys.setrecursionlimit(10**7)

MOD = 10**9+7

n, k = map(int, input().split())
to = [list() for _ in range(n)]
for _ in range(n-1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    to[a].append(b)
    to[b].append(a)

cnt = [0] * n
def dfs(v, p=-1):
    if p == -1:
        n_cnt = 1
    else:
        n_cnt = 2
    for u in to[v]:
        if u == p:
            continue
        cnt[u] = n_cnt
        n_cnt += 1
        dfs(u, v)
    return cnt

ans = 1
for i in dfs(0):
  ans *= max(0, k-i)
  ans %= MOD

print(ans)

Measured memory_bytes: 102192
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>

using namespace std;

int main() {
	string fs;
	string t;
	cin >> fs >> t;

	bool exist = false;

	// 思いついたこと　fsのなかでtを作り、その他の?にaを埋める
	// 図書館で借りた本になんかあったなぁ
	// 待った　後ろから始めた方が辞書的に早くなる
	// これだと計算量多くなるけど　制約短い矢
	for (int i = fs.size()-1; i >= 0; i--) {
		string s = fs.substr(i, t.size());
		if (s.size() != t.size()) continue;
		for (int j = 0; j < t.size(); j++) {
			if (s[j] != t[j] && s[j] != '?') {
				break;
			}
			//if (fs[i + j] != t[j] && fs[i + j] != '?') {
			//	break;
			//}
			if (j == t.size() - 1) {
				exist = true;
			}
		}

		
		if (exist) {
			int cnt = 0;
			for (int j = i; j < i + t.size(); j++) {
				fs[j] = t[cnt];
				cnt++;
			}
			break;
		}
	}

	if (exist) {
		//cout << fs << endl;
		replace(fs.begin(), fs.end(), '?', 'a');
		cout << fs << endl;
	}
	else cout << "UNRESTORABLE" << endl;

}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
using namespace std;
string s;
int main()
{
	int now=0;
	cin>>s;
	int l=s.size();
	for(int i=0;i<l;i++)
	{
		if(s[i]=='C'&&now==0)
			now=1;
		if(s[i]=='F'&&now==1)
			now=2;
	}
	if(now==2)
		cout<<"Yes";
	else
		cout<<"No";
	return 0;
}


Measured memory_bytes: 256
use std::fs;
use std::io::{stdin, Read};

macro_rules! parse {
    ($it: ident) => {
        $it.next().unwrap().parse().unwrap()
    };
    ($it: ident,2) => {
        (parse!($it), parse!($it))
    };
    ($it: ident,3) => {
        (parse!($it), parse!($it), parse!($it))
    };
    ($it: ident,4) => {
        (parse!($it), parse!($it), parse!($it), parse!($it))
    };
    ($it: ident, $n: expr) => {
        (&mut $it).take($n).map(|e| e.parse().unwrap()).collect();
    };
}

const MOD: usize = 998244353;

fn solve(s: &str) {
    let mut it = s.split_whitespace();
    let (n, s): (usize, usize) = parse!(it, 2);
    let a: Vec<usize> = parse!(it, n);
    let mut dp = vec![vec![vec![0, 0, 0]; s + 1]; n + 1];
    dp[0][0][0] = 1;
    for i in 0..n {
        for j in 0..(s + 1) {
            dp[i + 1][j][0] = dp[i][j][0];
            dp[i + 1][j][1] += dp[i][j][1] + dp[i][j][0];
            dp[i + 1][j][2] += dp[i][j][2] + dp[i][j][1] + dp[i][j][0];
            if j + a[i] <= s {
                dp[i + 1][j + a[i]][1] += dp[i][j][1] + dp[i][j][0];
                dp[i + 1][j + a[i]][2] += dp[i][j][1] + dp[i][j][0];
            }
            dp[i + 1][j][1] %= MOD;
            dp[i + 1][j][2] %= MOD;
        }
    }
    println!("{}", dp[n][s][2]);
}

fn test() {
    let mut f = fs::File::open("foo.txt").unwrap();
    let mut s = String::new();
    f.read_to_string(&mut s).unwrap();
    solve(&s);
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    solve(&s);
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn test_main() {
        test();
    }
    #[test]
    fn test_input() {
        let s = "
        ";
        solve(s);
    }
}


Measured memory_bytes: 549116
//g++ -std=c++11 -Wall -O2 -o main.exe main.cpp
//g++ -std=c++14 -Wall -O2 -o main.exe main.cpp

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <tuple>
#include <functional>
#include <algorithm>
#include <complex>
#include <numeric>

using namespace std;

#define spc " "
#define MOD 1000000007

typedef long long ll;
typedef long double ld;
typedef pair<int, int> p_ii;
typedef tuple<int, int, int, int> tup;

ll divc(ll a, ll b){ //割り算(切り上げ)
    return (a + b - 1) / b;
}

//------------------------------------------------------------------------------

int main(){
    int n;
    cin >> n;
    if(n == 3 || n == 5 || n == 7) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

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

int H,A[MAX+1];

void maxHeapify(int i){
  int l,r,largest;
  l=2*i;
  r=2*i+1;

  if(l<=H&&A[l]>A[i]) largest=l;
  else largest=i;
  if(r<=H&&A[r]>A[largest]) largest=r;

  if(largest!=i){
    swap(A[i],A[largest]);
    maxHeapify(largest);
  }
}

int main(){
  cin>>H;

  for(int i=1;i<=H;i++) cin>>A[i];
  for(int i=H/2;i>=1;i--) maxHeapify(i);

  for(int i=1;i<=H;i++){
    cout<<" "<<A[i];
  }
  cout<<endl;
  return 0;
}



Measured memory_bytes: 5040
#include<bits/stdc++.h>
using namespace std;
int main(){
  int i,j,n,w;
  cin>>n>>w;
  vector<vector<int>> arr(n , vector<int>(2,0));
  for(i=0;i<n;i++)
  for(j=0;j<2;j++)
  cin>>arr[i][j]; //Weight, Value

  vector<vector<long long int>> dp(n+1, vector<long long int>(w+1,0));
  for(i=1;i<=n;i++)
  for(j=0;j<=w;j++)
  if(arr[i-1][0]<=j)
    dp[i][j]=max(dp[i-1][j], arr[i-1][1]+dp[i-1][j-arr[i-1][0]]);
  else
    dp[i][j]=dp[i-1][j];

  /*
  for(i=0;i<=n;i++)
  {
  for(j=0;j<=w;j++)
    cout<<dp[i][j]<<" ";
  cout<<endl;
  }
  */
  cout<<dp[n][w]<<endl;
  return 0;
}


Measured memory_bytes: 80256
#include<stdio.h>
#include<stdlib.h>
void push(int);
int pop(void);

int s[100],top = 0;

int main()
{
  char c[100];
  int a,b;

  while(scanf("%s",c) != EOF) {
    switch(c[0]) {
    case '+':
      push(pop()+pop());
      break;
    case '-':
      a=pop();
      b=pop();
      push(b-a);
      break;
    case '*':
      push(pop()*pop());
      break;
    case ' ':
      break;
    default:
      push(atoi(c));
      break;
    }
  }
  printf("%d\n",pop());
  return 0;
}

void push(int x) 
{
  top++;
  s[top] = x;
}

int pop()
{
  top--;
  return s[top+1];
}

Measured memory_bytes: 548
#include <bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))
#define POW(n) (1LL<<(n))
#define IN(i,a,b) (a <= i && i <= b)
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a>b) { a=b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a<b) { a=b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(ALL(a)); }
template <typename T> inline void REV(T& a) { reverse(ALL(a)); }
template <typename T> inline void UNI(T& a) { sort(ALL(a)); a.erase(unique(ALL(a)),a.end()); }
const int MOD = 1000000007;
const int INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;
/* ---------------------------------------------------------------------------------------------------- */

string S;

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

  cin >> S;
  map<char,int> mp;
  for (char c : S) {
    mp[c]++;
    if (mp[c] >= 3) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << (mp.size() == 2 ? "Yes" : "No") << endl;

  return 0;
}

Measured memory_bytes: 256
def Int():
    return int(input())
def Ints():
    return map(int,input().split())
def IntList():
    return list(Ints())
def IntMat(N):
    return [IntList() for i in range(N)]

A,B,N = Ints()

x = min(int(A*N/B),A-1)
#print(x - A*int(x/A))

ans = 0
n = 1
x = -(-(B*n)//A)

while x<=N and n <= A-1:
    ans = max(ans, (A*x)//B-A*(x//B))
    n += 1
    x = -(-(B*n)//A)
print(ans)

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

int main(void) {
	string s,t;
	cin >> s >> t;
	bool a=false;
	for (int i = 0; i < s.length(); i++) {
		if (s==t) {
			a = true;
			break;
		}
		s = s + s[0];
		s.erase(s.begin());
	}
	if (a)cout << "Yes";
	else cout << "No";
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(void){
    char str[21];
    char reverse[21];
    int i,n;
    
    scanf("%s",str);
    n=strlen(str);
    
    for(i=0; i<n; i++){
        reverse[i]=str[n-1-i];
    }
    
    for(i=0;i<n;i++){
        printf("%c",reverse[i]);
    }
    printf("\n");
    
    return 0;
}

Measured memory_bytes: 524
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps = 1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt" > "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\b.txt"
  
bool isso(long long int a) {
	if (a == 1 || a == 0)return false;
	for (long long int i = 2; i*i <= a; ++i) {
		if ((a%i)) {
		}
		else {
			return false;
		}
	}
	return true;
}
int main() {
	int N;
	while (cin >> N) {
		int ans = 0;
		for (int i = 1; i <= N; ++i) {
			int j = N + 1 - i;
			if (isso(i) && isso(j))ans++;
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3052
import java.util.Scanner;

public class Main  {
    private static Scanner sc= new Scanner(System.in);
    public static void main(String[] s) {
        int a=sc.nextInt();
        sc.nextLine();
        String b=new String(sc.nextLine());
        if(a<3200){
            System.out.print("red");
        }
        else{
            System.out.print(b);
        }
    }}

Measured memory_bytes: 21972
#include<iostream>
using namespace std;
int main(){
  string input;
  cin >> input;
  string tmp = "AC";
  int i =  (int)input.find(tmp);
  if (i == -1){
    cout << "No" << "\n";
  }else{
    cout << "Yes" << "\n";
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <set>
using namespace std;
typedef pair<int, int> P;

set<int> stx[1000005], sty[1000005];

int main()
{
    int h, w, k;
    cin >> h >> w >> k;
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    x1--; y1--; x2--; y2--;
    vector<vector<char>> c(h, vector<char>(w));
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++) cin >> c[i][j];
    }
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            stx[i].insert(j);
            sty[j].insert(i);
        }
    }
    vector<vector<int>> r(h, vector<int>(w));
    for(int i = 0; i < h; i++){
        int s = w;
        for(int j = w - 1; j >= 0; j--){
            if(c[i][j] == '@') s = j;
            r[i][j] = s;
        }
    }
    vector<vector<int>> d(h, vector<int>(w));
    for(int j = 0; j < w; j++){
        int s = h;
        for(int i = h - 1; i >= 0; i--){
            if(c[i][j] == '@') s = i;
            d[i][j] = s;
        }
    }
    vector<vector<int>> l(h, vector<int>(w));
    for(int i = 0; i < h; i++){
        int s = -1;
        for(int j = 0; j < w; j++){
            if(c[i][j] == '@') s = j;
            l[i][j] = s;
        }
    }
    vector<vector<int>> b(h, vector<int>(w));
    for(int j = 0; j < w; j++){
        int s = -1;
        for(int i = 0; i < h; i++){
            if(c[i][j] == '@') s = i;
            b[i][j] = s;
        }
    }
    vector<vector<int>> e(h, vector<int>(w));
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            e[i][j] = -1;
        }
    }
    queue<P> que;
    e[x1][y1] = 0;
    sty[y1].erase(x1);
    stx[x1].erase(y1);
    que.push(P(x1, y1));
    while(que.size()){
        P p = que.front();
        que.pop();
        int x = p.first, y = p.second;
        auto bx = sty[y].lower_bound(max(b[x][y] + 1, x - k));
        auto dx = sty[y].upper_bound(min(d[x][y] - 1, x + k));
        auto itr = bx;
        while(itr != dx){
            int u = *itr, v = y;
            itr++;
            e[u][v] = e[x][y] + 1;
            que.push(P(u, v));
            stx[u].erase(v);
            sty[v].erase(u);
        }
        auto ly = stx[x].lower_bound(max(l[x][y] + 1, y - k));
        auto ry = stx[x].upper_bound(min(r[x][y] - 1, y + k));
        itr = ly;
        while(itr != ry){
            int u = x, v = *itr;
            itr++;
            e[u][v] = e[x][y] + 1;
            que.push(P(u, v));
            stx[u].erase(v);
            sty[v].erase(u);
        }
    }
    cout << e[x2][y2] << endl;
}


Measured memory_bytes: 215216
#include <bits/stdc++.h>
#define ll          long long int
#define uu          first
#define vv          second
#define pii         pair<int,int>
#define pll         pair<ll,ll>
#define fastio      ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int N = 1e6 + 6;
int taken[N];

int main()  {
    fastio;

    int k;
    cin>>k;
    int rem = 7;

    int ans = 0;

    while(++ans) {

        rem %= k;

        if(rem == 0) {
            cout<<ans<<'\n';
            return 0;
        }
        if(taken[rem]) break;

        taken[rem] = 1;
        rem *= 10;
        rem += 7;
    }
    cout<<-1<<'\n';
    return 0;
    
}

Measured memory_bytes: 7552
package main

import (
	"fmt"
)

func main() {
	var n int
	if _, err := fmt.Scan(&n); err != nil {
		panic(err)
	}

	rooms := make([]int, 4*3*10)
	for i := 0; i < n; i++ {
		var b, f, r, v int
		if _, err := fmt.Scan(&b, &f, &r, &v); err != nil {
			panic(err)
		}

		roomI := (b-1)*(3*10) + (f-1)*10 + (r-1)
		rooms[roomI] += v
	}

	for b := 0; b < 4; b++ {
		if b != 0 {
			fmt.Println("####################")
		}
		for f := 0; f < 3; f++ {
			for r := 0; r < 10; r++ {
				fmt.Printf(" %d", rooms[b*(3*10) + f*10 + r])
			}
			fmt.Println()
		}
	}
}



Measured memory_bytes: 1156
#include <iostream>

using namespace std;

int soba[][2] = {
	{200, 380},
	{300, 550},
	{500, 850}
};

int main() {
	int n, m = 5000 * 500;
	cin >> n;
	if (n == 0){
		return 0;
	}
	for (int i = n / soba[2][0]; i >= 0; i--) {
		for (int j = n / soba[1][0]; j >= 0; j--) {
			for (int k = n / soba[0][0]; k >= 0; k--) {
				int w = i * soba[2][0] + j * soba[1][0] + k * soba[0][0];
				if (w == n) {
					int p = (i / 3 * 3 * soba[2][1] * 0.88) + (i % 3 * soba[2][1]) + (j / 4 * 4 * soba[1][1] * 0.85) + (j % 4 * soba[1][1]) + (k / 5 * 5 * soba[0][1] * 0.8) + (k % 5 * soba[0][1]);
					if (p < m) {
						m = p;
					}
				}
			}
		}
	}
	cout << m << endl;
	return main();
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1000000007;


double dp[3000][3000];//dp[i][j]i枚を投げたとき、ｊ枚が表の確率
int main()
{
   memset(dp,0,3000*3000*sizeof(int));
   int n;
   cin >> n;
   vector<double> p(n);
   rep(i,n)cin >> p[i];
   dp[0][0]=1;
   rep(i,n)
   {
      rep(j,i+1)
      {
         dp[i+1][j+1] += dp[i][j]*p[i];
         dp[i+1][j] += dp[i][j]*(1.0-p[i]);
      }
   }
   
   double ans = 0;
   rep(i,n+1)
   {
      if(i>n/2)ans += dp[n][i];
   }
   printf("%.10lf\n",ans);
   return 0;
}

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

int main(){
	int n;
	cin >> n;
	vector<int> d(n);
	for(int i=0;i<n;i++) cin >> d[i];
	ll ans = 0;
	for(int i=0;i<n;i++) {
		for(int j=i+1;j<n;j++) {
			ans += d[i]*d[j];
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
ans=0
for i in range(62):
    c=0
    for ai in a:
        if ai&(1<<i):
            c+=1
    r=c*(n-c)
    ans+=(1<<i)*r
    ans%=(10**9+7)
print(ans)


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

#define rep(i, x, n) for (int i = x; i < n; i++)
typedef long long ll;

const int INF = 1e9 + 7;

using namespace std;

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

    ll a, b;
    cin >> a >> b;

    ll tmp = (b - a) / 2 + a;
    if (abs(a - tmp) == abs(b - tmp))
	cout << tmp << endl;
    else
	cout << "IMPOSSIBLE" << endl;
    
    return 0;
}


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

using namespace std;
using ull = unsigned long long;
using ll = long long;
using lli = long long int;
using ld = long double;
using pa = pair<int, int>;
using ppa = pair<pa, int>;
#define SORT(v, n) sort(v, v + n);
#define ALL(v) v.begin(), v.end()
#define VSORT(v) sort(ALL(v))
#define GRESORT(v) sort(ALL(v), greater<ll>())
#define REVERSE(v) reverse(ALL(v))
#define overlap(v) v.erase(unique(ALL(v)), v.end())
#define debug(x) cout << #x << ": " << x << endl
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for (int i = (b - 1); i >= a; i--)
#define rrep(i, n) RFOR(i, 0, n)
#define INF INT_MAX
#define SUP INT_MIN
#define mins(a, b) a = min(a, b)
#define maxs(a, b) a = max(a, b)

// 4近傍
int dy[]={0, 1, 0, -1};
int dx[]={1, 0, -1, 0};

// 8近傍
// int dy[]={0,0,1,-1,1,1,-1,-1};
// int dx[]={1,-1,0,0,1,-1,1,-1};

// const ll MOD = 1000000007;

ll pow_mod(ll a, ll b, ll mod) {
    ll tmp = 1;
    a %= mod;
    if (b > 0) {
        tmp = pow_mod(a, b / 2, mod);
        if (b % 2)
            tmp = (((tmp * tmp) % mod) * a) % mod;
        else
            tmp = (tmp * tmp) % mod;
    }
    return tmp;
}

void solve() {
    ll n,k; cin >> n >> k;
    ll ans = k;
    rep(i,n-1) ans *= (k-1);
    cout << ans << endl;
}

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

    solve();

    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define fr(i,n) for(i=0;i<n;i++)
#define F first
#define S second
#define fast std::ios_base::sync_with_stdio(false)
#define mod 1000000007
#define pi 3.14159265
int main() {
	fast;
	lli n,i;
	cin>>n;
	string s,t;
	cin>>s>>t;
	fr(i,s.length())
	{
		cout<<s[i]<<t[i];
	}
	
	return 0;
}

Measured memory_bytes: 256
//                                ** ALLAH **
//                        who is Hussain? -> whoishussain.org

#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define fi first
#define se second
#define int long long
typedef long long ll;
typedef pair<int,int> pii;
const int mod=1000000007;
inline int in(){ int x; scanf("%d",&x); return x; }
int n, a[300000];
int32_t main(){
        cin >> n;
        int ans = 0;
        for(int i = 0;i < 3*n;i ++){
                cin >> a[i]; 
        }
        sort(a,a + 3*n);
        for(int i = 3*n-2; i >= n; i-=2){
               ans += a[i]; 
        }
        cout << ans << endl; 
}


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

using namespace std;
using ll = long long;
const ll MOD = 1000003;

int main() {
    ll a, b, c, d;
    cin >> a >> b >> c >> d;

    ll imos[110] = {0};
    imos[a] += 1;
    imos[b] += -1;
    imos[c] += 1;
    imos[d] += -1;

    for (int i = 0; i <= 100; ++i) {
        imos[i+1] += imos[i];
    }

    ll cnt = 0;
    for (int i = 0; i <= 100; ++i) {
        if (imos[i] == 2) cnt++;
    }
    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <map>

using namespace std;

#define rep(i, a, b) for(auto (i)=a;i<b;i++)
#define list(i, N) for(auto (i)=0;i<N;i++)

typedef long long ll;
typedef vector <ll> vi;
typedef pair <ll, ll> pi;
#define mp make_pair
#define pb push_back
#define eb emplace_back

#define int ll
#define INF 1e18+5
#define mod 1000000007

template<class T>
T max(T a, T b, T c) {
    return max(a, max(b, c));
}

#define N 100005

int32_t main() {

    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    int n; cin >> n;
    int b[N] = {};
    list(i,n){
        int cur; cin >> cur;
        b[cur]++; b[cur-1]++; b[cur+1]++;
    }
    int mx = 0;
    list(i,N) mx = max(b[i],mx);

    cout << mx << "\n";
    return 0;
}

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

int main() {
    int64_t X,dis,sum;
    int max_A = 120;
    int64_t i,j;
    cin >> X;
    dis = 0;
    sum = 0;


    for(i = 0; i < max_A; i++){
        j = i;
        while(j >= 0){
            dis = (i-j)*(pow(i,4)+pow(i,3)*j+pow(i,2)*pow(j,2)+i*pow(j,3)+pow(j,4));
            sum = pow(i,5)+pow(j,5);
            //cout << "i = " << i << " " << "j = " << j << endl;
            //cout << "sum = " << sum << " " << "dis = " << dis << endl;
            if(sum == X || dis == X || dis >= X){
                break;
            }
            j--;
        }
        if(sum == X || dis == X){
            break;
        }
    }

    if(sum == X){
        cout << i << " " << j*(-1) << endl;
    }else if(dis == X){
        cout << i << " " << j << endl;
    }else{
        cout << "Error" << endl;
    }
}


Measured memory_bytes: 4096
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		long k = sc.nextLong();
		sc.close();

		long a = n % k;
		long ans = Math.min(a, k - a);
		System.out.println(ans);
	}
}


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

int main(){
  int n;
  cin>>n;
  vector<int> a(n+1,0);
  vector<int> ansa(n+1);
  vector<int> b(n+1,0);
  vector<int> ansb(n+1);
  for(int i=0;i<n;i++){
    cin>>ansa[i];
    a[ansa[i]]++;
  }
  for(int i=0;i<n;i++){
    cin>>ansb[i];
    b[ansb[i]]++;
  }
  int ans=-1;
  for(int i=1;i<=n;i++){
    if(b[i]==0){
      ans=i;
      break;
    }
  }
  //cout<<ans<<endl;
  if(ans==-1){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
    for(int i=0;i<n;i++){
      cout<<ansb[i];
      if(i!=n-1)cout<<" ";
    }
    cout<<endl;
    for(int i=0;i<n;i++){
      if(ansa[i]==ans){
        if(ansb[i]==n){
          cout<<ansb[i]-1;
        }else{
          cout<<ansb[i]+1;
        }
      }else{
        cout<<ansb[i];
      }
      if(i!=n-1)cout<<" ";
    }
    cout<<endl;
  }
}



Measured memory_bytes: 4428
#include <iostream>
#include <vector>
#include <algorithm>

int main(void) {
	// input
	int n, k;
	std::cin >> n >> k;
	std::vector<int> h(n);
	for(int i = 0; i < n; ++i) std::cin >> h[i];

	// sort
	std::sort(h.begin(), h.end());

	// minimum
	int dh = h[k - 1] - h[0];
	for(int i = 1; i + k <= n; ++i) {
		int dh_buf = h[i+k-1] - h[i];
		dh = (dh > dh_buf ? dh_buf : dh);
	}

	std::cout << dh << std::endl;

	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
int main(void){
	using namespace std;
	string A, B, C;
	bool flag = false;
	cin >> A >> B >> C;
	if(A[A.length() - 1] != B[0]){
		flag = true;
	}
	if(B[B.length() - 1] != C[0]){
		flag = true;
	}
	if(!flag){
		cout << "YES" << endl;
	}else{
		cout << "NO" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <string>
#include <set>
#include <map>
#include <tuple>
#include <queue>
#include <stack>
#include <functional>
#define rep(i, a, n) for(int (i) = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int (i) = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int (i) = (int)(a);(x);++(i))
#define repr(i, a, n) for(int (i) = (int)(a);(i) > (int)(n);--(i))
#define reper(i, a, n) for(int (i) = (int)(a);(i) >= (int)(n);--(i))
#define SIZE(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define RNG(x, n) &((x)[0]), &((x)[n])
#define BRK(x) { (x); break; }
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define fcout cout << fixed << setprecision(10)
#define pb push_back
#define EPS (1e-20)
#define INF 2147483647
#define MOD 1000000007
using llint = long long;
using VI = std::vector<int>;
using PII = std::pair<int, int>;
using SI = std::set<int>;
using MII = std::map<int, int>;
using TIII = std::tuple<int, int, int>;
using namespace std;


int N;
MII A;
map<int, int, greater<int>> edge;


void makeEdge(){
	for(PII p : A){
		if(p.second < 2) continue;
		if(p.second == 2 || p.second == 3) edge[p.first] = 2;
		else edge[p.first] = 4;
	}
}


llint solve(){
	if(edge.empty()) return 0;
	if(edge.begin()->second == 4) return (llint)edge.begin()->first*(llint)edge.begin()->first;
	return (llint)edge.begin()->first*(llint)(++edge.begin())->first;
}


signed main(){
	cin >> N;
	rep(i, 0, N){
		int a;
		cin >> a;
		A[a]++;
	}
	
	makeEdge();

	cout << solve() << endl;

	return 0;
}

Measured memory_bytes: 4992
#include <algorithm>
#include <iostream>
#include <queue>
#include <string>
#include <vector>
#include <math.h>
#include <utility>
#include <map>
#include <queue>
#include <stack>

using namespace std;

#define INF 210000000
#define int long long

int gcd(int a, int b) {
  int amari = a % b;
  int c = b;
  if (amari == 0) {
    return b;
  } else {
    return gcd(b, amari);
  }
}

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

signed main() {
		int n;
		cin >> n;
		int ans = 0;
		for(int i=n;0 < i;i--){
				if(to_string(i).length() % 2 == 1) ans++;
		}
		cout << ans;
}



Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
)

func fact(x int) int {
	if x == 0 {
		return 1
	} else {
		return x * fact(x-1)
	}
}

func main() {
	var n int
	fmt.Scan(&n)
	listx := make([]int, n)
	listy := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&listx[i], &listy[i])
	}

	total := 0.0
	ans := 0.0
	for i := 0; i < n; i++ {
		for j := i + 1; j < n; j++ {
			dis := math.Sqrt(math.Pow(float64(listx[j]-listx[i]), 2) + math.Pow(float64(listy[j]-listy[i]), 2))
			total += dis
		}
	}

	ans = total * 2 / float64(n)
	fmt.Println(ans)
}


Measured memory_bytes: 512