akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
#define pb push_back
#define mp make_pair
#define fi first
#define se second

int main()
{
	int a[105][105],b,n;
	vector<int> v;
	for (int i = 0; i < 3; ++i)
	{
		for(int j=0;j < 3; ++j)
		{
			cin>>a[i][j];
		}
	}
	cin>>n;
	for (int i = 0; i < n; ++i)
	{
		cin>>b;
		v.push_back(b);
	}
	for (int i = 0; i < 3; ++i)
	{
		for(int j=0;j < 3; ++j)
		{
			 for(int k=0;k < n; ++k)
			 {
			 	if(v[k]==a[i][j])
			 	{
			 		v[k]=0;
			 		a[i][j]=0;
			 	}
			 }
		}
	}
	for (int i = 0; i < 3; ++i)
	{
		if(a[i][0]==0&&a[i][1]==0&&a[i][2]==0)
		{
			cout<<"Yes"<<endl;
			return 0;
		}
		else if(a[0][i]==0&&a[1][i]==0&&a[2][i]==0)
		{
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	if((a[0][0]==0&&a[1][1]==0&&a[2][2]==0)||(a[0][2]==0&&a[1][1]==0&&a[2][0]==0))
	{
		cout<<"Yes"<<endl;
		return 0;
	}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(lint (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
#define all(x) (x).begin(),(x).end()
const lint MOD =1000000007;
const lint MAX = 1000000;
using Graph =vector<vector<lint>>;
typedef pair<lint,lint> P;
 
 
lint fac[MAX], finv[MAX], inv[MAX];
 
void COMinit() 
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
long long COM(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return 0;
        }
    }
 
    return 1;
}
   long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
    lint lcm(lint a,lint b){
        return a/__gcd(a,b)*b;
    }
     lint gcd(lint a,lint b){
        return __gcd(a,b);
    } 
    long double dp[4000][4000];
  int main(){      
      lint n;
      cin>>n;
      double a[n];
      rep(i,n)cin>>a[i];
      dp[0][0]=1;
        rep(i,n){
            rep(j,i+2){
           if(j==0) dp[i+1][j]=(1-a[i])*(dp[i][j]);
           else dp[i+1][j]=(1-a[i])*(dp[i][j])+(a[i])*dp[i][j-1];
            }
        }
        long double ans=0;
        repp(i,n/2+1,n+1)ans+=dp[n][i];
        printf("%.11Lf\n",ans);
      }
  
     


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

// int/long:		-2,147,483,648 - 2,147,483,648 (-2^31 <= int < 2^31)
// long/long long:	-9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

#define	INF (1<<29)
//536,870,912

// lower_bound(A.begin(), A.end(), N)
// upper_bound(...

// A.erase(unique(A.begin(), A.end()), A.end())

// bit: &/and, |/or, ^/xor, ~/not

// getline(cin, String)

// Graph
// Warshall-Floyd: Distance between each node, N^3
// Dijkstra: Distance from the start node, N^2
// DFS(Depth-First Search)

#define	MOD 1000000007

int	main() {
	int X;
	cin >>X;
	int MIN=X/105;
	int MAX=X/100;
	for (int i=MIN; i<=MAX; i++) {
		if ((X>=100*i)&&(X<=105*i)) {
			cout <<1 <<endl;
			return 0;
		}
	}
	cout <<0 <<endl;
	return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<string>
using namespace std;
int main(){
  string s,s1;
 cin>>s>>s1;
  int cnt=0;
  for(int i=0;i<s.size();i++){
    if(s[i]!=s1[i]){
      cnt++;
    }
    
  }
  cout<<cnt<<endl;
}


Measured memory_bytes: 3444
import java.util.*;
class Main{
	static Scanner s=new Scanner(System.in);
	static int getInt(){return Integer.parseInt(s.next());}
	public static void main(String[]$){
		int[]a=new int[114];
		++a[getInt()];
		--a[getInt()];
		++a[getInt()];
		--a[getInt()];
		Arrays.parallelPrefix(a,Integer::sum);
		System.out.println(Arrays.stream(a).filter(i->i==2).count());
	}
}

Measured memory_bytes: 30932
import sys
import math

def str_input():
    S = raw_input()
    if S[len(S)-1] == "\r":
        return S[:len(S)-1]
    return S

def float_to_str(num):
    return str("{:.10f}".format(num))

def list_input(tp):
    return map(tp, str_input().split())

# # # # # # # # # # # # # # # # # # # # # # # # #

n = input()
a = list_input(float)
b = list_input(float)

for d in xrange(1, 4):
    dist = 0
    for i in xrange(n):
        dist += pow(abs(a[i] - b[i]), d)
    dist = pow(dist, 1./d)
    print float_to_str(dist)

dist = 0
for i in xrange(n):
    dist = max(dist, abs(a[i] - b[i]))
print dist

Measured memory_bytes: 6696
#include<iostream>

using namespace std;

int main(){
  int n,q;
  cin>>n;
  int S[n];
  for(int i=0;i<n;i++){
    cin>>S[i];
  }
  cin>>q;
  int T[q];
  for(int i=0;i<q;i++){
    cin>>T[i];
  }
  int count=0;
  for(int i=0;i<q;i++){
    for(int p=0;p<n;p++){
      if(S[p]==T[i]){
        count++;
        break;
      }
    }
  }
  cout<<count<<endl;
}



Measured memory_bytes: 3132
<?php

fscanf(STDIN, "%d", $k);
fscanf(STDIN, "%d %d", $a, $b);

$flg = false;
for ($i = $a; $i <= $b; ++$i) {
    if ($i % $k === 0) {
        $flg = true;
        break;
    }
}

echo $flg ? 'OK' : 'NG';


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

struct Timer {
	timespec start;
	Timer(){ clock_gettime(CLOCK_MONOTONIC, &start); }
	double elapsed()
	{
		timespec curr;
		clock_gettime(CLOCK_MONOTONIC, &curr);
		auto sec=curr.tv_sec-start.tv_sec;
		auto nsec=curr.tv_nsec-start.tv_nsec;
		return sec+nsec*1e-9;
	}
};
int main()
{
	Timer timer;
	int n; cin>>n;

	timespec t={0, 1000};
	while (timer.elapsed()<0.789) nanosleep(&t, 0);
	cout<<(n/10%111==0 or n%1000%111==0 ? "Yes" : "No")<<endl;
}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
	public void run() {
		Scanner scan = new Scanner(System.in);
		StringBuilder str = new StringBuilder(scan.next());
		int p = Integer.parseInt(str.substring(0, 2));
		int s = Integer.parseInt(str.substring(2, 4));

		if (p == 0 && s < 13) {
			if (s == 0)
				System.out.println("NA");
			else
				System.out.println("YYMM");
			return;
		}
		if (s == 0 && p < 13) {
			if (p == 0)
				System.out.println("NA");
			else
				System.out.println("MMYY");
			return;
		}
		if (s == 0 || p == 0) {
			System.out.println("NA");
			return;
		}

		if (p > 12) {
			if (s > 12)
				System.out.println("NA");
			else
				System.out.println("YYMM");
		} else {
			if (s > 12)
				System.out.println("MMYY");
			else
				System.out.println("AMBIGUOUS");
		}
	}
	public static void main(String[] args) {
		new Main().run();
	}

}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define ff(i,a,b) for(int i = a; i < b; i++)
#define fb(i,a,b) for(int i = a; i > b; i--)
#define MOD 1000000007


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


void solve(){
	int n,x,t;
	cin>>n>>x>>t;
	int c=ceil(n/((1.0)*x));
	cout<<c*t;
}

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif

	//int t;
    //cin>>t;
	//while(t--)
		solve();
	cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
	return 0;
}

Measured memory_bytes: 3800
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

typedef long long ll;

#define rep(i, n) for (ll(i) = 0; i < (ll)(n); ++(i))
#define INF 10e12
#define MOD 1000000000 + 7
#define MX 51000
#define all(x) (x).begin(), (x).end()
#define MAX(x) *max_element(all(x))
#define MIN(x) *min_element(all(x))

using namespace std;

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    vector<vector<ll>> vec(N, vector<ll>(3));
    rep(i, N)
    {
        rep(j, 3) cin >> vec[i][j];
    }
    vector<vector<ll>> dp(N, vector<ll>(3));
    for (ll i = 0; i < 3; ++i)
        dp[0][i] = vec[0][i];
    for (ll i = 1; i < N; ++i)
    {
        dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + vec[i][0];
        dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + vec[i][1];
        dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + vec[i][2];
    }

    cout << max(dp[N - 1][0], max(dp[N - 1][1], dp[N - 1][2])) << endl;
}


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

int main(){
    int n;
    cin>>n;
    string str;
    map<string,int>mp;
    for(int i=1;i<=n;i++){
        cin>>str;
        mp[str]++;
    }
    int mx=0;
    for(auto it:mp){
        if(it.second>mx)
            mx=it.second;
    }
    set<string>vec;

    for(auto it:mp){
        if(it.second == mx){
            vec.insert(it.first);
        }
    }
 
    for(auto it:vec) cout<<it<<endl;
    return 0;
}


Measured memory_bytes: 34560
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=2e5+10;
inline ll read()
{
	ll x=0,f=1;char wty=getchar();
	while(!isdigit(wty)){if(wty=='-')f=0;wty=getchar();}
	while(isdigit(wty)){x=x*10+wty-'0';wty=getchar();}
	return f?x:-x;
}
struct mmp
{
	int nxt,to,w;
}e[N*2];
int n,m,cnt;
int vis[N],dis[N],head[N*2],pu[N];
inline void ade(int x,int y,int w)
{
	e[++cnt].nxt=head[x];
	e[cnt].to=y;
	e[cnt].w=w;
	head[x]=cnt;
}
queue<int> q;
inline bool spfa(int s)
{
	dis[s]=0,vis[s]=1;
	q.push(s);
	while(!q.empty())
	{
		int u=q.front();q.pop();
		for(int i=head[u];i;i=e[i].nxt)
		{
			int v=e[i].to;
			if(dis[v]==0x3f3f3f3f)
			{
				dis[v]=dis[u]+e[i].w;
				pu[v]=1;
				if(vis[v]) continue;
				q.push(v);
			}
			else if(dis[v]!=dis[u]+e[i].w) return false;
		}
		vis[u]=0;
	}
	return true;
}
int main()
{
	memset(dis,0x3f3f3f3f,sizeof(dis));
	n=read(),m=read();
	for(int i=1;i<=m;i++)
	{
		int l=read(),r=read(),d=read();
		ade(l,r,d),ade(r,l,-d);
	}
	for(int i=1;i<=n;i++)
	{
		if(pu[i]) continue;
		pu[i]=1;
		if(!spfa(i))
		{
			cout<<"No";
			return 0;
		}
	}
	cout<<"Yes";
	return 0;
}

Measured memory_bytes: 7936
#include<bits/stdc++.h>
using namespace std;
int main(){
int x,y[1000],z=0;
scanf("%d",&x);
for(int i=0;i<x;i++){
    scanf("%d",&y[i]);
}
for(int i=0;i<x;i++){
    for(int j=0;j<x-1;j++){
        if(y[j]>y[j+1]){
            int h;
            h=y[j];
            y[j]=y[j+1];
            y[j+1]=h;
            z++;
        }
    }
}
for(int i=0;i<x;i++){
        if(i==x-1){
            printf("%d\n",y[i]);
        }else{
            printf("%d ",y[i]);
        }
}
printf("%d\n",z);
}

Measured memory_bytes: 3180
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <set>
#include <cmath>
using namespace std;

typedef long long ll;


set<ll> yz;


bool f(ll x, ll y){
    while(x%y==0){
        x/=y;
    }
    return x%y==1;
}
int main(){
    ll n;
    cin>>n;
    if(n==2){
        cout<<1<<endl;
        return 0;
    }
    int S =0;
    for(int i = 2; i<=sqrt(n); i++ ){
        if(n%i==0) {
            if(f(n,i)) ++S;
        }
    }


    for(int i = 2; i<=sqrt(n-1); i++){
        if((n-1)%i==0){
            yz.insert(i);
            yz.insert((n-1)/i);
        }
    }
    int ans = S+yz.size();
    cout<<ans+2<<endl;
    return 0;

}

Measured memory_bytes: 256
s = input()
count = 0
first_half, second_half = s[:len(s)//2], s[(len(s)+1)//2:]
if first_half == reversed(second_half):
    print(count)
else:
    for x in range(len(first_half)):
        if first_half[x] != second_half[len(second_half)-x-1]:
            count += 1
    print(count)

Measured memory_bytes: 3060
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int main() {
	char a[15];scanf("%s",a+1);int n=strlen(a+1);int ans=0x7fffffff;
	for(int i=1;i<=n-2;++i) {
		int now=0;
		for(int j=i;j<=i+2;++j) 
			now=now*10+a[j]-'0';
		ans=min(ans,abs(now-753));
	}printf("%d",ans);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <stdio.h>
using namespace std;

int main()
{
    int k[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int num;
    while(~scanf("%d",&num)){
            printf("%d\n",k[num-1]);
    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
  unsigned long long a[30];
  unsigned long long b[30];
  char n[30];
  int cnt,i;
  unsigned long long A;
	
  	scanf("%llu",&A);
	
    b[0] = (unsigned long long)A%26;
    a[0] = ((unsigned long long)A/26);
     if(b[0] == 0){
       a[0] = a[0]-1;
     }

 	for(i=0;i<20;i++){
	      if(a[i] == 0){
	        cnt = i;
	        break;
	      }
 		
	  	b[i+1] = a[i]%26;
 		a[i+1] = (a[i]/26);
	     if(b[i+1] == 0){
   	     a[i+1] = a[i+1]-1;
   		 }
    }
	
  	for(i=cnt;i>=0;i--){
      	if(b[i] != 0){
    		n[i] = b[i]+96;
        }else{
         	n[i] = 122;
        }
    }
	
  	for(i=cnt;i>=0;i--){
     	printf("%c",n[i]); 
    }
  
}

Measured memory_bytes: 1628
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) (a).begin(),(a).end()
#define print(A,x,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i]x;}cout<<endl;
#define pprint(A,y,m,n) rep(j,0,m){print(A[j],y,n);}
const long mod=1e5;
const int size=1e5;
const int inf=1e9;
int main(){
	string s; cin>>s;
	if(s == "SSS") cout<<0<<endl;
	else if(s == "RRR") cout<<3<<endl;
	else if(s == "RRS" || s == "SRR") cout<<2<<endl;
	else cout<<1<<endl;
}

Measured memory_bytes: 3624
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Text;

public class Program
{

    public void Proc()
    {
        long[] inpt = Reader.ReadLine().Split(' ').Select(a => long.Parse(a)).ToArray();

        this.Kodomo = new long[(int)inpt[0]];

        long totalOkasi = inpt[1];

        this.Kodomo = Reader.ReadLine().Split(' ').Select(a => long.Parse(a)).OrderBy(s=>s).ToArray();

        int ans = 0;

        foreach(int k in Kodomo) {
            if(totalOkasi < k) {
                totalOkasi = 0;
                break;
            }
            totalOkasi -= k;
            ans++;
        }
        if(totalOkasi > 0) {
            ans--;
        }
        Console.WriteLine(ans);
    }


    private long[] Kodomo;

    public class Reader
    {
        static StringReader sr;
        public static bool IsDebug = false;
        public static string ReadLine()
        {
            if (IsDebug)
            {
                if (sr == null)
                {
                    sr = new StringReader(InputText.Trim());
                }
                return sr.ReadLine();
            }
            else
            {
                return Console.ReadLine();
            }
        }
        private static string InputText = @"



2 10
20 20

";
    }

    public static void Main(string[] args)
    {
#if DEBUG
        Reader.IsDebug = true;
#endif
        Program prg = new Program();
        prg.Proc();
    }
}


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

using namespace std;

int
main ()
{
  int n;
  cin>>n;
  int ac[n][3];
  int table[n][3];
  for(int i=0; i<n; i++){
      for(int j=0; j<3; j++){
        cin>>ac[i][j];
      }
  }
  for(int i=0; i<3; i++){
        table[0][i]=ac[0][i];
  }
  int in[3][2];
  in[0][0]=1;
  in[0][1]=2;
  in[1][0]=0;
  in[1][1]=2;
  in[2][0]=0;
  in[2][1]=1;
  //llenar
  for(int i=1; i<n; i++){
      for(int j=0; j<3; j++){
          table[i][j]=max(table[i-1][in[j][0]],table[i-1][in[j][1]])+ac[i][j];
      }
  }
  int res=max(max(table[n-1][0],table[n-1][1]),table[n-1][2]);
  cout<<res;

  return 0;
}

Measured memory_bytes: 2560
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>

auto& in = std::cin;
auto& out = std::cout;
#define all_range(C) std::begin(C), std::end(C)
const double PI = 3.141592653589793238462643383279502884197169399375105820974944;

int64_t N;

int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
	in.tie(nullptr);
	out.tie(nullptr);

	in >> N;
	if (N == 0) {
		out << 0 << endl;
		return 0;
	}
	std::string res;
	while (N != 0) {
		if (N%-2!=0) {
			N -= 1;
			res += '1';
		}
		else {
			res += '0';
		}
		N /= -2;
	}
	std::reverse(res.begin(), res.end());
	out << res << endl;


	return 0;
}
#endif


Measured memory_bytes: 256
from collections import deque

dq = deque(list(input()))

Q = int(input())

reverse_count = 0

for i in range(Q):
    query = input().split()
    if query[0] == "1":
        reverse_count = 1 - reverse_count
    else:
        F = query[1]
        C = query[2]
        if F == "1":
            if reverse_count == 0:
                dq.appendleft(C)
            else:
                dq.append(C)
        else:
            if reverse_count == 0:
                dq.append(C)
            else:
                dq.appendleft(C)

if reverse_count == 0:
    print("".join(dq))
else:
    print("".join(reversed(dq)))


Measured memory_bytes: 8548
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
typedef int64_t Int;


int main(){
    string S, T;
    cin >> S >> T;

    int L = S.length();

    rep(i, L){
        bool flag = true;
        rep(j, L){
            if(S[j] != T[(j+i)%L]) flag = false;
        }
        if(flag){
            cout << "Yes" << endl; return 0;
        }
    }

    cout << "No" << endl;
}

Measured memory_bytes: 256
n = gets.to_i
li_b = gets.split.map(&:to_i)
if li_b.length == 1
  puts(li_b[0] * 2)
else
  sum_a = li_b[0] + li_b.last
  (li_b.length - 1).times do |i|
    sum_a += li_b[i] < li_b[i+1] ? li_b[i] : li_b[i+1]
  end
  puts sum_a
end


Measured memory_bytes: 1788
n = int(input())
d = list(map(int, input().split()))
d.sort()
d_a = [v if i % 2 == 0 else 24-v for i, v in enumerate(d)]
d_b = [v if i % 2 == 1 else 24-v for i, v in enumerate(d)]
d_a.append(0)
d_b.append(0)
d_a.sort()
d_b.sort()
res_a = 24
res_b = 24
for i in range(n):
    res_a = min(res_a, d_a[i+1]-d_a[i])
    res_b = min(res_b, d_b[i+1]-d_b[i])
res_a = min(res_a, 24-d_a[-1]+d_a[0])
res_b = min(res_a, 24-d_b[-1]+d_b[0])
res = max(res_a, res_b)
if res == 24:
    res = 0
print(res)


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

int main()
{
    char a[102][102];
    int h,w;
    while(cin >> h >> w)
    {
        for(int i = 0;i < h;i++)
        cin >> a[i];
        for(int i = 0;i < h;i++)
        {
            for(int j = 0;j < 2;j++)
            cout << a[i] << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
import math
import sys
N,K=map(int,input().split())
anssub=0
for i in range(N,0,-1):
  a=0
  while i*(2**a)<K:
    a+=1
  for i in range(a):
    anssub+=(1/N)*(1/2)**(i+1)
ans=1-anssub
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
const int N=2005;
int n,x[N],y[N],len,f[N],d[N];
void Print(int X,int Y){
	for (int i=1;i<=len;i++){
		if (abs(X)>abs(Y)){
			if (X>0) putchar('R'),X-=d[i];
			else putchar('L'),X+=d[i];
		}
		else {
			if (Y>0) putchar('U'),Y-=d[i];
			else putchar('D'),Y+=d[i];
		}
	}
	puts("");
	return;
}
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;i++){
		scanf("%d%d",&x[i],&y[i]);
		f[(x[i]+y[i])%2]++;
	}
	if (f[1]&&f[0]){
		puts("-1");
		return 0;
	}
	for (int i=30;i>=0;i--)d[++len]=(1<<i);
	if (f[0])d[++len]=1;
	printf("%d\n",len);
	for (int i=1;i<=len;i++)printf("%d ",d[i]);
	puts("");
	for (int i=1;i<=n;i++)Print(x[i],y[i]);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int k,x,i=0;
    scanf("%lld %lld",&k,&x);
    if(k==1)
        printf("%lld",x);
    else
    {
        for(i=x-(k-1);i<=x+(k-1);i++)
            printf("%lld ",i);
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int num[5];
  cin >>num[0]>>num[1]>>num[2]>>num[3]>>num[4];
  sort(num,num+5);
  cout <<num[4]<<" "<<num[3]<<" "<<num[2]<<" "<<num[1]<<" "<<num[0]<<endl;
  return 0;
}

Measured memory_bytes: 1180
//01
#include<iostream>
#include<string>
#include<vector>

using namespace std;

int l,h;
vector<string> tr;
vector<int> hi,bl;
char t[11];
string a;
int ac;

void dfs(int d,int u){
  if(d!=l){
    for(int i=0;i<10;i++){
      if(!(u>>i&1)){
	t[d]='0'+i;
	for(int i=0;i<tr.size();i++){
	  int ch=0,cb=0;
	  for(int j=0;j<=d;j++){
	    if(tr[i].find(t[j])!=string::npos){
	      ((t[j]==tr[i][j])?ch:cb)++;
	    }
	  }
	  if(ch+l-d-1<hi[i]||ch>hi[i]||cb+l-d-1<bl[i]||cb>bl[i])goto next;
	}
	dfs(d+1,u|1<<i);
      next:
	;
      }
    }
  }else{
    t[d]=0;
    ac++;
    a=t;
  }
}

int main(){
  while(cin>>l>>h,l|h){
    tr.resize(h);
    hi.resize(h);
    bl.resize(h);
    while(h--){
      cin>>tr[h]>>hi[h]>>bl[h];
    }
    ac=0;
    dfs(0,0);
    if(ac==1){
      cout<<a<<endl;
    }else{
      cout<<"NO"<<endl;
    }
  }
  return 0;
}

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

using namespace std;

typedef long long ll;

#define INF (int)1e9+7
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vector<int>>
#define vvl vector<vector<long long>>
#define pii pair<int,int>
#define pll pair<long,long>
#define vpii vector<pii>
#define vpll vector<pll>
//#define N 100005
#define pb push_back
#define mp make_pair
#define PI 3.1415926535897932384626433832795


ll powM(ll a,ll b,ll m )
{ 
  a%=m;
  ll ans=1;
  while(b>0)
  {
    if(b&1)ans=ans*a%m;
    a=a*a%m;
    b>>=1;
  }

return ans;
}

ll N=2e5+1;

ll solve(ll t,vector<ll>& a,ll n)
{
  ll ans=0;
  for(int i=1;i<=n;i++)
    ans+=(a[i]-t)*(a[i]-t);

  return ans;

}


ll bx(ll n)
{
  ll temp=10;
  while(n)
  {
    temp=min(temp,n%10);
    n/=10;
  }
  return temp;
}

ll ax(ll n)
{
  ll temp=0;
  while(n)
  {
    temp=max(temp,n%10);
    n/=10;
  }
  return temp;
}



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


ll x;cin>>x;
cout<<3*x*x<<"\n";




return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
#include<vector> //動的配列
#include<string> 
#include <list> //双方向リスト
#include <map> //連想配列
#include <set> //集合
#include <stack>
#include <queue>
#include <deque>
#include <cmath>


//小さい順から取り出すヒープ
//priority_queue<ll, vector<ll>, greater<ll> > pque1;

typedef long long ll;


using namespace std;

typedef pair<int, int> P;

template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

int r,c,n,sr,sc;


int main(){
    cin>>r>>c>>n>>sr>>sc;
    char l1[n];
    char l2[n];
    for (int i=0;i<n;i++){
        cin>>l1[i];
    }
    for (int i=0;i<n;i++){
        cin>>l2[i];
    }
    P py=make_pair(1,r);
    P px=make_pair(1,c);
    for (int i=n;i>0;i--){
        if (l2[i-1]=='D'){
            py.first=max(1,py.first-1);
        } else if (l2[i-1]=='U'){
            py.second=min(r,py.second+1);
        } else if (l2[i-1]=='R'){
            px.first=max(1,px.first-1);
        } else if (l2[i-1]=='L'){
            px.second=min(c,px.second+1);
        }
        if (l1[i-1]=='D'){
            py.second=py.second-1;
        } else if (l1[i-1]=='U'){
            py.first=py.first+1;
        } else if (l1[i-1]=='R'){
            px.second=px.second-1;
        }else if (l1[i-1]=='L'){
            px.first=px.first+1;
        }
        if (px.first<=0 || py.first<=0 || c<px.second || r<py.second ||px.first>px.second || py.first>py.second){
            cout<<"NO"<<endl;
            return 0;
        }
        //cout<<px.first<<px.second<<py.first<<py.second<<endl;;
    }
    if (px.first<=sc && sc<=px.second && py.first<=sr && sr<=py.second){
        cout<<"YES"<<endl;
        return 0;
    } else {
        cout<<"NO"<<endl;
    }
    
}

Measured memory_bytes: 640
parseInt(x) = parse(Int, x)
parseBigInt(x) = parse(BigInt, x)
parseFloat(x) = parse(Float64, x)
parseBigFloat(x) = parse(BigFloat, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    s=chomp(readline())
    if s[3]==s[4] && s[5]==s[6]
        println("Yes")
    else
        println("No")
    end

end
main()

Measured memory_bytes: 109960
#include <iostream>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <string.h>
#include <stack>
#define Endl endl
#define mp make_pair
#define ll long long 
#define pii pair<int,int>
#define pll pair<ll,ll>
#define over(A) {cout<<A<<endl;exit(0);}
#define all(A) A.begin(),A.end()
#define ceil(a,b) ((a-1)/b+1)
#define srand() mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define rand(l,r) uniform_int_distribution<int>(l,r)(rng)
typedef unsigned long long ull;
const int inf=1039074182;
using namespace std;
int n,k;
int dp[105][10005];

namespace combinatorics
{
	int *fac;
	int *ifac;
	int mod;
	inline int add(int a,int b)
	{
		return (a+b)%mod;
	}
	inline int minus(int a,int b)
	{
		return (a-b+mod)%mod;
	}
	inline int mutiply(int a,int b)
	{
		return (1LL*a*b)%mod;
	}
	inline int fastpow(int basic,int x)
	{
		int res=1;
		while(x)
		{
			if(x&1)	res=mutiply(res,basic);
			basic=mutiply(basic,basic);
			x>>=1;
		}
		return res;
	}
	inline int inv(int x)
	{
		return fastpow(x,mod-2);
	}
	void init(int n,int tmod)
	{
		mod=tmod;
		fac=new int[n+5];
		ifac=new int[n+5];
		fac[0]=1;
		for(int i=1;i<=n;i++)
		{
			fac[i]=mutiply(fac[i-1],i);
		}
		ifac[n]=inv(fac[n]);
		for(int i=n-1;i>=0;i--)
		{
			ifac[i]=mutiply(ifac[i+1],i+1);
		}
	}
	inline int C(int n,int m)
	{
		return mutiply(mutiply(fac[n],ifac[m]),ifac[n-m]);
	}
};
using namespace combinatorics;
int main()
{
//	freopen("input.txt","r",stdin);
	cin>>n>>k;
	init(n,1e9+7);
	dp[n][0]=1;
	int res=mutiply(n,mutiply(k,mutiply(inv(2),fastpow(k+1,n))));
	for(int i=n;i>=1;i--)
	{
		for(int j=0;j<=k*(n-i);j++)
		{
			for(int put=0;put<=k;put++)
			{
				if(put<=i)
				{
					dp[i-1][j+(put+j)/i]=add(dp[i-1][j+(put+j)/i],dp[i][j]);
				}
				else
				{
					dp[i-1][j]=add(dp[i-1][j],dp[i][j]);
				}
			}
		}
	}
	for(int i=0;i<=n*k;i++)
	{
		res=combinatorics::minus(res,mutiply(dp[0][i],i));
	}
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 3968
# -*- coding: utf-8 -*-
from collections import Counter

def update_distance(d, num, N):
    minn = num
    maxx = num
    # 要素数の小さい方に向けて
    while True:
        if minn > 0:
            minn -= 1
        else:
            break
        if d[minn] > d[minn+1] + 1:
            d[minn] = d[minn+1] + 1
        else:
            break
    # 要素数の大きいほうに向けて
    while True:
        if maxx < (N - 1):
            maxx += 1
        else:
            break
        if d[maxx] > d[maxx-1] + 1:
            d[maxx] = d[maxx-1] + 1
        else:
            break

(N, X, Y) = (int(i) for i in input().split())
X = X-1
Y = Y-1

# まずは経路情報をd[N][N]の二次元配列に格納
# (i, j)がつながっていれば1, つながってなければ2*10^3

d = []
for i in range(N):
    dd = []
    for j in range(N):
        dd.append(abs(i - j))
    d.append(dd)

# XとYがつながることで最短経路を修正していく
for i in range(N):
    dd = d[i]
    dd[X] = min(dd[X], dd[Y] + 1)
    dd[Y] = min(dd[Y], dd[X] + 1)
    update_distance(dd, X, N)
    update_distance(dd, Y, N)

# dの全リストを連結してあとは0~N-1までカウントする
d_list = []
for i in range(N - 1):
    d_list += d[i][i+1:]

#print(d_list)
c = Counter(d_list)

for i in range(1, N):
    if i in c:
        print(c[i])
    else:
        print(0)

Measured memory_bytes: 150204
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int x,n;
    cin>>x>>n;
    if(n==0)
        cout<<x<<endl;
else 

{
    map<int,int>m;
    int xx;
    for(int i=0;i<n;i++)
    {
        cin>>xx;
        m[xx]=1;
    }
    if(m[x]==0)
        cout<<x<<endl;
    else 
    {
        if(x==1)
            cout<<0<<endl;
        else 
        {
            int left = x-1;
            int right = x+1;
            int flag_r=0;
            int flag_l=0;
            int found=0;
            int ans=0;
            while(left!=0)
            {
                if(m[left]==0)
                {
                    found=1;
                    ans=left;
                    break;
                }
                else if(m[right]==0)
                {
                    found=1;
                    ans=right;
                    break;
                }
                else 
                {
                    left--;
                    right++;
                }
            }
                cout<<ans<<endl;     
        } 
    }
}
    
    // sort(arr,arr+n);
   
    
    
    return 0;
}

Measured memory_bytes: 3636
#include<cstdio>
inline int abs(int x){
    return (x>0)?x:(-x);
}
inline int l1(int i,int j,int x,int y){
    return abs(x-i)+abs(y-j);
}
int ai[90001],aj[90001],l[90001];
int main(){
    int h,w,d,q,a;
    scanf("%d%d%d",&h,&w,&d);
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            scanf("%d",&a);
            ai[a]=i;
            aj[a]=j;
        }
    }
    for(int i=0;i<d&&i+d<=h*w;i++){
        l[i]=0;
        for(int x=i;x+d<=h*w;x+=d){
            l[x+d]=l[x]+l1(ai[x],aj[x],ai[x+d],aj[x+d]);
        }
    }
    scanf("%d",&q);
    for(int i=0;i<q;i++){
        int li,ri;
        scanf("%d%d",&li,&ri);
        printf("%d\n",l[ri]-l[li]);
    }
    return 0;
}

Measured memory_bytes: 2048
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  sort(a.begin(),a.end());
  int k=0,rm=0;
  while(k<n){
    int cnt=1;
    while(a[k]==a[k+1]) {
      k++;
      cnt++;
    }
    if(a[k]<=cnt){
      rm += cnt-a[k];
    }
    else{
      rm += cnt;
    }
    k++;
  }
  cout << rm << "\n";
  return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<numeric>
#include<limits>
#include<bitset>
#include<functional>
#include<type_traits>
#include<queue>
#include<stack>
#include<array>
#include<random>
#include<utility>
#include<cstdlib>
#include<ctime>

using namespace std;

typedef  long long ll;
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep2(i, begin_i, end_i) for (int i = (int)begin_i; i < (int)end_i; i++)

long long INF = 1LL<<60;
long long dp[100010];
int h[100010];
int x;
int main(){
    int64_t n,m;
    cin>>n>>m;
    if(n==1&&m==1)cout<<1<<endl;
    else if(m==1){cout<<n-2<<endl;}
    else if(n==1){cout<<m-2<<endl;}
    else cout<<(n-2)*(m-2)<<endl;
    return 0;
}




Measured memory_bytes: 256
# -*- coding: utf-8 -*-

if __name__ == '__main__':

	l = input()
	S1, S2 = [], []
	
	sum = 0
	n = len(l)
	for i in range(n):
		if l[i] == "\\":
			S1.append(i)
		elif l[i] == "/" and S1:
			j = S1.pop()
			a = i - j
			sum += a
	
			while S2 and S2[-1][0] > j:
				a += S2.pop()[1]
			S2.append([j, a])
	
	print(sum)
	print(len(S2), *(a for j, a in S2))

Measured memory_bytes: 8284
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define PB push_back
#define PPB pop_back
#define MP make_pair
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define test(x) cout<<(x)<<" "
#define d1(x) cout<<(x)<<endl
#define d2(x,y) cout<<(x)<<" "<<(y)<<endl
#define d3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define loop(i,start,end) for(ll i=start; i<end; i++)
#define rloop(j,start,end) for(ll j=start-1; j>=end; j--)

int main()
{   
    IOS;
  
    string s1,s2,ans="";
    cin>>s1>>s2;

    ll n=s1.length(),m=s2.length();
    ll dp[n+1][m+1];

    memset(dp,0,sizeof(dp));
    
    loop(i,1,n+1)
        loop(j,1,m+1)
        {
            if(s1[i-1]==s2[j-1])
                dp[i][j]=dp[i-1][j-1]+1;
            else
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
        }

    ll length=dp[n][m],temp;
    temp=length;
    char c[length];

    //c[length]='@';
    ll i=n,j=m;

    while(i>0 && j>0)
    {
        if(s1[i-1]==s2[j-1])
        {
            c[length-1]=s1[i-1];
            i--; j--;
            length--;
        }

        else if(dp[i-1][j]>dp[i][j-1])
            i--;
        else
            j--;
    }

    loop(i,0,temp)
        cout<<c[i];
    d1("");
}

Measured memory_bytes: 70656
package main

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

func main() {
	s := wordScanner()

	var l, r int
	scanInts(s, &l, &r)

	d := r - l
	head := l % 2019

	if head+d >= 2019 {
		fmt.Println(0)
	} else {
		min := 2019
		for i := l; i < r; i++ {
			for j := i + 1; j <= r; j++ {
				if a := (i * j) % 2019; a < min {
					min = a
				}
			}
		}
		fmt.Println(min)
	}
}

func wordScanner() *bufio.Scanner {
	s := bufio.NewScanner(os.Stdin)
	s.Split(bufio.ScanWords)
	return s
}

func scanInts(s *bufio.Scanner, vals ...*int) {
	for i := range vals {
		s.Scan()
		n, _ := strconv.Atoi(s.Text())
		*vals[i] = n
	}
}


Measured memory_bytes: 640
n,k=map(int,input().split())
DIV = 10**9+7

count = 0
for i in range(k,n+2):
  min_k = i*(i-1)/2
  max_k = i*(2*n-i+1)/2
  count += max_k - min_k + 1
print(int(count % DIV))

Measured memory_bytes: 9128
#![allow(unused_imports)]

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

use std::cmp::{min, max};
use std::collections::{HashMap, HashSet, VecDeque, BinaryHeap};

fn main() {
    input!{
        h1: i64,
        m1: i64,
        h2: i64,
        m2: i64,
        k: i64
    }
    let ans = 60 * (h2 - h1) + m2 - m1 - k;
    println!("{}", max(ans, 0));
}


Measured memory_bytes: 2068
n = gets.to_i
c = n.times.map{gets.to_i-1}
mod = 10**9+7
dp = Array.new(n+1,0)
dp[0] = 1
a = Hash.new(-1)
n.times do |i|
    dp[i+1] = dp[i]
    if a[c[i]] > -1 && c[i-1] != c[i]
        dp[i+1] += dp[a[c[i]]+1]
        dp[i+1] %= mod
    end
    a[c[i]] = i
end
puts dp[n]

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

int main(){
  int n, m; cin >> n >> m;
  vector<long long> h(n);
  for (int i = 0; i < n; i++)
  {
    cin >> h.at(i);
  }
  vector<vector<int>> path(n);
  for (int i = 0; i < m; i++)
  {
    int a,b;
    cin >> a >> b;
    a--;b--; //zero indexed
    path.at(a).push_back(b);
    path.at(b).push_back(a);
  }
  int ans = 0;
  for (int i = 0; i < n; i++)
  {
    bool flag = true;
    for (auto &&j : path.at(i))
    {
      if(h.at(j) >= h.at(i)){
        flag = false;
        break;
      }
    }
    if(flag){
      ans++;
    }
  }
  cout << ans << endl;
}

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

/*                    ॐ Shree ॐ                     */
/* ॐ ॐ ॐ
ॐ भूर् भुवः स्वः
तत् सवितुर्वरेण्यं
भर्गो देवस्य धीमहि
धियो यो नः प्रचोदयात्
*/
typedef long long ll;
using namespace std;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#else
// online submission
#endif
	int a;
	cin>>a;
	cout<<a+a*a+a*a*a;
}

Measured memory_bytes: 3624
#include <iostream>
#include<algorithm>
#include <vector>
#include<string>
#include<cmath>
#include<cstdio>

using namespace std;

int main() {
	int a = 0;
	string s;
	cin >> s;
	for (int i = 0; i < 4; i++) {
		if (s[i] == '+') {
			a++;
		}
		else if (s[i] == '-') {
			a--;
		}
	}
	cout << a;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef JLOCAL
#include "stress.h"
#endif
using namespace std;

#define rep(i, z, n) for (int i = (z); i < int(n); ++i)
#define repr(i, n, z) for (int i = int(n) - 1; i >= (z); --i)
#define shl(n) (1 << (n))
#define hbit(n, i) (((n) >> (i)) & 1)

#define STRESS 0
using lint = long long;

void solve(istream& cin, ostream& cout) {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, 0, n) {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    cout << a.back() - a.front();
}

int main() {
#if !defined(JLOCAL) || !STRESS
#ifdef JLOCAL
    freopen("input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    solve(cin, cout);
#else
    srand();
    for (int ti = 0; ti < 100; ti++) {
        stress::gen();
        stress::stupid();
        ifstream in("input.txt");
        ofstream out("output.txt");
        solve(in, out);
        out.flush();
        stress::check();
    }
    cout << "ok" << endl;
#endif
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
long long dp[100][21];
int main(){
    int n,s[100],w;
    cin>>n;
    for(int i=0;i<n-1;i++)
        cin>>s[i];
    cin>>w;
    for(int i=0;i<n;i++){
        for(int j=0;j<=20;j++){
            dp[i][j]=0;
        }
    }
    dp[0][s[0]]=1;
    for(int i=1;i<n-1;i++){
        for(int j=0;j<=20;j++){
            if(j-s[i]>=0)
                dp[i][j]+=dp[i-1][j-s[i]];
            if(j+s[i]<=20)
                dp[i][j]+=dp[i-1][j+s[i]];
        }
    }
    cout<<dp[n-2][w]<<endl;
    return 0;
}

Measured memory_bytes: 1172
#include<bits/stdc++.h>
#define ll long long
#define pii_ pair<int,int>
#define mp_ make_pair
#define pb push_back
#define fi first
#define se second
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define show1(a) cout<<#a<<" = "<<a<<endl
#define show2(a,b) cout<<#a<<" = "<<a<<"; "<<#b<<" = "<<b<<endl
using namespace std;
const ll INF = 1LL<<60;
const int inf = 1<<30;
const int maxn = 2e5+5;
inline void fastio() {ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);}

ll ans[maxn];

int main()
{
    fastio();
    int n;cin>>n;
    rep(i,1,n) rep(j,1,n) rep(k,1,n){
        ll x = (ll)i*i + (ll)j*j + (ll)k*k + (ll)i*j + (ll)i*k + (ll)j*k;
        if(x>n) break;
        ans[x]++;
    }
    rep(i,1,n) cout<<ans[i]<<endl;
    return 0;
}


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

int main() {
	int n, x;
	while (cin >> n >> x) {
		if (n == 0 && x == 0) break;
		int ans = 0;
		for (int i = 1; i <= n; i++) {
			for (int j = i + 1; j <= n; j++) {
				for (int k = j + 1; k <= n; k++) {
					if (i + j + k == x) ans++;
				}
			}
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 3088
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
char mat[100][100];

int main(){


int n,m;
cin>>n>>m;
vector<char> vc;
for(int i=0;i<n;i++){

    for(int j=0;j<m;j++){
        cin>>mat[i][j];}

}

for(int i=0;i<n;i++){

    for(int j=0;j<m;j++){

       cout<<mat[i][j];
       vc.push_back(mat[i][j]);

       }
       cout<<endl;
       for(auto x : vc)cout<<x;
vc.clear();



cout<<endl;
    }






return 0;

}



Measured memory_bytes: 764
H,W=gets.split.map(&:to_i)
c=[]
10.times{
    c << gets.split.map(&:to_i)
}
d=[]
10.times{|i|
    d << c[i][1]
}
loop{
    f=true
    10.times{|i|
        10.times{|j|
            if d[i]>c[i][j]+d[j]
                d[i]=c[i][j]+d[j]
                f=false
            end
        }
    }
    break if f
}
warn d.inspect
r=0
H.times{
    gets.split.each{|a|
        a=a.to_i
        next if a==-1
        r+=d[a]
    }
}
puts r


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

using namespace std;

typedef long long int llint;
typedef pair<int, int> pii;
typedef pair<llint, llint> pll;
typedef vector<int> vi;
typedef vector<llint> vl;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define ci cin
#define co cout
#define en endl
#define ln cout<< '\n'
#define rep(i, n) for(int i = 0; i < n; i++)
#define outl(x) cout<< (x) << '\n'
#define pb push_back
#define fi first
#define se second
#define MOD 1000000007

template<typename Tn> Tn gcd(Tn a, Tn b)
{
	return (b ? gcd(b, a % b) : a);
}

template<typename Tn> Tn lcm(Tn a, Tn b)
{
	return a / gcd(a, b) * b;
}

llint cnt = 0;
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};

int main()
{
    string s;
    ci >> s;

    string k = "keyence";

    bool flg = false;
    int idx = s.find(k);
    if(idx != string::npos && (idx == 0 || idx == s.size() - k.size())) {
	flg = true;
    } else {
	for(int i = 1; i < k.size(); i++) {
	    string a = "";
	    string b = "";
	    for(int j = 0; j < i; j++) a += k[j];
	    for(int j = i; j < k.size(); j++) b += k[j];
	    
	    if(s.find(a) == 0 && s.find(b, s.size() - b.size()) == s.size() - b.size()) flg = true;
	    //co << a << ' ' << b << en;
	}
    }
	
    if(flg) co << "YES" << en;
    else co << "NO" << en;
    
  
    return 0;
}

//keyofscience


Measured memory_bytes: 384
#pragma region

#include "bits/stdc++.h"
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define _rep3(i, begin, end) for (register int i = (begin), i##_end = (end); i < i##_end; i++)
#define _irep3(i, begin, end) for (register int i = (end)-1, i##_begin = (begin); i >= i##_begin; i--)
#define _rep2(i, n) _rep3(i, 0, n)
#define _irep2(i, n) _irep3(i, 0, n)
#define _overload3(_1, _2, _3, name, ...) name
#define rep(...) _overload3(__VA_ARGS__, _rep3, _rep2, )(__VA_ARGS__)
#define irep(...) _overload3(__VA_ARGS__, _irep3, _irep2, )(__VA_ARGS__)
#define out(x) cout << (x) << '\n';
#define debug(x) cerr << #x << " = " << (x) << " (line: " << __LINE__ << ") " << endl;

using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<long long>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<long long>>;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (auto &v : vec) is >> v;
  return is;
}
template <typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &pair) {
  cin >> pair.first >> pair.second;
  return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "[ ";
  rep(i, vec.size()) i == 0 ? os << vec[i] : os << ", " << vec[i];
  os << " ]";
  return os;
}

template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

template <class T>
bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

void init() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(16) << boolalpha;
}

#pragma endregion

#define MOD 1000000007
#define INF 2147483647

ll modpow(ll a, ll b, ll mod = MOD) {
  ll res = 1;
  while (b > 0) {
    if (b & 1) res = res * a % mod;
    a = a * a % mod;
    b >>= 1;
  }
  return res;
}

ll modinv(ll a, ll mod = MOD) {
  ll b = mod, u = 1, v = 0;
  while (b) {
    ll t = a / b;
    a -= t * b;
    swap(a, b);
    u -= t * v;
    swap(u, v);
  }
  u %= mod;
  if (u < 0) u += mod;
  return u;
}

int main() {
  init();

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

  ll ans = modpow(2, n) - 1;

  ll nca = 1, ncb = 1;
  rep(i, a) {
    nca = nca * (n - i) % MOD;
    nca = nca * modinv(i + 1) % MOD;
  }
  rep(i, b) {
    ncb = ncb * (n - i) % MOD;
    ncb = ncb * modinv(i + 1) % MOD;
  }

  ans = (ans - nca - ncb + MOD * 2) % MOD;

  out(ans);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<class T>
istream& operator >> (istream& is, vector<T>& v)
{
	for (auto &i : v) is >> i;
	return is;
}
template<class T>
ostream& operator<<(ostream& os, vector<T>& v)
{
	const string delimiter = "\n";
	REP(i, v.size())
	{
		os << v[i];
		if (i != v.size() - 1) os << delimiter;
	}
	return os;
}
/*--------------------template--------------------*/

int n;
vi a;

int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	cin >> n;
	a.resize(n * 3); cin >> a;
	sort(ALL(a));
	ll ans = 0;
	REP(i, n)
	{
		ans += a[n * 3 - 2 - i * 2];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1408
using System.Collections.Generic;
using System.IO;
using System.Linq;
using static System.Console;
class Z { static void Main() => new K(); }
class K
{
	int[] G => ReadLine().Split().Select(int.Parse).ToArray();
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	int V, Mod;
	List<int>[] es;
	void Solve()
	{
		var I = G;
		V = I[0];
		Mod = I[1];
		es = new List<int>[V];
		for (var u = 0; u < V; u++) es[u] = new List<int>();
		for (var e = 0; e < V - 1; e++)
		{
			I = G;
			es[I[0] - 1].Add(I[1] - 1);
			es[I[1] - 1].Add(I[0] - 1);
		}
		var dp0 = DFS0(0, V);
		var dp1 = DFS1(0, dp0);
		for (var u = 0; u < V; u++) WriteLine(dp0[u] * (dp1[u] + 1) % Mod);
	}
	long[] DFS0(int u, int p)
	{
		var dp = new long[V];
		var st = new Stack<A0>();
		st.Push(new A0(u, p));
		while (st.Count > 0)
		{
			var f = st.Pop();
			if (f.p >= 0)
			{
				dp[f.u] = 1L;
				es[f.u].Remove(f.p);
				if (es[f.u].Count == 0) continue;
				st.Push(new A0(f.u, -1));
				foreach (var v in es[f.u]) st.Push(new A0(v, f.u));
			}
			else foreach (var v in es[f.u]) dp[f.u] = dp[f.u] * (dp[v] + 1) % Mod;
		}
		return dp;
	}
	long[] DFS1(int u, long[] dp0)
	{
		var dp = new long[V];
		var st = new Stack<int>();
		st.Push(u);
		var y = new long[V + 1];
		while (st.Count > 0)
		{
			u = st.Pop();
			var W = es[u].Count;
			if (W == 0) continue;
			y[W] = 1;
			for (var i = W - 1; i >= 1; i--) y[i] = y[i + 1] * (dp0[es[u][i]] + 1) % Mod;
			var x = 1L;
			for (var i = 0; i < W; i++)
			{
				dp[es[u][i]] = (dp[u] + 1) * x % Mod * y[i + 1] % Mod;
				x = x * (dp0[es[u][i]] + 1) % Mod;
			}
			foreach (var v in es[u]) st.Push(v);
		}
		return dp;
	}
}
struct A0 { public int u, p; public A0(int u, int p) { this.u = u; this.p = p; } }


Measured memory_bytes: 35324