akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <numeric>

using namespace std;

int main(){
    unsigned int n;
    cin >> n;
    vector<unsigned int> a1(n), a2(n);
    for(int i = 0; i < n; ++i) cin >> a1[i];
    for(int i = 0; i < n; ++i) cin >> a2[i];

    unsigned int ans = accumulate(a2.begin(), a2.end(), 0) + a1[0];
    unsigned int sum = ans;
    for(int i = 0; i < n - 1; ++i){
        sum -= a2[i];
        sum += a1[i + 1];
        ans = max(ans, sum);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {

    static int mod = (int) (1e9 + 7);

    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        int n = in.nextInt();
        int k = in.nextInt();
        int[] val = new int[n];
        for (int i = 0; i < n; i++) {
            val[i] = in.nextInt();
        }

        long[] dp = new long[k + 1];
        dp[0] = 1;
        for (int i = 0; i < n; i++) {
            long[] dp2 = new long[k + 1];
            for (int j = k; j >= 0; j--) {
                int l = j + 1;
                int r = Math.min(j + val[i], k);
                if (l <= r) {
                    dp2[l] = (dp2[l] + dp[j]) % mod;
                    if (r + 1 <= k) {
                        dp2[r + 1] = (dp2[r + 1] - dp[j]) % mod;
                        if (dp2[r + 1] < 0) {
                            dp2[r + 1] += mod;
                        }
                    }
                }
            }
            long pref = 0;
            for (int j = 0; j <= k; j++) {
                pref = (pref + dp2[j]) % mod;
                dp[j] = (dp[j] + pref) % mod;
            }
        }

        out.println(dp[k] % mod);
        out.close();
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

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

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

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

    }
}


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

using namespace std;

/* g++ -g -fsanitize=address -lasan -std=c++11 -Dfoo_ */

/* freopen("input.txt", "rt", stdin); */
/* freopen("output.txt", "wt", stdout); */

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

const int inf = 1e9;
const int mod = 1e9+7;
const int maxn = 1e5+5;

int solve(vector<PII> A)
{
    sort(ALL(A));
    map<PII,int> cnt;
    const int n = A.size();
    FOR(i,0,n) FOR(j,i+1,n) {
        const int a = A[i].first  - A[j].first;
        const int b = A[i].second - A[j].second;
        if (a || b)
            cnt[PII(a,b)]++;
    }
    int ans = n;
    FOR_ALL(x,cnt)
        ans = min(ans, n - x->second);
    return ans;
}

int main()
{
#ifdef foo_
    freopen("foo", "rt", stdin);
#endif
    ios::sync_with_stdio(false);
    int n;
    while (cin >> n) {
        vector<PII> A(n),B(n);
        FOR(i,0,n) 
            cin >> A[i].first >> A[i].second;
        B = A;
        FOR_ALL(b,B)
            swap(b->first,b->second);
        const int a = solve(A);
        const int b = solve(B);
        cout << min(a,b) << endl;
    }
    return 0;
}


Measured memory_bytes: 384
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();
        int d = sc.nextInt();

        if(a*b > c*d){
            System.out.println(a*b);
        } else if(c*d > a*b){
            System.out.println(c*d);
        } else {
            System.out.println(a*b);
        }
    }

    public static void printArray(int[] array){
        for(int i=0; i<array.length; i++){
            if(i == array.length){
                System.out.println(array[i]);
            } else {
                System.out.print(String.format("%d ", array[i]));
            }
        }
    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define all(vec) vec.begin(),vec.end()
#define mp make_pair
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
const ll INF=1LL<<30;
const ll LINF=1LL<<60;
const double eps=1e-5;
const ll MOD=1000000007LL;
template<typename T>void chmin(T &a,T b){a=min(a,b);};
template<typename T>void chmax(T &a,T b){a=max(a,b);};
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
int main(){
    int n,a,b;cin>>n>>a>>b;
    cout<<min(a,b)<<" "<<max(0,a+b-n)<<endl;   
}

Measured memory_bytes: 764
#include<stdio.h>

int main(void){
    int place,i,j,n,flag;
    char p[101];
    //int a[101];

    while(scanf("%s",p)){
        if(p[0]=='#'&&p[1]=='\0') break;
        for(n=0;n<101;n++){
            if(p[n]=='\0') break;
            //a[n]=p[n];
        }

       // for(i=0;i<n;i++){
         //   printf("%c",p[i]);
        //}
        //puts("");

        //for(i=0;i<n;i++){
        //   printf("%d ",a[i]);
        //}

        place=0;
        flag=0;

        for(i=0;i<n;i++){
            switch(place){
                case 0:
                    if(p[i]=='0') place=1;
                    if(p[i]=='1') place=2;
                    break;
                case 1:
                    if(p[i]=='0') flag=1;
                    if(p[i]=='1') place=3;
                    break;
                case 2:
                    if(p[i]=='0') place=1;
                    if(p[i]=='1') flag=1;
                    break;
                case 3:
                    if(p[i]=='0') place=5;
                    if(p[i]=='1') place=4;
                    break;
                case 4:
                    if(p[i]=='0') place=2;
                    if(p[i]=='1') place=1;
                    break;
                case 5:
                    if(p[i]=='0') place=4;
                    if(p[i]=='1') place=2;
                    break;
            }
            if(flag) break;
        }
        if(place==4&&flag==0) puts("Yes");
        else puts("No");

    }
    return 0;
}

Measured memory_bytes: 524
#include <bits/stdc++.h>
#define F first
#define S second
#define mp make_pair
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pi;
ll n, w, wt[105], v[105], ans, sumv;
ll const inf = 1e18+5;
bool tog;
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	cin >> n >> w;
	for (ll i = 1; i <= n ; i++)cin >> wt[i] >> v[i];
	for (ll i=  1; i <= n; i++)sumv += v[i];
	//dp[i] stores min weight to achieve i val
	ll dp[sumv+5];
	for (ll i = 0; i<=sumv+4; i++)dp[i] = inf;
	dp[0] = 0;
	for (ll i = 1; i <= n; i++){
		for (ll j = sumv-v[i]; j >= 0; j--){
			//~ if (sumv-v[i] < 0)continue; 
			dp[j+v[i]] = min(dp[j+v[i]], dp[j]+wt[i]);
			//you cannot go from 0 to sumv-v[i] because you may modify dp[j] and then consider the same item again
			//for all possible j, you try to make the min weight with weight i
		}
	}
	for (ll i= 0; i<= sumv; i++){
		if (dp[i] <= w)ans = max(ans, i);
	}
	cout << ans;
}


Measured memory_bytes: 1024
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<deque>
#include<map>
#include<queue>
using namespace std;
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
static const ll maxLL = (ll)1 << 62;
const int mod=1000000007;
int dy[]={-1,0,1,0};
int dx[]={0,1,0,-1};

//#define int ll

int N,M,R;
int r[8];
int d[500][500];

void warshall_floyd(int n) { // nは頂点数
  for (int i = 0; i < n; i++)      // 経由する頂点
    for (int j = 0; j < n; j++)    // 開始頂点
      for (int k = 0; k < n; k++)  // 終端
        d[j][k] = min(d[j][k], d[j][i] + d[i][k]);
}

signed main(){
    cin>>N>>M>>R;
    rep(i,0,R)cin>>r[i],r[i]--;
    rep(i,0,N)rep(j,0,N){
        if(i!=j)d[i][j]=1e9;
    }
    rep(i,0,M){
        int a,b,c;
        cin>>a>>b>>c;
        a--,b--;
        d[a][b]=min(d[a][b],c);
        d[b][a]=min(d[b][a],c);
    }
    rep(i,0,N)d[i][i]=0;
    warshall_floyd(N);
    sort(r,r+R);
    int ans=1e9;
    
    do{
        int now=0;
        rep(i,0,R-1){
            now+=d[r[i]][r[i+1]];
        }
        ans=min(ans,now);
    }while(next_permutation(r,r+R));
    
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
typedef long long ll;
const ll MOD=1000000007;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }

int main(void){
    // Your code here!
    int n;
    cin >> n;
    string s;
    cin >> s;
    int res = 0;
    for ( int i = 1; i< n-1;i++){
        map<char ,int> mp{};
        for (int j = 0;j<i;j++){
            mp[s[j]]=1;
        }
        for (int j = i;j<=n-1;j++){
            if (mp[s[j]] ==1) mp[s[j]] =2;
        }
        int cur = 0;
        for (auto x :mp){
            if (x.second>=2) cur++; 
        }
        res = max(res,cur);
    }
    cout << res << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) FOR(i,0,b)
#define INF mugen
#define dump(x) cerr<<#x<<"="<<x<<endl
#define all(a) (a).begin(),(a).end()
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<vii> viii;
typedef pair<int,int> P;
template <class T> void chmin(T & a, T const & b) { if (b < a) a = b; }
template <typename T>
string to_string(const T &n){ostringstream stm;stm << n;return stm.str();}
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
using ll = long long;
const ll mod = LLONG_MAX;
 
signed main(){
 
    int a,b,t;
    cin>>a>>b>>t;
    cout<<(t/a)*b<<endl;
}

Measured memory_bytes: 764
#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 m, d;cin >> m >> d;
	ll ans = 0;
	for(int i = 4;i <= m;i++){
		for(int j = 1;j <= d;j++){
			int a = j % 10;
			int b = j / 10;
			if(a > 1 && b > 1 && a * b == i){
				ans++;
			}
		}
	}

	cout << ans << endl;

	return 0;
}


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

int main()
{
	bool t = false;
	int main_count=0;
	int N, M;
	string C[50];
	cin >> N >> M;
	int Ans = 0;
	for (int count = 0; count < N; count++)
	{
		cin >> C[count];
	}
	for (int count=1;count<(N-1);count++)
	{
		for (int count_2 = (count+1); count_2 < N;count_2++)
		{
			char color = 'W';
			for (int count_3=1;count_3<=N;count_3++)
			{
				if ((count_3 > 0) && (count_3 <= count))
				{
					color = 'W';
				}
				else
				{
					if ((count_3>count)&&(count_3<=count_2))
					{
						color = 'B';
					}
					else
					{
						color = 'R';
					}
				}
				for (int count_4 = 1; count_4 <= M; count_4++)
				{					
					if (C[count_3-1][count_4-1] != color)
					{
						main_count++;
					}
				}
			}
			if (t == false)
			{
				Ans = main_count;
				t = true;
			}
			else
			{
				if (main_count < Ans)
				{
					Ans = main_count;
				}
				main_count = 0;
			}
		}
	}
	cout << Ans << endl;
	cin>>Ans;
    return 0;
}

Measured memory_bytes: 3096
#include<stdio.h>
#include <string.h>
#include <stdlib.h>
int main()
{

        int a;
        int b;
        int h;
        int sum1;


	// 個数のの入力
        sum1 = 0;
        scanf("%d %d %d",&a,&b,&h);

        sum1 = ((a + b) * h) / 2; 


	printf("%d\n",sum1);

        
	return 0;
}

Measured memory_bytes: 128
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
using Graph = vector<vector<int>>;
typedef long long lint;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ldouble;
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<ull> ulvec;
typedef vector<double> dvec;
typedef vector<pair<int,int>> pvec;
typedef vector<pair<ll,ll>> plvec;
typedef vector<tuple<ll,ll,ll>> tvec;
typedef vector<string> svec;
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(){
    int n,m;
    cin>>n>>m;
    vec p(m);
    svec s(m);
    rep(i,m)cin>>p[i]>>s[i];
    set<int> st;
    rep(i,m){
        if(s[i]=="AC")st.insert(p[i]);
    }
    vector<stack<int>> que(n);
    rep(i,m){
        if(!que[p[i]-1].empty()&&que[p[i]-1].top()==2)continue;
        else if(s[i]=="WA"){
            que[p[i]-1].push(1);
        }else que[p[i]-1].push(2);
    }
    ll cnt=0;
    rep(i,n){
        if(que[i].size()>0){
            if(que[i].top()==2)cnt+=que[i].size()-1;
        }
    }
    cout<<st.size()<<' '<<cnt<<endl;
}

Measured memory_bytes: 77952
s=input()
count=0
ans=0

for i in range(len(s)):
  if s[i]=="A" or s[i]=="T" or s[i]=="G" or s[i]=="C":
    count+=1
  else:
    if ans<count:
      ans=count
    count=0
if ans<count:
      ans=count
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int  main(){
long long A,B,K;
cin>>A>>B>>K;
if(K<=A){
    cout<<A-K<<" "<<B<<endl;
}
else if(K<=A+B){
cout<<0<<" "<<A+B-K<<endl;
}
else
cout<<0<<" "<<0<<endl;
}


Measured memory_bytes: 256
//#pragma GCC optimize("O3")
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#define int long long
#define x first
#define y second
#define pb push_back

#define speed ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;

template<class T> ostream& operator<<(ostream& cout,vector<T> V)
{cout<<"[ ";for(auto v:V)cout<<v<<' ';return cout<<']';}
template<class L,class R> ostream& operator<<(ostream& cout,pair<L, R> P)
{return cout<<'('<<P.x<<','<< P.y<<')';}

signed main()
{
	speed
	char c;cin>>c;
	cout<<(++c)<<"\n";
}

Measured memory_bytes: 256
N = int(input())
nums = input().split()
costs = []
if nums.count(nums[0]) != len(nums):
    for i in range(-100, 101):
        sum = 0
        for num in nums:
            sum += (int(num) - i) ** 2
        costs.append(sum)
    ans = min(costs)
else:
    ans = 0
print(ans)

Measured memory_bytes: 3060
import java.util.*;
import java.io.*;
import java.lang.*;
import java.math.*;
 
public class Main {
	public static void main(String[] args) throws Exception {
		FastScanner sc = new FastScanner();
		long n = sc.nextLong(), m = sc.nextLong();
		if(n == 1 || m == 1) {
			if(n == 1 && m == 1) {
				System.out.println(1); return;
			}
			System.out.println(Math.max(n, m) - 2);
		} else{
			System.out.println(n * m - (n+m-2)*2);
		}
	}
	static class FastScanner {
		public BufferedReader reader;
		public StringTokenizer tokenizer;
 
		public FastScanner() {
			reader = new BufferedReader(new InputStreamReader(System.in), 32768);
			tokenizer = null;
		}
 
		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}
 
		public int nextInt() {
			return Integer.parseInt(next());
		}
 
		public long nextLong() {
			return Long.parseLong(next());
		}
 
		public double nextDouble() {
			return Double.parseDouble(next());
		}
 
		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
 
	}
}

Measured memory_bytes: 23124
#include<iostream>
#include<algorithm>
#include<cassert>
#include<vector>
#include<fstream>
#include<string>
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#include<queue>
#include<map>

using namespace std;
#define REP(m,n) for(int i=m;i<n;++i)
#define REPj(m,n) for(int j=m;j<n;++j)
#define INF 10000000000000000
#define MOD 1000000007
#define ll long long
#define mp make_pair

int main() {
	int n, m;
	int ans = 1;
	cin >> n;
	map<int, int>a;
	REP(0, n) {
		int tmp;
		cin >> tmp;
		a[tmp]++;
	}
	cin >> m;
	REP(0, m) {
		int tmp;
		cin >> tmp;
		if (a[tmp] == 0) {
			cout << "NO" << endl;
			return 0;
		}
		else {
			a[tmp]--;
		}
	}
	cout << "YES" << endl;
	return 0;
}

Measured memory_bytes: 9600
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string s = Console.ReadLine();
		int ans = 0;
		int N = s.Length;
		for(var i=0;i<s.Length/2;i++){
				if(s.Substring(i,1)!=s.Substring(N-1-i,1)){
					ans++;
				}
		}
		Console.WriteLine(ans);
	}
}

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

int main(){
	int h,w;
	int min[3];
	while(true){
		cin>>h>>w;
		if(h==0 && w==0){
			break;
		}
		min[0]=1000000000;
		min[1]=1000000000;
		min[2]=1000000000;
		for(int i=1;i<=250;i++){
			for(int j=1;j<=250;j++){
				if((i*i+j*j>h*h+w*w && i<j) && min[0]>i*i+j*j){
					min[0]=i*i+j*j;
					min[1]=i;
					min[2]=j;
				}
				else if((i*i+j*j>h*h+w*w && i<j) && (min[0]==i*i+j*j && min[1]>i)){
					min[0]=i*i+j*j;
					min[1]=i;
					min[2]=j;
				}
				else if(((i*i+j*j==h*h+w*w && i<j) && (h!=i || w!=j)) && h<i){
					if(min[1]>i || min[0]>h*h+w*w){
						min[0]=i*i+j*j;
						min[1]=i;
						min[2]=j;
					}
				}
			}
		}
		cout<<min[1]<<' '<<min[2]<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int l, r,d;
    cin>>l>>r>>d;
    int cnt = 0;
    for(int i = l ; i<=r; i++)
    {
        if(i%d==0)
        {
            cnt++;
        }
    }
    cout<<cnt<<endl;
}


Measured memory_bytes: 3616
/*
 * =====================================================================================
 *
 *       Filename:  main.cpp
 *
 *    Description:  standard template
 *
 *        Version:  1.0
 *        Created:  30/07/2019 16:17:02
 *       Revision:  none
 *       Compiler:  gcc
 *
 *         Author:  Luigi Berducci (), berducci.1647887@studenti.uniroma1.it
 *        Company:  University of Rome La Sapienza
 *
 * =====================================================================================
 */

#include <iostream>
#include <algorithm>
#include <vector>
#include <array>
#include <set>
#include <string>
#include <map>

using namespace std;
int N;
vector<string> V;
vector<bool> T;
map<array<int,26>, long int> M;

int main ( int argc, char *argv[] ) {
    cin >> N;
    
    for ( int i = 0; i < N; i += 1 ){
        array<int, 26> alpha;
        for(int i=0; i<26; i++){
            alpha[i] = 0;
        }
        for(int a=0; a<10; a++){
            char ai;
            cin >> ai;
            if(ai-'a'<0 || ai-'a'>25)   return -1;
            alpha[ai-'a']++;
        }
        if(M.find(alpha)==M.end()){
            M.insert(make_pair(alpha, 1));
        }else{
            M[alpha] = M[alpha]+1;
        }
    }
    long int k=0;
    for(auto v : M){
        k = k + v.second*(v.second-1)/2;
    }
    cout << k << endl;
    return EXIT_SUCCESS;
}				/* ----------  end of function main  ---------- */


Measured memory_bytes: 15872
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
	int h, n;
	cin>>h>>n;
	vector<int>v(n);
	for(int i=0;i<n;++i){
		cin>>v[i];
	}
	sort(v.begin(),v.end());
	for(int i=0;i<n;++i){
		h -= v[i];
	}
	if(h <= 0) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}


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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }

const int maxn = 1e6 + 7;

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);

    string s; cin >> s;
    int n = (int)s.size();

    ll tot = 0LL;
    for (int i = 0; i < n; i++) {
        tot += (s[i]-'0');
    }

    if (tot%9LL == 0LL) out("Yes");
    out("No");
    
    
    return 0;
}


Measured memory_bytes: 3916
#include<stdio.h>
#include<string.h>
int main(){
    int d;
    int eveday;
    char christmas[1024]="Christmas";
    char eve[]=" Eve";
    const int christmasday=25;
    scanf("%d",&d);
    eveday=christmasday-d;
    while(eveday){
        strcat(christmas,eve);
        eveday--;
    }
    printf("%s\n",christmas);
    return 0;
}

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

int main(){
  int N;
  cin>>N;
  vector<string> S(N);
  for (int i=0; i<N; i++) cin>>S[i];
  int num[50][27] = {};
  for (int i=0; i<N; i++){
    for (int j=0; j<S[i].size(); j++){
      int id = S[i][j]-'a';
      num[i][id]++;
    }
  }
  string ans="";
  for (int j=0; j<27; j++){
    int mn = num[0][j];
    for (int i=0; i<N; i++)
      mn = min(mn,num[i][j]);
    for (int i=0; i<mn; i++)
      ans += 'a' + j;
  }
  cout<<ans<<endl;
  return 0;
}


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

#define FI(i,a,b) for(int i=(a);i<=(b);i++)
#define FD(i,a,b) for(int i=(a);i>=(b);i--)

#define LL long long
#define Ldouble long double
#define PI 3.14159265358979323846264338327950288419

#define PII pair<int,int>
#define PLL pair<LL,LL>
#define mp make_pair
#define fi first
#define se second

using namespace std;

int n, s[100005];

int main(){
	scanf("%d", &n);
	FI(i, 1, n) scanf("%d", &s[i]);
	sort(s + 1, s + n + 1);
	reverse(s + 1, s + n + 1);
	int id = n;
	FI(i, 1, n) if(s[i] < i){
		id = i - 1;
		break;
	}
	
	if(id == n || s[id + 1] <= id){
		if((s[id] - id) & 1){
			printf("First\n");
			return 0;
		}
	}
	
	int fix = id;
	while(id < n && s[id + 1] == fix) id++;
	if((id - fix) & 1){
		printf("First\n");
		return 0;
	}
	printf("Second\n");
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vb=vector<bool>;
using vvb=vector<vb>;
using vc=vector<char>;
using vvc=vector<vc>;
using pii = pair<int,int>;
using pil = pair<int,ll>;
using pli = pair<ll,int>;
using pll = pair<ll,ll>;
using tiii = tuple<int,int,int>;
using vpii = vector<pii>;
using vpil = vector<pil>;
using vpli = vector<pli>;
using vpll = vector<pll>;

#define rep(i, n) for(int i=0;i<(int)n;i++)
#define rep2(i, s, n) for(int i=(s);i<(int)n;i++)
int INF=1e9+7;

ll ans=0;
string S;
int siz;

void dfs(int x,ll s,ll nows) {
  if(x==siz) {
    ans+=s+nows;
    return;
  }
  dfs(x+1,s,nows*10+(S[x]-'0'));
  dfs(x+1,s+nows,S[x]-'0');
}

int main() {
  cin >> S;
  siz=S.size();
  
  dfs(1,0,S[0]-'0');
  cout << ans << endl;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,k,a,minbox;
  cin >> n >> k;
  vector<int> ans;
  pair<int, int> p[n];
  for(int i=0;i<n;i++){
    cin >> a;
    p[i] = make_pair(a, i+1);
  }
  sort(p, p+n);
  for(int i=n-1;i>=0;i--){//大きい方から全部見る -> 必ずk-1できる
    ans.push_back(p[i].second);
    p[i].first--;
  }
  k--;
  minbox=p[0].second;
  /*
    最後に見た箱に絶対宝石はないので他の箱を全部見ると必ずk-1できる(できそう)
    これを繰り返すと良さそう？？？？
  */
  for(int i=k;i>=0;i--){
    int x;
    sort(p, p+n);
    for(int j=n-1;j>=0;j--){
      if(p[j].second!=minbox){;
        if(p[j].first == 0){
          cout << -1 << endl;
          return 0;
        }
        x=p[j].second;
        ans.push_back(p[j].second);
        p[j].first--;
      }
    }
    minbox=x;
  }
  cout << ans.size() << endl;
  for(size_t i=0;i<ans.size();i++){
    cout << ans[i] << ((i==ans.size()-1)?'\n':' ');
  }
  return 0;
}


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

using ll = long long;
const int MOD = 1e9 + 7;

void add_self(ll& a, ll b) {
    a += b;
    if(a > MOD) {
        a -= MOD;
    }
}

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

    vector<ll> dp(1 << n);
    dp[0] = 1;
    for(int mask = 0; mask < (1 << n); mask++) {
        int i = __builtin_popcount(mask);
        for(int k = 0; k < n; k++) {
            if(!(mask & (1 << k)) && a[i][k]) {
                add_self(dp[mask ^ (1 << k)], dp[mask]);
            }
        }
    }
    cout << dp[(1 << n) - 1] << endl;
}


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

int main(){
    int N;
    cin >> N;
    vector<long int> H(N);
    for (int i = 0; i < N;i++)
        cin >> H[i];
    int max = 0;
    bool check = true;
    int count = 0;
    for (int i = N - 1; i > 0;i--){
        if(H[i] <= H[i-1]){
            check = true;
            count++;
        }else{
            check = false;
        }
        if(check == false){
            count = 0;
            check = true;
        }
        if(count > max)
            max = count;
    }
    cout << max << endl;
    return 0;
}

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

int main(){
    int n, l;
    cin >> n >> l;
    vector<string> v;
    for(int i = 0; i < n; i++)
    {
        string s;
        cin >> s;
        v.push_back(s);
    }
    sort(v.begin(), v.end());
    for(auto&& i : v)
    {
        cout << i;
    }
    cout << "\n";
}

Measured memory_bytes: 256
// #include <iostream>
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

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

    vector<int> v(n);

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

    sort(v.begin(), v.end());
    cout << v.back() - v.front() << endl;

    return 0;
}


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

int main() {
  ll k;
  cin >> k;
  vl v = {1, 1, 1, 2, 1, 2, 1, 5,  2, 2, 1, 5, 1, 2, 1, 14,
          1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  cout << v[k - 1] << endl;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define Phuong_ ios_base::sync_with_stdio(0); cin.tie(0);
#define REP(i,a,b) for(int i=a; i<=b; ++i)

/// easy access -------------
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
typedef pair<int,int> pi;
typedef tuple<int, int, int> tp;
typedef vector<vector<int>> vv;
///-------------------------

int main()
{
    Phuong_; /// <3333
    int a[3][3];
    for(int i=0; i<3; ++i){
        for(int j=0; j<3; ++j) {
            cin >> a[i][j];
        }
    }
    bool b[3][3];
    memset(b, false, sizeof(b));
    int n;
    cin >> n;
    for(int i=0; i<n; ++i) {
        int u;
        cin >> u;
        for(int i=0;i<3;++i){
            for(int j=0; j<3; ++j) {
                if (a[i][j] ==u){
                    b[i][j]=true;
                }
            }
        }
    }
    bool ans = false;
    for(int i=0; i<3; ++i){
        bool f1= true;
        bool f2= true;
        for(int j=0; j<3; ++j){
            f1 = f1&b[i][j];
            f2 = f2&b[j][i];
        }
        if (f1 || f2) ans = true;
    }
    if (b[0][0] && b[1][1] && b[2][2]) ans=true; else
    if (b[0][2] && b[1][1] && b[2][0]) ans=true;
    if(ans) cout<<"Yes"; else cout << "No";
    return 0;
}


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

int main() {
	int A,B;
	cin >> A >> B;
  if(A == B){
    cout << 2 * A << endl;
  } else {
    cout << max(A,B) * 2 -1 << endl;
  }
}

Measured memory_bytes: 256
#!/usr/bin/env ruby

require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.chomp.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

N, M = get_ints
L = []
R = []
M.times do |i|
  L[i], R[i] = get_ints
end

min = 1
max = 10**5
M.times do |i|
  min = L[i] if L[i] > min
  max = R[i] if R[i] < max
end

ans = max - min + 1
puts ans < 0 ? 0 : ans



Measured memory_bytes: 16116
n = gets.strip.to_i
abc = (n-1).times.map { gets.strip.split.map(&:to_i) }
q, k = gets.strip.split.map(&:to_i)
xy = readlines.map {|line| line.strip.split.map(&:to_i) }

graph = Array.new(n+1) { [] }
abc.each do |s, g, cost|
  graph[s] << [g, cost]
  graph[g] << [s, cost]  
end

#p graph

def tree_distance_from(start, graph)
  distance = Array.new(graph.length, -1)

  stack = [[start, 0]]

  until stack.empty? do
    current, current_cost = stack.pop
    distance[current] = current_cost
    graph[current].each do |to, cost|
      stack << [to, current_cost + cost] if distance[to] == -1
    end
  end

  distance
end

distance_from_k = tree_distance_from(k, graph)

xy.each do|x, y|
  p distance_from_k[x]+distance_from_k[y]
end



Measured memory_bytes: 58972
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include<algorithm>
#include<sstream>
#include<iomanip>


using namespace std;

typedef long long ll;

const ll MOD_CONST = 1000000007;
const ll BIG_NUM = 1000000000000000000;



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

	vector<vector<int>> s(2*k+1,vector<int>(k+1));

	for (int i = 0; i < n;i++) {
		int x, y;
		string c;
		cin >> x >> y >> c;
		x %= 2 * k;
		y %= 2 * k;
		if (y >= k) {
			y = (y + k) % (k);
			x = (x + k) % (2 * k);
		}
		if (c == "B") {
			x = (x + k) % (2 * k);
		}
		x++;
		y++;
		s[x][y]++;
	}


	
	for (int i = 1; i <=2*k; i++) {
		for (int j = 1; j <=k;j++) {
			s[i][j] += s[i][j - 1];
		}
	}
	for (int i = 1; i <=2*k; i++) {
		for (int j = 1; j <=k;j++) {
			s[i][j] += s[i-1][j];
		}
	}

	int ans = 0;
	for (int i = 1; i <=k; i++) {
		for (int j = 1; j <=k;j++) {
			int cnt = 0;
			cnt += (s[i][j]);
			cnt += s[i + k][k] - s[i + k][j] - s[i][k] + s[i][j];
			
			cnt += s[2 * k][j] - s[i + k][j];
			
			ans = max(ans, max(cnt, n - cnt));

		}
	}

	cout << ans << endl;

}
	


Measured memory_bytes: 8192
#include<stdio.h>

int main(void)

{
	int n, a, b;
	scanf("%d", &n);
	scanf("%d", &a);
	scanf("%d", &b);
	if (a*n < b) {
		printf("%d", n * a);

	}
	else {
		printf("%d",  b);

	}
	return 0;
}

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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define FOR(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define FORR(i,a,b) for(ll (i)=(b)-1;(i)>=(a);(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
vl modinv;
void fillModInv(ll n, ll mod){
  modinv = vl(n+1);
  modinv[1] = 1;
  FOR(i,2,n+1){
    modinv[i] = modinv[mod%i] * (mod - mod/i) % mod;
  }
}
/*}}}*/
int main() {
  ll a,b;
  cin >> a >> b;

  ll ans = -1;
  REP(i,20000){
    if(floor(i*0.08)==a && floor(i*0.1)==b){
      ans = i;
      break;
    }
  }
  
  //cout << fixed << setprecision(10);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

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

		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		String line = reader.readLine();
		String[] str = line.split(" ");
		int N = Integer.parseInt(str[0]);
		int D = Integer.parseInt(str[1]);
		int[][] x = new int[N][D];

		for (int n = 0; n < N; n++) {
			line = reader.readLine();
			String[] x_str = line.split(" ");
			for (int d = 0; d < D; d++) {
				x[n][d] = Integer.parseInt(x_str[d]);
			}
		}

		int ans = 0;
		for (int i = 0; i < N; i++) {
			for (int k = i+1; k < N; k++) {
				double a = 0.0;
				for (int d = 0; d < D; d++) {
					a += (x[i][d] - x[k][d]) * (x[i][d] - x[k][d]);
				}
				a = Math.sqrt(a);
				double a_dbl = a % 1;
				if (a_dbl < 0.00001 || 0.99999 < a_dbl) {
					ans++;
				}
			}
		}
		System.out.println(ans);
		
	}
}


Measured memory_bytes: 23124
N = int(input())
A = list(map(int, input().split()))

Asum = [0]*(N+1)
for i in range(N):
    Asum[i+1] = Asum[i] + A[i]

Asum.sort()
ans = 0
same = 1
tmp = Asum[0] - 1
for i in range(N+1):
    if tmp != Asum[i]:
        ans += same*(same - 1)//2
        tmp = Asum[i]
        same = 1
    else:
        same += 1
ans += same*(same - 1)//2
print(ans)

Measured memory_bytes: 25724
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  string s;
  int a=0;
  int v[1005][2]={};
  while(getline(cin,s)){
    if(s[0]=='\0'){
      a++;
      continue;
    }
    int x=0;
    rep(i,s.size()){
      if(s[i]==',')break;
      x*=10;
      x+=s[i]-'0';
    }
    v[x][a]++;
  }
  rep(i,1005)
    if(v[i][0] && v[i][1])
      cout<<i<<" "<<v[i][0]+v[i][1]<<endl;
}

Measured memory_bytes: 3152
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  int N;

  long long A[222222], acc = 0, c = 0, x = 0;

  std::cin >> N;

  std::map<long long, int> map;

  for (int i = 0; i < N; i ++) {
    std::cin >> A[i];

    map[acc += A[i]] ++;
  }

  acc = 0;

  for (int i = 0; i < N; i ++) {
    if (map.count(acc))
      c += map[acc];

    acc += A[i];

    map[acc] --;
  }

  std::cout << c << std::endl;
  
  return 0;
}


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

int main(){
	for(int D=0; D<100; D++){
		int n;
		cin >> n;
		if(n == 0)break;

		else{
			//input
			int num[1010],pac[1010] ={},shi[1010] ={},sui[1010] ={};
				for(int i=0; i<n; i++){
					int s, p, q, r;
					cin >> s >> p >> q >> r;
					num[i] = s;
					pac[i] = p;
					shi[i] = q;
					sui[i] = r;
				}
			int P, Q, R, C;
			cin >> P >> Q >> R >> C;
			bool jud = false;

			//judge,output
				
			for(int i=0; i<n; i++){
				if (pac[i] <= P && shi[i] <= Q && sui[i] <= R && ( pac[i] + sui[i] ) * 4 + shi[i] * 9 <= C){ 
					cout << num[i] << endl;
					jud = true;
				}
			}
			if(jud == false){
				cout << "NA" << endl;
			}

		}
	}
	return 0;

}



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

using namespace std;

int main()
{
  int W, H, x, y;
  cin >> W >> H >> x >> y;

  double ans = ((double) W * (double) H) / 2.0;
  int ans2 = (W % 2 == 0 && x == (W / 2)) && (H % 2 == 0 && y == (H / 2)) ? 1 : 0;

  cout << ans << " " << ans2 << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int func(int Ai,int D){
int i,counts=1;
for(i=1;i<=D;i++){
    if((Ai*i+1)<=D){
        counts++;
    }
    else{
        break;
    }
}
return counts;
}


int main(){
int N,D,X,i,ans=0;
scanf("%d%d%d",&N,&D,&X);
int A[N+1];
ans=ans+X;
for(i=1;i<=N;i++){
    scanf("%d",&A[i]);
}
for(i=1;i<=N;i++){
    ans=ans+func(A[i],D);
}
cout<<ans<<endl;
}


Measured memory_bytes: 256
N = int(input())

NSP = []
for n in range(1, N+1):
    s, p = input().split()
    NSP.append([n, s, int(p)])

# sortはstable。レコードの中に同じキーがある場合、もともとの順序が維持される
sorted_NSP = sorted(NSP, key=lambda x: x[2], reverse=True)
sorted_NSP = sorted(sorted_NSP, key=lambda x:x[1]) 
for nsp in sorted_NSP:
    print(nsp[0])



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

const long long N = 3e6 + 17;
ll a[N], b[N], cnt = 1, ans, lnt, n, m, r1, r0, l1, l0, sum, mx, h, c[N], t[N], mn = N, x, y, k;
pair<ll,ll>pr[N];
vector<ll>v,v2;
map<ll,ll>mp;
bool used[N];
char ch[N];
ll prime[N] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53};

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    char ap, pa;
    cin >> n >> ap >> m >> pa >> k;
    if(m <= 4)
    {
        cout << "Heisei";
        return 0;
    }
    cout << "TBD";
}


Measured memory_bytes: 6400
S = input()
if S == 'SUN':
    print(7)
elif S == 'MON':
    print(6)
elif S == 'TUE':
    print(5)
elif S == 'WED':
    print(4)
elif S == 'THU':
    print(3)
elif S == 'FRI':
    print(2)
else:
    print(1)

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

int main()
{
	
	int a, b, c;
	char op;
		while (1){
			cin >> a >> op >> b;
			//?????????op??????
			if (op == '+') {
				c = a + b;
			}
			//?????????op??????
			else if (op == '-'){
				c = a - b;
			//?????????op??????
			}else if (op == '/') {
				c = a / b;
			//?????????op??????
			}else if (op == '*') {
				c = a * b;
			//?????????op??????
			}else if(op == '?'){
				break;
			}
			cout << c << endl;
		}
	return 0;
}

Measured memory_bytes: 1160
#include<iostream>
using namespace std;
class map{
public:
    bool dotti;
    int num;
};
int main(){
    int H,W,N;
    map **walk;
    while(cin>>H>>W>>N&&H!=0){
        walk=new map*[H+1];
        walk[0]=new map[W+1];
        for(int i=1;i<=H;++i){
            walk[i]=new map[W+1];
            for(int j=1;j<=W;++j){
                cin>>walk[i][j].dotti;
                walk[i][j].num=0;
            }
        }
        for(int i=0;i<=H;++i){
            walk[i][0].dotti=0;
            walk[i][0].num=0;
        }
        for(int i=0;i<=W;++i){
            walk[0][i].dotti=0;
            walk[0][i].num=0;
        }
        walk[1][1].num=N-1;
        for(int i=1;i<=H;++i){
            for(int j=1;j<=W;++j){
                walk[i][j].num+=(walk[i][j-1].dotti)?(walk[i][j-1].num+1)/2:walk[i][j-1].num/2;
                walk[i][j].num+=(walk[i-1][j].dotti)?walk[i-1][j].num/2:(walk[i-1][j].num+1)/2;
            }
        }
        for(int i=1;i<=H;++i){
            for(int j=1;j<=W;++j){
                if(walk[i][j].num%2){
                    walk[i][j].dotti=!walk[i][j].dotti;
                }
            }
        }
        //W=?¨?0H=???1
        int answer[]{1,1};
        while(answer[0]<=W&&answer[1]<=H){
            if(walk[answer[1]][answer[0]].dotti==1){
                ++answer[0];
            }else{
                ++answer[1];
            }
        }
        cout<<answer[1]<<' '<<answer[0]<<endl;
        for(int i=0;i<=H;++i){
            delete[] walk[i];
        }
        delete[] walk;
    }
    return 0;
}

Measured memory_bytes: 10748
#include<iostream> 
#include<algorithm>
using namespace std;
int main(){
	
	int n;
	int i,bn,cn,bi,ci;
	int a;
	int b[50001];
	int c[50001];
	int total,change;
	
	while(cin>>n) {
		bn=0;
		cn=0;
		
		for(i=0;i<n;i++){
			cin>>a;
			
			if (i%2==0){
				b[bn]=a;
				bn++;
			}else{
				c[cn]=a;
				cn++;
			}
		}
				
		sort(b,b+bn) ;
		sort(c,c+cn) ;
		
		total=-1;bi=0;ci=0;change=0;
				
		for(;bi<bn;){
			if(ci==cn){
				bi++;
				total++;
				if(total%2!=0)
					change++;
						
//				cout<<"bi"<<bi<<"##"<<change<<endl;
				continue;
			}

				if(b[bi]<c[ci]){
					bi++;
					total++;
					if(total%2!=0)
						change++;
						
//						cout<<"bi"<<bi<<"##"<<change<<endl;
				}else{
					ci++;
					total++;
				}
		
		} 
		
		cout<<change<<endl;
		
	}
	
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <string>
#include <cstring>
#include <cmath>
#include <complex>
#include <map>
#include <climits>
using namespace std;

#define reep(i,a,n) for(i=a,i<n;++i)
#define rep(i,n) reep(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define EPS 1e-8
#define F first
#define S second
#define mkp male_pair

static const double PI=6*asin(0.5);
typedef long long ll;
typedef complex<double> CP;
typedef pair<int,int> pii;
typedef pair<double,double> pdd;
typedef vector<int> vint;
static const int INF=1<<24;

double Add(double a,double b){
	//double EPS = 1e-10;
	if(abs(a+b)<1e-10*(abs(a)+abs(b))) return 0;
	return a+b;
}

struct P{
	double x,y;
	P(){}
	P(double x,double y) :x(x),y(y){
	}
	P operator + (P p){
		return P(Add(x,p.x),Add(y,p.y));
	}
	P operator - (P p){
		return P(Add(x,-p.x),Add(y,-p.y));
	}
	P operator * (double d){
		return P(x*d,y*d);
	}
	double dot(P p){ //内積
		return Add(x*p.x,y*p.y);
	}
	double det(P p){
		return Add(x*p.y,-y*p.x);
	}
};

bool cmp_x(const P& p,const P& q){
	if(p.x!=q.x) return p.x<q.x;
	return p.y<q.y;
}

#define DEBUG

int main(){
	int n;
	while(cin>>n,n!=0){
		//cout<<n<<endl;
		#ifdef DEBUG
		vector<P> ps(n);
		for(int i=0;i<n;i++){
			char t;
			cin>>ps[i].x>>t>>ps[i].y;
			//cout<<ps[i].x<<" "<<ps[i].y<<endl;
		}
		sort(ps.begin(),ps.end(),cmp_x);
		vector<P> qs(n*2);
		int k=0;
		for(int i=0;i<n;i++){
			while(k>1&&(qs[k-1]-qs[k-2]).det(ps[i]-qs[k-1])<=0)k--;
			qs[k++]=ps[i];
		}
		for(int i=n-2,t=k;i>=0;i--){
			while(k>t&&(qs[k-1]-qs[k-2]).det(ps[i]-qs[k-1])<=0) k--;
			qs[k++]=ps[i];
		}
		qs.resize(k-1);
		cout<<n-qs.size()<<endl;
		#endif
	}
	return 0;
}

Measured memory_bytes: 1236
#!/usr/bin/python

import sys

def main(argv):
    N, K = map(lambda x: int(x), sys.stdin.readline().split(" ", 2))
    while N and K:
        L = map(lambda x: int(x), raw_input().split(" ", N))
        print(sum(sorted(L)[-K:]))

        line = sys.stdin.readline()
        if line:
            N, K = map(lambda x: int(x), line.split(" ", 2))
        else:
            N = None
            K = None

if __name__ == "__main__":
    main(sys.argv)

Measured memory_bytes: 2568
N = int(input())
scores = []
for i in range(0, N):
	scores.append(int(input()))
scores.sort()
sum = 0
for i in range(0, N):
	sum += scores[i]
if sum%10 != 0:
	print(sum)
else:
	flag = False
	for i in range(0, N):
		if scores[i]%10 != 0:
			flag = True
			sum -= scores[i]
			break
	if flag:
		print(sum)
	else:
		print(0)

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

int main(){
    int x,a,b;
    for(x=1;x<4000;x++){
	cin>>a>>b;
	if(a==0&&b==0)break;
	if(a<=b){cout<<a<<" "<<b<<endl;}
	else{cout<<b<<" "<<a<<endl;}
}	   
}	


Measured memory_bytes: 2972
N=int(input())
a=[0]*N
b=[0]*N
c=[0]*N
a[0],b[0],c[0]=map(int,input().split())
for i in range(1,N):
  a[i],b[i],c[i]=map(int,input().split())
  a[i] += max(b[i-1],c[i-1])
  b[i] += max(a[i-1],c[i-1])
  c[i] += max(a[i-1],b[i-1])

print(max(a[-1],b[-1],c[-1]))

Measured memory_bytes: 14932
#include<cstdio>
#include<algorithm>
using namespace std;
using ll = long long;
using ull = unsigned long long;

int main(){
	unsigned N;
	scanf("%d", &N);
	int A[N];
	for (int i = 0; i < N; ++i){
		scanf("%d", A + i);
		A[i] -= i+1;
	}
	sort(A, A + N);
	ll b = (A[N-1>>1] + A[N>>1])/2;
	ull ans = 0;
	for (int i = 0; i < N; ++i){
		ans += abs(A[i] - b);
	}
	printf("%llu\n", ans);
	return 0;
}

Measured memory_bytes: 896