akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = (int)(a) ; i < (int)(b) ; i++)


#define SZ(x) ((int)(x).size())


typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
struct Vec{
    double x, y;
};

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

template<class T>
T min(T a, T b)
{
    if (a < b) return a;
    return b;
}

template<class T>
T max(T a, T b)
{
    if (a > b) return a;
    return b;
}

using namespace std;

int main()
{
    int N;
    cin >> N;
    cout << (N + 1) / 2 << endl;
    return 0;
}


Measured memory_bytes: 3644
import java.util.*;

//update 2020/1/1 23:01

public class Main{

  static Scanner sc = new Scanner(System.in);
  static StringBuilder sb = new StringBuilder();

  public static void main(String[] args) {

    for(int i=1;i<=5;i++){
      int x = nextInt();
      if(x!=i){
        System.out.println(i);
        break;
      }
    }




    //System.out.println();

  }

  static int lcm(int a,int b){
    return a*b*gcd(a,b);
  }

  static int gcd(int a,int b){
    if(a%b!=0){
      return gcd(b,a%b);
    }
    else{
      return b;
    }
  }

  /*
    static String toSmall(String s){
      char c = s.charAt(0);
      //if(Character.isUpperCase(c)){
      if(c<=90){
        c += 32;
      }
      return String.valueOf(c);
    }
    static String toBig(String s){
      char c = s.charAt(0);
      //if(Character.isLowerCase(c)){
      if(c>=97){
        c -= 32;
      }
      return String.valueOf(c);
    }
  */

  static String toSmall(String s){
    return s.toLowerCase();
  }

  static String toBig(String s){
    return s.toUpperCase();
  }

  static String next(){
    return sc.next();
  }

  static int nextInt(){
    return Integer.parseInt(sc.next());
  }

  static long nextLong(){
    return Long.parseLong(sc.next());
  }

  static double nextDouble(){
    return Double.parseDouble(sc.next());
  }

  static String[] splitString(String s){
    return s.split("");
  }

  static char[] splitChar(String s){
    return s.toCharArray();
  }

  static int charToInt(char a){
    return a - 48;
  }

////////////////////////////////////////////
  public static int max(int[] a){
    int lng = a.length;
    int max = a[0];
    for(int i=1;i<lng;i++){
      max = Math.max(max,a[i]);
    }
    return max;
  }
  public static long max(long[] a){
    int lng = a.length;
    long max = a[0];
    for(int i=1;i<lng;i++){
      max = Math.max(max,a[i]);
    }
    return max;
  }
////////////////////////////////////////////

////////////////////////////////////////////
  public static int min(int[] a){
    int lng = a.length;
    int min = a[0];
    for(int i=1;i<lng;i++){
      min = Math.min(min,a[i]);
    }
    return min;
  }
  public static long min(long[] a){
    int lng = a.length;
    long min = a[0];
    for(int i=1;i<lng;i++){
      min = Math.min(min,a[i]);
    }
    return min;
  }
////////////////////////////////////////////

}


Measured memory_bytes: 35632
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define inf 20021225
#define ll long long
using namespace std;

ll N,x,ans;

int main()
{
	scanf("%lld%lld",&N,&x);
	ans+=N; ll a=x,b=N-x,tmp;
	while(a && b)
	{
		if(a>b)	swap(a,b);
		tmp = b/a*a;
		//printf("%lld %lld %lld\n",a,b,tmp);
		b%=a;	ans+=2*tmp;
		if(!b)	ans-=a;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#define SIZE 244140625

int Hash(const char* c)
{
    int Hash = 0;
    while(*c){
        Hash *= 5;
        switch(*c){
        case 'A':
            Hash += 1; break;
        case 'C':
            Hash += 2; break;
        case 'G':
            Hash += 3; break;
        case 'T':
            Hash += 4; break;
        }
        ++c;
    }
    return Hash;
}
int main()
{
    bool* dic = new bool[SIZE];
    int n;
    std::scanf("%d\n", &n);
    char str[21];
    while(n--){
        std::gets(str);
        if(str[0] == 'i'){
            dic[Hash(str+7)] = true;
        }else{
            std::puts((dic[Hash(str+5)] ? "yes" : "no"));
        }
    }
    return 0;
}

Measured memory_bytes: 11760
#include<deque>
#include<stdint.h>
#include<set>
#include<stack>
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<queue>
#include<cstring>
#include<map>
using namespace std;
int a,b,c,d;
int main()
{
	cin>>a>>b>>c>>d;
	cout<<max(0,min(b,d)-max(a,c));
	return 0;
	} 

Measured memory_bytes: 256
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "\n" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N, K, C;
	cin >> N >> K >> C;

	string S;
	cin >> S;

	vector<int> fast(N), slow(N);
	int fcnt = 0;
	for (int i = 0; i < N; i++) {
		if (S[i] == 'o') {
			fast[i] = ++fcnt;
			i += C;
		}
	}
	int scnt = K;
	for (int i = N - 1; i >= 0; i--) {
		if (S[i] == 'o') {
			slow[i] = scnt--;
			i -= C;
		}
	}

	for (int i = 0; i < N; i++) {
		if (fast[i] && fast[i] == slow[i]) cout << i + 1 << "\n";
	}

	return 0;
}

Measured memory_bytes: 3348
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
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; }
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll INF = 1LL<<60;
const ll MOD = 1e9 + 7;


int main() {
    ll N,K;
    cin >> N >> K;
    vector<ll> vec;
    for (ll i = 0;i<N;i++) {
        ll a;
        cin >> a;
        vec.push_back(a);
    }
    sort(vec.begin(),vec.end());
    ll ans = 0;
    for (ll i = 0;i<K;i++) {
        ans+=vec.at(i);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3636
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <list>
#include <string.h>
#include <functional>
#include <unordered_set>
#define rep(i, n) for(int i = 0; i < n; i++)
//#include <Windows.h>
//#include "Library.h"
//#include "Math.h"
using namespace std;
typedef long long int ll; typedef pair <int, int> P; typedef vector <int> vecint;
const int INF = 100000000000;
const double EPS = 10e-9;
int dis[10];
int dist[10];
struct edge
{
	int to, cost; 
	edge() {};
	edge(int t, int c) { to = t, cost = c; }
};
vector <edge> G[10];
void dijkstra(int v)
{
	priority_queue <P, vector <P>, greater <P> > q;
	q.push(P(0, v));
	while (!q.empty())
	{
		int v = q.top().second;
		int d = q.top().first;
		q.pop();
		if (dis[v] < d) continue;
		rep(i, G[v].size())
		{
			edge e = G[v][i];
			if (dis[e.to] > dis[v] + e.cost)
			{
				dis[e.to] = dis[v] + e.cost;
				q.push(P(dis[e.to], e.to));
			}
		}
	}
}
int main()
{
	int h, w; cin >> h >> w;
	rep(i, 10)
	{
		rep(j, 10)
		{
			int c; cin >> c;
			G[i].push_back(edge(j, c));
		}
	}
	dist[1] = 0;
	rep(i, 10)
	{
		if (i == 1) continue;
		fill(dis, dis + 10, INF);
		dis[i] = 0;
		dijkstra(i);
		dist[i] = dis[1];
	}
	ll res = 0;
	rep(i, h)
	{
		rep(j, w)
		{
			int num; cin >> num;
			if (num == -1) continue;
			res += dist[num];
		}
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>
#include <unordered_map>

using namespace std;
typedef long long int ll;

#define SP(x) setprecision((int)x)
#define ALL(v) v.begin(), v.end()

// 約数の列挙O(sqrt(n))
vector<ll> divisor (ll n) {
    vector<ll> res;
    for (ll i = 1; i * i <= n; i++)
    {
        if (n % i == 0) {
            res.push_back(i);
            if (i * i != n) res.push_back(n / i);
        }
    }
    return res;
}

ll GetDigit(ll num)
{
    return std::to_string(num).length();
}

int main(int argc, char const *argv[])
{
    ll n;
    cin >> n;
    vector<ll> v = divisor(n);
    ll m = LLONG_MAX;
    for (auto i : v)
    {
        m = min(m, (max(GetDigit(i), GetDigit(n / i))));
    }
    cout << m << endl;
}

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

using namespace std;

int main(){

  int n, a[100], sum=0;

  cin>>n;
  for(int i=0;i<n;i++) cin>>a[i];

  sort(a, a+n, greater<int>());

  for(int i=0;i<n;i++){
    if(i%2==0) sum+=a[i];
    else sum-=a[i];
  }

  cout<<sum<<endl;

  return 0;
}


Measured memory_bytes: 256
n  =int(input())
ta=[]
for i in range(n):
    ta.append(list(map(int,input().split())))

import math
for i in range(n-1):
    bai = max(math.ceil((ta[i][0]-1)//ta[i+1][0]+1),math.ceil((ta[i][1]-1)//ta[i+1][1]+1))
    ta[i+1][0]=ta[i+1][0]*bai
    ta[i+1][1]=ta[i+1][1]*bai
print(ta[n-1][0]+ta[n-1][1])



Measured memory_bytes: 3188
def check():
    H, W = map(int, input().split())
    S = [0]*(H+2)
    S[0] = '.'*(W+2)
    S[H+1] = '.'*(W+2)
    for h in range(1,H+1):
        S[h] = '.' + input() + '.'
    
    dh = [0,1,0,-1]
    dw = [1,0,-1,0]
    
    for h in range(1,H+1):
        for w in range(1,W+1):
            if S[h][w]=='.':
                continue
            for i in range(4):
                h0 = h+dh[i]
                w0 = w+dw[i]
                if S[h0][w0]=='#':
                    break
            else:
                return 'No'
    return 'Yes'
    
print(check())

Measured memory_bytes: 9236
//subset sum problem

#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
typedef long long int ll;
typedef unsigned long long int ull;
#define fi first
#define se second
#define pb push_back
ll mod1=pow(10,9)+7;
int mod2=998244353;
ll inf=1e9;
ll maxxy=1e6+9;
typedef long double ld;
const double PI =  3.141592653589793238;

ll power(ll x, ll y, ll pp)
{
    ll res = 1;
    x = x % pp;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % pp;
        y = y>>1;
        x = (x*x) % pp;
    }
    return res;
}

ll modInverse(ll n, ll pp)
{
    return power(n, pp-2, pp);
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll h,w;
    cin>>h>>w;
    char a[h][w];
    int dp[h][w];
    for (int i = 0; i <h ; ++i) {
        for (int j = 0; j <w ; ++j) {
            cin>>a[i][j];
        }
    }
    for (int i = 0; i <h ; ++i) {
        for (int j = 0; j <w ; ++j) {
            if(a[i][j]=='#'){
                dp[i][j]=0;
            }
            else{
                if(i==0 && j==0){
                    dp[i][j]=1;
                }
                else{
                    dp[i][j]=0;
                    if(i-1>=0) {
                        dp[i][j] += dp[i - 1][j];
                        dp[i][j] %= mod1;
                    }
                    if(j-1>=0) {
                        dp[i][j] += dp[i][j - 1];
                        dp[i][j] %= mod1;
                    }
                }
            }
        }
    }
    cout<<dp[h-1][w-1]<<"\n";
    return 0;
}


Measured memory_bytes: 8464
def main():
    n = int(input())
    cnt = dict()
    for i in range(n):
        t = input()
        s = "".join(sorted(t))
        try:
            cnt[s] += 1
        except:
            cnt[s] = 1
    ans = 0
    for v in cnt.values():
        ans += (v * (v - 1)) // 2
    print(ans)

main()

Measured memory_bytes: 17888
#include <algorithm>
#include <map>
#include <vector>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cctype>
#include <cstdlib>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define IREP(it,array) for(vector<int>::iterator it=array.begin(); it!=array.end(); ++it)
#define PREP(it,array) for(vector<P>::iterator it=array.begin(); it!=array.end(); ++it)
#define SREP(it,array) for(vector<string>::iterator it=array.begin(); it!=array.end(); ++it)

#define MP       make_pair
#define PB       push_back
#define ALL(x)   (x).begin(),(x).end()

const int INF = 1<<29;
const double EPS = 1e-9;
double zero(double d){
  return d < EPS ? 0.0 : d;
}

typedef long long LL;
typedef pair<int,int> P;


int main()
{
  cout.setf(ios::fixed, ios::floatfield);
  cout.precision(2);

  int n,m;
  while( cin>>n>>m, n ){
    double g[n][n];
    REP(i,n){
      REP(j,n){
	double t;
	cin >> t;
	g[i][j] = t;
      }
    }

    double dp[m+1][n];
    memset( dp, 0, sizeof(dp) );
    REP(i,n)
      dp[0][i] = 1.0;

    REP(i,m-1){
      REP(j,n){
	REP(k,n)
	  dp[i+1][j] = max( dp[i+1][j], dp[i][k] * g[k][j] );
      }
    }
    
    double res=0.0;
    REP(i,n){
      res = max( res, dp[m-1][i] );
    }

    cout << res << endl;
  }


  return 0;
}

Measured memory_bytes: 1380
#include <iostream>
#include <vector>

using namespace std;

int main(void) {
	vector<int> answer;
	while(1) {
		int a, b;
		char op;
		cin >> a >> op >> b;
		if (op == '?') break;
		switch(op) {
			case '+': 
				answer.push_back(a+b);
				break;
			case '-': 
				answer.push_back(a-b);
				break;
			case '/': 
				answer.push_back(a/b);
				break;
			case '*': 
				answer.push_back(a*b);
				break;
		}
	}
	for (int i = 0; i < answer.size(); ++i) {
		cout << answer[i] << endl;
	}

	return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define DEBUG_ARR(v,n) cout<<#v<<":";REP(i,n)cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD
int n,m,q;
int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    cin>>n>>m>>q;
    vi a(q),b(q),c(q),d(q);
    REP(i,q){
        cin>>a[i]>>b[i]>>c[i]>>d[i];
    }

    ll ans=0;
    FOR(i1,1,m+1){
    FOR(i2,i1,m+1){
    FOR(i3,i2,m+1){
    FOR(i4,i3,m+1){
    FOR(i5,i4,m+1){
    FOR(i6,i5,m+1){
    FOR(i7,i6,m+1){
    FOR(i8,i7,m+1){
    FOR(i9,i8,m+1){
    FOR(i10,i9,m+1){
        vi r ={i1,i2,i3,i4,i5,i6,i7,i8,i9,i10};

        ll tmp=0;
        REP(j,q){
            if(r[b[j]-1] - r[a[j]-1] == c[j]){
                tmp += d[j];
            }
        }
        ans = max(ans,tmp);
    }
    }
    }
    }
    }
    }
    }
    }
    }
    }

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

Measured memory_bytes: 3608
input_list = []

while True:
    pair_str = input().split()
    pair_int = [int(s) for s in pair_str]
    if pair_int[0] == 0 and pair_int[1] == 0 :
        break
    else:
        input_list.append(pair_int)

for pair_int in input_list:
    if pair_int[0] <= pair_int[1]:
        print("{} {}".format(pair_int[0], pair_int[1]))
    else:
        print("{} {}".format(pair_int[1], pair_int[0]))


Measured memory_bytes: 5988
#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 Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

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

	int cnta = 0;
	int cntb = 0;
	int cntc = 0;

	rep(i,n){
		if(s[i] == 'c'){
			cout << "No" << endl;
			continue;
		}

		if(s[i] == 'a'){
			if(cnta + cntb < (a + b)){
				cnta++;
				cout << "Yes" << endl;
			}
			else{
				cout << "No" << endl;
			}
			continue;
		}

		if(s[i] == 'b'){
			if(cnta + cntb < (a + b) && cntb < b){
				cntb++;
				cout << "Yes" << endl;
				continue;
			}
			else{
				cout << "No" << endl;
				continue;
			}
		}
	}
}

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

using Int = long long;
using ll = long long;

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

template<typename T> void drop(T x){cout<<x<<endl;exit(0);};

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

  int n;
  cin>>n;

  vector<int> rs(n),cs(n);
  for(int i=0;i<n;i++) cin>>rs[i]>>cs[i],rs[i]--,cs[i]--;

  vector<int> as(n,0),bs(n,0);
  for(int i=0;i<n;i++) as[rs[i]]++;
  for(int i=0;i<n;i++) bs[cs[i]]++;

  if(*min_element(as.begin(),as.end())==0) drop(-1);
  if(*min_element(bs.begin(),bs.end())==0) drop(-1);

  using P = pair<int, int>;
  vector<P> vp;
  for(int i=0;i<n;i++) vp.emplace_back(rs[i],cs[i]);

  sort(vp.begin(),vp.end());
  vector<int> ds(n);
  for(int i=0;i<n;i++) ds[i]=vp[i].second;

  int ans=0;
  for(int i=0;i<n;i++){
    while(ds[i]!=i){
      //cout<<i<<":"<<ds[i]<<endl;
      swap(ds[i],ds[ds[i]]);
      ans++;
    }
  }
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 5720
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define rep(i,s,e) for(int i=s;i<e;i++)
#define endl '\n'
int main(){
    lli x;cin>>x;
    lli base=100;
    double rate=0.01;
    int res=0;
    while(base<x){
        base*=(1+rate);
        res++;
    }
    cout<<res<<endl;
}

Measured memory_bytes: 3676
//https://atcoder.jp/contests/abc133/tasks/abc133_e
#include <cstdio>
#include <vector>
using namespace std;
typedef long long int ll;
 
const int MAXN = 1e5 + 5;
const int mod = 1e9 + 7;
 
int n, k, u, v;
ll ans;
ll dp[MAXN];
vector<int> con[MAXN];
 
void ins(int start, int end) {
    con[start].push_back(end);
}
 
void get_dp(int nv, int fa) 
{
    int tmp = (nv == 1) ? (k - 1) : (k - 2);
    for (int i = 0; i < con[nv].size(); ++i) 
	{
        if (con[nv][i] == fa) continue;
        dp[con[nv][i]] = tmp;
        get_dp(con[nv][i], nv);
        --tmp;
    }
}
 
int main() {
    scanf("%d%d", &n, &k);
    for (int i = 1; i < n; ++i) {
        scanf("%d%d", &u, &v);
        ins(u, v);
        ins(v, u);
    }
    dp[1] = k;
    get_dp(1, 0);
    ans = 1;
    for (int i = 1; i <= n; ++i) {
        ans = ans * dp[i] % mod;
    }
    printf("%lld", ans);
    return 0;
}

Measured memory_bytes: 11136
import bisect,collections,copy,heapq,itertools,math,string
import sys
def S(): return sys.stdin.readline().rstrip()
def M(): return map(int,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
a, b, k = M()
if k >= a:
    k -= a
    a = 0
else:
    a -= k
    k = 0
if k >= b:
    b = 0
else:
    b -= k
print(a, b)

Measured memory_bytes: 74504
import java.util.*;

class Main{
  public static void main(String args[]){
    Scanner scan = new Scanner(System.in);
    int a = scan.nextInt();
    int b = scan.nextInt();
    if(a%2==1 && b%2==1){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}


Measured memory_bytes: 23124
from itertools import permutations
n, c = map(int, input().split())
D = [list(map(int, input().split())) for _ in range(c)]
C = [list(map(int, input().split())) for _ in range(n)]

colors = [[0]*c for _ in range(3)]
for i in range(n):
    for j in range(n):
        c_ij = C[i][j]-1
        index = (i+j)%3
        colors[index][c_ij] += 1

costs = [[0]*c for _ in range(3)]
for i in range(3):
    for c_cur in range(c):
        for c_tar in range(c):
            costs[i][c_tar] += D[c_cur][c_tar]*colors[i][c_cur]

ans = 1000*500**2
for c0, c1, c2 in permutations(range(c), 3):
    diff = costs[0][c0] + costs[1][c1] + costs[2][c2]
    ans = min(ans, diff)
print(ans)


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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define fi first
#define se second
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;}

int N;
string S[20];
int mem[256];
bool used[10];

int solve(int x,int y,int t){
    if(x==8){
        return t==0;
    }

    if(y==N){
        if(t<0||t%10)return false;
        return solve(x+1,0,t/10);
    }

    if(S[y].size()<=x)return solve(x,y+1,t);

    int ret=0;
    for(int i=0;i<10;i++){
        if(S[y].size()>1&&x+1==S[y].size()&&i==0)continue;
        if(mem[S[y][x]]!=-1){
            if(mem[S[y][x]]!=i)continue;
            ret+=solve(x,y+1,t+i*(y==N-1?-1:1));
        }
        else if(!used[i]){
            mem[S[y][x]]=i;used[i]=1;
            ret+=solve(x,y+1,t+i*(y==N-1?-1:1));
            mem[S[y][x]]=-1;used[i]=0;
        }
    }
    return ret;
}

signed main(){
    memset(mem,-1,sizeof(mem));
    while(cin>>N,N){
        rep(i,N)cin>>S[i];
        rep(i,N)reverse(all(S[i]));
        cout<<solve(0,0,0)<<endl;
    }
    return 0;
}

Measured memory_bytes: 3148
import sys

S = input()
alphabet_code = list(range(26))

i = 0
j = 0
while i < len(S):
    while j < 26:
        if ord(S[i]) == alphabet_code[j] + 97:
            alphabet_code[j] = -1
        j += 1
    j = 0
    i += 1

while j < 26:
    if alphabet_code[j] != -1:
        print(chr(alphabet_code[j] + 97))
        sys.exit(0)
    j += 1
print("None")


Measured memory_bytes: 3316
#include<bits/stdc++.h>
#include <array>
using namespace std;
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

template<class Ty>
using passive_queue = priority_queue<Ty, vector<Ty>, greater<Ty>>;

struct Problem {

	void Solve() {
		//string S; cin >> S;
		//rep(i, 3) if (S[i] == '7') { cout << "Yes" << endl; return; }
		//cout << "No" << endl;

		UL N; cin >> N;
		ULL ans = 0;
		for (UL i = 1; i <= N; i++) {
			if (i % 3 != 0) if (i % 5 != 0) ans += i;
		}
		cout << ans << endl;
	}

	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n) ;i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
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; }



int main(int argc, char const *argv[]) {
  int n,m;
  cin >> n >> m;
  vector<int> s(m),c(m);
  rep(i,m) cin >> s[i] >> c[i];
  int ans=-1;

  for(int i=1000; i>=0; i--){
    string S=to_string(i);
    bool ok=true;
    if(sz(S)!=n) ok=false;
    for(int j=0; j<m; j++){
      if(S[s[j]-1]!=(char)(c[j]+'0')) ok=false;
    }
    if(ok) ans=i;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
n=int(input())
a = [int(i) for i in input().split()]

def amari(a):
  y=0
  for i in range(n):
    if a[i]%2==1:
      y=1
  return y

cnt=0
while amari(a)==0:
  for i in range(n):
    a[i]=a[i]/2
  cnt+=1
  
print(cnt)




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

const string YES = "Possible";
const string NO = "Impossible";

int main(){
    ll n, l;
    cin >> n >> l;
    vector<pair<ll, ll>> a;
    vector<ll> ans;
    REP(i, n){
        ll ai;
        cin >> ai;
        a.emplace_back(ai, i);
        while(a.size() >= 2 && a.at(a.size() - 1).first + a.at(a.size() - 2).first >= l){
            auto p1 = a.back(); a.pop_back();
            auto p2 = a.back(); a.pop_back();
            ans.push_back(p1.second);
            a.emplace_back(p1.first + p2.first, p2.second);
        }
    }

    if(a.size() > 1){
        cout << NO << endl;
    }else{
        cout << YES << endl;
        assert(ans.size() == n - 1);
        reverse(ans.begin(), ans.end());
        for(ll i : ans){
            cout << i << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 4208
#include <bits/stdc++.h>
#include <algorithm>
#include <time.h>
#define l(x) x<<1
#define r(x) ((x<<1) | 1)
#define x first
#define y second
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
const int inf = 2*(1e9) + 10;
const long long MOD = 1000000009;
const int NMAX = 1000005;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};

int n;

int sumd(int v){
    int sum = 0;
    while(v)
    {
        sum+= (v % 10);
        v /= 10;
    }
    return sum;
}

int main(){
    cin>>n;
    int maxv, winn;
    maxv = 100000000;
    winn = 0;
    int i = 1;
    while(i < n){
        if (sumd(i) + sumd(n - i) <= maxv)
            maxv = sumd(i) + sumd(n - i), winn = i;
        i = i*10;
    }
    cout<<maxv<<"\n";

  return 0;
}


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

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;


int dp[100010][11];

int main(void){
	string in;
	while(cin >> in){
		if(in=="0") break;
		int n=in.size();
		rep(i,n+1)rep(j,11) dp[i][j]=0;

		rep(i,n){
			int digit=in[i]-'0';
			if(digit!=0) dp[i][digit]++;
			rep(j,11) if(i-1>=0) dp[i][(j*10+digit)%11]+=dp[i-1][j];
		}

		int ans=0;
		rep(i,n+1) ans+=dp[i][0];
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 5420
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const ll inf = 1e18;
const int MAX = 2005;

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

int f(ll x) {
    int res = 0;
    while (x % 2 == 0) {
        x /= 2;
        res++;
    }
    return res;
}

int main() {
    int n;
    ll m; 
    cin >> n >> m;
    vll a(n);
    rep(i,n) {
        int x; cin >> x;
        x /= 2;
        a[i] = x;
    }
    int l = f(a[0]);
    REP(i,n) {
        if (l != f(a[i])) {cout << 0 << endl; return 0;}
    }
    ll x = 1;
    for (int i = 0; i < n; i++) x = lcm(x,a[i]);
    if (x > m) {cout << 0 << endl; return 0;}
    m >>= l;
    x >>= l;
    cout << (m/x+1)/2 << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long
#define rep(i,a,b) for(long long i=a; i<b; i+=1)
#define repr(i,a,b) for(long long i=a; i<=b; i+=1)
#define vec vector<ll>
#define map map<string,int>
#define repa(p,A) for(auto p:A)
#define pb push_back
#define sort(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())

using namespace std;
int main() {
  ll N;
  cin>>N;
  cout<<(N+1)/2<<endl;
}


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

int main() {
    int n;
    cin >> n;
    int sum = 0;
    vector<int> s(n);
    for (int i = 0; i < n; i++) {
        cin >> s.at(i);
        sum += s.at(i);
    }

    if (sum % 10 > 0) {
        cout << sum << endl;
        return 0;
    }

    sort(s.begin(), s.end());
    for (int i = 0; i < n; i++) {
        if (s.at(i) % 10 > 0) {
            cout << sum - s.at(i) << endl;
            return 0;
        }
    }
    
    cout << 0 << endl;
}   

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

using namespace std;
using LL = long long;
using P = pair<int,int>;

int main(){
	int X, Y;
	cin >> X >> Y;
	rep(i,X+1){
		if(i*2+(X-i)*4==Y){
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 3600
import math
N, K = map(int, input().split())

var = N % K
if var == 0:
        print(0)
elif var == K-1 or var == 1:
        print(1)
else:
        while N >= math.ceil(K / 2):
                N = abs(N-K*(N//K+1))
        print(N)

Measured memory_bytes: 3060
import qualified Data.ByteString.Char8 as BS
import Data.Maybe

readInt = fromIntegral . fst . fromJust . BS.readInteger
readIntList = map readInt . BS.words

getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
  k <- getInt
  [a, b] <- getIntList
  putStrLn $ if b `div` k - (a-1) `div` k == 0 then "NG" else "OK"

Measured memory_bytes: 3692
#include<iostream>
#include<stdio.h>

using namespace std;

int main()
{
  int a1,a2,a3;
  cin>>a1>>a2>>a3;

  if(a1+a2+a3>21)
    cout<<"bust"<<endl;
  else
    cout<<"win"<<endl;
  return 0;
}


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

int main() {
    int n, temp, ans = 0;
    cin >> n;
    rep(i, n) {
        cin >> temp;
        while(temp % 2 == 0) {
            ans++;
            temp /= 2;
        }
    }
    cout << ans << endl;
}

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

int main(void){
    int n;
    cin>>n;
    vector<ll> a(n);
    rep(i,n) cin>>a[i];
    rep(i,n-1) a[i+1] += a[i];

    ll res = a[n-1];
    int left = 0, right = 0;
    rep(m,n){
        while(left < m){
            if(a[left]>=a[m]-a[left]) break;
            left++;
        }
        right = max(right,m+1);
        while(right < n-1){
            if(a[right]-a[m]>=a[n-1]-a[right]) break;
            right++;
        }

        int K = 1;
        for(int l = max(left-K,0); l < min(m,left+K); l++){
            for(int r = max(right-K,m+1); r < min(right+K,n-1); r++){
                vector<ll> seg = {a[l],a[m]-a[l],a[r]-a[m],a[n-1]-a[r]};
                sort(all(seg));
                res = min(res, seg[3]-seg[0]);
            }
        }
    }
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = (0); i < (n); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define DEBUG(val) cout << #val << " : " << val << endl
#define MOD 1000000007

int main() {
  int n;
  vector<ll> data;
  cin >> n;
  REP(i, n) {
    ll x;
    cin >> x;
    data.push_back(x);
  }
  ll all_xor = data[0];
  FOR(i, 1, n) { all_xor ^= data[i]; }
  REP(i, n) {
    if (i != n - 1) {
      cout << (data[i] ^ all_xor) << " ";
    } else {
      cout << (data[i] ^ all_xor) << endl;
    }
  }
}

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

int main()
{
	int w = 0, h = 0, x = 0, y = 0, r = 0;
	cin >> w >> h >> x >> y >> r;

	if ((x < r) || (x > (w - r)) || (y < r) || (y > (h - r))) {
		cout << "No" << endl;
	}
	else
	{
		cout << "Yes" << endl;
	}

	return 0;
}


Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define sz(A) (int)(A.size())
#define all(x) (x).begin(),(x).end()
#define get(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
typedef long long ll;
typedef pair<int, int> PII;
typedef vector<int> VI;

void solve() {
	int a, b, c, k;
	cin >> a >> b >> c >> k;
	if (k-a <= b) {
		cout << min(a, k) << endl;
	}
	else {
		cout << a + a + b - k << endl;
	}
}
int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int T_ = 1;
	//cin >> T_;
	for (int i = 0; i < T_; i++)solve();
	return 0;
}







Measured memory_bytes: 3672
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
int dfs (int cur, const vector<vector<int>>& g) {
  vector<int> v;
  for (int nxt : g[cur]) {
    v.push_back(dfs(nxt, g));
  }
  sort(v.rbegin(), v.rend());
  int res = 0;
  for (int i = 0; i < (int) g[cur].size(); i++) {
    res = max(res, i + 1 + v[i]);
  }
  return res;
}
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  int n;
  cin >> n;
  vector<vector<int>> g(n);
  for (int i = 1; i < n; i++) {
    int a;
    cin >> a;
    g[--a].push_back(i);
  }
  cout << dfs(0, g) << '\n';
  return 0;
}

Measured memory_bytes: 16640
import java.util.Scanner;

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

        int a = scan.nextInt();
        int b = scan.nextInt();
        int c = scan.nextInt();

        if((a < b) && (b < c)){
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}



Measured memory_bytes: 26132
program taskd;
var s,s5,s6,s7,s10:string;
    process,i,j,len:longint;
begin
readln(s);
process:=1;
len:=Length(s);
while process<len do
begin
  s5:=Copy(s,process,5);
  s6:=Copy(s,process,6);
  s7:=Copy(s,process,7);
  s10:=Copy(s,process,10);
  if (s7='dreamer') and (s10<>'dreamerase') then
  process:=process+7
  else if s6='eraser' then
  process:=process+6
  else if (s5='dream') or (s5='erase') then
  process:=process+5
  else
  break;
end;
if process<=len then
writeln('NO')
else
writeln('YES');
end.


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

using namespace std;

#define ll long long

int main() {
	ll A, B, C, ans;
	cin >> A >> B >> C;
	ans = A * B * ((C + 1) / 2 - C / 2);
	ans = min(ans, A * C * ((B + 1) / 2 - B / 2));
	ans = min(ans, C * B * ((A + 1) / 2 - A / 2)); 
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/math/constants/constants.hpp>
using namespace std;
typedef long long ll;
long double e = boost::math::constants::e<long double>();
long double pi = boost::math::constants::pi<long double>();
// 条件を見落としていませんか？

int main () {
    int x[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int K;
    cin >> K;
    cout << x[--K] << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define debug(x) cerr << #x << ':' << x << endl
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define ALL(c) (c).begin(), (c).end()
using namespace std;
typedef long long ll;

int main(){
    double R0,W0,C,R;

    while(1){
        cin >> R0 >>W0 >> C >> R;
        if(R0==0 && W0==0 && C==0 && R==0)break;

        ll left = 0LL, right = 10000000000;
        while(1){
            // cout << left << " " <<right << endl;
            int X = (left + right) / 2;
            double c_ = (R0 + X*R)/W0;
            if( C <= c_){
                right  = X;
            }
            else{
                left = X;
            }
            if(abs(left - right) <=1) break;
        }
        if(C <= (R0 + left*R)/W0) cout << left << endl;
        else cout << right << endl;
    }
    return 0;
}


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

/*

 * */

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

    double x[N];
    string u[N];
    rep(i, N){
        cin >> x[i] >> u[i];
    }

    double ans = 0;
    rep(i,N){
        if(u[i] == "JPY"){
            ans += x[i];
        }else{
            ans += x[i] * 380000.0;
        }
    }
    cout << ans << endl;
    return 0;
}


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

typedef long long ll;
typedef pair<ll, ll> pll;

#define m0(x) memset(x, 0, sizeof(x))
#define all(x) x.begin(), x.end()
#define rep(i, n) for(int i = 0; i < (n); i++)
#define asort(x) sort(all(x));
#define dsort(x, t) sort(x.begin(), x.end(), greater<t>());
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define MINS(m, s) m.insert(mp(s, 1));
#define MFIN(m, s) m.find(s) != m.end()
#define INF (1 << 29)
const int mod = 1000000007;

int main() {
    string s;
    cin >> s;
    for(int i = 0; i < s.length(); i++) {
        cout << "x";
    }
    cout << endl;
    return 0;
}

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

typedef long long int llint;

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

  string ans = "";
  
  while(n) {
    int m = n % 10;
    if(m == 1) ans += '9';
    else ans += '1';
    n /= 10;
  }

  reverse(ans.begin(), ans.end());
  
  cout<< ans <<endl;

  return 0;
}


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

typedef long long ll;

ll n;
int ans=2;

bool check(ll x){
    ll c=n;
    while(c%x==0)c/=x;
    return c%x==1;
}

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin>>n;if(n==2)ans--;
    for(ll i=2;i*i<=n;i++){
        ans+=check(i);
        if(n%i==0&&i*i<n)ans+=check(n/i);
        if((n-1)%i==0&&i*i<n-1)ans+=check((n-1)/i);
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
result = 0
def BT(k, current, s):
    global result
    if k >= len(a)-1 :
        if current == 0 :
            result += s
        # print(k,current,s,result)
    else :
        BT(k+1, int(a[k+1]), s+current)
        BT(k+1, current* 10 + int(a[k+1]), s)

a = input()+'0'
BT(0,int(a[0]),0)
print(result)


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

using namespace std;

int N;
int input[100000];
int score[100001];

int main() {
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> input[i];
		if (input[i] > 0)score[input[i] - 1]++;
		score[input[i]]++;
		if (input[i] < 100000)score[input[i] + 1]++;
	}
	cout << *max_element(score, score + 100001) << endl;
	return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>

int main( ){


  int t[200000],w,i,minv,maxv;
 
  scanf("%d",&w);

  for(i=0;i<w;i++){

    scanf("%d",&t[i]);

  }

  minv=t[0];
  maxv=t[1]-t[0];

  for(i=1;i<w;i++){

    if(maxv<t[i]-minv)maxv=t[i]-minv;
    
    if(minv>t[i]) minv=t[i];

  }
  
   
  printf("%d\n",maxv);

  return 0;

}

Measured memory_bytes: 1376
def main():
    n, m = map(int, input().split())
    f = [1, m]
    i = 2
    while i * i <= m:
        if m % i == 0:
            f.append(i)
            if m != i * i:
                f.append(m // i)
        i += 1
    f.sort()
    answer = 0
    for ff in f:
        if n <= ff:
            answer = m // ff
            break
    print(answer)


if __name__ == '__main__':
    main()



Measured memory_bytes: 3060
///Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>
using namespace std;
#define     int 	    long long
#define 	pb 	        push_back
#define 	mp 	        make_pair
#define 	pi 	        2*acos(0.0)
#define     scan(i)     scanf("%d",&i)
#define     loop(i,n) 	for(int i = 0 ; i <n ; i++)
#define 	vect 	    vector<int>
#define 	vec_it 	    vector<int>::iterator vi
#define     sorta(v)    sort(v.begin(),v.end())
#define     sortd(v)    sort(v.begin(),v.end(),greater<>())
#define 	mapp 	    map<int,int>
#define 	pairr 	    pair<int,int>
#define 	sett	    set<int>s
#define 	set_it 	    set<int>::iterator si
#define     map_it      map<int,int> :: reverse_iterator mi
#define 	yes 	    cout<<"YES"<<endl
#define 	no 	        cout<<"NO"<<endl
#define 	ff 	        first
#define 	ss 	        second
#define     mx          iNT_MAX
#define     lmx         LLONG_MAX
#define     mn          iNT_MiN
#define     lmn         LLONG_MiN
#define     GCD         __gcd(a,b)
#define     LCM         (a/GCD)*b
template <typename T> T gcd(T a,T b){return (b==0)?a:gcd(b,a%b);}
template <typename T> T lcm(T a,T b) {return a*(b/gcd(a,b));}
int modulo (int a, int b) { return a >= 0 ? a % b : ( b - abs ( a%b ) ) % b; }

void solve()
{
  // freopen ("(input).txt" , "r",  stdin) ;
  // string st,stt ;
  // int low=0,high=0;
  // int l,r;
    int n,k,t,b,c,x,y,z,d=0,temp=0,cnt=0,sum=0,f=0;
    cin>>n>>k>>x>>y;  ; vect v ,a  ; sett ; set_it ; mapp m,mp; pairr p; map_it;
    if(n<=k)
        cout<<x*n<<endl;
    else
        cout<<x*k+y*(n-k)<<endl;


}

main()
{
    int t;
  //  cin>>t;
  //  while(t--)
        solve();
}

Measured memory_bytes: 3596
#include<stdio.h>
#include<math.h>
#include<string.h>

int main()
{
	long int a, b;
	scanf("%ld %ld", &a, &b);
  
  int d=0;
 while(a>0){
   a = a/b;
   d++;
 }

  printf("%d", d);
		return 0;
	
}


Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        var N = Int32.Parse(Console.ReadLine());
        var A = new long[N];
        var B = new long[N];
        for (int i=0;i<N;++i)
        {
            var line = Console.ReadLine().Split(' ').Select(x => Int64.Parse(x)).ToArray();
            A[i] = line[0];
            B[i] = line[1];
        }
        Array.Sort(B,A);
        var currentTime = 0L;
        var ans = "Yes";
        for (int i=0;i<N;++i)
        {
            currentTime += A[i];
            if(B[i] < currentTime)
            {
                ans = "No";
                break;
            }
        }
        Console.WriteLine(ans);
    }
}



Measured memory_bytes: 20488
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
using namespace std;
typedef long long ll;
typedef pair<string,ll> P;

int main(){
  int n,m;
  cin>>n>>m;
  vector<ll> sw[15];
  for(int i=0;i<m;i++) {
    ll k;
    cin>>k;
    for(int j=0;j<k;j++){
      int ai;
      cin>>ai;
      ai--;
      sw[i].push_back(ai);
    }
  }
  int num[15]={0};
  for(int i=0;i<m;i++) cin>>num[i];
  ll ans=0;
  for(int i=0;i<(1<<n);i++){
    int array[15]={0};
    for(int j=0;j<n;j++){
      int onof=(i>>j)&1;
      array[j]=onof;
    }
   //for(int j=0;j<m;j++) cout<<array[j]<<" ";
   //cout<<endl;
    bool f=true;
    for(int j=0;j<m;j++){
      int ka=0;
      for(int k=0;k<sw[j].size();k++){
        ka+=array[sw[j][k]];
      }
      ka%=2;
      if(ka!=num[j]) f=false;
    }
    if(f) ans++;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){

    int a,b;
    char op;
    while(1){
        cin >> a >> op >> b;

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



}


Measured memory_bytes: 3100
#include "bits/stdc++.h"
#include<unordered_map>
#pragma warning(disable:4996)
using namespace std;

double eps = 1e-9;
int main() {
  int A; cin >> A;
  while (A--) {
    int N; cin >> N;
    vector<int>as;
    for (int i = 0; i < N; ++i) {
      int a; cin >> a;
      as.push_back(a);
    }
    sort(as.begin(), as.end());
    int Q; cin >> Q;
    for (int t = 0; t< Q; ++t) {
      int x, v; cin >> x >> v;
      double stoptime = double(v) / as.back();
      if (x + eps < stoptime*v / 2) {
        cout << "crash" << endl;
      }
      else {
        bool dp[201][101];
        memset(dp, false, sizeof(dp));
        dp[2 * x][v] = true;
        for (int i = 2 * x; i >0; --i) {
          for (int j = 1; j <= v; ++j) {
            if (dp[i][j]) {
              for (int k = 0; k < as.size(); ++k) {
                int nextspeed = j - as[k];
                if (nextspeed >= 0) {
                  if (i - j - nextspeed >= 0) {
                    dp[i - j - nextspeed][nextspeed] = true;
                  }
                }
              }
            }
            
          }
        }
        int dis = 9999;
        for (int i = 0; i <= 2 * x; ++i) {
          if (dp[i][0]) {
            dis = min(dis, i);
          }
        }
        if (dis == 9999) {
          cout << "try again" << endl;
        }
        else if (dis > 0) {
          cout << setprecision(3) << fixed << "good ";
          printf("%.3f", double(dis)/2);
          cout << endl;
        } 
        else {
          cout << "perfect" << endl;
        }
      }
    }
    if (A)cout << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3144
package main

import (
	"fmt"
	"math"
)

func makeCopy(nums []int) []int {
	return append([]int{}, nums...)
}

func factorial(n int) int {
	if n == 1 {
		return 1
	}
	return factorial(n-1) * n
}

func permute(nums []int, ret *[][]int) {
	*ret = append(*ret, makeCopy(nums))

	n := len(nums)
	p := make([]int, n+1)
	for i := 0; i < n+1; i++ {
		p[i] = i
	}
	for i := 1; i < n; {
		p[i]--
		j := 0
		if i%2 == 1 {
			j = p[i]
		}

		nums[i], nums[j] = nums[j], nums[i]
		*ret = append(*ret, makeCopy(nums))
		for i = 1; p[i] == 0; i++ {
			p[i] = i
		}
	}
}

func Permute(nums []int) [][]int {
	n := factorial(len(nums))
	ret := make([][]int, 0, n)
	permute(nums, &ret)
	return ret
}

func main() {
	var n int
	fmt.Scan(&n)
	x := make([]int, n)
	y := make([]int, n)
	nums := make([]int, n)
	for i := 0; i < n; i++ {
		nums[i] = i
		fmt.Scan(&x[i], &y[i])
	}

	sum := 0.0
	for _, v := range Permute(nums) {
		for i := 0; i < n-1; i++ {
			diff := math.Sqrt(math.Pow(float64(x[v[i]]-x[v[i+1]]), 2) + math.Pow(float64(y[v[i]]-y[v[i+1]]), 2))
			sum += diff
		}
	}
	fmt.Println(sum / float64(factorial(n)))
}


Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P   = pair<ll, ll>;
using mat = vector<vector<ll>>;

void IOS() { ios::sync_with_stdio(false), cin.tie(0); }

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

ll mod(ll a) {
	if (a > 0) return a % MOD;
	if (a % MOD == 0) return 0;
	ll x = -a / MOD + 1;
	a += x * MOD;
	return a % MOD;
}

template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}
// int dx[4]    = {1, 0, -1, 0};
// int dy[4]    = {0, 1, 0, -1};
// ll pas[5001][5002];

int main() {
	IOS();
	ll n;
	cin >> n;
	vector<ll> h(n);
	for (int i = 0; i < n; ++i) { cin >> h[i]; }
	bool unko = true;
	for (int i = 0; i < n; ++i) {
		if (h[i] != 0) unko = false;
	}
	if (unko) {
		cout << 0 << endl;
		return 0;
	}
	ll ans = 0;
	while (1) {
		int i = 0;
		while (h[i] == 0) ++i;
		while (h[i] > 0 && i < n) {
			h[i]--;
			++i;
		}
		ans++;
		bool ok = true;
		for (int i = 0; i < n; ++i) {
			if (h[i]) ok = false;
		}
		if (ok) break;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256