akhauriyash/Code-Regression huggingface dataset:
// I need some holiday
// But I don't wish that everyday is holiday
// Because I didn't bear the pain
// Because it wasn't a true freedom
//         ——『イヤホンと蝉時雨』·Orangestar

#include <bits/stdc++.h>

using namespace std;

typedef long long LL;
typedef long double LD;
typedef unsigned int UI;
typedef pair<int, int> pii;

#define DEBUG(...) fprintf(stderr, __VA_ARGS__)
#define MP make_pair
#define fst first
#define snd second
#define SZ(u) ((int) (u).size())
#define ALL(u) (u).begin(), (u).end()

inline void proc_status()
{
	ifstream t("/proc/self/status");
	cerr << string(istreambuf_iterator<char>(t), istreambuf_iterator<char>()) << endl;
}

template<typename T> inline int chkmin(T &a, const T &b) { return b < a ? a = b, 1 : 0; }
template<typename T> inline int chkmax(T &a, const T &b) { return b > a ? a = b, 1 : 0; }
template<typename T> inline T sqr(const T &val) { return val * val; }

namespace fastIO
{
	const int MAX_BUFFER_SIZE = 1 << 16;

	char buffer[MAX_BUFFER_SIZE], *cur = buffer, *ed = buffer;

	inline char getc() { return cur == ed && (ed = (cur = buffer) + fread(buffer, 1, MAX_BUFFER_SIZE, stdin), cur == ed) ? EOF : *cur++; }
}
using fastIO::getc;

template<typename T> inline T read()
{
	register T sum(0), fg(1);
	register char ch(getc());
	for(; !isdigit(ch); ch = getc()) if(ch == '-') fg = -1;
	for(;  isdigit(ch); ch = getc()) sum = sum * 10 - '0' + ch;
	return sum * fg;
}

inline char *read_str(char *s)
{
	register char ch(getc());
	while(!isgraph(ch)) ch = getc();
	for(; isgraph(ch); ch = getc()) *s++ = ch;
	*s = '\0';
	return s;
}

// END tpl.

const int MAXN = 6, MAXC = 50;

int n, C;

int L[MAXN + 5];

inline void input()
{
	n = read<int>(), C = read<int>();
	for(int i = 0; i < n; ++i) L[i] = read<int>();
}

inline void solve()
{
	sort(L, L + n);

	LD ans = 0;
	LL cnt = 0;
	do {
		const int U = (1 << n) - 1;

		static LL f[MAXC * MAXN + 5][1 << MAXN];
		memset(f, 0, sizeof f);

		f[L[n - 1] * n][1 << (n - 1)] = 1;
		for(int i = 0; i <= n * C; ++i)
			for(int j = i; j <= n * C; ++j) for(int S = 0; S < 1 << n; ++S) if(f[j][S])
			{
				int p = i % n - 1;
				if(p >= 0 && !(S >> p & 1)) f[min(n * C, max(j, i + L[p] * n))][S | 1 << p] += f[j][S];
			}
		++cnt, ans += f[n * C][U];
	} while(next_permutation(L, L + n - 1));

	ans /= cnt;
	for(int i = 1; i < n; ++i) ans /= C;
	printf("%.15Lf\n", ans);
}

int main()
{
#ifdef K_ON
	freopen("F.in", "r", stdin);
	freopen("F.out", "w", stdout);
#endif

	input();
	solve();

	return 0;
}




Measured memory_bytes: 384
#include <iostream>
#include <string>

using namespace std;

int main(){
	int n, k;
	cin >> n >> k;
	k--;
	string str;
	cin >> str;
	string new_str = "";
	for (int i = 0; i < n; i++) {
		if (i == k) new_str += tolower(str[i]);
		else new_str += str[i];
	}
	cout << new_str << endl;
	return 0;
}

Measured memory_bytes: 256
//
//  main.cpp
//  zero
//
//  Created by 叶金炜 on 2019/4/2.
//  Copyright © 2019 okstal. All rights reserved.
//

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string.h>
#include <string>
#define pi acos(-1)
using namespace std;
int main()
{
    char s[1207];
    int a[300];
    memset(a, 0, sizeof(a));
    int i=0;
    while(scanf("%c",&s[i])!=EOF)// \n作为字符串输入的结束符（可以输入带多个空格的字符串
    {
        if(s[i]==' '||s[i]=='\n')continue;
        a[s[i]]++;
        i++;
    }
//        for(int i=0;i<=strlen(s);i++)
//        a[s[i]]++;
    for(int i='a';i<='z';i++)
        printf("%c : %d\n",i,a[i]+a[i-'a'+'A']);
    return 0;
}



Measured memory_bytes: 3208
#include<iostream>
using namespace std;
int main() {
	int n = 0;
	int aa, bb = 0;
	while (cin >> n, n != 0) {
		aa = 0;
		bb = 0;
		int a[10000] = {};
		int b[10000] = {};


		for (int i = 0; i < n; i++) {
			cin >> a[i] >> b[i];
		}
		for (int j = 0; j < n; j++) {
			if (a[j] > b[j]) {
				aa += a[j] + b[j];
			}
			else if (a[j] < b[j]) {
				bb += a[j] + b[j];
			}
			else if (a[j] == b[j]) {
				aa += a[j];
				bb += b[j];
			}
		}
		cout << aa << " " << bb << endl;

	}
	return 0;
}

Measured memory_bytes: 3164
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

void solve() {
  string N;
  cin >> N;
  string a = N;
  reverse(a.begin(), a.end());
  if (a == N) puts("Yes");
  else puts("No");
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}
 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
    int K, A, B;
    cin >> K >> A >> B;
    bool bl = ((A-1) / K != B / K);
    puts(bl ? "OK" : "NG");
    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define endl '\n'
#define mod 1000000007
int main() {
    fio;
    ll n, k;
    cin >> n >> k;
    ll ans = 0;
    while (n--) {
        ll x, y;
        cin >> x >> y;
        double f = sqrt((x * x) + (y * y));
        if (f <= k) {
            ans++;
        }
    }
    cout << ans;
}

Measured memory_bytes: 3696
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

	final static long MOD = 1000000007;
	public static void main(String[] args) throws Exception {
		// TODO 自動生成されたメソッド・スタブ

		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String W = in.readLine();

		String[] Ws = W.split(" ");
		int N = Integer.parseInt(Ws[0]);
		int M = Integer.parseInt(Ws[1]);

		int[][] A = new int[M][2];
		for (int i = 0; i < M; i++) {
			W = in.readLine();
			Ws = W.split(" ");
			A[i][0] = Integer.parseInt(Ws[0]);
			A[i][1] = Integer.parseInt(Ws[1]);
		}

		int[] X = new int[N];
		Arrays.fill(X, -1);
		for(int i=0;i<A.length;i++){
			if((X[A[i][0]-1] == -1 || X[A[i][0]-1] == A[i][1]) ){
				X[A[i][0]-1] = A[i][1];
			}else{
				System.out.println(-1);
				return;
			}
		}

		int ans = 0;
		if(M!= 0 && X[0]==0 && N!=1){
			System.out.println(-1);
			return ;
		}

		for(int i=0;i<X.length;i++){
			if(X[i] == -1){
				X[i]=0;
			}
			ans += Math.pow(10, N-i-1)*X[i];

		}

		if(N>=2 && ans < Math.pow(10, N-1)){
			ans+=Math.pow(10, N-1);
		}

		System.out.println(ans);


	}
}


Measured memory_bytes: 21204
from collections import deque
N,M=map(int,input().split())
to=[[] for _ in range(N)]
for _ in range(M):
  a,b=map(int,input().split())
  to[a-1].append(b-1)
  to[b-1].append(a-1)

q=deque([0])
r=deque([None]*N)
r[0]=0
while q:
  x=q.popleft()
  for i in to[x]:
    if r[i] is None:
      q.append(i)
      r[i]=x+1
      
print('Yes')
r.popleft()
for i in range(N-1):
  print(r.popleft())

Measured memory_bytes: 36752
#include <iostream>
#include <string>
#include <algorithm>
#include <map>

using namespace std;

typedef long long llong;
const llong mod = 1000000000000037LL;
const llong base = 131;

struct modint {
  llong val;

  modint () {
    val = 0;
  }

  modint (llong _val) {
    val = _val % mod;
  }
};

modint operator+ (modint p, modint q) {
  return modint(p.val + q.val);
}

modint operator- (modint p) {
  return modint(mod - p.val);
}

modint operator- (modint p, modint q) {
  return p + (-q);
}

modint operator* (modint p, modint q) {
  return modint(p.val * q.val);
}

bool operator< (modint p, modint q) {
  return p.val < q.val;
}

modint operator== (modint p, modint q) {
  return p.val == q.val;
}

int length;
string str;
modint redhash (int mask) {
  int left = length;
  modint ans (0);
  for (int i = 0; i < length; i++) {
    if (mask & 1 << i) {
      left--;
      ans = ans * modint(base);
      ans = ans + modint(str[i]);
    }
  }
  for (int i = 0; i < left; i++) {
    ans = ans * modint(base);
  }
  return ans;
}

modint bluehash (int mask) {
  modint ans (0);
  for (int i = length - 1; i >= 0; i--) {
    if (!(mask & 1 << i)) {
      ans = ans * modint(base);
      ans = ans + modint(str[i]);
    }
  }
  return ans;
}

int main () {
  cin >> length >> str;

  map<modint, llong> cnt;
  for (int i = 0; i < 1 << length; i++) {
    modint hashd = redhash(i) - bluehash(i);
    if (cnt.count(hashd) == 0) {
      cnt[hashd] = 0;
    }
    cnt[hashd]++;
  }

  reverse(str.begin(), str.end());

  llong ans = 0;
  for (int i = 0; i < 1 << length; i++) {
    modint cur = redhash(i) - bluehash(i);
    if (cnt.count(cur) != 0) {
      ans += cnt[cur];
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 16768
#define _CRT_SECURE_NO_WARNINGS
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define rep(i,n) for(int i=0;i<(lint)(n);i++)
#define REP(i,n) for(int i=1;i<=(lint)(n);i++)
#define all(V) V.begin(),V.end()
#define stackReplaceBegin(size)\
	void* p=malloc(size);\
	esp_new=(lint)p+size-1;\
	void * stack_extend_memory_ = malloc(size);\
	void * stack_extend_origin_memory_;\
	char * stack_extend_dummy_memory_ = (char*)alloca((1+(int)(((long long)stack_extend_memory_)&127))*16);\
	*stack_extend_dummy_memory_ = 0;\
	asm volatile("mov %%rsp, %%rbx\nmov %%rax, %%rsp":"=b"(stack_extend_origin_memory_):"a"((char*)stack_extend_memory_+(size)-1024));
typedef long long lint;
typedef unsigned long long ulint;
typedef std::pair<int, int> P;
constexpr int INF = INT_MAX/2;
constexpr lint LINF = LLONG_MAX/2;
constexpr double eps = DBL_EPSILON;
constexpr double PI = 3.141592653589793238462643383279;
lint esp_new;
template<class T>
class prique :public std::priority_queue<T, std::vector<T>, std::greater<T>> {};
template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
	if (lhs < rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
	if (lhs > rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
inline lint gcd(lint a, lint b) {
	while (b) {
		lint c = a;
		a = b; b = c % b;
	}
	return a;
}
inline lint lcm(lint a, lint b) {
	return a / gcd(a, b) * b;
}
bool isprime(lint n) {
	if (n == 1)return false;
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0)return false;
	}
	return true;
}
template<typename T>
T mypow(T a, unsigned int b) {
	T res(1),now(a);
	while(b){
		if(b&1)res*=now;
		b>>=1;
		now*=now;
	}
	return res;
}
template<typename T>
void printArray(std::vector<T>& vec) {
	rep(i, (int)vec.size() - 1)std::cout << vec[i] << " ";
	if(!vec.empty())std::cout << vec.back() << std::endl;
}
template<typename T>
void printArray(T l, T r) {
	T rprev = r;
	rprev--;
	for (T i = l; i != rprev; i++) {
		std::cout << *i << " ";
	}
	std::cout << *rprev << std::endl;
}
int n;
int main(){
	std::cin>>n;
	int bt=0,bx=0,by=0;
	rep(i,n){
		int t,x,y;
		std::cin>>t>>x>>y;
		int d=std::abs(x-bx)+std::abs(y-by);
		if(t-bt<d||(t-bt-d)%2==1){
			puts("No");
			return 0;
		}
		bt=t;bx=x;by=y;
	}
	puts("Yes");
	return 0;
}


Measured memory_bytes: 3632
using System;
// using System.Collections.Generic;
// using System.Linq;
// using System.Text;

class Program
{
    static void Main()
    {
        string[] arr = Console.ReadLine().Split();
        int N;
        N = int.Parse(arr[0]);
        Console.WriteLine(Math.Floor((decimal)(N + 1) / 2) / N);
        return;
    }
}

Measured memory_bytes: 27552
#include<iostream>
#include<sstream>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>

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();}

vector<int> prime;

bool make()
{
  bool tmp[102000];
  memset(tmp,true,sizeof(tmp));
  for(int i=2;i<102000;i++)
    {
      if(tmp[i])
	{
	  prime.push_back(i);
	  for(int j=i+i;j<102000;j+=i)
	    tmp[j]=false;
	}
    }
}

int main()
{
  int n,p;
  make();
  for(;cin>>n>>p,n!=-1;)
    {
      vector<int > data;
      data.clear();
      int i;
      int size=prime.size();
      //      cout<<size<<endl;
      for(i=0;i<size;i++)
	{
	  //	  cout<<prime[i]<<" "<<n<<endl;
	  if(prime[i]>n)
	    {	    
	      break;
	    }
	}

      for(int j=i;j<i+100;j++)
	for(int k=j;k<i+100;k++)
	  {
	    data.push_back(prime[j]+prime[k]);
	  }
      sort(data.begin(),data.end());
      cout<<data[p-1]<<endl;
    }
  
}

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

// 隣接リストを用いた幅優先探索 O(|V|+|E|)
bool bfs(const vector<vector<int>> &G, int s, int g, vector<int> &ans2) {
  vector<int> d(G.size(), 1e9), from(G.size(), -1); // d[i]:始点sから頂点iまでの最短距離
  queue<int> q;
  q.push(s);
  d[s] = 0;
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (int i = 0; i < G[u].size(); i++) {
      if (u == g && G[u][i] == s) continue;
      if (d[G[u][i]] == 1e9) {
        d[G[u][i]] = d[u] + 1;
        from[G[u][i]] = u;
        q.push(G[u][i]);
      }
    }
  }
  
  if (d[g] == 1e9) return false;
  
  int now = g;
  ans2.emplace_back(now);
  while (now != s) {
    now = from[now];
    ans2.emplace_back(now);
  }
  
  return true;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  // 無向(有向)グラフの隣接リスト
  int n, m; // n:頂点数 m:辺数
  cin >> n >> m;
  
  vector<vector<int>> G(n); // G:頂点数nのグラフの隣接リスト
  
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    u--;
    v--;
    G[u].emplace_back(v);
    //G[v].emplace_back(u); // 有向グラフではコメントアウト
  }
  
  vector<int> ans;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < G[i].size(); j++) {
      vector<int> ans2;
      if (!bfs(G, G[i][j], i, ans2)) continue;
      if (ans.size() == 0 || ans.size() > ans2.size()) ans = ans2;
    }
  }
  
  if (ans.size() == 0) {
    cout << -1 << '\n';
  }
  else {
    cout << ans.size() << '\n';
    for (int i = 0; i < ans.size(); i++) cout << ans.at(i) + 1 << '\n';
  }
}

Measured memory_bytes: 3708
N, Y = map(int, input().split())
res_x = -1
res_y = -1
res_z = -1
for x in range(N+1):
  for y in range(N-x+1):
    z = N - x - y
    if 10000 * x + 5000 * y + 1000 * z == Y:
      res_x = x
      res_y = y
      res_z = z
print('{} {} {}'.format(res_x, res_y, res_z))


Measured memory_bytes: 9176
#include<bits/stdc++.h>
using namespace std;
int N;
int A[100100];
map<int,int> M;
int ans;
int main()
{
	cin>>N;
	for(int i=0;i<N;i++)
		cin>>A[i],
		M[A[i]]++;
	for(int i=0;i<N;i++)
		if(M[A[i]]>=A[i])
			ans+=M[A[i]]-A[i],
			M[A[i]]=A[i];
		else
			ans+=M[A[i]],
			M[A[i]]=0;
	cout<<ans<<endl;
	return 0;
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP0(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define RREP0(i,n) for(int i=n-1; i>=0; --i)
#define RREP1(i,n) for(int i=n; i>=1; --i)
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define FILL(c, v) fill((c).begin(),(c).end(), v)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define CLR(a) memset((a), 0 ,sizeof(a))

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 long long LL;
typedef unsigned long long ULL;

const int INTINF = 1e9;
const LL LLINF = 1e18;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

void solve()
{
    int N; cin >> N;
    int ans = 0;
    REP0(i, N)
    {
        int A; cin >> A;
        ans = gcd(ans, A);
    }
    cout << ans << endl;
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(10);
    solve();
    return 0;
}

Measured memory_bytes: 256
//Code by : Abhishek Tiwari
//codechef.com/users/devil_within || hackerearth.com/@devil_within
#include<bits/stdc++.h>
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long int
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define repr(i,a,b) for(int i=(a);i>(b);--i)
#define mp make_pair
#define pb push_back
#define pf push_front
#define pii pair<int,int> 
#define ff first
#define ss second 
#define mod 1000000007
#define inf 1000000000
#define gcd __gcd
#define lcm(a,b) ((a)*(b))/gcd(a,b)
using namespace std;

/*******************************************************************************************/
/*******************************************************************************************/
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v) { 
    os<<"["; for(int i=0;i<v.size()-1; ++i)os<<v[i]<<", ";os<<v[v.size()-1]<<"]\n"; return os; 
} 
template <typename T> ostream& operator<<(ostream& os, const set<T>& v) { 
    os<<"{"; for(auto it : v) { os<<it; if(it!=*v.rbegin()) os<<", "; } os<<"}\n"; 
    return os; 
}
template <typename T, typename S> ostream& operator<<(ostream& os, const map<T, S>& v) { 
    os<<"{"; for(auto it:v){ os<<"("<<it.first<<" : "<<it.second<<")"; if(it!=*v.rbegin()) os<<", "; } os<<"}\n"; 
    return os; 
}
template <typename T, typename S> ostream& operator<<(ostream& os, const pair<T, S>& v) { 
    os<<"("; os<<v.first<<", "<< v.second<<")"; 
    return os; 
} 
template<typename T> T maxi(T a,T b){return a>b ? a:b;}
template<typename T> T mini(T a,T b){return a<b ? a:b;}
/*******************************************************************************************/
/*******************************************************************************************/
int fpow(int x, int y, int p); 
int solve(int i , int j , vector<int> &a , int sum , vector<vector<int>> &dp)
{
    if(dp[i][j]!=-1)
        return dp[i][j];
    if(i==j)
    {
        dp[i][i] = a[i];
        return dp[i][i];
    }
    
    int v1 = sum - solve( i +1 , j , a , sum - a[i] , dp);
    int v2 = sum - solve( i , j-1 , a , sum - a[j] , dp);
    dp[i][j] = max( v1 , v2);
    return dp[i][j];
}

int32_t main()  
{
#ifndef ONLINE_JUDGE
//freopen("input.txt" , "r" , stdin);freopen("output.txt" , "w" , stdout);freopen("error.txt" , "w" , stderr);
#endif
fio;
int tcases = 1;
//cin>>tcases;
for(int tcase = 1 ; tcase <= tcases ; ++tcase)
{
    int n;
    cin>>n;
    vector<int>a(n);
    rep( i, 0, n) cin>>a[i];
    vector<vector<int>> dp(n);
    rep(i , 0 , n) dp[i].resize(n , -1);
    int sum = 0;
    for(auto i : a)
        sum+=i;
    int f = solve(0 , n-1 , a , sum , dp);
    int s = sum - f;
    cout<< f - s <<"\n";
    //cout<<"Case #"<<tcase<<": ";
}
return 0;
}



//Functions 

int fpow(int x, int y, int p) { 
    int res = 1; 
   x = x % p;  
   while (y > 0) { 
     if (y & 1) 
        res = (res * x) % p; 
     y = y >> 1; 
        x = (x * x) % p; 
    } 
    return res; 
} 


Measured memory_bytes: 70912
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
const int INF=1001001001;
int main(){
  int n,m;
  cin>>n>>m;
  vector<pair<int,int>>key;
  rep(i,m){
    int a,b;
    cin>>a>>b;
    int s=0;
    rep(j,b){
      int c;
      cin>>c;
      --c;
      s|=1<<c;
    }
    key.emplace_back(s,a);
  }
  
  vector<int> dp(1<<n,INF);
  dp[0]=0;
  rep(j,1<<n){
    rep(i,m){
      int t=j | key[i].first;
      int cost = dp[j]+key[i].second;
      dp[t]=min(dp[t],cost);
    }
  }
  int ans=dp.back();
  if (ans==INF) ans=-1;  
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main()
{
    int i,n,x[1001],y=0;
    double a=0,alpha,m;

    for(i=0;; i++)
    {
    scanf("%d",&n);
        if(n!=0)
        {
            a=0;y=0;
            for(i=0; i<n; i++)
            {
                scanf("%d",&x[i]);
                y=y+x[i];
            }
            m=(double)y/n;
    //printf("%.8lf\n",m);
    for(i=0;i<n;i++)
        a=a+((x[i]-m)*(x[i]-m));
    alpha=sqrt(a/n);
    printf("%.8lf\n",alpha);
    continue;
        }
        else if(n==0)
            break;
    }
    return 0;

}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(v) v.begin(), v.end()

int main(){
    int n;
    cin >> n;
    map <int, int> a;
    for(int i=0; i<n; i++){
        int di;
        cin >> di;
        a[di] = i;
    }

    for(int i=1; i<=n; i++){
        if(i == n) cout << a[n] + 1;
        else cout << a[i] + 1 << " ";
    }
}


Measured memory_bytes: 5504
#!/usr/bin/env python3
import sys
from collections.abc import Iterable
from math import *
from itertools import *
from collections import *
from functools import *
from operator import *
try:
    from math import gcd
except Exception:
    from fractions import gcd


def solve(N: int, L: int):
    ls = [L + i - 1 for i in range(1, N + 1)]
    return sum(ls) - ls[min([(abs(l), i) for i, l in enumerate(ls)])[1]]




def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    L = int(next(tokens))  # type: int
    result = solve(N, L)
    if isinstance(result, Iterable) and not isinstance(result, str):
        result = '\n'.join([str(v) for v in result])
    print(result)

if __name__ == '__main__':
    main()


Measured memory_bytes: 5228
#include<stdio.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
 
 
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//pair sort
bool compare_by_b(pair<LL, LL> a, pair<LL, LL> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}


void solve(long long N, long long A, long long B){
    LL d = N/(A+B);
    LL ans=d*A;

    N-=d*(A+B);
    ans+=min(A, N);
    cout<<ans<<endl;

}

int main(){
    long long N;
    scanf("%lld",&N);
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(N, A, B);
    return 0;
}


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

using namespace std;

int main(){

  long long A, B, C;
  long long  K;
  cin >> A >> B >> C >> K;

  if( K <= A){
    cout << K << endl;
  }
  else if( K <= A + B){
    cout << A << endl;
  }
  else{
    cout << A - (K - (A + B)) << endl;
  }

  return 0;
  

}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(i, n) for(int i=0; i<=n; i++)
#define repr(i, n) for(int i=n; i>0; i--)
#define REPR(i, n) for(int i=n; i>=0; i--)
const ll INF = 1e18;
const int INT_INF = 1e9;
const ll MOD = 1e9+7;
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; }
using namespace std;

int A, B;

int main() {
    cin >> A >> B;
    int tmp = max(A+B, A-B);
    cout << max(tmp, A*B) << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<queue>
#include<utility>
#include<cstring>
#include<stack>
#include<algorithm>
#include<cmath>
#include<iostream>
#define MAX_N 100001
#define INF 2147483647
#define REP(i,n) for(int i=0;i<(int)(n);i++)
void init(int n);
int find(int n);
void unite(int x,int y);
bool same(int x, int y);
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
using namespace std;
int main()
{
  int price = 700;
  char S[10];
  cin >> S;
  REP(i,3)
    if(S[i] == 'o')
      price += 100;
  cout << price << endl;
  return 0;
}

int par[MAX_N];
int ranks[MAX_N];

//n要素で初期化
void init(int n){
  REP(i,n){
    par[i] = i;
    ranks[i] = 0;
  }

}

//木の根を求める
int find(int x){
  if(par[x] == x){
    return x;
  }else{
    return par[x] = find(par[x]);
  }
}

void unite(int x,int y){
  x = find(x);
  y = find(y);
  if(x == y) return ;
  if(ranks[x] < ranks[y]){
    par[x] = y;
  }else{
    par[y] = x;
    if(ranks[x] == ranks[y]) ranks[x]++;
  }
}

bool same(int x, int y){
  return find(x) == find(y);
}



Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	if(a<=b&&b<=c) printf("%d\n",a+b);
	else if(a<=c&&c<=b) printf("%d\n",a+c);
	else if(b<=a&&a<=c) printf("%d\n",b+a);
	else if(b<=c&&c<=a) printf("%d\n",b+c);
	else if(c<=a&&a<=b) printf("%d\n",c+a);
	else if(c<=b&&b<=a) printf("%d\n",c+b);
	else printf("%d\n",a+b);
	return 0;
}

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

using namespace std;

int main() {
    vector<vector<int>> v(3, vector<int>(3));
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            cin >> v[i][j];
        }
    }

    bool ret = true;
    for (int i = 0; i < 2; i++) {
        for (int j = 0; j < 2; j++) {
            if (v[i][j] - v[i][j + 1] != v[i + 1][j] - v[i + 1][j + 1])ret = false;
            if (v[j][i] - v[j][i + 1] != v[j + 1][i] - v[j + 1][i + 1])ret = false;
        }
    }

    cout << (ret ? "Yes" : "No") << endl;
    return 0;
}

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

#define ll long long //data types used often, but you don't want to type them time by time
#define ull unsigned long long
#define ui unsigned int
#define mod 998244353
#define inf 100000000000010
#define us unsigned short
#define IOS ios_base::sync_with_stdio(0); //to synchronize the input of cin and scanf
#define INF LONG_MAX
#define PI 3.1415926535897932384626
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define rep(x,j,n)for(int x=j;x<n;x++)
#define all(x) (x).begin(), (x).end()

typedef vector<pair<ll,ll>> vpi;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll,ll> pi;

bool prime(ll n)
{
    if(n<=1)return false;
    if(n<=3)return true;
    if(n%2==0||n%3==0)return false;
    for(ll i=5;i*i<=n;i+=6)
    {
        if(n%i==0||n%(i+2)==0)return false;
    }
    return true;
}

ll modexp(ll a,ll b,ll m)
{
    ll r=1;
    a=a%m;
    while(b>0)
    {
        if(b&1)r=(r*a)%m;
        b = b>>1;
        a=(a*a)%m;
    }
    return r%m;
}

struct CustomCompare
{
    bool operator()(const int& lhs, const int& rhs)
    {
        return lhs < rhs;
    }
};

bool comp(pair<ll, pi>a,pair<ll,pi>b)
{
    if(a.se.fi==b.se.fi)return a.se.se>b.se.se;
    return a.se.fi>b.se.fi;
}

ll builtin_popcount(ll x)
{
    ll cnt = 0;
    for(ll i=60;i>=0;i--)
    {
        if((1LL<<i)&x)cnt++;
    }
    return cnt;
}


int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
ll p,q; cin>>p>>q;
ll y = (q - 2*p)/2;
ll x = p -y;
if(x<0||y<0||(x+y!=p)||(2*x+4*y!=q))cout<<"No\n";
else cout<<"Yes\n";
return 0;
}
/*
50 25
39 99 70 24 49 13 86 43 88 74 45 92 72 71 90 32 19 76 84 46 63 15 87 1 39 58 17 65 99 43 83 29 64 67 100 14 17 100 81 26 45 40 95 94 86 2 89 57 52 91 45
1221 360 459 651 958 584 345 181 536 116 1310 403 669 1044 1281 711 222 280 1255 257 811 409 698 74 838
*/


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
 
#define FAST ios_base::sync_with_stdio(0); cin.tie(); cout.tie();
 
#define MAXX 500005
#define PI 3.14159265358979323846264338327950
 
#define ll    long long int
#define mod  1000000007
ll t ,  ans, poi ; ll a[MAXX], b[MAXX], ans1;
ll divis(ll n){
	poi = 0;
	poi = (n*(n+1)) / 2;
	return (n*(n+1))/2;
}
int main()
{
	FAST;
	ll n;
	cin >> n;
	for(ll i = 1; i <= n; i++){
		ans += i * divis(n/i);
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 3656
#include<iostream>
#include <stdio.h>
#include<string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <cstdint>
#include <map>
#define MOD 1000000007
using namespace std;
typedef long long ll;
 
int main(){
 
  int n;
  cin >> n;
  
  map <int,int>num;
  
  for(int i = 0; i<n; i++){
    int N;
    cin >> N;
    num[N]++;
  }
  
  int ans = 0;
  for(auto i : num){
    if(i.second >= 2)
      ans += i.second - 1;
  }
    
  if(ans % 2 == 1) ans++;
  
  cout << n - ans << endl;
  
return 0;
}


Measured memory_bytes: 4992
#include<iostream>
#include<algorithm>
#include<functional>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<tuple>
#include<stack>
#include<queue>
#include<deque>
#include<sstream>
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<bitset>
#include<time.h>
#include<cstdlib>
#include<cassert>
#define ll long long
#define fi first
#define se second
using namespace std;

int n,m;
string s;
bool a[100];
                  
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(10);
  cout<<fixed;
#ifdef LOCAL_DEFINE
    freopen("in", "r", stdin); 
    freopen("out","w",stdout);
#endif
  cin>>s;
  n=(int)s.length();
  int cont=0;
  for(int i=0;i<n;i++){
    if(a[s[i]-'a']){
      continue;
    }else{
      a[s[i]-'a']=1;
      cont++;
    }
  }
  if(cont==2){
    cout<<"Second"<<"\n";
  }else{
    if(s[0]==s[n-1]){
      cout<<((n-3)&1?"First":"Second")<<"\n";
    }else{
      cout<<((n-2)&1?"First":"Second")<<"\n";
    }
  }
#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
  return 0;
}

Measured memory_bytes: 512
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
using namespace std;
typedef long long ll;
const double PI = acos(-1.0);

int main()
{
    int a, n, m = -1, m2 = -1, midx = -1;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a;
        if (max(m, a) == a) {
            midx = i;
            m2 = m;
            m = a;
        }
        else if (max(m2, a) == a) {
            m2 = a;
        }
    }

    for (int i = 0; i < n; i++) {
        if (i == midx) {
            if (m2 == -1) {
                cout << m << endl;
            }
            else {
                cout << m2 << endl;
            }
        }
        else {
            cout << m << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 1664
#include <iostream>
using namespace std;
int main()
{
	int A, B;
	string S, T, U;
	cin >> S >> T;
	"\n";
	cin >> A >> B;
	"\n";
	cin >> U;
	if (U == S) {
		A--;

	}
	else {
		B--;
	}
	cout << A << " " << B << endl;
	return 0;
}


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

typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define dump(x)  cout << #x << " = " << (x) << endl;	//debug
#define SZ(x) ((int)(x).size())
#define REP(i, n) for(ll i = 0; i < (n); i++)
#define REPR(i, n) for (ll i = (n); i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define ps(s) cout << #s << endl;
#define pv(v) cout << (v) << endl;
#define ALL(a)  (a).begin(),(a).end()
#define RANGE(a, l, r)  (a).begin()+(l),(a).begin()+(r)


int main() {
	int n;
	string s;
	vector<int> r, g, b;
	cin >> n >> s;
	FOR(i, 1, n) {
		if (s[i - 1] == 'R') r.push_back(i);
		if (s[i - 1] == 'G') g.push_back(i);
		if (s[i - 1] == 'B') b.push_back(i);
	}
	int rsize = r.size();
	int gsize = g.size();
	ll damecnt = 0;
	int num1, num2;
	FOR(i, 0, rsize - 1) {
		FOR(j, 0, gsize - 1) {
			num1 = min(r[i], g[j]);
			num2 = max(r[i], g[j]);
			auto itr1 = find(ALL(b), 2 * num2 - num1);
			auto itr2 = find(ALL(b), 2 * num1 - num2);
			if (itr1 != b.end()) damecnt++;
			if (itr2 != b.end()) damecnt++;
			if ((num2 - num1) % 2 == 0) {
				auto itr3 = find(ALL(b), (num1 + num2) / 2);
				if (itr3 != b.end()) damecnt++;
			}
		}
	}
	ll res = r.size()*g.size()*b.size() - damecnt;
	pv(res)
	return 0;
}

Measured memory_bytes: 3672
#include<stdio.h>
#include<algorithm>
#include<string.h>
using namespace std;
char str[210000];
int main(){
	scanf("%s",str);
	int n=strlen(str);
	for(int i=0;i<n-1;i++)if(str[i]==str[i+1]){
		printf("%d %d\n",i+1,i+2);return 0;
	}
	for(int i=0;i<n-2;i++)if(str[i]==str[i+2]){
		printf("%d %d\n",i+1,i+3);return 0;
	}
	printf("-1 -1\n");
}

Measured memory_bytes: 256
n = gets.chomp.to_i
s = gets.chomp.split('') 

alpha = [*('A'..'Z')]
l = alpha.length
s.each do |t|
    next_i = alpha.index(t) + n
    if next_i >= 26
        print alpha[next_i - 26]
    else
        print alpha[next_i]
    end
end


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

int main(){
  int N, m;
  cin >> N;
  
  int AS = 0;
  int BS = 0;
  m = 100000;
  
  for(int i = 1; i < (N/2)+1; i++){
    int k = N - i;
    int l = i;
    for(int j = 0; j < 5; j++){
      AS += l%10;
      l = l/10;
    }
    for(int j = 0; j < 5; j++){
      BS += k%10;
      k = k/10;
    }
    if(m > AS + BS){
      m = AS + BS;
    }
    AS = 0; BS = 0;
  }
  cout << m << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int main()
{
	char s[5];
	int i;
	while(scanf("%s",s)!=EOF)
	{
		int count = 0;
		for(i = 0 ; i <= 2; i++)
		{
			if(s[i] == '1')
			{
				count++;
			}
		}
		printf("%d\n",count);
	}
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <string>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <tuple>
#include <numeric>
#include <functional>

using namespace std;

/*-----------------------------------------------------------------------------
　定義
 -----------------------------------------------------------------------*/
#define ALL(a)				(a).begin(),(a).end()
#define REP(i, n)			for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n)		for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define INF					(1000 * 1000 * 1000 * 2)
#define MOD					(1000 * 1000 * 1000 + 7)
#define Ceil(x, n)			(((((x))+((n)-1))/n))	/* Nの倍数に切り上げ割り算 */
#define CeilN(x, n)			(((((x))+((n)-1))/n)*n)	/* Nの倍数に切り上げ */
#define FloorN(x, n)		((x)-(x)%(n))			/* Nの倍数に切り下げ */
#define IsOdd(x)			(((x)&0x01UL) == 0x01UL)			
#define IsEven(x)			(!IsOdd((x)))						
#define	BitSetV(Val,Bit)	((Val) |= (Bit))			
#define	BitTstV(Val,Bit)	((Val) & (Bit))				
#define M_PI				3.14159265358979323846
typedef long long			ll;
typedef pair<ll, ll>		P;

/*-----------------------------------------------------------------------------
　処理
 -----------------------------------------------------------------------------*/
// メイン
int main()
{
	ll A, B, K;
	cin >> A >> B >> K;
	ll cnt = min(A, K);
	A -= cnt;
	K -= cnt;
	cnt = min(B, K);
	B -= cnt;
	cout << A << " " << B << endl;
	return 0;
}



Measured memory_bytes: 256
#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;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;



llong GCD(llong A[],int n){
    llong a,b,c;
    a=A[0];
    b=A[1];
    int i=1;
    while(1){
        if(a == 0 or b==0) return 0;
        if(a<b) swap(a,b);
        while(1){
            if(a%b==0) break;
            c=b;
            b= a%b;
            a=c;
        }
        i+=1;
        if(i==n) break;
        a=A[i];
    }
    return b;
}


int main(){
    int t;
    cin >> t;
    llong a,b,c,d;
    REP(i,t){
        cin >> a >> b >> c >> d;
        if(a < b){
            cout << "No" << endl;
            continue;
        }
        if(b >d){
            cout << "No" << endl;
            continue;
        }
        if(b<=c){
            cout << "Yes" << endl;
            continue;
        }
        llong init = a - b*(a/b);
        init += b* ((c-1-init)/b);
        if(init >c){
            cout << "No" << endl;
            continue;
        }




        llong dx = d%b;
        llong A[2];
        A[0] = dx;
        A[1] = b;
        llong gcd =GCD(A,2);
        if(gcd == 0){
            cout << "Yes" << endl;
            continue;
        }

        if( (b - init)%gcd!=0 ){
            if( ((b-init) /gcd) *gcd >=c+1-init ){
                cout << "No" << endl;
                continue;
            }
            else{
                cout << "Yes" << endl;
            }
        }
        else{
            if( ((b-init) /gcd-1) *gcd >=c+1-init ){
                cout << "No" << endl;
                continue;
            }
            else{
                cout << "Yes" << endl;
            }
        }

    }
}

Measured memory_bytes: 256
// -*- coding:utf-8-unix -*-

use proconio::input;

fn p (n: i64, d: i64) -> i64 {
    let mut ans = 1;
    for i in 2..n + 1 {
        ans = (ans * i) % d;
    }
    ans
}

fn main() {
    input! {
        n: i64,
        m: i64,
    }

    if (n - m).abs() > 1 {
        println!("0");
        return;
    }

    let divisor = 10_i64.pow(9) + 7;
    if n == m {
        let pn = p(n, divisor);
        println!("{}", (((pn * pn) % divisor) * 2) % divisor);
    } else {
        let pn = p(n.min(m), divisor);
        println!("{}", (pn * ((pn * n.max(m)) % divisor)) % divisor);
    }
}


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


int main() {
    int n,m=0;
    cin>>n;
    int a[n],b[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        m^=a[i];
    }
    for(int i=0;i<n;i++)
    {
        b[i]=m^a[i];
    }
    for(int i=0;i<n;i++)
    cout<<b[i]<<" ";
    
	return 0;
}


Measured memory_bytes: 5124
# import bisect
# from collections import Counter, defaultdict, deque
# import copy
# from heapq import heappush, heappop, heapify
# from fractions import gcd
# import itertools
# from operator import attrgetter, itemgetter
# import math

import sys

# import numpy as np

ipti = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)

def main():
    x, y = list(map(int,ipti().split()))
    prize = [300000, 200000, 100000, 0]

    if x == y == 1:
        print(1000000)
    else:
        x = 4 if x > 3 else x
        y = 4 if y > 3 else y
        print(prize[x-1]+prize[y-1])

if __name__ == '__main__':
    main()

Measured memory_bytes: 38256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
 
int main(){
  bool c=true;
  string s;
  cin >> s;
  
  rep(i,s.size()){
    if(i % 2==0){
      if(s[i]=='L') 
        c=false;
    }else{
      if(s[i]=='R') 
        c=false;
    }
  }
  
  if(c==true) 
    cout << "Yes" << endl;
  else 
    cout << "No" << endl;
}

Measured memory_bytes: 256
/*######################################################
#########~~~~~####~~~~###~~##~~##~~##~~##~~##~~#########
#########~~##~~##~~##~~##~~~#~~##~~~#~~##~~##~~#########
#~~~~~~##~~~~~###~~~~~~##~~#~~~##~~#~~~##~~##~~##~~~~~~#
#########~~######~~##~~##~~##~~##~~##~~##~~##~~#########
#########~~######~~##~~##~~##~~##~~##~~###~~~~##########
######################################################*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
using namespace std;

#pragma GCC optimize("O3")
#define rtn return
#define endl '\n'
#define F first
#define S second
#define mt make_tuple
#define pb push_back
#define int long long
#define sz(x) (int) x.size()
#define value_at find_by_order
#define index_of order_of_key
#define fill(a, v) memset(a,v,sizeof(a))
#define copy(a, b) memcpy(b,a,sizeof(a))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rep(i, n) for(int i=0;i<(int)n;++i)
#define per(i, n) for(int i=(int)n-1;i>=0;--i)
#define rep1(i, n) for(int i=1;i<=(int)n;++i)
#define per1(i, n) for(int i=(int)n;i>=1;--i)
#define loop(i, begin, end) for(int i=(begin)-((begin)>(end));i!=(end)-((begin)>(end));i+=1-2*((begin)>(end)))
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr)

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " = " << arg1 << '\n';
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " = " << arg1 << " |";
  __f(comma + 1, args...);
}
#else
#define trace(...)
#endif

typedef string str;
typedef long double db;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef vector<str> vstr;
typedef vector<db> vdb;

template<class T, class V> void remin(T &a, V b) { a > b ? a = b : a = a; }
template<class T, class V> void remax(T &a, V b) { a < b ? a = b : a = a; }
template<class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());


const int INF = 1e18;
const db EPS = 1e-15;
const int MOD = 1e9 + 7;
const int N = 1e5 + 7;

//

int32_t main() {
  FAST_IO;
  int n;
  cin >> n;
  set<str> s;
  rep(i, n) {
    str ss;
    cin >> ss;
    s.insert(ss);
  }
  cout << s.size() << '\n';
  rtn 0;
}


Measured memory_bytes: 19224
#include <bits/stdc++.h>
#define REP(i, start, end) for (int64_t i=start, i##Len=(end); i < i##Len; ++i)
#define REPR(i, start, end) for (int64_t i=start, i##Len=(end); i > i##Len; --i)
using ll = int64_t;
using namespace std;


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    string S;
    cin >> S;
    ll N = S.size(), inf = 1ll << 60;
    vector<vector<ll>> dp(N+1, vector<ll>(2, inf));
    dp[0][0] = 0;

    REP(i, 0, N) {
        ll d = S[N-1-i] - '0';
        dp[i+1][0] = min({
            dp[i][0] + d,
            dp[i][1] + d + 1
        });
        dp[i+1][1] = min({
            dp[i][0] + (10 - d),
            dp[i][1] + (9 - d)
        });
    }

    cout << min(dp[N][0], dp[N][1] + 1) << endl;

}


Measured memory_bytes: 55964
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(void) {
  int A, B;
  scanf("%d%d", &A, &B);
  int add = A+B, sub = A-B, mul = A*B;
  if (add < sub) {
    if (sub < mul) printf("%d\n", mul);
    else printf("%d\n", sub);
  } else {
    if (add < mul) printf("%d\n", mul);
    else printf("%d\n", add);
  }

  return 0;
}

Measured memory_bytes: 128
from itertools import accumulate

N, Q = list(map(int, input().split()))
S = input()
A = [list(map(int, input().split())) for i in range(Q)]

tmp = []
for i in range(N-1):
    tmp_S  = S[i:i+2]
    if tmp_S == 'AC':
        tmp.append(1)
    else:
        tmp.append(0)

tmp2 = [0] + tmp
tmp2 = list(accumulate(tmp2))
#print(tmp2)

for j in A:
    print(tmp2[j[1]-1] - tmp2[j[0]-1])

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

int main(){
  int A,B,wa,sa,seki,saidai;
  cin >> A >> B;
  wa=A+B;sa=A-B;seki=A*B;
  saidai=max(wa,max(sa,seki));
  cout << saidai << endl;
}

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

//type
#define ll long long
typedef pair<int, int> P;
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007    //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first      //pairの一つ目の要素
#define S second     //pairの二つ目の要素
#define Z class
// OTHER
// xの二乗を返す (関数テンプレート版)
template <typename T>
T square(T x) { return x * x; }
#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))
// loop
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= ll(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= ll(b); i--)
#define FORA(i, I) for (const auto &i : I)

// vector
#define ALL(x) x.begin(), x.end()

// output
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n", (x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define ln cout << '\n'
template <Z A>
void pr(A a)
{
  cout << a;
  ln;
}
template <Z A, Z B>
void pr(A a, B b)
{
  cout << a << ' ';
}

int ans = 0;
bool check = 0;
int N = 0;
vector<int> v(N);
int a, b;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

int main()
{
  cin >> a >> b;
  if (a%3==0||b%3==0||(a + b) % 3 == 0)
    pr("Possible");
  else
    pr("Impossible");

  return 0;
}

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

int main()
{
    int n;
    cin >> n;
    int current = 0;
    int diff = 0;
    for(int i = 0; i < n; ++i)
    {
        if(diff < -1)
        {
            continue;
        }
        int t;
        cin >> t;
        diff += (t - current);
        diff = min(diff, 0);
        current = t;
    }
    string result = "Yes";
    if(diff < -1)
    {
        result = "No";
    }
    cout << result << endl;
}

Measured memory_bytes: 256
from collections import deque
from collections import defaultdict

# 木構造を作る
N, M  = map(int, input().split())

G = [[] for i in range(N)]
for i in range(M):
    # グラフに頂点を追加(距離があるときは,u,vの後に入れる)
    u,v = map(int,input().split())
    G[u-1].append((v-1))

cnt_in = defaultdict(int)
outs = defaultdict(list)
for vs in G:
    for v in vs:
        cnt_in[v] += 1
# print(cnt_in)
res = []
q = deque([i for i in range(N) if cnt_in[i]==0])
dp = [0]*(N+1)
# トポロジカルソートで、入次数を削っていくときに
# 入次数がゼロになったときに追加する
while len(q) > 0:
    v = q.popleft()
    res.append(v)
    for next_v in G[v]:
        cnt_in[next_v] -= 1
        if cnt_in[next_v] == 0:
            q.append(next_v)
            dp[next_v] = max(dp[next_v], dp[v] + 1)

print(max(dp))




Measured memory_bytes: 29156