akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <random>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <sstream>
#include <bitset>
#include <cassert>
#include <fstream>
#include <queue>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
	#define DBG(X) cout << #X << "=" << (X) << endl;
#else
	#define DBG(X)
	#define endl '\n'
#endif
 
using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld  = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF  = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for(auto el: v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline void goodbye(const T& val) { cout << val << endl; exit(0); }

const int MAX_N = 577;

int answ[MAX_N][MAX_N], H, W, h, w;
vector<int> g[MAX_N];
int met[MAX_N];
int ord[MAX_N], ord_sz = 0;
int result[MAX_N];

void dfs(int v)
{
	met[v] = 1;

	for(auto& u: g[v])
	{
		if(!met[u])
			dfs(u);
	}

	ord[ord_sz++] = v;
}

void generate_sequence(int sz, int param)
{
	for(int i = 0; i + param <= sz; ++i)
		g[i + param].push_back(i);

	g[0].push_back(sz);

	for(int v = 0; v <= sz; ++v)
	{
		if(!met[v])
			dfs(v);
	}

	for(int j = ord_sz - 1; j >= 0; --j)
		result[ord[j]] = ord_sz - j;

	int temp = result[0];

	for(int v = 0; v <= sz; ++v)
		result[v] -= temp;

	for(int v = sz; v > 0; --v)
		result[v] -= result[v - 1];
}

void solve()
{
	cin >> H >> W >> h >> w;

	if(H % h == 0 && W % w == 0)
		goodbye("No");

	cout << "Yes" << endl;

	if(W % w != 0)
	{
		generate_sequence(W, w);

		for(int row = 0; row < H; ++row)
		{
			for(int col = 0; col < W; ++col)
				cout << result[col + 1] << " ";

			cout << endl;
		}
	}
	else
	{
		generate_sequence(H, h);

		for(int row = 0; row < H; ++row)
		{
			for(int col = 0; col < W; ++col)
				cout << result[row + 1] << " ";

			cout << endl;
		}
	}
}

int main()
{
	fast_io();
	solve();

	return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <string>
#include <unordered_map>
#include <math.h>
#include <algorithm>
#include <deque>
#include <queue>
#include <climits>
using namespace std;
#define rep(i,l,r) for(int i=l;i<r;i++)
#define repb(i,r,l) for(int i=r;i>l;i--)
#define ll long long
#define ull unsigned long long
#define ve vector
#define umap unordered_map
#define iter iterator
void solve() {
    int n,m;
    cin>>n>>m;
    ve<int> ar(51,0);
    for(int i=1;i<=m;i++) {
        int a,b;
        cin>>a>>b;
        ar[a]++;
        ar[b]++;
    }
    for(int i=1;i<=n;i++) {
        if(i<=n) {
            cout<<ar[i]<<endl;
        }
    }
}

int main() {
    solve();
    return 0;
}

Measured memory_bytes: 256
b,w = ["b"]*3,["w"]*3
t = range(3)
while 1:
	try:
		bw = [list(raw_input()) for i in t]
		ans = "NA"
		for i in range(3):
			if b == bw[i] or b == [bw[j][i] for j in t]: ans = "b"
			if w == bw[i] or w == [bw[j][i] for j in t]: ans = "w"
		if b == [bw[i][i] for i in t] or b == [bw[i][2-i] for i in t]: ans = "b"
		if w == [bw[i][i] for i in t] or w == [bw[i][2-i] for i in t]: ans = "w"
		print ans
	except:
		break

Measured memory_bytes: 4260
n, k = map(int, input().split())

MOD = 10 ** 9 + 7

ans = 0
for i in range(k, n + 2):
    ans += i * (2 * n - i + 1) // 2 - i * (i - 1) // 2 + 1
    ans %= MOD

print(ans)


Measured memory_bytes: 63528
/*input

*/
#include <bits/stdc++.h>

using namespace std;

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


#define FileIn(file) freopen(file, "r", stdin)
#define FileOut(file) freopen(file, "w", stdout)
#define syso(n) cout<<n<<endl;
#define sysom(message, n) cout<<message<<n<<endl;
#define all(c) c.begin(), c.end() 
#define tr(container, it) \
for(typeof(container.begin()) it = container.begin(); it != container.end(); it++) 
#define present(container, element) (container.find(element) != container.end())  //map, set
#define cpresent(container, element) (find(all(container),element) != container.end()) //vector
#define what_is(x) cout << #x << " is " << x << endl; 


ll gcd(ll a, ll b){
    if (b==0) return a;
    return gcd(b, a%b);
} 

ll lcm(ll fir, ll sec){
	return (fir*sec)/(gcd(fir, sec));
}


const int MOD = 1e9 + 7;
const string small_alphabets = "abcdefghijklmnopqrstuvwxyz";
const int month_days[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
// --
// -- 
// -- 
// std::cout << std::fixed;
// std::cout << std::setprecision(5) << f << '\n';


int main(){
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	if(a+b>c+d){
		syso("Left");
	}
	else if(a+b<c+d){
		syso("Right");
	}
	else{
		syso("Balanced");
	}
	return 0;
}


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

Measured memory_bytes: 3228
#include<cstdio>
#include<algorithm>
using namespace std;
int gi(){
	int x=0,w=1;char ch=getchar();
	while ((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
	if (ch=='-') w=0,ch=getchar();
	while (ch>='0'&&ch<='9') x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
	return w?x:-x;
}
const int N = 6e5+5;
const int mod = 924844033;
int n,to[N],nxt[N],head[N],cnt,sz[N],ans[N],tmp[N],rev[N],og[N],inv[N],jc[N],jcn[N];
void dfs(int u,int f){
	sz[u]=1;
	for (int e=head[u];e;e=nxt[e])
		if (to[e]!=f){
			dfs(to[e],u),sz[u]+=sz[to[e]];
			++ans[sz[to[e]]],++ans[n-sz[to[e]]];
		}
}
int fastpow(int a,int b){
	int res=1;
	while (b) {if (b&1) res=1ll*res*a%mod;a=1ll*a*a%mod;b>>=1;}
	return res;
}
void init(int len){
	int l=0;while (1<<l<len) ++l;
	for (int i=0;i<len;++i) rev[i]=(rev[i>>1]>>1)|((i&1)<<l-1);
}
void ntt(int *P,int op,int len){
	for (int i=0;i<len;++i) if (i<rev[i]) swap(P[i],P[rev[i]]);
	for (int i=1;i<len;i<<=1){
		int W=fastpow(5,(mod-1)/(i<<1));
		if (op==-1) W=fastpow(W,mod-2);
		og[0]=1;for (int j=1;j<i;++j) og[j]=1ll*og[j-1]*W%mod;
		for (int p=i<<1,j=0;j<len;j+=p)
			for (int k=0;k<i;++k){
				int x=P[j+k],y=1ll*P[j+k+i]*og[k]%mod;
				P[j+k]=(x+y)%mod,P[j+k+i]=(x-y+mod)%mod;
			}
	}
	if (op==-1) for (int i=0,Inv=fastpow(len,mod-2);i<len;++i) P[i]=1ll*P[i]*Inv%mod;
}
int main(){
	n=gi();inv[1]=jc[0]=jcn[0]=1;
	for (int i=2;i<=n;++i) inv[i]=1ll*inv[mod%i]*(mod-mod/i)%mod;
	for (int i=1;i<=n;++i) jc[i]=1ll*jc[i-1]*i%mod,jcn[i]=1ll*jcn[i-1]*inv[i]%mod;
	for (int i=1;i<n;++i){
		int u=gi(),v=gi();
		to[++cnt]=v;nxt[cnt]=head[u];head[u]=cnt;
		to[++cnt]=u;nxt[cnt]=head[v];head[v]=cnt;
	}
	dfs(1,0);int len=1;while (len<=n<<1) len<<=1;
	for (int i=1;i<=n;++i) ans[i]=1ll*ans[i]*jc[i]%mod,tmp[i]=jcn[n-i];
	init(len);ntt(ans,1,len);ntt(tmp,1,len);
	for (int i=0;i<len;++i) ans[i]=1ll*ans[i]*tmp[i]%mod;
	ntt(ans,-1,len);
	for (int i=1;i<=n;++i) printf("%lld\n",(1ll*n*jc[n]%mod*jcn[n-i]-ans[n+i]+mod)%mod*jcn[i]%mod);
	return 0;
}


Measured memory_bytes: 33792
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    string str;
    ll i,ans=0;
    cin>>str;
    for(i=0;i<str.length();i++){
        if(str[i]=='+')
            ans+=1;
        else
            ans-=1;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
X, K, D = map(int, input().split())

minimum_try = min(abs(X) // D, K)
tmp_goal = abs(abs(X) - minimum_try*D)

if (K-minimum_try)%2==0:
  res1 = tmp_goal
else:
  res1 = abs(tmp_goal-D)

minimum_try = min((abs(X) // D) + 1, K)
tmp_goal = abs(abs(X) - minimum_try*D)

if (K-minimum_try)%2==0:
  res2 = tmp_goal
else:
  res2 = abs(tmp_goal-D)

print(min(res1, res2))

Measured memory_bytes: 9204
#include <iostream>
#include <vector>
#include <queue>
#include <string>
#include <algorithm>
#include <cstring>

using namespace std;

// ツサツイツコツδ債づ個姪環づ個遷ツ暗堋表ツ．ツ姪環氾板債づ債，ツ湘」ツ，ツ債カツ，ツ青ウツ姪環，ツ可コツ，ツ右ツ，ツ背ツ姪環づ個渉．
char dice[6][4] = {
	{5,2,1,4}, {1,1,3,0}, {0,3,2,2},
	{2,5,4,1}, {4,4,0,3}, {3,0,5,5}
};

int main(){
	int step[6][6];
	memset(step, -1, sizeof(step));
	queue< pair<pair<int, int>, int> > qu;
	qu.push(make_pair(make_pair(0, 2), 0));
	qu.push(make_pair(make_pair(0, 5), 0));
	while(!qu.empty()){
		pair< pair<int,int>, int > p = qu.front(); qu.pop();
		int a = p.first.first, b = p.first.second, c = p.second;
		if(step[a][b] != -1) continue;
		step[a][b] = c;
		for(int i=0;i<4;i++)
			qu.push(make_pair(make_pair(dice[a][i], dice[b][i]), c+1));
	}
	string str[6][3];
	int conv[6] = {2, 4, 5, 1, 0, 3};
	int mask[3][3] = {
		{ 9, 1, 3},
		{ 8, 0, 2},
		{12, 4, 6}
	};
	int front[3] = {0, 1, 4};
	int back[3]  = {2, 3, 5};
	int up[3][4] = {
		{5, 1, 4, 3},
		{5, 2, 4, 0},
		{2, 1, 0, 3}
	};
	while(cin >> str[0][0]){
		if(str[0][0] == "#") break;
		cin >> str[0][1] >> str[0][2];
		for(int i=1;i<6;i++)
			for(int j=0;j<3;j++) cin >> str[i][i==5 ? 2-j : j];
		for(int i=0;i<2;i++)
			for(int j=0;j<3;j++) reverse(str[i][j].begin(), str[i][j].end());
		int ans = 1000000000;
		for(int i=0;i<3;i++){
			int mf = 0, mb = 0;
			for(int j=0;j<3;j++)
				for(int k=0;k<3;k++){
					if(str[front[i]][j][k] == '*') mf |= mask[j][k];
					if(str[back[i]][j][k]  == '*') mb |= mask[j][k];
				}
			int m = (mf&mb);
			for(int j=0;j<4;j++)
				if(m&(1<<j)){
					ans = min(ans, step[conv[up[i][j]]][conv[front[i]]]);
					ans = min(ans, step[conv[up[i][j]]][conv[back[i]]]);
				}
		}
		cout << ans << endl;
	}
}

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

#define ln '\n'
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for(int i = (a); i <= (int)(b); ++i)
#define FORR(i, a, b) for(int i = (a); i >= (int)(b); --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<P> VP;
typedef vector<PL> VPL;
typedef vector<string> VS;


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, p;
    cin >> a >> p;
    cout << (a * 3 + p) / 2 << ln;
    return 0;
}


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

int main(){
	ll n, m;
	cin>>n>>m;
	vector<ll> v;
	ll sum=0;
	for (ll i=0; i<n; i++){
		ll x;
		cin>>x;
		sum+=x;
		ll p=2;
		ll a=x; // 13 6 3 1
		ll b;
		while (a){
			b=x/p;
			v.push_back(a-b);
			a=b;
			p*=2;
		}
	}
	sort(v.begin(), v.end());
	reverse(v.begin(), v.end());
	ll dis=0;
	for (ll i=0; i<m && i<v.size(); i++)
		dis+=v[i];
	cout<<sum-dis;
	return 0;
}






Measured memory_bytes: 34788
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

vector<vector<int>> G;
int par[200010], dep[200010], ans[200010];

void dfs(int key){
	for(int i=0; i<G[key].size(); ++i){
		if(G[key][i]!=par[key]){
			par[G[key][i]]=key;
			dep[G[key][i]]=dep[key]+1;
			dfs(G[key][i]);
		}
	}
}

int main() {
	int N;
	cin >> N;
	G.resize(N+1);
	for(int i=1; i<N; ++i){
		int a, b;
		cin >> a >> b;
		G[a].emplace_back(b);
		G[b].emplace_back(a);
	}
	dep[1]=0;
	dfs(1);
	int od=0;
	for(int i=1; i<=N; ++i){
		od += dep[i]%2;
	}
	if(min(od, N-od)*3<=N){
		int xnow=3, ynow=1;
		for(int i=1; i<=N; ++i){
			if(dep[i]%2==(od*2<N ? 1 : 0)){
				ans[i]=xnow;
				xnow += 3;
			}else{
				ans[i]=ynow;
				if(ynow%3==0) ynow -= 3;
				else{
					ynow += ynow%3;
					if(ynow>N) ynow=(N/3)*3;
				}
			}
		}
	}else{
		int t=1, u=2, v=3;
		for(int i=1; i<=N; ++i){
			if(dep[i]%2==0){
				if(t<=N){
					ans[i]=t;
					t += 3;
				}else{
					ans[i]=v;
					v += 3;
				}
			}else{
				if(u<=N){
					ans[i]=u;
					u += 3;
				}else{
					ans[i]=v;
					v += 3;
				}
			}
		}
	}
	cout << ans[1];
	for(int i=2; i<=N; ++i) cout << ' ' << ans[i];
	cout << endl;
	return 0;
}

Measured memory_bytes: 18560
#include<bits/stdc++.h>
 
using namespace std;
 
int main()
{
    int w,h,x,y;
    scanf("%d%d%d%d", &w,&h,&x,&y);

    bool able=false;
    if(w==x*2 && h==y*2) able=true;     
    printf("%.9lf %d\n",(double)w*(double)h/2, able);
}

Measured memory_bytes: 256
fun main(args : Array<String>) {
    val (n, k) = readLine()!!.split(" ").map { it.toInt() }
    val aa = readLine()!!.split(" ").map { it.toInt() }.groupBy { it }.entries.sortedBy { it.value.size }

    var cnt = 0
    aa.take(Math.max(0, aa.size-k)).forEach {
        cnt += it.value.size
    }

    println(cnt)
}

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

main() {
    string S; cin >> S;
    rep(i,5){
        cout << S[i];
    }
    cout << " ";
    for(int i=6;i<13;i++){
        cout << S[i];
    }
    cout << " ";
    for(int i=14;i<S.size();i++){
        cout << S[i];
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
// ========================================================================================================
// Library
// ========================================================================================================
#define _CRT_SECURE_NO_WARNINGS

#include <bits/stdc++.h>
using namespace std;

// competitive macro
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b) - 1; i >= (a); i--)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i ,n) for (int i = (n) - 1; i >= 0; i--)
#define LL long long
#define ULL unsigned long long


void fastIOS()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
}
// ========================================================================================================
// ========================================================================================================

int main()
{
	fastIOS();

    int n; cin >> n;
    int indexMax = -1;
    int max1 = -1 , max2 = -1;
    
    for(int i = 0; i< n; i++)
    {
        int tmp; cin >> tmp;
        
        if(tmp > max1)
        {
            max2 = max1;
            max1 = tmp;
            indexMax = i;
        }
        
        else if(tmp > max2)
        {
            max2 = tmp;
        }
    }
    
    for(int i = 0; i< n; i++)
    {
        if(i != indexMax)
        {
            cout << max1 << endl;
        }
        else{
            cout << max2 << endl;
        }
    }
    
    return 0;
}

Measured memory_bytes: 1664
#include <cstdio>
#include <cstring>
char s[100001];int n,k;int f[111][11][2];
int dfs(int cur,int cnt,bool lim)
{
	if(cnt>k)return f[cur][cnt][lim]=0;
	if(~f[cur][cnt][lim])return f[cur][cnt][lim];
	if(cur==n+1)return f[cur][cnt][lim]=(cnt==k);int ans=0;
	for(int i=0;i<=(lim?s[cur]-'0':9);++i)ans+=dfs(cur+1,cnt+!!i,lim&&i==s[cur]-'0');return f[cur][cnt][lim]=ans;
}
int main()
{
	scanf("%s%d",s+1,&k);n=strlen(s+1);memset(f,-1,sizeof(f));
	printf("%d\n",dfs(1,0,true));return 0;
}

Measured memory_bytes: 128
import math
a, b, x = list(map(int, input().split()))
capa = a * a * b
if capa / 2 < x:
    l = ( 2 * (capa - x) ) / (a*a)
    print(math.degrees(math.atan(l/a)))
    exit()
else:
    l = (2 * x) / (b * a)
    print(math.degrees(math.atan(b/l)))
    exit()

Measured memory_bytes: 3060
N,M = map(int,input().split())

class Bellman_Ford(object):
	"""
	ベルマンフォード法, O(EV)
	ステータス:distance(list),prev(list),length(int)
	edge=[i, j, cost] のリスト
	"""
	def __init__(self, edge, start, length):
		self.start=start
		self.length=length
		self.distance=[float("inf") for x in range(self.length)]
		self.distance[start]=0
		self.prev=[0 for x in range(self.length)]
		self.prev[start]=-1
		self.solvable=True
		def update():
			for i in edge:
				d=self.distance[i[0]]+i[2]
				if d<self.distance[i[1]]:
					self.distance[i[1]]=d 
					self.prev[i[1]]=i[0]
		for i in range(length-1):
			update()
		memo=self.distance[-1]
		for i in range(length-1):
			update()
		if memo!=self.distance[-1]:
			self.solvable=False

	def route(self,goal):
		route=[]
		while(True):
			route.append(self.prev[goal])
			goal=self.prev[goal]
			if goal==self.start:
				break
		route.reverse()
		return(route)

edges = []
for i in range(M):
	a,b,c = map(int,input().split())
	edges.append([a-1,b-1,-c])

B = Bellman_Ford(edges,0,N)
if (not B.solvable):
	print("inf")
else:
	print(-B.distance[-1])
















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

using namespace std;
using ll = long long;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define INF 9223372036854775807
#define all(x) (x).begin(), (x).end()

ll ts = 1000000007;

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

  string day[7] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"}, s;
  cin >> s;

  REP(i, 7) {
    if (s == day[i]) {
      cout << 7 - i << "\n";
    }
  }
}

Measured memory_bytes: 256
import std.stdio;
import std.algorithm;
import std.string;
import std.range;
import std.array;
import std.conv;
import std.complex;
import std.math;
import std.ascii;
import std.bigint;
import std.container;
import std.typecons;

auto readInts() {
	return array(map!(to!int)(readln().strip().split()));
}
auto readInt() {
	return readInts()[0];
}
auto readLongs() {
	return array(map!(to!long)(readln().strip().split()));
}
auto readLong() {
	return readLongs()[0];
}

const real eps = 1e-10;

void main(){
	auto dp = new int[1001][1001];
	for(int i = 1; i <= 1000; ++i) {
		for(int j = i; j <= 1000; ++j) {
			dp[i][j] = dp[i][j-1] + j;
		}
	}
	auto l = new int[1000001];
	for(int i; i <= 1000; ++i) {
		for(int j; j <= 1000; ++j) {
			++l[dp[i][j]];
		}
	}
	while(true) {
		auto N = readInt();
		if(N == 0) {
			return;
		}
		writeln(l[N]-1);
	}
}

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

using namespace std;
typedef long long ll;

#define rep(i, N) for (int i = 0; i < (int)N; i++)
const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;


int main() {
  int N; cin >> N;
  int d[N]={}; rep(i,N) { int a; cin >> a; d[a]++; }

  string result = "Impossible";
  int l = 0; while(d[l]==0) l++;
  int r = N-1; while(d[r]==0) r--;
  if ((r+1)/2==l) {
    result = "Possible";
    for (int i=l; i<=r; i++) {
      if (i==l) { if (d[i]!=r%2+1)  { result = "Impossible"; break; } }
      else { if (d[i]<=1) { result = "Impossible"; break; } }
    }
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
fun main(args:Array<String>) {
    val (m,d) = readLine()!!.split(" ").map { it.toInt() }
    var ans  = 0
    for(i in (1..m)) {
        for(j in (10..d)) {
            val d1 = j%10
            val d2 = j/10
            if(d1 < 2 || d2 < 2) {
                continue
            }
            if(d1*d2 == i) {
                ans++
            }
        }
    }
    println(ans)
}


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

#ifdef NON_SUBMIT
#define TEST(n) (n)
#define tout cerr
#else
#define TEST(n) ((void)0)
#define tout cin
#endif

using namespace std;

const int MOD=998244353;
int W[1000001], sum[1000001], res[1000000];

long long fast_pow(long long a, long long b)
{
	long long ret=1;
	for(;b;b>>=1) {
		if(b&1) ret=(ret*a)%MOD;
		a=(a*a)%MOD;
	}
	return ret;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	TEST(freopen("input.txt","r",stdin));
	TEST(freopen("output.txt","w",stdout));
	TEST(freopen("debug.txt","w",stderr));
	int N, ans=0;
	cin>>N;
	for(int i=1;i<=1000000;i++) {
		W[i]=(W[i]+fast_pow(i,MOD-2))%MOD;
		for(int j=2*i;j<=1000000;j+=i) W[j]=(W[j]+MOD-W[i])%MOD;
	}
	while(N--) {
		int a;
		cin>>a;
		for(int i=1;i*i<=a;i++) if(a%i==0) {
			res[i]=(res[i]+1LL*sum[i]*a)%MOD;
			sum[i]=(sum[i]+a)%MOD;
			if(i*i!=a) {
				res[a/i]=(res[a/i]+1LL*sum[a/i]*a)%MOD;
				sum[a/i]=(sum[a/i]+a)%MOD;
			}
		}
	}
	for(int i=1;i<=1000000;i++) ans=(ans+1LL*W[i]*res[i])%MOD;
	cout<<ans<<'\n';
	return 0;
}

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

const int64 mod = 1e9+7;

using Row = vector<int64>;
using Mat = vector<Row>;

double dp[301][301][301] = {};
double pro[301][301][301] = {};

int main(void){
	int64 N;
	cin >> N;
	vector<int64> a(N);
	int32 cnt[4] = {};
	REP(i, N){
		cin >> a[i];
		cnt[a[i]] += 1;
	}
	dp[cnt[1]][cnt[2]][cnt[3]] = 0;
	pro[cnt[1]][cnt[2]][cnt[3]] = 1;
	for(int32 thr = cnt[3];thr >= 0;thr--){
		for(int32 two = cnt[2]+cnt[3]-thr;two >= 0;two--){
			for(int32 one = cnt[1]+cnt[2]+cnt[3]-thr-two;one >= 0;one--){
				dp[one][two][thr] /= pro[one][two][thr];
				double empty = N-one-two-thr;
				double o = one, tw = two, th = thr;
				double cnt = (double)N/(o+tw+th);
				double npro = pro[one][two][thr]/(o+tw+th);
				if(one){
					dp[one-1][two][thr] += (dp[one][two][thr]+cnt)*pro[one][two][thr]*o/(o+tw+th);
					pro[one-1][two][thr] += npro*o;
				}
				if(two){
					dp[one+1][two-1][thr] += (dp[one][two][thr]+cnt)*npro*tw;
					pro[one+1][two-1][thr] += npro*tw;
				}
				if(thr){
					dp[one][two+1][thr-1] += (dp[one][two][thr]+cnt)*npro*th;
					pro[one][two+1][thr-1] += npro*th;
				}
			}
		}
	}
	cout << fixed << setprecision(10) << dp[0][0][0]/(double)pro[0][0][0] << endl;
}


Measured memory_bytes: 426240
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double pi=3.141592653589793;
typedef unsigned long long ull;
typedef long double ldouble;
const ll INF=1e18;

vector<int> cost(1000000);
vector<vector<int>> data(1000000);


int main(){
    int n, k;
    cin >> n >> k;
    vector<int> p(n);
    for(int i = 0; i < n; i++){
        cin >> p.at(i);
    }
    sort(p.begin(), p.end());
    int answer = 0;
    for(int i = 0; i < k; i++){
        answer += p.at(i);
    }
    cout << answer << endl;
}

Measured memory_bytes: 30516
//Do what you can't.
import java.io.*;
import java.util.*;

public class Main {

  public static void main(String[] args) {
    InputReader in = new InputReader(System.in);
    PrintWriter w = new PrintWriter(System.out);
    String a=in.readString();
    String b=in.readString();
    String c=in.readString();
    if (a.charAt(a.length()-1)==b.charAt(0) && b.charAt(b.length()-1)==c.charAt(0))
      w.println("YES");
    else
      w.println("NO");
    w.close();
    }
  static class InputReader {

    private final InputStream stream;
    private final byte[] buf = new byte[8192];
    private int curChar, snumChars;
    private SpaceCharFilter filter;

    public InputReader(InputStream stream) {
      this.stream = stream;
    }

    public int snext() {
      if (snumChars == -1)
      throw new InputMismatchException();
      if (curChar >= snumChars) {
        curChar = 0;
        try {
          snumChars = stream.read(buf);
        } catch (IOException e) {
          throw new InputMismatchException();
        }
        if (snumChars <= 0)
        return -1;
      }
      return buf[curChar++];
    }

    public int nextInt() {
      int c = snext();
      while (isSpaceChar(c)) {
        c = snext();
      }
      int sgn = 1;
      if (c == '-') {
        sgn = -1;
        c = snext();
      }
      int res = 0;
      do {
        if (c < '0' || c > '9')
        throw new InputMismatchException();
        res *= 10;
        res += c - '0';
        c = snext();
      } while (!isSpaceChar(c));
      return res * sgn;
    }

    public long nextLong() {
      int c = snext();
      while (isSpaceChar(c)) {
        c = snext();
      }
      int sgn = 1;
      if (c == '-') {
        sgn = -1;
        c = snext();
      }
      long res = 0;
      do {
        if (c < '0' || c > '9')
        throw new InputMismatchException();
        res *= 10;
        res += c - '0';
        c = snext();
      } while (!isSpaceChar(c));
      return res * sgn;
    }

    public int[] nextIntArray(int n) {
      int a[] = new int[n];
      for (int i = 0; i < n; i++) {
        a[i] = nextInt();
      }
      return a;
    }

    public String readString() {
      int c = snext();
      while (isSpaceChar(c)) {
        c = snext();
      }
      StringBuilder res = new StringBuilder();
      do {
        res.appendCodePoint(c);
        c = snext();
      } while (!isSpaceChar(c));
      return res.toString();
    }

    public String nextLine() {
      int c = snext();
      while (isSpaceChar(c))
      c = snext();
      StringBuilder res = new StringBuilder();
      do {
        res.appendCodePoint(c);
        c = snext();
      } while (!isEndOfLine(c));
      return res.toString();
    }

    public boolean isSpaceChar(int c) {
      if (filter != null)
      return filter.isSpaceChar(c);
      return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

    private boolean isEndOfLine(int c) {
      return c == '\n' || c == '\r' || c == -1;
    }

    public interface SpaceCharFilter {
      public boolean isSpaceChar(int ch);
    }
  }
}


Measured memory_bytes: 22996
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.IntStream;
 
public class Main{
	static IntStream REPS(int v){return IntStream.range(0,v);}
	static IntStream REPS(int l,int r){return IntStream.rangeClosed(l,r);}
	static IntStream INS(int n) {return REPS(n).map(i->getInt());}
	static Scanner s=new Scanner(System.in);
	static int getInt(){return Integer.parseInt(s.next());}
 
	public static void main(String[]$){
		int n=getInt(),m=getInt(),R=getInt();
		int[]r=INS(R).sorted().toArray();
		int[][]f=new int[n][n];
		for(int i=0;i<n;++i) {
			Arrays.fill(f[i],114514191);
			f[i][i]=0;
		}
		for(int i=0;i<m;++i) {
			int a=getInt()-1,b=getInt()-1,c=getInt();
			f[a][b]=c;
			f[b][a]=c;
		}
 
		for(int d=0;d<n;++d) {
			for(int i=0;i<n;++i) {
				for(int j=0;j<n;++j) {
					f[i][j]=Math.min(f[i][j],f[i][d]+f[d][j]);
				}
			}
		}
		//Arrays.stream(f).map(Arrays::toString).forEach(System.out::println);
		int res=Integer.MAX_VALUE;
		do {
			int buf=0;
			for(int i=1;i<R;++i) {
				buf+=f[r[i]-1][r[i-1]-1];
			}
			res=Math.min(res,buf);
		}while((r=nextPermutation(r))!=null);
		System.out.println(res);
	}
	private static int[] nextPermutation(int[] c){
		int first=getFirst(c);
		if(first==-1) return null;
		int toSwap=c.length-1;
		while(c[first]>=c[toSwap])
			--toSwap;
		swap(c,first++,toSwap);
		toSwap=c.length-1;
		while(first<toSwap)
			swap(c,first++,toSwap--);
		return c;
	}
	private static int getFirst(int[] c){
		for(int i=c.length-2;i>=0;--i)
			if(c[i]<c[i+1])
				return i;
		return -1;
	}
	private static void swap(int[] c,int i,int j){
		int tmp=c[i];
		c[i]=c[j];
		c[j]=tmp;
	}
}

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

int main() {
  string S; cin >> S;
  int N = S.length();
  bool used[26] = {};
  for (int i = 0; i < N; ++i) used[S[i] - 'a'] = true;
  if (S.length() == 26) {
    for (int i = N - 1; i > 0; --i) {
      used[S[i] - 'a'] = false;
      if (S[i - 1] < S[i]) {
        S.erase(begin(S) + i, end(S));
        char c = S.back(); S.pop_back();
        for (int j = c - 'a' + 1; j < 26; ++j) {
          if (!used[j]) {
            S += 'a' + j;
            break;
          }
        }
        cout << S << endl;
        return 0;
      }
    }
    cout << -1 << endl;
  } else {
    for (int i = 0; i < 26; ++i) {
      if (!used[i]) {
        S += 'a' + i;
        break;
      }
    }
    cout << S << endl;
  }
  return 0;
}


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

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintStream out = new PrintStream(System.out);

        StringBuffer str;
        String S_a, S_b, S_c, Sr_a, Sr_b, Sr_c;
        char card;

        S_a = sc.nextLine();
        S_b = sc.nextLine();
        S_c = sc.nextLine();

        str = new StringBuffer(S_a);
        Sr_a = str.reverse().toString();

        str = new StringBuffer(S_b);
        Sr_b = str.reverse().toString();

        str = new StringBuffer(S_c);
        Sr_c = str.reverse().toString();

        card = Sr_a.charAt(Sr_a.length()-1);
        Sr_a = Sr_a.substring(0, Sr_a.length() -1 );
        
        while (!Sr_a.isEmpty() || !Sr_b.isEmpty() || !Sr_c.isEmpty()) {
            if(card == 'a') {
                if(Sr_a.isEmpty()) break;

                card = Sr_a.charAt(Sr_a.length()-1);
                Sr_a = Sr_a.substring(0, Sr_a.length() -1 );

                
                continue;
            } else if(card == 'b') {
                if(Sr_b.isEmpty()) break;

                card = Sr_b.charAt(Sr_b.length()-1);
                Sr_b = Sr_b.substring(0, Sr_b.length() -1 );

                continue;
            } else if(card == 'c') {
                if(Sr_c.isEmpty()) break;

                card = Sr_c.charAt(Sr_c.length()-1);
                Sr_c = Sr_c.substring(0, Sr_c.length() -1 );

                continue;
            }
        }

        card -= 32;
        out.println(Character.toString(card));
        
        
        sc.close();
    }
}

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


int main() {

    int h, w;
    cin >> h >> w;
    char board[60][60];
    for (int i = 0; i < h; ++i) {
        cin >> board[i];
    }
    bool ans = true;
    int dx[4] = {1, -1, 0, 0};
    int dy[4] = {0, 0, 1, -1};
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            if (board[i][j]=='#') {
                bool found = false;
                for (int k = 0; k < 4; ++k) {
                    int in = i + dx[k];
                    int jn = j + dy[k];
                    if (0 <= in && in <= h && 0 <= jn && jn <= w && board[in][jn]=='#') {
                        found = true;
                    }
                }
                if (!found) ans = false;
            }
        }
    }
    
    cout << (ans ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
using namespace std;

int main() {
	int n,k;
	cin >> n >> k;
	
	int a=1;
	for(int i=0; i<n; i++){
		a=min(a*2,a+k);	
	}
	cout << a << endl;
	return 0;
}

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

using namespace std;

int n, field, players[10];

void do_s(int num)
{
  field += players[num] + 1;
  players[num] = 0;
}

void do_m(int num)
{
  players[num]++;
}

void do_l(int num)
{
  players[num] += field + 1;
  field = 0;
}


int main()
{
  while(true)
  {
    field = 0;
    for(int i = 0; i < 10; i++)
      players[i] = 0;
    cin >> n;

    if(!n)
      break;

    for(int turn = 0; turn < 100; turn++)
    {
      char c;
      cin >> c;
      switch(c)
      {
        case 'S':
          do_s(turn % n); break;
        case 'M':
          do_m(turn % n); break;
        case 'L':
          do_l(turn % n); break;
      }
    }
    sort(players, players + n);
    for(int i = 0; i < n; i++)
      cout << players[i] << " ";
    cout << field << endl;
  }
}

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

using namespace std;

int main() {
  string a, b;
  cin >> a >> b;
  if(a.size() < b.size()) swap(a, b);
  for(int i = 0; i < a.size(); i++) {
    cout << a[i];
    if(i < b.size()) cout << b[i];
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <map>
#include <algorithm>
#include <vector>

using namespace std;

int main(void)
{
	vector< pair<unsigned long,unsigned long> > team;

	unsigned long n;

	while( cin >> n && n != 0 ){
		team.clear();
		for( long i = 0;i < n;i++ ){
			unsigned long sum = 0;;
			unsigned long m,s;
			unsigned long number;

			cin >> number;

			for( long j = 0;j < 4;j++ ){
				cin >> m >> s;
				sum += m * 60 + s;
			}
			team.push_back( pair<unsigned long, unsigned long>( sum, number ) );
		}

		sort( team.begin(), team.end() );

		for( long i = 0;i < 2;i++ ){
			cout << team[i].second << endl;
		}
		cout << team[n - 2].second << endl;
	}

	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

ll a[100010];
ll b[100010];
int main() {
	string s;
	cin>>s;
	ll sum=0;
	for(int i=0;i<s.size();i++){
		if(s[i]=='R'){
			sum++;
			continue;
		}
		a[i-1]=sum;
		sum=0;
	}
	for(int i=s.size()-1;i>=0;i--){
		if(s[i]=='L'){
			sum++;
			continue;
		}
		if(s[i+1]=='L'){
		a[i+1]=sum;
		sum=0;
		}
	}
	for(int i=0;i<s.size()-1;i++){
		if(a[i]!=0){
			b[i]=(a[i]+2-1)/2+a[i+1]/2;
			b[i+1]=a[i]/2+(a[i+1]+2-1)/2;
			i++;
		}
	}
	for(int i=0;i<s.size();i++){
		cout << b[i]<<" ";
	}
	// your code goes here
	return 0;
}

Measured memory_bytes: 2176
import sys
def input(): return sys.stdin.readline().strip()
mod = 10**9+7

def main():
    N = int(input())

    """
    ダメワードは
        ACG, AGC, GAC, AxGC, AGxC (xはワイルドカード)
    なので、後ろ３文字を見ながらdpすればよさげ
    """

    char = ['A', 'C', 'G', 'T']
    NG1 = {"ACG", "AGC", "GAC"}
    NG2 = {"AAGC", "ACGC", "AGGC", "ATGC", "AGAC", "AGCG", "AGGC", "AGTC"}
    key = []
    for x in char:
        for y in char:
            for z in char:
                word = x + y + z
                if word not in NG1:
                    key.append(word)
    
    zeros = [0] * len(key)
    ones = [1] * len(key)
    d = dict(zip(key, ones))
    
    for _ in range(N - 3):
        d2 = dict(zip(key, zeros))
        for word in d:
            x, y, z = list(word)
            for w in char:
                if (y + z + w not in NG1) and (x + y + z + w not in NG2):
                    d2[y + z + w] += d[x + y + z]
                    d2[y + z + w] %= mod
        d = d2
    
    ans = 0
    for word in d:
        ans += d[word]
        ans %= mod
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 40432
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
   int x,y;
   while(cin>>x>>y,x||y){
        int field[50][50];
        for(int i=1;i<=y;i++)
            for(int j=1;j<=x;j++)
                cin>>field[i][j];

        int dp[50][50]={{0}};
        for(int i=1;i<=x;i++)dp[1][i]=1;
        for(int i=1;i<=y;i++){
            for(int j=1;j<=x;j++){
                if(field[i][j]==1){
                    dp[i][j]=0;
                    continue;
                }
                if(i==y)continue;
                if(field[i][j]==2){
                    int to=i+2;
                    dp[to][j]+=dp[i][j];
                    continue;
                }
                if(field[i+1][j+1]!=2)dp[i+1][j+1]+=dp[i][j];
                if(field[i+1][j-1]!=2)dp[i+1][j-1]+=dp[i][j];
                dp[i+1][j]+=dp[i][j];
            }
        }
        int sum=0;
        for(int i=1;i<=x;i++)sum+=dp[y][i]+dp[y+1][i];
        cout<<sum<<endl;

   }
}

Measured memory_bytes: 1184
import sys
A=int(input())
H=list(map(int,input().split()))
if A==1:
    print('Yes')
    sys.exit()
if H[0]==H[1]+1:
        H[0]-=1
elif H[0]>=H[1]+2:
        print('No')
        sys.exit()
for i in range(1,A-1):
    if H[i]==H[i+1]+1 and H[i]==H[i-1]:
        print('No')
        sys.exit()
    elif H[i]==H[i+1]+1 and H[i]>H[i-1]:
        H[i]-=1
    elif H[i]==H[i+1] and H[i]>H[i-1]:
        H[i]-=1
    elif H[i]>=H[i+1]+2:
        print('No')
        sys.exit()
print('Yes')

Measured memory_bytes: 14480
#include <algorithm>
#include <cassert>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <list>

using std::list;
using std::max;
using std::min;
using std::vector;

int compute_s(int n)
{
  int result = 0;
  while(0 < n) {
    result += n % 10;
    n = n / 10;
  }
  return result;
}

int main()
{
  int n;
  scanf("%d", &n);
  if(n % compute_s(n) == 0) {
    puts("Yes");
  } else {
    puts("No");
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <queue>
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cassert>
#include <cctype>  // std::islower(), std::isupper(), std::tolower, std::toupper
#include <iomanip> // std::std::setprecision(X)
#include <limits>  //std::numeric_limits<int>::max(), min()

typedef long long ll;

int main (void) {

  std::string S; std::cin >> S;

  if ( S[0] != 'A' ) {
    std::cout << "WA" << std::endl;
    return 0;
  }

  int cntC = 0;
  for(int i=1; i<S.size(); i++) {
    if ( i>=2 && i<=S.size()-2 && S[i] == 'C' ) cntC++;
    else if ( std::isupper(S[i]) ) {
      std::cout << "WA" << std::endl;
      return 0;
    }
  }
  if ( cntC != 1 ) std::cout << "WA" << std::endl;
  else std::cout << "AC" << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <bitset>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <queue>

#define mp make_pair
#define pb push_back


typedef long long ll;
typedef long double ld;

using namespace std;

vector<int> c[500];
int n;
ll cnk[500][5];
map<vector<int>, int > mm;
ll fc[5];

void init() {
	fc[0] = 1;
	fc[1] = 1;
	fc[2] = 2;
	fc[3] = 6;
	fc[4] = 24;
	for (int n = 0; n < 500; ++n)
		for (int k = 0; k < 5; ++k) {
			if (n == k || k == 0)
				cnk[n][k] = 1;
			else if (n < k)
				cnk[n][k] = 0;
			else
				cnk[n][k] = cnk[n - 1][k] + cnk[n - 1][k - 1];
		}
}

int mlt(vector<int> vv) {
	vector<int> vv2 = vv;
	int cnt = 0;
	for (int i = 0; i < 4; ++i) {
		rotate(vv2.begin(), vv2.begin() + 1, vv2.end());
		if (vv2 == vv)
			++cnt;
	}
	return cnt;
}

vector<int> srt(vector<int> vv) {
	vector<int> vv2 = vv;
	for (int i = 0; i < 4; ++i) {
		rotate(vv2.begin(), vv2.begin() + 1, vv2.end());
		if (vv2 < vv)
			vv = vv2;
	}
	return vv;
}

void del(int x) {
	--mm[c[x]];
}

void add(int x) {
	++mm[c[x]];
}



int main() {
	init();
	cin >> n;
	for (int j = 0; j < n; ++j)
		c[j].resize(4);
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < 4; ++j)
			cin >> c[i][j];
	}
	ll ans = 0;
	for (int i = 0; i < n; ++i)
		c[i] = srt(c[i]);
	for (int i = 0; i < n; ++i)
		add(i);
	for (int i = 0; i < n; ++i) {
		del(i);
		for (int j = i + 1; j < n; ++j) {
			del(j);
			for (int it = 0; it < 4; ++it) {
				rotate(c[i].begin(), c[i].begin() + 1, c[i].end());
				vector<vector<int> > vv;
				vv.push_back({c[i][0], c[j][1], c[j][0], c[i][1]});
				vv.push_back({c[i][3], c[j][2], c[j][1], c[i][0]});
				vv.push_back({c[i][2], c[j][3], c[j][2], c[i][3]});
				vv.push_back({c[i][1], c[j][0], c[j][3], c[i][2]});
				for (int k = 0; k < 4; ++k)
					vv[k] = srt(vv[k]);
				vector<int> was(4, 0);
				ll ml = 1;
				for (int k = 0; k < 4; ++k) {
					if (!was[k]) {
						int cnt = 0;
						for (int k1 = 0; k1 < 4; ++k1)
							if (vv[k] == vv[k1])
								++cnt, was[k1] = 1;
						ml *= cnk[mm[vv[k]]][cnt] * fc[cnt];
					}
					ml *= mlt(vv[k]);
				}
				ans += ml;
			}
			add(j);
		}
	}
	cout << ans << "\n";
	return 0;
}




Measured memory_bytes: 140032
#include<iostream>
int main() {
	int n,a,num,max,min;
	long total=0;
	a=1;
	max=-1000001;
	min=1000001;
	std::cin >> n;
	while (a<=n){
		std::cin >> num;
		if(max<num){
			max=num;
		}
		if(min>num){
			min=num;
		}
		total=total+num;
		a++;
	}
	if (a>n){
		std::cout << min << " " << max << " " << total << std::endl;
	}
	return 0;
}


Measured memory_bytes: 3116
#include<cstdio>
#include<iostream>
#include<string>
using namespace std;
int main(){
    string s;
    string p;
    int p_leg=0;
    int flag =0;
    int j=0;
    getline(cin,s);
    getline(cin,p);
    s += s;
    for(int i=0;i<s.size();i++){
     if(s[i] == p[p_leg]){
         j = i;
         while(s[j] == p[p_leg]){
             j +=1;
             p_leg +=1;
             if(s[j] !=p[p_leg]){
                 p_leg =0;
             }
        if(p_leg == p.size()-1) flag =1;
         }
     }
    }
    if(flag == 1)printf("Yes\n");
    else printf("No\n");
    return 0; 
    }


Measured memory_bytes: 3220
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;

string s, t;
int dp[3009][3009];

int main() {
    cin >> s >> t;

    for(int i = 1; i <= s.size(); i++) {
        for(int j = 1; j <= t.size(); j++) {
            dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
            if(s[i - 1] == t[j - 1])
                dp[i][j] = max(dp[i][j], dp[i - 1][j - 1] + 1);
        }
    }

    int i = s.size();
    int j = t.size();
    string res = "";
    while(i > 0 && j > 0) {
        if(dp[i][j] == dp[i - 1][j])
            i--;
        else if(dp[i][j] == dp[i][j - 1])
            j--;
        else {
            i--;
            j--;
            res.push_back(s[i]);
        }
    }
    reverse(res.begin(), res.end());

    cout << res << endl;
}

Measured memory_bytes: 35584
#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;

int main()
{
	int n;
	scanf("%d",&n);
	int cnt = 0;
	for (int i = 0;i < n;i++)
	{
		int x;
		scanf("%d",&x);
		while (x % 2 == 0)
		{
			cnt++;
			x /= 2;
		}
	}
	printf("%d\n",cnt);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;




int main(void) {
  ll N, M;
  cin >> N >> M;
  ll i, j;
  ll x[MAX];
  vector<ll> v[MAX];
  for(i=0; i<N; i++) {
    cin >> x[i];
    v[x[i]%M].push_back(x[i]);
  }
  
  for(i=0; i<M; i++) {
    v[i].push_back(INF);
    sort(v[i].begin(), v[i].end());
  }
  
  vector<ll> cnt[MAX];
  for(i=0; i<M; i++) {
    for(j=0; j<v[i].size(); j++) {
      ll t=1;
      while(v[i][j]==v[i][j+1]) {
        t++;
        j++;
      }
      cnt[i].push_back(t);
    }
    sort(cnt[i].begin(), cnt[i].end());
  }
  
  //INFの分を取り除く
  for(i=0; i<M; i++) cnt[i].erase(cnt[i].begin());
  
  ll s[MAX]={};
  ll odd[MAX]={};
  for(i=0; i<M; i++) {
    ll t=0;
    for(j=0; j<cnt[i].size(); j++) {
      t+=cnt[i][j];
      if(cnt[i][j]&1) odd[i]++;
    }
    s[i]=t;
  }
  
  ll ans=s[0]/2;
  if(M%2==0) ans+=s[M/2]/2;
  
  for(i=1; i<=M/2-(M&1 ? 0:1); i++) {
    ll a=i;
    ll b=M-i;
    
    if(s[a]>s[b]) swap(a, b);
    
    if(s[a]>=odd[b]) {
      ans+=s[a]+(s[b]-s[a])/2;
    }else {
      ans+=s[a]+(s[b]-odd[b])/2;
    }
    
  }
  
  pt(ans);
}








Measured memory_bytes: 14720
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			List<Integer> list = new ArrayList<>();
			for (int i = 0; i < 5; i++) {
				list.add(scanner.nextInt());
				scanner.nextLine();
			}
			list.sort((x, y) -> {
				int xremain = x % 10;
				int yremain = y % 10;
				return ((yremain == 0) ? 10 : yremain) - ((xremain == 0) ? 10 : xremain);
			});
			int sum = 0;
			for (int i = 0; i < list.size() - 1; i++) {
				sum += ceiling(list.get(i));
			}
			sum += list.get(list.size() - 1);
			System.out.println(sum);
		}
	}

	private static int ceiling(int integer) {
		int remain = integer % 10;
		if (remain == 0) {
			return integer;
		} else {
			return integer + 10 - remain;
		}
	}
}

Measured memory_bytes: 26836
from itertools import product

N=int(input())
datas=[]
for i in range(N):
    A=int(input())
    for j in range(A):
        x,y=map(int,input().split())
        datas.append((i,x-1,y)) #誰が　誰に　どう判断した？

#print(datas)

ans=0
for i in product([0,1],repeat=N):
    ok=True
    for j in datas:
        if i[j[0]]==1 and i[j[1]]!=j[2]:
            ok=False
            break
    if ok:
        ans=max(ans,sum(i))
print(ans)

Measured memory_bytes: 9216
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

	Scanner sca = new Scanner(System.in);
	int a = sca.nextInt();
	int b = sca.nextInt();
	int answer;
	if(a > b) {
		if(a == 3 && b == 2) {
			answer = 1;
		}
		else if(a == 3 && b == 1) {
			answer = 2;
		}
		else {
			answer = 3;
		}
	}
	else {
		if(b == 3 && a == 2) {
			answer = 1;
		}
		else if(b == 3 && a == 1) {
			answer = 2;
		}
		else {
			answer = 3;
		}
	}

	System.out.println(answer);

	sca.close();
	}
}

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

int main()
{
	int n;
	cin >> n;
	map<string, int> m;
	for( int i = 0; i < n; i++ ) {
		string cmd, str;
		cin >> cmd >> str;
		if( cmd == "insert" ) {
			m[str]++;
		}
		else {
			string ans = "yes";
			if( m.count( str ) == 0 ) {
				ans = "no";
			}
			cout << ans << endl;
		}
	}
}



Measured memory_bytes: 36460
#include <iostream>
#include <cstdio>

using namespace std;

int n;
int a[100005];
int b;
long long cnt;

int main()
{
    scanf("%d", &n);
    for(int i = 0; i <= n; i++)
    {
        scanf("%d", &a[i]);
    }
    for(int i = 0; i < n; i++)
    {
        scanf("%d", &b);
        if(b > a[i]) b -= a[i], cnt += a[i], a[i] = 0;
        else cnt += b, a[i] -= b, b = 0;
        if(b > a[i + 1]) b -= a[i + 1], cnt += a[i + 1], a[i + 1] = 0;
        else cnt += b, a[i + 1] -= b, b = 0;
    }
    printf("%lld", cnt);
    return 0;
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
	  
	public static void main(String args[]) {
		    Scanner scanner = new Scanner(System.in);
		    
		    int N  = scanner.nextInt();
		    int K = scanner.nextInt();
		    
		    //連続するK本のろうそくに着けることは明らかである。
		    int[] rousoku = new int[N];
		    
		    for(int i = 0; i < N; i++) 
		    {
		    	rousoku[i] = scanner.nextInt();
		    }
		    //N本のろうそくを読み込んだ。
		    
		    int min = rousoku[K-1] - rousoku[0]+(int)Math.min(Math.abs(rousoku[0]),Math.abs(rousoku[K-1]));
		    //初期は一番左のからK本。一本ずつずらす。
		    
		    for(int j = 0;  K + j <= N; j++ )
		    {
		    	if( rousoku[K+j-1] - rousoku[j]+
		    			(int)Math.min
		    			(Math.abs(rousoku[j]), Math.abs( rousoku[K+j-1])) 
		    	< min)
		    	{
		    		min = rousoku[K+j-1] - rousoku[j]+
			    			(int)Math.min
			    			(Math.abs(rousoku[j]), Math.abs( rousoku[K+j-1]));
		    	}
		    }
		    
		    System.out.println(min);
		    
		    scanner.close(); }
		  }


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

using namespace std;

#define pb push_back
#define fi first
#define se second
#define all(vec) vec.begin(),vec.end()
#define f(i,a,b) for(int i=a;i<b;i++)
#define SZ(x) (int)x.size()

typedef  vector<string> vs;
typedef  vector<int> vi;


int main(){
	
	int n,i; 
	
	cin >> n >> i; 
	
	cout << n - i + 1 << endl;
	

}



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

#define LL long long

#define FOR(INDEX, START, END) for (LL INDEX = (START); INDEX < (END); ++INDEX)
#define REP(INDEX, COUNT) for (LL INDEX = 0; INDEX < (COUNT); ++INDEX)

// 何連続成功すればいいか
double tbl[100001] = {};

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

	for (int i = K; i <= N; ++i) {
		tbl[i] = 0;
	}

	int cnt = 1;
	int right = K;
	int left = (right + 1) / 2;
	for (;;) {
		for (int i = left; i < right; ++i) {
			tbl[i] = cnt;
		}

		++cnt;
		right = left;
		left = (right + 1) / 2;

		if (left == right) {
			break;
		}
	}

	double rate = 0;
	for (int i = 1; i <= N; ++i) {
		rate += pow(0.5, tbl[i]);
	}

	rate /= N;

	cout << setprecision(16) << rate << endl;

	return 0;
}


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

using namespace std;

typedef long long ll;

int main() {
    ll n; scanf("%lld",&n);
    ll index=1, cnt=0;
    while (n-1) {
        cnt+=index; n=n/2;
        index=index*2;
    }
    cnt+=index;
    printf("%lld",cnt);
}

Measured memory_bytes: 256