akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define N 6001
#define INF (1e9)
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> PP;
vector<P> G[N];
int n,m,cap,ls[N];
void add_edge(int a,int b,int d){
  G[a].push_back(P(b,d));
  G[b].push_back(P(a,d));
}

int dijkstra(){
  map<P,int> D;
  int used[N]={};
  priority_queue<PP,vector<PP>,greater<PP> > Q;
  Q.push(PP(0,P(cap,0)));
  
  D[P(cap,0)]=0;
  while(!Q.empty()){
    PP t=Q.top();Q.pop();
    int d=t.first,c=t.second.first,pos=t.second.second;

    if(pos==1) return d;
    if(D[P(c,pos)]<d)continue;
    if(ls[pos])c=cap;
    if(used[pos]>c) continue;
    used[pos]=c;
    
    for(int i=0;i<G[pos].size();i++){
      int nd=d+G[pos][i].second;
      int nx=G[pos][i].first;
      int nc=c-G[pos][i].second;
      if(nc>=0&&(!D.count(P(nc,nx))||D[P(nc,nx)]>nd))
	Q.push(PP(nd,P(nc,nx))),D[P(nc,nx)]=nd;
    }
  }
  return -1;
}


int main(){
  while(1){
    cin>>n>>m>>cap;cap*=10;
    if(!n&&!m&&!cap)break;
    for(int i=0;i<N;i++)G[i].clear(),ls[i]=0;
    
    map<string,int> M;
    string a,b;
    cin>>a>>b;
    M[a]=0,M[b]=1;
    int _n=2;
    for(int i=0,d;i<n;i++){
      cin>>a>>b>>d;
      if(!M.count(a)) M[a]=_n++;
      if(!M.count(b)) M[b]=_n++;
      add_edge(M[a],M[b],d);
    }
    n=_n;
    for(int i=0;i<m;i++) {cin>>a;if(M.count(a))ls[M[a]]=1;}
    cout <<dijkstra()<<endl;
  }
  return 0;
}

Measured memory_bytes: 58820
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>

using namespace std;

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

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

#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EACH(t,i,c) for(t::iretator i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

const double EPS = 1e-10;

int toNum(string str) {
	int num = 0;
	int a = 1;

	REP(i, str.size()) {
		switch(str[i]) {
		case 'm':
			num += a*1000;
			a = 1;
			break;
		case 'c':
			num += a*100;
			a = 1;
			break;
		case 'x':
			num += a*10;
			a = 1;
			break;
		case 'i':
			num += a;
			a = 1;
			break;
		case '2':
		case '3':
		case '4':
		case '5':
		case '6':
		case '7':
		case '8':
		case '9':
			a = str[i]-'0';
			break;			
		}
	}

	return num;
}

string toMcxi(int num) {
	string str;
	int m, c, x, i;

	m = num/1000;
	num -= m*1000;
	c = num/100;
	num -= c*100;
	x = num/10;
	num -= x*10;
	i = num;

	if(m) {
		if(m != 1) {
			str += toString<int>(m);
		}
		str += 'm';
	}
	if(c) {
		if(c != 1) {
			str += toString<int>(c);
		}
		str += 'c';
	}
	if(x) {
		if(x != 1) {
			str += toString<int>(x);
		}
		str += 'x';
	}
	if(i) {
		if(i != 1) {
			str += toString<int>(i);
		}
		str += 'i';
	}
	return str;
}

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

	REP(i, n) {
		string str1, str2;
		cin >> str1 >> str2;

		cout << toMcxi(toNum(str1) + toNum(str2)) << endl;
	}

}

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

void trace(vector<int> a, int n, int cnt) {
	for (int i = 0;i < n;i++) {
		cout << a[i];
		if (i < n - 1)cout << " ";
		if (i == n - 1) cout << endl;
	}
	cout << cnt << endl;
}
void selectionSort(vector<int> a, int n) {
	int cnt = 0;
	for (int i = 0;i < n;i++) {
		int minj = i;
		for (int j = i;j < n;j++) {
			if (a[j] < a[minj]) {
				minj = j;
			}
		}
		if (minj != i)cnt++;
		int tmp = a[i];
		a[i] = a[minj];
		a[minj] = tmp;
	}
	trace(a, n, cnt);
}
int main(void) {
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0;i < n;i++)cin >> a[i];
	selectionSort(a, n);
	return 0;
}


Measured memory_bytes: 3140
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define pii pair <int, int>
#define F first
#define S second
#define ll long long
#define io ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define M_PI 3.14159265358979323846
const int N = 100005;
const int mod = 1e9 + 7;
int main() {
    io;
    int n;
    cin >> n;
    ll o = 1, p = 1, l = 2;
    for(int i = 1; i <= n; i++){
        p *= 10;
        l *= 9;
        o *= 8;
        l %= mod;
        p %= mod;
        o %= mod;
    }
    cout << ((p - l + o) + mod) % mod;
}


Measured memory_bytes: 3640
/*** akshaykumar99 ***/
 
#include<bits/stdc++.h> 
using namespace std;
 
const long long MOD = 1e9+7;
const long double PI = acos(-1);
const long long N = 5e2+1;
 
typedef long long ll;
typedef long double ld;

void test_case()
{
	string s;
	cin >> s;
	int n = s.size();
	int z = 0;
	for(int i = 0;i < n;i++)
	{
		z += s[i] - '0';
	}
	if(z %9 == 0)
		cout << "Yes\n";
	else
		cout <<"No\n";
}
 
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL); 
    ll tc=1;
    // cin>>tc;
    while(tc--)
        test_case();
    return 0;
}


Measured memory_bytes: 3716
#include<stdio.h>

int compare(int *a, int *b)
{
    return (*b - *a);
}

int main(void)
{
    int array[10], i;
    for(i = 0; i != 10; i++)
        scanf("%d",array+i);
    qsort(array, 10, sizeof(int), compare);
    for(i = 0; i != 3; i++)
        printf("%d\n", array[i]);
    return 0;
}

Measured memory_bytes: 604
#ifdef __GNUC__
#pragma GCC target("avx2")
#pragma GCC optimize ("O20")
#pragma GCC optimize ("tree-vectorize")
#pragma GCC optimize("unroll-loops")
#define iss std::cin
#endif
#include "bits/stdc++.h"
#define rep(i, times) for(ll i = 0; i < (times); ++i)
#define p(x) (cout << x << "\n")
using ll = uint16_t; using ld = long double; using namespace std;

#ifndef __GNUC__
string text =
R"X(
8
7 3 5 4 2 1 6 8
3 8 2 5 4 6 7 1
)X";
stringstream iss{text};
#endif

class CountOrder
{
	ll N{0};
	vector<ll> p, q;
	void inp( ) {
		iss >> N; p.resize(N); q.resize(N);
		rep(n, N) { iss >> p[n]; }
		rep(n, N) { iss >> q[n]; }
		//for_each(begin(p), end(p), [](auto x) { cout << x << "\n"; });
	}
	void change( ) {
		long long sa{0};
		auto it0{begin(p)}, it1{end(p)};
		if (p > q) { it0 = begin(q); it1 = end(q); }
		do {
			if (p == q) break;
			++sa;
		} while (next_permutation(it0, it1));
		p(sa);
	}
public:
	void procedures( ) {
		inp( );
		change( );
	}
};
//https://atcoder.jp/contests/abc145/tasks/abc145_c
int main( ) {
	cin.tie(0);	ios::sync_with_stdio(0);
	class CountOrder a; a.procedures( );
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
#define ll long long int 
#define mod 1000000007
#define se second
#define fi first
#define endl "\n"
#define pi 3.1415926535897932384626433832795028841971
#define MAX 9223372036854775807
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
//	cout<<fixed<<setprecision(15);
	ll n,k;
	cin>>n>>k;
	ll arr[n];
	for(int a=0;a<n;a++)
	cin>>arr[a];
	sort(arr,arr+n);
	ll ans=0;
	for(int a=0;a<k;a++)
	ans+=arr[a];
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3640
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def main():
    n = int(input().strip())
    a_list = list(map(int, input().split()))

    ans = 0
    for i in range(n):
        if (i + 1) % 2 == 1 and a_list[i] % 2 == 1:
            ans += 1
    print(ans)

if __name__ == '__main__':
    main()


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

const int mod=1000000007;
int n,f[2][(1<<17)+1],T,X,Y,Z,m,ans;
inline void reduce(int&x){x+=x>>31&mod;}

int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>n>>X>>Y>>Z;m=X+Y+Z;
	f[0][1]=ans=1;
	for(int i=1;i<=n;++i){
		ans=ans*10ll%mod;T^=1;memset(f[T],0,sizeof f[T]);
		for(int j=0;j<(1<<m);++j)if(f[!T][j])
			for(int k=1;k<=10;++k){
				int t=(j<<k)|1;
				if((t>>Z&1)&&(t>>(Y+Z)&1)&&(t>>(X+Y+Z)&1))continue;
				t&=(1<<m)-1;reduce(f[T][t]+=f[!T][j]-mod);
			}
	}
	for(int i=0;i<(1<<m);++i)reduce(ans-=f[T][i]);
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 1280
#include <iostream>
#include <cstdio>
#include <map>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < n; i++)
const int sz = 1e6;
int a, b;
map<int, int> dp;
void solve()
{
    cin >> a >> b;
    dp[0] = 1;
    int c = 0;
    int ret = 0;
    for (int i = 1; i <= a; i++)
    {
        int t;
        cin >> t;
        c += t;
        c %= b;
        ret += dp[c]++;
    }
    cout << ret << endl;
}
main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    solve();
    return 0;
}

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

namespace ConsoleApp1
{
    class Program
    {
        static int Calc(int data1, int data2) {

            int ans = data1 % data2;
            if (ans == 0) { return data2; }

            return Calc(data2, ans);    
        }

        static void Main(string[] args)
        {
            //////string[] inputData = Console.ReadLine().Split(' ');
            //////Int32 inputData = Int32.Parse(Console.ReadLine());
            ////string inputData = Console.ReadLine();

            ////if (inputData.Contains("7"))
            ////{
            ////    Console.WriteLine("Yes");

            ////} else
            ////{ 
            ////    Console.WriteLine("No");
            ////}
            //Int64 ans = 0;
            //Int64 inputData = Int64.Parse(Console.ReadLine());
            //for (Int64 loop = 1; loop <= inputData; loop++) {
            //    if (loop % 3 != 0 && loop % 5 != 0) {
            //        ans += loop;
            //    }
            //}

            int inputData = int.Parse(Console.ReadLine());

            Int64 ans = 0;
            for (int loop1 = 1; loop1 <= inputData; loop1++)
            {
                for (int loop2 = 1; loop2 <= inputData; loop2++)
                {
                    for (int loop3 = 1; loop3 <= inputData; loop3++)
                    {
                        int calc1 = Calc(loop1, loop2);
                        int calc2 = Calc(loop3, calc1);
                        ans += calc2;
                    }
                }
            }

            Console.WriteLine(ans);
            Console.ReadLine();
        }
    }
}


Measured memory_bytes: 27540
import java.io.*;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {

    static class Task {

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int[] arr = new int[n];
            for (int i = 0; i < n; i++) {
                arr[i] = in.nextInt();
            }

            int ans = 0;
            for (int i = 0; i < n; i++) {
                if (i % 2 == 0 && arr[i] % 2 == 1) {
                    ans++;
                }
            }

            out.println(ans);
        }
    }

    private static void sort(double[] arr) {
        Double[] objArr = Arrays.stream(arr).boxed().toArray(Double[]::new);
        Arrays.sort(objArr);
        for (int i = 0; i < arr.length; i++) {
            arr[i] = objArr[i];
        }
    }

    private static void sort(int[] arr) {
        Integer[] objArr = Arrays.stream(arr).boxed().toArray(Integer[]::new);
        Arrays.sort(objArr);
        for (int i = 0; i < arr.length; i++) {
            arr[i] = objArr[i];
        }
    }

    private static void sort(long[] arr) {
        Long[] objArr = Arrays.stream(arr).boxed().toArray(Long[]::new);
        Arrays.sort(objArr);
        for (int i = 0; i < arr.length; i++) {
            arr[i] = objArr[i];
        }
    }

    private static void solve() {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task task = new Task();
        task.solve(1, in, out);
        out.close();
    }

    public static void main(String[] args) {
        new Thread(null, () -> solve(), "1", 1 << 26).start();
    }

    static class InputReader {

        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

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

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

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

    }

}

Measured memory_bytes: 33928
#include <iostream>

bool solve(int i, int m);
int n, q, A[2000], m[2000];

int main()
{
	using namespace std;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> A[i];
	}
	cin >> q;
	for (int i = 0; i < q; i++)
	{
		cin >> m[i];
	}
	for (int i = 0; i < q; i++)
	{
		if (solve(0, m[i]))
		{
			cout << "yes\n";
		}
		else
		{
			cout << "no\n";
		}
	}
	return 0;
}

bool solve(int i, int m)
{
	if (m == 0)
	{
		return true;
	}
	if (i >= n)
	{
		return false;
	}
	return solve(i + 1, m) || solve(i + 1, m - A[i]);
}


Measured memory_bytes: 3092
/// Containers Start
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
/// C Header Files
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <math.h>
#include <stdio.h>
/// Containers End

using namespace std;

/// Math Start
#define PI acos(-1.0)
#define Pi 3.141592653589793
#define EPS (1e-7)
#define INF (0x3f3f3f3f)
/// Math End

/// Extra Start
#define nn '\n'
#define pb push_back
#define ull unsigned long long
#define ll long long
#define MOD 1000000007
#define sz(a) int((a).size())
#define space " "
#define All(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
/// Extra End

#define rep(i, n) for (int i = 0; i < n; i++)
#define Cini(a)                                                                \
    int a;                                                                     \
    cin >> a;
#define Cinii(a, b)                                                            \
    int a, b;                                                                  \
    cin >> a >> b;
#define Ciniii(a, b, c)                                                        \
    int a, b, c;                                                               \
    cin >> a >> b >> c;
#define Cins(s)                                                                \
    string s;                                                                  \
    cin >> s;
#define Cinss(s1, s2)                                                          \
    string s1, s2;                                                             \
    cin >> s1 >> s2;
#define Cinc(c)                                                                \
    char c;                                                                    \
    cin >> c;
/// Functions End


/// Debug Start
#define deb(x) cout << #x << ": " << x << endl
#define deb2(x, y) cout << #x << ": " << x << '\t' << #y << ": " << y << endl;
#define deb3(x, y, z)                                                          \
    cout << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": "   \
         << z << endl;
/// Debug End

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

/**>>>>>>>>>>>>>>>>>>> END <<<<<<<<<<<<<<<<<<**/

/// template

#define int long long

signed main(void) {
    cin.sync_with_stdio(false);
    cin.tie(0);
    Cinii(M,D);
    int ans = 0;
    rep(i,M)rep(j,D){
        int month = i+1;
        int day = j+1;
        int d1 = day % 10;
        int d10 = (day - d1)/10;
        if(d1>=2 && d10 >=2 && d1 * d10 == month) ans++;
    }
    cout << ans << nn;
    return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;


public class Main {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		int n = sc.nextInt();
		int i = sc.nextInt();

		pr.println(n - i + 1);
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(INPUT == null ? System.in : new ByteArrayInputStream(INPUT.getBytes()));
		pr = new Printer(System.out);

		solve();

//		pr.close();
		pr.flush();
//		sc.close();
	}

	static String INPUT = null;

	private static class Printer extends PrintWriter {
		Printer(OutputStream out) {
			super(out);
		}
	}
}


Measured memory_bytes: 22740
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
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 long long INF = 1LL << 60;
int main()
{
    int a,b;
    cin >> a>>b;

    string ab="";
    string ba="";
    REP(i,a) ba+=char('0'+b);
    REP(i,b) ab+=char('0'+a);
    // cout << "ab: "<<ab << endl;
    // cout << "ba: "<<ba << endl;
    if(ab>ba) cout << ba << endl;
    else cout << ab << endl;
    return 0;
}

Measured memory_bytes: 256
use proconio::input;
use proconio::marker::Chars;
use std::cmp::min;

fn main() {
    input! {
        _: usize,
        s: Chars,
    }

    let mut map = Vec::new();

    let mut num = 0;
    for c in &s {
        match c {
            'E' => num += 1,
            _ => {},
        }
        map.push(num);
    }

    let mut ans = 1_000_000;
    for i in 0..s.len() {
        let mut t = 0;
        // リーダより右側でWを向いていない者たちの数
        t += if i < s.len() - 2 { map[s.len() - 1] - map[i] } else { 0 };
        // リーダより左側でEを向いていない者たちの数
        t += if i > 1 { i - map[i - 1] } else { 0 };

        ans = min(ans, t);
    }

    println!("{:?}", ans);
}

Measured memory_bytes: 5944
#include<map>
#include<set>
#include<bitset>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<chrono>
#include<stack>
#include<fstream>
#include<list>
#define REP(i,x,y) for(ll i=x;i<=y;i++)
#define SIZE(a) ll(a.size())
#define vll vector<ll> 
#define MEMSET(a, n, m) for(ll i=0;i<=n;i++) a[i] = m
#define BIT(n) (ll(1)<<n)
#define UNIQUE(v) v.erase(unique(v.begin(),v.end()),v.end()) 
#define UNIQUE_ARRAY(a,x) unique(a + 1, a + x + 1) - a - 1
#define SORT(a,n) sort(a+1,a+n+1)
#define SORT_O(a,n,order) sort(a+1,a+n+1,order)
#define PER(i,y,x) for(ll i=y;i>=x;i--)
typedef long long ll;
using namespace std;


struct point
{
long long num; long long name;
bool operator<(const point& rhs) const {
	return num < rhs.num;
	}
};


ll const MAX = 2e3+4;

ll a[MAX];
point b[MAX];
ll c[MAX] = {};

int main() {
	cin.tie(0);
	ll n, k, q;
	cin >> n >> k >> q;
	REP(i, 1, n) {
		cin >> a[i];
		b[i] = { a[i],i };
	}
	SORT(b, n);
	ll ans = 1e18;
	c[n + 1] = 1;
	REP(i, 1, n) {
		if (i+q-1 > n) break;	

		//ll x = b[i + q - 1].num - b[i].num;
		//cout << x << endl;
		ll cur = 0;
		ll cnt = 0;
		vll t, s;
		REP(j, 1, n + 1) {
			if (c[j] == 0) {
				cur++;
				t.push_back(a[j]);
			}
			else {
				if (cur >= k) {
					sort(t.begin(), t.end());
					REP(i, 0, cur - k) {
						s.push_back(t[i]);
					}
				}
				cur = 0;
				t.clear();
			}
		}
		if (s.size() >= q) {
			sort(s.begin(), s.end());
			ans = min(ans, s[q - 1] - s[0]);
		}
		else { break; }
		c[b[i].name] = 1;
	}
	cout << ans << endl;
}

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

int main() {
	int n;
	cin >> n;
	int64_t ans[n + 1];
	ans[0] = 2;
	ans[1] = 1;
	for (int i = 2; i <= n; i++) {
		ans[i] = ans[i - 1] + ans[i - 2];
	}
	cout << ans[n] << endl;
	return 0;
}

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

a = []
x = 1
while x * x <= M:
    if M % x == 0:
        a.append(x)
        a.append(M/x)
    x += 1

res = 0
for i in a:
    if M / i >= N:
        res = max(res, i)
print(res)


Measured memory_bytes: 2568
#include<bits/stdc++.h>
using namespace std;
int main()
{
    cin.sync_with_stdio(false);
    string a;
    cin>>a;
    if(a=="AAB"||a=="BAA"||a=="ABA"||a=="BBA"||a=="BAB"||a=="ABB")
    cout<<"Yes";
    else cout<<"No";
    return 0;
}


Measured memory_bytes: 256
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_macros)]
#![allow(unused_imports)]

use std::str::FromStr;
use std::io::*;
use std::collections::*;
use std::cmp::*;

struct Scanner<I: Iterator<Item = char>> {
    iter: std::iter::Peekable<I>,
}

macro_rules! exit {
    () => {{
        exit!(0)
    }};
    ($code:expr) => {{
        if cfg!(local) {
            writeln!(std::io::stderr(), "===== Terminated =====")
                .expect("failed printing to stderr");
        }
        std::process::exit($code);
    }}
}

impl<I: Iterator<Item = char>> Scanner<I> {
    pub fn new(iter: I) -> Scanner<I> {
        Scanner {
            iter: iter.peekable(),
        }
    }

    pub fn safe_get_token(&mut self) -> Option<String> {
        let token = self.iter
            .by_ref()
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            Some(token)
        }
    }

    pub fn token(&mut self) -> String {
        self.safe_get_token().unwrap_or_else(|| exit!())
    }

    pub fn get<T: FromStr>(&mut self) -> T {
        self.token().parse::<T>().unwrap_or_else(|_| exit!())
    }

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

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

    pub fn char(&mut self) -> char {
        self.iter.next().unwrap_or_else(|| exit!())
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.get::<String>().chars().collect()
    }

    pub fn line(&mut self) -> String {
        if self.peek().is_some() {
            self.iter
                .by_ref()
                .take_while(|&c| !(c == '\n' || c == '\r'))
                .collect::<String>()
        } else {
            exit!();
        }
    }

    pub fn peek(&mut self) -> Option<&char> {
        self.iter.peek()
    }
}

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

impl<U: ToString, T: Iterator<Item = U>> Joinable for T {
    fn join(self, sep: &str) -> String {
        self.map(|x| x.to_string()).collect::<Vec<_>>().join(sep)
    }
}
fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin.bytes().map(|c| c.unwrap() as char));
    let n: usize = sc.get();
    let A: Vec<usize> = sc.vec(n);
    let q: usize = sc.get();
    let m: Vec<usize> = sc.vec(q);
    let mut sums = HashSet::new();
    for bit in 0..1<<n {
        let mut acc = 0;
        for j in 0..n {
            if bit>>j & 1 != 0 {
                acc += A[j];
            }
        }
        sums.insert(acc);
    }
    for i in 0..q {
        if sums.contains(&m[i]) {
            println!("yes");
        } else {
            println!("no");
        }
    }
}



Measured memory_bytes: 5032
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  ll n;
  cin >> n;
  map<ll, int> m;
  ll ans = 0;
  for (int i = 0; i < n; i++) {
    ll a;
    cin >> a;
    ans += m[i - a];
    m[i + a]++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 26296
#include<bits/stdc++.h>
using namespace std ;
#define ll long long int 
#define pb push_back 
#define mp make_pair 
#define pii pair <int , int > 
#define pll pair < ll , ll >
int main(){
	ios_base::sync_with_stdio(false) ;
	cin.tie(NULL) ;
	ll n ;
	cin >> n ;
	ll d[n + 1] ;
	for(int i = 1 ; i <= n ; i++) cin >> d[i] ;
	ll sum = d[1] + d[n] ;
	for(int i = 2 ; i < n ; i++){
		if(i %2 ) sum = sum + d[i] ;
		else sum = sum - d[i] ;
	} 
	// cout << sum << '\n' ;
	ll ans[n+ 1] ;
	ans[1] = sum/2 ;
	for(int i = 2 ; i < n ; i++) ans[i] = d[i - 1] - ans[i - 1] ;
	ans[n] = d[n] - ans[1] ;
	for(int i = 1 ; i <= n ; i++) cout << 2*ans[i] << " " ;
}

Measured memory_bytes: 2944
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
//typedef vector<unsigned int>vec;
typedef vector<ll>vec;
typedef vector<vec> mat;
typedef vector<vector<int>> Graph;

const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll  MOD = 1000000007;
//const ll MOD = 998244353;
const double PI = acos(-1.0);
const double EPS = 1e-10;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    double a, b, x, theta;
    cin >> a >> b >> x;
    double V = a*a*b;
    if(x >= V / 2) theta = atan(2 * (a*a*b - x) / (a * a * a));
    else theta = atan((a*b*b) / (2*x));
    theta *= 180 / PI;
    printf("%.12lf\n", theta);
}


Measured memory_bytes: 256
S = input()
T = input()
alph = [chr(i) for i in range(97, 97+26)]
flag = True
for a in alph:
    S_pos = [i for i in range(len(S)) if S[i] == a]
    T_pos = [i for i in range(len(T)) if T[i] == a]
    if len(S_pos) > 1:
        for i in S_pos:
            if T[i] != T[S_pos[0]]:
                flag = False
                break
    if len(T_pos) > 1:
        for i in T_pos:
            if S[i] != S[T_pos[0]]:
                flag = False
                break
    if not flag:
        break

if flag:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 11652
import java.util.*;
import java.io.*;
public class Main
{
    public static void main(String []args) throws IOException {
    	FastScanner in  = new FastScanner(System.in);
    	PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)), false);
    	solve(in, out);
    	in.close();
    	out.close();
    }
    static long gcd(long a, long b){ return (b==0) ? a : gcd(b, a%b); }
    static int gcd(int a, int b){ return (b==0) ? a : gcd(b, a%b); }
    static class FastScanner{
	BufferedReader reader;
	StringTokenizer st;
	FastScanner(InputStream stream){reader=new BufferedReader(new InputStreamReader(stream));st=null;}
	String next(){while(st == null || !st.hasMoreTokens()){try{String line = reader.readLine();if(line == null){return null;}
	     st = new StringTokenizer(line);}catch (Exception e){throw new RuntimeException();}}return st.nextToken();}
	String nextLine()  {String s=null;try{s=reader.readLine();}catch(IOException e){e.printStackTrace();}return s;}
	int    nextInt()   {return Integer.parseInt(next());}
	long   nextLong()  {return Long.parseLong(next());}
	double nextDouble(){return Double.parseDouble(next());}
	char   nextChar()  {return next().charAt(0);}
	int[]  nextIntArray(int n)         {int[] arr= new int[n];   int i=0;while(i<n){arr[i++]=nextInt();}  return arr;}
	long[] nextLongArray(int n)        {long[]arr= new long[n];  int i=0;while(i<n){arr[i++]=nextLong();} return arr;}
	int[]  nextIntArrayOneBased(int n) {int[] arr= new int[n+1]; int i=1;while(i<=n){arr[i++]=nextInt();} return arr;}
	long[] nextLongArrayOneBased(int n){long[]arr= new long[n+1];int i=1;while(i<=n){arr[i++]=nextLong();}return arr;}
	void   close(){try{reader.close();}catch(IOException e){e.printStackTrace();}}
    }
    
    /********* SOLUTION STARTS HERE ************/
    
    private static void solve(FastScanner in, PrintWriter out){
        int n = in.nextInt();
        out.println(n*n*3);
    }
    
    /************* SOLUTION ENDS HERE **********/
}

Measured memory_bytes: 21204
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <numeric>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

int main(void)
{
    int n;
    cin >> n;

    vector<ll> a(n), b(n);

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

    sort(a.begin(), a.end());
    sort(b.begin(), b.end());

    ll ans = 0;

    if (n & 1)
    {
        cout << b[n / 2] - a[n / 2] + 1 << endl;
    }
    else
    {
        cout << b[n / 2] + b[n / 2 - 1] - (a[n / 2] + a[n / 2 - 1]) + 1 << endl;
    }
}


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

int main(){
  int n,k;
  cin >> n >> k;
  vector<int> p(n);
  for(int i = 0;i < n;i++)
    cin >> p[i];
  double sum = 0.0,m = 0.0;
  for(int i = 0;i < n;i++){
    sum += p[i];
    if(i >= k)
      sum -= p[i - k];
    if(m < sum)
      m = sum;
  }
  cout << fixed << setprecision(10) << (m + k) / 2.0 << endl;
}

Measured memory_bytes: 1024
#include<stdio.h>

int main(){
 int i,n;
 long long int sum,min,max,x;
 scanf("%d",&n);
 scanf("%lld",&x);
 min = x;
 max = x;
 sum = x;
 for(i=1;i<n;i++){
  scanf("%lld",&x);
  sum = sum + x;
  if(x < min) min = x;
  if(max < x) max = x;}
 printf("%lld %lld %lld\n",min,max,sum);
 return 0;}

Measured memory_bytes: 600
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <cassert>
using namespace std;
typedef long long ll;

struct Idx { int ia, ib, ic; };
bool used[1003][1003][1003];
deque<Idx> que;
vector<ll> ans;

int main() {
	int X, Y, Z, K; cin >> X >> Y >> Z >> K;
	vector<ll> a(X), b(Y), c(Z);
	for (int i = 0; i < X; i++) cin >> a[i];
	for (int i = 0; i < Y; i++) cin >> b[i];
	for (int i = 0; i < Z; i++) cin >> c[i];
	sort(a.rbegin(), a.rend());
	sort(b.rbegin(), b.rend());
	sort(c.rbegin(), c.rend());
	vector<ll> ab;
	for (int i = 0; i < X; i++) {
		for (int j = 0; j < Y; j++) {
			ab.push_back(a[i] + b[j]);
		}
	}
	sort(ab.rbegin(), ab.rend());
	vector<ll> abc;
	for (int i = 0; i < min(X*Y, K); i++) {
		for (int j = 0; j < Z; j++) {
			abc.push_back(ab[i] + c[j]);
		}
	}
	sort(abc.rbegin(), abc.rend());
	for (int i = 0; i < K; i++) cout << abc[i] << endl;
	return 0;
}


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

int main(){
    int n,x;
    cin>>n>>x;
    vector<int>a(n);
    for(int i=0;i<n;i++)cin>>a[i];
    a.push_back(x);
    sort(a.begin(),a.end());
    int ans=a[1]-a[0];
    for(int i=1;i<n;i++)ans=__gcd(ans,a[i+1]-a[i]);
    cout<<ans;
}


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

int main(){
  int a, b;
  cin >> a >> b;
  if ((a * b * 1) % 2 == 1 || (a * b * 2) % 2 == 1 || (a * b * 3) % 2 == 1) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

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

#define ll long long 
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3f
#define all(x) (x).begin(),(x).end()
#define f(i, a, b) for (int i=a; i<(signed)(b); ++i)
#define pc __builtin_popcount // counts number of 1's in bin(num)
#define pb push_back
#define mp make_pair

// debug templates 
#define debug(x)       cerr<< #x <<" : "<< x << endl;
#define debuga(A,N)    cerr<< #A <<" : [";for(int i = 0; i<N;i++) cerr<<A[i]<<" "; cerr<<"]\n";
#define debuga2(A,N,M) cerr<< #A << " : \n"; for(int i=0;i<N;i++){cerr<<"[";for(int j=0;j<M;++j) cerr<<A[i][j]<<" ";cerr<<"]\n";}
#define debugp(p)      cerr<< #p <<" : "<<"("<<(p).first<<","<<(p).second<<")\n";
#define debugv(v)      cerr<< #v <<" : "<<"[";for(int i = 0; i< (v).size(); i++) cerr<<v[i]<<" "; cerr<<"]\n";
#define debugv2(v)     cerr<< #v << " : \n"; for(int i=0;i<v.size();i++){cerr<<"[";for(int j=0;j<(v[0].size());++j) cerr<<v[i][j]<<" ";cerr<<"]\n";}
#define debugs(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin(); itr!=m.end();itr++) cerr<<*itr<<" "; cerr<<"]\n";
#define debugm(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin();itr!=m.end(); itr++) cerr<<"("<<itr->first<<","<<itr->second<<") ";cerr<<"]\n";

void solve(){
	int k,a,b; cin >> k >> a >> b;
	bool can = 0;
	f(i,a,b+1){
		if(i%k==0) can = 1;
	}
	cout << (can ? "OK" : "NG" );
}

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








Measured memory_bytes: 3608
#include<bits/stdc++.h>
#include<math.h>
#include<string.h>
#define ll long long
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define ff first
#define ss second
#define mem(x,y) memset(x,y,sizeof(x))
#define mod 1000000007
#define INF 0x3f3f3f3f
#define MAX 1000005
using namespace std; 

typedef pair<int, int> pii;

int solve(vector<int> &v){
    int n = v.size();
    int dp[n];
    dp[0] = 0;
    dp[1] = abs(v[1]-v[0]);
    for(int i=2;i<n;i++){
        int cost1 = abs(v[i]-v[i-1]);
        int cost2 = abs(v[i]-v[i-2]);
        dp[i] = min(cost1 + dp[i-1], cost2 + dp[i-2]); 
    }
    return dp[n-1];
}

int main(){
    int n;cin>>n;
    vector<int> v;

    for(int i=0;i<n;i++){
        int x;
        cin>>x;
        v.push_back(x);
    }
    cout<<solve(v)<<endl;        
    return 0;
}



Measured memory_bytes: 4068
# https://atcoder.jp/contests/abc138/tasks/abc138_d
#　木探索

def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))

from collections import deque

N, Q = MAP()
counter = [0]*N
tree = [[] for _ in range(N)]
parent = [-1]*N
for _ in range(N-1):
    a, b = MAP()
    tree[a-1].append(b-1)
    tree[b-1].append(a-1)

for _ in range(Q):
    p, x = MAP()
    counter[p-1] += x

q = deque()
q.append(0)

while q:
    index = q.pop()
    pindex = parent[index]
    for i in tree[index]:
        if i == pindex:
            continue
        counter[i] += counter[index]
        parent[i] = index
        q.append(i)

print(*counter)





Measured memory_bytes: 56152
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx")

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
const double PI = 3.1415926535897932;   // acos(-1)
const double EPS = 1e-15;
const int INF = 1001001001;
const int mod = 1e+9 + 7;

// dp[i+1][j+1] := s[i], t[j] まで見たときの LCS(longest common subsequence) の長さ
int dp[3005][3005];
// 遷移前の状態を復元用に保持しておく。
vector<P> pre[3005][3005];

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

    string s, t;
    cin >> s >> t;
    int n1 = s.length();
    int n2 = t.length();
    for(int i = 0; i < n1; ++i){
        for(int j = 0; j < n2; ++j){
            if(s[i] == t[j]){
                dp[i+1][j+1] = dp[i][j] + 1;
                pre[i+1][j+1].push_back(P(i, j));
            }
            else{
                dp[i+1][j+1] = max(dp[i+1][j], dp[i][j+1]);
                if(dp[i+1][j] > dp[i][j+1]){
                    pre[i+1][j+1].push_back(P(i+1, j));
                }
                else if(dp[i+1][j] < dp[i][j+1]){
                    pre[i+1][j+1].push_back(P(i, j+1));
                }
                else{
                    pre[i+1][j+1].push_back(P(i+1, j));
                    pre[i+1][j+1].push_back(P(i, j+1));
                }
            }
        }
    }
    for(int i = 0; i < n1; ++i){
        pre[i+1][0].push_back(P(i, 0));
    }
    for(int i = 0; i < n2; ++i){
        pre[0][i+1].push_back(P(0, i));
    }
    P now = P(n1, n2);
    string res;
    while(now != P(0, 0)){
        int x = now.first, y = now.second;
        now = pre[x][y][0];
        int nx = now.first, ny = now.second;
        if(x - nx == 1 && y - ny == 1){
            res += s[nx];
        }
    }
    reverse(res.begin(), res.end());
    cout << res << endl;
}


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


#define FOR(i, start, end) for(uint64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

// 円周率
// M_PI

// #include <iomanip> // setprecisionを使用するのに必要
// cout << std::fixed << std::setprecision(15) << y << endl;

// 昇順
// priority_queue<int, vector<int>, greater<int> > queue;

signed main() {
  int64_t n, m;
  cin >> n >> m;
  
  int matrix[n*m] = {};
  int vector[m] = {};
  
  for(int i=0;i<n;i++){
      for(int j=0;j<m;j++){
          cin >> matrix[i*m + j];
      }
  }
  for(int j=0;j<m;j++){
      cin >> vector[j];
  }
 
  for(int i=0;i<n;i++){
      int answer = 0;
      for(int j=0;j<m;j++){
          answer += matrix[i*m + j]*vector[j];
      }
      cout << answer << endl;
  }

  
  
  return 0;
}


Measured memory_bytes: 3124
N = int(input())
ln = [i for i in range(1,N+1)]

for i in range(N):
  if ln[i] % 3 == 0:
    ln[i] = 0
  elif ln[i] % 5 == 0:
    ln[i] = 0
  elif ln[i] % 15 == 0:
    ln[i] = 0
print(sum(ln))

Measured memory_bytes: 48544
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#define rep(i,n) for (int i = 0; i < (n);i++)
typedef long long ll;
using namespace std;
/*#include<boost/range/adaptors.hpp>

namespace adaptor = boost::adaptors;*/


void Main()
{
	int k,x; cin >> k >> x;
	for(int i = max(-100000,x -k +1);i<= min(100000,x+k-1);i++) {
      cout << i << endl;
    }
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}

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

int main(){
int N,M; cin >> N >> M;
  
  vector<vector<int>> jobs(M + 1);
  
  for(int i = 0; i < N; i++){
    int a,b; cin >> a >> b;
    if( a > M){ continue;}
    
    jobs[M-a].push_back(b);}
  
  priority_queue<int> Q; long long  ans = 0;
  
  for(int i = M - 1; i >= 0 ; i--){
    //後ろから貪欲方
    for(int j = 0; j < (int) jobs[i].size(); j++){
      Q.push( jobs[i][j]);}
    
    if( Q.empty()){ continue;}
    
    ans += Q.top(); // priority_queueは降順に並んでいる
    Q.pop();
  }
  
  cout << ans << endl; return 0;}

Measured memory_bytes: 5504
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
using namespace std;
int main() {
    string s;
    cin >> s;
    string a;
    a = "abcdefghijklmnopqrstuvwxyz";
    int num[26] = {0};
    for(int i = 0; i < s.size(); i++){
        for(int j = 0; j < a.size(); j++){
            if(s[i] == a[j]) ++num[j];
        }
    }
    for(int i = 0; i < 26; i++){
        if(num[i] == 0){
            cout << a[i] << endl;
            return 0;
        }
    }
    cout << "None" << endl;
    return 0;
}

Measured memory_bytes: 3720
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll mod = 1e9+7;

int main() {
  int N; cin >> N;
  vector<P> vec;
  vector<ll> a(N), b(N);
  for(int i = 0; i < N; ++i) {
    cin >> a[i];
    vec.emplace_back(P(a[i], i));
  }
  for(int i = 0; i < N; ++i) {
    cin >> b[i];
    vec.emplace_back(P(b[i], N+i));
  }
  sort(vec.begin(), vec.end());
  ll v = 1, cnt = 0;
  for(int i = 0; i < vec.size(); ++i) {
    if(vec[i].second < N) {
      if(cnt < 0) {
        v *= 1LL * (-cnt);
      }
      cnt++;
    }
    if(vec[i].second >= N) {
      if(cnt > 0) {
        v *= 1LL * cnt;
      }
      cnt--;
    }
    v %= mod;
  }
  std::cout << v << std::endl;
  return 0;
}


Measured memory_bytes: 7664
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
#define ll long long
#define ull unsigned long long
#define mod 1000000007
#define SORT(v) sort(v.begin(), v.end())
#define RSORT(v) sort(v.rbegin(), v.rend())
typedef pair<int, int> pii;

ll exp(ll taban, ll us) {
    ll carpan = taban % mod;
    ll temp = us;
    ll res = 1;
    while(temp){
        if(temp % 2) res = (res*carpan) % mod;
        temp /= 2;
        carpan = (carpan*carpan) % mod;
    }
    return res;
}
ll ebob(ll a, ll b){
    if(!a)return b;
    return ebob(b%a, a);
}
ll ekok(ll a, ll b){
    return (a*b)/ebob(a, b);
}
ll gcd(ll a, ll b){
    if(!a) return b;
    return gcd(b%a, a);
}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL);
	ll n; cin>>n;
	ll res = 1;
	for(ll i = 2; i*i <= n; i++){
		if(n%i == 0){
			ll tmp = n;
			ll diger = n/i;
			while(tmp % i == 0) tmp/=i;
			if(tmp%i == 1) res++;
			if(i*i != n){
				tmp = n;
				while(tmp % diger == 0) tmp /= diger;
				if(tmp % diger == 1) res++;
			}
		}
	}
	n--;
	for(ll i = 1; i*i <= n; i++){
		if(n%i == 0){
			if(i != 1)res++;
			if(i*i != n) res++;
		}
	}
	cout<<res<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main()
{
    char inputS[99];
    long inputLength;

    scanf("%s", inputS);
    inputLength = strlen(inputS);
    
    // 2 cases for words with even number of letters and odd number of letters
    if (inputLength % 2 > 0)
    {
        for (int i = 0; i < inputLength / 2; i++)
        {
            if (inputS[i] != inputS[inputLength / 2 + i + 1])
            {
                printf("No \n");
                return 0;
            }
        }
    }
    else
    {
        for (int i = 0; i < inputLength / 2; i++)
        {
            if (inputS[i] != inputS[inputLength / 2 + i])
            {
                printf("No \n");
                return 0;
            }
        }
    }

    printf("Yes \n");

    return 0;
}


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

using namespace std;

int main() {
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    int res=0;
    for(int i=0;i<k;i++)
    {
        if(a > 0 )
            {
                res++;
                 a--;
                continue;
               
            }
            else if(b > 0)
            {
                b--;
                continue;
            }
            else if(c > 0)
            {
                res--;;
                c--;
                
            }
    }
    cout<<res<<endl;
}

Measured memory_bytes: 3676
from itertools import combinations
n=int(input())
s=[input()[0] for _ in range(n)]
a=[]
for i in ['M','A','R','C','H']:
  a+=[s.count(i)]
ans=0
for i in combinations(a,3):
  ans+=i[0]*i[1]*i[2]
print(ans)

Measured memory_bytes: 3888
import math
def gcd(a, b, c):
    x = math.gcd(a, b)
    return(math.gcd(x, c))
K = int(input())
sum = 0
for i in range(1, K + 1):
    for j in range(i, K + 1):
        for k in range(j, K + 1):
            if i == j == k:
                sum += gcd(i, j, k)
            elif i == j or j == k or k == i:
                sum += 3 * gcd(i, j, k)
            else:
                sum += 6 * gcd(i, j, k)
print(sum)


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

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

typedef long long ll;
const ll MOD = 1e9 + 7;

int main() {
  std::string S, T;
  std::cin >> S >> T;
  std::cout << T << S << '\n';
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

int main() {
    ll N, M, P;
    cin >> N >> M >> P;
    vector<ll> A(M), B(M), C(M);

    struct Edge {
        Edge(ll f, ll t, ll c) : from(f), to(t), cost(c) {}
        ll from, to, cost;
    };

    vector<Edge> edges;
    vector<vector<ll>> for_edges(N);
    vector<vector<ll>> rev_edges(N);
    for (ll i = 0; i < M; i++) {
        cin >> A[i] >> B[i] >> C[i];
        A[i]--; B[i]--;
        C[i] = -(C[i] - P);

        edges.emplace_back(A[i], B[i], C[i]);
        for_edges[A[i]].push_back(B[i]);
        rev_edges[B[i]].push_back(A[i]);
    }

    //行けるかどうかを先に判定
    vector<bool> can_reach_from_0(N, false);
    {
        stack<ll> st;
        st.push(0);
        while (!st.empty()) {
            auto t = st.top();
            st.pop();
            can_reach_from_0[t] = true;
            for (ll next_node : for_edges[t]) {
                if (can_reach_from_0[next_node]) {
                    continue;
                }
                st.push(next_node);
            }
        }
    }
    vector<bool> can_reach_from_N(N, false);
    {
        stack<ll> st;
        st.push(N - 1);
        while (!st.empty()) {
            auto t = st.top();
            st.pop();
            can_reach_from_N[t] = true;
            for (ll next_node : rev_edges[t]) {
                if (can_reach_from_N[next_node]) {
                    continue;
                }
                st.push(next_node);
            }
        }
    }
    vector<bool> can_be_path(N);
    for (ll i = 0; i < N; i++) {
        can_be_path[i] = (can_reach_from_0[i] && can_reach_from_N[i]);
    }

    constexpr ll INF = INT_MAX;
    vector<ll> cost(N, INF);
    cost[0] = 0;
    bool update = true;
    for (ll i = 0; i < N && update; i++) {
        update = false;
        for (const Edge& e : edges) {
            if (!can_be_path[e.to] || !can_be_path[e.from]) {
                continue;
            }

            if (cost[e.to] > cost[e.from] + e.cost) {
                cost[e.to] = cost[e.from] + e.cost;
                update = true;

                //N回目にも更新があるなら負の閉路が存在する
                if (i == N - 1) {
                    cout << -1 << endl;
                    return 0;
                }
            }
        }
    }

    cout << max((ll)0, -cost[N - 1]) << endl;
}

Measured memory_bytes: 896
//g++ -std=gnu++14 a.cpp
//#include <bits/stdc++.h>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <random>
#include <math.h>

using namespace std;

#define ll long long
#define rep(i, n) for(ll i = 0; i < (n); i++)
ll MOD = 1e9 + 7;
int INF = 1 << 30;
ll INFL = 1LL << 60;

ll atack(ll x){
  if(x == 1){
    return 1;
  }else{
    ll t = atack(x/2);
    return t*2 + 1;
  }
}

int main(){
   ll N;
   cin >> N;
   cout << atack(N) << endl;

}


Measured memory_bytes: 3612