akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll a, b, c, d;
  in2(a, b);
  in2(c, d);
  out((a - c) * (b - d));
  memi;
}

Measured memory_bytes: 384
#include"bits/stdc++.h"
#define int long long
#define rep(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define itr(i,x) for(auto i=(x).begin();i!=(x).end();++i)
#define All(x) (x).begin(),(x).end()
#define gridif(a,x,b) if((a)<=(x)&&(x)<=(b))
using namespace std;
typedef pair<int,int> P;
const int mod=1000000007;


int mpow(int a,int x);
int m_inv(int n){return mpow(n,mod-2);}

int gcd(int x,int y){return y?gcd(y,x%y):x;}
int lcm(int x,int y){return x*y/gcd(x,y);}

signed main(){
    string w;cin>>w;
    map<char,int> mp;
    rep(i,w.size()){
    	mp[w[i]]++;
    }
    itr(i,mp) if(i->second%2==1){
    	cout<<"No"<<endl;
    	return 0;
    }
    cout<<"Yes"<<endl;
}

int mpow(int a,int x){
	int ans=1;
	while(x>0){
		if(x%2==1) (ans*=a)%=mod;
		(a*=a)%=mod;
		x>>=1;
	}
	return ans;
}

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

using namespace std;

#define WA(x) #x << " = " << x << '\n'
#define FOR(i, n) for(int i = 0; i < (int) n; i++)
#define FORT(i, a, b) for(int i = a; i < (int) b; i++)
#define all(v) v.begin(), v.end()
#define PB push_back
#define F first
#define S second

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

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

	int n; cin >> n;
	vi v(n); for(auto& p: v) cin >> p;

	int mini = 1e9;
	for(int i = 1; i <= 100; i++){
		int aux = 0;
		for(auto& p: v){
			aux += (p-i)*(p-i);
		}
		mini = min(mini, aux);
	}

	cout << mini << '\n';

	return 0;
}

Measured memory_bytes: 256
h, w, k = map(int, input().split())

grid = [input() for _ in range(h)]

def check(grid, imask, jmask):
    black = 0
    for ii in range(h):
        for jj in range(w):
            if (1 << ii) & imask == 0 and (1 << jj) & jmask == 0 and grid[ii][jj] == '#':
                black += 1
    return black


cnt = 0
for imask in range(1 << h):
    for jmask in range(1 << w):
        t = check(grid, imask, jmask)
        if t == k:
            cnt += 1
print(cnt)



Measured memory_bytes: 68512
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define MAX 510000
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;

int main(){
    ll n; cin >> n;
    vl take(4,0);
    rep(i,3) cin >> take[i];
    vl l(n);
    rep(i,n) cin >> l[i];
    vl a(n);
    ll ans = INF;
    rep(i,pow(4,n)){
        ll tmp = i;
        vl t(4,0);
        rep(j,n-1){
            a[j] = tmp % 4;
            tmp /= 4;
        }
        a[n-1] = tmp;
        ll s = -30;
        rep(j,n){
            t[a[j]] += l[j];
            if(a[j]!=3) s += 10;
        }
        bool flag = true;
        rep(j,3){
            if(t[j]==0) flag = false; 
        }
        if(!flag) continue;
        rep(j,3){
            s += abs(take[j]-t[j]);
        }
        ans = min(ans, s);
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
 
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <iterator>
#include <functional>
#include <limits>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <stack>

using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
typedef int64_t ll;
 
#define endl '\n'
#define int ll
ll mod=1e9+7;
ll mod1=1e9+5;
int power(int a,int b)
{
    if(b==0) return 1;
    else if(b%2==0)
        return power((((a%mod)*(a%mod))%mod),b/2)%mod;
    else return ((a%mod)*(power((((a%mod)*(a%mod))%mod),b/2)%mod))%mod;
}


int32_t main()
{
    IOS
    
    
        int n;
        cin>>n;
        int a[n+1][n+1];
        vector<int> s[n+1];
        for(int i=1;i<=n;++i)
        {
            for(int j=1;j<=n-1;++j)
                {
                    int p;
                    cin>>p;
                    
                    s[i].push_back(p);
                }

        }
        int ans=0;;
        bool vi[n+1];
        while(1)
        {
            int check=1;
            for(int i=1;i<=n;++i)
            {
                if(s[i].size()!=0)
                {
                    check=0;
                    break;
                }
            }
            if(check)
                break;
            
            memset(vi,false,sizeof(vi));
            check=1;
            for(int i=1;i<=n;++i)
            {
                if(vi[i])
                    continue;
                if(s[i].size()==0)
                    continue;
                
                if(i==*s[*s[i].begin()].begin() and vi[*s[i].begin()]==false)
                {

                    int temp=*s[i].begin();
                    check=0;
                    vi[i]=true;
                    vi[temp]=true;
                    //out<<*s[i].begin()<<" "<<i<<endl;
                    s[i].erase(s[i].begin());
                    s[temp].erase(s[temp].begin());
                }
                

            }
            if(check)
            {
                cout<<-1;
                return 0;
            }
            
            ans++;
        }
        cout<<ans;

}


Measured memory_bytes: 10368
/*  
    Come feed the rain
	Cos I'm thirsty for your love
	Dancing underneath the skies of lust
	Yeah feed the rain...
	Cos without your love my life
	Ain't nothing but this carnival of rust
    _________________________
    _________________________
    816 Hours of Solitude
    Quarantine_Day : 34
*/

#include<bits/stdc++.h>

using namespace std;

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

#define pb(n)           push_back(n)
#define GSORT(v)        sort(v.begin(), v.end(), greater<int>())
#define SORT(v)         sort(v.begin(), v.end());
#define REV(v)          reverse(v.begin(), v.end());
#define db(a)           cout<<#a<<" = "<<a<<endl;
#define FIN             freopen("in.txt","r",stdin);
#define FOUT            freopen("out.txt","w",stdout);
#define REP(i,n)        for(int i = (int)(0); i < (int)(n); i++)
#define FOR(i, a, b)    for(int i = (int)a; i <= (int)b; i++)    

#define MAX 50005
#define MOD 1000000007

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

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

	cout<<max(0, max(a, b) - (w+ min(a, b)))<<"\n";

	return 0;
}


Measured memory_bytes: 384
X,Y,A,B,C = map(int,input().split())

p = list(map(int,input().split()))
q = list(map(int,input().split()))
r = list(map(int,input().split()))

p.sort(reverse = True)
q.sort(reverse = True)
r.sort(reverse = True)

lst = p[:X] + q[:Y] + r
lst.sort(reverse = True)

print(sum(lst[:X+Y]))


Measured memory_bytes: 23328
use std::str::FromStr;

fn get_one<T : FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    return s.trim().parse().ok().unwrap();
}

fn get_vec<T : FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    return s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect();
}

fn main() {
    let v : Vec<i32> = get_vec();
    if v[0] % 3 == 0 || v[1] % 3 == 0 || (v[0] + v[1]) % 3 == 0 {
        println!("{}", "Possible")
    }
    else {
        println!("{}", "Impossible")
    }
}


Measured memory_bytes: 4352
S = input()
N = len(S) - 1

ans = []

for i in range(2**N):
  tmp = ""
  for j in range(N):
    tmp += S[j]
    if (i >> j) & 1:
      tmp += "+"
  else:
    tmp += S[-1]

  ans.append(eval(tmp))

print(sum(ans))

Measured memory_bytes: 3060
#include<stdio.h>
int dx[4]={0,-1,0,1},dy[4]={-1,0,1,0},cnt,x,y;
char a[12][13];
void func(int y,int x){
	int i,xx,yy;
	a[y][x]='0';
	for(i=0;i<4;i++){
		xx=x+dx[i]; yy=y+dy[i];
		if(x>=0&&y>=0&&x<12&&y<12&&a[yy][xx]=='1') func(yy,xx);
	}
}
int main(void){
	int i,j;
	while(scanf("%s",&a[0])!=EOF)	{
		for(i=1;i<12;i++) scanf("%s",a[i]);
		cnt=0;
		for(i=0;i<12;i++){
			for(j=0;j<12;j++){
				if(a[i][j]=='1'){
					cnt++;
					func(i,j);
				}
			}
		}
		printf("%d\n",cnt);
	}
	return 0;
}

Measured memory_bytes: 2580
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)

typedef int long long ll;
using namespace std;
typedef pair<int,int> P;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll MOD=1e9+7;
static const int MAX = 100;
static const int INF = (1<<23);
template<class T> T gcd(T a, T b){return b? gcd(b,a%b) : a;}
template<class T> T lcm(T a,T b){return a / gcd(a,b)*b;}

int main(){
int n;
cin>>n;
ll sum = 0;

for(int i=1;i<=n;i++){
    if(i%3==0){

    }else if(i%5==0){

    }else{
        sum+=i;

    }

}
cout<<sum<<endl;



return 0;
}


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
#include <unistd.h>
#include <stdio.h>
#define all(a) (a).begin(),(a).end()
#define vecin(a) rep(i,a.size())cin >> a[i]
#define vecout(a) rep(i,a.size()){cout << a[i];cout << (i == a.size() - 1 ? "\n":" ");}
#define rep(i,x) for(int i = 0;i<x;i++)
#define REP(i,x) for(ll i = 1;i<=x;i++)
#define mp make_pair
using ll = long long;
using ld = long double;
using namespace std;
using dou = double;
const ll inf = 2147483647;
const ll INF = 1LL << 60;
const dou pi = 3.14159265358;
const ll mod = 1000000007LL;
//const ll mod = 998244353LL;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
template<class T> inline bool chmax(T& a, T b){if(a < b){a = b; return true;}return false;}
template<class T> inline bool chmin(T& a, T b){if(a > b){a = b; return true;}return false;}
template<class T> inline bool change(T a,T b){if(a > b){swap(a,b);return true;}return false;}
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    return a / gcd(a,b) * b;
}

//素数判定O(sqrt(N))
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}
const ll cmax = 1000000;
ll fac[cmax], finv[cmax], inv[cmax];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < cmax; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

// 二項係数計算
ll nCk(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
//nのm乗をMODで割ったあまりO(logm)
ll modpow(ll n,ll m,ll MOD){
    if(m == 0)return 1;
    if(m < 0)return -1;
    ll res = 1;
    while(m){
        if(m & 1)res = (res * n) % MOD;
        m >>= 1;
        n *= n;
        n %= MOD;
    }
    return res;
}
ll mypow(ll n,ll m){
    if(m == 0)return 1;
    if(m < 0)return -1;
    ll res = 1;
    while(m){
        if(m & 1)res = (res * n);
        m >>= 1;
        n *= n;
    }
    return res;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll N,K;
    cin >> N >> K;
    if(K == 1){
        cout << "0\n";
        return 0;
    }
    cout << N - K << "\n";
}

Measured memory_bytes: 3624
#include <algorithm>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;

int main() {
  int H, W, h, w;
  cin >> H >> W >> h >> w;
  if (H % h == 0 && W % w == 0) {
    cout << "No" << endl;
    return 0;
  }
  int minus = (H / h) * (W / w);
  int rem = H * W - h * w * minus;
  int pv = minus / rem + 1;
  int mv = -((h * w - 1) * pv + 1);
  cout << "Yes" << endl;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (i % h == h - 1 && j % w == w - 1) {
        cout << mv;
      } else {
        cout << pv;
      }
      cout << " ";
    }
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 1280
import java.awt.*;
import java.util.Scanner;

public class Main {
  private static void solve(int n, Point[] points) {
    int multi = 1;
    for (int i = 1; i <= n - 1; i++) multi *= i;
    double allSum = 0;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        if (i == j) continue;
        double distance = Math.hypot(
          points[i].getX() - points[j].getX(),
          points[i].getY() - points[j].getY());
        allSum += distance * multi;
      }
    }
    System.out.println(allSum / (multi * n));
  }
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = Integer.parseInt(sc.nextLine());
    Point[] points = new Point[n];
    for (int i = 0; i < n; i++) {
      points[i] = new Point();
      points[i].setLocation(sc.nextInt(), sc.nextInt());
    }
    sc.close();
    solve(n, points);
  }
}

Measured memory_bytes: 21844
/*Author: Gautam*/
 
 
#include<bits/stdc++.h>
#define FastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
#define MOD 1000000007
#define ull unsigned long long int
#define newline cout<<endl
 
 
/* TYPE DEFINITIONS */
typedef     long long int        ll;
typedef     vector<ll>     vi;
typedef     pair<ll,ll>   pi;
 
 
 
/* MATH */
bool isPrime(ull n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (ull i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
} 
 
ll pow(ll a,ll b,ll m)
{
    ll res=1;
    while(b>0)
    {
        if(b&1)res=(res*a)%m;
        a=(a*a)%m;
        b>>=1;
    }
    return res;
}
 
  
//
/* MACROS */
 
#define  all(A)         (A).begin() , (A).end()
#define  arrall(A,n)    (A),((A)+(n))
#define  rall(A)        (A).rbegin() , (A).rend()
#define  sz(A)          (int)(A).size()
#define  pb             push_back
#define  ppb            pop_back
#define  mp             make_pair
#define  ln(X)          (int)(X).length()
#define  square(X)      ((X)*(X))
#define  cube(X)        ((X)*(X)*(X))
#define  forn(i, n)  for (int i = 0; i < int(n); i++)
#define  forr(i, n)  for (int i = int(n - 1); i >= 0; i--)
#define  fora(i, a, b)  for (int i = int(a); i <= int(b); i++)
#define  forb(i, a, b)  for (int i = int(a); i >= int(b); i--)
#define  fore(it, a)    for(__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++) 
void solve()
{
	int a,b;
	cin>>a>>b;
	bool arr[4]={0};
	arr[a]=1;
	arr[b]=1;
	fora(i,1,3)
	{
		if(!arr[i])cout<<i<<endl;
	}
}
 
int main()
{
 
    FastIO;
    ll t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    #ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	#endif
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
ll n;
map<ll,ll> mp;
ll ans;
int main(){
	cin>>n;
	for(ll i=0;i<n;i++){
		ll x;
		cin>>x;
		ans+=mp[i-x];
		mp[i+x]++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 26268
#include <stdio.h>

int main()
{
	int i=0,j;
	char S[101];
	int flag = 0;
	int count = 0;
	scanf("%s",S);
	while(S[i]!='\0')
	{
		count = count + 1;
		i++;
	}
	count = count -1;
	for(i = 0,j = count;i < count/2;i++,j--)
	{
		if(S[i] != S[j])
		{
			flag = 1;
			break;
		}
	}
	if(flag == 1)
	{
		printf("No\n");
		return 0;
	}
		
	for(i = 0,j = (count - 1)/2; i<=(count-1)/2;i++,j--)
	{
		if(S[i] != S[j])
		{
			flag = 1;
			break;
		}
	}
	if(flag == 1)
	{
		printf("No\n");
		return 0;
	}
	for(i = (count+3)/2,j=count; i<=count*3/4;i++,j--)
	{
		if(S[i] != S[j])
		{
			flag = 1;
			break;
		}
	}
	if(flag == 0)
		printf("Yes\n");
	else
		printf("No\n");
	return 0;
}

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

int main(void){
    long long n;
    cin >> n;
    
    long long march[5] = {0};
    char input[12];
    long long i;
    for(i = 1; i <= n; i++){
        cin >> input;
        switch(input[0]){
            case 'M': march[0]++; break;
            case 'A': march[1]++; break;
            case 'R': march[2]++; break;
            case 'C': march[3]++; break;
            case 'H': march[4]++; break;
        }
    }
    
    long long ans = 0;
    long long j, k;
    for(i = 0; i <= 2; i++){
        for(j = i + 1; j <= 3; j++){
            for(k = j + 1; k <= 4; k++){
                ans += march[i] * march[j] * march[k];
            }
        }
    }
    
    cout << ans << endl;
    
    return 0;
}


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

void startup()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
}

int32_t main()
{
    startup();
	
		 int n;
		 cin>>n;
		 string s;
		 cin>>s;

		 int cntw=0;
		 int cntr=0;
		 for(int i=0 ; i<n ; ++i)
		 {
		 	if(s[i]=='W')
		 		cntw++;
		 	else
		 		cntr++;
		 }
		 if(cntw==cntr)
		 {
		 	int mid=n/2-1;
		 	int ans=0;
		 	for(int i=mid ; i>=0 ; --i)
		 	{
		 		if(s[i]=='W')
		 			++ans;
		 	}
		 	cout<<ans;
		 }
		 else 
		 {
		 	int ans=0;
		 	for(int i=cntr-1 ; i>=0 ; --i)
		 	{
		 		if(s[i]=='W')
		 			++ans;
		 	}
		 	cout<<ans;
		 }

    return 0;
}




Measured memory_bytes: 3780
main :: IO ()
main = do
    [a,b,c,d] <- (map read . words) <$> getLine
    print $ solve (a,b) (c,d)

solve :: (Int,Int) -> (Int,Int) -> Int
solve (a,b) (c,d)
    | a*b >= c*d    = a*b
    | otherwise     = c*d


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

#define int long long
#define fast_io(); ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define loop(i,a,b) for(int i=a;i<b;i++)
#define all(x) x.begin(),x.end()
#define us unordered_set
#define um unordered_map
#define ms multiset
#define mm multimap
#define pb push_back
#define pf push_front
#define ins insert
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define _max max_element
#define _min min_element
#define tc(T) int T; cin>>T; while(T--)
#define q(q) int q; cin>>q; while(q--)
#define pi 3.1415926535897932384626433832
const int pinf=((int)2e18);
const int ninf=((int)-2e18);
const int mod=1000000007;

using namespace std;

int power(int x,int n,int M)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)
        return power((x*x)%M,n/2,M);
    else
        return (x*power((x*x)%M,(n-1)/2,M))%M;
}

bool vowel(char c)
{
    return(c=='a' or c=='e' or c=='i' or c=='o' or c=='u' or c=='A' or c=='E' or c=='I' or c=='U' or c=='O');
}

int32_t main()
{
    fast_io();

    //FILE *fptr1=freopen("in.txt","r",stdin);
    //FILE *fptr2=freopen("out.txt","w",stdout);

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

    swap(a,b);
    swap(a,c);

    cout<<a<<" "<<b<< " "<<c;



    return 0;
}


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

typedef long long ll;
typedef pair<int,int> pii;

long long MOD = 1000000000 + 7;

int main(){
  cout << setprecision(10);
  int N; cin >> N;
  int K; cin >> K;

  int ans = 0;
  for(int i = 0; i < N ; i++){
    int tmp; cin >> tmp;
    ans += min(abs(tmp), abs(K - tmp));
  }
  cout << ans * 2 << endl;
}


Measured memory_bytes: 3636
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		if ((a == b && a != c) 
            || (a == c && a != b)
            || (b == c && b != a)) {
			System.out.println("Yes");
        } else {
			System.out.println("No");
        }
	}
}

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

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll pow(ll n, ll k)
{
	if (k == 0) return ll(1);
	if (k == 1) return ll(n);

	if (k % 2 == 1)
	{
		return pow(n,k-1) * n % MOD;
	}
	else
	{
		ll p = pow(n,k/2);
		return p * p % MOD;
	}
}

int main()
{
	COMinit();
	int n,k;
	cin >> n >> k;
	ll ans = 0;
	for (int i = 0; i <= min(n-1,k); ++i)
	{
		ans = (ans + COM(n,i) * COM(n-1,i) % MOD) % MOD;
		//cout << ans << endl;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 12160
N = int(input())
rest = [tuple(input().split()) for _ in range(N)]
def f1(l):
    s, p = l
    return s
def f2(l):
    s, p = l
    return int(p)
rest2 = sorted(rest, key = f2, reverse = True)
rest2.sort(key = f1)
dict = {}
for i in range(N):
    dict[rest[i]] = i+1
for j in rest2:
    print(dict[j])

Measured memory_bytes: 3064
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

struct edge{
    int to, cost;
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    vector<vector<edge>> v(n);
    rep(i,m){
        int l, r, d;
        cin >> l >> r >> d;
        l--; r--;
        edge e;
        e.to = r;
        e.cost = d;
        v[l].push_back(e);
        e.to = l;
        e.cost = -d;
        v[r].push_back(e);
    }
    vector<ll> dp(n, 1e18);
    queue<int> que;
    rep(i,n){
        if(dp[i] != 1e18) continue;
        dp[i] = 0;
        que.push(i);
        while(!que.empty()){
            int it = que.front();
            que.pop();
            for(auto e : v[it]){
                if(dp[e.to] == 1e18){
                    dp[e.to] = dp[it] + e.cost;
                    que.push(e.to);
                }
                else{
                    if(dp[e.to] != dp[it] + e.cost){
                        cout << "No" << endl;
                        return 0;
                    }
                }
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 9728
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

int gcd(int a, int b) {return b == 0 ? a : gcd(b, a % b);}

#define ll long long
#define pb push_back
#define ld long double
#define mp make_pair
#define F first
#define S second
#define pii pair<ll,ll> 

using namespace :: std;

const ll maxn=310;
const ll inf=1e9+800;
ll mod=1e9+7;

ll dp[maxn][maxn];
ll c[maxn][maxn];

inline void ok(ll &a){
	if(a>=mod)a-=mod;
}

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	ll n,k;
	cin>>n>>k>>mod;
	c[0][0]=1;
	for(ll i=1;i<maxn;i++){
		c[i][0]=1;
		c[i][i]=1;
		for(ll j=1;j<i;j++){
			c[i][j]=c[i-1][j]+c[i-1][j-1];
			ok(c[i][j]);
		}
	}
	for(ll i=0;i<=n;i++){
		for(ll j=1;j<=k;j++){
			if(i==0 || j==1){
				dp[i][j]=1;
			}else{
				dp[i][j]=dp[i][j-1];
				for(ll t=0;t<i;t++){
					dp[i][j]+=(((dp[t][j-1]*dp[i-t-1][j])%mod)*c[i][t])%mod;
					ok(dp[i][j]);
				}
			}
		}
	}

	cout<<dp[n][k];
}




















Measured memory_bytes: 1792
#include <cstdio>
#include <iostream>
#include <cassert>
#include <algorithm>    
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <cstring>
#include <cmath>
#include <bitset>
#define mk make_pair
#define eb emplace_back
#define eps 1e-8
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
// #define int long long
using namespace std;

typedef long double ld;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef unsigned long long ull; 
typedef vector<int> vii;
typedef vector<long double> vd;
const int inf = 1e9;
const int M = 1e9 + 7;
//__int128

const int maxn = 1005;
int vis[maxn], din[maxn], d[maxn];
std::vector<int> G[maxn], g[maxn];
int n, m;

bool flag[maxn];

/*void toposort(){
	queue<int> q;
	for(int i = 1; i <= n; i++) if(!in[i]) q.push(i), vis[i] = 1;//入度为0删去，且不用搜索
	while(!q.empty()){
		int u = q.front();
		q.pop();
		for(int i = head[u]; i; i = e[i].next){
			if(--in[e[i].v] == 0){
				q.push(e[i].v);
				vis[e[i].v] = 1;
			}
		}
	}
}*/
void topo() {
	queue<int> q;
	for(int i = 1; i <= n; ++i) {
		if(!din[i]) {
			q.push(i);
			flag[i] = 1;
		}
	}
	while(!q.empty()) {
		int u = q.front();
		q.pop();
		for(int i : g[u]) {
			if(--din[i] == 0) {
				q.push(i);
				flag[i] = 1;
			}
		}
	}
}

std::vector<int> res[maxn];

signed main()
{
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n >> m;
	for(int i = 0; i < m; ++i) {
		int u ,v;
		cin >> u >> v;
		G[u].eb(v);
		g[v].eb(u);
		din[u]++;
	}
	// topo();
	/*for(int i = 1; i <= n; ++i) {
		cout << i << ' ' << flag[i] << endl;
	}*/
	for(int i = 1; i <= n; ++i) if(!flag[i]) {
		memset(d, -1, sizeof(d));
		queue<int> q;
		q.push(i);
		d[i] = 0;
		bool ok = 0;
		while(!q.empty()) {
			int u = q.front();
			q.pop();
			for(int v : G[u]) {
				if(d[v] == -1) {
					q.push(v);
					d[v] = u;
				} else if(v == i){
					int x = u;
					while(x) {
						res[i].eb(x);
						x = d[x];
					}
					// cout << u << ' ' << (int)res[i].size() << endl;
					ok = 1;
				}
				if(ok) break;
			}
			if(ok) break;
		}
	}
	int tot = 100000, y = 0;
	for(int i = 1; i <= n; ++i) {
		int x = (int)res[i].size();
		if(x > 0 && x < tot) {
			tot = x;
			y = i;
		}
	}
	if(tot == 100000) cout << -1 << endl;
	else {
		cout << tot << endl;
		for(auto i : res[y]) {
			cout << i << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 4480
import sys
input = sys.stdin.readline
def ii(): return int(input())
def mi(): return map(int, input().rstrip().split())
def lmi(): return list(map(int, input().rstrip().split()))
def li(): return list(input().rstrip())
# template


S = li()
intS = map(int, S)

if int(''.join(S)) % sum(intS) == 0:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <algorithm>
#include <cassert>
#include <limits>
#include <numeric>
#include <type_traits>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <functional>
#include <utility>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <complex>

using namespace std;

typedef long long ll;
typedef vector<ll> vl;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)
int main(){
	ll N;
	cin >> N;
	vl p(N);
	REP(i, N){
		cin >> p[i];
	}
	ll count = 0;
	REP(j, N){
		if(p[j] != j + 1){
			count++;
			ll a = p[p[j]-1];
			p[p[j]-1] = p[j];
			p[j] = a;
		}
	}
	bool flag = true;
	REP(i, N-1){
		if(p[i+1] != p[i] + 1){
			flag = false;
		}
	}
	if(!flag){
		cout << "NO" << endl;
		return 0;
	}
	if(count == 1 || count == 0){
		cout << "YES" << endl;
	} else {
		cout << "NO" << endl;
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<sstream>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<cmath>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<numeric>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};

int main()
{

    int n;
    cin >> n;
    cout << n/3 << endl;

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <set>
using namespace std;

multiset<int> s;
multiset<pair<int, int>> s2;

int main()
{
	int n, m;
	long long ans = 0;

	scanf("%d %d", &n, &m);

	for (int i = 0; i < n; i++)
	{
		int a;
		scanf("%d", &a);
		s.insert(a);
	}

	for (int i = 0; i < m; i++)
	{
		int b, c;
		scanf("%d %d", &b, &c);
		s2.insert({ c, b });

	}

	for (int i = 0; i < n; i++)
	{
		if (s.empty())
		{
			int b = (--s2.end())->first;
			int b2 = (--s2.end())->second;
			ans += b;
			auto iter = s2.find({ b, b2 });

			s2.erase(iter);

			if (b2 > 1)
				s2.insert({ b, b2 - 1 });

			continue;
		}
		if (s2.empty())
		{
			int a = *(--s.end());
			ans += a;
			auto iter = s.find(a);
			s.erase(iter);
			continue;
		}
		
		int a = *(--s.end());
		int b = (--s2.end())->first;

		if (a > b)
		{
			ans += a;
			auto iter = s.find(a);
			s.erase(iter);
		}
		else
		{
			ans += b;
			int b2 = (--s2.end())->second;
			auto iter = s2.find({ b, b2 });

			s2.erase(iter);
			if (b2 > 1)
				s2.insert({ b, b2 - 1 });
		}
	}

	printf("%lld", ans);

	return 0;
}

Measured memory_bytes: 9600
H,W = map(int,input().split())
c = [list(map(int,input().split())) for i in range(10)]
import queue



d = c.copy()
for k in range(10):
    for i in range(10):
        for j in range(10):
            if d[i][j] > d[i][k]+d[k][j]:
                d[i][j] = d[i][k]+d[k][j]

cost = []
for i in range(10):
    cost.append(d[i][1])

ans = 0
for i in range(H):
    A = list(map(int,input().split()))
    for j in range(W):
        if A[j] != -1:
            ans += cost[A[j]]
print(ans)

Measured memory_bytes: 3952
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String input = ""; // Pの入力を受け取る変数
		String[] S_DATA = new String[4]; // 入力されたPのデータ(input)を配列に格納したもの
		Double[][] P = new Double[2][2];// S_DATAをDouble型に変換したもの
		int index = 0;// 二次元配列Pの１番目の配列番号を示す変数
		Double X_sa = 0.0; // 2点 P1(x1, y1), P2(x2, y2)におけるx1とx2の差
		Double Y_sa = 0.0;// 2点 P1(x1, y1), P2(x2, y2)におけるy1とy2の差
		Double distance = 0.0; //

		input = sc.nextLine();
		S_DATA = input.split(" ");
		for (int i = 0; i < S_DATA.length; i++) {
			index = i / 2; // i=0～1をP[0][]に i=1～2をP[1][]に格納する
							// P[0][]=P1,P[1][]=P2を表す
			if (i % 2 == 0) { // P[][0]にはx座標、P[][1]にはy座標を格納する
				P[index][0] = Double.parseDouble(S_DATA[i]);
			} else {
				P[index][1] = Double.parseDouble(S_DATA[i]);
			}
		}
		X_sa = Math.abs(P[0][0] - P[1][0]);
		Y_sa = Math.abs(P[0][1] - P[1][1]);
		distance = Math.sqrt(X_sa * X_sa + Y_sa * Y_sa);

		System.out.printf("%.5f", distance);

	}
}



Measured memory_bytes: 26496
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
int X, A;
  cin >> X >> A;
  if(X < A){
    cout << 0 << endl;
  }else{
    cout << 10 << endl;
  }

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<stdio.h>
#include<vector>
using namespace std;
#define rep(s,i,n) for(int i=s;i<n;i++)
#define c(n) cout<<n<<endl;
#define ic(n) int n;cin>>n;
#define sc(s) string s;cin>>s;
#define mod 1000000007
#define F first
#define s second
#define int long long		
int x[214514];
double y[214514];
string z[214514];
int sum[214514];
signed main(){
	ic(n)
	c((n*(n-1)/2))
}	


Measured memory_bytes: 2688
// writer: w33z8kqrqk8zzzx33
#include <bits/stdc++.h>
using namespace std;
 
#define iter(i, a, b) for(int i=(a); i<(b); i++)
#define rep(i, a) iter(i, 0, a)
#define rep1(i, a) iter(i, 1, (a)+1)
#define log(a) cerr<<"\033[32m[DEBUG] "<<#a<<'='<<(a)<<" @ line "<<__LINE__<<"\033[0m"<<endl
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define pb push_back
#define mp make_pair
 
using ll=long long;
using pii=pair<int, int>;
//#define int ll
const int MOD = 1000000007;

ll DP[20004];

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int H, N; cin >> H >> N;
	memset(DP, 15, sizeof DP);
	DP[0] = 0;
	while(N--) {
		int dam, cos; cin >> dam >> cos;
		iter(i, dam, 20000) DP[i] = min(DP[i], DP[i-dam]+cos);
	}
	ll mi = DP[20000];
	iter(v, H, 20000) mi = min(mi, DP[v]);
	cout << mi << endl;
}



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

int main()
{
    int N;
    std::cin >> N;
    bool a[N];
    for(int i=0; i<N; i++) scanf(" %d", &a[i]);

    bool ans[N];
    for(int i=N-1; i>=0; i--){
        if(i >= N/2){
            ans[i] = a[i]; continue;
        }
        int j = 2 * i + 1;
        bool sum = 0;
        while(j < N){
            sum ^= ans[j];
            //printf("%d %d %d\n", i, j, sum);
            j += i+1;
        }
        ans[i] = sum ^ a[i];
        //printf("ans = %d\n", ans[i]);
    }

    std::vector<int> b;
    for(int i=0; i<N; i++){
        if(ans[i] == true) b.push_back(i);
    }
    std::cout << b.size() << std::endl;
    for(auto&& itr = b.begin(); itr != b.end(); itr++) printf("%d ", (*itr)+1);
    if(!b.empty()) std::cout << std::endl;
}

Measured memory_bytes: 2040
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <math.h>
#include <cmath>
#include <set>   

using namespace std;


int main() {

	int n, k, l;
	int cnt = 0;
	vector<int> v;
	cin >> n >> k;

	for (int i = 0; i < n; i++) {
		cin >> l;
		v.push_back(l);
	}

	sort(v.begin(), v.end(), greater<int>());

	for (int i = 0; i < k; i++) {
		cnt += v[i];
	}
	
	cout << cnt << endl;
	return 0;


}

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

using namespace std;
using ll = long long;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define INF 9223372036854775807
#define all(x) (x).begin(), (x).end()

ll ts = 1000000007;

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

  vector<ll> a(n);
  REP(i, n) { cin >> a[i]; };

  bool can = true;
  REP(i, n) {
    if (a[i] % 2 == 0 && a[i] % 3 != 0 && a[i] % 5 != 0) {
      can = false;
    }
  }
  cout << (can ? "APPROVED" : "DENIED") << "\n";
}

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

int main(){
    int n,dp[41][401][401],ma,mb,ans=INF;
    cin >> n >> ma >> mb;
    vector<int> a(n),b(n),c(n);
    for(int i = 0;i < n;i ++){
        cin >> a[i] >> b[i] >> c[i];
    }
    fill(dp[0][0],dp[41][0],INF);
    dp[0][a[0]][b[0]] = c[0];
    for(int i = 1;i < n;i ++){
        for(int aw = 0;aw < 401;aw ++){
            for(int bw = 0;bw < 401;bw ++){
                if(aw-a[i]>0&&bw-b[i]>0) dp[i][aw][bw] = min(dp[i-1][aw-a[i]][bw-b[i]]+c[i],dp[i-1][aw][bw]);
                else dp[i][aw][bw] = dp[i-1][aw][bw];
            }
        }
        dp[i][a[i]][b[i]] = min(c[i],dp[i][a[i]][b[i]]);
    }
    for(int i = 1;i <= 400/max(ma,mb);i ++){
        ans = min(ans,dp[n-1][i*ma][i*mb]);
    }
    if(ans==INF) cout << -1 << endl;
    else cout << ans << endl; 
    return 0;
}

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

int main() {
    long long a,b,c;
    std::cin >> a >> b >> c;

    if (a % 2 && b % 2 && c % 2) {
        std::cout << std::min({ a*b, b*c, c*a }) << std::endl;
    } else {
        std::cout << 0 << std::endl;
    }

    return 0;
}

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

int main() {
  int ar[3];
  cin >> ar[0] >> ar[1] >> ar[2];
  sort(ar, ar+3);
  int ans = ar[2] * 10 + ar[0] + ar[1];
  cout << ans << endl;
  return 0;
}

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

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

   cout << 24 + 24 - m << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair<ll, ll>
#define F first
#define S second
const int MOD = 1000000007;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }
//sort(all(x))とするとソートできるよ
// 10^x は pow(10,(x)) 
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main(){
    LL H;cin >> H;
    LL ct = 0;
    while(H > 1){
        H /= 2;
        ct++;
    }
    ct++;

    //cout << ct << endl;

    LL ans = 0;
    rep(i,ct){
        ans += pow(2,i);
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int gcd(int a,int b);

int main(){
	int N, sum=0;
	scanf("%d",&N);
	for(int i=1; i<=N; i++){
	    for(int j=1; j<=N; j++){
	        for(int k=1; k<=N; k++){
	            sum+= gcd(i,gcd(j,k));
	           
	        }
	    }
	}

	 printf("%d\n",sum);
	return 0;
}

int gcd(int a, int b){
	int small;
	if(a<b){
	    small = a;
	}else{
		small = b;
	}
	int max = 1;
	for(int i=1; i<=small; i++){
	    if((a%i==0)&&(b%i==0)){
	        max = i;
	    }
	}
	//printf("a= %d b= %d max=%d\n",a,b,max);
	return max;
}

Measured memory_bytes: 1736
#include<bits/stdc++.h>
 
#define INF 100000000
 
using namespace std;
 
int main()
{
    string s;
    cin >> s;
    if(s[5] == '0'&&s[6] <= '4')
    {
        cout << "Heisei" << endl;
    }else{
        cout << "TBD" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main(){
    int A,B,C,X;
    cin >> A >> B >> C >> X;
    int ans = 0;
    for(int i = 0;i < A+1;i++){
        for(int j = 0;j < B+1;j++){
            for(int k = 0;k < C+1;k++){
                if(500 * i + 100 * j + 50 * k == X) ans++; 
            }
        }
    }
    cout << ans << endl;
}   

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <utility>
using namespace std;

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

typedef long long ll;

const int kMaxN = 100;
const int kInf = 1000000000;

int N;
int F[kMaxN][10];
int P[kMaxN][11];
int ans = -kInf;

bool opened = false;

void Bfs(int j, vector<int> c) {
  if (j < 10) {
    Bfs(j+1, c);

    opened = true;
    vector<int> c2(c);
    REP(i, N) { if (F[i][j]) { ++c2[i]; } }
    Bfs(j+1, c2);
    opened = false;
  } else if (opened) {
    int ans2 = 0;
    REP(i, N) { ans2 += P[i][c[i]]; }
    ans = max(ans, ans2);
  }
  return;
}

int main() {
  cin >> N;
  REP(i, N) { REP(j, 10) { cin >> F[i][j]; } }
  REP(i, N) { REP(j, 11) { cin >> P[i][j]; } }

  vector<int> c(N, 0);
  Bfs(0, c);

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<algorithm>
#include<math.h>
using namespace std;
 
template <class T> using V = vector<T>;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
 
 
#define FOR(i,a,b) for(ll i=(a);i<(ll)(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>(ll)(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(ll)(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 
 
ll sum(ll n) {
  ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
ll combi(ll n,ll m) {
  ll ans=1;
  rFOR(i,n,n-m){
    ans*=i;
  }
  FOR(i,1,m+1){
    ans/=i;
  }
  return ans;
}
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}
 
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  ll n;
  ci(n)
  vll A(n);
  vll B(n-1);
  ci(A[0])
  ll s=A[0];
  FOR(i,1,n){
    ll a;
    ci(a)
      s+=a;
    A[i]+=s;
  }
  
  FOR(i,0,n-1){
    B[i]=abs(s-A[i]-A[i]);
  }
  SORT(B);
  co(B[0])
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair


int main()
{
    int n;
    cin>>n;
   map<string ,int>m;
   while(n--){
   string s;
   cin>>s;
   m[s]++;
   }
   cout<<"AC x "<<m["AC"]<<endl;

   cout<<"WA x "<<m["WA"]<<endl;

   cout<<"TLE x "<<m["TLE"]<<endl;

   cout<<"RE x "<<m["RE"]<<endl;


}



Measured memory_bytes: 3640
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <queue>
#include <map>
#include <stack>
#include <bitset>
#include <numeric> //lcm
#include <iomanip> //double精度 setprecision

using namespace std;

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = n-1; i >= 0; --i)
#define rep1(i,n) for(int i = 1; i <= (n); ++i)
#define rrep1(i,n) for(int i = (n); i >= 1; --i)
#define REP(i,n,m) for(int i = (n); i < (m); ++i)
#define all(vec) (vec).begin(),(vec).end()

#define debug(vec) for(auto v : vec) cerr << v << " "; cerr << endl;
#define debug2D(vec2D) for(auto vec : vec2D) { for (auto v : vec) cerr << v << " "; cerr << endl; } 
#define debugP(vec) for(auto v : vec) cerr << "(" << v.first << "," << v.second << ") "; cerr << endl;
#define debug2DP(vec2D) for(auto vec : vec2D) { for (auto v : vec) cerr << "(" << v.first << "," << v.second << ") "; cerr << endl; } 

const char en = '\n';

typedef long long ll;

constexpr ll INF = 1000000000; //10^10
//const ll MOD = 998244353;
constexpr ll MOD = 1000000007;

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

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

	ll n; cin >> n;
	vector<ll> a(n), b(n);
	rep(i, n) cin >> a[i] >> b[i];

	vector<ll> sa(n), sb(n);
	rep(i, n) {
		sa[i] = a[i];
		sb[i] = b[i];
	}
	sort(all(sa)); sort(all(sb));

	if (n % 2) {
		cout << sb[n / 2] - sa[n / 2] + 1 << endl;
	}
	else {
		cout << (sb[n / 2] + sb[n / 2-1]) - (sa[n / 2] + sa[n / 2 - 1]) + 1 << endl;
	}
}



Measured memory_bytes: 9504
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MOD 1000000007
#define INF (1<<29)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

Int gin[2160];
Int gall[2160];
Int a[2160];
Int res;
Int n, k;
int main(){
    cin >> n >> k;
    for(int i = 0;i < n;i++){
        cin >> a[i];
        for(int j = 0;j < i;j++){
            if(a[j] > a[i])gin[i]++;
        }
    }
    for(int i = 0;i < n;i++){
        for(int j = 0;j < n;j++){
            if(a[j] > a[i])gall[i]++;
        }
    }

    for(int i = 0;i < n;i++){
        res += gall[i] * ((k*(k-1))/2%MOD) % MOD;res %= MOD;
        res += k * gin[i] % MOD;res %= MOD;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define arep(a,i,n) for(ll i=(a);i<(n);i++)
#define rep(i,n) for(ll i=0;i<(n);i++)
#define cinf(x,n) for(ll i=0;i<(n);i++)cin>>x[i];
#define coutf(x,n) for(ll i=0;i<(n);i++)cout<<x[i]<<endl;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

using namespace std;

int main(){
	string s;
	cin >> s;
	while(true){
		s.erase(s.begin()+s.length()-1);
		s.erase(s.begin()+s.length()-1);
		if(s.substr(0,s.length()/2)==s.substr(s.length()/2,s.length()/2)){
			cout << s.length() << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 3564
#include <stdio.h>

int main(void)
{
	int i, j;
	int st;
	int sta;
	int pair[13];
	int two, three, four;
	int card[5];
	int t;
	
	while (scanf("%d,%d,%d,%d,%d", &card[0], &card[1], &card[2], &card[3], &card[4]) != EOF){
		for (i = 0; i < 5; i++){
			for (j = 0; j < 4 - i; j++){
				if (card[j] > card[j + 1]){
					t = card[j + 1];
					card[j + 1] = card[j];
					card[j] = t;
				}
			}
		}
		for (i = 0; i < 13; i++){
			pair[i] = 0;
		}
		st = 0; sta = 0;
		two = 0; three = 0; four = 0;
		for (i = 0; i < 4; i++){
//			printf("%d", card[i]);
			pair[card[i] - 1]++;
			if (card[i + 1] - card[i] == 1){
				st++;
			}
			if (card[i] == i + 9 || card[i] == 1){
				sta++;
			}
		}
		if (card[i] == i + 9){
			sta++;
		}
//		printf("%d %d\n", card[i], sta);
		pair[card[i] - 1]++;
		if (card[i] == i + 1){
			sta++;
		}
		for (i = 0; i < 13; i++){
//			printf("%d", pair[i]);
			if (pair[i] == 2){
				two++;
			}
			if (pair[i] == 3){
				three++;
			}
			if (pair[i] == 4){
				four++;
			}
		}
//		printf("\n");
//		printf("%d %d %d\n", two, three, four);
		if (four == 1){
			printf("four card\n");
		}
		else if (two == 1 && three == 1){
			printf("full house\n");
		}
		else if (st == 4 || sta == 5){
			printf("straight\n");
		}
		else if (three == 1){
			printf("three card\n");
		}
		else if (two == 2){
			printf("two pair\n");
		}
		else if (two == 1){
			printf("one pair\n");
		}
		else {
			printf("null\n");
		}
	}
	
	return (0);
}

Measured memory_bytes: 580