akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <functional>
#include <tuple>

#ifdef USE_PYTHON_LIKE_PRINT
#include "print.h"
#else
template<char SEP = ' ', char END = '\n'> inline void print(...){}
template<char SEP = ' ', char END = '\n'> inline void printe(...){}
template<char SEP = ' ', char END = '\n'> inline void printo(...){}
#define define_print(...)
#define define_print_with_names(...)
#define define_to_tuple(...)
#endif

using namespace std;

inline int pow2(int n){
	int x = 1;
	for(int i = 0; i < n; i ++){
		x *= 2;
	}
	return x;
}

inline int pow3(int n){
	int x = 1;
	for(int i = 0; i < n; i ++){
		x *= 3;
	}
	return x;
}

void combi(const int N, vector<int>& towns, const int K, const int l, const int n, function<void(void)> f){
	if(l == K){
		f();
	}else{
		for(int i = n; i <= N - K + l; i ++){
			towns[l] = i;
			combi(N, towns, K, l + 1, i + 1, f);
		}
	}
}

struct Env{
	const int N;
	const vector<tuple<int, int, int>>& data;
	const vector<vector<int>>& table_dists_h;
	const vector<vector<int>>& table_dists_v;
	vector<unsigned long>& table;
};

void calc(const Env& env, int c, int b0, int b1, int b, int n){
	if(n == env.N){
		unsigned long value = 0;
		const auto& t0 = env.table_dists_h[b0];
		const auto& t1 = env.table_dists_v[b1];
		for(int i = 0; i < env.N; i ++){
			const int P0 = get<2>(env.data[i]);
			value += (unsigned long)min(t0[i], t1[i]) * (unsigned long)P0;
		}
		if(env.table[c] > value){
			env.table[c] = value;
		}
	}else{
		calc(env, c, b0, b1, b * 2, n + 1);
		calc(env, c + 1, b0 + b, b1, b * 2, n + 1);
		calc(env, c + 1, b0, b1 + b, b * 2, n + 1);
	}
};

int main(void){
	int N;
	cin >> N;
	
	vector<tuple<int, int, int>> data;
	
	unsigned long min_value_0 = 0;
	for(int i = 0; i < N; i ++){
		int X, Y, P;
		cin >> X;
		cin >> Y;
		cin >> P;
		data.push_back(make_tuple(X, Y, P));
		min_value_0 += (unsigned long)min(abs(X), abs(Y)) * (unsigned long)P;
	}
	
	cout << min_value_0 << endl;
	
	const int B = pow2(N);
	
	vector<vector<int>> table_dists_h(B + 1);
	vector<vector<int>> table_dists_v(B + 1);
	
	for(int b = 0; b < B; b ++){
		auto& dists_h = table_dists_h[b];
		auto& dists_v = table_dists_v[b];
		
		dists_h.reserve(N);
		dists_h.reserve(N);
		for(int i = 0; i < N; i ++){
			const int X0 = get<0>(data[i]);
			const int Y0 = get<1>(data[i]);
			int x = b;
			int j = 0;
			int d_h = abs(X0);
			int d_v = abs(Y0);
			while(x > 0){
				if(x % 2 == 1){
					const int X1 = get<0>(data[j]);
					const int Y1 = get<1>(data[j]);
					d_h = min(d_h, abs(X1 - X0));
					d_v = min(d_v, abs(Y1 - Y0));
				}
				x /= 2;
				j += 1;
			}
			dists_h.push_back(d_h);
			dists_v.push_back(d_v);
		}
	}
	
	vector<unsigned long> table(N + 1, min_value_0);
	
	const Env env = {
		N, data, table_dists_v, table_dists_h, table
	};
	calc(env, 0, 0, 0, 1, 0);
	
	for(int K = 1; K <= N; K ++){
		cout << table[K] << endl;
	}
	
	return 0;
}



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

using namespace std;

#define INF (1 << 30)
#define EPS 1e-10
#define MOD 1000000007

using ll = long long;

int main() {
    int h, w, c[10][10], a;
    cin >> h >> w;
    for (int i = 0; i < 10; ++i) {
        for (int j = 0; j < 10; ++j) {
            cin >> c[i][j];
        }
    }
    for (int k = 0; k < 10; ++k) {
        for (int i = 0; i < 10; ++i) {
            for (int j = 0; j < 10; ++j) {
                c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
            }
        }
    }

    int ans = 0;
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            cin >> a;
            if (a >= 0) {
                ans += c[a][1];
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
// Author -- xyr2005

#include<bits/stdc++.h>

#define lowbit(x) ((x)&(-(x)))
#define Finline __inline__ __attribute__ ((always_inline))
#define DEBUG fprintf(stderr,"Running on Line %d in Function %s\n",__LINE__,__FUNCTION__)
#define SZ(x) ((int)x.size())
#define mkpr std::make_pair
#define pb push_back

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef std::pair<int,int> pi;
typedef std::pair<ll,ll> pl;
using std::min;
using std::max;

const int inf=0x3f3f3f3f,Inf=0x7fffffff;
const ll INF=0x3f3f3f3f3f3f3f3f;

Finline uint rnd(){static uint seed=416;return seed+=0x71dad4bfu,seed^=seed>>5,seed+=0xc6f74d88u,seed^=seed<<17,seed+=0x25e6561u,seed^=seed>>13;}
template <typename _Tp>_Tp gcd(const _Tp &a,const _Tp &b){return (!b)?a:gcd(b,a%b);}
template <typename _Tp>Finline _Tp abs(const _Tp &a){return a>=0?a:-a;}
template <typename _Tp>Finline void chmax(_Tp &a,const _Tp &b){(a<b)&&(a=b);}
template <typename _Tp>Finline void chmin(_Tp &a,const _Tp &b){(b<a)&&(a=b);}
template <typename _Tp>Finline void read(_Tp &x)
{
	char ch(getchar());bool f(false);while(!isdigit(ch)) f|=ch==45,ch=getchar();
	x=ch&15,ch=getchar();while(isdigit(ch)) x=(((x<<2)+x)<<1)+(ch&15),ch=getchar();
	f&&(x=-x);
}
template <typename _Tp,typename... Args>Finline void read(_Tp &t,Args &...args){read(t);read(args...);}
template <typename _Tp,typename... Args>Finline _Tp min(const _Tp &a,const _Tp &b,const Args &...args){return a<b?min(a,args...):min(b,args...);}
template <typename _Tp,typename... Args>Finline _Tp max(const _Tp &a,const _Tp &b,const Args &...args){return a<b?max(b,args...):max(a,args...);}
Finline int read_str(char *s)
{
	char ch(getchar());while(ch==' '||ch=='\r'||ch=='\n') ch=getchar();
	char *tar=s;*tar=ch,ch=getchar();while(ch!=' '&&ch!='\r'&&ch!='\n'&&ch!=EOF) *(++tar)=ch,ch=getchar();
	return tar-s+1;
}

const int N=3005;
const int mod=1000000007;
template<typename _Tp1,typename _Tp2>Finline void add(_Tp1 &a,_Tp2 b){(a+=b)>=mod&&(a-=mod);}
template<typename _Tp1,typename _Tp2>Finline void sub(_Tp1 &a,_Tp2 b){(a-=b)<0&&(a+=mod);}
int dp[N<<1][N][2];
int sum[N];
int main()
{
	int n,m,k;read(n,m,k);
	int limit=(n+m-1)/(k-1)+1;
	dp[0][0][0]=1;
	int ans=0;
	for(int i=1;i<=limit;++i)
	{
		for(int j=0;j<=n;++j)
		{
			sum[j]=dp[i-1][j][0],add(sum[j],dp[i-1][j][1]);
			add(sum[j],sum[j-1]);
		}
		for(int j=0;j<=n;++j)
		{
			dp[i][j][0]=(dp[i-1][j][0]+dp[i-1][j][1])%mod;
			if(j) dp[i][j][1]=(sum[j-1]-(j>=k?sum[j-k]:0)+mod)%mod;
		}
		for(int j=0;j<=n;++j) if(j%(k-1)==n%(k-1)&&(i*(k-1)-j+1)%(k-1)==m%(k-1)&&i*(k-1)-j+1<=m) add(ans,dp[i][j][1]);
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 82228
using System;
using System.Linq;
class c
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        var a = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        var b = Enumerable.Range(1, n).ToArray();
        int ng = 0;
        for (int i = 0; i < n; i++) if (a[i] != b[i]) ng++;
        Console.WriteLine(ng > 2 ? "NO" : "YES");
    }
}

Measured memory_bytes: 13268
from itertools import*
n=int(input())
*a,=map(int,input().split())

a*=2
*odd,=accumulate([v if k%2 else -v for k,v in enumerate(a)])
*even,=accumulate([v if k%2==0 else -v for k,v in enumerate(a)])
#print(odd)
#print(even)
for i in range(n):
    if i%2==0:
        print(even[i+n-1]-even[i]+a[i],end=" ")
    else:
        print(odd[i+n-1]-odd[i]+a[i],end=" ")

Measured memory_bytes: 30024
#include <bits/stdc++.h>
using namespace std;
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  int m,d;
  cin >> m >> d;
  int ans = 0;
  for(int d1 = 2; d1 <= min(9,d); ++d1){
    for(int d2 = 2; 10*d2+d1 <= d; ++d2){
      if(d1*d2 <= m) ++ans;
    }
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 256
// #pragma GCC target("avx2")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
using namespace std;
const long long mod=998244353;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3121000;
long long fact[C_SIZE];
long long finv[C_SIZE];
long long inv[C_SIZE];
long long Comb(int a,int b){
 	if(a<b||b<0)return 0;
 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
}
void init_C(int n){
	fact[0]=finv[0]=inv[1]=1;
	for(int i=2;i<n;i++){
		inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
	}
	for(int i=1;i<n;i++){
		fact[i]=fact[i-1]*i%mod;
		finv[i]=finv[i-1]*inv[i]%mod;
	}
}
long long pw(long long a,long long b){
	if(a<0LL)return 0;
	if(b<0LL)return 0;
	long long ret=1;
	while(b){
		if(b%2)ret=ret*a%mod;
		a=a*a%mod;
		b/=2;
	}
	return ret;
}
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
double ABS(double a){return max(a,-a);}
int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
// ここから編集しろ
char S[110000];
char T[110000];
int nx[110000][26];
int las[26];
int main(){
	scanf("%s%s",S,T);
	int n=strlen(S);
	for(int i=0;i<26;i++)las[i]=-1;
	for(int i=0;i<26;i++)nx[n][i]=-1;
	for(int i=n-1;i>=0;i--){
		las[S[i]-'a']=i+1;
		for(int j=0;j<26;j++){
			nx[i][j]=las[j];
		}
	}
	int at=0;
	int ind=0;
	for(int i=0;T[i];i++){
		if(nx[ind][T[i]-'a']!=-1){
			ind=nx[ind][T[i]-'a'];
		}else{
			at++;
			ind=0;
			if(nx[ind][T[i]-'a']!=-1){
				ind=nx[ind][T[i]-'a'];
			}else{
				printf("-1\n");return 0;
			}
		}
	}
	long long ret=(long long)at*n+ind;
	printf("%lld\n",ret);
}

Measured memory_bytes: 12416
N, K = list(map(int, input().split()))

r = 0

# abc mod K -> all 0
k  = N // K
r += k * k * k

# abc mod K -> all K/2
if K % 2 == 0:
    k  = (N + K // 2) // K
    r += k * k * k

print(r)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
const int Maxn=100005;
int n;
long long a[Maxn],b[Maxn],ans,tmp;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n+1;i++)
		scanf("%lld",&a[i]);
	for(int i=1;i<=n;i++)
		scanf("%lld",&b[i]);
	for(int i=1;i<=n+1;i++)
	{
		if(b[i-1])
		{
			tmp=min(b[i-1],a[i]);
			a[i]-=tmp;
			b[i-1]-=tmp;
			ans+=tmp;
		}
		if(b[i])
		{
			tmp=min(b[i],a[i]);
			a[i]-=tmp;
			b[i]-=tmp;
			ans+=tmp;
		}
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b;
  cin >> a >> b;
  if (a <= 5) {
    cout << 0 << endl;
  } else if (a < 13) {
    cout << b / 2 << endl;
  } else {
    cout << b << endl;
  }
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<list>
#include<stack>
#include<queue>
#include<cctype>
#include<iomanip>
#include<functional>
#include<numeric>
#include<map>
#include<set>
#define EPS 1e-10
using namespace std;
typedef long long llong;
int main() {
	vector<int>l(10), v(2);
	char c;
	while (cin >> l[0]) {
		for (int i = 1; i < 10; i++)cin >> c >> l[i];
		cin >> c >> v[0] >> c >> v[1];
		int sum = accumulate(l.begin(), l.end(), 0);
		//cout << "sum = " << sum;
		int V = v[0] + v[1];
		// cout << "  V = " << V << "  ";
		double x = (double)v[0] * sum / (double)V;
		//cout << "x = " << x << " ";
		int z = 0;
		for (int i = 0; i < 10; i++) {
			z += l[i];
			if (z >= x) {
				cout << i + 1 << endl;
				break;
			}
		}
	}
	return 0;
}

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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

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

  string s;
  cin>>s;
  for(int i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      cout<<i+1<<" "<<i+2<<endl;
      return 0;
    }
  }
  for(int i=0;i<s.size()-2;i++){
    if(s[i]==s[i+2]){
      cout<<i+1<<" "<<i+3<<endl;
      return 0;
    }
  }
  cout<<-1<<" "<<-1<<endl;
  return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
typedef long long ll;

#define MAX_N 200010

class UnionFind {
private:
  // 親と木の深さ
  int par[MAX_N];
  int rank[MAX_N];
public:
  void init(int n);
  int find(int x);
  void unite(int x, int y);
};

// 要素数nで初期化
void UnionFind::init (int n) {
  for(int i=0; i<n; i++) {
    par[i] = i;
    rank[i] = 0;
  }
}

// 要素xの親を求める
int UnionFind::find(int x) {
  if(par[x] == x) return x;
  else return par[x] = find(par[x]);
}

// xとyの属する集合を併合
void UnionFind::unite(int x, int y) {
  // xとyの親
  x = find(x);
  y = find(y);
  if(x == y) return;

  // yのほうが深さが深い　xの親はyの親
  if(rank[x] < rank[y]) par[x] = y;
  else {
    par[y] = x;
    if( rank[x] == rank[y] ) rank[x]++;
  }
}

map<pair<int, int> , int> m;
UnionFind ar, br;

int main(){
	int n, k, l, p[100000], q[100000], r[100000], s[100000];
	cin >> n >> k >> l;
	for(int i = 0;i < k;i++) cin >> p[i] >> q[i];
	for(int i = 0;i < l;i++) cin >> r[i] >> s[i];

	ar.init(n);
	br.init(n);
	// 道路で連結
	for(int i = 0;i < k;i++){
		ar.unite(p[i]-1, q[i]-1);
	}
	// 鉄道で連結
	for(int i = 0;i < l;i++){
		br.unite(r[i]-1, s[i]-1);
	}

	// 同じpairを数える
	for(int i = 0;i < n;i++) m[make_pair(ar.find(i),br.find(i))]++;
	for(int i = 0;i < n;i++) cout << m[make_pair(ar.find(i),br.find(i))] << ' ';
		cout << endl;

	return 0;
}

Measured memory_bytes: 16640
N, K, Q = map(int, input().split())
index_list = [int(input()) - 1 for i in range(Q)]

zero_list = [0 for n in range(N)]

ori = K - Q
for i in range(Q):
    zero_list[index_list[i]] += 1
for i in range(N):
    zero_list[i] += ori
for i in range(N):
    if zero_list[i] > 0:
        print('Yes')
    else:
        print('No')

# shakayamiさんのコードを参考にしました
# for文が入れ子になると遅くなるから，出来るだけそうしない


Measured memory_bytes: 11776
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
using namespace std;

int main(){
	int H, W;
	cin >> H >> W;
	vector<vector<char>> a;
	for(int i=0;i<H;i++){
		vector<char> IN(W);
		for(int j=0;j<W;j++){
			cin >> IN[j];
		}
		a.push_back(IN);
	}
	int i=0;
	while(i<(int)a.size()){
		int check = 1;
		for(int j=0;j<W;j++){
			if(a[i][j] == '#'){
				check = 0;
				break;
			}
		}
		if(check)a.erase(a.begin() + i);
		else i++;
	}
	i = 0;
	while(i<(int)a[0].size()){
		int check = 1;
		for(int j=0;j<(int)a.size();j++){
			if(a[j][i] == '#'){
				check = 0;
				break;
			}
		}
		if(check){
			for(int j=0;j<(int)a.size();j++){
				a[j].erase(a[j].begin() + i);
			}
		}
		else i++;
	}
	for(i=0;i<(int)a.size();i++){
		for(int j=0;j<(int)a[0].size();j++){
			cout << a[i][j];
		}
		cout << endl;
	}
}

Measured memory_bytes: 256
/*input
happy,newyear,enjoy
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#ifdef leowang
#define debug(...) do{\
	fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){cerr<<x<<endl;}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){cerr<<x<<", ";_DO(tail...);}
#else
#define debug(...)
#endif
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}
//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}
int main()
{
	IOS;
	int n;
  cin>>n;
	cout<<800*n-n/15*200;
	return 0;
}


Measured memory_bytes: 256
// {{{
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <complex>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define FOR(i, a, b) for(ll i = static_cast<ll>(a); i < static_cast<ll>(b); i++)
#define FORR(i, a, b) for(ll i = static_cast<ll>(a); i >= static_cast<ll>(b); i--)
#define REP(i, n) for(ll i = 0ll; i < static_cast<ll>(n); i++)
#define REPR(i, n) for(ll i = static_cast<ll>(n); i >= 0ll; i--)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> IP;
typedef pair<ll, LP> LLP;

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

constexpr int INF = 100000000;
constexpr ll LINF = 10000000000000000ll;
constexpr int MOD = static_cast<int>(1e9 + 7);
constexpr double EPS = 1e-9;
// }}}

int n;
vector<ll> v;

void init()
{
}

#if 0
void solve()
{
    int mid1 = -1, mid2 = -1;
    double mid = v[n-1]/2.;
    sort(ALL(v));
    REP(i, n){
        if(mid1 == -1 || abs(mid-v[i]) < abs(mid-v[mid1])){
            mid2 = mid1;
            mid1 = i;
        }else if(mid2 == -1 || abs(mid-v[i]) < abs(mid-v[mid2])){
            mid2 = i;
        }
    }
    if(v[mid1] < v[mid2]) swap(mid1, mid2);
    cout << v[n-1] << " " << (v[mid1] < v[n-1] - v[mid2] ? v[mid1] : v[mid2]) << endl;
}
#endif

void solve()
{
    int ans = -1;
    int val = -1;
    sort(ALL(v));
    REP(i, n){
        int x = (v[i] < v[n-1]-v[i] ? v[i] : v[n-1]-v[i]);
        if(ans == -1 || x > val){
            ans = v[i];
            val = x;
        }
    }
    cout << v[n-1] << " " << ans << endl;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    REP(i, n){
        ll x;
        cin >> x;
        v.pb(x);
    }
    solve();
    return 0;
}

// vim:set foldmethod=marker:


Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
// Welcome to my source code!

int main() {
    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;
    ll price = 0, t;
    if (a + b >= 2 * c) {
        int maxq = max(x, y);
        int minq = min(x, y);
        if (maxq == x) t = a;
        else t = b;
        price += 2 * c * minq;
        maxq -= minq;
        minq = 0;
        if (maxq && t >= 2 * c) {
            price += 2 * c * maxq;
        } else if (maxq) {
            price += maxq * t;
        }
    } else {
        price = x * a + y * b;
    }
    cout << price << endl;
}

Measured memory_bytes: 256
import sys
import copy
import time
import random

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline

D = None
C = None
S = None

def cnt_score(t):
    global D, C, S
    score = 0
    cnt = [-1] * 26

    for i in range(D):
        score += S[i][t[i] - 1]
        minusscore = 0
        cnt[t[i] - 1] = i
        for j in range(26):
            minusscore += (i - cnt[j]) * C[j]
        score -= minusscore
    return score


def main():
    global D, C, S
    D = int(input())
    C = [int(x) for x in input().split()]
    S = [[int(x) for x in input().split()] for _ in range(D)]

    start = time.time()

    ans = []
    for s in S:
        ans.append(s.index(max(s)) + 1)

    # 初期値をランダムで探す
    while True:
        # time up
        current = time.time()
        if current - start > 0.3:
            break

        # main
        new_ans = []
        for _ in range(D):
            new_ans.append(random.randint(1, 26))

        if cnt_score(new_ans) > cnt_score(ans):
            ans = new_ans

    #ans = [1] * D

    day = 0
    while True:
        # time up
        current = time.time()
        if current - start > 1.8:
            break

        # main
        new_ans = copy.deepcopy(ans)
        old_score = cnt_score(ans)

        max_sore = old_score
        max_contest = ans[day]
        for i in range(26):
            new_ans[day] = i + 1
            new_score = cnt_score(new_ans)
            if new_score > old_score:
                max_contest = i + 1
                old_score = new_score
        ans[day] = max_contest

        # increment day
        day = (day + 1) % D

    for a in ans:
        print(a)



if __name__ == '__main__':
    main()


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

using namespace std;

const double eps = 1e-5;

/*
int main()
{
    int a,b,c;
    cin >> a >> b;
    c = ((double)(b)-eps)/((double)(a));
    cout << c+1 << "\n";
    return 0;
}


仔细读题
快速做题
快准狠
*/

int main()
{
    int a,b;
    cin >> a >> b;
    int sum =0;
    a--;
    b--;
    while(b>0)
    {
        sum++;
        b -= a;
    }
    cout << sum << "\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
int main()
{
    int N, K;
    cin >> N >> K;
    vector<int> vc( N );
    for( auto &x : vc )
    {
        cin >> x;
    }
    int res{};
    REP( i, N )
    {
        res += min( vc[ i ] * 2, ( K - vc[ i ] )* 2 );
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <utility>
#include <memory.h>
#include <algorithm>
#include <cassert>
#include <numeric>
#include <functional>
#include <queue>

using namespace std;

#define prev prev_______________________
#define next next_______________________
#define hash hash_______________________
#define y1 y1___________________________

#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define ford(i, n) for (int i = int(n) - 1; i >= 0; --i)
#define all(c) (c).begin(), (c).end()
#define sz(c) int((c).size())
#define mp(x, y) make_pair(x, y)
#define pb push_back
#define fst first
#define snd second

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using pii = pair<int, int>;

#ifdef LOCAL
#define eprintf(args...) fprintf(stderr, args), fflush(stderr);
#else
#define eprintf(args...) ;
#define cerr if (0) cerr
#endif

int n;
vi a;

bool read() {
    if  (!(cin >> n)) {
        return 0;
    }
    a.resize(n);
    forn(i, n) {
        cin >> a[i];
    }
    return 1;
}

ll solve() {
    forn(i, n - 1) {
        if  (a[i + 1] > a[i] + 1) {
            return -1;
        }
    }
    if  (a[0] > 0) {
        return -1;
    }

    ll ans = 0;
    int cur = a[n - 1];
    ans += cur;
    ford(i, n) {
        eprintf("i=%d, cur=%d, a[i]=%d\n", i, cur, a[i]);
        assert(cur <= a[i]);
        if  (cur != a[i]) {
            ans += a[i];
            cur = a[i];
        }
        cur = max(0, cur - 1);
    }
    return ans;
}

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

#ifdef LOCAL
    #define FNAME "a"
    freopen(FNAME ".in", "r", stdin);
    freopen(FNAME ".out", "w", stdout);
#endif

    while (read()) {
        cout << solve() << endl;

        eprintf("\n");
    }

    return 0;
}


Measured memory_bytes: 1024
package main

import (
	"fmt"
)

func main() {
	var (
		n, q int
		s    string
	)
	fmt.Scan(&n, &q, &s)
	l := make([]int, q)
	r := make([]int, q)
	for i := 0; i < q; i++ {
		fmt.Scan(&l[i], &r[i])
	}

	c := make([]int, n+1)
	c[0], c[1] = 0, 0
	for i := 2; i <= n; i++ {
		if s[i-2] == 'A' && s[i-1] == 'C' {
			c[i] = c[i-1] + 1
		} else {
			c[i] = c[i-1]
		}
	}
	for i := 0; i < q; i++ {
		a := c[r[i]] - c[l[i]-1]
		b := c[r[i]] - c[l[i]]
		if a == b {
			fmt.Println(a)
		} else {
			fmt.Println(a - 1)
		}
	}
}


Measured memory_bytes: 6144
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <cstdlib>
using namespace std;
int A[200010];
int B[200010];
int main()
{
    int N;
    while(scanf("%d",&N)!=EOF)
    {
        for(int i=0;i<N;i++)
            {
                scanf("%d",&A[i]);
                B[i]=A[i];
            }
        sort(A,A+N);
        int temp=N/2;
        for(int i=0;i<N;i++)
        {
            if(B[i]<A[temp])
                printf("%d\n",A[temp]);
            else
                printf("%d\n",A[temp-1]);
        }
    }
    return 0;
}


Measured memory_bytes: 3712
#include<stdio.h>
#include<string.h>
int main()
{
	char str[20],cp[20];
	int i,len;

	scanf("%s",str);
	
	len = strlen(str);

	for(i=len;i>0;i--)
	{
		printf("%c",str[i-1]);
	}

	printf("\n");
	return 0;
}

Measured memory_bytes: 524
#include <iostream>
#include <iomanip>
#include <sstream>
#include <stdio.h>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <math.h>
#include <utility>
#include <string>
#include <ctype.h>
#include <cstring>
#include <cstdio>
#include <sstream>
#include <functional>

using namespace std;

#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define INF 114514810
#define ll long long
#define ALL(a) (a).begin(),(a).end()
#define SORT(v) sort(ALL(v))
//#define scanf scanf_s

int n, q, k;
int a[1000001];

void update(int x, int y)
{
	x += k;
	a[x] = y;
	while (x>0)
	{
		x = (x - 1) / 2;
		a[x] = min(a[x * 2 + 1], a[x * 2 + 2]);
	}
}

int find(int x, int y, int k, int l, int r)
{
	if (r <= x || l >= y) return 2147483647;
	if (x <= l &&y >= r) return a[k];
	int vl = find(x, y, 2 * k + 1, l, (l + r) / 2);
	int vr = find(x, y, 2 * k + 2, (l + r) / 2, r);
	return min(vl, vr);

}
int main()
{
	cin >> n >> q;
	int n_ = 1;
	while (n > n_)
	{
		n_ *= 2;
	}
	n = n_;
	n_ *= 2;
	REP(i, n_+5) a[i] = 2147483647;
	int c, x, y;
	k = n_/2 - 1;
	REP(i, q)
	{
		cin >> c >> x >> y;
		if (c == 0) update(x, y);
		else cout << find(x, y+1, 0, 0, n) << endl;
	}
	return 0;
}

Measured memory_bytes: 2192
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class MainClass
{
	public const long Giri = 1000000007;
	public const long DpInf = 99999999999999;
	
	private static long max = 0;
	private static int[,] mt;
	private static int q = 0;
	public static void Main(string[] args)
	{
		var p = Input().ToInt();
		var n = p[0];
		var m = p[1];
		q = p[2];
		
		mt = new int[q,4];
		for(int i = 0; i < q; i++)
		{
			p = Input().ToInt();
			mt[i, 0] = p[0];
			mt[i, 1] = p[1];
			mt[i, 2] = p[2];
			mt[i, 3] = p[3];
		}
		
		var list = new List<int>(n);
		GetArray(list, 0, 1, m, n);
		Console.WriteLine(max);
	}
	
	static void GetArray(List<int> t, int ind, int mae, int m, int n)
	{
		if(ind == n)
		{
			long wa = 0;
			for(int i = 0; i < q; i++)
			{
				var ab = t[(mt[i, 1]-1)];
				var aa = t[(mt[i, 0]-1)];
				if(ab - aa == mt[i, 2])
				{
					wa += mt[i, 3];
				}
			}
			max = Math.Max(wa, max);
			return;
		}
		
		for(int i = mae; i <= m; i++)
		{
			t.Add(i);
			GetArray(t, ind+1, i, m, n);
			t.RemoveAt(t.Count - 1);
		}
		
		
		
	}
	
	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str, int offset = 0)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt() + offset;
		return r;
	}
}

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

int main() {
	int N;
	cin >> N;
	int x = 0;
	while(N != 0){
		x += N % 10;
		N /= 10;
	}
	if(x == 1){
		cout << 10 << endl;
		return 0;
	}
	cout << x << endl;
}

Measured memory_bytes: 256
num = list(map(int,input().split()))
num_list = list(map(int,input().split()))

sum = 0

for i in range(0,num[1]):
  sum = num_list[i] + sum
  
if sum >= num[0]:
  ans = "Yes"
elif sum < num[0]:
  ans = "No"
  
print(ans)

Measured memory_bytes: 13964
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstring>
#include <utility>
#include <numeric>

using namespace std;

int main(){

    int N;
    cin >> N;
    vector<pair<int, int>> TA(N);
    int t, a;
    for(int i = 0; i < N; i++){
        cin >> t >> a;
        TA[i] = make_pair(t, a);
    }

    long long T = TA[0].first;
    long long A = TA[0].second;
    for(int i = 1; i < N; i++){
        auto temp = TA[i];
        long long numT = (T + temp.first - 1) / temp.first;
        long long numA = (A + temp.second - 1) / temp.second;
        long long num = max(numT, numA);
        T = temp.first * num;
        A = temp.second * num;
    }

    cout << T + A << endl;

    return 0;
}

Measured memory_bytes: 256
$lines1 = []
$lines2 = []
loop{
	$lines1 = []
	$lines2 = []
	num = gets
	
	num = num.to_i()
	if num == 0 then
		break
	end

	lnum = gets.to_i()
	line = gets
	sp = line.split(nil)

	x = sp[0].to_i()
	y = sp[1].to_i()
	$lines1.push([0,0])
		
	for i in 1..lnum-1 do
		line = gets
		sp = line.split(nil)
		nx = sp[0].to_i() - x
		ny = sp[1].to_i() - y
		$lines1.push([nx,ny])
	end
	lx = $lines1[lnum-1][0]
	ly = $lines1[lnum-1][1]

	for pos in $lines1.reverse do
		$lines2.push([pos[0]-lx,pos[1]-ly]) 
	end

	for j in 1..num do
		llnum = gets.to_i()
		
		if llnum != lnum then
			for i in 1..llnum do
				a = gets
			end
			next;
		end
		line = gets
		sp = line.split(nil)
		x = sp[0].to_i()
		y = sp[1].to_i()
		flag = [[1,1],[1,1],[1,1],[1,1]]
		for i in 1..llnum-1 do
			line = gets
			sp = line.split(nil)
			nx = sp[0].to_i() - x
			ny = sp[1].to_i() - y
			if !($lines1[i][0] == nx and $lines1[i][1] == ny) then
				flag[0][0] = 0
			end
			if !($lines1[i][0] == -nx and $lines1[i][1] == -ny) then
				flag[1][0] = 0
			end
			if !($lines1[i][0] == ny and $lines1[i][1] == -nx) then
				flag[2][0] = 0
			end
			if !($lines1[i][0] == -ny and $lines1[i][1] == nx) then
				flag[3][0] = 0
			end
			
			if !($lines2[i][0] == nx and $lines2[i][1] == ny) then
				flag[0][1] = 0
			end
			if !($lines2[i][0] == -nx and $lines2[i][1] == -ny) then
				flag[1][1] = 0
			end
			if !($lines2[i][0] == ny and $lines2[i][1] == -nx) then
				flag[2][1] = 0
			end
			if !($lines2[i][0] == -ny and $lines2[i][1] == nx) then
				flag[3][1] = 0
			end
		end
		
		flag.each do |f1,f2|
			if f1 == 1 or f2 == 1 then
				print j
				print("\n")
			end
		end
	end
	print("+++++\n")
}

Measured memory_bytes: 6096
X, Y, Z, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)


# Priority QueueとしてHeapを使う
# Pythonのheapqは小さい順に取り出すので、-1を掛けて負数としてpushしていく
#   (-Ai-Bj-Ck, i, j, k)
# 取り出したi, j, kについて、(i+1, j, k), (i, j+1, k), (i, j, k+1)に対応するタプルをpushする
# ただし、すでにpushした値は入れないようにする

import heapq

def make(i, j, k):
    return (-A[i]-B[j]-C[k], i, j, k)


used = set()
l = []

heapq.heappush(l, make(0, 0, 0))
used.add((0, 0, 0))

for cnt in range(K):
    V, i, j, k = heapq.heappop(l)
    
    if i < X - 1 and (i+1, j, k) not in used:
        heapq.heappush(l, make(i+1, j, k))
        used.add((i+1, j, k))
    
    if j < Y - 1 and (i, j+1, k) not in used:
        heapq.heappush(l, make(i, j+1, k))
        used.add((i, j+1, k))
    
    if k < Z - 1 and (i, j, k+1) not in used:
        heapq.heappush(l, make(i, j, k+1))
        used.add((i, j, k+1))
    
    print(-V)




Measured memory_bytes: 4976
from itertools import accumulate
# -*- coding: utf-8 -*-
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N, C = map(int, input().split())
TV = dict()
programs = [list(map(int, input().split())) for _ in range(N)]
last_time = max([p[1] for p in programs])
for i in range(1, C+1):
    TV[i] = [0]*(last_time*2+2)

for s, t, c in programs:
    s *= 2
    t *= 2
    TV[c][s] += 1
    TV[c][t+1] -= 1

for c in range(1, C+1):
    TV[c] = list(accumulate(TV[c]))

ans = 0
for i in range(last_time*2+1):
    tmp = 0
    for c in range(1, C+1):
        if TV[c][i] > 0:
            tmp += 1
    ans = max(ans, tmp)
print(ans)


Measured memory_bytes: 77904
#include <stdio.h>

// 入力受付用の変数
#define BUF 200002
char str[BUF];

// 入力された値
int N, A, B;

void receive_input() {
	fgets(str, sizeof(str), stdin);
	sscanf(str, "%d %d %d", &N, &A, &B);
}

void solve() {
	if (N * A < B) {
		printf("%d\n", N*A);
	} else {
		printf("%d\n", B);
	}
}

int main(void) {
	receive_input();

	solve();

	return 0;
}


Measured memory_bytes: 128
n=int(input())
aa=[]
bb=[]
for _ in range(n):
  a,b=map(int,input().split())
  aa.append(a)
  bb.append(b)
aa.sort()
bb.sort()
if n%2==1:
  print(bb[n//2]-aa[n//2]+1)
else:
  am=aa[n//2]+aa[n//2-1]
  bm=bb[n//2]+bb[n//2-1]
  print(bm-am+1)

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

int main() {
	int a, b;
	char op;

	while (true) {
		cin >> a >> op >> b;
		if (op == '?')	break;
		else if (op == '+') cout << a + b << endl;
		else if (op == '-')	cout << a - b << endl;
		else if (op == '*')	cout << a * b << endl;
		else if (op == '/') cout << a / b << endl;
	}

	return 0;
}

Measured memory_bytes: 1164
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
using ll = long long;

using namespace std;

int main() {
    ll N;
    cin >> N;
    ll Tx,Ax;
    cin >> Tx >> Ax;
    for(ll i = 1; i < N; i++){
        ll T,A;
        cin >> T >> A;
        ll t = Tx / T;
        ll a = Ax / A;
        if(Tx % T != 0){
            t++;
        }
        if(Ax % A != 0){
            a++;
        }
        ll m = max(t,a);
        Tx = m * T;
        Ax = m * A;
        //cout << Tx << " " << Ax << endl;
    }
    cout << Tx + Ax << endl;
}

Measured memory_bytes: 256
package main

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

func main (){
  var n, a, b int
  var sum int
  sc := bufio.NewScanner(os.Stdin)
  var s string
  if sc.Scan(){
	s = sc.Text()
  }
  slice := strings.Split(s, " ")
  n,_ = strconv.Atoi(slice[0])
  a,_ = strconv.Atoi(slice[1])
  b,_ = strconv.Atoi(slice[2])
  var tmp, tmpSum int
  for i:=1; i<=n; i++ {
	tmp = i
	tmpSum = 0
	tmpSum = (tmp-tmp%10000)/10000

	tmp = tmp%10000
	tmpSum = tmpSum + (tmp-tmp%1000)/1000

	tmp = tmp%1000
	tmpSum = tmpSum + (tmp-tmp%100)/100

	tmp = tmp%100
	tmpSum = tmpSum + (tmp-tmp%10)/10

	tmpSum = tmpSum + tmp%10

	if tmpSum >= a{
	  if tmpSum <= b{
		sum = sum + i
	  }
	}
  }
  fmt.Println(sum)
}


Measured memory_bytes: 640
n, m = map(int, input().split())
a = [int(input()) for _ in range(m)]
MOD = 10**9+7
INF = MOD-1
dp = [INF]*(n+1)
dp[0] = dp[1] = 1

for x in a:
    dp[x] = 0

for i in range(2, n+1):
    if dp[i] == 0:
        continue
    dp[i] = (dp[i-1]+dp[i-2]) % MOD


print(dp[n] if dp[n] != INF else 0)

Measured memory_bytes: 7848
#include<bits/stdc++.h>
#define inf 0x3f3f3f3f
using namespace std;
const int N=55;
int n,x,d,v[N],w[N],m[N],fa[N],dp[N*N*N];
struct node
{
    int v,w,id;
    double k;
    node(int v=0,int w=0):v(v),w(w){k=1.0*v/w;}
    bool operator<(const node&o)const
    {
        return k>o.k;
    }
}a[N];
int main()
{
    scanf("%d%d%d",&n,&x,&d);
    scanf("%d",&m[1]);
    for(int i=2;i<=n;i++)
        scanf("%d%d",&m[i],&fa[i]);
    for(int i=n;i>=1;i--)
    {
        v[i]++;
        w[i]=min(w[i]+m[i],x+1);
        v[fa[i]]+=v[i];
        w[fa[i]]=min(w[fa[i]]+w[i],x+1);
    }
    for(int i=1;i<=n;i++)
        a[i]=node(v[i],w[i]),a[i].id=i;
    sort(a+1,a+1+n);
    int k=min(n,d);
    memset(dp,inf,sizeof(dp));
    dp[0]=0;
    for(int i=1;i<=n;i++)
        for(int j=1;j<=k;j++)
            for(int k=n*n*n;k>=v[i];k--)
            dp[k]=min(dp[k],dp[k-v[i]]+w[i]);
    int ans=0;
    for(int i=0;i<=n*n*n;i++)
    {
        if(dp[i]>x) continue;
        int y=x-dp[i],res=i;
        for(int j=1;j<=n;j++)
        {
            int tot=min(a[j].id==1?y/a[j].w:d-k,y/a[j].w);
            res+=tot*a[j].v;
            y-=tot*a[j].w;
        }
        ans=max(ans,res);
    }
    printf("%d\n",ans);
}


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

int main() {
	int N;
	int d[110];
	cin >> N;
	for (int i = 0; i < N; ++i) cin >> d[i];

	set<int> values; // insert するときに重複を取り除いてくれます
	for (int i = 0; i < N; ++i) {
		values.insert(d[i]); // 挿入します
	}

	// set のサイズを出力します
	cout << values.size() << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int a[4],b[2],i,j,temp;
  for(i=0;i<4;i++){
    scanf("%d",&a[i]);
  }
  for(i=0;i<2;i++){
    scanf("%d",&b[i]);
  }
  for(i=0;i<4;i++){
    for(j=0;j<3-i;j++){
      if(a[j]<a[j+1]){
	temp=a[j];
	a[j]=a[j+1];
	a[j+1]=temp;
      }
    }
  }
  if(b[0]<b[1]){
    b[0]=b[1];
  }
  printf("%d\n",a[0]+a[1]+a[2]+b[0]);
}

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

int main() {
  int num;
  int cntOne = 0;
  int cntTwo = 0;
  int cntFor = 0;
  string kekka = "No";
  
  cin >> num;
  vector<int> vec(num);
  vector<int> chk(num);
  
  int tmp;
  for(int i = 0; i < num; i++){
    cin >> tmp;
    vec.at(i) = tmp;
    
    if(tmp % 4 == 0){
      // 4の倍数
      vec.at(i) = 4;
      cntFor++;
    }else if(tmp % 2 == 0){
      // 2の倍数
      vec.at(i) = 2;
      cntTwo++;
    }else{
      // 1の倍数
      vec.at(i) = 1;
      cntOne++;
    }
  }
  
  if(cntTwo == 0){
    // 1と4  141 , 144 , 444
    // 4が一つ少ないか、4が同数以上ならおっけ
    if(cntOne <= cntFor+1) kekka = "Yes";
  }else{
    // 1,2,4 14222 
    // 1と4 が同数あればおっけ
    if(cntOne <= cntFor) kekka = "Yes";
  }
  
  cout << kekka;
}


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

int n[101];
int m;
int ans;
int N;

void func(int j,int k){
 if (j>k) {
  return;
 }
 else {
    ans++;
  if (n[(j+k)/2]<m) {
   func((j+k)/2+1,k);
  }
  else if (n[(j+k)/2]>m) {
   func(j,(j+k)/2-1);
  }
 }
 return;
}

 

int main(){
 
 while (1) {
  cin>>N;
  if (N==0) {
   break;
  }
  ans=0;
  for (int i=0; i<N; i++) {
   cin>>n[i];
  }
  cin>>m;
  func(0,N-1);
  cout << ans << endl;
 }
 
}

Measured memory_bytes: 0
#include<iostream>
using namespace std;
int n,ans=0;

void dfs(long long x,int a,int b,int c){
  if(x>n){
    return;
  }
  if(a&&b&&c)ans++;
    dfs(x*10+3,1,b,c);
    dfs(x*10+5,a,1,c);
    dfs(x*10+7,a,b,1);
}

int main(){
  cin>>n;
  dfs(0,0,0,0);
  cout<<ans<<endl;
}


Measured memory_bytes: 256
N = int(input())
S1 = list(input())
S2 = list(input())
MOD = 10**9 + 7

if S1[0] == S2[0]:
  ans = 3
  i = 1
else:
  ans = 6
  i = 2

while i < N:
  pre_s1, pre_s2 = S1[i-1], S2[i-1]
  s1, s2 = S1[i], S2[i]
  if pre_s1 == pre_s2:
    ans *= 2
    ans %= MOD
    if s1 == s2:
      i += 1
    else:
      i += 2
  else:
    if s1 == s2:
      i += 1
    else:
      ans *= 3
      ans %= MOD
      i += 2

print(ans)

Measured memory_bytes: 9212
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <array>
#include <vector>

using namespace std;

int main() {
  while ( true ) {
	int n;
	cin >> n;
	if ( n == 0 ) break;

	vector<int> accums( 30, 0 );
	vector<vector<int>> values( n, vector<int>() );
	vector<string> names( n );
	for ( int i = 0; i < n; i++ ) {
	  cin >> names[ i ];
	  int v;
	  cin >> v;
	  for ( int j = 0; j < v; j++ ) {
		int d;
		cin >> d;
		accums[ d ]++;
		values[ i ].push_back( d );
	  }
	}

	int min_index = -1;
	int min_val = 1000000;
	for ( int i = 0; i < n; i++ ) {
	  int score = 0;
	  for ( int v : values[ i ] ) {
		score += n - accums[ v ] + 1;
	  }
	  if ( score < min_val ||
		   ( score == min_val && names[ i ] < names[ min_index ] ) ) {
		min_index = i;
		min_val = score;
	  }
	}
	cout << min_val << " " << names[ min_index ] << endl;
  }
}

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


int main() {
  unsigned long long N, K;
  cin >> N >> K;
  unsigned long long M;
  if(N == 0) {
    cout << 0;
    return 0;
  }
  if(K == 0) {
    cout << N;
    return 0;
  }
  M = N / K;
  N = N - (M * K);
  while(1) {
    M = N;
    if(N >= K) N = N - K;
    if(N < K) N = K - N;
    if(N >= M) break;
  }
  cout << M;
}


Measured memory_bytes: 256
# 最大公約数
def gcd(a, b)
  a,b = b, a % b while b > 0
  a
end

# 最小公倍数
def lcm(a,b)
  a * b / gcd(a,b)
end

n = gets.chop.to_i

# ansは最小公倍数になる
ans = 1

n.times do |i|
  t = gets.chop.to_i

  ans = lcm(ans, t)
end

p ans


Measured memory_bytes: 1916
import sys
sys.setrecursionlimit(10**8)
N,M=map(int,input().split())
G1=[[] for i in range(N)]
G2=[[] for i in range(N)]
not_root=[False]*N
for i in range(N+M-1):
  a,b=map(int,input().split())
  G1[a-1].append(b-1)
  G2[b-1].append(a-1)
  not_root[b-1]=True
for i in range(N):
  if not not_root[i]:
    root=i
    break
Tree=[-2]*N
Tree[root]=-1
def dfs(x):
  for b in G1[x]:
    if Tree[b]>=-1:
      continue
    flag=0
    for a in G2[b]:
      if Tree[a]<-1:
        flag=1
        break
    if flag==0:
      Tree[b]=x
      dfs(b)
dfs(root)
for i in range(N):
  print(Tree[i]+1)
  

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

int get_digit(int num);

int main() {
	int first;
	int second;
	int data_cnt = 0;
	std::vector<int> inputs;

	while ((cin >> first >> second) /*|| (data_cnt < 200)*/) {
		data_cnt++;
		inputs.push_back(first + second);
	}

	for (int i = 0; i < data_cnt; i++) {
		cout << get_digit(inputs[i]) << endl;
	}

	return 0;
}

int get_digit(int num) {
	unsigned digit = 0;
	while (num != 0) {
		num /= 10;
		digit++;
	}
	return digit;
}

Measured memory_bytes: 3156
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ; //何もしない文
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size()) //unsignedのサイズをint型に変換
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    VI L(2*N);
    REP(i,2*N) cin>>L[i];

    sort(L.begin(),L.end(),greater<int>());


    LL ans = 0;
    REP(i,N)
    {
        int ta,tb;
        ta = 2*i; tb =ta+1;
        ans += L[tb];
    }
    cout << ans << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <cmath>
#include <queue>
#include <map>
using namespace std;

int main(){
    int k ;
    cin >> k ;
    if (k < 10)
    {
        cout << k << endl ;
        return 0 ;
    }
    int now = 9 ;
    queue<string> lunlun ;
    for (size_t i = 1; i < 10; i++)
    {
        string c = to_string(i) ;
        lunlun.push(c) ;
    }
    string ans ;
    while(now <= k){
        string st = lunlun.front() ;
        lunlun.pop() ;
        int last = st.at(st.size()-1) - '0' ;
        for (size_t i = 0; i < 3; i++)
        {
            if (last - 1 + i < 10 && 0 < last + i)
            {
                string d = to_string(last - 1 + i) ;
                string nst = st + d ;
                now ++ ;
                lunlun.push(nst) ;
                if (now == k)
                {
                    ans = nst ;
                }
            }
            
            
        }
        
    }

    cout << ans << endl ;
    
}

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

ll dp[100010][3];

int main(int argc, char **argv)
{
	ll N; cin >> N;
	vector<ll> A(N), B(N), C(N);
	for (ll i = 0; i < N; ++i) cin >> A[i] >> B[i] >> C[i];

	for (ll i = 0; i < N; ++i)
	{
		dp[i+1][0] = max(dp[i][1]+A[i], dp[i][2]+A[i]);
		dp[i+1][1] = max(dp[i][0]+B[i], dp[i][2]+B[i]);
		dp[i+1][2] = max(dp[i][0]+C[i], dp[i][1]+C[i]);
	}
	std::cout << max({dp[N][0], dp[N][1], dp[N][2]})<< std::endl;
}


Measured memory_bytes: 4992
sx, sy, tx, ty = map(int, input().split())

path1 = "U" * (ty - sy) + "R" * (tx - sx)
path2 = "D" * (ty - sy) + "L" * (tx - sx)
path3 = "L" + "U" * (ty - sy + 1) + "R" * (tx - sx + 1) + "D"
path4 = "R" + "D" * (ty - sy + 1) + "L" * (tx - sx + 1) + "U"

print(path1 + path2 + path3 + path4)

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<cmath>
#include<string>
#include<cstdlib>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define MOD 1000000007

using namespace std;
 
typedef long long int ll;

const ll INF=(ll)1e18;

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

    map<int, int> m;
    REP(i,N){
        int a;
        cin >> a;
        m[a]++;
    }
    vector<pair<int, int> > v;
    for(auto itr = m.begin(); itr != m.end(); itr++){
        v.push_back(make_pair(itr->second, itr->first));
    }
    sort(v.begin(), v.end());

    int ans = 0;
    if(v.size() > K){
        REP(i,v.size()-K){
            ans += v[i].first;
        }
    }

    cout << ans << endl;

}


Measured memory_bytes: 11768
n, m = list(map(int, input().split()))

d = {}
for i in range(m):
    p, y = list(map(int, input().split()))

    if p not in d:
        d[p] = [[y, i]]
    else:
        d[p].append([y, i])

for i in d:
    d[i].sort()

ans = {}
for i in d:
    for j in range(len(d[i])):
        ans[d[i][j][1]] = '{0:06d}'.format(i) + '{0:06d}'.format(j + 1)

for i in range(m):
    print(ans[i])

Measured memory_bytes: 56000
#include <bits/stdc++.h>
#ifdef TEST
#include <mytest.h>
#else
#define open(...) 0
#define print(...) 42
#endif
using namespace std;
const int N = 1e5 + 5;
typedef long long ll;
int a[N], dp[N];
int main() {
  ios::sync_with_stdio(false); cin.tie(0);
  ll n;
  cin >> n;
  cout << n * (n - 1) / 2 << endl;
}

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

#define M /* your task*/ 6700417
#define L 14

char H[M][L]; /* Hash Table */

int getChar(char ch)
{
    if (ch == 'A')
        return 1;
    else if (ch == 'C')
        return 2;
    else if (ch == 'G')
        return 3;
    else if (ch == 'T')
        return 4;
    return 0;
}

/* convert a string into an integer value */
long long getKey(char str[])
{
    long long sum = 0, p = 1, i;
    for (i = 0; i < strlen(str); i++)
    {
        sum += p * (getChar(str[i]));
        p *= 5;
    }
    return sum;
}

int h1(int key) { return /* your task */ key % M; }
int h2(int key) { return /* your task */ 1 + key % (M - 1); }

int find(char str[])
{
    /* your task */
    long long key, hash;
    long long i;
    key = getKey(str);

    for (i = 0;; i++)
    {
        hash = (h1(key) + i * h2(key)) % M;
        if (strcmp(H[hash], str) == 0)
            return 1;
        else if (strlen(H[hash]) == 0)
        {
            return 0;
        }
    }
    return 0;
}

int insert(char str[])
{
    /* your task */
    long long key, hash;
    long long i;
    key = getKey(str);

    for (i = 0;; i++)
    {
        hash = (h1(key) + i * h2(key)) % M;
        if (strcmp(H[hash], str) == 0)
            return 1;
        else if (strlen(H[hash]) == 0)
        {
            strcpy(H[hash], str);
            return 0;
        }
    }
    return 0;
}

int main()
{
    int i, n, h;
    char str[L], com[9];
    for (i = 0; i < M; i++)
        H[i][0] = '\0';

    scanf("%d", &n);

    for (i = 0; i < n; i++)
    {
        scanf("%s %s", com, str);

        if (com[0] == 'i')
        {
            insert(str);
        }
        else
        {
            if (find(str))
            {
                printf("yes\n");
            }
            else
            {
                printf("no\n");
            }
        }
    }

    return 0;
}



Measured memory_bytes: 93356