akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>

int cmp_int(const void *a, const void *b) {
    return *(int*)a - *(int*)b;
}

int main(void) {
    int n, i, ans, mid;
    scanf("%d", &n);
    int d[n];

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

    qsort(d, n, sizeof(int), cmp_int);
    mid = n/2;
    ans = d[mid]-d[mid-1];

    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 892
fun main(args:Array<String>) {
    val n = readLine()!!.toInt()
    val list = Array(n) { readLine()!! }

    fun pl(v:String) = println("$v x ${list.count{it == v}}")

    pl("AC")
    pl("WA")
    pl("TLE")
    pl("RE")
}

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

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
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;}
typedef long long int ll;
typedef pair<int,int> P_ii;
typedef pair<double,double> P_dd;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}

template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}


const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

void addM(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

// a^b mod M
long myPow(long a,long b,int M) {
    long ret = 1;
    long tmp = a;
    while(b>0) {
        if((b&1)==1) ret = (ret * tmp) % M;
        tmp = (tmp * tmp) % M;
        b = b>>1;
    }
    return ret;
}

 // nCk mod M
int nCk(int n,int k,int M) {
    long ret = 1;
    int mi = min(k, n-k);
    for(int i=1;i<=mi;i++) {
        ret = (ret * myPow(i,M-2,M)) % M;
    }
    for(int i=n-mi+1;i<=n;i++) {
        ret = (ret * i) % M;
    }
    return (int)ret;
};

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

    vector<ll> dp(N+3,0L);

    set<int> se;

    REP(i,M) {
        int tmp;cin >> tmp;
        se.insert(tmp);
    }

    dp[0]=1;
    if(se.count(1)==0) dp[1]=1;

    for(int i=2;i<=N;i++){
        if(se.count(i)!=0) continue;
        if(se.count(i-1)!=0 && se.count(i-2)!=0) {
            pl(0)
            return 0;
        }
        addM(dp[i],dp[i-1]);
        addM(dp[i],dp[i-2]);
    }

    pl(dp[N])

    return 0;
}

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

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

using namespace std;

int main(){
	int n; cin>>n;
	tuple<string,int,int> r[100];
	rep(i,n) cin>>get<0>(r[i])>>get<1>(r[i]), get<1>(r[i])*=-1, get<2>(r[i])=i;

	sort(r,r+n);

	rep(i,n) cout<<get<2>(r[i])+1<<endl;

	return 0;
}


Measured memory_bytes: 256
t, k = map(int, input().split())
a = list(map(int, input().split()))
a.sort(reverse=True)
if t%2==0:
    if t//2>=a[0]:
        ans = 0
    else:
        tmp = a[0] - (t//2)
        ans = 1 + 2*(tmp-1)
elif t%2!=0:
    if (t+1)//2>=a[0]:
        ans = 0
    else:
        tmp = a[0] - ((t+1)//2)
        ans = 2 * tmp

print(ans)

    

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

#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define LL long long
#define pii pair <int,int>
#define fi first
#define se second
#define pb push_back
#define mpr make_pair

using namespace std;

const LL MOD=1e9+7;

int n,t,c,pos;
string s;
vector <int> v,v2;

int main()
{
	cin>>n>>t>>c>>s;
	pos=0;
	while(s[pos]=='x') pos++;
	while(pos<n)
	{
		v.pb(pos);
		pos+=c+1;
		while(pos<n&&s[pos]=='x') pos++;
	}
	pos=n-1;
	while(s[pos]=='x') pos--;
	while(pos>=0)
	{
		v2.pb(pos);
		pos-=c+1;
		while(pos>=0&&s[pos]=='x') pos--;
	}
	while(v2.size()>t) v2.pop_back();
	reverse(v2.begin(),v2.end());
	rep(i,t) if(v[i]==v2[i]) cout<<v[i]+1<<endl;
	return 0;
}

Measured memory_bytes: 3448
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
const int INF = (1 << 30);
const ll INFL = (1LL << 62);
const ll MOD = 1000000007;
template <class T>
bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
T gcd(T a, T b) {
    return b ? gcd(b, a % b) : a;
}
template <class T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}
template <class T>
ll mod_pow(ll a, ll n, T mod) {
    mod = (ll)mod;
    ll res = 1, p = a % mod;
    while (n) {
        if (n & 1) res = res * p % mod;
        p = p * p % mod;
        n >>= 1;
    }
    return res;
}
void print() { std::cout << std::endl; }
template <typename T, typename... A>
void print(const T& first, const A&... rest) {
    cout << sizeof...(rest) << endl;
    std::cout << first;
    if (sizeof...(rest)) std::cout << " ";
    print(rest...);
}
template <typename... A>
void print(const A&... rest) {
    print(rest...);
}
template <typename A>
void print(const std::vector<A>& v) {
    std::for_each(v.begin(), v.end(), [](A x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, W;
    cin >> n >> W;
    vector<ll> w(n), v(n);
    rep(i, n) cin >> w[i] >> v[i];
    vector<vector<ll>> dp(n+1, vector<ll>(W+1, 0));
    for (int i = 1; i <= n; ++i) {
        rep(j, W + 1) {
            chmax(dp[i][j], dp[i - 1][j]);
            if (j - w[i-1] >= 0) {
                chmax(dp[i][j], dp[i - 1][j - w[i-1]] + v[i-1]);
            }
        }
    }
    cout << dp[n][W] << endl;
    return 0;
}

Measured memory_bytes: 80256
import sys
sys.setrecursionlimit(10**6)
input = lambda: sys.stdin.readline().rstrip()

def solve(): 
  n,q = map(int,input().split())
  G = [[] for i in range(n)]
  for i in range(n-1):  
    a,b = map(int,input().split())
    G[a-1].append(b-1)
    G[b-1].append(a-1)

  P = [0]*n
  for i in range(q):
    p,x = map(int,input().split())
    P[p-1] += x

  def dfs(v,pv):      
    for nv in G[v]:
      if nv != pv:
        P[nv] += P[v]
        dfs(nv,v)

  dfs(0,0)
  print(*P)

if __name__ == "__main__":
    solve()

Measured memory_bytes: 268420
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby
    #from itertools import product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    n = int(input())
    p = [[0]*10 for _ in range(10)]
    res = 0
    for x in range(1, n+1):
        x = str(x)
        c, d = int(x[0]), int(x[-1])
        if c==0 or d==0:
            continue
        p[d][c] += 1
        # if c != d:
        #     p[d][c] += 1
    for x in range(1, n+1):
        x = str(x)
        c, d = int(x[0]), int(x[-1])
        if c==0 or d==0:
            continue
        res += p[c][d]
        # if c != d:
        #     res -= 1
    print(res)

    # for i in range(1,10):
    #     for j in range(1,10):
    #         for x in range(1, n+1):
    #             x = str(x)
    #             c, d = int(x[0]), int(x[-1])
    #             if i==c and j==d:
    #                 p[c][d] += 1
    # for x in range(1, n+1):
    #     x = str(x)
    #     c, d = int(x[0]), int(x[-1])
    #     res += p[c][d]
    #     if c != d:
    #         res -= 1
    # print(res)



if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    long ans=0;
    double x=Math.sqrt(n);
    for(double i=1.0;i<x;i+=1.0){
      ans++;
      int ab=(int)(i*(i+1.0));
      for(;ab<n;ab+=i){
        ans+=2;
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 35740
import java.io.*;
import java.math.*;
import java.util.*;
 
public class Main {
    private static boolean debug = false;
    private static boolean elapsed = false;
 
    private static PrintWriter _out = new PrintWriter(System.out);
    private static PrintWriter _err = new PrintWriter(System.err);
 
    private void solve(Scanner sc) {
        String s = sc.nextLine();
        int idx1 = s.indexOf('A');
        int idx2 = s.lastIndexOf('Z');
        _out.println((idx2 - idx1 + 1));
    }
    private static BigInteger C(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        for (long i = r; i > 1; --i) {
            res = res.divide(BigInteger.valueOf(i));
        }
        return res;
    }
    private static BigInteger P(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        return res;
    }
    /*
     * 10^10 > Integer.MAX_VALUE = 2147483647 > 10^9
     * 10^19 > Long.MAX_VALUE = 9223372036854775807L > 10^18
     */
    public static void main(String[] args) {
        long S = System.currentTimeMillis();
 
        Scanner sc = new Scanner(System.in);
        new Main().solve(sc);
        _out.flush();
 
        long G = System.currentTimeMillis();
        if (elapsed) {
            _err.println((G - S) + "ms");
        }
        _err.flush();
    }
}

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

typedef complex<int> P;

namespace std{
	bool operator < (const P &a,const P &b){
		if( a.real() != b.real() ) return a.real() < b.real();
		return a.imag() < b.imag();
	}
	bool operator == (const P &a,const P &b){
		if( a.real() != b.real() ) return false;
		return a.imag() == b.imag();
	}
};

vector<vector<P>> ptn = {
	{P(0,0),P(1,1),P(1,0),P(0,1)},
	{P(0,0),P(0,2),P(0,1),P(0,3)},
	{P(0,0),P(1,0),P(2,0),P(3,0)},
	{P(1,0),P(1,1),P(0,1),P(0,2)},
	{P(0,0),P(1,0),P(1,1),P(2,1)},
	{P(0,0),P(0,1),P(1,1),P(1,2)},
	{P(1,0),P(2,0),P(0,1),P(1,1)}
};

string s[8];
int main(){
	while(true){
		for(int i = 0 ; i < 8 ; i++){
			if(!(cin >> s[i]))exit(0);
			
		}
		for(int i = 0 ; i < 7 ; i++)
			sort(ptn[i].begin(),ptn[i].end());
		for(int i = -10 ; i <= 10 ; i++)
			for(int j = -10 ; j <= 10 ; j++){
				vector<P> tmp;
				for(int y = 0 ; y < 8 ; y++)
					for(int x = 0 ; x < 8 ; x++){
						if( s[y][x] == '1'){
							tmp.push_back(P(x-j,y-i));
						}
					}
				sort(tmp.begin(),tmp.end());
				for(int k = 0 ; k < 7 ; k++){
					if( tmp == ptn[k] ){
						cout << (char)(k+'A') << endl;
					}
				}
			}
	}
					
					
	
	
}

Measured memory_bytes: 3152
#include<stdio.h>
int main(){
  int w,h,n,i,a,b,x=1,y=1,s=0,d,dx,dy;
  scanf("%d %d %d",&w,&h,&n);
  for(i=0;i<n;i++){
    scanf("%d %d",&a,&b);
    if(!i){
      x=a;
      y=b;
    }
    dx=a-x;
    dy=b-y;
    if(dx*dy>0){
      d=abs(dx);
      if(d<abs(dy))d=abs(dy);
    }
    else{
      d=abs(dx-dy);
    }
    x=a;
    y=b;
    s+=d;//printf("%d\n",s);
  }
  printf("%d\n",s);
  return 0;
}
 

Measured memory_bytes: 596
import java.util.Scanner;

/**
 * Created by yangyuyin on 16/10/8.
 */
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s=sc.next();
        s=s.substring(0,4)+" "+s.substring(4,12);
        System.out.println(s);
    }
}  

Measured memory_bytes: 9684
#include <bits/stdc++.h>
using namespace std;
    
#define int long long int
#define vi vector<int>
#define vvi vector<vi>
#define read(a)  for(int i = 0; i < n; i++) cin >> a[i];
#define print(a)  for(int i = 0; i < n; i++) cout << a[i] << " ";
#define pb push_back
#define pql priority_queue<int>
#define pqs priority_queue<int, vi, greater<int>>
#define pqlv priority_queue<vi>
#define pqsv priority_queue<vi, vvi, greater<vi>>
#define endl '\n'
#define N 10000002
#define MOD 1000000007
    
signed main() {
    vi stk;
    string s;
    cin >> s;
    int cnt = 0;
    for(int i = 0; i < s.size(); i++) {
        bool f = false;
        int num = s[i] - '0';
        if(stk.size()) {
            if(stk.back() == 1 - num) {
                stk.pop_back();
                f = true;
            }
        }
        if(!f)
            stk.pb(num);
    }
    cout << s.size() - (stk.size()) << endl;
}

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


#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T, class T2> void amax(T& a,T2 b){ if(a < b) a = b;}


int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n; ll a, b;
	cin >>n >>a >>b;
	
	VL x(n);
	rep(i, n) cin >>x[i];
	ll ans = 0;
	rep2(i, 1, n){
		ans += min(b, (x[i] - x[i-1]) * a);
	}
	cout << ans <<"\n";
	return 0;
}


Measured memory_bytes: 1024
import sys
H, W = map(int, input().split())
X = ['.'*(W+2)]
for _ in range(H):
    X.append('.'+input().strip()+'.')
X += ['.'*(W+2)]
for i in range(1, H+1):
    for j in range(1, W+1):
        if X[i][j] == "#" and '#' not in [X[i+1][j], X[i-1][j], X[i][j-1], X[i][j+1]]:
            print("No")
            sys.exit()
print("Yes")


Measured memory_bytes: 39024
#include <bits/stdc++.h>
typedef long long int lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define all(a) (a).begin(), (a).end()
#define INV ((long long int)1000000007)

using namespace std;

void execute()
{
	string input;
	cin >> input;
	stack<char> data;

	for (int i = 0; i < input.size(); i++)
	{
		if (input[i] == 'B')
		{
			if (!data.empty())
				data.pop();
		}
		else
			data.push(input[i]);
	}
	string ans = "";
	for (; !data.empty();)
	{
		ans = data.top() + ans;
		data.pop();
	}

	cout << ans << endl;
	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

Measured memory_bytes: 256
a = [list(map(int, input().split())) for _ in range(3)]
n = int(input())
b = [int(input()) for _ in range(n)]

for x in b:
    for i in range(3):
        for j in range(3):
            if a[i][j] == x:
                a[i][j] = 'x'
for x in range(3):
    if (a[x][0] == a[x][1] == a[x][2] == 'x') or (a[0][x] == a[1][x] == a[2][x] == 'x'):
        print('Yes')
        exit()
if (a[0][0] == a[1][1] == a[2][2] == 'x') or (a[0][2] == a[1][1] == a[2][0] == 'x'):
    print('Yes')
    exit()
print('No')

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main(int argc, char** argv) {
	int n,d=99999999;
	scanf("%d",&n);
	for(int i = 1; i<=n/2; i++){
		int j=n-i,b=i,c=0;
		while(b){
			c+=b%10;
			b=b/10;
		}
		while(j){
			c+=j%10;
			j=j/10;
		}
		d=min(c,d);
		
	}
	cout<<d;
	return 0;
}

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

cnt = 0
for i in range(N-1):
    if A[i] == i+1:
        A[i],A[i+1] = A[i+1],A[i]
        cnt += 1
        i += 1
if A[N-1]==N:
    cnt += 1
print(cnt)

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

int main()
{
    int n, z, w;
    cin >> n >> z >> w;
    int a[2005];
    for(int i = 0; i < n; i++) cin >> a[i];
    if(n == 1) cout << abs(a[0] - w) << endl;
    else cout << max(abs(a[n - 1] - w), abs(a[n - 2] - a[n - 1])) << endl;
}


Measured memory_bytes: 3668
#include <iostream>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <vector>
#include <map>
#include <stdio.h>
using namespace std;
int main() {
	int N; cin >> N;
	vector<int> Q(N, 0), P(N), M(N);
	int ans = 0;
	for (int i = 0; i < N; i++) {
		cin >> P.at(i);
	}
	for (int i = 0; i < N; i++) {
		cin >> M.at(i);
		ans += M.at(i);
	}
	for (int i = 1; i < N; i++) {
		cin >> Q.at(i);
		ans += Q.at(i);
	}
	ans -= Q.at(P.at(0) - 1);
	for (int i = 1; i < N; i++) {
		if (P.at(i) - P.at(i - 1) != 1) {
			ans -= Q.at(P.at(i) - 1);
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;

namespace F
{
    class Program
    {
        static void Main(string[] args)
        {
            string line = Console.ReadLine();
            long N = long.Parse(line);
            var n1 = Yakusu(N - 1);
            var n = Yakusu(N);
            var count = 0;
            for(int i = 0; i < n.Count; i++)
            {
                var now = N;
                while(now % n[i] == 0)
                {
                    now = now / n[i];
                }
                if (now % n[i] == 1)
                {
                    count++;
                }
            }

            Console.WriteLine(n1.Count + count);
        }

        public static List<long> Yakusu(long num)
        {
            var ret = new List<long>();
            if (num == 1) return ret;
            ret.Add(num);
            for (long i = 2; i * i <= num; i++)
            {
                if (num % i == 0)
                {
                    ret.Add(i);
                    if (i * i != num)
                        ret.Add(num / i);
                }
            }
            return ret;
        }
    }
}


Measured memory_bytes: 13140
#include <algorithm>
#include <iostream>
#include <vector>
#include <array>
#include <string>
#include <cmath>
#include <iomanip>
#include <set>
#include <map>
#include <climits>
#include <utility>
#include <deque>
using namespace std;

int main()
{
	int n;
	cin >> n;
	deque<int> neg, pos;
	for (int i = 0; i < n; ++i) {
		auto val = 0;
		cin >> val;
		if (val < 0)neg.push_back(val); else pos.push_back(val);
	}
	sort(neg.begin(), neg.end());
	sort(pos.begin(), pos.end());
	
	vector<pair<int, int>> method;
	int negSize, posSize;
	for (negSize = neg.size(), posSize = pos.size();; negSize = neg.size(), posSize = pos.size()) {
		if (posSize + negSize == 1)break;
		if (negSize == 0) {
			neg.push_back(pos.front());
			pos.pop_front();
		}
		if (posSize == 0) {
			pos.push_front(neg.back());
			neg.pop_back();
		}
		if (negSize < posSize) {
			auto negVal = neg.back() - pos.front();
			method.push_back(make_pair(neg.back(), pos.front()));
			neg.pop_back();
			pos.pop_front();
			neg.push_back(negVal);
		}
		else {
			auto posVal = pos.front() - neg.back();
			method.push_back(make_pair(pos.front(), neg.back()));
			pos.pop_front();
			neg.pop_back();
			pos.push_front(posVal);
		}
	}

	cout << pos[0] << endl;
	for (auto m : method) {
		cout << m.first << " " << m.second << endl;
	}
	return 0;
}

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


N = int(input())
L = list("abcdefghij")

def nasu(x, n, e):
  if n == N:
    print(x)
    return
  for i in range(e + 1):
    if i == e:
      nasu(x + L[i], n + 1, e + 1)
    else:
      nasu(x + L[i], n + 1, e)

nasu("", 0, 0)


Measured memory_bytes: 4412
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>
#include <unordered_map>

using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
#define Fi first
#define Se second
#define pb(x) push_back(x)
#define szz(x) (int)x.size()
#define rep(i, n) for(int i=0;i<n;i++)
#define all(x) x.begin(), x.end()
typedef tuple<int, int, int> t3;

char S[40];

void solve(){
	int N;
	scanf("%d%s", &N, S);
	ll ans = 0;
	rep(i, 1<<N) {
		char X[20] = {}, Y[20] = {};
		int sx = 0, sy = 0;
		rep(j, N) {
			if(1<<j & i) X[++sx] = S[j];
			else Y[++sy] = S[j];
		}
		reverse(X + 1, X + 1 + sx);
		reverse(Y + 1, Y + 1 + sy);
		ll d[2][20][20] = {};
		int v = 0;
		d[0][0][0] = 1;
		for(int a=N;a<2*N;a++) {
			v ^= 1;
			for(int b=0;b<=sx;b++) for(int c=0;c<=sy;c++) {
				if(b && X[b] == S[a]) d[v][b][c] += d[!v][b-1][c];
				if(c && Y[c] == S[a]) d[v][b][c] += d[!v][b][c-1];
			}
			memset(d[!v], 0, sizeof d[!v]);
		}
		ans += d[v][sx][sy];
	}
	printf("%lld\n", ans);
}

int main(){
	int Tc = 1; //scanf("%d", &Tc);
	for(int tc=1;tc<=Tc;tc++){
		solve();
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream> 
#include <algorithm>
using namespace std;
int main() {
	int N, A, B;
	cin >> N >> A >> B;
	int max = min(A, B);
	int min = A + B - N;
	if (min <= 0) {
		cout << max << " " << "0" << endl;
	}
	else {
		cout << max << " " << min << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(X,Y) ((X)>(Y)?X=(Y),true:false)
#define chmax(X,Y) ((X)<(Y)?X=(Y),true:false)
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

int main(){
	ll a[4], n;
	rep(i, 4) cin>>a[i]; cin>>n;
	rep(i, 3) a[i+1] = min(a[i+1], a[i]*2);
	n *= 4;
	ll res = 0;
	for(ll i = 3; i >= 0; i--){
		ll x = 1<<i;
		ll t = n/x;
		res += t*a[i];
		n -= t*x;
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
using ll = long long;
int main(void){
   string S;
   cin>>S;
   bool a=false,b=false,c=false;
   
   rep(i,3){
       if(S[i]=='a') a=true;
       if(S[i]=='b') b=true;
       if(S[i]=='c') c=true;
   }
   if(a==true&&b==true&&c==true){
       cout<<"Yes"<<endl;
   }
   else{
       cout<<"No"<<endl;
   }
}

Measured memory_bytes: 3568
import java.util.*;
public class Main{
  public static void main(String[]args){
      Scanner sc = new Scanner(System.in);

      String S = sc.next();
      char c ;
      int count = 0;
      char[] data = new char[S.length()+1];

      for(int i = 0;i<S.length();i++){
        c = S.charAt(i);
        data[i+1]=c;
      }

      for(int i = 1;i<=S.length();i++){
        if(i%2==0){
          if(data[i]=='R'){
            System.out.println("No");
            System.exit(0);
          }
          }

          if(i%2!=0){
            if(data[i]=='L'){
            System.out.println("No");
            System.exit(0);
            }
        }
      }
        System.out.println("Yes");
           }
      }

Measured memory_bytes: 23764
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define pb(a) push_back(a)

typedef long long ll;
using namespace std;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

//const int dy[] = { 0, 0, 1, -1 };
//const int dx[] = { 1, -1, 0, 0 };
const int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
const int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };
ll gcd(ll a, ll b);
ll lcm(ll x, ll y);

vector<ll> h;

int main()
{
	ll n;
	string ans="Yes";
	cin >> n;

	for (ll i = 0; i <n; i++) {
		ll tmp;
		cin >> tmp;
		h.push_back(tmp);
	}

	for (ll i = n-1; i > 0; i--) {
		if (h[i] == h[i-1]) {

		}
		else if ((h[i]+1) == h[i - 1]) {
			h[i - 1]--;
		}
		else if ((h[i]+1) < h[i - 1]) {
			ans = "No";
			break;
		}
		else {
			int tmp = 0;
		}
	}

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


Measured memory_bytes: 1528
#include<bits/stdc++.h>
using namespace std;
int main(){
    int x,y,z;
    cin >> x >> y >> z;
    int a,b,c;
    a = z;
    b = x;
    c = y;
    cout << a  << " " << b << " " << c << endl;
    return 0;
}




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

#define endl "\n"
using namespace std;

int main(){
	ios::sync_with_stdio(0);cin.tie(0);
	vector<int> arr;
	long long n;
	cin >> n;
	long long ans;
	ans = ((n-1)*n)/2;
	cout << ans;
	return 0;
}

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

int main() {
  int n, m, t_sum = 0; cin >> n;
  int time[n];
  
  for (int i = 0; i < n; ++i) {
    int t; cin >> t;
    time[i] = t;
    t_sum += t;
  }
  cin >> m;
  
  for (int i = 0; i < m; ++i) {
    int p, x; cin >> p >> x;
    --p; // indexに変換
    cout << t_sum - (time[p] - x) << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3572
#pragma comment(linker, "/stack:247474112")
#pragma GCC optimize("Ofast")

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
ll dp[200001];
map<int, int> sum;
int n;
vector<int> C;

void input()
{
    cin >> n;
    int p = 0;
    for(int i = 0; i < n; ++i) {
        int c;
        if(i == 0) {
            cin >> c;
            C.push_back(c);
            ++p;
        }else {
            cin >> c;
            if(c != C[p-1]) {
                C.push_back(c);
                ++p;
            }
        }
    }
    n = C.size();
}

int solve()
{
    for(int i = 0; i < n; ++i) {
        if(i == 0) {
            dp[i] = 1;
            sum[C[i]] += dp[i];
        }else {
            dp[i] = dp[i-1];
            dp[i] += sum[C[i]];
            dp[i] %= mod;
            sum[C[i]] += dp[i-1];
            sum[C[i]] %= mod;
        }
    }
    return dp[n-1];
}

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


Measured memory_bytes: 12148
#include<iostream>
#include<string>
#include<vector>
#include<map>
using namespace std;
int main()
{
	vector<string>m(10);
	m[1]="',.!?";
	m[2]="abcABC";
	m[3]="defDEF";
	m[4]="ghiGHI";
	m[5]="jklJKL";
	m[6]="mnoMNO";
	m[7]="pqrsPQRS";
	m[8]="tuvTUV";
	m[9]="wxyzWXYZ";
	string s;
	int i,x,y;
	while(cin>>s)
	{
		typedef pair<int,int>P;
		vector<P>v;
		for(i=0;i<s.size()-1;)
		{
			if(s[i]-s[i+1])
			{
				v.push_back(P(s[i]-'0',i+1));
				s.erase(0,i+1);
				i=0;
			}
			else ++i;
		}
		v.push_back(P(s[0]-'0',s.size()));
		for(i=0;i<v.size();++i)
		{
			x=v[i].first,y=v[i].second-1;
			if(x)
			{
				cout<<m[x][y%m[x].size()];
			}
			else if(y>0)cout<<string(y,' ');
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, a, b, c, d;
  cin >> N;
  
  a = N / 1000;
  b = (N % 1000) / 100;
  c = (N % 100) / 10;
  d = N % 10;
  
  if (a == b && b == c ) cout << "Yes" << endl;
  else if (b == c && c == d) cout << "Yes" << endl;
  else cout << "No" << endl;
}


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

int main() {
    int A, B, K;
    cin >> A >> B >> K;
    int AA = A + K - 1;
    int BB = B - K + 1;
    if(AA<BB) {
        for(int i=0; i<K; i++) {
            cout << (A+i) << endl;
        }
        for(int i=K-1; i>=0; i--) {
            cout << (B-i) << endl;
        }
    }
    else {
        for(int i=A; i<=B; i++) {
            cout << i << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 256
# https://atcoder.jp/contests/agc028/tasks/agc028_a

n, m = map(int, input().split())
s = input()
t = input()

def gcd(x, y): #GCD
    # greatest_common_divisor
    if x < y:
        x, y = y, x
    if y == 0:
        return 0
    if x % y == 0:
        return y
    return gcd(y, x % y)

def lcm(x, y): #LCM
    # lowest_common_multiple
    return x * y // gcd(x, y)

l = lcm(n, m)
d = gcd(n, m)
n //= d
m //= d

for i in range(d):
    if s[i * n] != t[i * m]:
        print(-1)
        break
else:
    print(l)

Measured memory_bytes: 39536
#include<cstdio>
#include<vector>

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

using namespace std;

typedef long long ll;

struct edge{
	int u,v;
	ll cost;
};

int n;
vector<edge> G[100000];

vector<edge> T[100000]; // G の全域木

bool vis[100000];
void dfs1(int u){
	vis[u]=true;
	rep(i,G[u].size()){
		edge e=G[u][i];
		if(!vis[e.v]){
			T[u].push_back(e);
			dfs1(e.v);
		}
	}
}

ll dist[100000]; // dist[u] := ( T における頂点 0-u 間の距離 )
void dfs2(int u,ll sum){
	dist[u]=sum;
	rep(i,T[u].size()){
		edge e=T[u][i];
		dfs2(e.v,sum^e.cost);
	}
}

int main(){
	int m,q; scanf("%d%d%d",&n,&m,&q);
	rep(i,m){
		int u,v;
		ll cost; scanf("%d%d%lld",&u,&v,&cost);
		G[u].push_back((edge){u,v,cost});
		G[v].push_back((edge){v,u,cost});
	}

	dfs1(0);
	dfs2(0,0);

	ll basis[60]={};
	rep(u,n) rep(i,G[u].size()) {
		edge e=G[u][i];
		ll sum=dist[e.u]^dist[e.v]^e.cost;
		int i0=-1;
		for(int i=59;i>=0;i--){
			if(sum&(1LL<<i)){
				sum^=basis[i];
				if(sum&(1LL<<i)){ i0=i; break; }
			}
		}
		if(i0!=-1) basis[i0]=sum;
	}

	while(q--){
		int u,v; scanf("%d%d",&u,&v);
		ll ans=dist[u]^dist[v];
		for(int i=59;i>=0;i--){
			if((ans&(1LL<<i))==0){
				ans^=basis[i];
			}
		}
		printf("%lld\n",ans);
	}

	return 0;
}

Measured memory_bytes: 19372
while True:
    a,b = map(int,input().split())
    if a == 0 and b == 0:
        break
    for i in range(a):
        for j in range(b):
            if ( i + j ) % 2 == 0:
                print("#", end = "")
            else:
                print(".", end = "")
        print()
    print()
        
    


Measured memory_bytes: 7008
mod=10**9+7
N,X=map(int,input().split())
S=[int(i) for i in input().split()]
S.sort(reverse=True)

Factorial=[1]*(N+1)
for i in range(1,N+1):
  Factorial[i]=Factorial[i-1]*(i)%mod
def power(x,y):
  if y==0:
    return 1
  elif y==1:
    return x%mod
  elif y%2==0:
    return power(x,y//2)**2%mod
  else:
    return ((power(x,y//2)**2)*x)%mod
inv=[0]*(N+1)
for i in range(N+1):
  inv[i]=power(i,mod-2)
dp=[[0]*(X+1) for i in range(N+1)]
for x in range(X+1):
  dp[N][x]=x
for i in range(N)[::-1]:
  for x in range(X+1):
    dp[i][x]=dp[i+1][x%S[i]]+(N-i-1)*dp[i+1][x]
    dp[i][x]%=mod
print((dp[0][X])%mod)

Measured memory_bytes: 193672
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

ll mod = 1e9 + 7;

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

	ll n;
	cin >> n;
	vll w(3);
	REP(i, 3) cin >> w[i];
	vll l(n);
	REP(i, n) cin >> l[i];

	ll res = 1e15;
	REP(i, 1 << (2 * n)){
		ll tmp = i;
		vll c(4, 0), s(4);
		REP(j, n){
			c[tmp % 4]++;
			s[tmp % 4] += l[j];
			tmp /= 4;
		}
		if(c[0] * c[1] * c[2] == 0) continue;
		ll cnt = 0;
		REP(i, 3) cnt += (c[i] - 1) * 10 + abs(w[i] - s[i]);
		res = min(res, cnt);
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
import math
nowx = 0
nowy = 0
nowa = 90
while True:
    (d,a) = [int(i) for i in raw_input().split(',')]
    if(d == a == 0):
        print int(nowx)
        print int(nowy)
        break
    else:
        nowx += math.cos(nowa / 180.0 * math.pi) * d
        nowy += math.sin(nowa / 180.0 * math.pi) * d
        nowa -= a

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

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

    int n;
    cin >> n;
    vector<int> d(n);
    rep(i, n) cin >> d[i];

    sort(d.begin(), d.end());
    if(d[n/2-1] == d[n/2]) {
        cout << 0 << endl;
        return 0;
    }
    cout << d[n/2] - d[n/2-1] << endl;


    return 0;
}

Measured memory_bytes: 640
import java.util.*;

public class Main{
  public static char chalpha(int n){
		char[] ch="ABCDEFGHIJKLMNOPQRSTUVWXYZ".toCharArray();
		return ch[n];
	}
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
  	int h=sc.nextInt(),w=sc.nextInt(),f=0;
    char c='A';
    String[][] str=new String[h][w];
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
        str[i][j]=sc.next();
        if(str[i][j].equals("snuke")){
          f=i+1;
          c=chalpha(j);
        }
      }
    }
    System.out.println(c+""+f);
  }
}


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

int main() {
  int n;
  int a = 1;
  cin >> n;
  vector<string> s(n);
  for(int i = 0; i < n; i++){
  	cin >> s.at(i);
  }
  sort (s.begin(),s.end());
  for(int i = 0; i < n-1; i++){
  	if(s.at(i) != s.at(i+1)){
    	a++;
    }
  }
	cout << a << endl;
}

Measured memory_bytes: 9540
#include<stdio.h>
 
/* void judge(int data[], int n){
    for(int i = 1; i < n; i++){
        for(int j = 0; j < i; j++){
            if(data[i] == data[j]){
                printf("NO\n");
                return ;
            }
        }
    }
    printf("YES\n");
    return ;
}
*/


#define SWAP(type,a,b) { type work = a; a = b; b = work; }

/*
    基準値を選ぶ
*/
int select_pivot(const int* array, int begin, int end)
{
    return array[(begin + end) / 2];  // 中央の要素を基準値とする
}


/*
    クイックソート (再帰部分、昇順)
*/
void quick_sort_rec(int* array, int begin, int end)
{
    int pivot = select_pivot( array, begin, end );
    int i = begin;
    int j = end;

    while( 1 ){
        while( array[i] < pivot ){ ++i; }  // 基準値以上の値が見つかるまで右方向へ進めていく
        while( array[j] > pivot ){ --j; }  // 基準値以下の値が見つかるまで左方向へ進めていく

        if( i >= j ){ break; }  // 左右から進めてきたiとjがぶつかったらループを終える

        // 基準値の位置よりも左側にあり、基準値よりも大きい値 (array[i]) と、
        // 基準値の位置よりも右側にあり、基準値よりも小さい値 (array[j]) の
        // 位置関係を交換する。
        SWAP( int, array[i], array[j] );

        // 次回に備えて、注目点をずらす
        i++;
        j--;
    }


    // 基準値の位置より左側に要素が２つ以上あれば、
    // その部分についてクイックソートを再帰させる
    if( i - begin >= 2 ){
        quick_sort_rec( array, begin, i - 1 );
    }

    // 基準値の位置より右側に要素が２つ以上あれば、
    // その部分についてクイックソートを再帰させる
    if( end - j >= 2 ){
        quick_sort_rec( array, j + 1, end );
    }
}


void sort(int* array, int size){
    // 配列全体を対象にする
    quick_sort_rec( array, 0, (int)(size - 1) );
}

int main(void){
    int n, judge = 1;
    scanf("%d", &n);
    int data[n];
    for(int i = 0; i < n; i++){
        scanf("%d", &data[i]);
    }
    sort(data, n);
    for(int i = 0; i < n - 1; i++){
        if(data[i] == data[i + 1]){
            printf("NO\n");
            return 0;
        }
    }
    printf("YES\n");
    return 0;
}

Measured memory_bytes: 896
#include<iostream>
#include<math.h>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<vector>
using namespace std;
typedef long long LL;
typedef pair<int, int> P;

int main(){
    LL N,a[5];
    cin>>N;
    LL ans=0;
    LL m=1001000100010001;
    for(int i=0;i<5;i++){
        cin>>a[i];
        m=min(m,a[i]);
    }
    cout<<4+(N+m-1)/m<<endl;
    return 0;
}

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

long long n, l, t, now, cnter = 0, x, w;
vector<long long> ans;

int main() {
  int i;
  cin >> n >> l >> t;
  for(i = 0; i < n; ++i) {
    cin >> x >> w;
    if(w == 1) {
      now = x + t;
      ans.push_back(now % l);
      cnter -= now / l;
    }
    else {
      now = t - x;
      if(t >= x) {
        ++cnter;
        if(t % l == x) --cnter;
        cnter += now / l;
      }
      if(now % l == 0)
        now = l;
      else
        now %= l;
      if(t >= x)
        ans.push_back(l - now);
      else
        ans.push_back(-now);
    }
  }
  if(cnter > 0)
    cnter %= n;
  else {
    cnter *= -1;
    cnter = n - cnter % n;
  }
  // cout << cnter << " ";
  sort(ans.begin(), ans.end());
  for(i = 0; i < n; ++i) cout << ans[((n - cnter) + i) % n] << endl;
  return 0;
}


Measured memory_bytes: 2164
#include<iostream>
#include<vector>
#include<string>

int main(){
    int n;
    std::cin >> n;
    std::vector<int> x(n);
    int minX = 100, maxX = 0;
    for(int i = 0; i < n; i++){
        std::cin >> x[i];
        minX = std::min(minX, x[i]);
        maxX = std::max(maxX, x[i]);
    }

    long long ans = 100 * 100 * 100;
    for(int i = minX; i <= maxX; i++){
        long long tmp = 0;
        for(int j = 0; j < n; j++){
            tmp += (x[j] - i) * (x[j] - i);
        }
        ans = std::min(ans, tmp);
    }

    std::cout << ans << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;

bool ans(vector<char> &cal, vector<int> &num, int n, bool finished){
    if (finished) {
        return true;
    }
    if (n == 0) {
        int sum = num.at(0);
        for (int i = 0; i < 3; i++) {
            if (cal.at(i) == '+') {
                sum += num.at(i + 1);
            }
            else {
                sum -= num.at(i + 1);
            }
        }
        if (sum == 7) {
            for (int i = 0; i < 3; i++) {
                cout << num.at(i) << cal.at(i);
            }
            cout << num.at(3) << "=7";
            return true;
        }
        else {
            return false;
        }
    }
    else {
        cal.at(3 - n) = '+';
        finished = ans(cal, num, n - 1, finished);
        if (finished) {
            return true;
        }
        cal.at(3 - n) = '-';
        finished = ans(cal, num, n - 1, finished);
        if (finished) {
            return true;
        }
    }
}

int main() {
    int s;
    cin >> s;
    vector<int> num(4);
    for (int i = 3; i > -1; i--) {
        num.at(i) = s % 10;
        s /= 10;
    }
    vector<char> cal(3);
    bool finished = false;
    ans(cal, num, 3, finished);
}

Measured memory_bytes: 256
#include <iostream>

long long mod_pow(long long x, long long n, long long mod) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) {
      res = res * x % mod;
    }
    x = x * x % mod;
    n >>= 1;
  }
  return res;
}

long long mod_inverse(long long x, long long mod) {
  return mod_pow(x, mod - 2, mod);
}

// return nCk % mod
// it takes O(k)
long long mod_comb(long long n, long long k, long long mod) {
  long long numer = 1, denom = 1;
  for (long long i = 0; i < k; i++) {
    numer = numer * ((n - i) % mod) % mod;
    denom = denom * ((i + 1) % mod) % mod;
  }
  return numer * mod_inverse(denom, mod) % mod;
}

int main() {
  const int mod = 1000000007;
  int N, K;
  std::cin >> N >> K;

  for (int i = 1; i <= K; i++) {
    long long ans = mod_comb(N - K + 1, i, mod);
    ans = (ans * mod_comb(K - 1, i - 1, mod)) % mod;
    ans = (ans + mod) % mod;

    std::cout << ans << "\n";
  }

  return 0;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	sc.Scan()
	a, err := strconv.Atoi(sc.Text())
	if err != nil {
		f.Println(err)
	}
	return a
}

func scanSlice(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = scanInt()
	}
	return a
}

func main(){
	sc.Split(bufio.ScanWords)
	num := scanSlice(5)

	for i, _ := range num {
		if num[i] == 0 {
			f.Println(i+1)
			break;
		}
	}
}

Measured memory_bytes: 1756
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
using namespace std;
///////////////////library zone!!!!!!!!!!!!!!!!!!!!!!!!!!!!
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
#define EPS (1e-5)
#define bit(n,k) ((n>>k)&1)
const ll Mod = 1000000007;
const ll mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H &b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H &b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H &b) const { return x == b.x&&y == b.y; }
	bool operator!=(const H &b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P &b) const { return cost < b.cost; }
	bool operator>(const P &b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E &b) const { return cost < b.cost; }
	bool operator>(const E &b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T &a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T &a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	ll k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j%i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
vector<string>split(string s, char c = ' ') {
	vector<string>vec;
	string h = "";
	for (int i = 0; i < s.size();) {
		int j = i;
		while (j < s.size() && s[j] != ' ') {
			h += s[j++];
		}
		if (h.size() > 0) vec.push_back(h);
		h = "";
		i = j + 1;
	}
	return vec;
}
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
int a, b, t;
signed main() {
	cin >> a >> b >> t;
	cout << t / a * b << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF (int)1e9
#define endl "\n"
#define ll long long
#define ull unsigned long long

using namespace std;

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

    ll n, k;
    cin >> n >> k;

    map<int, int> look;

    for (int i = 0; i < k; i++)
    {
        int d;
        cin >> d;

        for (int j = 0; j < d; j++)
        {
            int p;
            cin >> p;
            look[p - 1]++;
        }
    }

    int ans = 0;
    for (int i = 0; i < n; i++)
        ans += !look[i];
    cout << ans << endl;
}

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

#define PI 3.141592653589
#define ll long long int
#define ld long double
#define vi vector<int>
#define ii pair<int,int>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define pll pair<ll,ll>
#define vv vector
int MOD=1e9+7;
ll power(ll a, ll b){//a^b
    ll res=1;
    a=a%MOD;
    while(b>0){
        if(b&1){res=(res*a)%MOD;b--;}
        a=(a*a)%MOD;
        b>>=1;
    }
    return res;
}
ll fermat_inv(ll y){return power(y,MOD-2);}
ll gcd(ll a, ll b){return (b==0)?a:gcd(b,a%b);}
ll min(ll a,ll b){return (a>b)?b:a;}
ll max(ll a,ll b){return (a>b)?a:b;}
bool prime[1000001];
vi primes;
void SieveOfEratosthenes(int n) 
{ 
    memset(prime, true, sizeof(prime)); 
    for (int p=2; p*p<=n; p++) 
    { 
        if (prime[p] == true) 
        { 
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
    for(int p=2;p<1000001;p++)
        if(prime[p])
            primes.pb(p);
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif

	int t=1;
	//cin>>t;
	//SieveOfEratosthenes(1000000);
    while(t--){
        int n;
        cin>>n;
        int a[n];
        for(int i=0;i<n;i++)
            cin>>a[i];
        vi v,z;
        z.pb(a[0]);
        for(int i=1;i<n;i++)
            if(a[i]!=z.back())
                z.pb(a[i]);
        if(z.size()==1){
            cout<<1000;
            continue;
        }
        if(z[0]<z[1])
            v.pb(z[0]);
        for(int i=1;i<z.size()-1;i++){
            if(z[i]>z[i-1]&&z[i]>z[i+1]||z[i]<z[i-1]&&z[i]<z[i+1])
                v.pb(z[i]);
        }
        v.pb(z.back());
        if(v.size()==1){
            cout<<1000;
            continue;
        }
        ll cash=1000;
        for(int i=0;i<v.size()-1;i+=2){
            ll c=cash/v[i];
            cash+=c*(v[i+1]-v[i]);
        }
        cout<<cash;
    }
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
  
int main()
{
  int N;
  cin >> N;
  vector<ll> A(3*N);
  REP(i, 3*N) cin >> A[i];

  sort(ALL(A));
  reverse(ALL(A));
  ll sum = 0;
  REP(i,2*N){
    if(i%2 == 1){
      sum+=A.at(i);
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 5556
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {n: u128};

    let mut result = 1;
    let max = 1_000_000_000 + 7;

    for i in 1..n + 1 {
        result *= i;
        if result > max {
            result %= max;
        }
    }

    println!("{}", result)
}


Measured memory_bytes: 2144