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

int main() {
	int N;
    cin >> N;
    vector<int> X(N);
    for(int i=0;i<N;i++){
      cin >> X.at(i);
    }
    int s = 0;
    vector<int> Y(N);
    int j = 0;
    sort(X.begin(),X.end());
    int m = X.at(N-1);
    vector<int> Z(m+1);
    for(int j=0;j<=m;j++){
        s = 0;
    	for(int i=0;i<N;i++){
     		Y.at(i) = (X.at(i)-j-1)*(X.at(i)-j-1);
      		s = s + Y.at(i);
    	}
       Z.at(j) = s;
    }
    sort(Z.begin(),Z.end());
    cout << Z.at(0) << endl;
}
  

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

//{ START
using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (a); i > (n); --i)
#define arep(i, x) for (auto &&i : (x))
#define irep(i, x) for (auto i = (x).begin(); i != (x).end(); ++i)
#define rirep(i, x) for (auto i = (x).rbegin(); i != (x).rend(); ++i)
//降順はgreater<T>()
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
// gcd lcmはそのままok
#define gcd(a, b) __gcd(a, b)
#define bits(n) (1LL << (n))
#define pcnt(x) __builtin_popcountll(x)
//配列内等要素削除
#define unique(x) (x).erase(unique((x).begin(), (x).end()), (x).end())
#define Fixed(n) fixed << setprecision(n)
//総和
#define sowa(n) (((n) * ((n) + 1)) / 2)
#define pb(x, a) (x).push_back(a)
#define fb(x, a) (x).push_front(a)
#define eb(x, a) (x).emplace_back(a)
#define cauto const auto &
using P = pair<int, int>;
using Graph = vector<vector<P>>;
template <class T>  //昇順
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template <class T>  //降順
using max_heap = priority_queue<T>;
template <class A, class B>
using umap = unordered_map<A, B>;
template <class A>
using uset = unordered_set<A>;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {  //多次元初期化
  std::fill((T *)array, (T *)(array + N), val);
}
template <class A, class B>
bool chmax(A &a, const B &b) {  //最大値更新 返り値はbool
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class A, class B>
bool chmin(A &a, const B &b) {  //最小値更新 返り値はbool
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr int LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9 + 7;
constexpr int mod2 = 998244353;
//} END

signed main(void) {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);

  string x;
  cin >> x;
  stack<char> st;

  rep(i, 0, x.size()) {
    if (x[i] == 'S')
      st.push(x[i]);
    else {
      if (st.empty()) st.push(x[i]);
      if (st.top() == 'S')
        st.pop();
      else
        st.push(x[i]);
    }
  }

  cout << (st.size() == 0 ? 0 : st.size() - 1) << '\n';
  return 0;
}

Measured memory_bytes: 3784
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
	"strings"
)

func main() {
	resolve(os.Stdin)
}

func resolve(r io.Reader) {
	const (
		initialBufSize = 100000
		maxBufSize     = 1000000
	)
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords) // bufio.ScanLines
	s := scanString(sc)
	t := scanString(sc)
	if strings.HasPrefix(t, s) {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

// snip-scan-funcs
func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return int(i)
}
func scanString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

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

typedef long long int ll;
typedef unsigned long long int ull;
#define rep(i,n) for(auto i=0;i<(n);i++)

using namespace std;


int main(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];

    vector<ll> memo(n, 0);
    ll cnt = 0;
    
    rep(i, n){
        if(i == 0) memo[0] = a[0];
        else memo[i] = memo[i-1] + a[i];
    }

    set<ll> keys;
    map<ll, ll> m;
    for(auto x : memo){
        m[x]++;
        keys.insert(x);
    }

    for(auto key: keys){
        if(m[key] < 2) continue;
        rep(i, m[key]) cnt += i;
    }

    rep(i, n){
        if(memo[i] == 0) cnt++;
    }

    cout << cnt << endl;



    return 0;
}


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

using namespace std;

int main() {
  int A, B, C, X, count = 0;
  cin >> A >> B >> C >> X;
  for (int i = 0; i <= A; ++i) {
    for (int j = 0; j <= B; ++j) {
      int tmp = X - 500 * i - 100 * j;
      if (tmp < 0) break;
      if (tmp / 50 <= C) count++;
    }
  }
  cout << count << endl;

  return 0;
}

Measured memory_bytes: 3608
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define M 900001
#define L 14

char H[1000000][L];

void insert(char *);
int find(char *);
int h(int , int);
int h1(int);
int h2(int);
int getChar(char);
int getkey(char *);

int n;

int main()
{
  char s[L],com[9];
  int i,j,ret;
  
  for(i = 0; i < M; i++)H[i][0] = '\0';
  
  scanf("%d",&n);
  
  for(i = 0; i < n; i++){
    scanf("%s %s",com,s);
    if(com[0] == 'i'){
      insert(s);
    }
    else{
      ret = find(s);
      if(ret == 1)printf("yes\n");
      else printf("no\n");
    }
  }

  return 0;
}

void insert(char str[])
{
  int i,j,key,ret;

  key = getkey(str);
  for(i = 0; ; i++){
    ret = (h1(key) + i * h2(key)) % M;
    if(strcmp(H[ret],str) == 0)return;
    else if(strlen(H[ret]) == 0){
      strcpy(H[ret], str);
      return;
    }
  }
}

int find(char str[])
{
  int i,j,ret,key;

  key = getkey(str);
  for(i = 0; ; i++){
    ret = (h1(key) + i * h2(key)) % M;
    if(strcmp(H[ret],str) == 0)return 1;
    else if(strlen(H[ret]) == 0){
      return 0;
    }
  }
  return 0;
}

int h(int k, int i)
{
  return (h1(k) + (i * h2(k))) % n;
}

int h1(int k)
{
  return k % n;
}

int h2(int k)
{
  return 1 + (k % (n - 1));
}

 int getChar(char ch){
   if(ch == 'A')return 1;
   else if( ch == 'C') return 2;
   else if ( ch == 'G') return 3;
   else if ( ch == 'T') return 4;
 }

 int getkey(char str[]){
   long long sum = 0, p = 1, i;
   for ( i = 0; i < strlen(str); i++ ){
     sum += p*(getChar(str[i]));
     p *= 5;
   }
   return sum;
 }



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

using namespace std;

int main(){
  int n,m,a,b; cin >> n>>m>>a>>b;
  vector<int> x(n+1), y(m+1);
  x[0] = a; y[0] = b;
  int i,l;
  for ( i = 1; i<=n; i++){
    cin >> x[i];
  }
  for ( i = 1; i<=m; i++){
    cin >> y[i];
  }
  int x_max,y_min;
  x_max = -101; y_min = 101;
  for ( i = 0; i<=n; i++){
    if ( x_max < x[i]){
      x_max = x[i];
    }
  }
  for ( i = 0; i<=m; i++){
    if ( y_min > y[i]){
      y_min = y[i];
    }
  }
  if(x_max < y_min){
    cout << "No War"<<endl;
  }
  else cout << "War" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int n,k,a[200050],q;
int main()
{
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)
	{
		int x;
		scanf("%d",&x);
		if(a[x]==0) q++;
		a[x]++;
	}
	sort(a+1,a+1+n);
	int p=0,ans=0;
	for(int i=1;i<=n;i++)
	if(a[i])
	{
		if(q-p<=k) break;
		p++;
		ans+=a[i];
	}
	printf("%d",ans);
}

Measured memory_bytes: 1024
/* -----------------------------------------------------------------------------
	????????????????????? 2012 ?????? ??????5 
	???????????????????????????????????????(?????????) C++?¨????
	g++ pckpre1205.cpp -O2
----------------------------------------------------------------------------- */
#include <iostream>
#include <algorithm>
#include <vector> 

using namespace std;

#define PIPE_MAX 65000

int main() {

	int		n;						// ???????????¬??°
	int 	pipe[PIPE_MAX];			// ??????????????????
	vector<int>	joint;				// ?????§??????????????????
	
	long long		jp;						// ????????¨???????????§??????????????????
	long long		L, L_max;				// ?????????+?????§????????????????????????
	long long		mul;					// ??????
	long long		wage;	// ??????

	// ???????????¬??°???????????????
	cin >> n;

	while(n > 0) {

		// ?????????????????????????????????
		for(int i = 0; i < n; i++)
			cin >> pipe[i];

		// ?????????????????????????????????
		for(int i = 1; i < n; i++) {
			int x;	cin >> x; joint.push_back(x); 
		}

		// ???????????????????????´????????????
		sort(joint.begin(), joint.end());

		// ????????¨???????????§??????????????????
		jp = n-2;
		
		// ????????????????????????
		L = 0;
		for(int i = 0; i < n; i++) L += pipe[i];
		L_max = L; mul = n;

		// ???????????§???????±???????
		for(int i = n - 1; i >= 1; i--) {
			// 
			if(L_max * mul < (L + joint[jp]) * i) {
				// ?????§??????????????????????????????+?????§???????????????????????????????¨???¶
				L_max = L + joint[jp]; mul = i;
			}
			// ??´??°
			L += joint[jp];
			jp--;
		}
				
		// ?????§???????????¨???
		cout << L_max * mul << endl;

		// ???????????¬??°???????????????
		cin >> n;
		joint.clear();
	}

	return 0;
}

Measured memory_bytes: 1796
#define LOCAL
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rrep(i, n) for(int i=(n-1); i>=0; --i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()
#define memr(dp, val) memset(dp, val, sizeof(dp))
using namespace std;
typedef long long ll;
static const int INTINF = (INT_MAX >> 1); // 10^9 + 10^7
static const ll LLINF = (LLONG_MAX >> 1);
static const int MAX = 1e5+1;
static const ll MOD = 1e9+7;
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<typename T>
using min_priority_queue = priority_queue<T, vector<T>, greater<T> >;
string to_string(string s) { return '"' + s + '"'; }
string to_string(bool b) { return b ? "true" : "false"; }
template <size_t N> string to_string(bitset<N> bs) {
  string res;
  for (size_t i = 0; i < N; ++i) res += '0' + bs[i];
  return res;
}
string to_string(vector<bool> v) {
  string res = "{";
  for (bool e : v) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p);
template <class C> string to_string(C c) {
  string res = "{";
  for (auto e : c) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
void debug() { cerr << '\n'; }
template <class Head, class... Tail> void debug(Head head, Tail... tail) {
  cerr << '\t' << to_string(head), debug(tail...);
}
#ifdef LOCAL
#define print(...) cerr << "[" << #__VA_ARGS__ << "]:", debug(__VA_ARGS__)
#else
#define print(...)
#endif

int main(int argc, const char * argv[]) {
	std::cout << std::fixed << std::setprecision(15);

	string str;
	int k; cin >> k >> str;
	rep(i, str.size()){
		if(i >= k){
			cout << "...";
			break;
		}
		cout << str[i];
	}
	cout << endl;

	return 0;
}


Measured memory_bytes: 3624
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace D
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var h = long.Parse(Console.ReadLine());

            Console.WriteLine(Rec(h));
        }

        static long Rec(long x)
        {
            if (x == 0) return 0;
            if (x == 1) return 1;
            return 2 * Rec((long)Math.Floor(x / 2.0)) + 1;
        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;

ll mod = 1e9 + 7;
const ld error = 1e-8;
const ld PI = acosl(-1); //const ld PI = acosl(-1)

#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define eq(x, y) (fabs((x)-(y))<error)
#define bt(i) (1LL<<(i))

#define debug(x) cerr<<#x<<" = "<<(x)<<"\n"
#define hoise cerr<<"hoise - "<<__LINE__<<"\n"
#define tham getchar()
mt19937 rng((unsigned)chrono::system_clock::now().time_since_epoch().count()); //mt199937_64 for ll

inline ll MOD(ll x, ll m = mod)
{
    ll y = x % m;
    return (y >= 0) ? y: y+m;
}

const int inf = 1e9;
const ll infl = 1e18+1;
const int nmax = bt(16)+1;
///===========================================  template  =======================================================

int main(){
    FASTIO;
    int n;
    cin>>n;
    bool ok = true;
    for(int i = 0; i<n; i++){
        int x;
        cin>>x;
        if(x % 2 == 0){
            if(x % 3 != 0 && x % 5 != 0) ok = false;
        }
    }
    if(ok) cout<<"APPROVED";
    else cout<<"DENIED";
    return 0;
}


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

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

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <bitset>
#include <functional>
#include <random>
#define REP(_i,_a,_n) for(int _i=_a;_i<=_n;++_i)
#define PER(_i,_a,_n) for(int _i=_n;_i>=_a;--_i)
#define hr putchar(10)
#define pb push_back
#define lc (o<<1)
#define rc (lc|1)
#define mid ((l+r)>>1)
#define ls lc,l,mid
#define rs rc,mid+1,r
#define x first
#define y second
#define io std::ios::sync_with_stdio(false)
#define endl '\n'
#define DB(_a) ({REP(_i,1,n) cout<<_a[_i]<<',';hr;})
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int P = 1e9+7, INF = 0x3f3f3f3f;
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll qpow(ll a,ll n) {ll r=1%P;for (a%=P;n;a=a*a%P,n>>=1)if(n&1)r=r*a%P;return r;}
ll inv(ll x){return x<=1?1:inv(P%x)*(P-P/x)%P;}
inline int rd() {int x=0;char p=getchar();while(p<'0'||p>'9')p=getchar();while(p>='0'&&p<='9')x=x*10+p-'0',p=getchar();return x;}
//head



#ifdef __APPLE__
const int N = 1e2+50;
#else
const int N = 1e6+50;
#endif



int h1,m1,h2,m2,k;
int chk(int h1, int m1, int h2, int m2, int k) {
	while (h1!=h2||m1!=m2) {
		--k;
		++m1;
		if (m1==60) ++h1,m1=0;
	}
	return k<=0;
}
int main() {
	scanf("%d%d%d%d%d",&h1,&m1,&h2,&m2,&k);
	int ans = 0;
	while (h1!=h2||m1!=m2) {
		if (chk(h1,m1,h2,m2,k)) { 
			++ans;
		}
		++m1;
		if (m1==60) ++h1,m1=0;
	}
	printf("%d\n", ans-1);
}









Measured memory_bytes: 3760
#include<bits/stdc++.h>
#define ll                  long long
#define dl                 double
#define pb                push_back
#define F                  first
#define S                  second
#define endl              "\n"
#define rep(i,a,b)       for(i=a;i<b;i++)
#define all(v)             v.begin(),v.end()
#define allr(v)            v.rbegin(),v.rend()
#define mod              1000000007LL
#define CIN(V,s,n)      for(int i=s;i<n;i++){cin >> V[i];}
#define COUT(V,s,n)   {for(int i=s;i<n;i++){cout <<  V[i] << " "  ;} cout << endl;}
#define fast               ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define CLEAR(V);      for(ll i=0;i<V.size();i++) V[i] = 0;
#define N                  150
#define tmod             998244353LL
using namespace std;

bool sBs(const pair<int,int> &a,const pair<int,int> &b)
{   return (a.second < b.second);   }

ll SUMD(ll n);
ll BS(vector<pair< ll ,ll > > &PS,ll s,ll e,ll ser);
ll MI(ll a, ll m);
//bool P[N+1];
void Sieve(int n=N);
ll Powb(ll b,ll n,ll m);

int main()
{
fast;
ll q=1,t;
//cin >> q;
while(q--)
{
    ll i,j,n,m,k,l,r,a,b,c=0,d=0,e,g,p,q,u,v,w,x,y,flag=1;
    //n=m=k=i=j=l=r=a=b=c=d=u=v=w=p=x=y=0;
    cin >> n >> a >> b >> c;
    vector<string > Q(n),A;
    for(i=0;i<n;i++) cin >> Q[i];
    for(i=0;i<n;i++)
    {
        if(Q[i]=="AB")
        {
            if(a>b or (a==b and i<n-1 and Q[i+1]!="AC") ) {A.pb("B"); a--; b++;}
            else {A.pb("A"); a++;b--;}
        }
        else if(Q[i]=="BC")
        {

            if(b>c or(b==c and i<n-1 and Q[i+1]!="AB")) {A.pb("C"); b--;c++;}
            else {A.pb("B"); b++;c--;}
        }
        else
        {
            if(a>c or ( a==c and i<n-1 and Q[i+1]!="AB")) {A.pb("C"); a--;c++;}
            else {A.pb("A");c--;a++;}
        }
        if(a<0 or b<0 or c<0) {cout << "No"; return 0;}
    }

    cout << "Yes\n";
    for(i=0;i<n;i++) cout << A[i] << endl;
}
    return 0;
}

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

ll Powb(ll b,ll n,ll m)
{
    if(n==0) return 1LL;
    if(n==1) return b;
    ll temp = Powb(b,n/2,m);
    if(n%2==0){return (temp*temp)%m;}
    else{return (b*((temp*temp)%m))%m;}
}

ll SUMD(ll n)
{   ll sum=0;
    while(n>0){sum += n%10;n = n/10;}
    return sum;

}
ll BS(vector<pair<ll,ll> > &PS,ll s,ll e,ll ser)
{
    if(s>e)
        return s;
    ll mid = (s+e)/2;
    if(PS[mid].F==ser)
    {
        return mid;
    }
    else if(PS[mid].F > ser)
    {
        return BS(PS,s,mid-1,ser);
    }
    else
        return BS(PS,mid+1,e,ser);
}
ll MI(ll a, ll m)
{
    ll m0 = m;
    ll y = 0, x = 1;
    if (m == 1)
      return 0;
    while (a > 1)
    {
        ll q = a / m;
        ll t = m;
        m = a % m, a = t;
        t = y;
        y = x - q * y;
        x = t;
    }
    if (x < 0)
       x += m0;
    return x;
}
/*
void Sieve(int n)
{
    memset(P,true,sizeof(P));
    P[0] = false;
    P[1]= false;
    for(ll i=2;i*i<=n;i++)
    {
        if(P[i])
        {
            for(ll j=i*i;j<=n;j+=i)
            {
                P[j]=false;
            }
        }
    }

}

*/


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

using namespace std;

int main()
{
    int a,b;
    cin>>a;
    cin>>b;
    if(a==1&&b==2)
        cout<<"3"<<endl;
    else if(a==1&&b==3)
        cout<<"2"<<endl;
    else if(a==2&&b==1)
        cout<<"3"<<endl;
    else if(a==2&&b==3)
        cout<<"1"<<endl;
    else if(a==3&&b==1)
        cout<<"2"<<endl;
    else if(a==3&&b==2)
        cout<<"1"<<endl;
    else if(b==1&&a==2)
        cout<<"3"<<endl;
    else if(b==1&&a==3)
        cout<<"2"<<endl;
    else if(b==2&&a==1)
        cout<<"3"<<endl;
    else if(b==2&&a==3)
        cout<<"1"<<endl;
    else if(b==3&&a==1)
        cout<<"2"<<endl;
    else if(b==3&&a==2)
        cout<<"1"<<endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main(){
   ll n,sum=0;
	cin>>n;
	 map<string,ll> s;
	 for(ll i=0;i<n;i++){
	 	 string h;
	 	 cin>>h;
	 	 sort(h.begin(),h.end());
	 	 s[h]++;
	 }
	  map<string ,ll>::iterator it;
	 for(it=s.begin();it!=s.end();it++){
	 	ll f=(it->second);
	 	f=f*(f-1)/2;
	 	sum+=f;
	 }
	 cout<<sum;
	 
}

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

using namespace std;

#define int long long

inline int start(int a, int i) {
    if (i < a) return i;
    return i + 1;
}

inline int finish(int b, int i, int x) {
    if (x < b) return x - i + 1;
    int lst = x + 1;
    if (lst - i + 1 > b) return lst - i + 1;
    return lst - i;
}

inline int get(int a, int b, int x) {
    int ans = 0;
    for (int i = max((long long)1, x / 2 - 2); i <= min(x, x / 2 + 2); ++i) {
        ans = max(ans, start(a, i) * finish(b, i, x));
    }
    return ans;
}

main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int q, a, b;
    cin >> q;
    while (q--) {
        int l = 0, r = 2000 * 1000 * 1000;
        cin >> a >> b;
        while (r - l > 1) {
            int m = (r + l) / 2;
            if (get(a, b, m) < a * b) l = m;
            else r = m;
        }
        cout << l << '\n';
    }
    return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <vector>
#include <list>
#include <queue>
#include <stack>

using namespace std;




int main() {
    map<string, int> mp;
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        mp[s]++;
    }
    cout << mp.size() << endl;

    return 0;
}




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

int main() {

	int k, s;
	cin >> k >> s;
	
	long long ans = 0;
	int diff = 0;
	for (int i = 0; i <= k; i++) {
		for (int j = 0; j <= k; j++) {
			if (s - i - j < 0) {
				continue;
			}
			else if (s - i - j > k) {
				continue;
			}
			ans++;
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3640
import java.util.*;

class Main{
  public static void main(String args[]){
    Scanner scan = new Scanner(System.in);
    int h = scan.nextInt();
    int w = scan.nextInt();
    int a[][] = new int[h][w];
    int ks = 0;
    int[] x = new int[h*w];
    int[] y = new int[h*w];
    int[] x1 = new int[h*w];
    int[] y1 = new int[h*w];
    for(int i = 0;i < h;i++){
      for(int j = 0; j < w;j++){
        a[i][j] = scan.nextInt();
      }
    }
    for(int i = 0;i < h;i++){
      for(int j = 0;j < w;j++){
        if(a[i][j]%2 == 1&& a[i][j] != 0){
          if(j != w-1 ){
            if(a[i][j+1]%2 == 1){
            a[i][j] -=1;
            a[i][j+1] += 1;
            x[ks] = j;
            y[ks] = i;
            x1[ks] = j+1;
            y1[ks] = i;
            ks++;
            continue;
          }
          }
          if(i != h-1 ){
            if(a[i+1][j]%2 == 1){
            a[i][j] -=1;
            a[i+1][j] += 1;
            x[ks] = j;
            y[ks] = i;
            x1[ks] = j;
            y1[ks] = i+1;
            ks++;
            continue;
          }
          }
          if(j != w-1){
          a[i][j] -=1;
          a[i][j+1] += 1;
          x[ks] = j;
          y[ks] = i;
          x1[ks] = j+1;
          y1[ks] = i;
          ks++;
          continue;
        }
        if(i != h-1 ){
          a[i][j] -=1;
          a[i+1][j] += 1;
          x[ks] = j;
          y[ks] = i;
          x1[ks] = j;
          y1[ks] = i+1;
          ks++;
          continue;
        }
      }
      }
    }
    System.out.println(ks);
    for(int i =0 ;i <ks ;i++){
      System.out.println((y[i]+1)+" "+(x[i]+1)+" "+(y1[i]+1)+" "+(x1[i]+1));
    }
  }
}

Measured memory_bytes: 112764
#include<cstdio>
#include<cmath>
int main(){
  int x,t;
  scanf("%d",&x);
  scanf("%d",&t);
  //printf("%d",(x-t)>0 ? x-t:0);
  if(x-t>0){
    printf("%d",x-t);
  }else{
    printf("0");
  }
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define FORR(i, a, b) for (int i = b - 1; i >= a; --i)
#define SORT(v) sort(v.begin(), v.end())
#define SORTR(v) sort(v.rbegin(), v.rend())
#define REV(v) reverse(v.begin(), v.end())
#define ITER(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define LB(v, x) (lower_bound(v.begin(), v.end(), x) - v.begin())
#define UB(v, x) (upper_bound(v.begin(), v.end(), x) - v.begin())
#define SZ(v) (int)v.size()
using namespace std;
using ll = long long;
using P = pair<int, int>;

class Main {
    int k;
    vector<ll> a;
    void input() {
        cin >> k;
        a.resize(k);
        REP(i, k) { cin >> a[i]; }
    }
    void output() {
        ll n_max = 2, n_min = 2;
        REPR(i, k) {
            if (n_min % a[i] && n_min % a[i] + (n_max - n_min) < a[i]) {
                cout << -1 << endl;
                return;
            }
            n_max = n_max / a[i] * a[i] + a[i] - 1;
            n_min = ((n_min - 1) / a[i] + 1) * a[i];
        }

        cout << n_min << " " << n_max << endl;
    }

public:
    Main() {
        input();
        output();
    }
};

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

    Main();

    return 0;
}


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

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

    int cnt = 0, ans = 0;
    rep(i, n) {
        int d1, d2;
        cin >> d1 >> d2;
        if (d1 == d2)
            cnt++;
        else
            cnt = 0;
        ans = max(ans, cnt);
    }

    if (ans >= 3)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3628
from itertools import combinations

n = int(input())
d = dict({'M':0, 'A':0, 'R':0, 'C':0, 'H':0})
for i in range(n):
    f = input()[0]
    if f in d:
        d[f] += 1

ans = 0
for a, b, c in list(combinations(d.keys(), 3)):
    ans += (d[a] * d[b] * d[c])

print(ans)

Measured memory_bytes: 74608
#include <bits/stdc++.h>
 
using namespace std;
#define ll long long
#define ld long double
#define PI 3.141592653L
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const ll INF = (ll)1e18;
const int N = 2e5 + 5;
const ll MOD = 1e9+7;
 
int parent[N];
 
int gcd(int a, int b) { 
    if (a == 0) 
        return b;  
    return gcd(b%a, a);  
} 
   
int lcm(int a, int b) {  
    return (a*b)/gcd(a,b);  
} 
 
ll pow(ll x, ll y, ll p) {
    if(y == 0) return 1;
    ll res = 1;
    x %= p;
    if(x == 0) return 0LL;
    while(y > 0) {
        if(y & 1) res = (res*x) % p;
        y >>= 1;
        x = (x*x) % p;
    }
    return res;
}
 
int find(int x) {
    return x == parent[x] ? x : parent[x] = find(parent[x]);
}
 
void Union(int x, int y) {
    int xPar = find(x), yPar = find(y);
    if(xPar != yPar) parent[xPar] = yPar;
}
 
ll nCr(ll n, ll r) {
    ll res = 1;
    for(ll i=1;i<=r;i++) {
        res = res * (n - r + i) / i;
        // is different from
        // res *= (n -r + i) / i;
    }
    return res;
}
 
int ask(int i, int j) {
    cout << "? " << i + 1 << ' ' << j + 1 << endl;
    int v;
    cin >> v;
    return v;
}

void solve() {
    int h, w, m;
    cin >> h >> w >> m;
    vector<int> row(h), col(w);
    set<pair<int, int>> se;
    for(int i=0;i<m;i++) {
        int x, y;
        cin >> x >> y;
        x--, y--;
        row[x]++;
        col[y]++;
        se.emplace(x, y);
    }
    int maxX = 0, maxY = 0;
    for(int i=0;i<h;i++) maxX = max(maxX, row[i]);
    for(int i=0;i<w;i++) maxY = max(maxY, col[i]);
    int res = maxX + maxY - 1;
    vector<int> bestX, bestY;
    for(int i=0;i<h;i++) if(row[i] == maxX) bestX.push_back(i);
    for(int i=0;i<w;i++) if(col[i] == maxY) bestY.push_back(i);
    bool ok = false;
    for(auto x : bestX) {
        for(auto y : bestY) {
            if(!se.count({x, y})) {
                res = maxX + maxY;
                ok = true;
            }
        }
        if(ok) break;
    }
    cout << res << endl;
    return;
} 
 
int main()
{
    IOS
    //int t;
    //cin >> t;
    //while(t--) 
    solve();
    return 0; 
}

Measured memory_bytes: 23808
#include<bits/stdc++.h>
#define ll long long
using namespace std;
inline int rd(){
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-') f=0;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+(ch^48);ch=getchar();}
	return f?x:-x;
}
struct Edge{
	int nxt,to;
}e[400050];
int fir[200050],n,cnt;
inline void add(int from,int to){
	e[++cnt].nxt=fir[from];
	fir[from]=cnt;e[cnt].to=to;
}
inline int dfs(int x,int fa){
	int len=0;
	for(int i=fir[x];i;i=e[i].nxt){
		int y=e[i].to;
		if(y==fa) continue;
		len=len^(dfs(y,x)+1);
	}
	return len;
}
int main(){
	n=rd();int u,v;
	for(int i=1;i<n;i++){
		u=rd(),v=rd();
		add(u,v);add(v,u);
	}
	if(dfs(1,0)) puts("Alice");
	else puts("Bob");
	return 0;
}

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

vector<int> to[200005];
vector<int> ans;

void dfs(int v, int p=-1) {
    for (int u : to[v]) {
        if (u == p) continue;
        ans[u] += ans[v];
        dfs(u,v);
    }
}

int main() {
    int n, q;
    cin >> n >> q;
    rep(i,n-1) {
        int a, b;
        cin >> a >> b;
        --a; --b;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    ans.resize(n);
    rep(i,q) {
        int p, x;
        cin >> p >> x;
        --p;
        ans[p] += x;
    }
    dfs(0);
    rep(i,n) {
        if (i != n-1) printf("%d ", ans[i]);
        else printf("%d\n", ans[i]);
    }
    return 0;
}


Measured memory_bytes: 23424
#include <cstdio>
#include <cmath>
#include <iostream>
#include <cstring> 
#define debug	0
#define 	MAXN		128
using namespace std;
char s[MAXN],t[MAXN];
int len;
void rotation()
{	char c = s[len-1];
	for(int i=len -1 ; i> 0;i--)
	{	s[i] = s[i-1];
	}
	s[0] = c;
}
using	namespace std;

int main()
{	
#if debug	
freopen("data.txt","r",stdin);
#endif
	scanf("%s\n%s",s,t);
	len = strlen(s);
	if( strcmp(s,t) == 0)
	{	printf("Yes\n");
		return 0;
	}
	for(int i = 0 ;i <len;i++)
	{	rotation();
		if(strcmp(s,t) == 0)
		{	printf("Yes\n");
			return 0;
		}
	}
	printf("No\n");
			return 0;
 } 

Measured memory_bytes: 256
a, b, c = map(int, input().split())

num_list = sorted([a,b,c], reverse=True)

subd1 = num_list[0] - num_list[1]
subd2 = num_list[0] - num_list[2]

if subd1 % 2 == subd2 % 2:
    ret = (subd1+ subd2) // 2
else:
    ret = (subd1+ subd2 + 1) // 2 + 1

print(ret)



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

int main() {
  ll x, k, d, l;
  cin >> x >> k >> d;

  if (x == 0) {
    if (k % 2 == 0)
      cout << 0 << endl;
    else
      cout << d << endl;
  } else {
    l = abs(x) / d;
    if (l < k) {
      if (l % 2 == k % 2)
        cout << abs(abs(x) - l * d) << endl;
      else
        cout << abs(abs(x) - (l + 1) * d) << endl;
    } else if (l >= k)
      cout << abs(abs(x) - k * d) << endl;
  }
}

Measured memory_bytes: 3564
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>

using namespace std;

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

	if (A + B >= C) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}



}






Measured memory_bytes: 3604
using System;
class Program
{
	static void Main(string[] args)
	{
		// 整数の入力
		int r = int.Parse(Console.ReadLine());
		string output;
        if(r<1200)output="ABC";
        else if(r<2800)output="ARC";
        else output="AGC";
		//出力
		Console.WriteLine(output);
	}
}

Measured memory_bytes: 11092
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int ufr[225816][2],ufp[225816];

void ufinit(){
	int i;
	for(i=0; i<200000; ++i){
		ufp[i] = i;
		ufr[i][i/100000] = 1;
	}
}

int ufind(int x){
	if(x == ufp[x]){
		return ufp[x];
	}
	ufp[x] = ufind(ufp[x]);
	return ufp[x];
}

void unionf(int x, int y){
	x = ufind(x);
	y = ufind(y);
	if(x==y){
		return;
	}else if(ufr[x][0]+ufr[x][1]<ufr[y][0]+ufr[y][1]){
		swap(x,y);
	}
	ufp[y] = x;
	ufr[x][0] += ufr[y][0];
	ufr[x][1] += ufr[y][1];
}

int main(void){
	int n,i,x,y,p;
	ll ans;
	ufinit();
	cin >> n;
	for(i=0; i<n; ++i){
		cin >> x >> y;
		--x; --y;
		unionf(x,100000+y);
	}
	ans = -n;
	for(i=0; i<200000; ++i){
		if(i!=ufind(i)){
			continue;
		}
		ans += (ll)ufr[i][0]*ufr[i][1];
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 2560
function getLines(input){
	return input.split("\n").map((s)=>s.trim())
}
function parseLine(line){
	return line.split(" ").map((s)=>s.trim());
}
function parseLineToInt(line){
	return line.split(" ").map((s)=>parseInt(s.trim()));
}
// parameter "input" gets all data
function Main(input) {
	// the first line is assigned to input[0], the second line is assigned to input[1] similarly.	
	input = parseInt(parseLine(input)[0]);
	ans = parseInt(input/500)*1000;
	input-= parseInt(input/500)*500;
	ans+=parseInt(input/5)*5;

	console.log(ans);
}
// Don't edit this line!
//Main(require("fs").readFileSync(__dirname+'/in.txt', "utf8"));
Main(require('fs').readFileSync('/dev/stdin', 'utf8'));


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

int main()
{
	int H1, M1, H2, M2, K;
	cin >> H1 >> M1 >> H2 >> M2 >> K;

	int st = H1 * 60 + M1;
	int ed = H2 * 60 + M2;
	int ans = max( ed - st - K, 0 );

	cout << ans << endl;
}


Measured memory_bytes: 3636
#include<stdio.h>
#include<stdlib.h>
#define NIL NULL

struct node{
struct node *right;
struct node *left;
struct node *parent;
int key;
};

typedef struct node * Node;


Node root;

Node treeMinimum(Node x){


}

Node treeMaximum(Node x){


}

Node treeSearch(Node u, int k){


}

Node treeSuccessor(Node x){


}

void treeDelete(Node z){
  Node y; 
  Node x; 



}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x!=NIL){
    y=x;
    if(z->key < x->key){
      x=x->left;
    }else{
      x=x->right;
    }
  }
  z->parent=y;

  if(y==NULL){
    root=z;
  }else if(z->key < y->key){
    y->left=z;
  }else{
    y->right=z;
  }

}

void inorder(Node u){
  if(u!=NIL){
    inorder(u->left);
    printf(" ");
    printf("%d",u->key);
    inorder(u->right);
  }
}
  void preorder(Node u){
    if(u!=NIL){
      printf(" ");
      printf("%d",u->key);
      preorder(u->left);
      preorder(u->right);
    }
  }


  int main(){
    int n=0, i, x;
    char com[20];
    scanf("%d", &n);

    for ( i = 0; i < n; i++ ){
      scanf("%s", &com[0]);
      if ( com[0] == 'f' ){
	x=0;
	scanf("%d", &x);
	Node t = treeSearch(root, x);
	if ( t != NIL ) printf("yes\n");
	else printf("no\n");
      } else if ( com[0] == 'i' ){
	scanf("%d", &x);
	insert(x);
      } else if ( com[0] == 'p' ){
	inorder(root);
	printf("\n");
	preorder(root);
	printf("\n");
      } else if ( com[0] == 'd' ){
	scanf("%d", &x);
	treeDelete(treeSearch(root, x));
      }
    }

    return 0;
  }

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

int n, W;
ll w[110], v[110];
ll dp[110][100100];

int main()
{
	cin >> n >> W;
	for (int i = 1; i <= n; i++)
	{
		cin >> w[i] >> v[i];
	}

	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j <= W; j++)
		{
			if (w[i + 1] <= j)
				dp[i + 1][j] = max(dp[i][j - w[i + 1]] + v[i + 1], dp[i][j]);
			else
				dp[i + 1][j] = dp[i][j];
		}
	}
	ll ans = 0;
	for (int i = 0; i <= W; i++)
		ans = max(dp[n][i], ans);
	cout << ans << endl;
}


Measured memory_bytes: 79360
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

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

int main(){
	string str,W,p;
	long long int q,a,b;
	cin >> str >> q;
	REP(i,q){
		cin >> W >> a >> b;
		if (W == "print"){
			string c(str, a, b - a + 1);
			cout << c << "\n";
		}
		else if (W == "reverse"){
			reverse(str.begin() + a, str.begin() + b + 1);
		}
		else if (W == "replace"){
			cin >> p;
			str.replace(a, b - a + 1, p);

		}
	}
	return 0;
}

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

using namespace std;

#define ll 			long long
#define db			double
#define up(i,j,n)		for (int i = j; i <= n; i++)
#define down(i,j,n)	for (int i = j; i >= n; i--)
#define cadd(a,b)		a = add (a, b)
#define cpop(a,b)		a = pop (a, b)
#define cmul(a,b)		a = mul (a, b)
#define pr			pair<int, int>
#define fi			first
#define se			second
#define SZ(x)		(int)x.size()
#define bin(i)		(1 << (i))
#define Auto(i,node)	for (int i = LINK[node]; i; i = e[i].next)

template<typename T> inline bool cmax(T & x, T y){return y > x ? x = y, true : false;}
template<typename T> inline bool cmin(T & x, T y){return y < x ? x = y, true : false;}

const int MAXN = 1e5 + 5;
const int oo = 0x3f3f3f3f;

int N, Q, f[MAXN], siz[MAXN], g[MAXN];

pr getf(int x){
	if (f[x] == x) return make_pair(x, 0);
	pr cx = getf(f[x]);
	cx.se += g[x];
	return cx;
}

int main(){
	scanf("%d%d", &N, &Q);
	up (i, 1, N) {
		f[i] = i;
		siz[i] = 1;
	}
	while (Q--) {
		int x, y, d;
		scanf("%d%d%d", &x, &y, &d);
		pr cx = getf(x), cy = getf(y);
		if (cx.fi != cy.fi) {
			int rx = cx.fi, ry = cy.fi;
			if (siz[rx] > siz[ry]) {
				swap(rx, ry);
				swap(cx, cy);
				swap(x, y);
				d = -d;
			}
			siz[ry] += siz[rx];
			f[rx] = ry;
			g[rx] = d - cx.se + cy.se;
		}else {
			int dx = cx.se, dy = cy.se;
			if (dx - dy != d) return puts("No") * 0;
		}
	}
	puts("Yes");
	return 0; 
}


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

struct P{
    int x;
    int y;
    P(){}
    ~P(){}
    P(int a, int b): x(a), y(b){}
};

P add(P a, P b){
    return P(a.x + b.x, a.y + b.y);
}

P sub(P a, P b){
    return P(a.x - b.x, a.y - b.y);
}

bool eq(P a, P b){
    return a.x == b.x && a.y == b.y;
}

P rot90(P a){
    return P(-a.y, a.x);
}

bool identical(vector<P> va, vector<P> vb){
    if(va.size() != vb.size()) return false;
    int n = va.size();
    bool flg = true;
    for(int c = 0; c < 4; c++){
        int i;
        for(i = 1; i < n; i++){
            if(!eq(sub(va[i], va[i-1]), sub(vb[i], vb[i-1]))) break;
        }
        if(i == n) return true;
        for(i = 1; i < n; i++){
            if(!eq(sub(va[i], va[i-1]), sub(vb[n-1-i], vb[n-i]))) break;
        }
        if(i == n) return true;
        for(i = 0; i < n; i++) va[i] = rot90(va[i]);
    }
    return false;
}

int main(){
    int n, m;
    while(true){
        scanf("%d", &n);
        if(n == 0) break;
        vector<P> orig, trg;
        scanf("%d", &m);
        for(int j = 0; j < m; j++){
            int x, y;
            scanf("%d%d", &x, &y);
            orig.push_back(P(x, y));
        }
        for(int i = 1; i <= n; i++){
            scanf("%d", &m);
            for(int j = 0; j < m; j++){
                int x, y;
                scanf("%d%d", &x, &y);
                trg.push_back(P(x, y));
            }
            if(identical(orig, trg)){
                printf("%d\n", i);
            }
            trg.clear();
        }
        puts("+++++");
    }
    return 0;
}

Measured memory_bytes: 1200
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define all(v) v.begin(),v.end()
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
template<class T> void chmin(T &a,const T &b){if(a>b) a=b;}
template<class T> void chmax(T &a,const T &b){if(a<b) a=b;}

vector<vector<int>> g;

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

  ll N;
  cin>>N;
  g.resize(N);
  vector<pair<int,int>> edges;
  rep(i,N-1){
      int a,b;
      cin>>a>>b;
      a--;b--;
      edges.push_back(mkp(a,b));
  }

  ll ans=0;
  rep(i,N) ans+=(i+1)*(N-i);
  rep(i,N-1){
      ll a=edges[i].first;
      ll b=edges[i].second;
      if(a>b) swap(a,b);

      ans-=(a+1)*(N-b);
  }
  cout<<ans<<endl;

  return 0;
}


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

//引数の整数の約数が入った配列を返す関数
vector<ll> func( ll n ){
  vector<ll> a;
  for(ll i=1;i*i<=n;++i){
    if( n%i == 0 ) a.push_back(i);
  }
  return a;
}

ll keta( ll n ){
  if( n == 0 ) return 0;
  return 1 + keta(n/10);
}


int main() {
  ll n;cin >> n;
  vector<ll> a = func(n);
  
  // rep(i,a.size()) cout << a.at(i) << " ";
  // cout << endl;

  ll ans = 9999999999;
  for(ll i=0;i<a.size();++i){
    ll an = a.at(i);
    ll bn = n/an;
    ans = min(ans,max(keta(an),keta(bn)));
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3536
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
#include <string>
#include <sstream>
#include <map>
using namespace std;

#define EPS (1e-9)
#define EQ(a,b) (abs((a)-(b))<EPS)

typedef pair<int,int> P;
int main(){
  int n,pp;
  while(cin>>pp>>n&&!(n==0&&pp==0)){
    P lbp;
    double p=sqrt(pp);
    double lbval=-100000000;
    P ubp;
    double ubval=100000000.0;
    for(int i = 1; i <= n; i++){
      int bound=i*i*pp;
      int mm=bound-1;
      int m1=floor(sqrt(mm)+EPS);
      int m2=m1+1;
      if(m1<=n&&m1>=1&&!EQ(1.0*m1/i,p)&&((1.0*m1/i)<p)
    	 &&(lbval<1.0*m1/i)&&!EQ(lbval,1.0*m1/i)){
    	lbval=1.0*m1/i;
    	lbp=P(m1,i);
      }
      if(m2<=n&&m2>=1&&!EQ((1.0*m2/i),p)&&((1.0*m2/i)>p)
    	 &&(ubval>1.0*m2/i)&&!EQ(ubval,1.0*m2/i)){
    	ubval=1.0*m2/i;
    	ubp=P(m2,i);
      }
    }
    // // ツ閉ェツ陛ェツづーツ個按津ィ
    // for(int i = 1; i <= n; i++){
    //   // ub/iツつェpツづヲツづィツ妥・ツつォツつュツづ按づゥツ催渉ャツづ蛍bツづーツ探ツつキ
    //   int ub=n;
    //   int lb=-1;
    //   while(ub-lb>1){
    // 	int med=(ub+lb)/2;
    // 	double val=1.0*med/i;
    // 	if(p<val)
    // 	  ub=med;
    // 	else
    // 	  lb=med;
    //   }
    //   if(ub>=1&&!EQ((1.0*ub/i),p)&&((1.0*ub/i)>p)
    // 	 &&(ubval>1.0*ub/i)&&!EQ(ubval,1.0*ub/i)){
    // 	ubval=1.0*ub/i;
    // 	ubp=P(ub,i);
    //   }
    //   lb=ub-1;
    //   if(lb>=1&&!EQ(1.0*lb/i,p)&&((1.0*lb/i)<p)
    // 	 &&(lbval<1.0*lb/i)&&!EQ(lbval,1.0*lb/i)){
    // 	lbval=1.0*lb/i;
    // 	lbp=P(lb,i);
    //   }
    // }
    printf("%d/%d %d/%d\n",ubp.first,ubp.second,lbp.first,lbp.second);
  }
  return 0;
}

Measured memory_bytes: 896
#include <stdio.h>
#define MAX 251

int main(){
  int n, i;
  int array[MAX];

  scanf("%d", &n);

  for( i=1; i<=n; i++){
    scanf("%d", &array[i]);
  }

  for( i=1; i<=n; i++){
    printf("node %d: key = %d, ", i, array[i]);
    if( i/2 >= 1 )printf("parent key = %d, ", array[i/2]);
    if( 2*i <= n )printf("left key = %d, ", array[i*2]);
    if( 2*i+1 <= n )printf("right key = %d, ", array[i*2+1]);
    printf("\n");
  }
 
  return 0;
}

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

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

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

using ll = long long;
const ll INF = 1LL << 60;

int main()
{
  int n, k;
  ll d[100100];
  ll h[100100];

  cin >> n >> k;
  for (int i = 1; i <= n; ++i)
  {
    cin >> h[i];
  }
  for (int i = 1; i <= n; ++i)
  {
    d[i] = INF;
  }
  d[1] = 0;
  for (int i = 1; i <= n; ++i)
  {
    for (int j = 1; j <= k; ++j)
    {
      chmin(d[i + j], d[i] + abs(h[i + j] - h[i]));
    }
  }
  cout << d[n] << endl;

  return 0;
}

Measured memory_bytes: 1792
h, w = gets.chomp.split.map(&:to_i)
q = []
t = Array.new(h) { Array.new(w, 0) }
m = []
h.times do |x|
  row = gets.chomp.chars
  (0...w).each do |y|
    if row[y] == "."
      q << [x, y]
    else
      [-1, 0, 1].each do |dx|
        [-1, 0, 1].each do |dy|
          next if x + dx < 0 || x + dx >= h
          next if y + dy < 0 || y + dy >= w
          t[x + dx][y + dy] += 1
        end
      end
    end
  end
  m << row
end

q.each do |x, y|
  m[x][y] = t[x][y].to_s
end

puts m.map(&:join)

Measured memory_bytes: 2044
#include<stdio.h>
#include<string.h>

int main() {
	char s[11];
	scanf("%s", s);
	int flag = 0;
	for (int i = 0; i < strlen(s); i++) {
		if (strlen(s) %2== 1) { printf("No"); return 0; }
		if (i % 2 == 0) {
			if (s[i] != 'h') {
				printf("No");
				return 0;
			}
		}
		else if (s[i] != 'i') {
			printf("No");
			return 0;
		}
	}
	printf("Yes");

	return 0;
}

Measured memory_bytes: 2116
H,W = map(int,input().split())
a = []
for i in range(H):
    a.append(list(input()))

rm = []

for i in range(H):
    if "#" not in a[i]:
        for j in range(W):
            rm.append([i,j])

for i in range(W):
    t = []
    for k in range(H):
        t.append(a[k][i])
    if "#" not in t:
        for j in range(H):
            rm.append([j,i])


aa = []
for i in range(H):
    t = []
    for j in range(W):
        if [i,j] not in rm:
            t.append(a[i][j])
    if len(t) != 0 :
        aa.append(t)


for i in range(len(aa)):
    for j in range(len(aa[i])):
        print(aa[i][j],end="")
    print("")


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

int main()
{
  int N;
  string s, t;
  cin >> N >> s >> t;
  for (int i = N; i > 0; i--)
  {
    if (t.substr(0, i) == s.substr(N - i, i))
    {
      cout << 2 * N - i << endl;
      return 0;
    }
  }
  cout << 2 * N << endl;
}

Measured memory_bytes: 256
n, a, b, c = map(int, input().split())
length = []
inf = 10**9 + 7

for i in range(n):
    length.append(int(input()))


def DFS(cur, x, y, z):
    if cur == n:
        if min(x, y, z) > 0:
            return abs(x - a) + abs(y - b) + abs(z - c) - 30
        else:
            return inf

    part0 = DFS(cur + 1, x, y, z)
    part1 = DFS(cur + 1, x + length[cur], y, z) + 10
    part2 = DFS(cur + 1, x, y + length[cur], z) + 10
    part3 = DFS(cur + 1, x, y, z + length[cur]) + 10

    return min(part0, part1, part2, part3)


print(DFS(0, 0, 0, 0))


Measured memory_bytes: 3064
import java.util.*;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String[] Sz = new String[N];
        for (int i = 0; i < N; i++){
            Sz[i] = sc.next();
        }

        HashSet<String> set = new HashSet<String>();
        for (int i = 0; i < N; i++){
            set.add(Sz[i]);
        }
        System.out.println(set.size());
    }
}

Measured memory_bytes: 75860
#!/bin/bash
':' /*
docker run --rm -it -v $(cd $(dirname $0) && pwd):/vo:ro node:5.2-slim \
  /bin/bash -c "node /vo/$(basename $0) < /vo/g.inp"; exit $?
exit 0
*/

"use strict";

let main = (input) => {
    let j = input.length;
    let lc = Math.ceil(j/2);
    let cnt = 0;
    for(let i=0; i<lc; i++) {
        j--;
        if (input.substring(i,i+1)!=input.substring(j,j+1)) cnt+=1;
    }
    return cnt;
}
console.log(main(require('fs').readFileSync("/dev/stdin", "utf-8").trim()));

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


int N;
int main() {
  while (cin >> N) {
	int res = 0;
	int a[210000];
	for (int i = 0; i < N; ++i) cin >> a[i];
	sort(a, a+N, greater<int>());
	for (int i = 0; i < N; ++i) {
	  if (i % 2 == 0) res += a[i];
	  else res -= a[i];
	}
	cout << res << endl;
  }
}


Measured memory_bytes: 256
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    A, B, C = map(int, readline().split())

    def judge():
        for i in range(0, 100000):
            cur = A * i
            if cur % B == C:
                return True
        return False

    if judge():
        print("YES")
    else:
        print("NO")


if __name__ == '__main__':
    main()


Measured memory_bytes: 62940
using System;
using System.Collections.Generic;

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			var inputs = new List<int>();
			while(inputs.Count < 6)
			{
				var _input = Console.ReadLine();
				// 無効な入力のとき
				int result;
				if (!int.TryParse(_input, out result))
				{
					continue;
				}
				inputs.Add(result);
			}

			var input = new Input
			{
				A = inputs[0],
				B = inputs[1],
				C = inputs[2],
				D = inputs[3],
				E = inputs[4],
				K = inputs[5],
			};

			if (input.IsValid())
			{
				Console.WriteLine("Yay!");
			} else
			{
				Console.WriteLine(":(");
			}
		}
	}

	public class Input
	{
		public int A { get; set; }

		public int B { get; set; }

		public int C { get; set; }

		public int D { get; set; }

		public int E { get; set; }

		public int K { get; set; }

		public bool IsValid()
		{
			if (!IsValidDistance(A, B))
			{
				return false;
			}
			if (!IsValidDistance(A, C))
			{
				return false;
			}
			if (!IsValidDistance(A, D))
			{
				return false;
			}
			if (!IsValidDistance(A, E))
			{
				return false;
			}
			if (!IsValidDistance(B, C))
			{
				return false;
			}
			if (!IsValidDistance(B, D))
			{
				return false;
			}
			if (!IsValidDistance(B, E))
			{
				return false;
			}
			if (!IsValidDistance(C, D))
			{
				return false;
			}
			if (!IsValidDistance(C, E))
			{
				return false;
			}
			if (!IsValidDistance(D, E))
			{
				return false;
			}
			return true;
		}

		private bool IsValidDistance(int pointA, int pointB)
		{
			return pointB - pointA <= K;
		}
	}
}


Measured memory_bytes: 13268