akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)

int main(){

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


	int n;cin>>n;
	map<string,int> m; int best=0;
	while(n--){
		string s;cin>>s;
		best=max(best,++m[s]);
	}
	set<string> st;
	for(auto x:m){
		if(x.second==best) st.insert(x.first);
	}
	for(auto x:st)cout<<x<<"\n";
}


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

using namespace std;

const int N = 1e5 + 5;
vector< int > g[N];
int dfs(int v, int par = -1) {
  int ret = 0;
  for (int u : g[v]) if (u != par)
    ret ^= (1 + dfs(u, v));
  return ret;
}

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    int u, v;
    scanf("%d %d", &u, &v);
    u--; v--;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  int ans = dfs(0);
  puts(ans ? "Alice" : "Bob");
  return 0;
}

Measured memory_bytes: 10368
import math
a,b,x = map(int,input().split())
v = a*a*b

if x >= (v/2):
    right = x - b*(a**2)
    left = -(a**2)/2
    y = right/left

    alpha = math.degrees(math.atan(y/a))
else:
    right = x
    left = b*a/2
    y = right/left
    alpha = math.degrees(math.atan(b/y))
    
print(alpha)

Measured memory_bytes: 38256
#include <iostream> 

using namespace std; 

int main() 
{ 
    int N;
    cin >> N;
    
    for (int i = 0; i <= 10000; i += 1000) {
        if (i - N >= 0) {
            cout << (i - N) << endl;
            return 0;
        }
    }
} 

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

int main() {
	int x,a,b;
	cin>>x>>a>>b;
	if(a>=b){
		cout<<"delicious"<<endl;
	}
	else if(x>=b-a){
		cout<<"safe"<<endl;
	}
	else{
		cout<<"dangerous"<<endl;
	}
}

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

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int

int main(){
  int A,B;
  cin>>A>>B;
  if(A>=13)
    cout<<B;
  else if(6<=A&&A<=12)
    cout<<B/2;
  else
    cout<<0;

  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
// #define int long long

template <class T>
bool INRANGE(T x, T a, T b) { return a <= x && x <= b; }
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;
}

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= (b); --i)
#define ALL(v) (v).begin(), (v).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;

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

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

    int l, r, d;
    cin >> l >> r >> d;

    int ans = 0;
    FOR(i, l, r+1) {
        if (i >= d) if (i%d == 0) ans++;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3580
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 1145141919364364
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}

int kai(int x) {
	if (x == 1)return 1;
	return kai(x - 1)*x%mod;
}

int mod_pow(int x, int y, int moder) {
	int res = 1;
	while (y > 0) {
		if (y & 1)res = res * x%moder;
		x = x * x%moder;
		y >>= 1;
	}
	return res;
}

int comb(int x, int y) {
	if (y > x)return 0;
	if (x == y)return 1;
	return kai(x)* mod_pow(kai(x - y), mod - 2, mod) % mod * mod_pow(kai(y), mod - 2, mod) % mod;
}

int a, b;

signed main() {
	cin >> a >> b;
	cout << max({ a + b,a - b,a*b }) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(vec) vec.begin(),vec.end()
#define mp make_pair
using namespace std;
using ll=long long;
using P=pair<int,int>;
const ll INF=1LL<<30;
const ll LINF=1LL<<60;
const double eps=1e-9;
const ll MOD=1000000007LL;
template<typename T>void chmin(T &a,T b){a=min(a,b);};
template<typename T>void chmax(T &a,T b){a=max(a,b);};
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V>typename enable_if<is_class<T>::value==0>::type fill_v(T& t,const V& v){t=v;}
template<typename T,typename V>typename enable_if<is_class<T>::value!=0>::type fill_v(T& t,const V& v){for(auto &e:t)fill_v(e,v);};
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
vector<string> s;
int h,w;
int dfs(int co,vector<int> v){
    if(co==h/2+h%2){
        vector<int> vis(w);
        bool ff=w%2;
        for(int i=0;i<w;i++){
            if(vis[i])continue;
            for(int j=i+1;j<w;j++){
                if(vis[j])continue;
                bool f=true;
                for(int k=0;k<h;k++){
                    if(s[v[k]][i]!=s[v[h-k-1]][j])f=false;
                }
                if(f){
                    vis[i]=true;
                    vis[j]=true;
                    break;
                }
            }
            if(vis[i])continue;
            bool fff=true;
            for(int k=0;k<h;k++){
                if(s[v[k]][i]!=s[v[h-k-1]][i])fff=false;
            }
            if(ff&&fff){
                ff=false;
                vis[i]=true;
            }else{
                return 0;
            }
        }
        return 1;
    }
    int res=0;
    if(h%2&&co==0){
        for(int i=0;i<h;i++){
            vector<int> nv=v;
            nv[h/2]=i;
            res|=dfs(co+1,nv);
        }
    }else{
        int vis=0;
        for(int i=0;i<h;i++){
            if(v[i]>=0)vis|=(1<<v[i]);
        }
        for(int i=0;i<h;i++){
            if(vis&(1<<i))continue;
            for(int j=i+1;j<h;j++){
                if(vis&(1<<j))continue;
                vector<int> nv=v;
                nv[co-h%2]=i,nv[h-co-1+h%2]=j;
                res|=dfs(co+1,nv);
            }
            break;
        }
    }
    return res;
}
int main(){
    cin>>h>>w;
    s.resize(h);
    for(int i=0;i<h;i++)cin>>s[i];
    if(dfs(0,vector<int>(h,-1))){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
}

Measured memory_bytes: 256
from collections import defaultdict
def solve():
    S = input()
    d = defaultdict(int) 

    cur = 0
    tenFactor = 1
    d[cur] += 1
    for i in range(len(S)):
        cur = (cur + int(S[-i-1]) * tenFactor) % 2019
        tenFactor = tenFactor * 10 % 2019
        d[cur] += 1
    
    ans = 0
    for i in range(2019+1):
        ans += d[i] * (d[i]-1) // 2
    
    print(ans)

if __name__ == '__main__':
    solve()

Measured memory_bytes: 69224
from collections import defaultdict
N = int(input())
dic = defaultdict(list)
for n in range(1, N + 1):
    s, p  = input().split()
    p = int(p)
    dic[s].append((p, n))
for s in sorted(dic.keys()):
    lis = sorted(dic[s])[::-1]
    for _, p in lis:
        print(p)

Measured memory_bytes: 3316
import java.util.Scanner;
class Main
{
	public static void main(String args[])
	{
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        String s=sc.next();

        if(n%2==0){

            String t1=s.substring(0,n/2);
            String t2=s.substring(n/2,n);
            if(t1.equals(t2)){
                System.out.println("Yes");
            }
            else{
                System.out.println("No");
            }
        }
        else{
                System.out.println("No");
        }
    }
}

Measured memory_bytes: 21844
(defun solve (n a)
  (let ((hash (make-hash-table)))
    (loop for x in a
          if (gethash x hash)
          do (return "NO")
          else
          do (setf (gethash x hash) t)
          finally (return "YES"))))

#-swank
(let* ((n (read))
       (a (loop repeat n collect (read))))
  (format t "~A~%" (solve n a)))


Measured memory_bytes: 61928
import math

a, b, x = map(int, input().split())

if x / (a ** 2 * b) >= 0.5:
    h = b - x / a ** 2
    w = a / 2
else:
    h = b
    w = 2 * x / (a * b)
    
atan1 = math.degrees(math.atan(h / w))
print(atan1)

Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define RNG(i,from,to) for(int i=(from); i<(int)(to); i++)
#define gcd(i,j) __gcd((i), (j))
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<ll> vecll;
template<typename S, typename T> string to_string(pair<S, T> p) { return "("+to_string(p.first)+","+to_string(p.second)+")"; }
template<typename T> string to_string(T p[2]) { return "["+to_string(p[0])+","+to_string(p[1])+"]"; }
template<typename T> void println(T e){ cout << to_string(e) << endl; }
template<typename T> void println(const vector<T>& v){ cout << "[";for(const auto& e : v){ cout << to_string(e) << ","; }cout << "]";cout << endl; }
template<typename T> void println(const vector<vector<T>>& vv){ for(const auto& v : vv){ println(v); } }
template<typename Iter> void println(Iter first, Iter last){ for(auto it=first; it != last; it++){ cout << *it << " "; }; cout << endl; }
template<typename T> T mod_pow(T x, T n, const T &p) { T ret = 1; while(n > 0) { if(n & 1) (ret *= x) %= p; (x *= x) %= p; n >>= 1; } return ret; }
template<typename T> T mod_inv(T x, const T &p) { return mod_pow(x, p-2, p); }
const ll DVSR = 1e9+7;


int main(int argc, char const *argv[])
{
  ll N = 50, K; cin >> K;
  vecll A(N);
  REP(i, N) A[i] = i;
  REP (i, K%N) {
    A[i] += N;
    REP(j, N) if (i != j) {
      A[j] -= 1;
    }
  }
  REP (i, N) A[i] += K/N;

  cout << N << endl;
  REP (i, N-1) {
    cout << A[i] << " ";
  }
  cout << A[N-1] << endl;
  return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define int long long
using namespace std;

signed main(){
  
  int n;
  
  string s, t;

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


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <string>
#include <iostream>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <vector>
#define mem(a, b) memset(a, (b), sizeof(a))
 
using namespace std;
 
 
typedef long long ll;
const int Maxn = 1e9 + 10;
const int N = 1e6 + 10;
const int INF=(0x7fffffff)/2;
const int MOD = 1000000007;
const int MaxN = 1000;
 
int a[110];
int main(){
	int a, b, c, x, y;
	while(~scanf("%d %d %d %d %d", &a,&b, &c, &x, &y)){
		int k = min(x, y), h = max(x , y);
		ll sum = 0;
		sum = a *x + b * y;
		ll s= k * 2 * c;
		if(x >= y) s += (x - y) * a;
		else s += (y - x) * b;
		ll ss= h  * 2 *c;
		s= min(s, ss);
		ll ans = min(sum, s);
		printf("%lld\n", ans);
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string s;
char front,last;
int l;
int main()
{
	cin>>s;
	front=s[0];
	l=s.size();
	last=s[l-1];
	cout<<front<<l-2<<last<<endl;
	return 0;
 } 

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		double N = Integer.parseInt(sc.next());

		double odd = 0;
		for(int i = 1; i <= N;i++) {
			if(i%2 != 0) odd++;
		}
		System.out.println(odd/N);
	}
}

Measured memory_bytes: 22612
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
using namespace std;

int main(){

  int n, ans=0;
  cin >> n;
  int a[n], b[n];

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

  for(int i=0; i<n; i++){
    int sum=0;
    for(int j=0; j<=i; j++){
      sum+=a[j];
    }
    for(int j=i; j<n; j++){
      sum+=b[j];
    }
    ans=max(ans, sum);
  }

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

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<numeric>
#include<cmath>
#include<queue>
#include<stack>
#include<list>
#include<unordered_map>
#include<unordered_set>

using namespace std;
typedef long long int ll;typedef pair<int, int> P;
const long long mod = 1e9 + 7;
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define ALL(a) (a).begin(),(a).end()



int main(void) {
	int n; cin >> n;
	bool f = 0;
	for (int hi = 0; hi <= 15; hi++) {
		for (int wi = 0; wi <= 25; wi++) {
			if (n == wi * 4 + hi * 7) {
				f = 1;
				break;
			}
		}
		if (f)break;
	}
	cout << (f ? "Yes" : "No") << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
flush = sys.stdout.flush
digit = [0] * 11
for i in range(11):
  print("?", pow(10, i))
  flush()
  s = input()[: -1]
  digit[i] = s == "Y"
d = 0
for i in range(11):
  if digit[i]:
    d = i

if d < 10:
  ok = pow(10, d)
  ng = pow(10, d + 1)
  while ng - ok > 1:
    m = (ok + ng) // 2
    print("?", m * 10)
    flush()
    s = input()[: -1]
    if s == "N": ok = m
    else: ng = m
  print("!", ok + 1)
  flush()
  exit(0)
else:
  res = 1
  for i in range(11):
    print("?", pow(10, i + 1) - 1)
    flush()
    s = input()[: -1]
    if s == "Y":
      res = pow(10, i)
      break
  print("!", res)
  flush()
  exit(0)

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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

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 main(){
    int n;cin>>n;
    if(n%1000==0)cout<<0<<endl;
    else cout<<1000-n%1000<<endl;
}


Measured memory_bytes: 3636
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <cstdio>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>

using namespace std;

typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P > PP;

int tx[] = {0,1,0,-1};
int ty[] = {-1,0,1,0};

static const double EPS = 1e-8;

class Data{
public:
	int wrong[11];
	bool correct[11];
	int penalty;
	Data(){
		memset(wrong,0,sizeof(wrong));
		memset(correct,0,sizeof(correct));
		penalty = 0;
	}
};

class Team{
public:
	int solved;
	int penalty;
	int tid;
	Team (int _sol,int _pen,int _tid) : solved(_sol),penalty(_pen),tid(_tid) {}
	bool operator<(const Team& t) const{
		if(solved != t.solved){
			return solved > t.solved;
		}
		else if(solved == t.solved && penalty != t.penalty){
			return penalty < t.penalty;
		}
		else{
			return tid < t.tid;
		}
	}
};

int main(){
	int T,P,R;
	while(~scanf("%d %d %d",&T,&P,&R)){
		if(T==0 && P==0 && R==0) break;
		map<int,Data> status;
		for(int i=1;i<=T;i++){
			status[i];
		}
		for(int i=0;i<R;i++){
			int tID;
			int pID;
			int time;
			string str;
			cin >> tID >> pID >> time >> str;
			if(str == "CORRECT"){
				status[tID].correct[pID] = true;
				status[tID].penalty += status[tID].wrong[pID] * 1200 + time; 
			}
			else{
				if(!status[tID].correct[pID]) status[tID].wrong[pID]++;
			}
		}

		vector<Team> teams;

		for(map<int,Data>::iterator it = status.begin(); it != status.end(); it++){
			teams.push_back(Team(count(it->second.correct,it->second.correct + 11,true),it->second.penalty,it->first));
		}

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

		for(int i=0;i<teams.size();i++){
			printf("%d %d %d\n",teams[i].tid,teams[i].solved,teams[i].penalty);
		}
	}
}

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

using namespace std;
const int inf=1e8;

int main(){

    while(1){
        int n, m;
        cin>> n>> m;
        if(n==0&&m==0) break;
        int a[m], b[m];
        for(int i=0; i<m; i++){
            cin>> a[i]>> b[i];
            a[i]--; b[i]--;
        }

        int mtrx[n][n];
        fill(mtrx[0], mtrx[n], inf);
        for(int i=0; i<m; i++){
            mtrx[a[i]][b[i]]=mtrx[b[i]][a[i]]=1;
        }


        for(int k=0; k<n; k++)
            for(int i=0; i<n; i++)
                for(int j=0; j<n; j++)
                    mtrx[i][j]=min(mtrx[i][j], mtrx[i][k]+mtrx[k][j]);

        int ans=0;
        for(int i=1; i<n; i++){
            if(mtrx[0][i]<=2) ans++;
        }

        cout<< ans<< endl;

    }

    return 0;
}

Measured memory_bytes: 4036
#include "bits/stdc++.h"

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

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


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	if (s[0] == s[1] || s[1] == s[2] || s[2] == s[3])cout << "Bad" << endl;
	else cout << "Good" << endl;
}

Measured memory_bytes: 764
#include <string.h>
#include <math.h>
#include <iostream>
#include <algorithm>
using namespace std;

#define INF (1e+9)

#define REP(i, n) for(int i = 0; i < n; i++)

#define pow (int)pow

int main()
{
  int n, ans = -INF;
  int f[100][11], p[100][11];

  cin >> n;
  REP(i, n)
    REP(j, 10)
      cin >> f[i][j];

  REP(i, n)
    REP(j, 11)
      cin >> p[i][j];

  for(int i = 1; i < 1024; i++){
    int sum = 0;
    REP(j, n){
      int a = 0;
      REP(k, 10){
         if(f[j][k] && (i & pow(2, k))) a++;
      }
      sum += p[j][a];
    }
    if(sum != 0)
      ans = max(ans, sum);
  }

  cout << ans << endl;

  return 0;
}

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

class Program
{
    public static void Main()
    {


        var N = int.Parse(Console.ReadLine());
        var V = Console.ReadLine().Split(' ').Select(x => double.Parse(x));

        List<double> list = new List<double>(V);

        list.Sort();

        double k = 0;

        for(int i = 0;i < N-1; i++)
        {
            if (i == 0)
            {
                k = list[i];
            }

            k = (k + list[i + 1]) / 2;
        }

        Console.WriteLine(k);
    }
}

Measured memory_bytes: 13524
k = int(input())
a_list = [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]
print(a_list[k - 1])

Measured memory_bytes: 2940
#include<iostream>
#include<algorithm>
int main(){
    int N, M;
    std::cin >> N >> M;
    int A[N];
    float max = 0;
    for(int i=0; i<N; i++) {
        std::cin >> A[i];
        max += A[i];
    }
    std::sort(A, A+N, std::greater<int>());
    for(int i=0; i<M; i++) {
        if(float(A[i])/max < 1.0/float(4*M)){
            std::cout << "No\n";
            return 0;
        }
    }
    std::cout<<"Yes\n";

}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int where[15];
int n;

ll calc(int a,int b){
	ll ans=1;
	if(b<=0)	return 0;
	for(int i=0;i<b;i++){
		ans*=a;
	}
	return ans-1;
}

ll check(bool left){
	ll ans=0;
	for(int i=0;i<n;i++){
		int now=left?0:2;
		if(abs(now-where[i])==2){
			ans+=2*calc(3,n-i-1)+2;
		}
		else if(where[i]==1){
			ans+=calc(3,n-i-1)+1;
			left^=1;
		}
	}
	return ans;
}

int main(){
	refrain:;
	int m;	cin>>n>>m;
	if((n|m)==0)	return 0;
	int num,in;
	for(int i=0;i<3;i++){
		cin>>num;
		for(int j=0;j<num;j++){
			cin>>in;
			where[in-1]=i;
		}
	}
	ll ans=min(check(true),check(false));
	if(ans<=m)	cout<<max(0LL,ans)<<endl;
	else 	cout<<-1<<endl;
	goto refrain;
}

Measured memory_bytes: 1156
#include <stdio.h>
#include <math.h>
#include <vector>
#include <utility>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define mp make_pair
#define EPS (1e-8)

struct P {
    double x, y, z;
    P() {}
    P(double _x, double _y, double _z) : x(_x), y(_y), z(_z) {}
};

inline P operator+(const P& l, const P& r) {
    return P(l.x+r.x, l.y+r.y, l.z+r.z);
}
inline P operator-(const P& l, const P& r) {
    return P(l.x-r.x, l.y-r.y, l.z-r.z);
}
inline P operator*(double x, const P& r) {
    return P(x*r.x, x*r.y, x*r.z);
}
inline double dot(const P& l, const P& r) {
    return l.x*r.x + l.y*r.y + l.z*r.z;
}
inline double norm(const P& p) { return dot(p, p); }
inline double abs(const P& p) { return sqrt(norm(p)); }
inline P unit(const P& p) { return 1/abs(p)*p; }

P readP() {
    int u, v, w;
    scanf("%d%d%d", &u, &v, &w);
    return P(u, v, w);
}

void dump(const P& p) {
    printf("(%.9f, %.9f, %.9f)\n", p.x, p.y, p.z);
}

P projection(const P& l0, const P& l1, const P& p) {
    return l0 + dot(p-l0, l1-l0) / norm(l1-l0) * (l1-l0);
}

vector<P> crosspoint(const P& p, double r, const P& s, const P& t) {
    const P q = projection(s, t, p);
    const double dd = norm(q-p);
    if (dd > r*r) return vector<P>();
    else if (fabs(r*r-dd) < EPS) return vector<P>(1, q);
    else {
        vector<P> rs;
        const double x = sqrt(r*r-dd);
        rs.push_back(q+x*unit(t-s));
        rs.push_back(q-x*unit(t-s));
        return rs;
    }
}

int N;
P ps[200];
double rs[200];

P solve(P s, P t) {
    vector<pair<P, P> > cs;
    rep (i, N) {
        const vector<P> a = crosspoint(ps[i], rs[i], s, t);
        rep (j, a.size()) {
            if (dot(t-s, a[j]-s) > EPS) cs.push_back(mp(a[j], ps[i]));
        }
    }
    if (cs.size() == 0) return s;
    int ix = 0;
    rep (i, cs.size()) {
        if (norm(cs[ix].first-s) > norm(cs[i].first-s)) ix = i;
    }
    const P q = cs[ix].first, z = cs[ix].second;
    const P m = projection(z, q, s);
    return solve(q, s+2*(m-s));
}

int main() {
    for (;;) {
        scanf("%d", &N);
        if (N == 0) return 0;
        P p = readP();
        rep (i, N) {
            ps[i] = readP();
            scanf("%lf", rs+i);
        }
        P ans = solve(P(0, 0, 0), p);
        printf("%.9f %.9f %.9f\n", ans.x, ans.y, ans.z);
    }
}

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

int main(){

int a,b,c,t;
cin >>a >>b >>c;
if(a>b){
t=a;
a=b;
b=t;
}
if(b>c){
t=b;
b=c;
c=t;
}
if(a>b){
t=a;
a=b;
b=t;
}
cout <<a <<" " <<b <<" " <<c <<endl;
return 0;
}

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

using namespace std;

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int a, b, c;
	cin >> a >> b >> c;
	int d = a - b;
	cout << max(c - d, 0);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <list>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)

int main(){
    ll n;
    cin >> n;
    ll a[n];
    rep(i,n) cin >> a[i];

    ll c=-1;
    ll ans=1;
    ll stat=0;
    while(c!=n-2){
        c++;
        if(a[c] < a[c+1]){
            if(stat == -1){
                ans++;
                stat = 0;
            }
            else stat = 1;
        }
        if(a[c] > a[c+1]){
            if(stat == 1){
                ans++;
                stat = 0;
            }
            else stat = -1;
        }
    }
    cout << ans << endl;
}

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

int main() {
    int N; cin >> N;
    vector<ll> a(N); for (int i = 0; i < N; i++) cin >> a[i];
    ll sum = 0;
    for (int i = 0; i < N; i++) sum ^= a[i];
    for (int i = 0; i < N; i++) {
        cout << (sum ^ a[i]) << ' ';
    }
    cout << endl;
}

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

int main() {
  int x;
  std::cin >> x;
  int h = x / 3600;
  int m = (x - h * 3600) / 60;
  int s = (x - ((x - h * 3600) + (x - m * 60))) * -1;
  std::cout << h << ":" << m << ":" << s << std::endl;
}



Measured memory_bytes: 3112
n = int(input())
d_list = []
for i in range(n):
    val = int(input())
    if val:
        d_list.append(val)
for j in range(n):
    for k in range(n):
        if j == k:
            pass
        else:
            if d_list[j] == d_list[k]:
                d_list[k] = 0
print(len([a for a in d_list if a > 0]))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n;
    map<string, int> ma, mb;
    rep(i, 0, n){
        string s;
        cin >> s;
        ma[s]++;
    }
    cin >> m;
    rep(i, 0, m){
        string s;
        cin >> s;
        mb[s]++;
    }
    int ans = 0;
    for(auto it = ma.begin(); it != ma.end(); it++){
        ans = max(ans, max(0LL, it -> second - mb[it -> first]));
    }
    cout << ans << endl;
}

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

using namespace std;
 
/// ----------------------------- (Debug) ------------------------------
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; }; sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0); sim > char dud(...);
struct debug {
#ifndef ONLINE_JUDGE
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i));}
sim, class b dor(pair < b, c > d) {ris << "(" << d.first << ", " << d.second << ")";}
sim dor(rge<c> d) {*this << "["; for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it; ris << "]";}
#else
sim dor(const c&) { ris; }
#endif
};
vector<char*> tokenizer(const char* args) {
	char *token = new char[111]; strcpy(token, args); token = strtok(token, ", ");
	vector<char*> v({token});
	while(token = strtok(NULL,", ")) v.push_back(token);
	return reverse(v.begin(), v.end()), v;
}
void debugg(vector<char*> args) { cerr << "\b\b "; }
template <typename Head, typename... Tail>
void debugg(vector<char*> args, Head H, Tail... T) {
	debug() << " [" << args.back() << ": " << H << "] ";
	args.pop_back(); debugg(args, T...);
}
#define harg(...) #__VA_ARGS__
#ifndef ONLINE_JUDGE
#define dbg(...) { debugg(tokenizer(harg(__VA_ARGS__, \b\t-->Line)), __VA_ARGS__, __LINE__); cerr << endl;}
#else
#define dbg(...) { }
#endif
/// -----------------------------------------------------------------------
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi; 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)    
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define print(x) cout << x << "\n";
#define REP(i,a,b) for(i=a;i<=b;i++)
#define RAP(i,a,b) for(i=a;i>=b;i--)
#define spa <<" "<<
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)x.size()
ll mod=998244353;
const int MX=0x3f3f3f3f;

int main(){
	IOS;
	int n,k,i;
	cin>>n>>k;
	int p[n];
	REP(i,0,n-1) cin>>p[i];
	sort(p,p+n);
	ll sum=0;
	REP(i,0,k-1) sum+=p[i];
	cout<<sum;
	return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
const ll MAXN = 1e18;
int main() {
    int n; cin >> n;
    ll a[n] = {};
    for (int i = 0; i < n; i++)
        cin >> a[i];
    if (count(a, a + n, 0)) {
    	cout << 0 << "\n";
    	return 0;
    }
    ll ans = 1;
    for (int i = 0; i < n; i++) {
        if ((__int128)ans * a[i] > MAXN) {
            cout << -1 << "\n";
            return 0;
        }
        ans *= a[i];
    }
    cout << ans << "\n";
}

Measured memory_bytes: 4404
s=input()
ans=0
for i in range(len(s)):
    if s[i] == 'A':
        for j in range(len(s)-1,0,-1):
            if s[j] == 'Z':
                if ans < abs(i-j):
                    ans = abs(i-j)
                break

print(ans+1)


Measured memory_bytes: 3516
#![allow(non_snake_case)]

#[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)*} }; }
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)*} };}
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, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

fn main() {
    input!{
        A: [usize; 3],
    }
    let mut A = A;
    A.sort();
    println!("{}", A[0] + A[1] + A[2] * 10);
}


Measured memory_bytes: 4352
use proconio::{input, fastout};

#[fastout]
fn main() {
    input! {
        n: usize,
        aa: [usize; n],
    }


    let mut bit_count = vec![0; 32];

    for i in 0..n {
        let mut a = aa[i];

        for j in 0..32 {
            bit_count[j] += (a & 1) as isize;
            a >>= 1;
        }
    }

    let mut ans = vec![];

    for i in 0..n {
        let mut a = aa[i];

        let mut val = 0;
        for j in 0..32 {
            let b = bit_count[j] - (a & 1) as isize;
            val += (b % 2) << j;
            a >>= 1;
        }
        ans.push(val);

    }

    let ans = ans.iter().map(|x| x.to_string()).collect::<Vec<_>>().join(" ");

    println!("{}", ans);
}

Measured memory_bytes: 20368
//Zory-2019
#include<cmath>
#include<ctime>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<map>
#include<set>
#include<queue>
#include<deque>
#include<stack>
#include<bitset>
#include<vector>
#include<algorithm>
#include<iostream>
#include<deque>
// #include<unordered_map>
using namespace std;
int bin[40],lg[1<<21];
namespace mine
{
	typedef long long ll;
	#define double long double
	const int INF=0x3f3f3f3f;
	const ll LLINF=0x3f3f3f3f3f3f3f3fll;
	ll qread()
	{
		ll ans=0;char c=getchar();int f=1;
		while(c<'0' or c>'9') {if(c=='-') f=-1;c=getchar();}
		while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar();
		return ans*f;
	}
	void write(ll num)
	{
		if(num<0) {num=-num;putchar('-');}
		if(num>9) write(num/10);
		putchar('0'+num%10);
	}
	void writeln(int num){write(num);puts("");}
	#define FR first
	#define SE second
	#define MP make_pair
	#define pr pair<int,int>
	#define PB push_back
	#define vc vector
	void chmax(int &x,const int y) {x=x>y?x:y;}
	void chmin(int &x,const int y) {x=x<y?x:y;}
	const int MAX_N=2e3+10;
	const int MOD=1e9+7;
	void add(int &x,int y) {x+=y;if(x>=MOD) x-=MOD;if(x<0) x+=MOD;}

	const int MAX_M=MAX_N*MAX_N;
	int fac[MAX_M],inv[MAX_M],facinv[MAX_M];
	int C(int n,int m) {if(n<m) return 0;return (ll)fac[n]*facinv[m]%MOD*facinv[n-m]%MOD;}
	int f[MAX_N][MAX_N];
	void main()
	{
		inv[1]=1;for(int i=2;i<MAX_M;i++) inv[i]=ll(MOD-MOD/i)*inv[MOD%i]%MOD;
		fac[0]=1;for(int i=1;i<MAX_M;i++) fac[i]=(ll)fac[i-1]*i%MOD;
		facinv[0]=1;for(int i=1;i<MAX_M;i++) facinv[i]=(ll)facinv[i-1]*inv[i]%MOD;

		int n=qread(),k=qread();
		if(k==1) {puts("1");return;}
		f[0][0]=1;
		for(int i=1;i<=n;i++) for(int j=0;j<=i;j++)
		{
			if(i>0) add(f[i][j],f[i-1][j]);
			if(j>0) add(f[i][j],(ll)f[i][j-1]*(n-j+1)%MOD*C(n-i+(k-1)*(n-j+1)-1,k-2)%MOD );
			// printf("f[%d][%d]=%d\n",i,j,f[i][j]);
		}
		printf("%d",f[n][n]);
	}
};
int main()
{
	srand(time(0));
	bin[0]=1;for(int i=1;i<=30;i++) bin[i]=bin[i-1]<<1;
	lg[1]=0;for(int i=2;i<(1<<21);i++) lg[i]=lg[i>>1]+1;
	mine::main();
}


Measured memory_bytes: 71552
#include<bits/stdc++.h>
using namespace std;
#define ff          first
#define ss          second
#define ll         	long long int
#define pb          push_back
#define ar 			array
#define mp 			make_pair
#define f(i,n)   	for(ll i =0;i<n;i++)
#define inf 		INT_MAX
#define pll 		pair<ll,ll>
const ll INF = 1e18;
void init(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE 
		freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#endif
}

bool checkp2(ll n){
	return n && (n-1);
}

ll power(ll x , ll n){
	ll po = 1;
	while(n){
		if(n & 1){
			po *= x;
		}
		n = n>>1;
		x = x * x;
	}
	return po;
}

bool isPrime(ll x){
	if(x < 2)
		return 0;
	for(ll y = 2; y * y <= x; y++){
		if(x % y == 0){
			return 0;
		}
	}
	return true;
}
void solve(){

	ll n;
	cin>>n;
	vector<ll> a(n+1);
	ll count = 0;
	for(ll i = 1; i<=n; i++){
		cin>>a[i];
		if((i & 1) && (a[i] & 1)){
			count++;
		}
	}
	cout<<count<<endl;

	
}
int main(){
	
	init();
	ll t = 1;
	//cin>>t;
	for(ll i=1;i<=t;i++){
		//cout<<"Case #"<<i<<": ";
		solve();
	}

}

Measured memory_bytes: 3612
#!/usr/bin/env python3

N = int(input())
A = list(map(int, input().split()))

ret = 0
h = 0
for i in range(1, N):
    if A[i] < A[i-1]+h:
        ret += A[i-1] + h - A[i]
        h = A[i-1] + h - A[i]
    else:
        h = 0
print(ret) 


Measured memory_bytes: 94208
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename X> ostream& operator << (ostream& x,const vector<X>& v){for(ll i=0;i<v.size();++i) x<<v[i]<<" ";return x;}
template <typename X> ostream& operator << (ostream& x,const set<X>& v){for(auto it:v) x<<it<<" ";return x;}
template <typename X, typename Y> ostream& operator << (ostream& x, const pair<X,Y>& v) {x<<v.ff<<" "<<v.ss;return x;}
template <typename T, typename S> ostream& operator << (ostream& os, const map<T, S>& v) { for (auto it : v) os << it.first << "=>" << it.second << endl; return os; }
struct pair_hash {inline std::size_t operator()(const std::pair<ll, ll> & v) const {return v.first*31+v.second;}};
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC targett("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL)
#define pb push_back
#define fr first
#define sc second
#define prnt(m) for(auto it = m.begin() ; it != m.end() ; ++it){cout<<*it<<endl;}
#define tra(it,m) for(auto it=m.begin();it!=m.end();++it)
#define DBG(x) cout<<"# # #     "<<x<<'\n';
#define fri(i,s,n) for(ll i=s;i<n;i++)
#define mod 1000000007LL
#define mod2 998244353
#define vct2 vector<vector<ll>>
#define vct vector<ll>
#define pll pair<ll,ll>
#define rz(n) resize(n)
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define arrin(a,n) for(ll i = 0; i < n ; i++){cin>>a[i];}
#define arrout(a,n) for(ll i = 0;i < n; i++){cout<<a[i]<<" ";}
#define ex(s) cout<<s<<endl,exit(0);
#define inf 4e18
#define five 100005;
#define six 1000005;
#define printclock cerr<<"Time"<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
//_______________________________________________________________________________
const int N = 2002;
ll dp[N][N][2];
int main()
{
       int n;
       cin>>n;
       ll mnp,mxp,mxn,mnn;
       mnp = 1e15;
       mnn = 1e15;
       mxp = -1e15;
       mxn = -1e15;
       fri(i,0,n){
              ll x,y;
              cin>>x>>y;
              ll pp = x+y;
              ll nn = x-y;
              mnp = min(pp,mnp);
              mxp = max(pp,mxp);
              mxn = max(nn,mxn);
              mnn = min(nn,mnn);
       }
       ll ans = max((mxp-mnp),(mxn-mnn));
       cout<<ans<<endl;
}


Measured memory_bytes: 3616
str = input()

str1 = str[::-1]
a = str1 == str
str2 = str[:int((len(str)-1)/2)]
str3 = str2[::-1]
b = str3 == str2
str4 = str[int((len(str)+3)/2)-1:]
str5 = str4[::-1]
c = str5 == str4
if a and b and c:
    print("Yes")
else:
    print("No")

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

int main() {
    string sa, sb, sc;
    cin >> sa >> sb >> sc;
    char turn = 'a';
    while( 1 ) {
        if ( turn == 'a' ) {
            if ( sa.size() == 0 ) {
                cout << "A" << endl;
                break;
            }
            turn = sa.front();
            sa.erase(sa.begin());
        } else if ( turn == 'b' ) {
            if ( sb.size() == 0 ) {
                cout << "B" << endl;
                break;
            }
            turn = sb.front();
            sb.erase(sb.begin());
        } else {
            if ( sc.size() == 0 ) {
                cout << "C" << endl;
                break;
            }
            turn = sc.front();
            sc.erase(sc.begin());
        }
    }
}

Measured memory_bytes: 256
// @prefix atcoder
// @description atcoder template

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

// typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

// rep
//------------------------------------------
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
#define DEBUG(x) cerr << #x << ": " << x << '\n'
#define DEBUGP(x) cerr << #x << ": " << x.first << " \t" << x.second << '\n'
#define INF (1ll<<60)

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; }
const int MOD = 1e9 + 7;

int n, m, x;

VI c(13);
VVI a(13, VI(13));

signed main()
{
	cin >> n >> m >> x;

	REP(i, n){
		cin >> c[i];
		REP(j, m){
			cin >> a[i][j];
		}
	}

	int mi = INF;
	REP(i, (1<<n)){
		VI cnt(m, 0);
		int cost = 0;
		REP(j, n){
			if (i & (1 << j)){
				REP(k, m){
					cnt[k] += a[j][k];
				}
				cost += c[j];
			}
		}
		bool flag = true;
		REP(j, m){
			if (cnt[j] < x) flag = false;
		}
		if (flag){
			mi = min(mi, cost);
		}
	}

	if (mi == INF){
		cout << -1 << endl;
	} else {
		cout << mi << endl;
	}
	return 0;
}


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

using namespace std;
using ll = long long int;

ll dist(ll x, ll y){
    return x * x + y * y;
}

int main(){

    ll n, d, ans = 0;
    cin >> n >> d;

    while(n--){

        int x, y;
        cin >> x >> y;

        if (dist(x, y) <= d * d){
            ans++;
        }
    }

    cout << ans << endl;


    return 0;
}

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


int main(){
  int k,x;
  cin >> k >> x;
  vector <int> answer(1000);
  for(int i = 1-k;i<k;i++){
    int zahyo = x+i;
    cout << zahyo <<" ";
  }
  cout<<endl;
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define INF (1LL << 55)
#define MOD (1000 * 1000 * 1000 + 7)
#define maxn 55

typedef long long ll;
typedef long double ld;

ll arr[maxn];

vector<pair<ll, ll> > ans;

int main(){
	ll n, mini = INF, maks = -INF;
	scanf("%lld", &n);
	for(ll i = 0; i < n; i++){
		scanf("%lld", arr + i);
		maks = max(maks, arr[i]);
		mini = min(mini, arr[i]);
	}

	if(abs(maks) >= abs(mini)){
		for(ll i = 0; i < 1; i++){
			for(ll k = 0; k < 2; k++){
				ll x = -INF;
				ll ind = 0;
				for(ll j = 0; j < n; j++){
					if(arr[j] > x){
						x = arr[j];
						ind = j;
					}
				}

				ans.pb(mp(ind, i));
				arr[i] += x;
			}
		}
		for(int i = 1; i < n; i++){
			ans.pb(mp(i - 1, i));
			ans.pb(mp(i - 1, i));
		}
	}

	if(abs(maks) < abs(mini)){
		for(ll i = n - 1; i >= n - 1; i--){
			for(ll k = 0; k < 2; k++){
				ll x = INF;
				ll ind = 0;
				for(ll j = 0; j < n; j++){
					if(arr[j] < x){
						x = arr[j];
						ind = j;
					}
				}

				ans.pb(mp(ind, i));
				arr[i] += x;
			}
		}
		for(int i = n - 2; i >= 0; i--){
			ans.pb(mp(i + 1, i));
			ans.pb(mp(i + 1, i));
		}
	}

	printf("%lld\n", (ll) ans.size());
	for(auto i : ans)
		printf("%lld %lld\n", i.fi + 1, i.se + 1);


	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{

     public static void main(String []args){
        
        int N,K;
        int Ans = 0;
        Scanner input = new Scanner(System.in);
        
        N = input.nextInt();
        K = input.nextInt();
        
        Ans = (N-1)/(K-1);

        if( (N-1)%(K-1) != 0){
            Ans++;
        }
        
        System.out.println(Ans);
     }
}

Measured memory_bytes: 25172
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()

#define endl "\n"
#define pb push_back
#define cout_db cout << fixed

#define MOD 1000000007LL
#define PI 3.1415926

typedef long long ll;

template <typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}
template <typename T> inline T POW(T a,T b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}

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

	int n, a, x[52];
	cin >> n >> a;
	int X = a;
	for (int i = 0; i < n; i++) {
		cin >> x[i];
		if(x[i] > X) X = x[i];
	}
	// i番目までからj個えらんで和がkとなる場合の数
	vector< vector < vector<ll> > > dp(n+1, vector<vector<ll> >(n+1, vector<ll>(X*n+1)));
	for (int i = 0; i <= n; i++) {
		for (int j = 0; j <= n; j++) {
			for (int k = 0; k <= X*n; k++) {
				if(i == 0 and j == 0 and k == 0) dp[i][j][k] = 1;
				else if(i >= 1 and k < x[i-1]) dp[i][j][k] = dp[i-1][j][k];
				else if(i >= 1 and j >= 1 and k >= x[i-1]) dp[i][j][k] = dp[i-1][j][k]+dp[i-1][j-1][k-x[i-1]];
				else dp[i][j][k] = 0;
			}
		}
	}
	ll ans = 0;
	for (int i = 1; i <= n; i++) {
		cerr << dp[n][i][a*i] << endl;
		ans += dp[n][i][a*i];
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 52224
import sys
readline=sys.stdin.buffer.readline

N=int(readline())
A=list(map(int,readline().split()))
B=A[::-1]

def gcd(a,b):
  return gcd(b,a%b) if b else a

gcd_l=[0]*N
gcd_r=[0]*N

for i in range(N):
  gcd_l[i]=gcd(gcd_l[i-1],A[i])
  gcd_r[i]=gcd(gcd_r[i-1],B[i])
gcd_r=gcd_r[::-1]
#print(gcd_l)
#print(gcd_r)

gcd_l[-1]=0
gcd_r[0]=0

max_gcd=0
for i in range(N):
  max_gcd=max(max_gcd,gcd(gcd_l[i-1],gcd_r[(i+1)%N]))
print(max_gcd)

Measured memory_bytes: 58224
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
#include <random>
#include <map>
#include <unordered_map>
#include <cstdlib>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define mod 1000000007
#define p pair<int,int>
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
using namespace std;
int POW(int x,int y){return int(pow(double(x),double(y)));}



int main(){
	vector<vector<char>> z(100);
	rep(i,100){
		if(i<50){
			z[i].resize(100);
			rep(j,100){
				z[i][j]='.';
			}
		}else{
			z[i].resize(100);
			rep(j,100){
				z[i][j]='#';
			}
		}
	}

	int a,b;
	cin>>a>>b;

	--b;
	int i=0,j=0;
	while(b){
		z[i][j]='#';
		--b;
		j+=2;
		if(j>=100){
			i+=2;
			j=0;
		}
	}

	--a;
	i=51,j=0;
	while(a){
		z[i][j]='.';
		--a;
		j+=2;
		if(j>=100){
			i+=2;
			j=0;
		}
	}
	cout<<100<<" "<<100<<endl;
	rep(i,100){
		rep(j,100){
			cout<<z[i][j];
		}
		cout<<endl;
	}
		

}


Measured memory_bytes: 256
s=input()
L=len(s)
cnt=0
ans=0
dic=["A", "G", "C", "T"]

for i in range(L):
    if s[i] in dic:
        cnt+=1
        if cnt > ans:
            ans=cnt
    else:
        if cnt > ans:
            ans=cnt
        cnt=0


print(ans)

Measured memory_bytes: 3064
from math import gcd
def main():
  K = int(input())
  ans = 0
  
  for i in range(1, K + 1):
    for j in range(1, K + 1):
      for k in range(1, K + 1):
        ans += gcd(i, gcd(j, k))
        
  print(ans)

if __name__ == '__main__':
  main()

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

using ll = long long;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define ALL(c) (c).begin(), (c).end()
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;}
const int MOD = 1000000007;
const int INF = 1000000001;
const char EOL = '\n';

void solve();

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

void solve() {
    ll n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;
    ll g = abs(a - b);
    ll r = (d - c) * (n - 1);
    REP(i, n - 1) {
        ll m = d * (n - 1 - i) - c * i;
        if (m < 0) break;
        if (m >= g && m - r <= g) {
            cout << "YES" << EOL;
            return;
        }
    }
    cout << "NO" << EOL;
}



Measured memory_bytes: 256