akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;

public class D
{
	public static void Main() => (new Solver()).Solve();
}

public class Solver
{
	public void Solve()
	{
		long H = GetLong();
		WriteLine(rec(H));
	}

	private long rec(long X)
	{
		if(X == 1)
			return 1;

		return 2 * rec(X / 2) + 1;
	}
}

public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static decimal GetDecimal() => decimal.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(long N) => Enumerable.Range(0, (int)N).Select(_ => GetInt()).ToArray();
	public static long[] GetLongs(long N) => Enumerable.Range(0, (int)N).Select(_ => GetLong()).ToArray();
	public static double[] GetDoubles(long N) => Enumerable.Range(0, (int)N).Select(_ => GetDouble()).ToArray();
	public static decimal[] GetDecimals(long N) => Enumerable.Range(0, (int)N).Select(_ => GetDecimal()).ToArray();
	public static string[] GetStrings(long N) => Enumerable.Range(0, (int)N).Select(_ => GetString()).ToArray();
}

public static class MyUtil
{
	public static void chmax<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) < 0)
			x = y;
	}

	public static void chmin<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) > 0)
			x = y;
	}

	public static void swap<T>(ref T x, ref T y)
	{
		T tmp = x;
		x = y;
		y = tmp;
	}
}

Measured memory_bytes: 11092
N,K=map(int,raw_input().split())
D=map(int,raw_input().split())
n=[0,1,2,3,4,5,6,7,8,9]

a=[]	#Allowed numbers
for i in n:
	if i not in D:
		a.append(i)


i=N
while True:
	for j in D:
		if str(i).find(str(j))!=-1:
			break
	else:
		print str(i)
		break
	i+=1

Measured memory_bytes: 2568
N = int(input()); INF = float("inf")
Z = []
S = set([])
for i in range(N):
  x,y,h = map(int,input().split())
  Z.append((x,y,h))
  S.add((x,y))
Z.sort(key=lambda x : x[2],reverse=True)
#print(Z)
for i in range(101):
  for j in range(101):
    #Flag = True #0以外があればFalse
    MAX = INF
    for t in range(N):
      #print(Z[t][2])
      if t == 0: #最初は必ず0以外。
        ans = abs(i-Z[t][0])+abs(j-Z[t][1])+Z[t][2]
      elif Z[t][2] == 0:
        MAX = min(MAX,abs(i-Z[t][0])+abs(j-Z[t][1])+Z[t][2])
      else:
        temp = abs(i-Z[t][0])+abs(j-Z[t][1])+Z[t][2]
        if temp != ans:
          break
      if t != N-1: #最後じゃないなら続く。
        continue
      #print(i,j,MAX,ans)
      if ans <= MAX:
        ret = [i,j,ans]
        print(*ret);exit()
      else:
        break
      


Measured memory_bytes: 68516
#include <stdio.h>

int main() 
{
    int i, j, c[3][3], x, y;
    
    for(i = 0; i < 3; i++){
    	for(j = 0; j < 3; j++) scanf("%d", c[i] + j);
	}
	
	x = c[0][1] - c[0][0], y = c[0][1] - c[0][2];
	for(i = 1; i < 3; i++){
		if(c[i][1] - c[i][0] != x || c[i][1] - c[i][2] != y) break;
	}
	if(i < 3){
		puts("No");
		return 0;
	}
	x = c[1][0] - c[0][0], y = c[1][0] - c[2][0];
	for(i = 1; i < 3; i++){
		if(c[1][i] - c[0][i] != x || c[1][i] - c[2][i] != y) break;
	}
	if(i < 3) puts("No");
	else puts("Yes");
	
    return 0;
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;

int fib(int n);

int main() {
    int n;
    int dp[45];

    //?????????
    /* ??????3-1 */
    dp[0] = 1;
    /* ??????3-2 */
    dp[1] = 1;

    //??\???
    cin >> n;

    //DP
    for (int i = 2; i <= n; i++) {
        /* ??????3-3 */
        dp[i] = dp [i-1] + dp[i-2];
    }

    //??????
    cout << dp[n] << endl;

    return 0;
}

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

int main() {
	int k, a = 7, ans = 1;
	cin >> k;
	rep(i, k) {
		if (k == 7) {
			cout << ans << endl;
			return 0;
		}
		a %= k;
		if (a == 0) {
			cout << ans << endl;
			return 0;
		}
		a = a * 10 + 7;
		ans++;
	}
	cout << -1 << endl;
}

Measured memory_bytes: 3612
#include<stdio.h>
int main(){
int a,b,N;
char op;
scanf("%d %c %d",&a,&op,&b);
while(op != '?'){
 if(op == '+'){
  N = a + b;
  printf("%d\n",N); }
 else if(op == '-'){
  N = a - b;
  printf("%d\n",N);}
 else if(op == '*'){
  N = a * b;
  printf("%d\n",N);}
 else{
  N = a / b;
  printf("%d\n",N);}
scanf("%d %c %d",&a,&op,&b);}
return 0;
}


Measured memory_bytes: 2032
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>

#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>

#include <cmath>
#include <numeric>
#include <random>
#include <cstring>
#include <cassert>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <stack>

// type
#include <cstdint>
#include <functional>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
template <class T> using MaxHeap = priority_queue<T>;
template <class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
#define P pair<ll, ll>

/* ---------- Constants  */
const double PI = 3.141592653589793238462643383279;
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

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

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */
int gcd(int a, int b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}

signed main() {
    cin.sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int K;
    cin >> K;
    int s = 0;
    for (int a = 1; a <= K; a++) {
        for (int b = 1; b <= K; b++) {
            for (int c = 1; c <= K; c++) {
                s += gcd(a, gcd(b, c));
            }
        }
    }

    cout << s << endl;
    return 0;
}

Measured memory_bytes: 3640
#include<cstdio>
#include<iostream>
#include<string>
#include<map>
#include<queue>
#include<set>
#include<algorithm>

using namespace std;

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

int main(){
	while(1){
		int n,T;
		cin>>n>>T;
		if(n==0)break;
		
		int ya[1111];
		ya[0]=0;
		reps(i,n){
			cin>>ya[i];
		}
		n++;
		
		vector<int> pt;
		rep(i,n){
			rep(j,n){
				pt.push_back(ya[i]+ya[j]);
			}
		}
		
		sort(pt.begin(),pt.end());
		
		int maxi=0;
		
		rep(i,pt.size()){
			if(pt[i]>T)break;
			vector<int>::iterator a;
			a=lower_bound(pt.begin(),pt.end(),T-pt[i]);
			
			maxi = max(maxi, pt[i] + *(a-1));
		}
		
		printf("%d\n",maxi);
	}
}

Measured memory_bytes: 4964
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int N, M; cin >> N >> M;
	VI H(N);
	REP(i, N)cin >> H[i];
	vector<VI>G(N);
	REP(i, M) {
		int a, b; cin >> a >> b; a--; b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	int ans = 0;
	REP(i, N) {
		bool F = 1;
		fore(to, G[i]) {
			//cout << i << " " << to << endl;
			if (H[i] <= H[to])F = 0;
		}
		if (F) {
			ans++;
			//cout << i + 1<< endl;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 9768
def main():

    N = int(input())
    B = list(map(int, input().split()))
    tot = 0
    for i in range(N):
        if i == 0:
            tot += B[i]
        elif i == N-1:
            tot += B[i-1]
        else:
            tot += min(B[i], B[i-1])
    return tot


if __name__ == '__main__':
    print(main())

Measured memory_bytes: 38384
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize (2)
#pragma G++ optimize (2)
#include <bits/stdc++.h>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define wuyt main
typedef long long ll;
#define HEAP(...) priority_queue<__VA_ARGS__ >
#define heap(...) priority_queue<__VA_ARGS__,vector<__VA_ARGS__ >,greater<__VA_ARGS__ > >
template<class T> inline T min(T &x,const T &y){return x>y?y:x;}
template<class T> inline T max(T &x,const T &y){return x<y?y:x;}
//#define getchar()(p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 21, stdin), p1 == p2) ? EOF : *p1++)
//char buf[(1 << 21) + 1], *p1 = buf, *p2 = buf;
ll read(){ll c = getchar(),Nig = 1,x = 0;while(!isdigit(c) && c!='-')c = getchar();
if(c == '-')Nig = -1,c = getchar();
while(isdigit(c))x = ((x<<1) + (x<<3)) + (c^'0'),c = getchar();
return Nig*x;}
#define read read()
const ll inf = 1e15;
const int maxn = 2e5 + 7;
const int mod = 1e9 + 7;
#define start int wuyt()
#define end return 0
char ss[maxn];
start{
    int n=read;
    scanf("%s",ss+1);
    int cnt=0;
    for(int i=1;i<=n;i++)
    {
        if(ss[i]!=ss[i+1])
            cnt++;
    }
    cout<<cnt;
	end;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <fstream>

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;

int H,W;
void solve(){
  ll defT=H*H+W*W;
  vector<ppi> v;
  for(int i=1;i<=1000;i++){
    for(int j=1;j<=1000;j++){
      if(j>i){
        ll T=i*i+j*j;
        v.push_back(make_pair(pii(T,i),j));
      }
    }
  }
  //v.push_back(make_pair(pii(defT,H),W));
  sort(v.begin(),v.end());
  for(int i=0;i<(int)v.size();i++){
    if(v[i].first.second==H&&v[i].second==W){
      cout<<v[i+1].first.second<<" "<<v[i+1].second<<endl;
      return;
    }
  }
}

int main(){

  while(cin>>H>>W&&(H|W)){
    solve();
  }
  
  return 0;
}

Measured memory_bytes: 13264
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,int> PLI;
const int MAXN=100005;
const int MAXM=200005;
const LL INF=1e18;
const int mod=1e9+7;

vector<PLI > edge[MAXN];
int n,m,s,t;
LL e[MAXM][3];
LL dis1[MAXN],dis2[MAXN];
LL num1[MAXN],num2[MAXN];

priority_queue<PLI,vector<PLI>,greater<PLI> > pq; 
void SPFA(int s,LL* dis,LL* num){
    for(int i=1;i<=n;i++){
        num[i]=0;
        dis[i]=INF;
    }
    dis[s]=0; num[s]=1;
    pq.push(PLI(0,s));
    while(!pq.empty()){
        PLI a=pq.top(); pq.pop();
        int u=a.second;
        if (dis[u]<a.first) continue;
        for(int i=0;i<edge[u].size();i++){
            int v=edge[u][i].first;
            LL d=edge[u][i].second;
            if (dis[v]>=dis[u]+d){
                if (dis[v]>dis[u]+d) num[v]=num[u],pq.push(PLI(dis[u]+d,v));
                else (num[v]+=num[u])%=mod;
                dis[v]=dis[u]+d;
            }
        }
    }
}

int main(){    
    scanf("%d%d%d%d",&n,&m,&s,&t);
    for(int i=1;i<=m;i++){
        int a,b,c; scanf("%d%d%d",&a,&b,&c);
        e[i][0]=a; e[i][1]=b; e[i][2]=c;
        edge[a].push_back(PLI(b,c));
        edge[b].push_back(PLI(a,c));
    }
    SPFA(s,dis1,num1);
    SPFA(t,dis2,num2);
    LL ans=num1[t]*num2[s]%mod;    
    LL ans1=0;
    for(int i=1;i<=n;i++){
        if (dis1[i]==dis2[i] && dis1[i]+dis2[i]==dis1[t]){
            LL tmp=num1[i]*num2[i]%mod;
            ans-=tmp*tmp%mod;
            if (ans<0) ans+=mod;
        }
    }
    //LL ans2=0;
    for(int i=1;i<=m;i++){
        LL a,b,c; a=e[i][0]; b=e[i][1]; c=e[i][2];
        if (dis1[a]>dis1[b]) swap(a,b);
        if (dis1[a]*2<dis1[t] && dis2[b]*2<dis1[t] && dis1[a]+dis2[b]+c==dis1[t]){
            LL tmp=num1[a]*num2[b]%mod;
            ans-=tmp*tmp%mod;
            if (ans<0) ans+=mod;
        }
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 21752
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

struct UnionFind {
	vector<int> v;
	UnionFind(int n) : v(n) { for (int i = 0; i < n; i++) v[i] = i; }
	int  find(int x) { return v[x] == x ? x : v[x] = find(v[x]); }
	void unite(int x, int y) { v[find(x)] = find(y); }
};
string comp(string s1, string s2) {
	if (s1.length() > s2.length())
		return s1;
	if (s1.length() < s2.length())
		return s2;
	if (s1 > s2)
		return s1;
	else
		return s2;
}
int main() {
	int w, h;
	while (cin >> w >> h, w) {
		vector<string> wards(h);
		REP(i, h) {
			cin >> wards[i];
		}
		vector<vector<string>> memo(h, vector<string>(w,""));
		for (int i = h - 1;i >= 0;i--)
			for (int j = w - 1;j >= 0;j--) {
				if (isdigit(wards[i][j])) {
					memo[i][j] = wards[i][j];
					if (i != h - 1)
						memo[i][j]=comp(wards[i][j] + memo[i + 1][j], memo[i][j]);
					if (j != w - 1)
						memo[i][j] = comp(wards[i][j] + memo[i][j + 1], memo[i][j]);
				}
			}
		string ans = "";
		REP(i, h)
			REP(j, w)
			if(memo[i][j][0]!='0')
			ans = comp(ans, memo[i][j]);
		cout << ans << endl;
	}
}

Measured memory_bytes: 3304
#include<cmath>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

#define MAXN 200000
#define INF 0x7fffffff
int N,A,B;

int main(){
	scanf("%d",&N);
	bool flag=0;
	long long All=0,Rest=INF;
	for(int i=1;i<=N;i++){
		scanf("%d%d",&A,&B);
		All+=B;
		flag|=A!=B;
		if(A>B)
			Rest=min(Rest,1ll*B);
	}
	printf("%lld",flag*(All-Rest));
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define all(x)    (x).begin(),(x).end()
typedef long long ll;
const int MOD = (int)1e9 + 7;

int solve(vector<int> a, int depth, vector<int>p_num, vector<int> c_val,int g){
  if(depth == p_num.size()){
    int buf = 0, score = 0, rest_max = 0;
    rep(i,a.size()){
      if(a[i] == 1) {
        score += p_num[i]*(i+1)*100 + c_val[i];
        buf += p_num[i];
      }
      else rest_max = i;
    }
    if(g>score){
      int s1 = (rest_max + 1) * 100;
      int rest = (g - score + s1 - 1) / s1;
      if (rest < p_num[rest_max]){
        buf += rest;
        score += rest * (rest_max + 1) * 100;
      }
    }
    return (score >= g) ? buf : MOD ;
  }

  int ans1 = solve(a,depth+1,p_num,c_val,g);
  a[depth] = 1;
  int ans2 = solve(a,depth+1,p_num,c_val,g);
  int ans = min(ans1,ans2);
  return ans;
}

int main(){
  int d,g;
  cin >> d >> g;
  vector<int> p(d), c(d);
  rep(i,d) cin >> p[i] >> c[i];
  vector<int> a(d,0);
  cout << solve(a,0,p,c,g) << endl;
}


Measured memory_bytes: 256
k = gets.to_i
a = gets.split.map(&:to_i)

ans = [2,2]
a.reverse.each do |v|
  if ans[0] % v != 0 && ans[1]/v == ans[0]/v
    p -1
    exit
  else
    t = []
    t[0] = (ans[0]/v.to_f).ceil * v
    t[1] = ans[1]/v * v + v-1
    ans = t
  end
end
puts ans.join(" ")

Measured memory_bytes: 11908
//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin, output: process.stdout
});
var obj; var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  console.error('\n↑入力 ↓出力');
  Main();
});
function makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){  
  return {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}}
  };
}
function myout(s){console.log(s);}
function myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}
//param "no" is
//unknown or outlier : return i. 1: parseInt.
//2: split space. 4: split space and parseInt.
//6: split 1 character. 7: split 1 character and parseInt.
//8: join space. 9: join nextline. 0: join no character.
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}

//Don't have to see. end------------------------------------------
function Main(){
  var N = nextInt();
  myout(Math.ceil(N / 2));
}

Measured memory_bytes: 30984
m = []
a = 0
for i in range(input()+1):
    if i == 0:
        continue
    if i % 3 == 0:
        m.append(str(i))
    else:
        a = i
        while True:
            if a % 10 == 3:
                m.append(str(i))
                break
            a /= 10
            if a == 0:
                break
print " " + " ".join(m)

Measured memory_bytes: 6700
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define ios ios_base::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0)
#define so sizeof
#define pb push_back
#define cl clear() ;
#define vl vector<ll>
#define sz size()
#define len length()
#define emp empty()
#define el endl;cout.flush()
#define be begin()
#define fi first
#define se second
#define br break
#define en end()
#define ro return 0
#define eb emplace_back
#define con continue
#define ms(x) memset(x , 0, so x)
#define all(x) (x).be , (x).en
#define acc(x) accumulate((x).be , (x).en , 0ll)
#define forn(i,a,b) for(ll i=a;i<=b;++i)
#define rng_58 mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define vll vector<pair<ll,ll> >
#define pll pair<ll,ll>
#define plll pair<ll,pair<ll,ll>>
#define plvl pair<pair<ll,ll> ,ll>
#define mp make_pair
#define trace3(a,b,c) cerr <<"a is " << a << " b is " << b << " c is " << c << el;
#define trace4(a,b,c,d) cerr <<"a is " << a << " b is " << b << " c is " << c <<" d is " << d << el ;
#define trace5(a,b,c,d,e) cerr <<"a is " << a << " b is " << b << " c is " << c <<" d is " << d << " e is " << e << el;
#define trace6(a,b,c,d,e,f) cerr <<"a is " << a << " b is " << b << " c is " << c <<" d is " << d << " e is " << e << " f is " << f << el ;

int main()
{
    ios;
    unordered_map<char , ll > mpp[55] ;
    ll n ;
    cin >> n ;
    forn(i , 1 , n ) {
       string s;
       cin >> s;
       sort(s.be , s.en );
       forn(j , 0 , s.len - 1){
          char c = s[j] ;
          mpp[i][c]++;
       }
    }
    vector<char> v ;
    ll val = 97 ;
    forn(i , 1 , 26){
       char c = char(val++) ;
       v.pb(c) ;
    }
    string ans = "" ;
    forn(i , 0 , v.sz - 1){
       char c = v[i] ;
       ll minn = 1e18 ;
       forn(j , 1 , n){
           minn = min(minn , mpp[j][c]);
       }
       forn(k , 1 , minn){
          ans = ans  + c;
       }
    }
    cout << ans << el ;

}































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

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

  vector<int> num(N);
  
  for(int i = 0; i < N;i++){
    cin >> num.at(i);
  }
  
  sort(num.begin(), num.end()); 
  reverse(num.begin(), num.end());
  
  int a = 0,b=0;
  
  for(int i = 0; i < N;i++){
    if( i%2 == 0 )	a += num.at(i);
    else b += num.at(i);
  }

  cout << a-b << endl;
}






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

int main() {
  int a,b,c,d; cin >>a >>b >>c >>d;
  int e = b-a, f = c-b, g = c-a;
  bool ok = false;
  if (g*g <= d*d) ok = true;
  else if (e*e <= d*d && f*f <= d*d) ok = true;
  
  if (ok) cout <<"Yes" <<endl;
  else cout <<"No" <<endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstring>
#include<string>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#include<iterator>
#include<queue>
#include<vector>
using namespace std;

int n,a[200010]={0},b[200010]={0};
int ans[30]={0},result=0;

int zset[30][200010]={0},oset[30][200010]={0};
int zpos[30]={0},opos[30]={0};

inline void readx(int& x)
{
	x=0; int k=1; register char ch=0;
	while (ch<'0' || ch>'9') { ch=getchar(); if (ch=='-') k=-1; }
	while (ch>='0' && ch<='9') { x=x*10+ch-'0'; ch=getchar(); }
	x*=k;
}

inline void process()
{
	for (int i=1;i<=n;i++)
	{
		int pren=0;
		for (int w=0;w<=28;w++)
		{
			if ((a[i]&(1<<w)))
			{
				opos[w]++;
				oset[w][opos[w]]=pren;
			}
			else
			{
				zpos[w]++;
				zset[w][zpos[w]]=pren;
			}
			pren+=((1<<w)&a[i]);
		}
	}
	
	for (int w=0;w<=28;w++)
	{
		sort(zset[w]+1,zset[w]+zpos[w]+1);
		sort(oset[w]+1,oset[w]+opos[w]+1);
	}
}

inline int BinSearchO(int lim,int wx)
{
	int mid,ansx=0,lx=1,rx=opos[wx];
	while (lx<=rx)
	{
		mid=(lx+rx)>>1;
		if (oset[wx][mid]<lim)
		{
			ansx=mid;
			lx=mid+1;
		}
		else rx=mid-1; 
	}
	return ansx;
}

inline int BinSearchZ(int lim,int wx)
{
	int mid,ansx=0,lx=1,rx=zpos[wx];
	while (lx<=rx)
	{
		mid=(lx+rx)>>1;
		if (zset[wx][mid]<lim)
		{
			ansx=mid;
			lx=mid+1;
		}
		else rx=mid-1; 
	}
	return ansx;
}

int main()
{
	readx(n);
	for (int i=1;i<=n;i++) readx(a[i]);
	for (int i=1;i<=n;i++) readx(b[i]);
	
	process();
	
	for (int i=1;i<=n;i++)
	{
		int preb=0,upat;
		for (int w=0;w<=28;w++)
		{
			upat=(1<<w)-preb;//>= inc
			
			if (((1<<w)&b[i]))//nowbit = 1
			{
				ans[w]+=BinSearchZ(upat,w);
				ans[w]+=opos[w]-BinSearchO(upat,w);
			}
			else//nowbit = 0
			{
				ans[w]+=BinSearchO(upat,w);
				ans[w]+=zpos[w]-BinSearchZ(upat,w);
			}
			
			preb+=((1<<w)&b[i]);
		}
	}
	
	for (int w=0;w<=28;w++) ans[w]%=2;
	for (int w=0;w<=28;w++) if (ans[w]) result+=(1<<w);
	printf("%d\n",result);
	return 0;
}

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

using namespace std;
typedef long long ll;
//typedef unsigned long long ll;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
//typedef pair<ll, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX / 100;
//const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)

bool contain(set<char> &s, int a) { return s.find(a) != s.end(); }


//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

typedef priority_queue<ll, vector<ll>, greater<ll>> PQ_ASK;
const int mod = 1000000007;

int main() {
    int n;
    cin >> n;
    string s, t;
    cin >> s >> t;

    for (int i = 0; i < n; i++) {
        cout << s[i] << t[i];
    }
    cout << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n, ans, r, g, b, c;
    r=g=b=0;
    string s;
    cin >> n;
    cin >> s;
     for(int i = 0 ;i<n ;i++)
     {
        if(s[i]=='R')
            r++;
        else if(s[i]=='G')
            g++;
        else if(s[i]=='B')
            b++;
     }

     ans = r*b*g;

    for(int i=0; i<s.size(); i++)
    {
        for(int j=i, k=i; k<s.size(); j++, k+=2)
        {
            
                if(s[i]+s[j]+s[k] == 'R'+'G'+'B')
                {
                    
                        ans--;
                }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>

using namespace std;
const int MaxN = 200005;
int n, k, fr[MaxN], m;

int main()
{
    cin >> n >> k;
    for (int i = 1; i <= n; i++)
    {
        int x;
        cin >> x;
        if (!fr[x]) m++;
        fr[x]++;
    }
    if (m <= k)
    {
        cout << 0 << '\n';
        return 0;
    }
    sort(fr + 1, fr + n + 1);
    int poz = 1;
    while (fr[poz] == 0) poz++;
    int ans = 0;
    for (int i = 0; i < m - k; i++) ans += fr[poz + i];
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 1024
let rev_iter (f : int -> unit) (a : int array) =
  let rec doit i =
    if i >= 0 then (f a.(i); doit (i - 1))
  in
  doit (Array.length a - 1)

let counting_sort a b k =
  let c = Array.make (k + 1) 0 in
  Array.iter (fun e -> c.(e) <- c.(e) + 1) a;
  Array.iteri (fun i _ -> if i <> 0 then c.(i) <- c.(i) + c.(i - 1)) c;
  rev_iter (fun e -> b.(c.(e) - 1) <- e; c.(e) <- c.(e) - 1) a

let () =
  let n = read_int () in
  let a = Array.init n (fun _ -> Scanf.scanf "%d " (fun e -> e)) in
  let k = Array.fold_left max (-1) a in
  let b = Array.make n 0 in
  counting_sort a b k;
  Array.iteri (fun i e -> if i <> 0 then print_string " "; print_int e) b;
  print_newline ()

Measured memory_bytes: 36036
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007

int main() {

  int N;
  cin >> N;

  vector<int> A(N);
  for(int i = 0;i < N;i++) {
    cin >> A.at(i);
  }

  int ans = 1,i = 0;

  while(i < N-1) {

    if(A.at(i) < A.at(i+1)) {
      while(i < N-1 && A.at(i) <= A.at(i+1)) i++;
    }else if(A.at(i) == A.at(i+1)) {
      while(A.at(i) == A.at(i+1)) i++;
      continue;
    }else {
      while(i < N-1 && A.at(i) >= A.at(i+1)) i++;
    }

    if(i == N-1) break;
    i++;
    ans++;
  }

  cout << ans << endl;
  
}

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

int main()
{
    string s, t, u;
    cin >> s >> t;
    int a, b;
    cin >> a >> b;
    cin >> u;
    if (s == u) a--;
    if (t == u) b--;
    cout << a << " " << b << endl;
    return 0;
}

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

using namespace std;

//#define FILE_IO

typedef long long LL;

int N;
int v[100005];
LL up[100005];
int g[100005];
vector <int> edg[100005];

void yes() {printf("YES\n"); exit(0);}
void no() {printf("NO\n"); exit(0);}

bool cmp(int a, int b)
{
    return up[a] > up[b];
}

void DFS(int nod, int fth)
{
    if(edg[nod].size() <= 1)
    {
        up[nod] = v[nod];
        return;
    }
    LL cnt = 0;
    LL mx = 0;
    for(auto nxt: edg[nod])
    {
        if(nxt == fth)  continue;
        DFS(nxt, nod);
        cnt += up[nxt];
        mx = max(mx, up[nxt]);
    }

    up[nod] = 2LL * v[nod] - cnt;
    if( (cnt - up[nod]) % 2 != 0 )  no();
    if(up[nod] < 0) no();

    LL st = 0;
    LL dr = mx;
    LL maxval = mx;
    while(st <= dr)
    {
        LL mij = st + (dr - st) / 2;
        LL rem = up[nod];
        for(auto nxt: edg[nod])
        {
            if(nxt == fth)  continue;
            rem -= max(0LL, up[nxt] - mij);
        }

        if(rem >= 0)
        {
            maxval = mij;
            dr = mij - 1;
        }
        else
            st = mij + 1;
    }

    if(maxval > (cnt - up[nod]) / 2)    no();
}

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

    scanf("%d", &N);
    for(int i = 1; i <= N; i++)
        scanf("%d", &v[i]);
    if(N == 2)
    {
        if(v[1] == v[2])    yes();
        no();
    }
    for(int i = 1; i < N; i++)
    {
        int x, y;
        scanf("%d%d", &x, &y);
        edg[x].push_back(y); g[x]++;
        edg[y].push_back(x); g[y]++;
    }

    int root = 1;
    for(int i = 1; i <= N; i++) if(g[i] > 1)    {root = i; break;}

    DFS(root, 0);
    if(up[root] == 0)   yes();
    no();

    return 0;
}


Measured memory_bytes: 15232
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
  string s;
  cin >> s;
  int n = s.length()-1;
  if (s[n] == '3'){
    cout << "bon" << endl;
  }
  else if(s[n] == '0' || s[n] == '1' || s[n] == '6' || s[n] == '8'){
    cout << "pon" << endl;
  }
  else cout << "hon" << endl;
}

Measured memory_bytes: 3628
n = int(input())
w = [''] * n
for i in range(n):
    w[i] = str(input())

flag = True
for i in range(1,n):
    a = list(w[i-1])
    b = list(w[i])
    if a[-1] == b[0]:
        pass
    else:
        flag = False

chk = list(set(w))
if len(w) == len(chk):
    pass
else:
    flag = False
        
if flag:
    print('Yes')
else:
    print('No')


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

int main(){
	int x;	cin>>x;
	for(int i=x;i<=1000000;i++){
		bool flag=true;
		for(int j=2;j*j<=i;j++){
			if(i%j==0){
				flag=false;
				break;
			}
		}
		if(flag){
			cout<<i<<endl;
			return 0;
		}
	}

	return 0;
}


Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))
M=0
X=(10**9)+7
Y=0
for k in range (0,N):
  M=M + A[k]
  Y=A[k]*A[k]+Y
M =M*M
Z= (M-Y)//2
print(Z%X)

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

#define int long long
#define fi first
#define se second
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define yn(x) ((x) ? "YES" : "NO")

typedef pair <int, int> ii;
typedef pair <int, ii> iii;

const int siz = 2e5 + 10;
const int SIZ = 1e6 + 10;
const int mod = 1e9 + 7;
const int maxx = 2e9;
const int MAXX = 1e18;
const string file = "1";

int n;
int val[siz];
vector <vector <int> > edges;
int f[siz], g[siz];

void dfs(int u, int p = -1) {
    int k = lower_bound(g + 1, g + 1 + n, val[u]) - g;
    int save = g[k];
    g[k] = val[u];
    f[u] = k - 1;

    if (p != -1) {
        f[u] = max(f[u], f[p]);
    }

    for (auto &v : edges[u]) {
        if (v == p) {
            continue;
        }

        dfs(v, u);
    }

    g[k] = save;
}

int32_t main() {
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

//    freopen ((file + ".inp").c_str(), "r", stdin);
//    freopen ((file + ".out").c_str(), "w", stdout);

    cin >> n;

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

    edges.resize(n + 1);
    for (int i = 1; i <= n - 1; i++) {
        int a, b;
        cin >> a >> b;

        edges[a].push_back(b);
        edges[b].push_back(a);
    }

    fill (g + 1, g + 1 + n, maxx);
    g[1] = 0;

    dfs(1);

    for (int u = 1; u <= n; u++) {
        cout << f[u] << "\n";
    }

//    cerr << "Time: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";

    return 0;
}


Measured memory_bytes: 33196
using System;
using System.Linq;

namespace C_sharp
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                var items = Console.ReadLine().Split();
                
                var H = int.Parse(items[0]);
                var W = int.Parse(items[1]);

                if (H == 0 && W == 0)
                {
                    break;
                }

                var w_set = W / 2;
                var odd_line = string.Concat(Enumerable.Repeat("#.", w_set));
                var even_line = string.Concat(Enumerable.Repeat(".#", w_set));

                if (W % 2 == 1)
                {
                    odd_line += "#";
                    even_line += ".";
                }

                var lines = odd_line + "\n" + even_line + "\n";

                var h_set = H / 2;
                var board = String.Concat(Enumerable.Repeat(lines, h_set));

                if (H % 2 == 1)
                {
                    board += odd_line + "\n";
                }
                
                Console.WriteLine(board);
            }
        }
    }
}



Measured memory_bytes: 16240
#include <iostream> // cout, endl, cin
#include <iomanip>
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <numeric>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
const int INF = 1001001001;
const int BG = 1000000007;

int get_dist(int a, int b, int c, int d)
{
    return abs(a - c) + abs(b - d);
}

int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> a(n), b(n), c(m), d(m);
    rep(i, n) cin >> a[i] >> b[i];
    rep(i, m) cin >> c[i] >> d[i];
    rep(i, n)
    {
        int mini = INF;
        int idx = -1;
        rep(j, m)
        {
            int dist = get_dist(a[i], b[i], c[j], d[j]);
            if (mini > dist)
            {
                mini = dist;
                idx = j + 1;
            }
        }
        cout << idx << endl;
    }
}


Measured memory_bytes: 256
using System;
using static System.Console;
using System.Linq;

namespace AC
{
   public class shiokara
   {
      static void Main(string[] args)
      {
         var tmp = ReadLine().Split(' ').Select(int.Parse).ToArray();
         int hour1 = tmp[0], min1 = tmp[1];
         int hour2 = tmp[2], min2 = tmp[3];
         int k = tmp[4];
         int sum = (hour2 * 60) + min2 - (hour1 * 60) - min1;
         WriteLine(sum - k);
      }
   }
}

Measured memory_bytes: 28296
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <climits>
#include <iomanip>
#include <string.h>
#include <algorithm>

using namespace std;
#define fast ios::sync_with_stdio(false);cin.tie(0); cout.tie(0)
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n); i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define clr(a,b) memset((a),b,sizeof(a))
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define tr(container, it) \
for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define sz(a) int((a).size())
#define pb push_back

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;

template<typename T> T gcd(T a,T b) { if(a==0) return b; return gcd(b%a,a); }
template<typename T> T pow(T a,T b, ll m){T ans=1; while(b>0){ if(b%2==1) ans=(ans*a)%m; b/=2; a=(a*a)%m; } return ans%m; }

const int N = (int)2e5+77;

ll n, m, k, x, y;
ll a[N];
int main() {
    fast;
    cin>>n;
    forn(i,n) cin>>a[i];
    ll i;
    for(i=n-1;i>=0;i-=2){
        cout<<a[i]<<" ";
    }
    if(n&1) i=1;
    else i=0;
    for(;i<n-1;i+=2){
        cout<<a[i]<<" ";
    }
    return 0;
}

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

using static Input;
using static Util;
class Program
{
    static int N, K;
    static int[] A;
    static void INPUT()
    {
        N = NextInt();
        K = NextInt();
        A = LineInt();
    }

    static void OUT()
    {
        var dp = new bool[K + 1];
        for (int i = 0; i <= K; i++)
        {
            foreach (var a in A)
            {
                if(a <= i)
                dp[i] |= !dp[i - a];
            }
        }

        Console.WriteLine(dp[K] ? "First" : "Second");
    }
    static void Main(string[] args)
    {
#if DEBUG  
        //TESTINPUT();
        INPUT();

#else
        INPUT();
#endif
        OUT();
    }

    static void TESTINPUT()
    {
    }

}

public class Input
{
    public const long MOD = 1000000007;
    public const int INF = 1000000007;
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}

class Util
{

}




Measured memory_bytes: 13416
from sys import stdin, setrecursionlimit


def main():
    input = stdin.buffer.readline
    s = input()[:-1].decode()
    l = int(s[:2])
    r = int(s[2:])
    if (l >= 13 or l == 0) and 1 <= r <= 12:
        print('YYMM')
    elif 1 <= l <= 12 and (r >= 13 or r == 0):
        print('MMYY')
    elif 1 <= l <= 12 and 1 <= r <= 12:
        print('AMBIGUOUS')
    else:
        print('NA')


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()


Measured memory_bytes: 38512
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#define fi first
#define se second
#define pb push_back
#define forn(i,n) for(int i=0;i<(n);i++)
#define for1(i,n) for(int i=1;i<=n;i++)
#define forr(i,n) for(int i=n;i>=0;i--)
#define all(x) x.begin(), x.end()
const int MAXN = 1e5 +5;

void fio(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}

vector<array<int,4> > Q;
int n,m,q;
int an = 0;
vector <int> v;

void dfs(int u){
	if(v.size()==n){
		int ma = 0;
		an = max(an, accumulate(all(Q), ma, [&](int k, array<int,4> z){
			return v[z[1]-1] - v[z[0]-1] == z[2]? k + z[3]: k;
		}));
		return;
	}
	for(int i = u; i<=m ;i++){
		v.pb(i);
		dfs(i);
		v.pop_back();
	}
}

int main(){
  fio();
  cin>>n>>m>>q;
  Q.resize(q);
  forn(i,q) forn(j,4) cin>>Q[i][j];
  dfs(1);
  cout<<an<<endl;
  return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <regex>
#include <map>
#include <set>
using namespace std;
int main(){
    int A,B,K;
    cin >> A >> B >> K;
    
    int tmp =100;
    while(K>0){
        if(A%tmp == 0 && B%tmp == 0){
            K--;
        }
        --tmp;
    }
    cout << tmp+1 <<endl;
    return 0;
}


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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

int main()
{
	int A, B, C;
	cin >> A >> B >> C;
	int D = max({A,B,C});
	ce(A+B+C-D)
    return 0;
}



Measured memory_bytes: 256
n=int(input())
v=list(map(int, input().split()))
c=list(map(int, input().split()))

xmy = 0
dp=[0]*n
dp[0] = max(v[0]-c[0], 0)
for i in range(1, n):
    dp[i] = max(dp[i-1]+v[i]-c[i], dp[i-1])
print(dp[-1])

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

int main(){
  string s;
  cin >> s;
  if(s == "hi" || s == "hihi" || s == "hihihi" || s == "hihihihi" || s == "hihihihihi"){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3576
#include<stdio.h>

int main(){
   int a,b,c,k;

   scanf("%d %d %d %d", &a, &b, &c, &k);

   if(k <= a){
      printf("%d\n", k);
   }else if(k <= a + b){
      printf("%d\n", a);
   }else{
      printf("%d\n", a-(k-a-b));
   }
   return 0;
}


Measured memory_bytes: 1720
#include <bits/stdc++.h>
#define fi first
#define se second

using namespace std;
map<long long,long long> mps,mpd;
long long n,ans;
pair<long long, long long> arr[200005];
int main(){
    cin>>n;
    for(int i =1;i<=n;i++){
        cin>>arr[i].fi;
        arr[i].se=i;
    }
    for(int i =1;i<=n;i++){
        long long sum,diff;
        sum=arr[i].fi+arr[i].se;
        diff=arr[i].se-arr[i].fi;
        mps[sum]++;
        mpd[diff]++;
    }
    for(int i =1;i<=n;i++){
        long long sum,diff;
        sum=arr[i].fi+arr[i].se;
        diff=arr[i].se-arr[i].fi;
        mps[sum]--;
        mpd[diff]--;
        ans+=mps[diff]+mpd[sum];
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 52016
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
cin>>n;
vector<double>a(n);
for(double &x:a)cin>>x;
sort(a.begin(),a.end());
double sum=(a[0]+a[1])/2;
for(int i=2;i<n;i++){
    sum=(sum+a[i])/2;
}
cout<<sum;
return 0;
}


Measured memory_bytes: 256
//
// Created by Myabu on 2020/01/01.
//

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <math.h>
#include <stack>
#include <queue>
#include <cstdio>

using namespace std;


int main(void){
    int X,A;
    cin>>X>>A;

    if(X<A){
        cout<<0<<endl;
    }else{
        cout<<10<<endl;
    }


    return 0;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)    FOR (i,0,n)
#define ALL(f,x,...) ([&](decltype((x)) ALL) {                          \
            return (f)(begin(ALL), end(ALL), ## __VA_ARGS__); })(x)

using namespace std;

const char sp = ' ';

vector<int> vi;

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

    vi.resize(N);

    REP(i, N) cin >> vi[i];

    int min = *ALL(min_element, vi);
    int max = *ALL(max_element, vi);

    ALL(sort, vi);

    int half = max / 2;

    // 以上
    auto itr = ALL(lower_bound, vi, half);

    int h = distance(vi.begin(), itr);

    if (N == 2) cout << max << sp << min << endl;
    else
    {
        // half - vi[h - 1] < vi[h] - half
        if (2 * half < vi[h - 1] + vi[h])
        {
            cout << max << sp << vi[h - 1] << endl;
        }
        else
        {
            cout << max << sp << vi[h] << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 640
//good luck
# include <iostream>
# include <cstdio>
# include <cmath>
# include <cstdlib>
# include <cstring>
# include <string>
# include <algorithm>
# include <vector>
# include <queue>
# include <ctime>
# include <map>

#define LL long long
#define maxn (int)1e5+5
#define inf  (int)2147483640
#define is(a) (a>='0'&&a<='9')
#define iabs(a) ((a)>0?(a):(-a))
#define imax(a,b) ((a)>(b)?(a):(b))
#define imin(a,b) ((a)<(b)?(a):(b))
 
using namespace std;

LL N,d,a[maxn],sum;

inline void read(LL &x)
{
  x=0;bool f=0;char ch=getchar();
  for (;!is(ch);ch=getchar()) f|=ch=='-';
  for (;is(ch);ch=getchar()) x=(x<<3)+(x<<1)+(ch^48);
  x=f?-x:x;
}

long double c;

int main()
{
	read(N); 
	for (int i = 1; i <= N; ++i) read(a[i]),c+=((long double)1.0/a[i]);
	printf("%.8LF",(long double)1.0/c);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
#include<set>
#include<iterator>
#include<map>
#include<cmath>
#include<unordered_map>
#include<vector>
using namespace std;
#define int long long
#define endl "\n"
#define pb push_back
#define F first
#define S second
#define fo(i,n) for(int i=0;i<n;++i)
#define all(v) v.begin(),v.end()
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
const int inf = (1e18)+7;
const int neginf = -1*((int)1e17 ) + 7 ; 

int32_t main() {
    fastio
        
    int n,m;
    cin>>n>>m;
    
    char arr[n][n];
    
    fo(i,n)
        fo(j,n)
        cin>>arr[i][j];
    
    char brr[m][m];
    
    fo(i,m)
        fo(j,m)
        cin>>brr[i][j];
    
    bool flag ;
  for(int i=0; i<n-m+1; i++){
        for(int j=0; j<n-m+1; j++){
           flag = 0;
            for(int k=0; k<m; k++){
                for(int l=0; l<m; l++){
                    if(arr[i+k][j+l]!=brr[k][l]){
                        flag=1;
                        break;
                    }
                }
            }
            if(flag==0)
            {
                cout<<"Yes";
                return 0;
            }
        }
  }
    
    cout<<"No";
    
    
     
    
    
    

        
        
        
    
            
        
       
        
        
        
    
     
    
    
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int a, b, c, k;
	int sum = 0;

	scanf("%d %d %d %d", &a, &b, &c, &k);

	if (k <= a) {
		sum = k;
		k = 0;
	}
	else {
		k -= a;
		sum = a;
	}

	if (k != 0) {
		k -= b;
	}

	while (k > 0) {
		sum--;
		k--;
	}

	printf("%d\n", sum);

	return 0;
}

Measured memory_bytes: 1728