akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for(ll i=0;i<n;i++)
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (b>a) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const long long INF = 2LL << 60;
using ll = long long;
using P = pair<ll, ll>;

int main(int argc, char const *argv[]){
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    ll ans=0;
    ll Ki=1;
    rep(i,n){
        if(a[i]==Ki){
            Ki++;
        }else{
            ans++;
        }
    }
    if(ans==n) ans=-1;
    cout << ans << endl;

    return 0;
}



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

char s[110];
int i,a,b,x;

int main(){
	while(scanf("%s",s)!=EOF){
		a=b=0;
		for(i=0;i<strlen(s);i++){
			if(s[i]=='I')x=1;
			else if(s[i]=='V')x=5;
			else if(s[i]=='X')x=10;
			else if(s[i]=='L')x=50;
			else if(s[i]=='C')x=100;
			else if(s[i]=='D')x=500;
			else if(s[i]=='M')x=1000;
			if(b>=x)a=x+a;
			else a=a+x-2*b;
			b=x;
		}
		printf("%d\n",a);
	}
	
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <stack>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;
template<class T> inline bool chmax(T& a, T b){ if(a < b) { a=b; return 1; }return 0;}
template<class T> inline bool chmin(T& a, T b){ if(a > b) { a=b; return 1; }return 0;}
const long long INF = 1LL << 60;

// --------write my code!!!!!----------//

int main(){
    int s; cin >> s;int res = 1;
    int now = s;
    while(s!=4 && s!=2 && s!=1){
        if(s%2!=0) s=s*3+1;
        else s=s/2;
        res++;
    }
    cout << res+3 << endl;
}


Measured memory_bytes: 256
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <queue>
#include <iostream>
#include <string.h>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <cstdint>
#include <climits>
#include <unordered_set>
#include <sstream>
#include <stack>

using namespace std;

#define ll long long int

int main()
{
    ll k;
    cin >> k;
    ll n = k / 50;
    ll m = k % 50;
    cout << 50 << endl;
    for(int i = 0;i < 50;i++)
    {
        if(i < m)
        {
            cout << 50 + n << " ";
        }
        else
        {
            cout << 50 + n - m - 1<< " ";
        }
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cstdlib>
#include<ctime>
#include<functional>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<bitset>
#include<assert.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
void open(const char *s){
#ifndef ONLINE_JUDGE
	char str[100];sprintf(str,"%s.in",s);freopen(str,"r",stdin);sprintf(str,"%s.out",s);freopen(str,"w",stdout);
#endif
}
void open2(const char *s){
#ifdef DEBUG
	char str[100];sprintf(str,"%s.in",s);freopen(str,"r",stdin);sprintf(str,"%s.out",s);freopen(str,"w",stdout);
#endif
}
template <class T>
int upmin(T &a, const T &b){return (b<a?a=b,1:0);}
template <class T>
int upmax(T &a, const T &b){return (b>a?a=b,1:0);}
namespace io
{
	const int SIZE=(1<<20)+1;
	char ibuf[SIZE],*iS,*iT;
	char obuf[SIZE],*oS=obuf,*oT=oS+SIZE-1;
	int getc()
	{
		(iS==iT?iS=ibuf,iT=ibuf+fread(ibuf,1,SIZE,stdin):0);
		return iS==iT?EOF:*(iS++);
	}
	int f;
	char c;
	template <class T>
	void get(T &x)
	{
		f=1;
		for(c=getc();(c<'0'||c>'9')&&c!='-';c=getc());
		(c=='-'?f=-1,c=getc():0);
		x=0;
		for(;c>='0'&&c<='9';c=getc())
			x=x*10+c-'0';
		x*=f;
	}
	void flush()
	{
		fwrite(obuf,1,oS-obuf,stdout);
		oS=obuf;
	}
	void putc(char x)
	{
		*(oS++)=x;
		if(oS==oT)
			flush();
	}
	int a[55],t;
	template <class T>
	void put(T x)
	{
		if(!x)
			putc('0');
		x<0?putc('-'),x=-x:0;
		while(x)
		{
			a[++t]=x%10;
			x/=10;
		}
		while(t)
			putc(a[t--]+'0');
	}
	void space()
	{
		putc(' ');
	}
	void enter()
	{
		putc('\n');
	}
	struct flusher
	{
		~flusher()
		{
			flush();
		}
	}
	io_flusher;
}
const int N=1000010;
vector<int> g[N];
int s1[N];
int s2[N];
int b[N];
void dfs(int x,int fa)
{
	s1[x]=0;
	int num=0;
	for(auto v:g[x])
		if(v!=fa)
		{
			dfs(v,x);
			s1[x]+=s1[v];
			if(!s1[v])
				num++;
		}
	if(num)
		s1[x]+=num-1;
}
void dfs2(int x,int fa)
{
	int temp1=s2[x];
	int temp2=(fa?(s2[x]?0:1):0);
	for(auto v:g[x])
		if(v!=fa)
		{
			temp1+=s1[v];
			temp2+=(s1[v]?0:1);
		}
	for(auto v:g[x])
		if(v!=fa)
		{
			s2[v]=temp1-s1[v]+(temp2-!s1[v]?temp2-!s1[v]-1:0);
			dfs2(v,x);
		}
}
void dfs3(int x,int fa)
{
	s1[x]=0;
	int num=0;
	for(auto v:g[x])
		if(v!=fa)
		{
			dfs3(v,x);
			s1[x]+=s1[v];
			if(!s1[v])
				num++;
		}
	if(num)
	{
		s1[x]+=num-1;
		for(auto v:g[x])
			if(v!=fa)
			{
				if(!s1[v]&&num>1)
				{
					b[v]=1;
					num--;
				}
			}
	}
}
void solve()
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		g[i].clear();
		b[i]=s1[i]=s2[i]=0;
	}
	int x,y;
	for(int i=1;i<n;i++)
	{
		scanf("%d%d",&x,&y);
      x++;
      y++;
		g[x].push_back(y);
		g[y].push_back(x);
	}
	dfs(1,0);
	dfs2(1,0);
	pii ans(0x7fffffff,0);
	for(int i=1;i<=n;i++)
		ans=min(ans,pii(s1[i]+s2[i]+1,i));
	for(int i=1;i<=n;i++)
	{
		b[i]=0;
		s1[i]=0;
	}
	dfs3(ans.second,0);
	b[ans.second]=1;
	printf("%d\n",ans.first);
}
int main()
{
	open2("g");
		solve();
	return 0;
}


Measured memory_bytes: 47872
#include <cstdio>
#include <vector>
#include <queue>
using namespace std;

class Guard
{
public:
	bool wt;
	int rest, pt;
	
	Guard(){}
	
	Guard(int rest, int pt, bool wt)
	:rest(rest),pt(pt),wt(wt)
	{}
};

class Wait
{
public:
	int id, st;
	Wait(int id, int st)
	:id(id),st(st)
	{}
	
	bool operator<(const Wait& w) const
	{
		if(st!=w.st) return st>w.st;
		return id>w.id;
	}
};

int main()
{
	int N,T;
	while(scanf("%d%d", &N,&T), (N||T))
	{
		int sptn[100];
		vector<vector<int> > ptn;
		for(int i=0; i<N; i++)
		{
			int t;
			vector<int> pt;
			while(scanf("%d", &t), t)
			{
				pt.push_back(t);
			}
			
			sptn[i]=pt.size();
			ptn.push_back(pt);
		}
		
		int cnt=0;
		Guard guard[100];
		for(int i=0; i<N; i++)
			guard[i]=Guard(ptn[i][0], 0, false);
		
		priority_queue<Wait> q;
		for(int i=0; i<T; i++)
		{
			for(int j=0; j<N; j++)
			{
				if(guard[j].rest==0)
				{
					guard[j].pt=(guard[j].pt+1)%sptn[j];
					guard[j].rest=ptn[j][guard[j].pt];
					guard[j].wt=!guard[j].wt;

					if(guard[j].wt) q.push(Wait(j,i));
				}

				if(!guard[j].wt) guard[j].rest--;
			}
			
			if(!q.empty())
			{
				Wait w=q.top();
				guard[w.id].rest--;
			}
			
			if(!q.empty()) 
			{
				cnt+=q.size()-1;
				Wait w=q.top();
				if(guard[w.id].rest==0) q.pop();
			}
			
		}
		
		printf("%d\n", cnt);
	}
}

Measured memory_bytes: 840
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	ll n; cin>>n;
	ll ans=1e18;
	for(ll d=1; d*d<=n; d++){
		if(n%d==0){
			ans=min(ans, d-1+n/d-1);
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> l_l;
typedef pair<int,int> i_i;
const ll mod=1e9+7;
const int inf=1<<30;

int main(){
  int n; cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  int cnt4=0,cnt2=0;
  rep(i,n){
    if(a[i]%4==0) cnt4++;
    if(a[i]%4!=0&&a[i]%2==0) cnt2++;
  }
  if(cnt2==1) cnt2--;
  if(cnt2>0&&cnt4*2+cnt2>=n) cout << "Yes" << endl;
  else if(cnt2==0&&cnt4*2+1>=n) cout << "Yes" << endl;
  else cout << "No" << endl;
  
}

Measured memory_bytes: 640
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <climits> // FOO_MAX, FOO_MIN
#include <cmath> 
#include <cstdlib> // abs(int)

#define roundup(n,d) ( ((n) + ((d)-1)) / (d) )
#define ll long long
#define llv vector<long long>
#define assign_max(into, compared) (into = max((into), (compared)))
#define assign_min(into, compared) (into = min((into), (compared)))
#define rep(i,n) for(long long i = 0;i < n;i++)

using namespace std;

int main(void){
    char c;
    cin >> c;
    if('A' <= c && c <= 'Z') cout << 'A';
    else cout << 'a';
    cout << endl;
}

Measured memory_bytes: 3068
n = int(input())
b = list(map(int,input().split()))
a = []
pre = b[0]
for i in range(n):
  if i == n - 1:
    a.append(b[-1])
    break
  # 同じならそのまま
  if pre == b[i]:
    a.append(pre)
  # 上がったら1個前のを
  elif pre < b[i]:
    a.append(pre)
    pre = b[i]
  # 下がったらその都度下げる
  elif pre > b[i]:
    a.append(b[i])
    pre = b[i]
print(str(sum(a)))

Measured memory_bytes: 3064
#include <iostream>
#include <string>
using namespace std;
int main(void){
    int n,l;
    cin >> n >> l;
    int sum = 0;
    for (int i = 0; i < n; ++i) sum += l + i;
    if (l > 0) cout << sum -l << endl;
    else if (n + l -1 > 0) cout << sum << endl;
    else cout << sum - (n + l - 1) << endl;
    return 0;
}


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

int step_score=0;

vector< vector<int> > step(vector< vector<int> > T,int H){
    for(int i=0;i<H;i++){
        for(int j=0;j<6;j++){
            for(int k=j+1;k<6;k++){
                if(T.at(i).at(k)!=T.at(i).at(k-1)){
                    if(k-j>=3){
                        for(int l=j;l<k;l++){
                            step_score+=T.at(i).at(l);
                            T.at(i).at(l)=0;
                        }
                    }
                    break;
                }
            }
        }
    }
    vector< vector<int> > T_next(H,vector<int>(6,0));
    for(int j=0;j<6;j++){
        int p=H-1;
        for(int i=H-1;i>=0;i--){
            if(T.at(i).at(j)!=0){
                T_next.at(p).at(j)=T.at(i).at(j);
                p--;
            }
        }
    }
    return T_next;
}

int main(){
    int H;
    cin >> H;
    while(H>0){
        vector< vector<int> > D(H,vector<int>(6,0));
        for(int i=0;i<H;i++) D.at(i).at(5)=10;
        for(int i=0;i<H;i++){
            for(int j=0;j<5;j++){
                cin >> D.at(i).at(j);
            }
        }
        int totalscore=0;
        while(true){
            step_score=0;
            D=step(D,H);
            /*
            for(int i=0;i<H;i++){
                for(int j=0;j<6;j++){
                    cout << D.at(i).at(j) << " ";
                }
                cout << endl;
            }
            cout << endl;
            */
            if(step_score>0){
                totalscore+=step_score;
            }else{
                break;
            }
        }
        cout << totalscore << endl;
        cin >> H;
    }
}


Measured memory_bytes: 3128
#include <cstdio>
#include <algorithm>

using namespace std;

int main()
{
	int m,n;
	
	while(scanf("%d %d", &m, &n) != EOF){
		if(n > m) swap(m, n);
		
		int x = m;
		int y = n;
		
		while(n != 0){
			int tmp = n;
			n = m%n;
			m = tmp;
		}
		
		printf("%d %d\n", m, x/m*y);
	}
	
	return(0);
}

Measured memory_bytes: 1024
from collections import deque

def solve(top, sa, sb, sc):
  if len(s[top]) == 0:
    return top.upper()
  top = s[top].popleft()
  return solve(top, sa, sb, sc)
  
s = {}
s['a'] = deque(input())
s['b'] = deque(input())
s['c'] = deque(input())

top = s['a'].popleft()
print(solve(top, s['a'], s['b'], s['c']))


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

int main()
{

    int N;
    cin >> N;

    deque<int> s;
    for (int i = 0; i < N; i++)
    {
        int a;
        cin >> a;
        int p = lower_bound(s.begin(), s.end(), a) - s.begin();
        if (p == 0)
        {
            s.push_front(a);
        }
        else
        {
            s[p - 1] = a;
        }
    }

    cout << s.size() << endl;
    return 0;
}

Measured memory_bytes: 3976
#include <iostream>
#include <vector>
#include <cassert>

using namespace std;

int n, q;

template <typename T>
class BIT {
private:
    vector<T> v;
    const int n;

public:
    BIT(int _n) : v(_n + 1, 0), n(_n) {}

    // a[0] + a[1] + ... + a[i - 1]
    T sum (int i) {
        assert(0 <= i && i < n + 1);
        T s = 0;
        while(i > 0) {
            s += v[i - 1];
            i -= i & -i;
        }
        return s;
    }

    // a[i] + a[i + 1] + ... + a[j - 1]
    T sum (int i, int j) {
        return sum(j) - sum(i);
    }

    // a[i] += x
    void add(int i, T x) {
        assert(0 <= i && i < n);
        i++;
        while (i <= n) {
            v[i - 1] += x;
            i += i & -i;
        }
    }

};

int main() {
    cin >> n >> q;
    auto bit = BIT<int>(n);
    for (int i = 0; i < q; ++i) {
        int com, x, y;
        cin >> com >> x >> y;
        if (com) cout << bit.sum(x - 1, y) << endl;
        else bit.add(x - 1, y);
    }
}

Measured memory_bytes: 3116
import heapq as h
import sys

input=sys.stdin.readline

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

hen=[[] for i in range(0,N)]
for i in range(0,N-1):
    hen[a[i]].append([b[i],c[i]])
    hen[b[i]].append([a[i],c[i]])

distance=[-1 for i in range(0,N)]
Q,K=map(int,input().split())
distance[K-1]=0

q=[]
q.append(K-1)
h.heapify(q)
sub=[]
h.heapify(sub)
while q!=[]:
    while q!=[]:
        x=h.heappop(q)
        for p in hen[x]:
            if distance[p[0]]==-1:
                h.heappush(sub,p[0])
            else:
                distance[x]=distance[p[0]]+p[1]
        if q==[]:
            q=sub
            sub=[]
            h.heapify(sub)
            break

ans=[0 for i in range(0,Q)]
for i in range(0,Q):
    x,y=map(int,input().split())
    ans[i]=distance[x-1]+distance[y-1]

for i in range(0,Q):
    print(ans[i])

Measured memory_bytes: 92080
#include<iostream>
#include<sstream> 


using namespace std;

int main()
{
	int Values[9];
	char inputs[9];
	string num = "";
	string firsts;
	int result = 0;
	int ne;
	cin >> firsts;
	for (int i = 0; i < firsts.length(); i++) {
		inputs[i] = firsts[i];
		num += inputs[i];
		Values[i] = inputs[i] - '0';
		result += Values[i];
	}
	stringstream geek(num);
	geek >> ne;
	if (ne % result) {
		cout << "No";
	}
	else {
		cout << "Yes";
	}

	return 0;	
}

Measured memory_bytes: 256
package main 

import "fmt"

func main() {
	a := scanNums(3)
    b := a[0]*a[1]
    if b>=a[2]{
      fmt.Println(a[2])
    }else{
     fmt.Println(b)
    }
}

func scanNums(len int) (nums []int) {
    var num int
    for i := 0; i < len; i++ {
        fmt.Scan(&num)
        nums = append(nums, num)
    }
    return
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
long long N, W;
long long w[101], v[101], dp[110][100100];
long long rec(int i, int j) {
  if(dp[i][j] >= 0)return dp[i][j];
  long long ret;
  if(i == N) ret = 0;
  else if (j < w[i]) ret = rec(i+1, j);
  else ret = max(rec(i+1, j), rec(i+1, j-w[i])+v[i]);
  return dp[i][j] = ret;
}
int main() {
  cin >> N >> W;
  for(int i=0;i<N;i++)
  cin >> w[i] >> v[i];
  memset(dp, -1, sizeof(dp));
  cout<<rec(0, W);
}


Measured memory_bytes: 86272
import itertools
n,a,b,c=map(int,input().split())
x=[a,b,c]
l=[int(input()) for i in range(n)]
ans=1000000
loop='012'
for i in range(2**n):
    use=[]
    for j in range(n):
        if((i>>j)&1):
            use.append(l[j])
    if(len(use)>=3):
        for j in (itertools.product(loop,repeat=len(use))):
            A=[[] for i in range(3)]
            for k in range(len(use)):
                A[int(j[k])].append(use[k])
                
            if(len(A[0])!=0 and len(A[1])!=0 and len(A[2])!=0):
                res=0
                for i in range(3):
                    res+=abs(sum(A[i])-x[i])+(len(A[i])-1)*10
                ans=min(res,ans)
print(ans)

Measured memory_bytes: 3444
//#include"bits/stdc++.h"
#include<iostream>
#include<ostream>
#include<vector>
#include<string>
#include<algorithm>

#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)


using namespace std;
using ll = long long;

void solve();

int main() {

   solve();
   return 0;

}

void solve() {

	vector<ll> v(3);
	ll n;

	cin >> n;

	REP(i, n) {
		cin >> v[0] >> v[1] >> v[2];
		sort(v.begin(), v.end());
		cout << (v[0]*v[0]+v[1]*v[1]==v[2]*v[2] || v[0]*v[0]+v[2]*v[2]==v[1]*v[1] || v[1]*v[1]+v[2]*v[2]==v[0]*v[0]? "YES": "NO") << endl;
	}

}

Measured memory_bytes: 3032
#include<bits/stdc++.h>
#define pb push_back
#define db double
using namespace std;
db sqr(db x){return x*x;}
struct B{
	db x, y, z, r;
};
struct L{
	db x, y, z, b;
	db val;
};
struct P{
	db x, y, z;
	P(db x, db y, db z):x(x), y(y), z(z){}
	P(B &bl):x(bl.x), y(bl.y), z(bl.z){}
	P(L &ls):x(ls.x), y(ls.y), z(ls.z){}
	P(){}
	db dis(P &p){return sqr(p.x-x)+sqr(p.y-y)+sqr(p.z-z);}
};
struct V{
	db x, y, z;
	V(){}
	V(P &p1, P &p2):x(p2.x-p1.x), y(p2.y-p1.y), z(p2.z-p1.z){}
	V(V &a, V &b):x(a.y*b.z-a.z*b.y), y(a.x*b.z-a.z*b.x), z(a.x*b.y-a.y*b.x){}
	db dot(V &v){return x*v.x+y*v.y+z*v.z;}
	db mod(){return x*x+y*y+z*z;}
};
db dis(P &p, P &p1, P &p2){
	V v1(p1, p), v2(p1, p2), v3(p2, p), v4(p2, p1), v5(v2, v1);
	if(v1.dot(v2)<0) return p.dis(p1);
	if(v3.dot(v4)<0) return p.dis(p2);
	return (db)v5.mod()/(db)v2.mod();
}
const int MAX_N=2e3+50, MAX_M=1000;
bool vis[MAX_N];
B bl[MAX_N];
L ls[MAX_M];
vector<int> block[MAX_M];
int N, M, R;
P obj;
bool is_block(int i, int j){
	P a(ls[i]), b(bl[j]);
	if(b.dis(a)<sqr(bl[j].r)&&b.dis(obj)<sqr(bl[j].r)) return false;
	return dis(b, a, obj)<(db)sqr(bl[j].r);
}
bool ok(int x){
	int cnt=0;
	memset(vis, 0, sizeof(vis));
	for(int i=0; i<M; i++){
		if(!(x&1<<i)) continue;
		for(int j=0; j<block[i].size(); j++)
			if(!vis[block[i][j]]) vis[block[i][j]]=true, cnt++;
		if(cnt>R) return false;
	}
	return true;
}
db calc(int x){
	db ans=0;
	for(int i=0; i<M; i++){
		if(!(x&1<<i)) continue;
		ans+=ls[i].val;
	}
	return ans;
}
void solve(){
	double ans=0;
	for(int i=0; i<(1<<M); i++){
		if(ok(i)) ans=max(ans, calc(i));
	}
	printf("%.9f\n", ans);
}
int main(){
	//freopen("in", "r", stdin);
	while(~scanf("%d%d%d", &N, &M, &R)){
		if(N||M||R){
			for(int i=0; i<N; i++)
				scanf("%lf%lf%lf%lf", &bl[i].x, &bl[i].y, &bl[i].z, &bl[i].r);
			for(int i=0; i<M; i++){
				scanf("%lf%lf%lf%lf", &ls[i].x, &ls[i].y, &ls[i].z, &ls[i].b);
				block[i].clear();
			}
			scanf("%lf%lf%lf", &obj.x, &obj.y, &obj.z);
			for(int i=0; i<N; i++){
				P p(ls[i]);
				ls[i].val=(db)ls[i].b/(db)obj.dis(p);
			}
			for(int i=0; i<M; i++){
				P p1(ls[i]);
				for(int j=0; j<N; j++)
					if(is_block(i, j)) block[i].pb(j);
			}
			solve();
		}
	}
	return 0;
}

Measured memory_bytes: 1448
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto S = readln.chomp;
    int a, b;
    foreach (i, c; S) {
        if ((i%2 == 0 && c == '1') || (i%2 == 1 && c == '0')) ++a;
        if ((i%2 == 0 && c == '0') || (i%2 == 1 && c == '1')) ++b;
    }
    writeln(min(a, b));
}

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

long long rec(int n,long long x){ //レベルがnのバーガーに含まれるパティｘ

    if(n == 0)return 1;
    //前のレベルの量
    long long len = (1LL << (n + 1)) - 3;
    long long num = (1LL << n) - 1;
    if(x == 1)return 0;
    else if (x <= len + 1)return rec(n - 1, x - 1);
    else if (x == len + 2)return num + 1;
    else if (x <= (len + 1) * 2)return num + 1 + rec(n - 1, x - len - 2);
    else return num * 2 + 1;
}

int main()
{
    int n; long long x;
    std::cin >> n >> x;
    std::cout << rec(n, x) << std::endl;

}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int h,w,i,j;cin >> h >> w;bool white;
  char a[h][w];
  for(i=0;i<h;i++){
    for(j=0;j<w;j++) cin >> a[i][j];
  }
  for(j=0;j<w;j++){
    white = true;
    for(i=0;i<h;i++){
      if(a[i][j]=='#') white = false;
    }
    if(white){
      for(i=0;i<h;i++) a[i][j] = 'x';
    }
  }
  for(i=0;i<h;i++){
    white = true;
    for(j=0;j<w;j++){
      if(a[i][j]=='#') white = false;
    }
    if(!white){
      for(j=0;j<w;j++){
        if(a[i][j]!='x') cout << a[i][j];
      }
      cout << endl;
    }
  }
}

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

int par[100000];
int abc[100000];

void init(int n){
  rep(i,0,n){
    par[i]=i;
    abc[i]=0;
  }
}

int find(int x){
  if(par[x]==x){
    return x;
  }
  else{
    return par[x]=find(par[x]);
  }
}

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

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

int main() {
  int n,m;
  cin>>n>>m;
  init(n);
  rep(j,0,m){
    int a,b,c;
    cin>>a>>b>>c;
    unite(a-1,b-1);
  }
  
  int a[n];
  rep(i,0,n) a[i]=find(i);
    
  sort(a,a+n);
  int cur=-1;
  int ans=0;
  rep(i,0,n){
    if(cur!=a[i]){
      ans++;
      cur=a[i];
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 1408
/**
 *  winners never quit
**/

#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define pp pop_back
#define mp make_pair
#define IO cin.tie(0),cout.tie(0)
#define ISWS ios::sync_with_stdio(0)
typedef long long Long;
void FastIO(){ISWS;IO;}

const int N = 1e5;

int main()
{
  FastIO();
  int tc, ca = 0;
  double d, t, s;
  cin >> d >> t >> s;
  if (d/s <= t)cout << "Yes" << '\n';
  else cout << "No" << '\n';
  return 0;
}


Measured memory_bytes: 3708
function Main(input) {
  var A = input.split(" ")[0];
  var B = input.split(" ")[1];
  
  A = parseInt(A,10);
  B = parseInt(B,10);
  
  var coin = 0;
  for(i=0; i<=1; i++){
    if(A>=B){
      coin += A;
      A -= 1;
    }else{
      coin += B;
      B -= 1;
    }
  }
    
  console.log(coin);
  
  
  


  
}


Main(require('fs').readFileSync('/dev/stdin','utf8'));

Measured memory_bytes: 7372
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <map>
#include <set>
#include <stack>
#include <queue>
 
using namespace std;
 
#define pb(n)	push_back(n)
#define mp(n,m) make_pair(n,m)
#define fi 	first
#define se 	second
#define all(r) (r).begin(),(r).end()
 
#define REP(i,s,e)	for(int i=(s); i<(e); i++)
#define rep(i,n)	REP(i,0,n)
#define REPE(i,s,e)	for(int i=s; i>e; i--)
#define repe(i,n)	REPE(i,n,-1)


typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
typedef vector<vi> vvi;
 
const int IMAX=((1<<30)-1)*2+1;
const int INF=100000000;
const double EPS=1e-10;
//int mod=1000000007
 


int main(){
	int n;
	while(cin >> n && n>0){
		int a,b,sa=0,sb=0;
		rep(i,n){
			cin>>a>>b;
			if(a>b) sa+=(a+b);
			else if(a==b) sa+=a,sb+=b;
			else sb+=(a+b);
		}
		cout<<sa<<" "<<sb<<endl;
	}
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define print(x) cout << (x) << endl;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int P, Q, R;
    cin >> P >> Q >> R;
    vector<int> A(3);
    A.at(0) = P;
    A.at(1) = Q;
    A.at(2) = R;
    sort(A.begin(), A.end());
    cout << A.at(0) + A.at(1) << endl;
}

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

int main() {
	int N; cin >> N;
	vector<int> d(N + 1);
	for (int i = 0; i < N; ++i) {
		cin >> d[i];
	}
	
	std::sort(d.begin(),d.end());

	int ans = d[N/2+1]-d[N/2];

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int input=0;
		int sosuko=0;
		long wa=0l;
		int genzai=0;
		boolean ss=false;
		while(sc.hasNext()) {
			input=sc.nextInt();
			sosuko=0;
			wa=0l;
			genzai=0;

			if(input>=1) {
				wa+=2;
				genzai=2;
				sosuko=1;
			}
			if(input==0) {
				System.exit(0);
			}
			genzai=3;
			while(input>sosuko) {
				ss=true;
				for(int j=2; j<=Math.sqrt(genzai)+1;) {
					if(genzai%j==0) {
						genzai+=2;
						ss=false;
						break;
					}
					j++;
				}
				if(ss==true) {
					wa+=genzai;
					sosuko++;
					genzai+=2;
				}
			}
			System.out.println(wa);
		}
	}
}


Measured memory_bytes: 26792
#include <stdio.h>
#include <memory.h>
#include <stdbool.h>

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, -1, 0, 1};
int c[1000][1000];
int dat[1000][1000];
int cost[1000][1000];
int destination = 1;
int startposx, startposy;
int h, w, n;

struct QUEUE {
  int x, y;
};
QUEUE queue[1000000];
int qbegin = 0, qend = 0;

void bfsToDestination(int x, int y);
void PushQueue(int x, int y);
QUEUE PopQueue();
bool isQueueEmpty();


int main (void) {

  int i, j;

  scanf("%d%d%d", &h, &w, &n);

  for(i = 0; i < h; i++) {
    for(j = 0; j < w; j++) {
      dat[j][i] = fgetc(stdin);
      if (dat[j][i] == '\n') dat[j][i] = fgetc(stdin);
      if (dat[j][i] == 'S') {
	startposx = j; startposy = i;
	cost[j][i] = 0;
      }
    }
  }

  //for(i = 0; i < h; i++) {
  //  for(j = 0; j < w; j++) {
  //    printf("%c", dat[j][i]);
  //  }
  //  printf("\n");
  //}

  for (i = 0; i < n; i++) {
    memcpy(c, dat, sizeof(dat));
    bfsToDestination(startposx, startposy);
  }
  
  printf("%d\n", cost[startposx][startposy]);
    
  return 0;
}

void bfsToDestination(int x, int y) {

  int i;
  QUEUE ret;

  qbegin = 0; qend = 0;

  // map
  // int j;
  //printf("---map\n");
  //for(i = 0; i < h; i++) {
  //  for(j = 0; j < w; j++) {
  //    printf("%c", c[j][i]);
  //  }
  //  printf("\n");
  //}

  PushQueue(x, y);
  c[x][y] = 'X';

  while(!isQueueEmpty()) {
    ret = PopQueue();
    
    //printf("ret.x:%d ret.y:%d cost.x,y:%d\n", ret.x, ret.y, cost[ret.x][ret.y]);
    
    for (i = 0; i < 4; i++) {
      int nx = ret.x + dx[i];
      int ny = ret.y + dy[i];

      if ((nx >= 0) && (ny >= 0) && (nx < w) && (ny < h )) {
	if (c[nx][ny] != 'X') {
	  PushQueue(nx, ny);
	  cost[nx][ny] = cost[ret.x][ret.y] + 1;
	  if ((c[nx][ny] - '0') == destination) {
	    destination++;
	    startposx = nx; startposy = ny;
	    return;
	  }
	  c[nx][ny] = 'X';
	}
      }
    }
  }

}

void PushQueue(int x, int y) {
  queue[qend].x = x; queue[qend].y = y;
  qend++;
}

QUEUE PopQueue() {
  QUEUE ret;
  ret.x = queue[qbegin].x; ret.y = queue[qbegin].y;
  qbegin++;

  return ret;
}

bool isQueueEmpty() {
  if (qend == qbegin) return true;

  return false;
}

Measured memory_bytes: 18520
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define int long long

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF (3e15)

using namespace std;

int dsum(int n) {
    int sum = 0;
    while (n > 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}

int N;
signed main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin >> N;

    int ans = INF;
    FOR(i, 1, N - 1) { ans = min(ans, dsum(i) + dsum(N - i)); }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d", $n);
$a = explode(" ",fgets(STDIN));

$ans = 0;

for($i=0; $i<$n; $i++) {
    $a[$i] = 1/$a[$i];
    $ans += $a[$i];
}

$ans = 1/$ans;

echo $ans;

Measured memory_bytes: 4728
#include <cstdio>
#include <numeric>
#include <vector>

using namespace std;

#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)

typedef vector<int> vi;

const int INFTY=1<<29;

const int vals[]={1,5,10,50,100,500};

int getpay(int ns[],int x)
{
	int res=0;
	per(i,6){
		int use=min(x/vals[i],ns[i]);
		res+=use;
		x-=use*vals[i];
	}
	return x>0?-1:res;
}

int getchange(int x)
{
	static int memo[666001];
	if(!x || memo[x]) return memo[x];
	int& res=memo[x];
	per(i,6){
		res+=x/vals[i];
		x%=vals[i];
	}
	return res;
}

int main()
{
	for(int p,ns[6];scanf("%d",&p),p;){
		rep(i,6) scanf("%d",ns+i);
		int pmax=inner_product(ns,ns+6,vals,0);
		
		int res=INFTY;
		repi(i,p,pmax+1){
			int pay=getpay(ns,i);
			if(pay!=-1)
				res=min(res,pay+getchange(i-p));
		}
		printf("%d\n",res);
	}
	
	return 0;
}

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

int main(void) {
	long long A, B, C;
	cin >> A >> B >> C;
	if ((A == B) && (B == C)) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define rep(i,n) for(ll i=0;i<n;++i)
#define ALL(a) (a).begin(),(a).end()

using namespace std;
using ll  = long long;
using pll = pair<ll, ll>;

const ll MOD  = 1e9 + 7;
const ll LINF = 1LL << 60;
const int INF = 1e9 + 7;

vector<vector<ll>> g(100010); 
vector<ll> dist(100010);

void dfs(ll par, ll pos){
    rep(i, g[pos].size()){
        if(g[pos][i] == par)continue;

        dist[g[pos][i]] = dist[pos] + 1;

        dfs(pos, g[pos][i]);
    }
}

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

    rep(i, n-1){
        ll a, b;
        cin >> a >> b;
        a--, b--;

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

    dist[0] = 0;
    dfs(0, 0);
    vector<ll> dist_fe = dist;

    dist[n-1] = 0;
    dfs(n-1, n-1);

    ll cnt = 0;
    rep(i, n){ 
        if(dist[i] < dist_fe[i])cnt++;
    }

    if(cnt >= n - cnt)cout << "Snuke\n";
    else cout << "Fennec\n";
}

Measured memory_bytes: 11904
H, W = map(int,input().split())
G = ["."*(W+2)]
for k in range(H):
    G.append("."+input()+".")
G.append("."*(W+2))

for h in range(1,H+1):
    for w in range(1,W+1):
        if G[h][w] == "#":
            if G[h-1][w] == "#" or G[h+1][w] == "#" or G[h][w-1] == "#" or G[h][w+1] == "#":
                pass
            else:
                print("No")
                exit(0)
print("Yes")


Measured memory_bytes: 3060
//#define MYDEBUG
#include <bits/stdc++.h>

#ifdef MYDEBUG
#define dbp(x) cout<<#x<<": "<<x<<endl
#define dbp2(x,y) cout<<#x<<","<<#y<<": "<<x<<","<<y<<endl
#define dbp3(x,y,z) cout<<#x<<","<<#y<<","<<#z<<": "<<x<<","<<y<<","<<z<<endl
#define dbp4(w,x,y,z) cout<<#w<<","<<#x<<","<<#y<<","<<#z<<": "<<w<<","<<x<<","<<y<<","<<z<<endl
#define ifcin(x) std::ifstream cin(x)
#else
#define dbp(x)
#define dbp2(x,y)
#define dbp3(x,y,z)
#define dbp4(v,x,y,z)
#define ifcin(x)
#endif
#define ll long long
#define ull unsigned long long
#define eps 1e-14
#define all(x) x.begin(), x.end()
#define rep(i, from, to) for(int i=from; i<to; ++i)
#define REP(i, from, to) for(int i=from; i<=to; ++i)
using std::vector;
using std::cout;
using std::cin;
using std::endl;
using std::max;
using std::min;
using std::swap;
using std::string;
using std::fill;
using std::pair;
using std::sort;
using std::reverse;
using std::pair;
using std::greater;
using std::priority_queue;
using std::stack;

template<typename T>
std::ostream& operator<<(std::ostream& out, const vector<T>& v) {
  out << "[";
  size_t last = v.size() - 1;
  for (size_t i = 0; i < v.size(); ++i) {
    out << v[i];
    if (i != last)
      out << ",";
  }
  out << "]";
  return out;
}

int n;
string s, ans;
stack<char> st;

void solve() {
  cin >> n >> s;
  ans = s;
  //)で死んだら左から(
  //最後まで読んで(が余ったら
  //余った数だけ右に)
  rep(i,0,n)
  {
    if (!st.empty()) {
      if (s[i] == ')') {
        st.pop();
      } else if (s[i] == '(') {
        st.push(s[i]);
      }
    } else {
      if (s[i] == ')') {
        ans = '(' + ans;
      } else {  //(
        st.push(s[i]);
      }
    }
  }
  if (!st.empty()) {
    int rest = st.size();
    rep(i,0,rest)
    {
      ans = ans + ')';
    }
  }
  cout << ans << endl;
}

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int Seq[200200],P;
int To[200200];
bool Used[200200];
int main()
{
	long long N,K;
	cin>>N>>K;
	//cout<<N<<K<<endl;
	for(int i=1;i<=N;i++)
		cin>>To[i];
	Seq[0]=1;
	Used[1]=true;
	while(!Used[To[Seq[P]]])
	{
		P++;
		Seq[P]=To[Seq[P-1]];
		Used[Seq[P]]=true;
	}
	int Pos=0;
	for(int i=0;i<=P;i++)
		if(Seq[i]==To[Seq[P]])
		{
			Pos=i;
			break;
		}
	//cout<<To[1]<<endl;
	//cout<<Seq[0]<<" "<<Seq[1]<<" "<<Seq[2]<<endl;
	//cout<<Seq[P]<<endl;
	//cout<<To[Seq[P]]<<endl;
	int Circle=P-Pos+1;
	if(K<=P)
	{
		cout<<Seq[K]<<endl;
		return 0;
	}
	K-=P;
	K--;
	K%=Circle;
	//cout<<Pos<<" "<<K<<endl;
	cout<<Seq[Pos+K]<<endl;
	return 0;
}

Measured memory_bytes: 5344
import java.util.Scanner;

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

		int k = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();

		if (a % k == 0 || k + k * (a / k) <= b)
			System.out.println("OK");
		else
			System.out.println("NG");
	}

}


Measured memory_bytes: 27092
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>
#include <random>

#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<long long>vll;
typedef pair<int,int> pi;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

int N, A;
ll dp[55][55][2505];

int main(){
  cin >> N >> A;
  vector<int> x(N);
  rep(i, N) cin >> x[i];

  dp[0][0][0] = 1;
  for(int i = 0; i < N; i++){ // i枚目までのカードのうち
    for(int j = 0; j < N; j++){ // j枚カードを選択した時の
      for(int k = 0; k < 2505; k++){ // 総和がkの個数
	
	// 何も選ばない時
	dp[i + 1][j][k] += dp[i][j][k];
	// 選ぶ時
	dp[i + 1][j + 1][k + x[i]] += dp[i][j][k];
      }
    }
  }

  ll ans = 0;
  for(int i = 1; i < N + 1; i++){
    ans += dp[N][i][i * A];
  }

  cout << ans << endl;
  return 0;
}


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

using namespace std;

int main() {
	string a, b, c;
	cin >> a >> b >> c;
	int asz, bsz;
	asz = a.size();
	bsz = b.size();
	if (a[asz - 1] == b[0] && b[bsz - 1] == c[0]) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
vector<int> data;
int n,N;

int getLeft(){
	rep(i,n)if(data[i] == 0)return i;
	return -1;
}

int B(){
	for(int i=n-1;i>=0;i--){
		if(data[i] == 0 && data[i+1] != 1 && data[i-1] != 1)return i;
	}
	return getLeft();
}
int C(){
	bool f = true;
	rep(i,N)f &=(data[i+1]==0);
	if(f)return (N&1?n/2:N/2+1);
	
	rep(i,n){
		if(data[i] && data[i] != -1){
			if(data[i+1]==0)return i+1;
			else if(data[i-1]==0)return i-1;
		}
	}
}

int most(int pos,int a){
	int i = 0;
	while(!data[pos+i*a]){
		i++;
		if(data[pos+i*a] == -1)return 999999;
	}
	return i;
}

int D(){
	int good , val = -1;
	rep(i,n){
		if(data[i] == 0){
			int t = min( most(i,-1) , most(i,1) );
			if(t > val){
				val = t;
				good = i;
			}
		}
	}
	return good;
}
int main(){
	string tab = "#ABCD";
	int m;
	while(cin >> n >> m , n ){
		N = n ; n++;
		data.resize(N+2);
		fill(data.begin(),data.end(),0);
		data[0] = -1 , data[n] = -1;
		
		rep(i,m){
			char c; cin >> c;
			switch(c){
			case 'A':
				data[getLeft()] = 1;
				break;
			case 'B':
				data[B()] = 2;
				break;
			case 'C':
				data[C()] = 3;
				break;
			case 'D':
				data[D()] = 4;
				break;
			}
		}
		rep(i,N){
			int t = data[i+1];
			cout << tab[t];
		}
		cout << endl;
	}
}

Measured memory_bytes: 0
N = input()

import itertools

num = int(N)
d = len(N)

lst = ['3', '5', '7']

arr = []
for j in range(3, d+1):
    arr += [int("".join(i)) for i in itertools.product(lst, repeat=j) if '3' in i and '5' in i and '7' in i]

cnt = sum([arr[k]<=num for k in range(len(arr))])
print(cnt)

Measured memory_bytes: 4412
#include<stdio.h>

int main(void){
    int N,i,j;
    char S[101],T[101],U[300];

    scanf("%d",&N);
    scanf("%s%s",S,T);

    j = 0;
    for(i=0; i<N; i++){
        U[j] = S[i];
        U[j+1] = T[i];
        j = j + 2; 
    }
        U[j] = '\0'; 

    printf("%s",U);

    return 0;
}

Measured memory_bytes: 128
#[allow(unused_macros)]
macro_rules ! read_value {($ next : expr , ($ ($ t : tt ) ,* ) ) => {($ (read_value ! ($ next , $ t ) ) ,* ) } ; ($ next : expr , [$ t : tt ; $ len : expr ] ) => {(0 ..$ len ) . map (| _ | read_value ! ($ next , $ t ) ) . collect ::< Vec < _ >> () } ; ($ next : expr , chars ) => {read_value ! ($ next , String ) . chars () . collect ::< Vec < char >> () } ; ($ next : expr , usize1 ) => {read_value ! ($ next , usize ) - 1 } ; ($ next : expr , $ t : ty ) => {$ next () . parse ::<$ t > () . expect ("Parse error" ) } ; }
#[allow(unused_macros)]
macro_rules ! input_inner {($ next : expr ) => {} ; ($ next : expr , ) => {} ; ($ next : expr , $ var : ident : $ t : tt $ ($ r : tt ) * ) => {let $ var = read_value ! ($ next , $ t ) ; input_inner ! {$ next $ ($ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input {(source = $ s : expr , $ ($ r : tt ) * ) => {let mut iter = $ s . split_whitespace () ; let mut next = || {iter . next () . unwrap () } ; input_inner ! {next , $ ($ r ) * } } ; ($ ($ r : tt ) * ) => {let stdin = std :: io :: stdin () ; let mut bytes = std :: io :: Read :: bytes (std :: io :: BufReader :: new (stdin . lock () ) ) ; let mut next = move || -> String {bytes . by_ref () . map (| r | r . unwrap () as char ) . skip_while (| c | c . is_whitespace () ) . take_while (| c |! c . is_whitespace () ) . collect () } ; input_inner ! {next , $ ($ r ) * } } ; }

fn main() {
    input! {
        r: i32,
    }

    if r < 1200 {
        println!("ABC");
    } else if r < 2800 {
        println!("ARC");
    } else {
        println!("AGC");
    }
}


Measured memory_bytes: 2148
S = input()
s = list(map(int, list(S)))

ans = 0
op_cnt = len(s) - 1
for i in range(2 ** op_cnt):
    op = ["-"] * op_cnt
    for j in range(op_cnt):
        if (i >> j) & 1:
            op[op_cnt - 1 - j] = "+"
    op += ["-"]

    expr = "".join([n+o for n, o in zip(S, op)]).replace("-", "")
    ans += eval(expr)
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
typedef vector<int> vi;
typedef vector<ll> vl;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define IN cin >> 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (m-1); i >= (int)(n); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v,c) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////


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

    P(180 * (n-2));
    */
    string s;
    cin >> s;

    int n = 0;
    rep(i,0,sz(s))if(s[i] == 'o')n++;

    if((15-sz(s)) + n >= 8)YES;
    else NO;
    
    return  0;
}


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

using namespace std;

typedef long long ll;

const ll INF = 1e18;

int main() {
  int n; cin >> n;
  vector<ll> a(n), ps(n);
  for (int i = 0; i < n; i++) cin >> a[i], ps[i] = a[i] + ((i > 0) ? ps[i - 1] : 0);
  auto sum = [&](ll i, ll j) {
    return ps[j] - (i == 0 ? 0 : ps[i - 1]);
  };
  vector<vector<ll> > memo(n + 1, vector<ll>(n + 1, -1));
  function<ll(ll, ll)> dp = [&](ll i, ll j) {
    if (i == j) {
      return 0LL;
    }
    else if (memo[i][j] != -1) return memo[i][j];
    else {
      ll ret = INF;
      for (int k = i; k < j; k++) {
        ret = min(ret, dp(i, k) + dp(k + 1, j) + sum(i, j));
      }
      return memo[i][j] = ret;
    }
  };
  cout << dp(0, n - 1) << endl;
  return 0;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(b);i>(a);--i)
#define eper(i,a,b) for(int i=((int)(a));i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF (1<<28)-1
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

string s;
int main() {
 ios::sync_with_stdio ( false );
 cin.tie ( 0 );
    cin >> s;
    bool flag = true;
    if (s[0] != 'A') flag = false;
    int cnt = 0, itr = 0;
    erep(i, 2, s.size()-2) {
        if (s[i] == 'C') itr = i, cnt++;
    }
    if (cnt != 1) {
        flag = false;
        itr = -1;
    }
    rep(i, 0, s.size()) {
        if (i == 0 || i == itr) continue;
        if (islower(s[i]) == 0) flag = false;
    }
    if (flag) cout << "AC" << endl;
    else cout << "WA" << endl;
    return 0;
}


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

using ll = long long;
using ull = uint64_t;
using P = pair<int, int>;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
// constexpr int mod = 1000000007;
constexpr int mod = 998244353;

template<class T>
inline bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template<typename T>
struct CumulativeSum2D{
    vector<vector<T>> data;

    CumulativeSum2D(int W, int H) : data(W + 1, vector<T>(H + 1, 0)) {}

    void add(int x, int y, T z){
        ++x, ++y;
        if(x >= data.size() || y >= data[0].size()) return;
        data[x][y] += z;
    }

    void build(){
        for(int i = 1; i < data.size(); ++i){
            for(int j = 1; j < data[i].size(); ++j){
                data[i][j] += data[i][j - 1] + data[i - 1][j] - data[i - 1][j - 1];
            }
        }
    }

    T query(int sx, int sy, int gx, int gy){
        return (data[gx][gy] - data[sx][gy] - data[gx][sy] + data[sx][sy]);
    }
};

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

    int n, k;
    cin >> n >> k;
    CumulativeSum2D<int> S(k * 2, k * 2);
    for(int i = 0; i < n; ++i){
        int x, y;
        char c;
        cin >> x >> y >> c;
        if(c == 'B')    x += k;
        x %= k * 2, y %= k * 2;
        S.add(x, y, 1);
    }
    S.build();
    int ans = 0;
    for(int i = 0; i <= k; ++i){
        for(int j = 0; j <= k; ++j){
            int X = S.query(i, j, i + k, j + k);
            X += S.query(0, 0, i, j);
            X += S.query(i + k, 0, k * 2, j);
            X += S.query(0, j + k, i, k * 2);
            X += S.query(i + k, j + k, k * 2, k * 2);
            chmax(ans, X);
        }
    }
    for(int i = k; i <= k * 2; ++i){
        for(int j = 0; j <= k; ++j){
            int X = S.query(i, j, k * 2, j + k);
            X += S.query(i - k, 0, i, j);
            X += S.query(i - k, j + k, i, k * 2);
            X += S.query(0, j, i - k, j + k);
            chmax(ans, X);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 19024
#include<iostream>

using namespace std;

int main()
{
    int l;
    int x[10000], y[10000];
    for( l = 0; ; l++ )
    {
        cin >> x[l] >> y[l];
	if( x[l] == 0 && y[l] == 0 )
            break;
    }

    for( int i = 0; i < l; i++)
    {
        if( x[i] > y[i])
        {
            int tmp = x[i];
	    x[i] = y[i];
	    y[i] = tmp;
        }
        cout << x[i] << ' ' << y[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 3104
#include <iostream>

using namespace std;

using int64 = long long;

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

int64 lcm(int64 a, int64 b)
{
    return a / gcd(a, b) * b;
}

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

    int64 ans = 1, T;
    for (int i = 0; i < N; i++) {
        cin >> T;
        ans = lcm(ans, T);
    }

    cout << ans << endl;    
    return 0;
}



Measured memory_bytes: 256