akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <numeric>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
int Max(int(a), int(b), int(c)) {
	return max(max(a, b), c);
}
int Min(int(a), int(b), int(c)) {
	return min(min(a, b), c);
}





int main() {
	ll A,B,C;
	cin >> A>>B>>C ;
	ll an = 0;
	if (A == B && B == C) {
		an =( A+1) % 2;
		an *= -1;
	}
	else {
		
		while (((A + 1) % 2) * ((B + 1) % 2) * ((C + 1) % 2)>0) {
			ll a = (B + C) / 2;
			ll b = (A + C) / 2;
			ll c = (A + B) / 2;
			A = a;
			B = b;
			C = c;
			an++;
		}
	}
	
	cout << an << endl;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
#include <set>

using namespace std;

char s[100010];
int K , N;

int main(){
	scanf("%s" , s);
	scanf("%d" , &K);
	for(N = 0 ; s[N] != 0 ; ++N);
	for(int i = 0 ; i < N && K > 0 ; ++i){
		if(s[i] == 'a') continue;
		int y = 'z' - s[i] + 1;
		if(K >= y){
			s[i] = 'a';
			K -= y;
		}
	}
	int t = s[N - 1] - 'a';
	t = (t + K) % 26;
	s[N - 1] = t + 'a';
	printf("%s\n" , s);
	return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include <cassert>
#include <numeric>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
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 (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int,int> P;

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main(){
    int n;
    cin >> n;
    map<pair<ll,ll>,P> mp;
    int zero = 0;
    rep(i,n){
        ll x,y;
        cin >> x >> y;
        if(x==0&&y==0){
            zero++;
            continue;
        }
        ll g = gcd(x,y);
        x/=g;
        y/=g;
        if(y<0)x=-x,y=-y;
        if(y==0&&x<0)x=-x,y=-y;
        //first field or second field or zero
        if(x>0)mp[make_pair(x,y)].first++;
        else mp[make_pair(y,-x)].second++;
    }
    mint ans = 1;
    for(auto p:mp){
        int N = p.second.first;
        int M = p.second.second;
        //cout << N << " " << M << endl;
        mint res = mint(2).pow(N)-1+mint(2).pow(M)-1;
        res += 1;
        //cout << res << endl;
        ans *= res;
    }
    ans -= 1;
    ans += zero;
    cout << ans << endl;
}

Measured memory_bytes: 15976
// #pragma GCC target("avx2")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3121000;
long long fact[C_SIZE];
long long finv[C_SIZE];
long long inv[C_SIZE];
long long Comb(int a,int b){
 	if(a<b||b<0)return 0;
 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
}
void init_C(int n){
	fact[0]=finv[0]=inv[1]=1;
	for(int i=2;i<n;i++){
		inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
	}
	for(int i=1;i<n;i++){
		fact[i]=fact[i-1]*i%mod;
		finv[i]=finv[i-1]*inv[i]%mod;
	}
}
long long pw(long long a,long long b){
	if(a<0LL)return 0;
	if(b<0LL)return 0;
	long long ret=1;
	while(b){
		if(b%2)ret=ret*a%mod;
		a=a*a%mod;
		b/=2;
	}
	return ret;
}
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
double ABS(double a){return max(a,-a);}
int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
// ここから編集しろ
double dp[310][310][310];
int st[4];
int N;
double dfs(int a,int b,int c){
	if(a+b+c==0)return 0.0;
	if(dp[a][b][c]>-0.5)return dp[a][b][c];
	double ks=(double)N/(a+b+c);
	double ret=0;
	if(a){
		ret+=(dfs(a-1,b,c)+ks)*a/(a+b+c);
	}
	if(b){
		ret+=(dfs(a+1,b-1,c)+ks)*b/(a+b+c);
	}
	if(c){
		ret+=(dfs(a,b+1,c-1)+ks)*c/(a+b+c);
	}
	
	return dp[a][b][c]=ret;
}
int main(){
	int a;scanf("%d",&a);N=a;
	for(int i=0;i<a;i++){
		int t;scanf("%d",&t);
		st[t]++;
	}
	for(int i=0;i<=a;i++)for(int j=0;j<=a;j++)for(int k=0;k<=a;k++)
		dp[i][j][k]=-1;
	double ret=dfs(st[1],st[2],st[3]);
	printf("%.12f\n",ret);
}

Measured memory_bytes: 227584
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1LL << 60;
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)


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

	int N;
	cin >> N;
	vector<int>A(1 << N);
	for (int i = 0; i < 1 << N; i++)cin >> A[i];

	ll ans = 0;
	for (int x = 1; x < (1 << N);x++) {
		ll mx1 = -1;
		ll mx2 = -1;
		for (int j = x; j > 0; j = (j - 1)&x) {
			if (A[j] > mx1) {
				mx2 = mx1;
				mx1 = A[j];
			}
			else if (A[j] > mx2)mx2 = A[j];
		}
		if (A[0] > mx1) {
			mx2 = mx1;
			mx1 = A[0];
		}
		else if (A[0] > mx2)mx2 = A[0];
		ans = max(ans, mx1 + mx2);
		puts(ans);
	}
	
	return 0;
}

Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
int main()
{
    char s[4];
    int flag=0;
    
    for(int i=0;i<4;i++)
    { cin>>s[i];}
    
    for(int i=0;i<3;i++)
    { if(s[i]==s[i+1])
    { flag=1;}
    }
    
    if(flag==1)
    { cout<<"Bad";}
    
    else cout<<"Good";
    
    return 0;
}
    


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
#define read freopen("in.in","r",stdin)
#define write freopen("out.out","w",stdout)
#define FastIO ios::sync_with_stdio(0)

#define All(a) a.begin(),a.end()
#define PI 3.1415926535897932385
#define INF 1000000000
#define eps 1e-7
#define Clear(a) memset(a,0,sizeof(a))
#define MOD 1000000007
typedef vector<int> vi;
typedef pair<pair<int, int>, int> pii;
typedef unsigned long long ull;


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

ll GCD(ll a, ll b)
{
	if (b == 0)return a;
	return GCD(b, a % b);
}
ll LCM(ll a, ll b)
{
	return (a / GCD(a, b)) * b;
}

pair<ll, pair<ll, ll> > extendedEuclid(ll a, ll b) {
	if (a == 0) return make_pair(b, make_pair(0, 1));
	pair<ll, pair<ll, ll> > p;
	p = extendedEuclid(b % a, a);
	return make_pair(p.first, make_pair(p.second.second - p.second.first * (b / a), p.second.first));
}

ll modInverse(ll a, ll m) {
	return (extendedEuclid(a, m).second.first + m) % m;
}

ll inverseMod(ll x, ll y, ll z) {
	return ((x % z) * modInverse(y, z)) % z;
}
ll BigMod(ll x, ll y) {
	if (y == 0)return 1;
	if (x == 1)return 1;
	if (y == 1)return x;
	ll ans = BigMod(x, y / 2) % MOD;
	if (y & 1)
		return ((x % MOD * ans % MOD) % MOD * ans % MOD) % MOD;
	return
		(ans % MOD * ans % MOD) % MOD;
}



int n, m;
int in[1001][1001];
int dp[1001][1001];
int val(int x, int y) {
	return x >= 0 && y >= 0 && x < n && y < m && in[x][y] == 0;
}
int solve(int x, int y) {
	if (x == n - 1 && y == m - 1)return 1;;
	if (dp[x][y] != -1)return dp[x][y];
	int ans = 0;
	for (int c = 0; c < 2; c++) {
		int xx = x + dx[c], yy = y + dy[c];
		if (val(xx, yy))
			ans += solve(xx, yy);
		ans %= MOD;
	}
	return dp[x][y] = ans % MOD;
}
int main() {
	FastIO;


	cin >> n >> m;
	for (int c = 0; c < n; c++) {
		for (int i = 0; i < m; i++) {
			char x;
			cin >> x;
			if (x == '.')in[c][i] = 0;
			else in[c][i] = 1;
		}
	}
	memset(dp, -1, sizeof dp);
	cout<<solve(0, 0)%MOD<<" ";
	//cout << dp[n - 1][m - 1]+1 << endl;
	return 0;
}

Measured memory_bytes: 8192
// Theater

#include <iostream>

using namespace std;

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

	int res = 0;

	for (int i = 0; i < N; ++i){
		int l, r;
		cin >> l >> r;
		res += r - l + 1;
	}

	cout << res << endl;

	return 0;
}

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

using namespace std;

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

	string s;
	cin >> s;

	int x = s.size() & 1;
	int y = *s.begin() == s.back();

	if(x ^ y) {
		cout << "First" << '\n';
	} else {
		cout << "Second" << '\n';
	}

	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,b) FOR(i,0,b)
using namespace std;
const int SIZE=1+1e5;
int main() {
	string s;
	cin >> s;
	int K;
	cin >> K;
	REP(i,s.size()){
		if(s[i]=='a') continue;
		if('z'-s[i]+1<=K){
			K-='z'-s[i]+1;
			s[i]='a';
		}
	}
	if(K>='z'-'a'+1) K%='z'-'a'+1;
	s[s.size()-1]+=K;
	cout << s << endl;
	return 0;
}

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

struct Data{

  string name;
  int b_year;
  int w_year;
  
};

int main(){

  int N,Q;
  Data list[1000];
  
  while(1){
    
    cin >>N>>Q;
    if(N==0 && Q==0)break;
    
    for(int i=0 ; i < N ; i++){
      cin >>list[i].name>>list[i].b_year>>list[i].w_year;
    }
    
    int year;
    
    for(int i=0 ; i < Q ; i++){
      cin >>year;
      bool flag=true;
      for(int j=0 ; j < N ; j++){
	if(year > list[j].w_year-list[j].b_year && year <= list[j].w_year){
	  cout <<list[j].name<<" "<<list[j].b_year-(list[j].w_year-year)<<endl;
	  flag=false;
	  break;
	}
      }
      if(flag)cout <<"Unknown"<<endl;
    }
    
  }
  return 0;
}

Measured memory_bytes: 1300
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int r = sc.nextInt();
        int g = sc.nextInt();
        int b = sc.nextInt();
        int rgb = r*100 + g*10 + b*1;

        System.out.println(rgb%4 == 0 ? "YES" : "NO");
    }

}


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

int main()
{
    int N, K, x;
    cin >> N;
    cin >> K;
    x = 1;
    for (int i = 0; i < N; ++i)
    {
        if (x * 2 < x + K)
        {
            x = x * 2;
        }
        else
        {
            x = x + K;
        }
    }
    cout << x << endl;
}

Measured memory_bytes: 3604
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <iostream>

using namespace std;

int main()
{
    int i,x;
    for(i=1;i<=5;i++){cin>>x;if(x==0){break;}}
    cout<<i;
    return 0;
}


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

int main() {
  int N;
  cin>>N;
  int A=0;
  int B=0;
  vector<int> point(N);
  for(int i=0;i<N;i++){
    cin>>point.at(i);
  }
  sort(point.begin(),point.end());
  reverse(point.begin(),point.end());
  for(int i=0;i<N;i+=2){
    A+=point.at(i);
  }
  for(int i=1;i<N;i+=2){
    B+=point.at(i);
  }
  cout<<A-B<<endl;
}


Measured memory_bytes: 3628
#include <iostream>
#include <bits/stdc++.h>
#include <math.h>

using namespace std;

int main(){
    int a,b;
    cin>>a>>b;
    
    int hoge=b-a;
    int fuga=hoge*(hoge+1)/2;
    
    cout<<fuga-b<<endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define PI 3.141592653589
int main()
{
    double a,b,h,m;
    cin >> a >> b >> h >> m;
    double ans,rad;
    rad = 6 * m  - 30 * h - 0.5 * m;
    // if ( rad > 180 )
    //     rad = 360 - rad;
    if ( rad < 0 )
        rad = -rad;
    ans = pow(a,2) + pow(b,2) - 2 * a * b * cos ( rad / 180.0 * PI);
    printf("%.10f\n",sqrt(ans));
    return 0;
}

Measured memory_bytes: 4176
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional> 
#define ff first 
#define endl "\n"
#define ss second 
#define li list<int>
#define vi vector<int>
#define ll long long int
#define pii pair<int,int>
#define vii vector<pair<int,int> >
#define mp make_pair
#define pb push_back
#define setbits(x) __builtin_popcountll(x)
#define custom  pair<int,pair<int,int> >
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> pbds; 
#define mod 1000000007
double dp[3001][3001];
double solve(double* arr,int i,int n,int x){
    if(x==0){
        return 1;
    }
    if(i==n){
        return 0;
    }
    if(dp[i][x]>(-0.9)){
        return dp[i][x];
    }
    double one=arr[i]*solve(arr,i+1,n,x-1);
    double two=(1-arr[i])*solve(arr,i+1,n,x);
    return dp[i][x]=one+two;
}
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int n;
    cin>>n;
    double arr[n];
    memset(dp,-1,sizeof dp);
    for(int i=0;i<n;i++){
        cin>>arr[i];
    }
    int x=(n+1)/2;
    double prob= solve(arr,0,n,x);
    cout<<fixed<<setprecision(9)<<prob;
    return 0;
}

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

using namespace std;

const long long INF = 1LL<<60;

int main(void){
    
    int n;
    cin >> n;
    
    vector<long long> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    
    long long allSum = std::accumulate(a.begin(), a.end(), 0LL); 
    
    long long ans = INF;
    long long snuke = 0;
    
    for (int i = 0; i < n-1; i++){
        snuke += a[i];
        long long arai = allSum - snuke;
        
        ans = min(ans, abs(snuke-arai));
    }
    cout << ans << endl;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define vi vector<ll>
#define pb push_back
#define F first
#define S second
#define all(v) (v).begin(),(v).end()
#define pii pair<ll,ll>
#define vii vector<pii>
#define MOD 1000000007LL
#define calc_fact(n) tgamma(n+1)
#define INF LONG_LONG_MAX

pii solve(string s,char ch)
{
    vi v;pii p;
    for(ll i=0;i<s.length();i++)
    {
        if(s[i]==ch)
        v.pb(i);
    }
    if(v.size()<=1)
    {
        p.F=-1;p.S=-1;
        return p;
    }
    ll j=0;
    for(ll i=1;i<v.size();i++)
    {
        while(v[i]-v[j]+1>=2*(i-j+1) and i-1>j)j++;
        
        if(i>j and v[i]-v[j]+1<(i-j+1)*2)
        {
            p.F=v[j]+1;p.S=v[i]+1;
            return p;
        }
    }
    
    p.F=-1;p.S=-1;
    return p;
}

signed main()
{
    FIO;
    string s;
    cin>>s;
    set<char> st;
    for(ll i=0;i<s.length();i++)
    st.insert(s[i]);
    
    for(auto it:st)
    {
        pii p=solve(s,it);
        if(p.F!=-1 and p.S!=-1)
        {
            cout<<p.F<<" "<<p.S;
            goto h;
        }
    }
    cout<<"-1 -1";
    h:;
}

Measured memory_bytes: 4140
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e+15;

class SlideMax {
public:
    deque<pair<ll,ll>> dq;
    SlideMax(){};
    void push(ll val, ll i) {
        while ( ! dq.empty() && dq.back().first <= val) {
            dq.pop_back();
        }
        dq.push_back(make_pair(val, i));
    }
    void pop(ll i) {
        while ( ! dq.empty() && dq.front().second < i) {
            dq.pop_front();
        }
    }
    ll getval() {
        if (dq.empty()) return -INF;
        return dq.front().first;
    }
};

/**
 * dx := Brunoの市場価値 - Annaの市場価値
 * dy := Brunoの貴重度 - Annaの貴重度
 */
void f(int i, int n, ll dx, ll dy, vector<ll> &x, vector<ll> &y, vector<pair<ll,ll>> &res) {
    if (i == n) {
        res.emplace_back(dx, dy);
        return ;
    }
    f(i+1, n, dx, dy, x, y, res); // No one
    f(i+1, n, dx-x[i], dy-y[i], x, y, res); // Anna
    f(i+1, n, dx+x[i], dy+y[i], x, y, res); // Bruno
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N; ll D;
    cin >> N >> D;
    vector<ll> x(N), y(N);
    for (int i=0; i<N; ++i) cin >> x[i] >> y[i];

    vector<pair<ll,ll>> L, R;
    f(0, N/2, 0, 0, x, y, L);
    f(N/2, N, 0, 0, x, y, R);
    sort(L.rbegin(), L.rend());
    sort(R.begin(), R.end());

    SlideMax smax;
    int k = 0;
    ll mx = 0;
    for (int i=0; i<(int)L.size(); ++i) {
        while (k < (int)R.size() && R[k].first <= -L[i].first+D) {
            smax.push(R[k].second, R[k].first);
            k ++;
        }
        smax.pop(-L[i].first-D);
        mx = max(mx, L[i].second + smax.getval());
    }
    cout << mx << endl;

    return 0;
}


Measured memory_bytes: 489088
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        long k = sc.nextLong();
        int cnt = 0;
        boolean same = true;
        for (int i = 0; i < s.length() - 1; i++) {
            if (s.charAt(0) != s.charAt(i + 1)) {
                same = false;
            }
            if (s.charAt(i) == s.charAt(i + 1)) {
                cnt++;
                i++;
            }
        }
        if (same) {
            System.out.println(s.length() * k / 2);
            return;
        }
        long ans = k * cnt;
        if (s.charAt(0) == s.charAt(s.length() - 1)) {
            int a = 0;
            while (s.charAt(0) == s.charAt(a)) {
                a++;
            }
            int b = 0;
            while (s.charAt(s.length() - 1) == s.charAt(s.length() - b - 1)) {
                b++;
            }
            ans -= (k - 1) * (a / 2 + b / 2 - (a + b) / 2);
        }
        System.out.println(ans);
    }
}



Measured memory_bytes: 23892
/*

                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                    prayer
*/

// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
#define yes cout<<"Yes\n"
#define no cout<<"No\n"

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

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

	int n,k,q;
  cin>>n>>k>>q;
  vi in(n);
  rep(i,q){
    int a;cin>>a;
    in[a-1]++;
  }
  rep(i,n)if(k-q+in[i]>0)yes;
  else no;
}


Measured memory_bytes: 1408
using System;
class Program
{
	static void Main(string[] args)
	{
		string[] input1 = Console.ReadLine().Split(' ');
		int bound = int.Parse(input1[0]) + 1;
		int area = int.Parse(input1[1]);
      	string[] input2 = Console.ReadLine().Split(' ');
      	int dist = 0;
        int answer = 0;
      	for(int i = 0; i < input2.Length; i++){
          dist += int.Parse(input2[i]);
          if(dist <= area){
          	answer++;
          }else{
          }
        }
      	Console.WriteLine(answer+1);
	}
}

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

using namespace std;
using namespace __gnu_pbds;
#define ll 		 long long int
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 	 1000000007
#define MOD      998244353
#define mp       make_pair
#define pb       push_back
#define F        first
#define S        second
#define t()      ll test;cin>>test;while(test--)
#define ii       pair<int,int>
#define endl     "\n"
#define que_max  priority_queue <int>
#define IOS      ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

typedef tree < int ,  null_type ,  greater <int> ,  rb_tree_tag ,  tree_order_statistics_node_update > pbds;

int pw(int b, int p) { int r = 1; while (p > 0) { if (p & 1) r = r * b;
        p = p >> 1; b = b * b; } return r; }


const int INF = 1e9+5;
int main()
{
	ll n;
	cin>>n;
	vector <ll> v(n);
	for(auto &i : v)
		cin>>i;

	vector <ll> dp(n,INF);
	dp[0] = 0;
	
	for(int i=0;i<n;++i)
	{
		for(int j : {i+1 , i+2})
		{
			if(j<n)
			{
				dp[j] = min(dp[j] , dp[i]+abs(v[i]-v[j]));
			}
		}
	}
	cout<<dp[n-1]<<endl;
	return 0;

}

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

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner(System.in);
		int x = sc.nextInt(), y = sc.nextInt();
		if((y-2*x)%2 != 0 || 2*x > y || 4*x < y) {
			System.out.println("No");
		}else {
			System.out.println("Yes");
		}
	}

	static class FastScanner {
		private BufferedReader reader = null;
	    private StringTokenizer tokenizer = null;
	    public FastScanner(InputStream in) {
	        reader = new BufferedReader(new InputStreamReader(in));
	        tokenizer = null;
	    }

	    public String next() {
	        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                tokenizer = new StringTokenizer(reader.readLine());
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }
	        return tokenizer.nextToken();
	    }

	    public String nextLine() {
	        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                return reader.readLine();
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }

	        return tokenizer.nextToken("\n");
	    }

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

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

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

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


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

int main() {
    int a,b,c;
    cin >> a >> b >> c;
    set<int> st;
    st.insert(a);
    st.insert(b);
    st.insert(c);
    if(st.size() != 2) cout << "No" <<endl;
    else cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int k,x,i;
    int min= -1000000;
    int max= 1000000;
    scanf("%d %d",&k ,&x);
    if(x-k+1> -1000000){
        min = x-k+1;
    }
    if(x+k-1< 1000000){
        max = x+k-1;
    }
    for(i=min;i<=max;i++){
        printf("%d ",i);
    }
    printf("\n");
    return 0;
}

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

int main() {
	int N;
	cin>>N;
	vector<int> a(N);
	int memory=1;
	int count= 0;
	
	for(int i=0;i<N;i++){
		cin>>a.at(i);
	}
	for(int i=0;i<N;i++){
		if(a.at(i)==memory){
			memory+=1;
		}
		else{
			count+=1;
		}
	}
	if(memory==1){
		cout<<-1<<endl;
	}
	else{
	cout<<count<<endl;
	}
	return 0;
}

Measured memory_bytes: 1024
h, w, d = map(int, input().split())
d_x = [-1] * (h*w + 1)
d_y = [-1] * (h*w + 1)
for i in range(h):
    tmp = list(map(int, input().split()))
    for j in range(len(tmp)):
        d_x[tmp[j]] = i
        d_y[tmp[j]] = j

dist = [-1] * (h*w + 1) 
for i in range(h*w):
    j = h*w - i
    if h*w - j < d:
        dist[j] = 0
    else:
        dist[j] = dist[j+d] + abs(d_x[j+d] - d_x[j]) + abs(d_y[j+d] - d_y[j])
    
q =  int(input())
for _ in range(q):
    start, end = map(int, input().split())
    print(dist[start]- dist[end])

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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}

const int N = 1e5+23;

int a[N];

void solve() {
  string s; cin >> s;
  vector<int> l, r;
  for (int i = 0; i < (int)s.size(); ++i) {
    if (s[i] == 'R') r.push_back(i);
    else l.push_back(i);
  }
  for (int i = 0; i < (int)s.size(); ++i) {
    debug(s[i]);
    if (s[i] == 'R') {
      int j = lower_bound(l.begin(), l.end(), i)-l.begin();
      if ((l[j]-i)%2) {
	++a[l[j]-1];
      } else {
	++a[l[j]];
      }
    } else {
      int j = lower_bound(r.begin(), r.end(), i)-r.begin()-1;
      if ((i-r[j])%2) {
	++a[r[j]+1];
      } else {
	++a[r[j]];
      }
    }
  }
  for (int i = 0; i < (int)s.size(); ++i) cout << a[i] << ' ';
}

int main() {
  init();
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}


Measured memory_bytes: 4540
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <cstring>
#include <cctype>
#include <sstream>
#include <set>
#include <map>
#include <queue>
#include <complex>
using namespace std;
#define REP(i,n) for(int i = 0; i < (int)n; i++)
#define FOR(i,a,b) for(int i = a; i < (int)b; i++)
const int INF = 1<<28;

int main() {
	int bill;
	const int cur[4] = {10, 50, 100, 500};
	bool first = false;
	while(cin >> bill, bill) {
		if(first) cout << endl;
		int sum = 0, in[4];
		REP(i, 4) {
			cin >> in[i];
			sum += cur[i] * in[i];
		}
		sum -= bill;
		for(int i=3; i>=0; i--) {
			while(sum >= cur[i]) {
				sum -= cur[i];
				in[i]--;
			}
		}

		REP(i, 4) if(in[i] > 0) cout << cur[i] << ' ' << in[i] << endl;
		first = true;
	}
	return 0;
}

Measured memory_bytes: 1164
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define ll long long int

int main(){
  ll n,m;
  scanf("%lld%lld",&n,&m);
  ll h[100001];
  ll yoi[100001]={};
  for(ll i=1;i<=n;i++){
    scanf("%lld",&h[i]);}
  ll ans=n;
  int a,b;
  for(int i=0;i<m;i++){
    scanf("%d%d",&a,&b);
    if(h[a]>h[b]){
      yoi[b]=1; continue;}
    if(h[a]<h[b]){
      yoi[a]=1; continue;}
    yoi[a]=1;
    yoi[b]=1;}

  for(int i=1;i<=n;i++){
    if(yoi[i]==1) ans--;}

  printf("%lld\n",ans);
  
  return 0;
}


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

int N, A[105];

int main() {
    scanf("%d", &N);

    for(int i = 0; i < N; i++)
        scanf("%d", &A[i]);

    long long int ans = 1e18;
    for(int i = -100; i <= 100; i++) {
        long long int sum = 0;
        for(int j = 0; j < N; j++) {
            sum += (i - A[j]) * (i - A[j]);
        }
        ans = min(ans, sum);
    }

    printf("%lld", ans);
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
void dfs(int x,string a,string b,string c){
    if(x==a.length()){
        if(b==c){puts("YES");exit(0);}
        else return ;
    }
    if(a[x]=='A')dfs(x+1,a,b,c);
    dfs(x+1,a,b,c+a[x]);
}
int main(){
    string s,t="AKIHABARA";
    cin>>s;
    dfs(0,t,s,"");
    puts("NO");
}

Measured memory_bytes: 256
n, a, b = map(int, input().split())
if a > b: a, b = b, a
if (a + b) % 2 == 0:
    print(((a + b) // 2) - a)
else:
    t = min(a - 1, n - b)
    if a - 1 <= n - b:
        t -= -1
        b -= t
        t += (((1 + b) // 2) - 1)
        print(t)
    else:
        t -= -1
        a += t
        t += (((a + n) // 2) - a)
        print(t)

Measured memory_bytes: 38384
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		List<String> al = new ArrayList<>();
		
		while(sc.hasNext()) {
			al.add(returnClass(sc.nextDouble()));
		}
		
		for(String i : al) {
			System.out.println(i);
		}
	}
	
	static String returnClass(double className) {
		if(className <= 48)			return "light fly";
		else if(className <= 51)	return "fly";
		else if(className <= 54)	return "bantam";
		else if(className <= 57)	return "feather";
		else if(className <= 60)	return "light";
		else if(className <= 64)	return "light welter";
		else if(className <= 69)	return "welter";
		else if(className <= 75)	return "light middle";
		else if(className <= 81)	return "middle";
		else if(className <= 91)	return "light heavy";
		else						return "heavy";
	}
}

Measured memory_bytes: 27728
def abc(n,p):
    ans=1
    b = 2
    if n==1:
        return p
    e=0
    while p%b == 0:
        p = p//b
        e +=1
    e=int(e//n)
    if e:
        ans*=(b**e)
    b+=1
    while b**2<=p:
        e=0
        while p%b == 0:
            p = p//b
            e +=1
        e=int(e//n)
        if e:
            ans*=(b**e)
        b+=2
    return ans

n,p=map(int,input().split())
print(abc(n,p))


Measured memory_bytes: 3064
using System;

namespace ALDS1_5_C_KochCurve
{
	class Program
	{
		static void Main ( string[] args )
		{
			Vector startPoint = new Vector (0, 0);
			Vector endPoint = new Vector (100, 0);

			int recursiveCount = int.Parse (Console.ReadLine ());

			Console.WriteLine (startPoint);
			KochCurve (recursiveCount, startPoint, endPoint);
			Console.WriteLine (endPoint);
		}

		static double cos = Math.Cos (60 * Math.PI / 180);
		static double sin = Math.Sin (60 * Math.PI / 180);

		static void KochCurve ( int restCount, Vector startPoint, Vector endPoint )
		{
			if (0 < restCount)
			{
				Vector s = new Vector ();
				Vector t = new Vector ();
				Vector u = new Vector ();

				s.X = (2 * startPoint.X + 1 * endPoint.X) / 3;
				s.Y = (2 * startPoint.Y + 1 * endPoint.Y) / 3;

				t.X = (1 * startPoint.X + 2 * endPoint.X) / 3;
				t.Y = (1 * startPoint.Y + 2 * endPoint.Y) / 3;

				u.X = ((t.X - s.X) * cos - (t.Y - s.Y) * sin) + s.X;
				u.Y = ((t.X - s.X) * sin + (t.Y - s.Y) * cos) + s.Y;

				KochCurve (restCount - 1, startPoint, s);
				Console.WriteLine (s);

				KochCurve (restCount - 1, s, u);
				Console.WriteLine (u);

				KochCurve (restCount - 1, u, t);
				Console.WriteLine (t);

				KochCurve (restCount - 1, t, endPoint);
			}
		}
	}

	class Vector
	{
		public Vector () { }
		public Vector ( double x, double y )
		{
			this.X = x;
			this.Y = y;
		}

		public double X { set; get; }
		public double Y { set; get; }
		public override string ToString ()
		{
			return X + " " + Y;
		}
	}
}

Measured memory_bytes: 9388
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
const int mod =1e+9+7;

const int dy[4]={0,1,0,-1};
const int dx[4]={1,0,-1,0};
const ll INF=1e10;

int main(){
    ll n; cin>>n;
    ll ans=0;
    for(int i=1;i<=n;i++){
        ans+=(n/i)*(i+i*(n/i))/2;
    }
    cout<<ans<<endl;
}














































































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

int main() {
 string S;
 cin >> S;

int sum = 0;
 if(S.at(0) == 'o'){
   sum += 100;
 }
 else{
   sum += 0;
 }

 if(S.at(1) == 'o'){
   sum += 100;
 }
 else{
   sum += 0;
 }

 if(S.at(2) == 'o'){
sum += 100;
 }
 else{
 sum += 0;
 }

 cout << 700 + sum << endl;
}

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

int main()
{
    int n;
    cin >> n;
    ll a[3*n];
    for(int i=0;i<3*n;i++){
        cin >> a[i];
    }
    priority_queue<ll> backa;
    priority_queue<ll, vector<ll>, greater<int> > fronta;
    ll left[n+1],right[n+1];
    left[0]=right[n]=0;
    //initializing front and back queues
    for(int i=0;i<n;i++){
        fronta.push(a[i]);
        backa.push(a[3*n-i-1]);
        left[0]+=a[i];
        right[n]+=a[3*n-i-1];
    }
    //filling left
    for(int i=1;i<=n;i++){
        left[i]=left[i-1]+a[n+i-1];
        fronta.push(a[n+i-1]);
        ll k=fronta.top();
        fronta.pop();
        left[i]-=k;
    }
    //filing right
    for(int i=n-1;i>=0;i--){
        right[i]=right[i+1]+a[n+i];
        backa.push(a[n+i]);
        ll k=backa.top();
        backa.pop();
        right[i]-=k;
    }
    ll ans=LONG_LONG_MIN;
    for(int i=0;i<=n;i++){
        ans=max(ans,left[i]-right[i]);
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 5868
#include <bits/stdc++.h>
using namespace std; 
using ll = long long;
#include <math.h>
double log10(double x);
int main() {
  int n;
  cin >> n;
  int64_t a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] == 0) {
      cout << 0 << endl;
      return 0;
    }
  }
  int64_t ans = 1LL;
 /* for (int i = 0; i < n; i++) {
    if (a[i] == 0) {
      cout << 0 << endl;
      return 0;
    }
  }*/
  for (int i = 0; i < n; i++) {
    if (log10(a[i]) + log10(ans) > 18) {
    //if (a[i] > 1000000000000000000LL / ans) {
      cout << -1 << endl;
      return 0;
    }
    ans *= a[i];
  }
  
  if (ans > 1000000000000000000LL /*|| ans < 0LL*/) {
    cout << -1 << endl;
  }
  else {
    cout << ans << endl;
  } 
  
} 
  



Measured memory_bytes: 4752
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

alias Point = Tuple!(int, "x", int, "lr", int, "idx");

void main() {
    int n, m;
    scan(n, m);

    bool[] ok = new bool[](m + 1);
    Point[] a;

    foreach (i ; 0 .. m) {
        int ai, bi;
        scan(ai, bi);
        a ~= Point(ai, 1, i);
        a ~= Point(bi, 0, i);
    }

    a.sort();

    debug {
        writeln(a);
    }

    int[] f;
    int ans;

    foreach (i ; 0 .. 2*m) {
        debug {
            writeln(f);
        }
        if (a[i].lr == 1) {
            f ~= a[i].idx;
        }
        else {
            if (!ok[a[i].idx]) {
                ans++;

                foreach (fi ; f) {
                    ok[fi] = true;
                }

                f = null;
            }
            
        }
    }

    writeln(ans);
}









































void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}


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

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

typedef long long ll;
typedef long double ld;

using namespace std;

int n, tr, tb, tg;
string s;
ll ans, cr, cg, cb;

int main()
{
	cin >> n >> s;
	for (auto &w : s)
	{
		if (w == 'R')
			tr++;
		else if (w == 'G')
			tg++;
		else
			tb++;
	}
	for (auto &w : s)
	{
		if (w == 'R')
		{
			cr++;
			ans += cb * (tg - cg) + cg * (tb - cb);
		}
		else if (w == 'G')
		{
			cg++;
			ans += cr * (tb - cb) + cb * (tr - cr);
		}
		else
		{
			cb++;
			ans += cg * (tr - cr) + cr * (tg - cg);
		}
	}
	for (int i = 0; i < n; i++)
	{
		for (int j = 1; j <= min(i, n - 1 - i); j++)
		{
			if (s[i - j] != s[i] && s[i] != s[i + j] && s[i - j] != s[i + j])
				ans--;
		}
	}
	cout << ans;
	return 0;
}


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

int main() {
  int N, sum;
  cin >> N;
  
  for (int i = 0; i < N; i++) {
    int l, r;
    cin >> l >> r;
    
    sum += r - l + 1;
  }
  
  cout << sum << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using LL = long long int;
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define dec(i, n)  decID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define FI first
#define SE second
#define FR front()
#define BA back()
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
auto setmin   = [](auto & a, auto b) { return (b <  a ? a = b, true : false); };
auto setmax   = [](auto & a, auto b) { return (b >  a ? a = b, true : false); };
auto setmineq = [](auto & a, auto b) { return (b <= a ? a = b, true : false); };
auto setmaxeq = [](auto & a, auto b) { return (b >= a ? a = b, true : false); };
#define SI(v) static_cast<int>(v.size())
#define RF(e, v) for(auto & e: v)
#define until(e) while(! (e))
#define if_not(e) if(! (e))
#define ef else if
#define UR assert(false)
#define IN(T, ...) T __VA_ARGS__; IN_(__VA_ARGS__);
void IN_() { };
template<typename T, typename ... U> void IN_(T &  a, U &  ... b) { cin >> a; IN_(b ...); };
template<typename T                > void OUT(T && a            ) { cout << a << endl; }
template<typename T, typename ... U> void OUT(T && a, U && ... b) { cout << a << " "; OUT(b ...); }

// ---- ----

template<typename T> T MV(T v) { return v; }
template<typename T, typename ... U> auto MV(T v, int a, U ... b) { return vector<decltype(MV(v, b ...))>(a, MV(v, b ...)); }

#define bit(b, i) (((b) >> (i)) & 1)
#define PC __builtin_popcountll
#define BL(a) (a ? 64 - __builtin_clzll(a) : 0)

int main() {
	IN(int, n, m, x);
	auto a = MV(0, n, m);
	vector<int> c(n);
	inc(i, n) {
		cin >> c[i];
		inc(j, m) { cin >> a[i][j]; }
	}
	
	int INF = 1e9, ans = INF;
	inc(b, 1 << n) {
		int s = 0;
		vector<int> t(m);
		inc(i, n) {
			if(bit(b, i) == 1) {
				s += c[i];
				inc(j, m) { t[j] += a[i][j]; }
			}
		}
		bool f = true;
		inc(j, m) { f &= (t[j] >= x); }
		if(f) { setmin(ans, s); }
	}
	if(ans == INF) { ans = -1; }
	OUT(ans);
}


Measured memory_bytes: 3636
#include<iostream>
using namespace std;
int main(){
  int a,b;
  cin >> a >> b;
  if (a == 1) {
    a += 13;
  }
  if (b == 1) {
    b += 13;
  }
  if (a > b) {
    cout << "Alice" << endl;
  } else if (a < b) {
    cout << "Bob" << endl;
  } else {
    cout << "Draw" << endl;
  }
}

Measured memory_bytes: 256
N = int(input())
a = list(map(int, input().split()))

val1 = a[0]
val2 = a[0] ^ a[0]

for i in range(1, N):
    val1 = val1 ^ a[i]
    val2 = val2 ^ a[i] ^ a[i]

if( val1 == val2):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 14212
// 問題の URL を書いておく
// 

#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>

using namespace std;

//#define ENABLE_PRINT

#if defined(ENABLE_PRINT)

#define Print(v) \
do {\
    cout << #v << ": " << v << endl; \
}while(0)

#define PrintVec(v) \
do {\
    for(int __i = 0; __i < v.size(); ++__i) \
    { \
        cout << #v << "[" << __i << "]: " << v[__i] << endl; \
    }\
}while(0)

#else

#define Print(v) ((void)0)
#define PrintVec(v) ((void)0)

#endif

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

using ll = int64_t;

const int VMax = 1005 * 105;
ll dp[105][VMax];

const ll INF = 10000000000;

int main(int, const char**)
{
    ll N, W;
    cin >> N >> W;
    rep(i, VMax)
    {
        dp[0][i] = INF;
    }
    dp[0][0] = 0;
    rep(i, N)
    {
        int w, v;
        cin >> w >> v;
        rep(j, VMax)
        {
            if(j - v < 0 || dp[i][j - v] + w > W)
            {
                dp[i + 1][j] = dp[i][j];
            }
            else
            {
                dp[i + 1][j] = min(dp[i][j], dp[i][j - v] + w);
            }
        }
    }
    rep(i, VMax)
    {
        auto ti = VMax - 1 - i;
        if(dp[N][ti] != INF)
        {
            cout << ti << endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 86864
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#include<random>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define rrep(i,a) for(int i=(int)a-1;i>=0;--i)
#define REP(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RREP(i,a,b) for(int i=(int)a-1;i>=b;--i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
typedef std::vector<int> vi;
typedef std::vector<std::vector<int>> vvi;
typedef std::vector<long long> vl;
typedef std::vector<std::vector<long long>> vvl;
#define out(x) cout<<x<<"\n";
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

ll gcd(ll n, ll m) {
    ll tmp;
    while (m!=0) {
        tmp = n % m;
        n = m;
        m = tmp;
    }
    return n;
}

ll lcm(ll n, ll m) {
    return abs(n) / gcd(n, m)*abs(m);//gl=xy
}
 
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;
}
 
using namespace std;

void solve(){
  ll k,n;
  cin>>k>>n;
  vector<ll>a(n);
  rep(i,n)cin>>a[i];
  ll ans=INF;
  chmin(ans,a[n-1]-a[0]);
  rep(i,n){
    chmin(ans,k-a[i]+a[(n-1+i)%n]);
    chmin(ans,a[i]+k-a[(i+1)%n]);
  }
  cout<<ans;
}

int main(){
    ios::sync_with_stdio(false);
  cin.tie(0);
    cout<<fixed<<setprecision(15);
  solve();
    return 0;
}


Measured memory_bytes: 1792
#define _GLIBCXX_DEBUG
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <map>
#include <list>
using namespace std;
typedef long long ll;
#define ALL(v) (v).begin(), (v).end()
#define mp make_pair
const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = 1e9+7;

ll C[51][51];

void comb_table(int N) {
	for (int i = 0; i <= N; i++) {
		for (int j = 0; j <= i; j++) {
			if (j == 0 || j == i) {
				C[i][j] = 1LL;
			} else {
				C[i][j] = C[i-1][j-1] + C[i-1][j];
			}
		}
	}
}

int main() {
	int N, A, B;
	cin >> N >> A >> B;

	ll v[50];
	for (int i = 0; i < N; i++) cin >> v[i];

	comb_table(N);
	sort(v, v+N);
	reverse(v, v+N);

	double max_av = 0.0;
	for (int i = 0; i < A; i++) max_av += v[i];
	max_av /= A;

	int a_th_num_in_all = 0, a_th_num_until_a = 0;
	for (int i = 0; i < N; i++) {
		if (v[i] == v[A-1]) {
			a_th_num_in_all++;
			if (i < A) {
				a_th_num_until_a++;
			}
		}
	}

	ll cnt = 0LL;
	if (a_th_num_until_a == A) {
		for (a_th_num_until_a = A; a_th_num_until_a <= B; a_th_num_until_a++) 
			cnt += C[a_th_num_in_all][a_th_num_until_a];
	} else {
		cnt += C[a_th_num_in_all][a_th_num_until_a];
	}

	cout.precision(20);
	cout << fixed << max_av << endl;
	cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
int main() {
    int n,l;
    cin>>n>>l;
    int goodness = 0;
    for (int i = 1; i <= n; ++i) {
        goodness += l+i-1;
    }
    int ans = 100000000;
    int ans_good = 1000000;
    for (int j = 1; j <= n; ++j) {
        int goodness_bit = goodness - (l+j-1);
        if(abs(goodness-goodness_bit) <= ans){
            ans = abs(goodness-goodness_bit);
            ans_good = goodness_bit;
        }
    }

    cout<<ans_good<<endl;
}


Measured memory_bytes: 256
import qualified Data.ByteString.Char8 as B
import qualified Data.Array.IArray as A
import Data.Maybe
import Data.Bool

main = do
  [n,_] <- map read . words <$> getLine
  es <- readUndirectedEdge <$> B.getContents
  let g = buildG n es
  putStrLn $ bool "IMPOSSIBLE" "POSSIBLE" (voyage n g)

voyage n g = any (elem n . from g) (from g 1)

type Vertex = Int
type Edge = (Vertex, Vertex)
type Graph = A.Array Vertex [Vertex]

buildG :: Int -> [Edge] -> Graph
buildG n = A.accumArray (flip (:)) [] (1, n)

from :: Graph -> Vertex -> [Vertex]
from g = (g A.!)

readUndirectedEdge :: B.ByteString -> [Edge]
readUndirectedEdge = concatMap (constructTwoWay . map readInt . B.words) . B.lines

constructTwoWay :: [Int] -> [Edge]
constructTwoWay [s,t] = [(s, t), (t, s)]
constructTwoWay _ = undefined

readInt :: B.ByteString -> Int
readInt = fst . fromJust . B.readInt


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

int main(){
	int n, k, s;
	while(scanf("%d%d%d", &n, &k, &s), n){
		vector<vector<int> > dp(k + 1, vector<int>(s + 1));
		dp[0][0] = 1;
		for(int i = 1; i <= n; ++i)
		for(int j = k; j > 0; --j)
		for(int t = s; t >= i; --t){
			dp[j][t] += dp[j - 1][t - i];
		}
		printf("%d\n", dp[k][s]);
	}
}

Measured memory_bytes: 1052