akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,x,n) for(int i=x; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()
#define X first
#define Y second
#define pb push_back
#define eb emplace_back

using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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

template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }

template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"; return os;}
template<class T,size_t n> ostream& operator<<(ostream &os, const array<T,n> &t) {os<<"{"; rep(i,n) {os<<t[i]<<",";} os<<"}"; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}

const ll INF = 1e9+7;


int main(){
	//ios_base::sync_with_stdio(false);
	ll N, ans=0;
	ll a[10004], b[10004];

	cin >> N;
	rep(i,N) cin >> a[i];
	rep(i,N) cin >> b[i];

	ll cnt[2];
	rep(i,N){
		ll d = b[i] - a[i];
		if( d > 0 ) cnt[0] += (d+1)/2, cnt[1] += d%2;
		else cnt[1] += -d;
	}
	if( cnt[0] >= cnt[1] ){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <unordered_map>

using namespace std;

int main() {
	int N;
	cin >> N;
	unordered_map <int, bool> uniques;
	int a, count = 0;
	for (int i = 0; i < N; i++) {
		cin >> a;
		
		if (uniques[a] == false) {
			uniques[a] = true;
		} else {
			count += 1;
		}
	}
	
	cout << (count % 2 == 0 ? N - count : N - count - 1);

	return 0;
}

Measured memory_bytes: 4388
#include<bits/stdc++.h>
//#include <atcoder/all>

#define INF 1e9
#define rep(i,n)for(long long i=0;(i)<(long long)(n);i++)
#define REP(i,a,b)for(long long i=(long long)(a);(i)<=(long long)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()
#define pb push_back

using namespace std;
//using namespace atcoder;
using ll = long long;
using P = pair<ll, ll>;
//using mint = modint1000000007;


ll cnt[20][20];
int main(){
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n + 1);
    rep(i, n)cin >> a[i];
    int mx = 62;
    vector<vector<ll>> next(mx + 1, vector<ll> (n + 1, -1));
    rep(i, n)next[0][i + 1] = a[i];
    rep(i, mx){
        REP(j, 1, n)next[i + 1][j] = next[i][next[i][j]];
    }
    int now = 1;
    for(int i = mx; i >= 0; i--){
        if(((k >> i) & 1)){
            now = next[i][now];
        }
    }
    cout << now << endl;
  //rep(i, 10){rep(j, n + 1) cout << next[i][j] << " "; cout << endl;}
}

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

using namespace std;

#define ll  long long
#define ld  double

#define sz(x)   (int)x.size()
#define all(x)  x.begin(),x.end()

#define pb  emplace_back
#define X   first
#define Y   second

const int   N   = 2e5 + 5;

typedef pair<int,int>   ii;

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

    int n;  cin >> n;

    vector<int> x(n);
    vector<int> y(n);

    int parity = -1;

    for(int i = 0 ; i < n ; ++i)    {
        cin >> x[i];
        cin >> y[i];

        int p = (x[i] + y[i]) % 2;
        if (p < 0)
            p += 2;

        if (parity < 0)
            parity = p;
        if (parity != p)    {
            cout << "-1";
            return  0;
        }
    }
    vector<ll>  arms;

    for(int i = 0 ; i < 39 ; ++i)
        arms.pb(1ll << (38 - i));

    if (parity == 0)    {
        arms.pb(1);
        for(int&v : x)
            v -= 1;
    }

    cout << arms.size() << "\n";

    for(ll  x : arms)
        cout << x << " ";

    cout << "\n";

    int dx[] = {-1,0,1,0};
    int dy[] = {0,-1,0,1};
    char dir[] = {'L','D','R','U'};

    for(int i = 0 ; i < n ; ++i)    {
        ll  posX = 0;
        ll  posY = 0;
        for(int j = 0 ; j < 39 ; ++j)
        for(int k = 0 ; k < 4 ; ++k)    {
            ll  nxtX = posX + arms[j] * dx[k];
            ll  nxtY = posY + arms[j] * dy[k];

            if (abs(nxtX - x[i]) + abs(nxtY - y[i]) < arms[j])  {
                cout << dir[k];
                posX = nxtX;
                posY = nxtY;
                break;
            }
        }
        assert(posX == x[i]);
        assert(posY == y[i]);

        if (parity == 0)
            cout << "R\n";
        else
            cout << "\n";
    }
}

Measured memory_bytes: 384
// B - NarrowRectanglesEasy

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

int main() {
	int W, a, b;
	cin >> W >> a >> b;

	int ans;
	if (a + W < b) ans = b - (a + W);
	else if (b + W < a) ans = a - (b + W);
	else ans = 0;

	cout << ans << 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;

bool visited[10];
int N;
vector<double> x(10),y(10);
double sum = 0;

void dfs(int now,int cnt,double cost){
	if(cnt == N){
		sum += cost;
		return;
	}
	for(int i=0;i<N;i++){
		if(i==now)continue;
		if(visited[i])continue;
		visited[i] = 1;
		double dis = sqrt((x[now]-x[i])*(x[now]-x[i])+(y[now]-y[i])*(y[now]-y[i]));
		dfs(i,cnt+1,cost + dis);
		visited[i] = 0;
	}
}
int main(void){
	cin >> N;
	rep(i,N)cin >> x[i] >> y[i];
	for(int i=0;i<N;i++){
		visited[i] = 1;
		dfs(i,1,0);
		visited[i] = 0;
	}
	double fact = 1;
	for(int i=1;i<=N;i++)fact *= i;
	cout << fixed << setprecision(10) << sum/fact << endl;
}

Measured memory_bytes: 256
S = input()
Q = int(input())

dire = 0
front = ""
back = ""

for i in range(Q):
    quary = [_ for _ in input().split()]
    if len(quary) == 1:
        T = quary[0]
        dire += 1
    else:
        T, F, C = quary
        if F == "1":
            if dire % 2 == 0:
                front += C
            else:
                back += C
        else:
            if dire % 2 == 1:
                front += C
            else:
                back += C

S = front[::-1] + S + back

if dire % 2 == 1:
    print(S[::-1])
else:
    print(S)


Measured memory_bytes: 4596
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

class Program
{
    static void Main()
    {
        int N = int.Parse(Console.ReadLine());

        long[] A = Console.ReadLine().Split(' ').Select(s => long.Parse(s)).ToArray();

        //ひっくり返すかひっくり返さないか
        long[,] DP = new long[N, 2];

        //インデックスiを逆転したとき(i+1も逆転されている)の0~iまでの和の最大値をDP[i,1]とする。
        //インデックスiを逆転していないとき(i+1も逆転されていないとき)の0~iまでの和の最大値をDP[i,0]とする。

        DP[0, 0] = A[0];
        DP[0, 1] = -A[0];

        for(int i = 1; i <= N - 1; i++)
        {
            DP[i, 0] = Math.Max(DP[i - 1, 0] + A[i], DP[i - 1, 1] - A[i]);
            DP[i, 1] = Math.Max(DP[i - 1, 0] - A[i], DP[i - 1, 1] + A[i]);
        }

        Console.WriteLine(Math.Max(DP[N - 2, 0] + A[N - 1], DP[N - 2, 1] - A[N - 1]));
    }
}



static class MathUtil
{
    public static IEnumerable<IEnumerable<int>> GetPermutation(int n)
    {
        if (n == 0)
        {
            yield return Single(0);
            yield break;
        }

        for (int i = 0; i <= n; i++)
        {
            foreach (var x in GetPermutation(n - 1))
            {
                yield return Single(i).Concat(x.Select(itm => itm < i ? itm : itm + 1));
            }
        }
    }

    private static IEnumerable<int> Single(int x)
    {
        yield return x;
    }

    public static IEnumerable<int> EnumeratePrimeNumbers()
    {
        List<int> primes = new List<int>() { 2 };
        yield return 2;

        for (int i = 3; i < int.MaxValue; i++)
        {
            bool isPrime = true;
            int Sqrt = (int)Math.Sqrt(i) + 1;

            foreach (var prime in primes)
            {
                if (prime > Sqrt)
                {
                    break;
                }
                if (i % prime == 0)
                {
                    isPrime = false;
                    break;
                }
            }

            if (isPrime)
            {
                primes.Add(i);
                yield return i;
            }
        }
    }
}



Measured memory_bytes: 30044
#include <stdio.h>
int main(int argc, char const* argv[])
{
	int n[5];
	char s[128];
	sscanf(fgets(s,sizeof(s),stdin),"%d %d %d %d %d",n,n+1,n+2,n+3,n+4);

	int i,j,t;

	for(i = 0; i <= 5 ; i++){
		for(j = i; j <= 5 ; j++){
			if(n[i] < n[j]){
				t = n[j];
				n[j] = n[i];
				n[i] = t;
			}
		}
	}
	printf("%d %d %d %d %d\n",n[0],n[1],n[2],n[3],n[4]);

	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD=1'000'000'007;
const int NN=100002;


ll add(ll x, ll y) { return ((x + y) % MOD + MOD) % MOD;}
ll sub(ll x, ll y) { return ((x - y) % MOD + MOD) % MOD; }
ll mul(ll x, ll y) { return x * y % MOD; }

bitset<NN> is; int mu[NN];
void mobiusSieve() {
  for (int i = 1; i < NN; ++i) mu[i] = 1;
  for (int i = 2; i < NN; ++i) if (!is[i]) {
  for (int j = i; j < NN; j += i){
  is[j] = 1;
  mu[j] *= -1;
  }
 
  for (long long j = 1LL*i*i; j < NN; j += i*i)
  mu[j] = 0;
 
}
}
 


ll pow(ll a, ll b, ll MOD){
  if (b==0) return 1;
  else if (b%2==0){
    ll temp=pow(a,b/2,MOD);
    return temp*temp%MOD;
  }
  else{
    return a*pow(a,b-1,MOD)%MOD;
  }
}


int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  mobiusSieve();  
  int N,K;
  cin >> N >> K;
  ll ans=0;
  ll check=0;
  for (ll i=1; i<=K; i++){
    for (ll j=1; j<=K/i; j++){
      ll temp=mul(mu[j],pow(K/(i*j),N,MOD));
      ans=add(ans,mul(i,temp));


    }    
    //ans=add(ans,mul(i,sub(pow(temp,N,MOD),pow(temp-1,N,MOD))));
    //check=add(check,mul(i,sub(pow(temp,N,MOD),pow(temp-1,N,MOD))));

  }
  cout<<ans%MOD<<endl;
  //cout<<check%MOD<<" "<<pow(K,N,MOD)<<endl;




}

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

int main(){
  string s;  cin >> s;
  string t;  cin >> t;
  sort(s.begin(),s.end());
  sort(t.rbegin(),t.rend());
  if(s<t) puts("Yes");
  else puts("No");
  return 0;
}

Measured memory_bytes: 256
/*
 *    author:  Gary Shih
 *    created: 2020-05-03 22:32:29
 */
#pragma GCC optimize("O3")
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.setf(ios::fixed), cout.precision(9);
  int n, W;
  cin >> n >> W;
  vector<int> w(n), v(n);
  for (int i = 0; i < n; ++i) cin >> w[i] >> v[i];

  int V = n * 1000;
  vector<long long> dp(n * 1000 + 1, LLONG_MAX);
  dp[0] = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = V; j >= 0; --j) {
      if (j - v[i] < 0) continue;
      if (dp[j - v[i]] != LLONG_MAX) {
        dp[j] = min(dp[j], dp[j - v[i]] + w[i]);
      }
    }
  }
  for (int j = V; j >= 0; --j)
    if (dp[j] <= W) {
      cout << j << '\n';
      break;
    }
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define pb push_back
#define inf 1000000000000000000
void checkpoint1()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);
	/*#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
	*/
}
int main()
{
	checkpoint1();
	ll n,k;
	cin>>n>>k;
	ll a[n],dp[n];
	for(ll i=0;i<n;i++){
		cin>>a[i];
		dp[i]=inf;
	}
	dp[0]=0;
	for(ll i=1;i<n;i++)
	{
		for(ll j=1;j<=k;j++)
		{
			if(i-j>=0)
				dp[i]=min(dp[i],dp[i-j]+abs(a[i]-a[i-j]));
		}
	}
	cout<<dp[n-1];
	return 0;
}


Measured memory_bytes: 1792
def add(n, sum, count, count2, k):
    count += 1
    if k >= sum: 1
    elif count == 3:
        if sum <= n:
            count2 += 1
        #print(sum, count2, count)
    else:
        for i in range(int(sum / 2 - k)):
            j = i + k + 1
            #print(j, count2, count)
            count2 += add(n, sum - j, count, 0, j)
    return count2

while True:
    n, m = map(int, input().split())
    if n == 0 and m == 0:
        break
    print(add(n, m, 0, 0, 0))




Measured memory_bytes: 5600
#include <bits/stdc++.h>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
using namespace std;
using lli = long long int;
int main() {
    lli n;cin >> n;
    vector<pair<lli,lli>> a(n);
    rep(i,n) cin >> a[i].second >> a[i].first;
    sort(a.begin(),a.end());
    lli cur = 0;
    rep(i,n){
        if(cur + a[i].second > a[i].first){
            cout << "No"<<endl;
            return 0;
        }else {
            cur += a[i].second;
        }
    }
    cout << "Yes"<<endl;
}


Measured memory_bytes: 3328
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <tuple>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <cstdio>
#include <numeric>
#define REP(i, n) for(LL i = 0;i < n;i++)
#define REPR(i, n) for(LL i = n;i >= 0;i--)
#define FOR(i, m, n) for(LL i = m;i < n;i++)
#define FORR(i, m, n) for(LL i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define INF (LL)1e15
#define MOD 1000000007
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;
typedef pair<int, P> PP;
typedef pair<LL, LP> LPP;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

/*************** using variables ***************/
int a, b;
/**********************************************/

int main(){
    cin >> a >> b;
    if(a * b % 2 == 0){
        cout << "Even" << endl;
    }else{
        cout << "Odd" << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <iterator>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <cstring>
#include <stack>
#include <vector>
#include <list>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <limits>
#include <utility>
#define EPS (1e-10)
#define REP(i,n) for(int i=0;i<n;i++)
#define equals(a,b) (fabs((a) - (b)) < EPS)
#define ll long long
using namespace std;

//typedef pair<int,int> P;
//const ll MOD = 1000000007;
//const ll INF = 100000000;

const int max_N = 100000;
string S;

//stack<int> stack;
//queue<int> que;
//priority_queue<int> pque;
//set<int> s; set<int>::iterator ite;
//multiset<int> ms; multiset<int>::iterator ite;
//map<int, int> m; map<int, int>::iterator ite;
//multimap<int, int> mm; multimap<int, int>::iterator ite;

//int dp[][];
//int dx[4] = {1, 0, -1, 0}; int dy[4] = {0, -1, 0, 1};
//int dx[8] = {1, 1, 1, 0, -1, -1, -1, 0};
//int dy[8] = {0, -1, -1, -1, 0, 1, 1, 1};

void solve() {
  if(S == "ABC") printf("ARC\n");
  else printf("ABC\n");
}

int main(int argc, char const *argv[]) {

  cin >> S;

  solve();
  return 0;
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

using namespace std;

main()
{
    fast;
    ll n;
    cin>>n;
    if (n%2==0)
        cout<<n<<endl;
    else
        cout<<2*n<<endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.StringTokenizer;

public class Main {
    static int MAX_INF = Integer.MAX_VALUE;
    
    public static void main(String[] args) throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st;
        String line;
        double xa, ya, xb, yb, xc, yc, xd, yd;
        while ((line = in.readLine()) != null) {
            st = new StringTokenizer(line, ",");
            xa = Double.parseDouble(st.nextToken());
            ya = Double.parseDouble(st.nextToken());
            xb = Double.parseDouble(st.nextToken());
            yb = Double.parseDouble(st.nextToken());
            xc = Double.parseDouble(st.nextToken());
            yc = Double.parseDouble(st.nextToken());
            xd = Double.parseDouble(st.nextToken());
            yd = Double.parseDouble(st.nextToken());
            
            double x1 = xb - xa, y1 = yb - ya,
            x2 = xc - xb, y2 = yc - yb, 
            x3 = xd - xc, y3 = yd - yc,
            x4 = xa - xd, y4 = ya - yd;
            
            xa = x1 * y2 - x2 * y1;
            xb = x2 * y3 - x3 * y2;
            xc = x3 * y4 - x4 * y3;
            xd = x4 * y1 - x1 * y4;
            
            if (xa * xb > 0 && xb * xc > 0 && xc * xd > 0 && xa * xd > 0) {
                System.out.println("YES");
            } else {
                System.out.println("NO");
            }
        }
    }
}


Measured memory_bytes: 24336
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll n;
  cin >> n;
  ll x = n, f = 0;
  while(x > 0) {
    f += x % 10;
    x /= 10;
  }
  cout << (n % f ? "No" : "Yes") << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#define l(i,a,b) for(auto i=a;i<b;i++)
#define lr(i,a,b) for(auto i=a;i>=b;i--)
#define sl(i,m) for(auto i=m.begin();i!=m.end();++i)
#define ll long long
#define lli long long int
#define ld long double
#define vec vector<int>
#define mii map<int,int>
#define vl vector<long long>
#define se set <long long int>
#define pii pair<long long,long long>
#define pb push_back
#define mp make_pair
#define ft first
#define sd second
#define tc int t;i(t);while(t--)
#define all(v) v.begin(), v.end()
#define i(x) cin>>x
#define o(x) cout<<x
#define nl o("\n");
#define pi 3.14159265359
#define SYNC ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int main()
{
    SYNC 
    //#ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //#endif
    int x,n,t,ans;
    i(n)>>x>>t;
    ans=(n%x)?n/x+1:n/x;
    o(t*ans);
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vll = vector<vl>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1e9+7;
const ll INF = 2e15;
template<class T> void print(const T& t){ cout << t << endl; }
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; }
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

int main(){
  ll n;
  cin >> n;
  vector<Pll> num;
  rep(i,n){
    ll a, b;
    cin >> a >> b;
    num.pb(mp(a, b));
  }
  ll sum = 0;
  ll button = 0;
  for (ll i = n - 1; i >= 0; i--){
    ll tmp = (num[i].F + button) % num[i].S;
    if(tmp==0){
      continue;
    }
    else{
      button += num[i].S - tmp;
    }
  }
  print(button);
}

Measured memory_bytes: 5304
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const ll INF = 1LL << 60;
ll mod_pow(ll, ll, ll); ll mod_fact(ll, ll); ll mod_inv(ll, ll); ll gcd(ll, ll); ll lcm(ll, ll);
//
int main(){
    int n, m, x;
    cin >> n >> m >> x;
    int value[n];
    int pnt[n][m];
    for(int i = 0; i < n; i++){
        cin >> value[i];
        for(int j = 0; j < m; j++){
            cin >> pnt[i][j];
        }
    }
    ll mn = INF;
    for(int i = 0; i < (1 << n); i++){
        ll sum = 0;
        vector<int> alg(m);
        for(int j = 0; j < n; j++){
            if(i >> j & 1){
                sum += value[j];
                for(int k = 0; k < m; k++){
                    alg[k] += pnt[j][k];
                }
            }
        }
        /*for(int j = 0; j < m; j++){
            cout << alg[j] << " ";
        }*/
        bool flag = true;
        for(int j = 0; j < m; j++){
            flag &= (alg[j] >= x);
        }
        if(flag) mn = min(sum, mn);
    }
    if(mn == INF) cout << -1;
    else cout << mn;
}

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

int main()
{
    int a, b;
    string ans[3] = {"Alice", "Bob", "Draw"};
    cin >> a >> b;
    if (a == 1) a = 14;
    if (b == 1) b = 14;
    if (a > b) cout << ans[0] << endl;
    if (a < b) cout << ans[1] << endl;
    if (a == b) cout << ans[2] << endl;

    return 0;
}


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

double mx, d1, d2, d3;

int main(void)
{
double x[100], y;
int n, i;

scanf("%d", &n);

for (i = 0; i < n; i++) {
scanf("%lf", &x[i]);
}

for (i = 0; i < n; i++) {
scanf("%lf", &y);
x[i] = x[i] - y;
if (x[i] < 0) x[i] = -x[i];
if (x[i] > mx) mx = x[i];
}

for (i = 0; i < n; i++) {
d1 += y = x[i];
d2 += y *= y;
d3 += x[i] * y;
}
printf("%lf\n", d1);
printf("%lf\n", sqrt(d2));
printf("%lf\n", cbrt(d3));
printf("%lf\n", mx);

return 0;
}



Measured memory_bytes: 2044
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;


int main(){
    ll a,b,c; cin >> a >> b >> c;
    if(a >= c){
        cout << a-c << " " << b << endl;
    }
    else{
        cout << 0 << " " << max(0LL,b-(c-a)) << endl;
    }
}
    



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fr(i, n) for (int i = 0; i < n; i++)
#define frab(i, a, b) for (int i = a; i < b; i++)
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;
typedef long double ld;

const ll INF = 2e9 + 10;
const ld EPS = 1e-9;
const ld PI = acos(-1);
const int M = 1e3 + 10;
const ll MOD = 1e9 + 7;
const int N = 1e6 + 10;

struct Pt {
    ll a, b, num;
} a[N], b[N];

ll f1(Pt a) {
    return max(a.a, a.b);
}

ll f2(Pt a) {
    return min(a.a, a.b);
}

bool cmp1(Pt a, Pt b) {
    return f1(a) < f1(b);
}

bool cmp2(Pt a, Pt b) {
    return f2(a) > f2(b);
}

int main() {
    //freopen("a.in", "r", stdin);
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    fr(i, n) {
        cin >> a[i].a >> a[i].b;
        a[i].num = i;
        b[i] = a[i];
    }
    ll ansA = 0, ansB = 0;
    fr(i, n)
        ansA += a[i].a, ansB += a[i].b;
    sort(a, a + n, cmp1);
    sort(b, b + n, cmp2);

    ll ans = 0;
    fr(i, n)
        ans += min(a[i].a, a[i].b);
    int cur = 0;
    while (cur < n && f1(a[cur]) < f2(b[cur])) {
        ans += (f1(a[cur]) - f2(b[cur]));
        cur++;
    }
    if (!cur) {
        if (a[0].num != b[0].num)
            ans += (f1(a[0]) - f2(b[0]));
        else
            ans += min(f1(a[0]) - f2(b[1]), f1(a[1]) - f2(b[0]));
    }
    cout << min({ans, ansA, ansB});

}


Measured memory_bytes: 8448
#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
#define DEBUG
#ifdef DEBUG
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << '(' << p.first << ',' << p.second << ')';
    return os;
}
template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
    os << '{';
    for(int i = 0; i < (int)v.size(); i++) {
        if(i) {
            os << ',';
        }
        os << v[i];
    }
    os << '}';
    return os;
}
void debugg() { cerr << endl; }
template <class T, class... Args>
void debugg(const T &x, const Args &... args) {
    cerr << " " << x;
    debugg(args...);
}
#define debug(...)                                                             \
    cerr << __LINE__ << " [" << #__VA_ARGS__ << "]:", debugg(__VA_ARGS__)
#define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl
#else
#define debug(...) (void(0))
#define dump(x) (void(0))
#endif

struct Setup {
    Setup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(15);
    }
} __Setup;

using ll = long long;
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

#include <atcoder/segtree>
using namespace atcoder;

//-------------------------------------

int e() { return -INF; }
int op(int a, int b) { return max(a, b); }

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    static segtree<int, op, e> dp(vector<int>(300010, 0));
    for(int i = 0; i < n; i++) {
        int tmp = dp.prod(max(a[i] - k, 0), min(a[i] + k + 1, 300010)) + 1;
        chmax(tmp, dp.get(a[i]));
        dp.set(a[i], tmp);
    }
    cout << dp.all_prod() << "\n";
}

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

const int MOD=1e9+7;

vector<ll> fac(300001);
vector<ll> ifac(300001);

ll modpow(ll x,ll n){
    ll ans=1;
    while(n!=0){
        if(n&1) ans=ans*x%MOD;
        x=x*x%MOD;
        n=n>>1; 
    }
    return ans;
}

ll comb(ll a, ll b){
    if(a==0&&b==0) return 1;
    if(a<b||a<0) return 0;
    ll tmp = ifac[a-b]*ifac[b] % MOD;
    return tmp*fac[a]%MOD;
}

void prepare(){
    fac[0]=1;ifac[0]=1;
    for(ll i=0;i<300000;i++){
        fac[i+1]=fac[i]*(i+1)%MOD;
        ifac[i+1]=ifac[i]*modpow(i+1,MOD-2)%MOD;
    }
}

const int maxn = 100005;

int main(){
    prepare();
    int n,k;
    cin>>n>>k;
    vector<int> v;
    rep(i,n) {
        int tmp;
        cin>>tmp;
        v.push_back(tmp);
    }

    sort(v.begin(),v.end());
    vector<int> mx(n,0);
    vector<int> mn(n,0);

    rep(i,n){
        mx[i]=(comb(i,k-1)*v[i])%MOD;
        mn[i]=(comb(n-i-1,k-1)*v[i])%MOD;
    }
    ll ans=0;
    rep(i,n){
        ans=(ans+mx[i]-mn[i])%MOD;
    }
    cout<< ans << endl;

}

Measured memory_bytes: 6264
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define inf 1e+9
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }

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

    ll n,k,ans=0;
	cin >> n;
	ll a[n+1],b[n];
	rep(i,n+1){
		cin >> a[i];
	}
	rep(i,n){
		cin >> b[i];
	}

	rep(i,n){
		if(a[i]<b[i]){
			//b[i] -= a[i];
			if((b[i]-a[i])<a[i+1]){
				a[i+1] -= (b[i]-a[i]);
				ans += b[i];
				//cout << ans << endl;
			}
			else{
				ans += a[i];
				ans += a[i+1];
				a[i+1] = 0;
				//cout << "aaa" << endl;
			}
		}
		else{
			ans += b[i];
			//cout << a[i] << b[i] << endl;
		}
		//cout << ans << endl;
	}

	// rep(i,n){
	// 	ans += min(a[i],b[i]);
	// }
	// ans += a[n];

	// for(int i=n;i>=1;i--){
	// 	if(a[i]<b[i-1]){
	// 		//b[i] -= a[i];
	// 		if((b[i-1]-a[i])<a[i-1]){
	// 			a[i-1] -= (b[i-1]-a[i]);
	// 			ans += b[i-1];
	// 			//cout << ans << endl;
	// 		}
	// 		else{
	// 			ans += a[i];
	// 			ans += a[i-1];
	// 			a[i-1] = 0;
	// 			//cout << "aaa" << endl;
	// 		}
	// 	}
	// 	else{
	// 		ans += b[i-1];
	// 		//cout << a[i] << b[i] << endl;
	// 	}
	// 	//cout << ans << endl;
	// }

	cout << ans << endl;

	// int dp[n+2];
	// dp[0]=0;
	// dp[1]=abs(s[0]-s[1]);
	// rep(i,n){
	// 	dp[i+2] = min(dp[i+1]+abs(s[i+2]-s[i+1]),dp[i]+abs(s[i+2]-s[i]));
	// }

	// cout << dp[n-1] << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <stack>
#include <queue>
#include <iomanip>
using namespace std;
using ll = long long;
using P = pair<int, int>;


int main()
{
    int n, m;
    cin >> n >> m;
    vector<string> a(n), b(m);
    for (int i = 0; i < n; ++i) cin >> a[i];
    for (int i = 0; i < m; ++i) cin >> b[i];

    for (int di = 0; di <= n - m; ++di)
    {
        for (int dj = 0; dj <= n - m; ++dj)
        {
            bool ok = true;
            for (int i = 0; i < m; ++i)
            {
                for (int j = 0; j < m; ++j)
                {
                    if (a[i + di][j + dj] != b[i][j])
                    {
                        ok = false;
                        break;
                    }
                }
                if (!ok)
                    break;
            }
            if (ok)
            {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define debug(x) cerr << #x << " : " << x << '\n'

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<ll, ll> pll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const ll Mod = 1000000007LL;
const int Maxn = 2e5 + 10;
const ll Inf = 2242545357980376863LL;
const ll Log = 30;

int main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ll h, w, n;
	cin >> h >> w >> n;
	ll ans = h;
	for(int i = 0; i <= h; i++){
		for(int j = 0; j <= w; j++){
			if(w*i + h * j - i * j >= n) ans = min(ans, 0ll + i + j);
		}
	}
	cout << ans << '\n';
	return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
#define int long long
#define vvectorl vector<vector<long long>>
#define vectorl vector<long long>
int gcd(int a, int b) {
	if (b == 0) {
		return a;
	}
	int r = a % b;
	return gcd(b, r);
}
int squ(int x) {
	return x * x;
}
int di(vectorl x, vectorl y, int i, int j) {
	return squ(x[i] - x[j]) + squ(y[i] - y[j]);
}
int qmmin(int &a, int b) {
	if (a == -1) {
		a = b;
	}
	else {
		a = min(a, b);
	}
	return a;
}
int nex(int a) {
	return (a + 1) % 3;
}
signed main() {
	int n; cin >> n;
	vvectorl h(n, vectorl(3));
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 3; j++) {
			cin >> h[i][j];
		}
	}
	vvectorl sh(n, vectorl(3,-1));
	sh[0] = h[0];
	for (int i = 1; i < n; i++) {
		for (int j = 0; j < 3; j++) {
			sh[i][j] = max(sh[i - 1][nex(j)] + h[i][j], sh[i - 1][nex(nex(j))] + h[i][j]);
		}
	}
	int ans = 0;
	for (int i = 0; i < 3; i++) {
		ans = max(ans, sh[n - 1][i]);
	}
	cout << ans << endl;
}

Measured memory_bytes: 11136
n, x, y = gets.split.map(&:to_i)
shorten = y - x - 1
loop = y - x + 1

dists_counts = [0] * n

(1..(n - 1)).each{|from|
    (from..n).each{|to|
        dist = 0
        if from <= x && to >= y
            dist = to - from - shorten
        elsif to <= x || from >= y
            dist = to - from
        else
            left = from
            right = to
            if from < x
                dist += x - from
                left = x
            end
            if to > y
                dist += to - y
                right = y
            end
            dist += [right - left, left - right + loop].min
        end
        dists_counts[dist] += 1
    }
}

dists_counts.drop(1).each{|it|
    puts it
}

Measured memory_bytes: 3836
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstring>
#include<queue>
using namespace std;

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

const int MAXH = 10, MAXW = 10, MAXN = 11;

bool w[MAXN][MAXH][MAXW];
bool check[MAXN][MAXH][MAXW];
int dx[12] = {0,1,2,2,2,1,0,-1,-2,-2,-2,-1};
int dy[12] = {-2,-2,-1,0,1,2,2,2,1,0,-1,-2};

bool ok ;
int sx, sy, n;

int main()
{
    while(cin >> sx >> sy &&( sx || sy))
    {
        memset(w, false, sizeof(w));
        cin >> n;
        int spx, spy;
        REP(n)
        {
            cin >> spx >> spy;
            rep(y,3)rep(x,3)if(spx + x - 1 > -1 && spx + x - 1 < MAXW && spy + y -1 > -1 && spy + y -1 < MAXH)
                w[i][spx + x - 1][spy + y - 1] = true;
        }       

        ok = false;
        memset(check, false, sizeof(check));
        check[0][sx][sy] = true;

        rep(t,n)rep(y,MAXH)rep(x, MAXW)if(check[t][x][y])
        {
            rep(i,12)if(x+dx[i]> -1 && x+dx[i] < MAXW && y+dy[i] > -1 && y + dy[i] < MAXH)
                if(w[t][x+dx[i]][y+dy[i]])
                {
                    //cout << "t:" <<t << " x:" << x+dx[i] << " y:" << y+dy[j] << endl;
                    check[t+1][x+dx[i]][y+dy[i]] = true;
                }
        }
        rep(y, MAXH)rep(x,MAXW)if(check[n][x][y]) ok = true;

        if(ok) cout << "OK" << endl;
        else cout << "NA" << endl;
    }

    return 0;
}

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

namespace C
{
    internal static class Program
    {
        private static void Main(string[] args)
        {
            var k = Cint();
            var sum = 0L;
            
            for (var a = 1; a <= k; ++a)
            {
                for (var b = 1; b <= k; ++b)
                {
                    for (var c = 1; c <= k; ++c)
                    {
                        var gcd = Gcd(Gcd(a, b), c);
                        sum += gcd;
                    }
                }
            }

            Cout(sum);
        }
        
        private static int Gcd(int a, int b)
        {
            while (a != 0 && b != 0)
            {
                if (a > b)
                    a %= b;
                else
                    b %= a;
            }

            return a == 0 ? b : a;
        }

        #region Input and Output

        private static readonly List<string> Buffer = new List<string>();

        private static string Cin()
        {
            ReadBuffer();

            var str = Buffer.First();
            Buffer.RemoveAt(0);

            return str;
        }

        private static IEnumerable<string> CinA() => Console.ReadLine()?.Split();
        private static int Cint() => int.Parse(Cin());
        private static int[] CintA() => CinA().Select(int.Parse).ToArray();
        private static void Cout(object obj) => Console.WriteLine(obj);

        private static void ReadBuffer()
        {
            if (Buffer.Any()) return;

            var line = Console.ReadLine();
            if (line != null && line.Contains(' '))
            {
                Buffer.AddRange(line.Split());
            }
            else
            {
                Buffer.Add(line);
            }
        }

        #endregion

        #region Loops

        private static void Loop(int count, Action<int> action) => Loop(0, count, action);

        private static void Loop(int init, int count, Action<int> action, int step = 1)
        {
            for (var i = init; i < count + init; i += step)
            {
                action(i);
            }
        }

        #endregion
    }
}


Measured memory_bytes: 28248
#include <bits/stdc++.h>
using namespace std;
int main(){
char a;
char b;
cin>>a>>b;
if(a == 'H'){
    cout<<b<<endl;
}
else{
    if(b == 'H'){
        cout<<"D"<<endl;
    }
    else{
        cout<<"H"<<endl;
    }
    
}
return 0;
}

Measured memory_bytes: 256
import java.io.PrintStream;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
	static final PrintStream out = System.out;
	static Scanner sc = new Scanner(System.in);
	static final long Mod = 1000_000_007L;
	public static void main(String[] args) {
		Main main = new Main();
		main.solve();
		System.exit(0);
	}

	void solve() {
		int N = nextInt();
		long K = nextLong();
		int[] A = new int[N];
		long sum = 0;
		for(int i=0;i<N;i++) {
			A[i] = nextInt();
			sum+=A[i];
		}

		Set<Long> candidates = new HashSet<>();

		for(int i=1;i*i<=sum;i++) {
			if(sum%i==0) {
				candidates.add((long) i);
				candidates.add((long) sum/i);
			}
		}
		long ans = 1;
		for(long x:candidates) {
			long need;
			{ // calc need
				long[] r = new long[N];
				for(int i=0;i<N;i++)r[i] = A[i]%x;
				Arrays.sort(r);
				long tot = 0;
				for(int i=0;i<N;i++)tot += r[i];
				int l = (int) (N -tot/x);
				need = 0;
				for(int i=0;i<l;i++) need += r[i];
			}
			if(need<=K)ans = Math.max(ans, x);
		}

		out.println(ans);

	}

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)a[i] = nextInt();
		return a;
	}
	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)a[i] = nextLong();
		return a;
	}
	public int nextInt() {
		return Integer.parseInt(next());
	}
	public long nextLong() {
		return Long.parseLong(next());
	}
	public String next() {
		return sc.next();
	}

}

Measured memory_bytes: 27944
N=int(input())
W=[]
for i in range(N):
    w=input()
    W.append(w)
words=W.copy()
words=set(words)

for k in range(N-1):
    if W[k][-1]!=W[k+1][0]:
        print('No')
        break
    elif len(W)!=len(words):
        print('No')
        break
    else:
        continue
else:
    print('Yes')

Measured memory_bytes: 3064
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;

long long H, W;
vector<long long> v;

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	cin >> H >> W ;
	long long S, s, ans;

	if((H % 3) == 0 || (W % 3) == 0){
		ans = 0;
		printf("%lld\n", ans);
		return 0;
	}

	long long w, h;
	v.clear();

	w = W / 3;
	h = H / 2;
	for(long long i = -2; i <= 2; i++){
		if(w+i<1 || w+i>=W) continue;
		for(long long j = -2; j <= 2; j++){
			if(h+j<1 || h+j>=H) continue;
			long long a = H * (w+i);
			long long b = (h+j)*(W-(w+i));
			long long c = (H-(h+j))*(W-(w+i));
			S = max( a, max( b, c ) );
			s = min( a, min( b, c ) );
			v.push_back(S - s);
		}
	}
	
	h = H / 3;
	w = W / 2;
	for(long long i = -2; i <= 2; i++){
		if(h+i<1 || h+i>=H) continue;
		for(long long j = -2; j <= 2; j++){
			if(w+j<1 || w+j>=W) continue;
			long long a = (h+i) * W;
			long long b = (H-(h+i))*(w+j);
			long long c = (H-(h+i))*(W-(w+j));
			S = max( a, max( b, c ) );
			s = min( a, min( b, c ) );
			v.push_back(S - s);
		}
	}

	h = H / 3;
	for(int i = -2; i <= 2; i++){
		for(int j= -2; j <= 2; j++){
			long long a = (h + i) * W;
			long long b = (h + j) * W;
			long long c = (H - (h+i) - (h+j)) * W;
			S = max(a, max(b, c));
			s = min(a, min(b, c));
			v.push_back(S - s);
		}
	}

	w = W / 3;
	for(int i = -2; i <= 2; i++){
		for(int j= -2; j <= 2; j++){
			long long a = (w + i) * H;
			long long b = (w + j) * H;
			long long c = (W - (w+i) - (w+j)) * H;
			S = max(a, max(b, c));
			s = min(a, min(b, c));
			v.push_back(S - s);
		}
	}

	sort(v.begin(), v.end());
	ans = v[0];
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 3720
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

int main(void){
  int n;
  cin >> n;
  int ans = 0;
  REP(i, n+1){
    if(i%2 == 0) continue;
    int count = 0;
    for(int j = 1; j*j <= i; j++){
      if(i%j) continue;
      count++;
      if(i != j*j) count++;
    }
    if(count == 8) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
import math

n,p = iim()
A = iil()

if n > 1:
    even = 0
    odd = 0
    for i in A:
        if i%2 == 0:
            even += 1
        else:
            odd += 1
    if odd > 0:
        p0 = 2**(odd-1)
        print(2**even*p0)
    else:
        print(2**even if p == 0 else 0)
else:
    if p == 0:
        print(2 if A[0]%2 == p else 0)
    else:
        print(1 if A[0]%2 == p else 0)


Measured memory_bytes: 3064
N, K = map(int,input().split())
As = list(map(int,input().split()))
bit_length = max(len(bin(K)), len(bin(max(As))))-2 #0bの除去
ans = 0
for i in range(bit_length,-1,-1): #上から順番に
    bit = 2**i 
    #iビット目の立っている数を数える
    n_bit = sum([1 for a in As if a & bit]) 
    # 0のほうが大きい場合
    # Xのビットは立っているのが望ましいが、Kを超えては駄目
    if n_bit < N - n_bit and K-bit >= 0:
        n_bit = N - n_bit
        K -= bit
    ans += bit * n_bit
print(ans)

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin>>n;
    n%=10;
    if (n==2||n==4||n==5||n==7||n==9){
        cout<<"hon\n";
    }else if(n==0||n==1||n==6||n==8){
        cout<<"pon\n";
    }else{
        cout<<"bon\n";
    }
    return 0;
}


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

int n, q, N;
int dat[4*100000];

void init(){
	N = 1;
	while(N < n) N *= 2;
	rep(i,N*2) dat[i] = 0;
}

void add(int x, int y){
	x += N-1;
	dat[x] += y;
	while(x > 0){
		x = (x-1)/2;
		dat[x] += y;
	}
}

int getSum(int a, int b, int t, int r, int l){
	if(a >= l || b <= r) return 0;
	if(a <= r && l <= b) return dat[t];
	return getSum(a,b,t*2+1,r,(r+l)/2)+getSum(a,b,t*2+2,(r+l)/2,l);
}

int main(){
	scanf("%d%d",&n,&q);
	init();
	rep(i,q){
		int com, x, y;
		scanf("%d%d%d",&com,&x,&y);
		if(com == 0){
			x--;
			add(x,y);
		}
		else{
			x--; y--;
			printf("%d\n",getSum(x,y+1,0,0,N));
		}
	}
}

Measured memory_bytes: 2216
#include<bits/stdc++.h>
#define x second
#define y first
using namespace std;
pair<int,int>a[101][101];
int col[101][101];
int n;
void dfs(int y1,int x1){
  col[y1][x1]=1;
  if(!col[a[y1][x1].y][a[y1][x1].x])dfs(a[y1][x1].y,a[y1][x1].x);
  for(int i=0;i<n;i++)
    for(int j=0;j<n;j++)
      if(!col[i][j]&&a[i][j].y==y1&&a[i][j].x==x1)
        dfs(i,j);
}
int main(){
  while(cin>>n,n){
    memset(col,0,sizeof(col));
    memset(a,0,sizeof(a));
    for(int i=0;i<n;i++)
      for(int j=0;j<n;j++)
        cin>>a[i][j].x>>a[i][j].y;
    int sum=0;
    for(int i=0;i<n;i++)
      for(int j=0;j<n;j++)
        if(!col[i][j])dfs(i,j),sum++;
    cout<<sum<<endl;
  }
}

Measured memory_bytes: 3204
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#define llong long long
#define INF (__INT64_MAX__ / 2)
#define EPS 10e-8
#define MAX_N 100000

using namespace std;
typedef pair<llong, llong> ipair;
llong modulo(llong left, llong right) { return (left % right + right) % right; }

llong N, M;
vector<ipair> adj_list[MAX_N];

llong x[MAX_N];
bool solve(llong node) {
    stack<llong> st;
    st.push(node);
    x[node] = 0;

    while(!st.empty()) {
        llong cur = st.top();   st.pop();
        
        for(ipair pr : adj_list[cur]) {
            if(x[pr.first] != INF && x[pr.first] != x[cur] + pr.second)
                return false;
            
            if(x[pr.first] == INF) {
                st.push(pr.first);
                x[pr.first] = x[cur] + pr.second;
            }
        }

    }

    return true;
}

int main(int argc, char **argv) {
    cin >> N >> M;

    for(int i = 0; i < M; ++i) {
        llong L, R, D;
        cin >> L >> R >> D;
        L--;
        R--;
        adj_list[L].push_back(make_pair(R, D));
        adj_list[R].push_back(make_pair(L, -D));
    }

    for(int i = 0; i < N; ++i)
        x[i] = INF;

    bool res = true;
    for(int i = 0; i < N; ++i)
        if(x[i] == INF)
            res &= solve(i);
    
    cout << (res ? "Yes" : "No") << endl;
}

Measured memory_bytes: 14812
n=input()
n=int(n)
import math
x1=n/1.08

a=math.floor(math.floor(x1)*1.08)
b=math.floor(math.ceil(x1)*1.08)
if n==a:
	print(math.floor(x1))
elif n==b:
	print(math.ceil(x1))
else:
	print(':(')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define SZ(x) ((int)x.size())
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef long double ld;
const int MOD = 1e9 + 7;
const int MX = 1e6;
int n;
int a[MX + 10], fac[MX + 10] = {1}, inv[MX + 10] = {1};
int modpow(int a, long long n, int mod = MOD) {
	int r = 1, b = a;
	while(n > 0) {
		if(n & 1) r = 1ll * r * b % mod;
		b = 1ll * b * b % mod;
		n >>= 1;
	}
	return r;
}
int nCr(int n, int r) {
	if(r < 0 || r > n) return 0;
	return 1ll * fac[n] * inv[r] % MOD * inv[n-r] % MOD;
}
int main() {
	for(int i=1; i<=MX; i++) {
		fac[i] = 1ll * fac[i-1] * i % MOD;
		inv[i] = modpow(fac[i], MOD - 2);
	}
	scanf("%d", &n);
	ll res = 0;
	for(int i=(n+1)/2; i<=n-1; i++) {
		a[i] = 1ll * nCr(i-1, n-1-i) * fac[i] % MOD * fac[n-1-i] % MOD;
		res = (res + 1ll * (a[i] - a[i-1] + MOD) % MOD * i % MOD) % MOD;
	}
	printf("%lld", res);
	return 0;
}

Measured memory_bytes: 11648