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

using ll = long long;
using vi = vector<int>;
using vi2 = vector<vector<int>>;
#define MP(a,b) make_pair((a),(b))
#define MT(...) make_tuple(__VA_ARGS__)

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl;
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl;

#define DCOUT(x,n) cout << fixed << setprecision(n) << (x) << endl;

#define sz(x) (int)(x).size()
#define HOGE cout << "hoge" << endl;
using P = pair<ll,ll>;

template<typename T>inline istream& operator>>(istream&i,vector<T>&v)
{REP(j,sz(v))i>>v[j];return i;}

int main(){
	int N;
	cin >> N;
	vi A(N);
	REP(i,N){
		cin >> A[i];
	}

	int s=0;
	REP(i,N) s += A[i];
  	int t=0;
	REP(i,N/2) t += 2*A[2*i+1];
  	//cout << s << " " << t << endl;
	
  	int x = s-t;
	cout << x << endl;
	REP(i,N-1){
		x = 2*A[i] - x;
		cout << x << endl;
	}
}


Measured memory_bytes: 1664
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String s = sc.next();
        int ans = 0;
        for (int i = 1; i < n - 1; i++) {
            int count = 0;
            for (char c = 'a'; c <= 'z'; c++) {
                if (s.substring(0, i).contains(String.valueOf(c)) && s.substring(i).contains(String.valueOf(c))) {
                    count++;
                }
            }
            ans = Math.max(ans, count);
        }
        System.out.println(ans);
    }
}

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

int main(){
    cin.sync_with_stdio(false);
    int n, w; cin >> n >> w;

    vector<vector<long long>>a(n, vector<long long>(2));
    for(int i = 0; i < n; i++){
        cin >> a[i][0] >> a[i][1];
    }
    
    vector<vector<long long>>dp(n,vector<long long>(w+1));
    
    for(long long i = a[n-1][0]; i <= w; i++){
        dp[n-1][i] = a[n-1][1];
    }

    for(int i = n-2; i >= 0; i--){
        for(long long j = 0; j <= w; j++){
            if(a[i][0] <= j){
                dp[i][j] = max(a[i][1]+dp[i+1][j-a[i][0]], dp[i+1][j]);
            }else{
                dp[i][j] = dp[i+1][j];
            }
        }
    }

    cout<<dp[0][w]<<endl;
}


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

#define debug(var)  do{std::cerr << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cerr << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cerr << e << " "; } std::cerr << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<ll> v1;
typedef vector<v1> v2;
typedef vector<v2> v3;

typedef unordered_map<ll, unordered_map<ll, ll>> graph;

const ll INF = 1ll << 50;
const ll mod = 1000000007;

ll n,k;
v1 x;

ll ans = 0;

int main(){
    cin >> n >> k;
    x = v1(n);
    for(ll i = 0;i < n;i++){
        cin >> x[i];
    }
    for(ll i = 0;i < n;i++){
        ans += min(x[i], k-x[i]) * 2;
    }
    cout << ans << endl;
}


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

#define REP(type, i, a, b) for( type i = a; i < b; i++ )
typedef long long ll;

using namespace std;

int main (void) {
    int r;
    scanf("%d", &r);
    printf("%d\n", r*r*3);
    return 0;
}

Measured memory_bytes: 256
/**********************************************************************/
/********                                                      ********/
/********                     Writer:孙~~                      ********/
/********                       Lang:C++                       ********/
/********                     Status:Unknow                    ********/
/********                                                      ********/
/**********************************************************************/
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>
#include <queue>
#include <list>
#include <cstdlib>
#include <algorithm>
#include <set>
#include <map>
#include <deque>
#include <cstring>
#include <cmath>
//#include<bits/stdc++.h>
using namespace std;

const int INF=0x3f3f3f3f;
const int SIZE=200005;

long long a[SIZE];

int main(){
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%lld",a+i);
		a[i]-=i+1;
	}
	sort(a,a+n);
	if(n==1){
		puts("0");
	}
	else if(n%2==0){
		long long tmp=0;
		for(int i=0;i<n;i++){
			tmp+=abs(a[i]-a[n/2]);
		}
		long long tmp2=0;
		for(int i=0;i<n;i++){
			tmp2+=abs(a[i]-a[n/2-1]);
		}
		printf("%lld\n",min(tmp,tmp2));
	}
	else{
		long long tmp=0;
		for(int i=0;i<n;i++){
			tmp+=abs(a[i]-a[n/2]);
		}
		printf("%lld\n",tmp);
	}
	return 0;
}




Measured memory_bytes: 1792
#include "bits/stdc++.h"

using namespace std;
using ll = long long;
using P = pair<int, int>;
#define all(c) (c).begin(), (c).end()
const int INF = 1e9 + 1;
const ll LINF = 1e18 + 1;
const ll MOD = 1e9 + 7;

template <class T>
T fast_pow(T n, int exp) {
  T ret = 1, powOf2 = n;
  while (exp > 0) {
    if (exp & 1) ret *= powOf2;
    powOf2 *= powOf2;
    exp /= 2;
  }
  return ret;
}

class modint {
 public:
  ll n;
  int mod = MOD;

  modint(const ll x = 0) noexcept : n(x) {}
  modint inverse() { return fast_pow(*this, mod - 2); }
  modint& operator+=(const modint a) {
    n += a.n;
    n %= mod;
    return *this;
  }
  modint operator+(const modint a) { return modint(*this) += a; }
  modint& operator-=(const modint a) {
    n += (mod - a.n);
    n %= mod;
    return *this;
  }
  modint operator-(const modint a) { return modint(*this) -= a; }
  modint& operator*=(const modint a) {
    n *= a.n;
    n %= mod;
    return *this;
  }
  modint operator*(const modint a) { return modint(*this) *= a; }
  modint& operator/=(modint a) { return (*this) *= a.inverse(); }
  modint operator/(const modint a) { return modint(*this) /= a; }
};
ostream& operator<<(ostream& o, const modint& m) {
  o << m.n;
  return o;
}

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

  int n;
  cin >> n;
  vector<ll> a(n);
  vector<int> cnt1(60, 0);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    ll t = a[i];
    for (int j = 0; j < 60; ++j) {
      if (t % 2) ++cnt1[j];
      t /= 2;
    }
  }

  modint ans = 0;
  for (ll t : a) {
    modint p = 1;
    for (int i = 0; i < 60; ++i) {
      modint x = t % 2 ? n - cnt1[i] : cnt1[i];
      ans += x * p;
      p *= 2;
      t /= 2;
    }
  }
  ans /= 2;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 2560
#include<stdio.h>
int main(){
int H, W;
	while(1){
		scanf("%d %d",&H,&W);
		if(H==0 && W==0) break;
		for(int i=1;i<=H;i++){
			for(int k=1;k<=W;k++){
				if(i%2!=0){
					if(k%2!=0){
						printf("#");
					}else printf(".");
				}else{
					if(k%2==0){
						printf("#");
					}else printf(".");
				}
			}
			printf("\n");
		}
		printf("\n");
	}
}



Measured memory_bytes: 2036
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a;
    int cnt = 0;
    cin >> a;
    while(true){
        if(a==2){
            cout << 2 << endl;
            break;
        }
        for(int i=2;i<a;i++){
        if(a%i == 0){
            a++;
            break;
        }
        if(i == a-1){
            cout << a << endl;
            cnt++;
            break;
        }
        }
        if(cnt == 1)break;
    }
}



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

int main() {
	int sum = 0;
	char number[1001];

	while (1) {
		cin >> number;

		sum = 0;

		for (int i = 0; i < 1000; i++) {
			if (number[i] == 0)
				break;
			sum += number[i] - '0';
		}

		if (sum == 0)
			break;
		else
		cout << sum << endl;
	}

	return 0;
}

Measured memory_bytes: 1140
def insertionSort(a, n)
    for i in 1..n-1
        v = a[i]
        j = i-1
        while j >= 0 && a[j] > v
            a[j+1] = a[j]
            j-=1
        end
        a[j+1] = v
        puts a.join(" ")
    end
end

N = gets.strip.to_i
a = gets.strip.split(" ").map{|i| i.to_i}
puts a.join(" ")
insertionSort(a, N)


Measured memory_bytes: 6896
#include<stdio.h>
#include<stdlib.h>

int main()
{
  int i,j,n,hold,count=0;
  int Array[100];
  
  scanf("%d",&n);
  if( n < 1 || n > 100 )
    exit(1);
  
  for( i = 0; i < n; i++ )
    {
      scanf("%d",&Array[i]);
      if( Array[i] < 0 || Array[i] > 100 )
	exit(1);	
    }
  
  for( i = 0; i < n-1; i++ )
    {
      for( j = n-1; j > i; j-- )
	{
	  if(Array[j] < Array[j-1])
	    {
	      hold = Array[j];
	      Array[j] = Array[j-1];
	      Array[j-1] = hold;
	      count++;
	    }
	}
    }
 
  for( i = 0; i <= n-2; i++ )
    printf("%d ",Array[i]);
  printf("%d\n",Array[n-1]);
  printf("%d\n",count);

  return 0;
}



Measured memory_bytes: 2072
#define _USE_MATH_DEFINES
#include <cmath>
#include <string>
#include <iostream>
#include <iomanip>
#include <limits>
#include <vector>
#include <algorithm>
#include <functional>

typedef long long lint;

using namespace std;
#define rep(i, n) for(lint i = 0; i < (lint)(n); i++)
#define repi(i,a,b) for(lint i=lint(a);i<lint(b);++i)
#define all(x) (x).begin(),(x).end()
#define sl(c) (('a')<=(c)&&(c)<=('z'))
#define ll(c) (('A')<=(c)&&(c)<=('Z'))
lint* arr1(lint x) {
	lint *array = new lint[x];
	rep(i, x)array[i] = 0;
	return array;
}
lint** arr2(lint x, lint y) {
	lint **array = new lint*[x];
	rep(i, x)array[i] = new lint[y];
	rep(i, x)rep(j, y)array[i][j] = 0;
	return array;
}
int main() {
	lint* arr = arr1(26);

	while (!cin.eof()) {
		char c=' ';
		cin >> c;
		if (sl(c))arr[c - 'a']++;
		else if (ll(c))arr[c - 'A']++;
	}
	rep(i, 26)cout << (char)('a' + i) << " : " << arr[i]<<"\n";
}


Measured memory_bytes: 3080
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String masu = sc.next();
		char[] masuList = masu.toCharArray();
		int count = 0;
		for(char a : masuList) {
			if (a == '1') {
				count = count + 1;
			}
		}
		System.out.println(count);

	}
}


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

int main() {

  int x;
  cin>>x;
  if(x>=400 && x<=599) cout << "8";
  else if(x>=600 && x<=799) cout << "7";
  else if(x>=800 && x<=999) cout << "6";
  else if(x>=1000 && x<=1199) cout << "5";
  else if(x>=1200 && x<=1399) cout << "4";
  else if(x>=1400 && x<=1599) cout << "3";
  else if(x>=1600 && x<=1799) cout << "2";
  else  cout << "1";

  
}

Measured memory_bytes: 3624
#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 SX, SX2;
  SX = 0;
  SX2 = 0;
  for (int i = 0; i < N; i++) {
    SX += X.at(i);
    SX2 += (X.at(i) * X.at(i));
  }
  int P1, P2;
  P1 = SX / N;
  P2 = P1 + 1;
  int m1, m2;
  m1 = N * P1 * P1 - 2 * SX * P1 + SX2;
  m2 = N * P2 * P2 - 2 * SX * P2 + SX2;
  cout << min(m1, m2) << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <queue>
using namespace std;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define REP(i,n) for(ll i=0;i<n;i++)
#define REPR(i,n) for(ll i=n-1;i>=0;i--)

typedef long long ll;
#define INF 1e18

int main(){
	ll N;
	string S;
	cin>>N>>S;
	ll cnt=0;
	FOR(i,0,1000){
		ll tmp=i;
		ll old=0;
		ll j;
		for(j=0;j<3;j++){
			string c(1,(char)(tmp%10)+3*16);
			tmp/=10;
			auto it=search(S.begin()+old,S.end(),c.begin(),c.end());
			if(it==S.end())break;
			old=it-S.begin()+1;
		}
		if(j==3)cnt++;
	}
	cout<<cnt<<endl;
	return 0;
}


Measured memory_bytes: 256
// unordered return continue break vector visited check flag bool while iterator temp true false ll_MAX ll_MIN insert pop push compare ll64_MAX ll64_MIN   replace stringstream string::npos  substr front 
#include<bits/stdc++.h>
using namespace std;
#ifdef AAYUSH
#include "/home/aayj/debug.cpp"
#else
#define debug(...) ;
#endif
#define ll  long long
const ll mod = 1e9 + 7 ;
const ll inf =
 1e9 + 5 ;
 //1e18L + 5;
void min_self(ll&a , ll b){a=min(a,b);}
void max_self(ll&a , ll b){a=max(a,b);}
void add_self(ll&a , ll b){a=(a+b);
	if(a>=mod)a-=mod;
}
#define all(x) x.begin(),x.end()
#define pb push_back
#define ff first
#define ss second
#define bg begin
#define ed end
#define lb lower_bound
#define ub upper_bound
#define cl clear
#define er erase
#define rev reverse
#define lg length
#define pii pair<ll,ll>
#define heap priority_queue
//#define (x)  get<0>(x) 
//#define (x)  get<1>(x)
//#define (x)  get<2>(x)
#define sz(a) (ll)((a).size())
#define forn(i, n) for (ll i = 0; i < ll(n); ++i)
#define fore(i, l, r) for (ll i = ll(l); i < ll(r); ++i)
#define YYY cout << "YES" << endl;
#define NNN cout << "NO" << endl;
const ll nax = 2e5+5   ;

signed main() {
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
ll n; cin >> n;
ll can[n+1][n+1] = {0};
for(ll i = 0; i < n; i++){
	for(ll j = 0; j < n; j++){
		cin >> can[i+1][j+1];
	}
}
ll x = (1<<(n));

// vector<vector<ll>> dp(n+1, vector<ll>(x));
// dp[0].fill(1);
// fill(all(dp[0]),1);
vector<ll> dp(x);
dp[0]=1;

for(ll mask = 0; mask < x-1; mask ++){
	ll a = __builtin_popcount(mask) + 1;
	for(ll b = 1; b<=n; b++){
		ll m2 = 1<<(b-1);
		if((!(mask&m2)) && can[a][b]){
			// assert(mask|m2 < x);
			// assert(a<=n);
			add_self(dp[mask|m2], dp[mask]);
		}
	}
}
cout << dp[x-1];
	
}


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

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

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int n,k; cin>>n>>k;
	map<int,ll> ct;
	for (int i=1; i<=n; i++)
		ct[i%k]++;
	ll ret=0;
	for (int a=0; a<k; a++) {
		int b=(k-a)%k, c=(k-b)%k;
		if((c+a)%k)
			continue;
		ret+=ct[a]*ct[b]*ct[c];
	}
	cout << ret << endl;
	return 0;
}


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

int n,s,arr[11],sum;

int main(){
	cin>>n;
	for (int i = 1;i <= n;i++){
		cin>>arr[i];
		sum+= arr[i];
	}
	sort(arr + 1,arr + 11);
	if(arr[10] < sum - arr[10]){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
  using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define ll  long long
  #define ld long double
  #define pb push_back
  #define mp3 make_pair
  #define rep1(i,a,b) for(ll i=a;i<=b;i++)
  #define rep2(i,a,b) for(ll i=a;i<b;i++)
  const ll  mod=998244353;
  template<typename T> T pow(T a,T b, long long m){T ans=1; while(b>0){ if(b%2==1) ans=(ans*a)%m; b/=2; a=(a*a)%m; } return ans%m; }
  template<typename T> T add(T a,T b,ll m){a+=b;while(a>=0)a-=m;while(a<0)a+=m; return a;}
  template<typename T> T mul(T a,T b,ll m){return (a*1ll*b)%m;}

 int main(){
   IOS;
   string s,t;
   cin>>s>>t;
   ll j=0,i=0,cnt=0;
   ll n=s.length();
   ll m=t.length();
   ll ans=0;
   while(j+m-1<n){
     ll cnt=0,mx=0;
     for(ll i=j;i<j+m;i++){
       if(s[i]==t[cnt])
       mx++;
       cnt++;
     }
     ans=max(mx,ans);
     j++;
   }
   cout<<m-ans<<endl;
 }

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

typedef map<int, set<int> > msi;

#define F first
#define S second

const int inf = 2e9;

int n, ans;
msi xup, xdown, yleft, yright;
msi upm, upp, downm, downp;
msi leftm, leftp, rightm, rightp;

void relax(msi &a, msi &b, int mult) {
	for (auto &t: a) {
		if (!b.count(t.F)) continue;
		for (int i: t.S) {
			auto it = b[t.F].lower_bound(i);
			if (it == b[t.F].end()) continue;
			ans = min(ans, (*it - i) * mult);
		}
	}
}

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		int x, y; char d;
		cin >> x >> y >> d;
		if (d == 'U') {
			xup[x].insert(y);
			upm[x - y].insert(y);
			upp[x + y].insert(y);
		} else if (d == 'D') {
			xdown[x].insert(y);
			downm[x - y].insert(y);
			downp[x + y].insert(y);
		} else if (d == 'L') {
			yleft[y].insert(x);
			leftm[x - y].insert(y);
			leftp[x + y].insert(y);
		} else {
			yright[y].insert(x);
			rightm[x - y].insert(y);
			rightp[x + y].insert(y);
		}
	}
	ans = inf;
	relax(xup, xdown, 5);      
	relax(yright, yleft, 5);  
	relax(upm, leftm, 10);    
	relax(upp, rightp, 10);    
	relax(rightm, downm, 10);  
	relax(leftp, downp, 10);  
	if (ans == inf) cout << "SAFE";
	else cout << ans;
}


Measured memory_bytes: 87768
s=input()
t=input()
s=s+s
count=0
flag=False
for i in range(len(s)):
  if count==len(t):
    break
  if s[i]==t[count] and flag==False:
    flag=True
    count+=1
  elif s[i]==t[count]:
    count+=1
  else:
    count=0
    flag=False
if count==len(t):
  print("Yes")
else:
  print("No")
    



Measured memory_bytes: 3060
#include<stdio.h>

int main(void)

{

int ai,n,i,min,max;

long sum;

scanf("%d",&n);

for(i=0;i<n;i++)

{

scanf("%d",&ai);

if(i==0)

{

min=ai;

max=ai;

sum=ai;

}

else{

sum=sum+ai;

if(min>ai){

min=ai;

}

if(max<ai){

max=ai;

}

}

}

printf("%d %d %ld\n",min,max,sum);

return 0;

}

Measured memory_bytes: 600
// ProblemURL : https://atcoder.jp/contests/cf17-final/tasks/cf17_final_b
// ---------------------------------------------
package main

import "fmt"

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func main() {
	var s string
	fmt.Scan(&s)
	ct := [3]int{}
	for _, ss := range s {
		ct[ss-'a']++
	}
	ok := abs(ct[0]-ct[1]) <= 1 && abs(ct[1]-ct[2]) <= 1 && abs(ct[2]-ct[0]) <= 1
	if ok {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


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

#define lld long long
#define pi pair<int, int>
#define pl pair<lld, lld>
#define mem0(x) memset(x, 0, sizeof(x))
#define fillnum(x, n) fill(begin(x), end(x), n)
#define asort(x) sort(x.begin(), x.end())
#define dsort(x, t) sort(x.begin(), x.end(), greater<t>())

int main() {
    string S, T;
    cin >> S;
    cin >> T;
    for(int i = 0; i < S.size(); i++) {
        if(S[i] != T[i]) {
            cout << "No" << endl;
            exit(0);
        }
    }
    if(S.size() + 1 != T.size()) {
        cout << "No" << endl;
        exit(0);
    }
    cout << "Yes" << endl;
}

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

using namespace std;
using ll = long long;
using P = pair<int, int>;

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

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

  vector<P> p;

  rep(i, m) {
    int s, c;
    cin >> s >> c;
    --s;
    p.push_back({s, c});
  }

  rep(i, 1000) {
    int x = i / 10;
    vector<int> d{i % 10};
    while (x > 0) {
      d.push_back(x % 10);
      x /= 10;
    }

    reverse(d.begin(), d.end());

    if (d.size() != n) continue;

    bool ok = true;
    rep(j, m) {
      if (d[p[j].first] != p[j].second) ok = false;
    }

    if (ok) {
      for (int v : d) {
        cout << v;
      }
      cout << '\n';
      return 0;
    }
  }

  cout << -1 << '\n';

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<algorithm>
#include<functional>
typedef long long ll;
int main() {
	ll n = 0, m = 0, f = 0;
	std::cin >> n >> m;
	if (n > m) { f = m; m = n; n = f; }
	if (n == 1 && m == 1) { std::cout << '1' << std::endl; return 0; }
	if (n == 1) { std::cout << m - 2 << std::endl;		   return 0; }
	std::cout << (n - 2)*(m - 2) << std::endl;
	return 0;
}

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

const int maxn = 1e5 + 5;

struct Point {
    double X, Y;

    void Input() {
        scanf("%lf%lf", &X, &Y);
    }

    void Output() {
        printf("(%lf,%lf)", X, Y);
    }

    Point operator - (const Point &B) const {
        return Point {X - B.X, Y - B.Y};
    }

    double operator * (const Point &B) const {
        return X * B.X + Y * B.Y;
    }
    
    double operator ^ (const Point &B) const {
        return X * B.Y - Y * B.X;
    }

    bool operator < (const Point &B) const {
        return X < B.X;
    }
};

double Distance(Point A, Point B) {
    return sqrt((B - A) * (B - A));
}

struct Line {
    Point S, T;

    void Input() {
        S.Input();
        T.Input();
    }

    Point operator & (const Line &B) const {
        double Temp = ((S - B.S) ^ (B.S - B.T)) / ((S - T) ^ (B.S - B.T));
        return Point {S.X + (T.X - S.X) * Temp, S.Y + (T.Y - S.Y) * Temp};
    }
};

struct Statu {
    int Left, Right;
    double Length;

    bool operator < (const Statu &B) const {
        return Length > B.Length;
    }
};

int N;
int Tot;
Point points[maxn];
set<pair<int, int> > Vis;

void Init() {
    for (int i = 0; i < N; ++i) {
        double Height = points[i].Y;
        Line SkyLine = Line {Point {-1005.0, Height}, Point {1005.0, Height}};
        for (int j = 0; j < N - 1; ++j) {
            if ((Height - points[j].Y) * (Height - points[j + 1].Y) < 0) {
                points[Tot++] = SkyLine & Line {points[j], points[j + 1]};
            }
        }
    }
    sort(points, points + Tot);
}

double Bfs() {
    Vis.clear();
    priority_queue<Statu> Que;
    Que.push(Statu {0, Tot - 1, 0.0});
    while (!Que.empty()) {
        Statu Cur = Que.top(); Que.pop();
        if (Cur.Left == Cur.Right) {
            return Cur.Length;
        }
        if (Vis.find(make_pair(Cur.Left, Cur.Right)) != Vis.end()) {
            continue;
        }
        Vis.insert(make_pair(Cur.Left, Cur.Right));
        for (int i = -1; i < 2; ++i) {
            for (int j = -1; j < 2; ++j) {
                if (i || j) {
                    int LeftIndex = Cur.Left + i, RightIndex = Cur.Right + j;
                    if (LeftIndex >= 0 && LeftIndex < Tot && RightIndex >= 0 && RightIndex < Tot) {
                        if (points[LeftIndex].Y == points[RightIndex].Y) {
                            Que.push(Statu {LeftIndex, RightIndex, Cur.Length + Distance(points[Cur.Left], points[LeftIndex]) + Distance(points[Cur.Right], points[RightIndex])});
                        }
                    }
                }
            }
        }
    }
    return 0.0;
}

int main(int argc, char *argv[]) {
    while (~scanf("%d", &N) && N) {
        Tot = 0;
        for (int i = 0; i < N; ++i) {
            points[Tot++].Input();
        }
        Init();
        printf("%.10lf\n", Bfs());
    }
    return 0;
}



Measured memory_bytes: 18416
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<ctime>
#include<map>
#include<bitset>
#include<set>
#define LL long long
#define mp(x,y) make_pair(x,y)
#define pll pair<long long,long long>
#define pii pair<int,int>
using namespace std;
inline int read()
{
	int f=1,x=0;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int stack[20];
template<typename T>inline void write(T x)
{
	if(x<0){putchar('-');x=-x;}
    if(!x){putchar('0');return;}
    int top=0;
    while(x)stack[++top]=x%10,x/=10;
    while(top)putchar(stack[top--]+'0');
}
template<typename T>inline void pr1(T x){write(x);putchar(' ');}
template<typename T>inline void pr2(T x){write(x);putchar('\n');}
const int MAXN=100005;
struct edge{int x,y,c,next;}a[2*MAXN];int len,last[MAXN];
void ins(int x,int y,int c){len++;a[len].x=x;a[len].y=y;a[len].c=c;a[len].next=last[x];last[x]=len;}

int vis[MAXN];bool tf;
int col[MAXN],si[5],tim,sum,sum1;
void dfs(int x)
{
	vis[x]=1;++si[col[x]];++sum1;
	for(int k=last[x];k;k=a[k].next)
	{
		int y=a[k].y;
		if(a[k].c==1)++sum;
		int u=(col[x]+a[k].c+3)%3;
		if(!vis[y])col[y]=u,dfs(y);
		else if(col[y]!=u)tf=true;
	}
}
int n,m;
int main()
{
	n=read();m=read();
	for(int i=1;i<=m;i++)
	{
		int x=read(),y=read();
		ins(x,y,1);ins(y,x,-1);
	}LL ans=0;
	for(int i=1;i<=n;i++)if(!vis[i])
	{
		sum=tf=sum1=si[0]=si[1]=si[2]=0;++tim;dfs(i);
		if(tf)ans+=1LL*sum1*sum1;
		else if(si[0]&&si[1]&&si[2])ans+=1LL*si[0]*si[1]+1LL*si[1]*si[2]+1LL*si[2]*si[0];
		else ans+=sum;
	}pr2(ans);
	return 0;
}


Measured memory_bytes: 7680
#include <stdio.h>

int taxi;
int train;

int n;
int a;
int b;

int main(void){
    scanf( "%d %d %d", &n, &a, &b);
    while(1 <= n <= 20 && 1 <= a <= 50 && 1 <= b <= 50){
        taxi =  b;
        train = n*a;
        if(taxi<train){
            printf("%d\n",taxi);
        }else{
            printf("%d\n",train);
        }
        break;
    }
    return 0;
}

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

int main(){
    int n;
    cin>>n;
    map<string,int> m;
    string s[n];
    set<string> se;
    rep(i,n){
        cin>>s[i];
        m[s[i]]++;
        se.insert(s[i]);
    }

    int ma=0;
    rep(i,n){
        ma=max(ma,m[s[i]]);
    }

    vector<string> ans;
    for(auto x : se){
        if(m[x]==ma) ans.push_back(x);
    }
    
    sort(all(ans));

    rep(i,ans.size()) cout<<ans[i]<<endl;
}

Measured memory_bytes: 37876
#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
#include<algorithm>
#include<functional>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

#define rep(i,x,y) for(int i=(x); i<(y); ++i)

template <typename T>
void vec_print(vector<T> VEC){
  rep(i, 0, VEC.size()){
    cout << VEC[i] << " ";
  }
  cout << "\n";
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  rep(i, 0, MAT.size()){
    rep(j, 0, MAT[i].size()){
      cout << MAT[i][j] << " ";
    }
    cout << "\n";
  }
};

template <typename CLASS1, typename CLASS2>
class HOGE{
  public:
    CLASS1 key;
    CLASS2 value;
    HOGE(ll key, ll value){
      this->key = index;
      this->value = value;
    };
    ~HOGE(void){
      return;
    };

    void print(void){
      cout << "key : " << key << ", value : " << value << "\n";
      return;
    };
    
    bool operator==(const HOGE &obj){
      return (this->value == obj.value);
    };
    bool operator<(const HOGE &obj){
      return (this->value < obj.value);
    };
    bool operator>(const HOGE &obj){
      return (this->value > obj.value);
    };
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;

ll dp[400][400];
ll a[400];

/*
ll search(const int start, const int end){
  if(start>=end) return dp[start][end]=0;
  if(dp[start][end]>=0) return dp[start][end];
  if(start+1==end) return dp[start][end] = a[start]+a[end];
  ll tmp=INFLL;
  ll sum=0;
  rep(i, start, end){
    ll tmp1 = search(start, i);
    ll tmp2 = search(i+1, end);
    tmp = min(tmp, tmp1+tmp2);
    sum += a[i];
  }
  sum += a[end];
  return dp[start][end] = tmp+sum;
}
*/

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll N;
  cin >> N;
  //vll a(N);
  rep(i, 0, N){
    cin >> a[i];
  }

  //vvll dp(N, vll(N, -1));
  memset(dp, -1, sizeof(dp));

  //cout << search(0, N-1) << "\n";

  rep(start, 0, N-1){
    dp[start][start+1] = a[start] + a[start+1];
    dp[start][start]=0;
  }
  dp[N-1][N-1]=0;

  rep(diff, 2, N){
    rep(start, 0, N-diff){
      //calc dp[start][start+diff]
      dp[start][start+diff] = INFLL;
      ll tmp = 0;
      rep(i, start, start+diff){
        dp[start][start+diff] = min(dp[start][start+diff], dp[start][i] + dp[i+1][start+diff]);
        tmp += a[i];
      }
      tmp += a[start+diff];
      dp[start][start+diff] += tmp;
    }
  }

  cout << dp[0][N-1] << "\n";

  return 0;
}


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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

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

    cout << ((r < 1200) ? "ABC" : (r < 2800) ? "ARC" : "AGC") << '\n';
    return 0;
}


Measured memory_bytes: 3640
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10

#solve
def solve():
    n = II()
    a = IR(n)
    if sum(map(lambda x: x & 1, a)):
        print("first")
    else:
        print("second")
    return


#main
if __name__ == '__main__':
    solve()


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

int main()
{
  int N, D;
  cin >> N >> D;
  if(N%(D*2+1))
    cout << N/(D*2+1)+1<< endl;
  else
    cout << N/(D*2+1)<< endl;
  return 0;
}

Measured memory_bytes: 256
A, B, C, D = map(int, input().split())

sub_c = (A - 1) // C
all_c = (B) // C
bic = all_c - sub_c


sub_d = (A - 1) // D
all_d = (B) // D
bid = all_d - sub_d

def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a

#最小公倍数
def lcm(a,b):
    return a*b//gcd(a,b)

tmp = lcm(C,D)
sub_tmp = (A - 1) // tmp
all_tmp = (B) // tmp
bitmp = all_tmp - sub_tmp

sub_all = bid + bic - bitmp


print((B - A) + 1 - sub_all)

Measured memory_bytes: 38256
#include <iostream>
#include <climits>
#include <stack>
#include <queue>
#include <string>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
 
using namespace std;
 
typedef long long ll;
 
typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.141592653589;
const int mod = 1000000007;
// memset(a,0,sizeof(a)); →全部０にする
 
vector<int> G[100005];
std::vector<P> tree[100010];
 
int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
 
#define p(x) cout<<x<<endl;
#define e cout<<endl;
#define pe(x) cout<<x<<" ";
#define re(i,a,b) for(i=a;i<=b;i++)
 
ll i,j,k,l,ii,jj;
ll n,m;
ll a,b,c;
ll h,w;

ll ans=0;
ll sum=0;
ll memo,num;
bool dame=false;
bool x[500005];//素数ならtrue

int main(){
	cin>>n;
	
	for(i=1;i<=500000;i++){
		x[i]=true;
	}
	x[1]=false;
	x[2]=true;
	for(i=1;i<=500000;i++){
		if(!x[i])continue;
		for(j=2;j*i<=500000;j++){
			x[i*j]=false;
		}
	}
	k=0;
	for(i=1;i<=500000;i++){
		if(k>=n)break;
		if(x[i] && i%5==1 && k<n){
			pe(i);
			k++;
		}
	}
	e;

	
	return 0;
				
}

Measured memory_bytes: 5376
while line = gets.chomp
  break if line == "0"
  ary = []
  max = -100001
  line.to_i.times do
    n = gets.to_i
    ary << 0
    ary.map!{|v| v + n}
    max_temp = ary.max
    max = max_temp if max_temp > max
  end
  puts max
end

Measured memory_bytes: 6104
#include <stdio.h>

int main()
{
    int n;
    scanf("%d", &n);
    int a[n];
    int pre;
    for (pre = 0; pre < n; pre++)
    {
        scanf("%d", &a[pre]);
    }

    int i;
    int num = 0;
    for (i = 0; i <= n - 1; i++)
    {
        int minj = i;
        int j;
        for (j = i; j <= n - 1; j++)
        {
            if (a[j] < a[minj])
            {
                minj = j;
            }
        }
        if (a[i] != a[minj])
        {
            int temp = a[i];
            a[i] = a[minj];
            a[minj] = temp;
            num++;
        }
    }
    for (pre = 0; pre < n; pre++)
    {
        printf("%d", a[pre]);
        if (pre < n - 1)
        {
            printf(" ");
        }
    }
    printf("\n%d\n", num);
    return 0;
}

// 1 selectionSort(A, N) // N個の要素を含む0-オリジンの配列A
// 2   for i が 0 から N-1 まで
// 3     minj = i
// 4     for j が i から N-1 まで
// 5       if A[j] < A[minj]
// 6         minj = j
// 7     A[i] と A[minj] を交換


Measured memory_bytes: 2124
#include <iostream>
#include <string>

using namespace std;

#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define pb push_back

// #define int long long

int main(){
    int count=0;
    string s;
    string t="CODEFESTIVAL2016";
    cin>>s;

    for(int i=0;i<t.size();i++){
        if(s[i]!=t[i])count++;
    }

    cout<<count<<endl;
}

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

int digit_sum(int n){
    if (n < 10)
        return n;
    return digit_sum(n / 10) + n % 10;
}

bool is_dudeney(int x, int t){
    if(digit_sum(x)==t)
        return true;
    else    return false;
}

int main(){
    double a,n,m;
    int ans(0);
    cin >> a >> n >> m;

    for(int i=1;i<100000;i++){
        int x = pow(double(i+a),n);
        if(m>=x){
            if(is_dudeney(x,i)){
                ans++;
            }   
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, M;
  cin >> N >> M;
  vector<map<int, pair<int, int>>> E(N);
  for (int i = 0; i < M; i++){
    int X, Y;
    cin >> X >> Y;
    X--;
    Y--;
    E[X][Y] = make_pair(1, i + 1);
    E[Y][X] = make_pair(1, - (i + 1));
  }
  int S, T;
  cin >> S >> T;
  S--;
  T--;
  int F = 0;
  while (1){
    vector<int> prev(N, -1);
    vector<bool> used(N, false);
    used[S] = true;
    queue<int> Q;
    Q.push(S);
    while (!Q.empty()){
      int v = Q.front();
      Q.pop();
      for (auto P : E[v]){
        if (P.second.first > 0){
          int w = P.first;
          if (!used[w]){
            used[w] = true;
            prev[w] = v;
            Q.push(w);
          }
        }
      }
    }
    if (!used[T]){
      break;
    }
    int v = T;
    while (v != S){
      E[prev[v]][v].first--;
      E[v][prev[v]].first++;
      v = prev[v];
    }
    F++;
  }
  set<int> st;
  for (int i = 0; i < N; i++){
    for (auto P : E[i]){
      if (P.second.first == 2 && P.second.second > 0){
        st.insert(P.second.second);
      }
    }
  }
  cout << F << endl;
  int R = st.size();
  cout << R << endl;
  for (int id : st){
    cout << id << endl;
  }
}


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

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

  int n;
  cin >> n;
  n %= 1000;
  n = 1000 - n;
  n %= 1000;
  cout << n << "\n";
}


Measured memory_bytes: 3656
#include <iostream>
#include <string>
#include <map>
#include <algorithm>
#include <math.h>
#define rep(i,s,n)for(int i = s;i<n;i++)
#define repe(i,s,n)for(int i = s;i<=n;i++)
using namespace std;
typedef long long ll;
static const ll MOD = 1e9 + 7;

ll a[20][20] = {};
int main() {
	ll n, d; cin >> n >> d;

	rep(i, 0, n)rep(j, 0, d) {
		cin >> a[i][j];
	}
	ll ans = 0;
	rep(i, 0, n)rep(j, i + 1, n) {
		if (i != j) {
			double X = 0;
			rep(k, 0, d) {
				X += (a[i][k] - a[j][k])*(a[i][k] - a[j][k]);
			}
			double Y = sqrt(X);
			int Z = sqrt(X);
			if (Y == Z)ans++;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
using System;

class Program
{
    static void Main(string[] args)
    {
        var input = Console.ReadLine().Split(' ');
        var wight = Convert.ToInt32(input[0]);
        var height = Convert.ToInt32(input[1]);

        Console.WriteLine(wight * height + 1 - wight - height);
    }
}


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


int main() {
  int n=0,temp,count=0,i;
  cin>>n;
  vector<int>data(n);
  for(int i=0;i<n;i++){
    cin>>data.at(i);
    data.at(i)--;
  }
  
  for(i=0;i<n;i++){
    temp=data.at(temp);
    if(temp==1) break;
}
  if(i==n)cout << -1<<endl;
  else cout << i+1<<endl;
      
}


Measured memory_bytes: 640
program sample
    implicit none
  
    integer(8) :: i,j,m,n,s,t,xi,yi,a,b,c
   
    integer(8),allocatable :: x(:),y(:)
  
    read(*,*) a,b,m
    allocate(x(a),y(b))
    read(*,*)x
    read(*,*)y
    s=minval(x)+minval(y)
    do i=1,m
        read(*,*)xi,yi,c
        if (x(xi)+y(yi)-c<s)then
            s=x(xi)+y(yi)-c
        end if
    end do


  
    write(*,*) s
  
    stop
end program sample
  



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

int main() {
  int N, K;
  scanf("%d %d\n", &N, &K);
  vector<int> h(N);
  for (int i = 0; i < N; i++) {
    scanf("%d", &h[i]);
  }

  vector<int> dp(N);
  dp[0] = 0;
  for (int i = 1; i < N; i++) {
    int ans = INT_MAX;
    for (int j = max(i - K, 0); j < i; j++) {
      ans = min(ans, dp[j] + abs(h[i] - h[j]));
    }
    dp[i] = ans;
  }

  printf("%d\n", dp[N-1]);
}

Measured memory_bytes: 1024
import sys
 
stdin = sys.stdin
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda x: [na() for _ in range(x)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda x: [ns() for _ in range(x)]
nas = lambda: stdin.readline().split()

a = na()
a.sort()
print(a[0] + a[1])

Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main() {
  int K, A, B;
  cin >> K >> A >> B;
  bool result = (A % K == 0) || (B % K == 0) ||
    (0 < (B / K - A / K));
  cout << (result ? "OK" : "NG") << endl;
  return 0;
}


Measured memory_bytes: 3600
defmodule Main do
  def main do
      [a, b, k] =
      IO.read(:line)
      |> String.trim
      |> String.split(" ")
    a = String.to_integer(a)
    b = String.to_integer(b)
    k = String.to_integer(k)
    ans1 = a..Enum.min([a + k - 1, b])
    ans2 = Enum.max([b - k + 1, Enum.min([a + k - 1, b])])..b
    Enum.to_list(ans1) ++ Enum.to_list(ans2) |> Enum.dedup |> Enum.each(fn x -> IO.puts(x) end)  
  end
end


Measured memory_bytes: 30756
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <stdio.h>
#include <string.h>
using ll = long long;

//LLONG_MAX
#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
using namespace std;


int A, B;

signed main()
{
	cin >> A >> B;
	int a = A + B;
	int b = A - B;
	int c = A * B;

	int ans = MAX(a, MAX(b, c));

	cout << ans << endl;
}











Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N(0);
  cin >> N; 
  string color[N];
  for(int i = 0; i < N; i++)
  {
   	cin >> color[i];
  }
  
  for(int i = 0; i < N; i++)
  {
	if( color[i] == "Y" )
    {
      cout << "Four" << endl;
      return 0;
    }	
  }
  cout << "Three" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<queue>
#include<vector>
#include<map>
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for (int i=a;i>=b;i--)
#define LL long long
#define INF (2147483647)
#define sqr(x)  ((x)*(x))
#define mod (1000000007)
using namespace std;
inline void read(int &data){
    data=0; 
	int w=1; char ch=0;
    while (ch!='-'&&(ch<'0'||ch>'9')) ch=getchar();
    if (ch=='-') w=-1,ch=getchar();
    while  (ch>='0' && ch<='9') data=data*10+ch-'0',ch=getchar();
    data=data*w;
}
inline void read(LL &data){
    data=0;
	int w=1; char ch=0;
    while (ch!='-'&&(ch<'0'||ch>'9')) ch=getchar();
    if (ch=='-') w=-1,ch=getchar();
    while  (ch>='0' && ch<='9') data=data*10+ch-'0',ch=getchar();
    data=data*w;
}
inline void write(int x){
    if(x<0) putchar('-'),x=-x;
    if(x>9) write(x/10);
    putchar(x%10+'0');
} 
inline void write(LL x){
    if(x<0) putchar('-'),x=-x;
    if(x>9) write(x/10);
    putchar(x%10+'0');
}
int n,m,v[200005],a[200005];
int main(){
	read(n),read(m);
	memset(v,true,sizeof(v));
	rep(i,1,m){
		read(a[i]);
	}
	per(i,m,1){
		if (v[a[i]]){
			write(a[i]),puts("");
			v[a[i]]=false;
		}
	}
	rep(i,1,n)	if (v[i])	write(i),puts("");
}

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

int main() {
  int N,T;
  cin>>N>>T;
  
  int c[110],t[110];
  for(int i=0;i<N;++i){
    cin>>c[i]>>t[i];
  }
  
  int min=10000;
  for(int i=0;i<N;++i){
    if(t[i]<=T && c[i]<min)
      min=c[i];
  }
  
  if(min==10000)
    cout<<"TLE"<<endl;
  else
    cout<<min<<endl;
}


Measured memory_bytes: 256
// ABC 145-B
// 2019.11.16 bal4u

#include <stdio.h>

char S[105];

int main()
{
	int i, N;
	
	scanf("%d%s", &N, S);
	if (N & 1) puts("No");
	else {
		N /= 2;
		for (i = 0; i < N; i++) {
			if (S[i] != S[N+i]) { puts("No"); return 0; }
		}
		puts("Yes");
	}
	return 0;
}


Measured memory_bytes: 128
# -*- coding: utf-8 -*-
"""
A - T or T
https://atcoder.jp/contests/abc133/tasks/abc133_a

"""
import sys


def main(args):
    n, a, b = map(int, input().split())
    ans = min(n * a, b)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])


Measured memory_bytes: 2940
package main

import (
	"fmt"
)

func max(a, b, c int) int {
	if a <= b {
		if b <= c {
			return c
		}
		return b
	}
	if a <= c {
		return c
	}
	return a
}

func main() {
	var a, b int
	fmt.Scan(&a, &b)
	fmt.Println(max(a+b, a-b, a*b))
}


Measured memory_bytes: 512
#include<iostream>
using namespace std;
int main(){
	int x,y,z,w;
	for (x = 1, z = 1; z <= 9; z++, x++){
		for (y = 1, w = 1; w <= 9; w++, y++){
			cout << x << "x" << y << "=" << x * y << endl;
		}
	}








	return 0;
}


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

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

  vector<char> s;
  for( int i = 0; i < buf.size(); i++ ) {
    if( buf[ i ] == 'B' ) {
      if( s.size() != 0 ) {
        s.pop_back();
      }
    }
    else {
      s.push_back( buf[ i ] );
    }
  }

  for( int i = 0; i < s.size(); i++ ) {
    cout << s[ i ];
  }
  cout << endl;

  return 0;
}



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

#define ll long long
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define ii pair < int, int >
#define vi vector < int > 
#define all(a) (a).begin(), (a).end()

using namespace std;

const int MAXN = 2e5 + 10;

void solve() {
	int n;
	cin >> n;
	bool ok = true;
	for( int i = 0;i < n;i++ ) {
		int x;cin >> x;
		if ( x % 2 ) continue;
		if ( x % 3 && x % 5 ) ok = false;
	}
	puts( ok ? "APPROVED" : "DENIED" );
}

int main() {
	int t = 1;
	//cin >> t;
	while ( t-- ) solve();
	return 0;
}


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

void solve(){
    double x;
    cin>>x;
    x=x/3;
    double res=pow(x,3);
    printf("%0.12lf",res);
}

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    solve();
    return 0;
}

Measured memory_bytes: 256
///Bismillahir Rahmanir Rahim
///ALLAH HU AKBAR

#include<bits/stdc++.h>
using namespace std;
int main()
{
    string a;

    cin>>a;
    if(a=="SUN")
        cout<<'7'<<endl;
    else if(a=="MON")
        cout<<'6'<<endl;
    else if(a=="TUE")
        cout<<'5'<<endl;
    else if(a=="WED")
        cout<<'4'<<endl;
    else if(a=="THU")
        cout<<'3'<<endl;
    else if(a=="FRI")
        cout<<'2'<<endl;
    else if(a=="SAT")
        cout<<'1'<<endl;
}


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

#define pb push_back
#define all(a) (a).begin(), (a).end()

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

int main() {
	ios::sync_with_stdio(false);cin.tie(nullptr);
	int s, w; cin >> s >> w;
	cout << (w >= s ? "unsafe" : "safe") << '\n';
}
 


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPi(i, a, b) for(int i=int(a); i<int(b); i++)
#define MEMS(a,b) memset(a,b,sizeof(a))
#define mp make_pair
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll MOD = 1e9+7;

class SegTree{
    int n;
    vector<int> node;

    public:
    SegTree(vector<int> v){
        n = 1;
        while(n < v.size()) n *= 2;

        node.resize(2*n - 1, 0);
        for(int i = 0; i < v.size(); i++)
            node[n-1 + i] = v[i];
        for(int i = n-2; i >= 0; i--)
            node[i] = node[2*i+1] + node[2*i+2];
    }

    void update(int i, int x){
        i += n-1;
        node[i] = x;
        while(i > 0){
            i = (i-1)/2;
            node[i] = node[2*i+1] + node[2*i+2];
        }
    }

    int get_sum(int l, int r, int k=0, int a=0, int b=-1){
        if(b < 0) b = n;

        if(l <= a && b <= r)
            return node[k];

        if(r <= a || b <= l)
            return 0;

        int vl = get_sum(l, r, 2*k+1, a, (a+b)/2);
        int vr = get_sum(l, r, 2*k+2, (a+b)/2, b);
        return vl+vr;
    }
};

SegTree* tree[30];
vector<int> X[30];

int main(){
    ll N;
    string S;
    cin >> N >> S;
    ll Q;
    cin >> Q;

    REP(i,30)
        X[i].resize(N);

    REP(i,N){
        int c = S[i] - 'a';
        X[c][i] = 1;
    }

    REP(i,30){
        tree[i] = new SegTree(X[i]);
    }

    REP(q,Q){
        int type;
        cin >> type;
        if(type == 1){
            int i;
            char c;
            cin >> i >> c;
            i--;
            //s -> t
            int s, t;
            t = c - 'a';
            s = S[i] - 'a';
            tree[s]->update(i, 0);
            tree[t]->update(i, 1);
            S[i] = c;
        }
        else if(type == 2){
            int l, r;
            cin >> l >> r;
            l--, r--;
            int ans = 0;
            REP(i,30){
                int n = tree[i]->get_sum(l, r+1);
                if(n > 0) ans++;
            }
            cout << ans << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 184416
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String S = scanner.next();
		int ans = 0;
		switch(S) {
		case "SUN":
			ans = 7;
			break;
		case "MON":
			ans = 6;
			break;
		case "TUE":
			ans = 5;
			break;
		case "WED":
			ans = 4;
			break;
		case "THU":
			ans = 3;
			break;
		case "FRI":
			ans = 2;
			break;
		case "SAT":
			ans = 1;
			break;
		default:
			break;
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define ld long double

using namespace std;

int main(){
  int ans = 0;
  ld n, d;
  cin >> n >> d;
  for (int i = 0; i < n; i++){
    ld a, b;
    cin >> a >> b;
    if (hypotl(a, b) <= d)
      ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3872