akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
#define rep(i,n) for(int i = 0;i < n;i++)
#define req(i,n) for(int i = 1;i <=n;i++)
#define rrep(i,n) for(int i = n -1;i >= 0;i--)
typedef long long ll;
typedef long double ld;
vector<int> v;
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}
int main() {
    ll n, m,a; cin >> n >> m;
    rep(i, n) {
        cin >> a; a /= 2;
        v.push_back(a);
    }
    while (v[0] % 2 == 0) {
        for (int i = 0; i < n; ++i) {
            if (v[i] % 2 != 0) {
                cout << 0 << endl;
                return 0;
            }
            v[i] /= 2;
        }
        m /= 2;
    }
    rep(i, n) if (v[i] % 2 == 0) {
        cout << 0 << endl;
        return 0;
    }
    ll lcm = 1;
    rep(i, n) {
        lcm = lcm / gcd(lcm, v[i]) * v[i];
        if (lcm > m) {
            cout << 0 << endl;
            return 0;
        }
    }
    cout << (m / lcm + 1) / 2 << endl;
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
#define ll long long
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define M 1000000007
using namespace std;
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,i,ans = 0,tans,r,j,k;
    cin>>n;
    pair <ll,ll> a[n];
    for(i=0;i<n;i++)
        cin>>a[i].ff>>a[i].ss;
    multiset <ll> x,y;
    multiset <pair<ll,ll>> z;
    for(i=0;i<n;i++)
    {
        x.insert(a[i].ff);
        y.insert(a[i].ss);
    }
    sort(a,a+n);
    for(i=0;i<n;i++)
    {
        x.erase(x.find(a[i].ff));
        y.erase(y.find(a[i].ss));
        z.insert(mp(a[i].ss, a[i].ff));
        if(x.size())
        {
            r = *x.rbegin();
            j = *y.begin();
        }
        else
            r = 0, j = -1;
        k = z.begin()->ff;
        tans = max(k-a[i].ff+1,0ll)+max(j-r+1,0ll);
        //cout<<tans<<" ";
        if(r != 0)
            tans = max(tans, a[i].ss-a[i].ff +1+ max(min(j,k)-r+1, 0ll));
        //cout<<tans<<"\n";
        ans = max(ans,tans);
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 11264
#include <bits/stdc++.h>
using namespace std;
#define int  long long int
#define mod 1000000000000007
#define pb push_back
#define mp make_pair
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define gcd __gcd
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define all(i) i.begin(),i.end()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define set_bit __builtin_popcount //gives number of set_bits
#define ff first
#define ss second
#define cases(t) int t;cin>>t; rep(casn,1,t+1)
#define el cout<<"\n";
#define deci(n) int n; scanf("%lld",&n);
#define decs(n) string n; cin>>n;
#define sz(v) v.size()
#define repit(m) for(auto it=m.begin();it!=m.end();it++)
// #define find(m,i) (m.find(i)!=m.end())
// #define find(m,i) (m.find(i)==m.end())
#define cYES cout<<"YES\n";
#define cNO cout<<"NO\n";
#define ins insert
#define imax 1000000000000000000
#define imin -1000000000000000000
// #define NP 50000
//  cerr << "\nTime : " << (double)clock() / (double)CLOCKS_PER_SEC << "s\n";
 
//  IIITA
//SUNEET KUMAR -->  ਸੁਨੀਤ
 
// scanning numbers extremely fast/////////
void fs(int &number)
{
    bool negative = false;
    register int c;
    number = 0;
    c = getchar();
    if (c=='-')
    {
        negative = true;
        c = getchar();
    }
    for (; (c>47 && c<58); c=getchar())
        number = number *10 + c - 48;
    if (negative)
        number *= -1;
}
// ========================================
int power(int a,int x)
{
        a%=mod;
    int res=1;
    while(x>0)
    {
        if(x&1)
        res=res*a%mod;
        a=a*a%mod;
        x>>=1;
    }
    return res;
}
int max(int a,int b)
{
    if(a>b)
    {
        return a;
    }
    else
    {
        return b;
    }
}
int min(int a,int b)
{
    if(a>b)
    {
        return b;
    }
    else
    {
        return a;
    }
}
int madd(int a,int b)
{
    int ans;
    ans=(a%mod+b%mod)%mod;
    return ans;
}
int mmult(int a,int b)
{
    int ans=1;
    ans=((a%mod)*(b%mod))%mod;
    return ans%mod;
}
int modinverse(int a)
{
    return power(a,mod-2);
}
 
void nhi_degi()
{
    int h1,s1,h2,s2;cin>>h1>>s1>>h2>>s2;
    int count=0,flag=0;
    while(1)
    {
        if(flag%2==0)
        {   
            h2-=s1;
        }
        else
        {
            h1-=s2;
        }
        if(h1<=0)
        {
            count=1;
            break;
        }
        if(h2<=0)
        {
            count=2;
            break;
        }
        flag++;
    }
    if(count==1)
    {
        cout<<"No\n";
    }
    else
    {
        cout<<"Yes\n";
        // cYES;
    }

}
signed main()
{
    // cases(t)
    // {
        nhi_degi();
    // }
}

Measured memory_bytes: 3676
#include <algorithm>
#include<stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include<stack>
#include <queue>
#include<map>
#include <set>
#include<math.h>
using namespace std;
#define int long long
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define Rep(i,n) for(ll i=1;i<=n;++i)
#define loop(i,m,n) for(ll i=m;i<n;++i)
#define ggr getchar(); getchar();return 0;
#define pie 3.141592653589793238462643383279
#define elif else if
#define P pair<ll,ll>
#define prique priority_queue<ll>
const int mod = 1000000007;
const int mod2 = 998244353;
int bin(int bina) {
	int ans = 0;
	for (int i = 0; bina > 0; i++)
	{
		ans = ans + (bina % 2) * pow(10, i);
		bina = bina / 2;
	}
	return ans;
}
bool prime(int n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % mod;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod;
		}
		x = x * x % mod;
		y >>= 1;
	}
	return res;
}
long nCr(int n, int r) {
	int ans = 1;
	for (ll i = n; i > n - r; --i) {
		ans = ans * i;
	}
	for (ll i = 1; i < r + 1; ++i) {
		ans = ans / i;
	}
	return ans;
}
struct union_find {
	int par[200010], size_[200010];
	void init(int x) {
		rep(i, x) { par[i] = i; size_[i] = 1; }
	}
	int find(int x) {
		if (par[x] == x)return x;
		return par[x] = find(par[x]);
	}
	void unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y)return;
		if (size_[x] < size_[y]) {
			par[x] = y;
			size_[y] += size_[x];
		}
		else {
			par[y] = x;
			size_[x] += size_[y];
		}
	}
};
int n,s,a[100010],ans=0;
signed main() {
	cin>>n>>s;
	cin>>a[0]>>a[1];
	if(a[0]+a[1]>s){
		if(a[0]>s){
			ans+=a[1];
			a[1]=0;
			ans+=a[0]-s;
		}
		else{
			ans+=(a[0]+a[1])-s;
			a[1]-=ans;
		}
	}
	loop(i,2,n){
		cin>>a[i];
	}
	loop(i,2,n){
		if(a[i-1]+a[i]>s){
			ans+=a[i-1]+a[i]-s;
			a[i]-=a[i-1]+a[i]-s;
		}
	}
	cout<<ans<<endl;
}



Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a,b;
  cin>>a>>b;
  if(a>b)
  {
    for(int i = 0 ; i < a ; i++)
    {
      cout<<b;
    }
  }
  else
  {
    for(int i = 0 ; i < b ; i++)
    {
      cout<<a;
    }
  }
  return 0;
}

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

int mini[100005],maxi[100005];

int main(){
	int n,k;
	scanf("%d%d",&n,&k);
	int x;
	int bata,smini=0,smaxi=0;
	for(int i=0;i<n;i++){
		scanf("%d",&x);
		if(x<0) {
			smini++;
			mini[smini] = -x;
		}
		else{
			smaxi++;
			maxi[smaxi] = x;
		}
	}
	sort(mini+1,mini+1+smini);
	int cost = 1000000000;
	for(int i = 0 ; i <= smini; i++){
		if(i>k) break;
		if(i==0){
			if(k > smaxi) continue;
			cost = maxi[k];
		}
		else if(i==k){
			cost = min(cost,mini[k]);
		}
		else{
			if(k-i > smaxi ) continue;
			cost = min(cost,2*mini[i]+maxi[k-i]);
			cost = min(cost,mini[i]+maxi[k-i]*2);
		}
	}
	printf("%d\n",cost);
	return 0;
}

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

int main()
{
  int a,b,c,d,e,f;
 cin >>a;
  cin >>b;
  cin >>c;
  cin >>d;
  e=(a+b);
  f=(c+d);
  
  if (e>f)
  {
    cout << "Left"<< endl;
  }
  if (f>e)
  {
    cout << "Right"<< endl;
  }
  if (e==f)
  {
    cout << "Balanced"<< endl;
  }
  return 0;
}

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

using namespace std;

const int N = 2e5 + 100;

char t[N], d[N];
string s;
int n, q, ans;

bool check1(int m) {
	for (int i = 0; i < q; i++) {
		if (s[m] == t[i]) {
			if (d[i] == 'R')
				m++;
			else
				m--;
			if (m == n)
				return true;
		}
	}
	return false;
}

bool check2(int m) {
	for (int i = 0; i < q; i++) {
		if (s[m] == t[i]) {
			if (d[i] == 'R')
				m++;
			else
				m--;
			if (m < 0)
				return true;
		}
	}
	return false;
}

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n >> q >> s;
	for (int i = 0; i < q; i++)
		cin >> t[i] >> d[i];
	int s = -1, e = n;
	while (e - s > 1) {
		int m = (s + e) / 2;
		if (check1(m))
			e = m;
		else
			s = m;
	}
	ans = e - 1;
	s = 0, e = n + 1;
	while (e - s > 1) {
		int m = (s + e) / 2;
		if (check2(m))
			s = m;
		else
			e = m;	
	}
	ans -= s;
	return cout << (ans >= 0 ? ans : 0), 0;
}

Measured memory_bytes: 976
#include<stdio.h>
#include<stdbool.h>

int main()
{
  int h,w;
  
  scanf("%d%d",&h,&w);
  
  char s[h][w];
  int i,j;
  bool b=true;
 
  for(i=0;i<h;i++)
  {
    scanf("%s",&s[i]);
  }    

  for(i=0;i<h;i++)
  {
    for(j=0;j<w;j++)
    {
      if(s[i][j]=='#')
      {
        if(i!=0||i!=h-1||j!=0||j!=w-1)
        {
          if(s[i][j+1]!='#'&&s[i][j-1]!='#'&&s[i-1][j]!='#'&&s[i+1][j]!='#')
          {
            b=false;
          }
        }
        else
        {
          if(s[i][j+1]!='#'&&s[i+1][j]!='#')
          {
            b=false;
          }
        }
      }
    }
  }
        
  if(b==true)
  {
    printf("Yes\n");
  }
  else
  {
    printf("No\n");
  }
  
  return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<cmath>
#include<queue>
#include<stack>
#include<list>

#define endl "\n"
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define REP(i, n) for(int i = 0; i < n; i++)
using Graph = vector<vector<int>>;

int main(){
    double a,b,h,m;
    cin>>a>>b>>h>>m;
    double htheta,mtheta;
    htheta = 360 / 12 * (h+m/60);
    mtheta = 360 / 60 * m;
    double dtheta = abs(htheta - mtheta);
    if(abs(htheta - mtheta) > 180){
        dtheta = 360 - dtheta;
    }
    dtheta *= M_PI / 180;

    double ans = 0;
    if(dtheta <= 90){
        double sq = a*a*sin(dtheta)*sin(dtheta) + (b-a*cos(dtheta))*(b-a*cos(dtheta));
        ans = sqrt(sq);
    }
    else{
        double sq = a*a*sin(dtheta)*sin(dtheta) + (-a*cos(dtheta)+b)*(-a*cos(dtheta)+b);
        ans = sqrt(sq);
    }

    printf("%.25f\n", ans);
}

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

int N;
map<long long, long long> cacheResult;

// 計算
long long f(int x, int y, int z) {
    return (pow(x, 2) + pow(y, 2) + pow(z, 2)) + (x * y + y * z + z * x);
}

// 無理やりだけど
void calcLoop(int end) {
    long long result;
    // -- 1つendパターン --
    // iが固定(これを3回繰り返すから3つプラスする)
    for (int j = 1; j < end; j++) {
        for (int k = 1; k < end; k++) {
            result = f(end, j, k);
            if (result > N) break;
            cacheResult[result] += 3;
        }
    }

    // -- 2つendパターン --
    // i,jが固定(これを3回繰り返すから3つプラスする)
    for (int k = 1; k < end; k++) {
        result = f(end, end, k);
        if (result > N) break;
        cacheResult[result] += 3;
    }

    // -- 3つendパターン --
    result = f(end, end, end);
    cacheResult[result]++;
}

int main() {
    cin >> N;

    for (int i = 1; i <= N; i++) {
        calcLoop(i);
        cout << cacheResult[i] << endl;
    }
}



Measured memory_bytes: 4608
#include<bits/stdc++.h>
char s[50],a[9]={1,6,8,6,8,8},i,j,p,n,q;
main(){for(;scanf("%d\n",&n),n;printf("%d\n",i)){
for(i=0;i<n;s[i++]=strlen(gets(s+i)));
for(i=j=0;j<7;)for(p=i++,j=q=1;q>0;)for(q=a[j++];q>1;q-=s[p++]);
}}

Measured memory_bytes: 1200
#include <iostream>

int main(void){
  int x, tmp, f = 0, i;
  std::cin >> x;
  tmp = x;
  while(tmp != 0){
    f += tmp % 10;
    tmp /= 10;
  }
  if((x %= f) == 0) std::cout << "Yes" << std::endl;
  else std::cout << "No" << std::endl;
  return 0;
}

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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;

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

	cout << (n+1)/2 << endl;
	return (0);
}


Measured memory_bytes: 3484
#include <bits/stdc++.h>
using namespace std;
 
/*#ifndef ONLINE_JUDGE
    #include <lol.h>
#endif*/
#define mp make_pair
#define pb push_back
#define pf push_front
#define sz(a) (int)((a).size())
#define fr(i,n) for(long long int i=0;i<n;i++)
#define fr1(i,n) for(ll i=1;i<=n;i++)
#define frk(i,k,n) for(ll i=k;i<n;i++)
#define rfr(i,n) for(ll i=n-1;i>=0;i--)
#define foa(i,a,n) for(ll i=0;i<n;i+=a)
#define f first
#define s second
//#define mod 1000000007
#define all(x) (x).begin(),(x).end()
#define endl "\n"
//#define inf LLONG_MAX
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define vsort(x) sort(all(x))
#define debug cout<<"Hey Sweetie, Stop Right Here......"<<endl;
 
typedef long long int ll;
typedef stack<ll> stll;
typedef queue<ll> qll;
typedef priority_queue<ll> pqll;
typedef set<ll> sll;
typedef multiset<ll> msll;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
typedef vector<ll> vll;
typedef vector<pair<ll,ll>> vpll;
typedef map<ll,ll> mll;
typedef unordered_map<ll,ll> umll;
typedef long double ld;


const ll mod = 1e9+7;
const ll inf = 1e9;
ll modmulti(ll a, ll b, ll m){
   return ((a%m)*(b%m))%m;
}
ll gcd(ll a, ll b){
   if(b==0)
      return a;
   return gcd(b,a%b);
}
 
ll power(ll x, ll y, ll m) 
{ 
    if (y == 0) 
        return 1; 
    ll p = power(x, y/2, m) % m; 
    p = (p * p) % m; 
  
    return (y%2 == 0)? p : (x * p) % m; 
} 
ll dp[3][100005];

int main(){
    fastio;
    ll n,wt;
    cin>>n>>wt;
    ll dp[n+1][wt+1];
    vll w(n+1),p(n+1);
    w[0] = 0; p[0] = 0;
    fr1(i,n) cin>>w[i]>>p[i];
    fr(i,n+1){
      fr(j,wt+1) dp[i][j] = 0;
    }
    fr(i,n+1){
      fr(j,wt+1){
        if(i==0) dp[i][j] = 0;
        else if(j-w[i]<0) dp[i][j] = dp[i-1][j];
        else dp[i][j] = max(dp[i-1][j],dp[i-1][j-w[i]]+p[i]);
      }
    }
    cout<<dp[n][wt]<<endl;
    return 0;
}

Measured memory_bytes: 79232
N, = map(int, input().split())
X = list(map(int, input().split()))
Y = list(map(int, input().split()))[::-1]
on = []
z = 0
for i in range(N):
    if not X[i]-Y[i]:
        on.append(i)
        z = X[i]
for i in range(N):
    if X[i]!=z and Y[i] != z and on:
        j = on.pop()
        Y[i], Y[j] = Y[j], Y[i]
if on:
    print("No")
else:
    print("Yes")
    print(*Y)



Measured memory_bytes: 104948
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc =new Scanner(System.in);
        int z = sc.nextInt();
        int[] r = new int[z];
        for(int i = 0; i < z; i++){
            r[i] = sc.nextInt();
        }
        int min = r[0];
        int max = r[1] - min;
        for(int i = 1; i < r.length; i++){
            max = max > r[i] - min ? max : r[i] - min;
            min = min > r[i] ? r[i] : min;
        }
        System.out.println(max);
    }
}

Measured memory_bytes: 101324
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
//#include<unordered_map>//イテレータあるけど順序保持しないmap
//#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
#include<valarray>//なんとなく追加
//メモ：表示桁数を大きくする　　cout << fixed << setprecision(20) << cm << endl;
using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define PI acos(-1.0)
#define answer(ans) cout<<ans<<endl;


signed main() {
ll X,P=100;
int count=0;
cin >> X ;
while(X > P){
  P = P * 1.01 ;
    count++;
}
cout << count <<endl;
}

Measured memory_bytes: 3620
#include<iostream>
using namespace std;
int main(){
  int a[100],n,v,j;
  cin>>n;
  for(int i=0;i<n;i++)cin>>a[i];
  
  for(int i=0;i<n-1;i++)cout<<a[i]<<' ';
  cout<<a[n-1]<<endl;
  
  for(int i=1;i<n;i++){
    v=a[i];
    j=i-1;
    while(j>=0 && a[j]>v){
      a[j+1]=a[j];
      j--;
    }
    a[j+1]=v;
    for(int i=0;i<n-1;i++)cout<<a[i]<<' ';
    cout<<a[n-1]<<endl;
  }
  return 0;
}



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

int main(){
	int n,x,t;
	cin>>n>>x>>t;
	int time = t;
	//while(n>x && x != 1){
		//n =  n%x;
		//time += t;
	//}
	n = (n+x-1)/x;
	cout<<(n*t);
	return 0; 
}

Measured memory_bytes: 3588
N = int(input())
str_list = []
str_list = [str(input()) for i in range(N)]

print('AC x ' + str(str_list.count(('AC'))))
print('WA x ' + str(str_list.count(('WA'))))
print('TLE x ' + str(str_list.count(('TLE'))))
print('RE x ' + str(str_list.count(('RE'))))


Measured memory_bytes: 16156
#include <stdio.h>

int main(void) {
    char s[101];
    int k,i;
    scanf("%s %d",s,&k);
    for (i = 0;i < 102;i++) {
        if (s[i] != '1') {
            printf("%c\n",s[i]);
            break;
        } else if (i == k - 1) {
            printf("1\n");
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 128
from collections import Counter
import copy


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

if N >= 24:
    print (0)
    exit()

lst_time = [0]
lst_candidate = []

C = Counter(D)
for i in range(13):
    if i == 0:
        if C[0] > 0:
            print (0)
            exit()
    elif i == 12:
        if C[12] >= 2:
            print (0)
            exit()
        if C[12] == 1:
            lst_time.append(12)
    else:
        if C[i] >= 3:
            print (0)
            exit()
        elif C[i] == 2:
            lst_time.append(i)
            lst_time.append(24 - i)
        elif C[i] == 1:
            lst_candidate.append(i)

# print (lst_time)
# print (lst_candidate)

def calc(lst):
    tmp = 10 ** 9
    for i in range(len(lst)):
        for j in range(i + 1, len(lst)):
            tmp = min(tmp, min(abs(lst[i] - lst[j]), 24 - abs(lst[i] - lst[j])))
    return tmp

s = 0 #ans
n = len(lst_candidate)
for i in range(2 ** n):
    tmp_lst = copy.deepcopy(lst_time)
    for j in range(n):
        if (i >> j) & 1:
            tmp_lst.append(lst_candidate[j])
        else:
            tmp_lst.append(24 - lst_candidate[j])
    
    # print (tmp_lst)
    # tmp = calc(tmp_lst)
    s = max(s, calc(tmp_lst))

print (s)

Measured memory_bytes: 3444
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#define ll long long
#define fi first
#define se second
#define pb push_back
#define me memset
const int N = 1e6 + 10;
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;
using namespace std;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
 
inline int read()
{
    int X=0; bool flag=1; char ch=getchar();
    while(ch<'0'||ch>'9') {if(ch=='-') flag=0; ch=getchar();}
    while(ch>='0'&&ch<='9') {X=(X<<1)+(X<<3)+ch-'0'; ch=getchar();}
    if(flag) return X;
    return ~(X-1);
}
 
int s;
int dp[N];

int main() {
    //ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	s=read();
	dp[0]=1;
	for(int i=1;i<=s;++i){
		for(int j=0;j<=i-3;++j){
			dp[i]+=dp[j];
			dp[i]%=mod;
		}
	}
	printf("%d\n",dp[s]);

    return 0;
}

Measured memory_bytes: 3740
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
ll div_2(ll a) {
  ll ans = 0;
  while(a % 2 == 0) {
    ans++;
    a /= 2;
  }
  return ans;
}
int main() {
  int N;
  cin >> N;
  vector<ll> A(N);
  ll min = 1000000000;
  rep(i, N) {
    cin >> A[i];
    if(min > div_2(A[i])) {
      min = div_2(A[i]);
    }
  }
  cout << min << endl;
}


Measured memory_bytes: 3628
#include<stdio.h>

int main(void){
   char k[4];
   char abc[4]="ABC";
   char arc[4]="ARC";

   scanf("%s",k);

   if(k[1]==abc[1]){
      printf("ARC");
   }
   if(k[1]==arc[1]){
      printf("ABC");
   }

   return 0;
}


Measured memory_bytes: 1724
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    if(a<=8 && b<=8 && a+b<=16){
        cout<<"Yay!"<<endl;
    }
    else{
        cout<<":("<<endl;
    }
    return 0;
}


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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

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

int main(){
	cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
	ll a, b, c;cin >> a >> b >> c;
	cout << max(0LL, c - (a - b)) << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long
#define pb push_back
#define fi first
#define se second 
#define mp make_pair
#define int long long
signed main()
{
    IOS
    string str; cin>>str;
    map<char,int> Hash;
    Hash[str[0]]++;
    Hash[str[1]]++; Hash[str[2]]++; Hash[str[3]]++;
    if(Hash.size() == 2)
    {
      auto it = Hash.begin(); auto itr = it++;
      if(it->second == 2 && itr->second == 2){
        cout<<"Yes"<<endl;
        return 0;
      }
    }
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
n, k = map(int, raw_input().split())
a = [input() for i in range(n+k)]
cnt = {i:0 for i in range(n)}
for i in range(n,n+k):
    for j in range(n):
        if a[i] >= a[j]:
            cnt[j] += 1
            break
print sorted(cnt.items(), key = lambda x:x[1], reverse = True)[0][0] + 1

Measured memory_bytes: 6588
#include <cstdio>
#include <algorithm>
#include <set>
#define MAX(a,b) ((a)>(b))?(a):(b)
using namespace std;


int main() {
	int n,p,q,r,max=-1,w;
	int i,j;
	int c;
	int *sum;
	set<int> under;
	set<int> over;
	bool flag=false;
	scanf("%d%d",&n,&q);
	sum=(int *)malloc(sizeof(int)*n);
	scanf("%d",&w);
	max=sum[0]=w;
	for(i=1; i<n; ++i) {
		scanf("%d",&w);
		max=MAX(w,max);
		sum[i]=sum[i-1]+w;
	}
	if(q==1) {
		printf("%d\n",sum[n-1]);
		return 0;
	}
	p=max;
	while(1) {
		i=0;
		for(c=0; c<q-1; ++c) {
			for(j=0; i+j<n; ++j) {
				if(i==0) {
					if(sum[j]>p) {
						i=j;
						j=0;
						break;
					}
				} else {
					if(sum[i+j]-sum[i-1]>p) {
						i+=j;
						j=0;
						break;
					}
				}
			}
			if(i+j==n-1 && c<q-2) {
				if(p==max || flag) {
					printf("%d\n",p);
					return 0;
				}
				over.insert(p);
				if(flag) {
					++p;
				} else if(!under.empty()) {
					p=((*over.begin())+(*(--under.end())))/2;
				} else {
					p=(max+p)/2;
				}
			}
		}
		r=sum[n-1]-sum[i-1];
		if(r==p) {
			printf("%d\n",p);
			return 0;
		} else if (!flag) {
			if(r<p) {
				over.insert(p);
				if(!under.empty()) {
					p=((*(over.begin()))+(*(--under.end())))/2;
				} else {
					p=r+(p-r)/2;
				}
			} else if(r>p) {
				if((!over.empty() && !under.empty() && (*(over.begin()))-(*(--under.end()))<=10) || r-p<=10 ) {
					flag=true;
					under.insert(p);
					++p;
				} else {
					under.insert(p);
					if(!over.empty()) {
						p=((*(over.begin()))+(*(--under.end())))/2;
					} else {
						p=p+(r-p)/2;
					}
				}
			}
		} else {
			if(r>p) {
				++p;
			} else {
				printf("%d\n",p);
				return 0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3200
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array;

import std.math;

void main() {
    int n;
    scan(n);
    writeln(n/3);
}


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: 256
#YouTube
import sys
sys.setrecursionlimit(10**6)

def kukan(l,r,el=1,er=1):
    em=el+er
    if l+1==r:
        return 0
    if l+2==r:
        return a[l+1]*em
    t=(l,r,el,er)
    if t in memo:
        return memo[t]
    re=10**11
    for m in range(l+1,r):
        tmp=kukan(l,m,el,em)+kukan(m,r,em,er)+a[m]*em
        if tmp<re:
            re=tmp
    memo[t]=re
    return re

n=int(input())
a=list(map(int,input().split()))
memo={}
print(a[0]+kukan(0,n-1)+a[-1])

Measured memory_bytes: 25168
from math import factorial
n = int(input())
p = [int(i) for i in input().split()]
q = [int(i) for i in input().split()]
a = 0
b = 0

for i in range(n):
    a+= (p[i]-1)*factorial(n-1-i)
    b+= (q[i]-1)*factorial(n-1-i)
    for j in range(n):
        if p[i] < p[j]:
            p[j] -= 1
        if q[i] < q[j]:
            q[j] -= 1

print(abs(a-b))

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;

const int MOD = 2019;

int main() {
	string S;
	cin >> S;
	reverse(S.begin(), S.end());
	long long digit = 1, len = S.size();
	vector<long long> T(len + 1); // 後ろから見ていき、MOD取って収納.
	map<long long, int> ma; // 数数えのために持ってきたよ.
	T.at(0) = 0;
	ma[0]++;
	for (int i = 1; i <= len; i++) {
		long long tmp = (long long)(S.at(i - 1) - '0') * digit;
		tmp %= MOD;
		T.at(i) = (tmp + T.at(i - 1)) % MOD;
		ma[T.at(i)]++;
		digit *= 10;
		digit %= MOD;
	}

	long long ans = 0;
	for (auto x : ma) {
		long long tmp = x.second;
		ans += tmp * (tmp - 1) / 2;
	}

	cout << ans << endl;
}

Measured memory_bytes: 5140
#include <iostream>
using namespace std;
int main(){
  int n, m, c, ans=0, sum;
  cin >> n >> m >> c;
  int b[m], a[n][m];
  for(int i=0; i<m; i++)
    cin >> b[i];
  for(int i=0; i<n; i++)
    for(int j=0; j<m; j++)
      cin >> a[i][j];
  for(int i=0; i<n; i++){
    sum=c;
    for(int j=0; j<m; j++){
      sum+=a[i][j]*b[j];
    }
    if(sum>0)
      ans++;
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 256
import java.io.IOException;

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        try (
            BufferedReader reader = new BufferedReader(
                new InputStreamReader(System.in))) {
            String s = reader.readLine();
            int N = Integer.parseInt(s);

            s = reader.readLine();
            int K = Integer.parseInt(s);

            int now = 1;
            for (int i = 0; i < N; i++) {
                if (now * 2 < now + K) now *= 2;
                else now += K;
            }
            System.out.println(now);
        }
    }
}


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

using namespace std;

int arr[2005];

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

    int n,i,j;
    long long ans=0;
    cin>>n;
    for(i=0;i<n;i++)cin>>arr[i];
    sort(arr,arr+n);
    for(i=2;i<n;i++){
        for(j=i-1;j>0;j--){
            if(arr[j]*2<=arr[i])break;
            int x = upper_bound(arr,arr+n,arr[i]-arr[j])-arr;
            ans+=(j-x);
        }
    }
    cout<<ans<<'\n';
	return 0;
}


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

int main() {
  int N, A, B, C, D; cin >> N >> A >> B >> C >> D;
  string S; cin >> S;
  
  int wall = 200000;
  int space = 200001;
  for(int i = 0; i < S.size() - 1; ++i){
    if(S.at(i) == '#' && S.at(i+1) == '#'){
      wall = min(i+1,wall);
    }
  }
  
  for(int i = 0; i < S.size() - 2; ++i){
    if(S.at(i) == '.' && S.at(i+1) == '.' && S.at(i+2) == '.' && B < i+3 && D != i+1){
      space = min(i+2,space);
    }
  }
  
  if(A-1 < wall && wall < C-1) cout << "No" << endl;
  else if(B-1 < wall && wall < D-1) cout << "No" << endl;
  else if(space == 200001 && D < C) cout << "No" << endl;
  else cout << "Yes" << endl;
}

Measured memory_bytes: 640
'use strict';
const main = input => {
  const n = parseInt(input[0]);
  let p = [];
  for(let i=0; i<n; i++) {
    let k = input[i+1].split(' ').map(val => parseInt(val));
    p[i] = {x: k[0], y: k[1]};
  }
  let distanceSum = 0;
  for(let i=0; i<n-1; i++) {
    for(let j=i; j<n; j++) {
      distanceSum += Math.sqrt(Math.pow(p[i].x-p[j].x, 2)+Math.pow(p[i].y-p[j].y, 2));
    }
  }
  console.log(distanceSum/n*2);
}
main(require("fs").readFileSync("/dev/stdin", "utf8").split('\n'));

Measured memory_bytes: 21320
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  string s;
  ll k;
  cin >> s >> k;
  string t = s;
  ll n = 1ll * s.size();
  ll ans = 0;
  if (s[0] != s[n - 1]) {
    REP(i, n - 1) {
      if (s[i] == s[i + 1]) {
        ans++;
        s[i + 1] = 'A';
      }
    }
    cout << ans * k << endl;
  } else {
    bool all_same = true;
    REP(i, n) {
      if (s[0] != s[i]) all_same = false;
    }
    if (all_same) {
      if (n % 2 == 0) {
        cout << (n / 2) * k << endl;
      } else {
        ll d = k / 2;
        cout << (n / 2 + 1) * d + (n / 2) * (k - d) << endl;
      }
    } else {
      ll cnt = 0;
      REP(i, n - 1) {
        if (s[i] == s[i + 1]) {
          cnt++;
          s[i + 1] = 'A';
        }
      }
      ll tmp = cnt * k + (s[0] == s[n - 1]) * (k - 1);
      ll cnt2 = 0;
      for (int i = n - 1; i >= 1; --i) {
        if (t[i] == t[i - 1]) {
          cnt2++;
          t[i - 1] = 'A';
        }
      }
      ll tmp2 = cnt2 * k + (t[0] == t[n - 1]) * (k - 1);
      cout << min(tmp, tmp2) << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repr(i,from,to) for(int (i)=(from);(i)<(to);(i)++)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
#define all(x) begin((x)), end((x))
#define vprint(x) for(auto a:(x)) cout << x << endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;
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;
}


int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a;
    cin>>a;
    ll res = 0;
    repr(i,1,a+1) {
        repr(j,1,a+1) {
            repr(k,1,a+1) {
                res += __gcd(__gcd(i,j),k);
            }
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<ll> ql;
typedef deque<ll> dql;
typedef priority_queue<ll/*, vl, greater<ll>*/> pql; //降順(/*昇順*/)
typedef set<ll> sl;
typedef pair<ll, ll> pl;
typedef vector<vl> vvl;
typedef vector<pl> vpl;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define rep2(i, k, n) for(ll i = ll(k); i <= ll(n); i++)
#define rep3(i, n, k) for(ll i = ll(n); i >= ll(k); i--)
#define all(v) (v).begin(), (v).end()
ll mod(ll a, ll b) {if(b == 0) return 0; return (a % b + b) % b;}
bool chmin(ll &a, ll b) {if(b < a) {a = b; return 1;} return 0;}
bool chmax(ll &a, ll b) {if(b > a) {a = b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
const ll MAX = 1e9;
const char newl = '\n';

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

  ll n;
  cin >> n;
  vl a(n);
  rep(i, n) cin >> a[i];
  
  ll h=a[0], sum=0;
  rep2(i, 1, n-1) {
    if(a[i] < h) sum += h-a[i];
    else h=a[i];
  }
  cout << sum << newl;
  return 0;
}

Measured memory_bytes: 4764
#include<iostream>
#include<cstdio>
#include<algorithm>

using namespace std;

void debug(int k){
    cout << k << endl;
}

int A[2000001],B[2000001];
int C[10002];

int main(){
    int n;
    int max = 0;
    cin >> n;
    
    for (int i = 0; i < 10002; i++) {
        C[i] = 0;
    }
    for (int i = 0; i < n; i++) {
        scanf("%d",&A[i]);
        if (A[i] > max) {
            max = A[i];
        }
        C[A[i]]++;
    }
    for (int i = 1; i <= max; i++) {
        C[i] += C[i-1];
    }
    for (int i = 0; i < n; i++) {
        B[C[A[i]]-1] = A[i];
        C[A[i]]--;
    }
    for (int i = 0; i < n-1; i++){
        printf("%d ",B[i]);
    }
    cout << B[n-1] << endl;
    
    return 0;
}

Measured memory_bytes: 16940
#include<cstdio>
#include<iostream>
#include<cstring>
#define RG register
#define ll long long
using namespace std;
int n;
ll a[101],sum,ans1,ans2,tt;
inline ll read(){
	char ch=getchar(); ll x=0, f=1;
	while(ch<'0' || ch>'9') {if(ch=='-') f=-1;ch=getchar();}
	while(ch>='0' && ch<='9') {x=x*10+ch-'0'; ch=getchar();}
	return x*f;}
inline ll poww(ll x){return x*x;}
int main()
{
	//freopen("Be Together.in","r",stdin);
	//freopen(".out","w",stdout);
	n=read();
	for(RG int i=1;i<=n;i++)
	{
		a[i]=read(); 
		sum+=a[i];
	}
	tt=sum/n;
	for(RG int i=1;i<=n;i++) ans1+=poww(tt-a[i]);
	tt++;
	for(RG int i=1;i<=n;i++) ans2+=poww(tt-a[i]);
	printf("%lld",min(ans1,ans2));;
	//fclose(stdin); fclose(stdout);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
     
     
typedef long long ll;
typedef vector <int> vi;
typedef pair <int,int> pi;
typedef tuple <int,int,int> ti;

#define forn(i,a,n) for(int i = a; i < n ; i++)
#define mem(str,a) memset(str, a, sizeof(str));
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(nullptr)
const int MOD = 1e9+7, N = 1e7 + 10, E = 1e-9;
/*
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
//vector <int> show;
//for (auto x : show)
//   cout << x << " ";
getline(cin,s);


*/

int main() {
    int w,a,b;
    cin >> w >> a >> b;
    int ans = max(a,b) - min(a,b) - w;
    if(ans < 0) ans = 0;
    cout << ans << endl;
    return 0;
}

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

#define all(v) (v).begin(), (v).end()
#define sortv(v) sort(all(v))
#define uniqv(v) (v).erase(unique(all(v)), (v).end())
#define pb push_back
#define FI first
#define SE second
#define lb lower_bound
#define ub upper_bound
#define mp make_pair
#define test 1
#define TEST if(test)

using namespace std;

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

const int MOD = 1000000007; // 998244353
const int INF = 2e9;
const ll INFLL = 1e18;
const int MAX_N = 1;

ll N, A, B;

int main(){
	cin>>N>>A>>B;
	if(A%2==B%2){
		cout<<(B-A)/2LL;
	}else{
		cout<<min(A+(B-A)/2LL, N-B+1LL+(B-A)/2LL);
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <numeric>
#include <algorithm>
#include <math.h>

using namespace std;

int64_t N;

int main(){
	cin >> N;

	string ans = "";
	if( N == 0 )	ans = "0";
	while ( N != 0 ){
		if( N % 2 == 0 ){
			ans = "0" + ans;
		}else{
			ans = "1" + ans;
			N--;
		}
		N /= -2;
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
#include<random>
#include<ctime>
#include<set>

using namespace std;
#define SAY_YES cout<<"YES"<<endl;
#define SAY_Yes cout<<"Yes"<<endl;
#define SAY_NO cout<<"NO"<<endl;
#define SAY_No cout<<"No"<<endl;
#define IFYES(TRUE_OR_FALSE) if(TRUE_OR_FALSE){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;} 
#define IFYes(TRUE_OR_FALSE) if(TRUE_OR_FALSE){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;} 
#define IFyes(TRUE_OR_FALSE) if(TRUE_OR_FALSE){cout<<"yes"<<endl;}else{cout<<"no"<<endl;} 
#define DEBUG_OUTPUT_ARRAY(XXX,ONE) for(int i=0;i<(ONE);i++){cout<<"DEBUG: i = "<<i<<" -> "<<XXX[i]<<endl;}
#define DEBUG_OUTPUT_ARRAY2(XXX,ONE,TWO) for(int i=0;i<(ONE);i++){cout<<"<<< i = "<<i<<" >>>"<<endl;for(int j=0;j<(TWO);j++){cout<<"DEBUG: j = "<<j<<" -> "<<XXX[i][j]<<endl; } }
#define DEBUG_OUTPUT_ARRAY2_BOX(XXX,ONE,TWO) for(int i=0;i<(ONE);i++){cout<<i<<"  ";for(int j=0;j<(TWO);j++){cout<<XXX[i][j]<<" "; } cout<<endl;}

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


const long long int mod=1000000007;
const long long int INF=99999999999999999;

long long int n,q,A[50],m[250],memo[2200]={};
pair<long long int,long long int>star[205],allstar[1005];
map<pll,bool>mp;
int main() {
	cout << fixed << setprecision(18);
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>A[i];
    }
    cin>>q;
    for(int i=0;i<q;i++){
        cin>>m[i];
    }
    for(int i=0;i<(1<<n);i++){
        long long int tmp=0;
        for(int j=0;j<n;j++){
            if((i&(1<<j))==0){tmp+=A[j];}
        }
        if(tmp<=2000){memo[tmp]=1;}
    }
    for(int i=0;i<q;i++){
        if(memo[m[i]]==1){cout<<"yes"<<endl;}
        else{cout<<"no"<<endl;}
    }
    //DEBUG_OUTPUT_ARRAY(memo,200);
} 



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

int main(){
    int n;
    int a[100000];
    int x[100000];

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

    

    int symbol;
    
    for(int i=0;i<1;i++){
        symbol = 1;
        for(int j=0;j<n;j++){
            int tmp=(i+j)%n;
            x[i] += a[tmp]*symbol;
            symbol *= -1;
        }
    }//x[0]だけ求めた

     for(int i=1;i<n;i++){

        x[i] = (-1)*x[i-1] + 2*a[i-1];
  
    }




    for(int i=0;i<n;i++){
        printf("%d", x[i]);
        if(i!=n-1) printf(" ");
        else printf("\n");
    }
    
    return 0;
}

Measured memory_bytes: 2048
n = input()

def sum(k):
    return (k+1)*k//2

pre = ">"
up = 0
down = 0
ans = 0
for x in n:
    if pre==">" and x ==">":
        down += 1
    elif pre=="<" and x=="<":
        up += 1
    elif pre=="<" and x==">":
        down += 1
    elif pre==">" and x=="<":
        ans += sum(max(up,down)) + sum(min(up,down)-1)
        up = 1
        down = 0
    pre = x

if pre==">":
    ans += sum(max(up,down)) + sum(min(up,down)-1)
elif pre=="<":
    ans += sum(up)

print(ans)


Measured memory_bytes: 4116
/**
 *    author:  yoseph
 *    created: 18.07.2020 22:41:10      
**/
#include <bits/stdc++.h>
using namespace std;
// === Debug macro starts here ===

int recur_depth = 0;
#ifdef LOCAL
#define dbg(x) {++recur_depth; auto x_=x; --recur_depth; cerr<<string(recur_depth, '\t')<<"\e[91m"<<__func__<<":"<<__LINE__<<"\t"<<#x<<" = "<<x_<<"\e[39m"<<endl;}
#else
#define dbg(x)
#endif
template<typename Ostream, typename Cont>
typename enable_if<is_same<Ostream,ostream>::value, Ostream&>::type operator<<(Ostream& os,  const Cont& v){
	os<<"[";
	for(auto& x:v){os<<x<<", ";}
	return os<<"]";
}
template<typename Ostream, typename ...Ts>
Ostream& operator<<(Ostream& os,  const pair<Ts...>& p){
	return os<<"{"<<p.first<<", "<<p.second<<"}";
}

// === Debug macro ends here ===
const int inf = (1 << 31) - 1;
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, k;
	cin >> n >> k;
	vector<int > v(n);
	for (int i = 0; i < n; ++i)
		cin >> v[i];

	sort(v.begin(),v.end());
	int ans = inf;
	for (int i = 0; i < n - k + 1; ++i) {
		dbg(ans);
		ans = min(ans,v[i + k - 1] - v[i]);
	}
	cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 3656
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
using namespace std;
int main()
 {
	int x,a,b;
	cin>>x>>a>>b;
	if(abs(x-a)>abs(x-b))
	  cout<<'B'<<endl;
	else
	  cout<<'A'<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(signed i=0;i<n;++i)
#define repi(n) rep(i,n)
#define repvin(n) vint a(n);r(i,n)cin>>a[i];
#define int long long
#define str string
#define vint vector<signed>
#define pint pair<signed,signed>
#define pb(a) push_back(a)
#define all(v) v.begin(),v.end()
#define yn(b) cout<<((b)?"Yes":"No")<<endl
#define YN(b) cout<<((b)?"YES":"NO")<<endl
#define call(a) for(auto t:a)cout<<t<<" ";cout<<endl
#define ENDL printf("\n");
#define debg(a) cout<<#a<<":"<<a<<endl;
#define SORT(a) sort(all(a));
#define C(a) cout<<a<<endl;

signed main(){
    str s;
    cin>>s;
    char t[9]={s[0],s[1],s[2],s[3],s[5],s[6],s[8],s[9]};
    int a=atoi(t);
    cout<<(a>20190430?"TBD":"Heisei")<<endl;
  
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
int32_t main(){
	int n;
	cin>>n;
	int arr[n];
	for(int i=0;i<n;i++){
		cin>>arr[i];
	}
	int ans =0;
	for(int i=0;i<n-2;i++){
		for(int j=i+1;j<n-1;j++){
			for(int k=j+1;k<n;k++){
				int a=arr[i],b=arr[j],c=arr[k];
				if((a+b)>c && (b+c)>a && (c+a)>b && a!=b && b!=c && a!=c){
					ans++;
				}
			}
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 3640
//#pragma GCC target ("avx2")
//#pragma GCC optimize ("Ofast")
//#pragma GCC optimize ("unroll-loops")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define int long long

using namespace std;
using namespace __gnu_pbds;

template <class T> using ordered_set =
tree<T, null_type, less<T>,
rb_tree_tag, tree_order_statistics_node_update>;

const int N = (int)(1e6 + 5);
const int M = (int)(1e9 + 7);
const int INF = (int)(1e18 + 9);
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, 1, -1};

signed main() {
  ios_base :: sync_with_stdio(0);
  cin.tie(0);
  string s;
  cin >> s;
  if (s == "Sunny")
    cout << "Cloudy";
  if (s == "Rainy")
    cout << "Sunny";
  if (s == "Cloudy")
    cout << "Rainy";
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;
template <typename A, size_t N, typename T> void Fill(A (&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
// long long mod = 998244353;
#define REP(i, n) for (long long i = 0; i < (n); i++)
#define rep(i, a, n) for (long long i = a; i < (n); i++)
typedef long long ll;
typedef pair<ll, ll> P;
long long mod = 1000000007;
long long modpow(long long m, long long n, long long modvalue) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2, modvalue);
        return t * t % modvalue;
    } else {
        return modpow(m, n - 1, modvalue) * m % modvalue;
    }
}

long long moddiv(long long a, long long b, ll modvalue) { return (a * modpow(b, mod - 2, modvalue)) % modvalue; }

const ll INF = 1LL << 60;

string change_binary(long long a) {
    string ret;
    for (int i = 31; i >= 0; i--) {
        ret += (a >> i & 1) + '0';
    }
    return ret;
}

ll nCkmod(ll n, ll k, ll modvalue) {
    ll numera = 1;
    for (int i = n; i > n - k; i--) {
        numera *= i;
        numera %= modvalue;
    }
    ll denomi = 1;
    REP(i, k) {
        denomi *= (i + 1);
        denomi %= modvalue;
    }
    return moddiv(numera, denomi, modvalue);
}
signed main() {
    ll n;
    cin >> n;
    map<ll, ll> cnt;
    vector<ll> as(n);
    REP(i, n) {
        cin >> as[i];
        cnt[as[i]]++;
    }
    ll sum = 0;
    for (auto x : cnt) {
        sum += x.second * (x.second - 1) / 2;
    }
    REP(i, n) { cout << sum - cnt[as[i]] + 1 << endl; }
}

Measured memory_bytes: 12688
#include "bits/stdc++.h"
using namespace std;
#define int long long
int mod=1e9+7;

signed main(){
  int n;
  cin>>n;
  vector<int> s(14,0);
  vector<int> h(14,0);
  vector<int> c(14,0);
  vector<int> d(14,0);
  for(int i=0;i<n;i++){
    char ca;
    int a;
    cin>>ca>>a;
    if(ca=='S')s[a]++;
    if(ca=='H')h[a]++;
    if(ca=='C')c[a]++;
    if(ca=='D')d[a]++;
  }
  for(int i=1;i<14;i++){
    if(!s[i])cout<<"S "<<i<<endl;
  }
  for(int i=1;i<14;i++){
    if(!h[i])cout<<"H "<<i<<endl;
  }
  for(int i=1;i<14;i++){
    if(!c[i])cout<<"C "<<i<<endl;
  }
  for(int i=1;i<14;i++){
    if(!d[i])cout<<"D "<<i<<endl;
  }
}



Measured memory_bytes: 3072
def calcX(a, e)
  return a * e
end

def calcY(b, c, d, e)
  if c >= e
    return b
  else
    return b + ((e - c) * d)
  end
end

a = gets.to_i
b = gets.to_i
c = gets.to_i
d = gets.to_i
e = gets.to_i

puts [calcX(a, e), calcY(b,c,d,e)].min

Measured memory_bytes: 8600
### SNIPPET
  # n = gets.split.map(&:to_i)
  # array = n.times.map { gets.split.map(&:to_i) }
  # [].all?(&:even?)
  # a = [*1..m].repeated_combination(n).to_a
  # [1,2,3,4,5].select { |num| num.even? }  # => [2, 4]
  # ["a","a","b"].group_by(&:itself).map{|k,v| [k, v.count]}.to_h #=> {"a"=>2, "b"=>1}
  # 切り捨て: .floor(2).to_f ,切り上げ： .ceil(2).to_f,四捨五入: round(2)
  # 3.upto(6) do |i|, 6.downto(3) do |i|
  # 公約数125.gcd(100)、公倍数125.lcm(100)
  # PI = Math::PI
  # 高さ = a * Math.sin(w / 180.0 * Math::PI), 底辺 = a * Math.cos(w / 180.0 * Math::PI)
  # def chmax(a, b) a > b ? a : b end
  # INF = Float::INFINITY
  # def chmin(a, b) a < b ? a : b end

n = gets.to_i
x = gets.split.map(&:to_i)

pa = []
1.upto(x.max) do |p|
  sum = 0
  1.upto(n) do |i|
    sum += (x[i-1] - p) ** 2
  end
  pa << sum
end

puts pa.min

Measured memory_bytes: 1788
#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;

int main(){
	string s;
	cin >> s;
	int a = s[0]-'0';
	int b = s[1]-'0';
	int c = s[2]-'0';
	int d = s[3]-'0';

	if(a+b+c+d==7) {
		printf("%d+%d+%d+%d=7", a,b,c,d);
		return 0;
	}
	if(a-b+c+d==7) {
		printf("%d-%d+%d+%d=7", a,b,c,d);
		return 0;
	}
	if(a+b-c+d==7) {
		printf("%d+%d-%d+%d=7", a,b,c,d);
		return 0;
	}
	if(a+b+c-d==7) {
		printf("%d+%d+%d-%d=7", a,b,c,d);
		return 0;
	}
	if(a-b-c+d==7) {
		printf("%d-%d-%d+%d=7", a,b,c,d);
		return 0;
	}
	if(a+b-c-d==7) {
		printf("%d+%d-%d-%d=7", a,b,c,d);
		return 0;
	}
	if(a-b+c-d==7) {
		printf("%d-%d+%d-%d=7", a,b,c,d);
		return 0;
	}
	if(a-b-c-d==7) {
		printf("%d-%d-%d-%d=7", a,b,c,d);
		return 0;
	}
	
	
	
    return 0;
}



Measured memory_bytes: 256