akhauriyash/Code-Regression huggingface dataset:
//19
#include<iostream>
#include<complex>
#include<algorithm>

using namespace std;

typedef complex<double> P;

double cr(P a,P b){
  return a.real()*b.imag()-a.imag()*b.real();
}

double dot(P a,P b){
  return a.real()*b.real()+a.imag()*b.imag();
}

bool is(P a,P b,P c,P d){
  return (a.real()<=d.real())==(c.real()<=b.real())
    &&(a.imag()<=d.imag())==(c.imag()<=b.imag())
    &&cr(a-b,c-b)*cr(a-b,d-b)<=0&&cr(c-d,a-d)*cr(c-d,b-d)<=0;
}

double dt(P a,P b,P c,P d){
  P p[4]={a,b,c,d};
  double m=1<<30;
  for(int i=0;i<2;i++){
    for(int j=0;j<2;j++){
      m=min(m,abs(p[i]-p[j+2]));
    }
  }
  for(int i=0;i<2;i++){
    swap(p[0],p[2]);
    swap(p[1],p[3]);
    for(int j=0;j<2;j++){
      if(dot(p[2+j]-p[0],p[1]-p[0])*dot(p[2+j]-p[1],p[0]-p[1])>0){
	m=min(m,fabs(cr(p[2+j]-p[0],p[1]-p[0]))/abs(p[1]-p[0]));
      }
    }
  }
  //  cout<<a<<' '<<b<<' '<<c<<' '<<d<<' '<<m<<endl;
  return m;
}

int main(){
  for(int n;cin>>n,n;){
    int sx,sy,ex,ey;
    cin>>sx>>sy>>ex>>ey;
    P s=P(sx,sy),e=P(ex,ey);
    int ix[50],iy[50],ax[50],ay[50],h[50];
    P ll[50],hl[50],hh[50],lh[50];
    bool on=false;
    for(int i=0;i<n;i++){
      cin>>ix[i]>>iy[i]>>ax[i]>>ay[i]>>h[i];
      ll[i]=P(ix[i],iy[i]);
      hl[i]=P(ax[i],iy[i]);
      hh[i]=P(ax[i],ay[i]);
      lh[i]=P(ix[i],ay[i]);
      on|=is(s,e,ll[i],hl[i])|is(s,e,hl[i],hh[i])|is(s,e,hh[i],lh[i])|is(s,e,lh[i],ll[i]);
      on|=ix[i]<=min(sx,ex)&&max(sx,ex)<=ax[i]&&iy[i]<=min(sy,ey)&&max(sy,sy)<=ay[i];
    }
    if(on){
      cout<<0<<endl;
    }else{
      double m=1<<30;
      for(int i=0;i<n;i++){
	P *p[4]={ll+i,hl+i,hh+i,lh+i};
	for(int j=0;j<4;j++){
	  double d=dt(*p[j],*p[(j+1)%4],e,s);
	  if(d<h[i]){
	    m=min(m,d);
	  }else{
	    m=min(m,(d*d+h[i]*h[i])/2/h[i]);
	  }
	}
      }
      cout<<fixed<<m<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1264
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>
#include<math.h>

#define DIV 1000000007
using namespace std;
using ll = long long;

typedef struct {
	vector<int> edge;
	ll dis = 1e10;
}node_t;
vector<node_t> node;

int main(void) {
	int N, M;
	cin >> N >> M;
	
	node = vector<node_t>(3*N + 1);
	for (int i = 0; i < M; i++) {
		int a, b;
		cin >> a >> b;
		node[a].edge.push_back(b+N);
		node[a+N].edge.push_back(b+2*N);
		node[a + 2 * N].edge.push_back(b);
	}

	int S, T;
	cin >> S >> T;

	queue<int> q;

	vector<bool> visit(3*N + 1);
	q.push(S);
	visit[S] = true;
	node[S].dis = 0;
	ll cnt = 0;
	while (!q.empty()&&cnt<=1e7) {
		int x = q.front();
		q.pop();	
		for (auto to : node[x].edge) {
			if (visit[to]) continue;
			visit[to] = true;
			q.push(to);
			node[to].dis = node[x].dis + 1;
			cnt++;
		}
	}

	if (node[T].dis == 1e10)
		cout << -1 << endl;
	else
		cout << node[T].dis/3 << endl;

}


Measured memory_bytes: 19072
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  int N;
  cin >> N;
  string S,T;
  cin >> S >> T;
  string ans = "";
  for (int i = 0; i < N; i++) {
    ans += S[i];
    ans += T[i];
  }
  cout << ans << endl;
  return 0;
}

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

int main(){
  
  int n, v, w;
  char t;
  long long d;
  string s;
  
  cin >> n;
  tuple<int, int, char, long long, string> goods[n];
  for(int i = 0;i < n;i++){
    cin >> v >> w >> t >> d >> s;
    goods[i] = make_tuple(v, w, t, d, s);
  }
  
  sort(goods, goods + n);
  
  for(int i = 0;i < n;i++){
    tie(v, w, t, d, s) = goods[i];
    cout << v << " " << w << " " << t << " " << d << " " << s << endl;
  }
  
  return 0;
}


Measured memory_bytes: 12412
/////////////////////////////////////////////////////////
//
//  c/temp.cpp file
//  Last Updated: 2018-10-23 ...Maybe
//
//    I hope you adding this code to the setting file
//    alias g++='g++ -std=c++1y -DDEBUG_LOCAL'
//
/////////////////////////////////////////////////////////

#include <bits/stdc++.h>

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back

//#define int long long

#define _overload3(_1,_2,_3,name,...) name
#define _REP(i,n) REAP(i,0,n)
#define REAP(i,a,b) for(int i=int(a);i<int(b);++i)
#define REP(...) _overload3(__VA_ARGS__,REAP,_REP,)(__VA_ARGS__)

#define _REPR(i,n) REAPR(i,n,0)
#define REAPR(i,a,b) for(int i=int(a-1);i>=int(b);--i)
#define REPR(...) _overload3(__VA_ARGS__,REAPR,_REPR,)(__VA_ARGS__)

#define ALL(a) a.begin(),a.end()
#define rALL(a) a.rbegin(),a.rend()

#define coutALL(a) {int loop_coutALL=0;for(auto e:a) cout<<(loop_coutALL++?" ":"")<<e; cout<<endl;}

#define coutYN(a) cout<<((a)?"YES":"NO")<<endl;
#define coutYn(a) cout<<((a)?"Yes":"No")<<endl;
#define coutyn(a) cout<<((a)?"yes":"no")<<endl;

#define pcnt __builtin_popcount
#define buli(x) __builtin_popcountll(x)

const int INF=1145141919;
//const long long INF=114514191911451419;
const int MOD=(int)1e9+7;
const double EPS=1e-12;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};
//const int dx[]={-1,-1,-1,0,1,1,1,0},dy[]={-1,0,1,1,1,0,-1,-1};

using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;

typedef pair<int,int> pii;
typedef pair<int,string> pis;
typedef pair<string,int> psi;
typedef pair<string,string> pss;

typedef long long ll;

template<typename T> istream &operator >> (istream &is, vector<T> &v){for(T &x:v) is>>x;return is;}
template<typename T> ostream &operator << (ostream &os, vector<T> &v){int i=0;for(T &x:v) os<<(i++?" ":"")<<x;return os;}

ll rev(ll n){ll x=0;for(;n>0;){x=x*10+n%10;n/=10;}return x;}

ll upper(ll n,ll m){return (n+m-1)/m;};
ll rounding(ll n){return (long double)n+0.5;};

bool inG(ll x,ll n){return 0<=x && x<n;}
bool outG(ll x,ll n){return x<0 || n<=x;}

inline int qp(int a,ll b){if(!b)return 1;int ans=1;do{if(b&1)ans=1ll*ans*a;a=1ll*a*a;}while(b>>=1);return ans;}
inline int qp(int a,ll b,int mo){if(!b)return 1;int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}

inline ll fac(ll k,ll n){ll a=1;for(int i=0;i<n;i++)a*=k--;return a;}
inline ll fac(ll k,ll n,int mo){ll a=1;for(int i=0;i<n;i++)a*=k--,a%=mo;return a;}

inline int dsum(ll n){int a=0;for(;n;n/=10)a+=n%10;return a;}

struct Arithmetic{Arithmetic(){cin.tie(0);ios::sync_with_stdio(0);cout<<fixed<<setprecision(20);}};

//#define DEBUG_LOCAL

#ifdef DEBUG_LOCAL
template<typename T> void deb(T a){cerr<<"deb: "<<a<<"です"<<endl;}
#define debl {cerr<<"debug: "<<__LINE__<<"行目だ"<<endl;}
void what_cr(){cout<<__GCC_ATOMIC_CHAR16_T_LOCK_FREE<<" ←？"<<endl;}
//ori_func S

//ori_func E
#else
template<typename T>void deb(T a){}
#define debl
void what_cr(){}void t_t(){}
#endif

signed main(){

  Arithmetic Exception;

  string s;
  cin>>s;

  int n=0;
  REP(i,s.size()) n+=s[i]-'0';

  cout<<min(n,(int)s.size()-n)*2<<endl;

  return 0;

}


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

#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
const long long int m = 1000000007;

int main()
{
  int n;
  cin>>n;
  string s;
  cin>>s;
  vector<vector<ll>> dp(n+1,vector<ll>(n+1,0));
  dp[1][1] = 1;
  vector<vector<ll>> prefix(n+1,vector<ll>(n+1,0));
  prefix[1][1] = 1;
  for(int i = 0 ; i < n-1 ; i++ )
  {
    for(int j = 1; j <= i+2; j++ )
    {
      if(s[i]=='>'){
        dp[i+2][j] = prefix[i+1][i+1] - prefix[i+1][j-1];
        if(dp[i+2][j]<0)dp[i+2][j]+=m;
      }
      if(s[i]=='<'){
        dp[i+2][j] = prefix[i+1][j-1];
      }
      prefix[i+2][j] = (prefix[i+2][j-1] + dp[i+2][j])%m;
    }
  }
  cout<<prefix[n][n]<<"\n";
  return 0;
}


Measured memory_bytes: 141184
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,T,A,h,D,X=0;cin>>N>>T>>A>>h;
  D=abs(1000*(T-A)-6*h);
  for(int i=1;i<N;i++){
    cin>>h;
    if(D>abs(1000*(T-A)-6*h)){
      X=i;D=abs(1000*(T-A)-6*h);
    }
  }
  cout<<X+1<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)

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

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

    ll n, k;
    cin>>n>>k;
    vector<ll> as(n);
    rep(i, n) cin>>as[i];
    vector<ll> cnt(50);
    ll md = 0;
    rep(d, 50) rep(i, n) {
        if (as[i]>>d&1) cnt[d]++;
        if (k>>d&1) md = d;
    }
    ll base = 1;
    rep(i, 49) base *= 2;
    vector<vector<ll>> dp(51, vector<ll>(2));
    for (int d = 49; d >= 0; --d) {
        ll kd = k>>d&1;
        rep(i, 2) rep(j, 2) {
            int ni = i;
            if (j > kd && !i) continue;
            if (i && d > md) continue;
            if (i && d == md && j) continue;
            if (j < kd && !i) ni = 1;
            if (j)
                dp[d][ni] = max(dp[d][ni], dp[d + 1][i] + (n - cnt[d]) * base);
            else
                dp[d][ni] = max(dp[d][ni], dp[d + 1][i] + cnt[d] * base);
        }
        base /= 2;
    }
    cout<<max(dp[0][0], dp[0][1])<<endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
using namespace std;
int p[100];
int main(){
  int n,a,b,ca=0,cb=0,c=0;
  cin>>n>>a>>b;
  for(int i=0;i<n;i++){
    cin>>p[i];
    if(p[i]<=a)
      ca++;
    else if(p[i]>b)
      cb++;
    else
      c++;
  }
  if(ca<=cb and ca<=c)
    cout<<ca<<endl;
  else if(c<ca and c<cb)
    cout<<c<<endl;
  else
    cout<<cb<<endl;
}

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

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

typedef struct node * Node;

Node root;

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

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

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

}

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

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

Node find(int x,Node u){
  while(u!=NULL&&u->key!=x){
    if(x < u->key)
      u=u->left;
    else
      u=u->right;
  }
  return u;
}

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

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
   
    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]=='f'){
      scanf("%d",&x);
      if(find(x,root)!=NULL){
	printf("yes\n");
      }
      else{
	printf("no\n");
      }
    }
  }

  return 0;
}



Measured memory_bytes: 20472
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n ; cin>> n;
    vector<int>arr(n);
    for(int&p:arr)cin >> p ;
    sort(arr.rbegin(),arr.rend());
    int a = 0 , b = 0 ;
    for(int i = 0 ; i < n ; i++)   
    {
        if(i%2==0) a += arr[i];
        else b += arr[i];
    }
    cout << a - b ;
    return 0 ;
}

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

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)
#define rep(i,n) for(int i=0; i<n; i++)
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> P;
typedef map<int,int> mp;

const int MOD = 1e9 + 7;


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

    int n;
    cin >> n;
    vi v(n);
    rep(i, n){
        cin >> v[i];
    }

    sort(all(v));

    ll ans = v[n/2] - v[n/2 - 1];


    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 640
A, B = map(int, input().split())
S = input()
tr, fal = "Yes", "No"

def judge_post_code():
    if len(S) != A + B + 1:
        return fal
    if S[A] != "-":
        return fal
    for i in S[:A]:
        if not i in "0123456789":
            return fal
    for i in S[A+1:]:
        if not i in "0123456789":
            return fal
    return tr

print(judge_post_code())

Measured memory_bytes: 3060
local s = io.read()
local t = io.read()
local n = #s
local tbl1, tbl2 = {}, {}
for i = 1, 26 do tbl1[i] = 0 tbl2[i] = 0 end
local isok = true
for i = 1, n do
  local ssub, tsub = s:sub(i, i):byte(), t:sub(i, i):byte()
  ssub, tsub = ssub - 96, tsub - 96
  if tbl1[ssub] ~= 0 and tbl1[ssub] ~= tsub then
    isok = false break
  end
  if tbl2[tsub] ~= 0 and tbl2[tsub] ~= ssub then
    isok = false break
  end
  tbl1[ssub] = tsub
  tbl2[tsub] = ssub
end
print(isok and "Yes" or "No")


Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
#define ll long long                                    // long long省略
#define pb push_back                                    // push_back省略
#define mp make_pair                                    // make_pair省略
#define fi first                                        // first省略
#define se second                                       // second省略
#define itn int                                         // int誤字保険
#define count cout                                      // cout誤字保険
#define vecotr vector                                   // vector誤字保険
#define ednl endl                                       // endl誤字保険
#define opt() cin.tie(0); ios::sync_with_stdio(false)   // 入出力速度改善

#define rep(i,l,r) for(ll i=(l);i<(r);i++)               // 範囲[l, r)で刻み1のfor文(順方向)
#define repp(i,l,r,k) for(ll i=(l);i<(r);i+=(k))         // 範囲[l, r)で刻みkのfor文(順方向)
#define rrep(i,l,r) for(ll i=(r-1);i>=(l);i--)           // 範囲[l, r)で刻み1のfor文(逆方向)
#define rrepp(i,l,r,k) for(ll i=(r-1);i>=(l);i-=(k))     // 範囲[l, r)で刻みkのfor文(逆方向)
#define all(x) (x).begin(), (x).end()                   // vectorのポインタ位置指定用
#define max(p,q)((p)>(q)?(p):(q))                       // max拡張
#define min(p,q)((p)<(q)?(p):(q))                       // min拡張
#define bit(n,m)(((n)>>(m))&1)                          // 変数nのm番目のbitを取り出す

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; }

int dy[]={0, 1, 0, -1};                                 // 4方向近傍
int dx[]={1, 0, -1, 0};                                 // 4方向近傍

int main(){
    ll a,b,h;cin>>a>>b>>h;
    cout<<(a+b)*h/2<<endl;
}



Measured memory_bytes: 256
// B.cpp

#include <iostream>

using namespace std;

int gcd(int, int);
int lcm(int, int);

int main(void) {
	int a, b;
	
	while(cin >> a >> b) {
	cout << gcd(a, b) << " " <<  lcm(a, b) << endl;
	}
	
	return 0;
}

int gcd(int a, int b) {
	int max, min, res;
	
	res = 1;
	
	if(a > b){
		max = a, min = b;
	}
	if(a <= b){
		max = b, min = a;
	}
	if(min == 0) return max;
	while(res) {
		res = max % min;
		max = min;
		min = res;
	}
	return max;
}
int lcm(int a, int b) {
	return a / gcd(a, b) * b;
}

Measured memory_bytes: 1160
#include<iostream>
#include<string>
#define M 10000
using namespace std;

short dp[2][2][3][10][550]; //dp[digit][bound][dec or else or inc][prv num][mod]

int zig(string s,int m){
  int n = s.size(),up,mod,ub,odd,nxt;

  for(int j=0;j<3;j++)
    for(int k=0;k<10;k++)
      for(int l=0;l<m;l++)
	dp[0][0][j][k][l] = dp[0][1][j][k][l] = 0;
  dp[0][1][1][0][0] = 1;

  for(int i=0;i<n;i++){
    odd = i&1, nxt = 1-odd;
    for(int j=0;j<3;j++)
      for(int k=0;k<10;k++)
	for(int l=0;l<m;l++)
	  dp[nxt][0][j][k][l] = dp[nxt][1][j][k][l] = 0;

    for(int j=0;j<2;j++){
      if(j==1)up = s[i]-'0';
      else up = 9;
      for(int k=0;k<3;k++){
	for(int l=0;l<10;l++){
	  for(int x=0;x<=up;x++){
	    if(k==0 && x<=l)continue;
	    if(k==2 && l<=x)continue;
	    for(int y=0;y<m;y++){
	      mod = (y*10 + x) % m;
	      if(j==1 && x==up)ub = 1;
	      else ub = 0;

	      if(k==1 && l==0){
		dp[nxt][ub][1][x][mod] += dp[odd][j][k][l][y];
		dp[nxt][ub][1][x][mod] %= M;
	      }else if(x<l){
		dp[nxt][ub][0][x][mod] += dp[odd][j][k][l][y];
		dp[nxt][ub][0][x][mod] %= M;
	      }else if(x>l){
		dp[nxt][ub][2][x][mod] += dp[odd][j][k][l][y];
		dp[nxt][ub][2][x][mod] %= M;
	      }
	    }
	  }
	}
      }
    }
  }
 
  int ans = 0; odd = n&1;
  for(int i=0;i<2;i++)
    for(int j=0;j<3;j++)
      for(int k=0;k<10;k++){
	ans += dp[odd][i][j][k][0];
	ans %= M;
      }
  return ans;
}

string dec(string a){
  int n = a.size() - 1;
  while(a[n]=='0'){
    a[n--] = '9';
  }
  a[n]--;
  if(a[n] == '0')a = a.substr(1,n-1);
  return a;
}

int main(){
  string a,b;
  int m;
  cin >> a >> b >> m;
  cout << (zig(b,m) - zig(dec(a),m) + M) % M << endl;
}

Measured memory_bytes: 1344
def getPermutation(n, x):
    if x==1 or x==n*2-1:
        return None
    if n==2:
        return [1, 2, 3]
    if x==2:
        bar = [x+1, x-1, x, x+2]
    else:
        bar = [x-1, x+1, x, x-2]
    rem = [i for i in xrange(1, n*2) if i not in bar]
    return rem[:n-2]+bar+rem[n-2:]

def main():
    n, x = [int(i) for i in raw_input().strip().split()]
    res = getPermutation(n, x)
    if res is None:
        print 'No'
    else:
        print 'Yes'
        for i in res:
            print i

if __name__ == '__main__':
    main()

Measured memory_bytes: 12148
import sys

h, w = map(int, sys.stdin.readline().split())
grid = [[int(x) for x in sys.stdin.readline().split()] for _ in range(h)]

def main():
    n = 0
    move = []

    for i in range(h):
        for j in range(w-1):
            if grid[i][j] & 1:
                grid[i][j] -= 1
                grid[i][j+1] += 1
                move.append((i+1, j+1, i+1, j+2))
                n += 1
    
    for i in range(h-1):
        if grid[i][-1] & 1:
            grid[i][-1] -= 1
            grid[i+1][-1] += 1
            move.append((i+1, w, i+2, w))
            n += 1
    
    yield [n]
    for m in move:
        yield m
    
if __name__ == '__main__':
    ans = main()
    for i in ans:
        print(*i, sep=' ')

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




int main(){
#ifdef debug
    freopen("a.in", "r", stdin);
#endif
    int n, m;
    cin>>n>>m;
    vector<int> cnt(n, 0);
    for(int i=0; i<m; ++i){
        int u, v;
        cin>>u>>v;
        --u; --v;
        cnt[u]++;
        cnt[v]++;
    }
    for(int i=0; i<n; ++i){
        cout<<cnt[i]<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define sz(a) a.size()
#define re return 
#define MP make_pair
#define pb push_back
#define pii pair<int,int>
#define se second
#define fi first
using namespace std;
const int MOD=1e9+7;
int n;
int x,y;
signed main(){
	ios_base::sync_with_stdio(0);
	cin>>n;
	while(n--){
		int a;
		cin>>a;
		x=(x+a)%MOD;
		y=(y+(a*a%MOD))%MOD; 
	}
	x=(x*x-y)%MOD;
	if(x%2) x+=MOD;
	cout<<x/2;
	re 0;
}

Measured memory_bytes: 3640
#include<iostream>
#include<vector>
#include<map>
#include<string>
#include<math.h>
#include <iomanip>
#include<queue>
using namespace std;
const double PI=3.14159265358979323846;
void a(){
    int n;
    cin >>n;
    n = n%10;
    if(n==3)
    {
        cout<<"bon";
    }
    else if(n==0 ||n==1 ||n==6 ||n==8)
    {
        cout<<"pon";
    }
    else cout<<"hon";
    return;
}

void b(){
    int k;
    string s;
    cin >> k>>s;
    if(s.length()<=k)cout<<s;
    else
    {
        cout<<s.substr(0,k)+"...";
    }
}

void c(){
    int a,b,h,m;
    cin >>a>>b>>h>>m;
    double t1 = (double)h/12*2*PI;
    double t2 = (double)m/60*2*PI;
    double t3 = (t1 - t2);
    double l = sqrtf128(a*a+b*b-2*a*b*cos(t3));
    cout<<t1<<" "<<t2;
    cout<< setprecision(14)<<l;
    return;
}

void d(){
    int n;
    int m;
    cin >> n>>m;
    vector<vector<int> >room(n);
    for(int i=0;i<m;i++)
    {
        int a,b;
        cin >>a>>b;
        room[a-1].push_back(b-1);
        room[b-1].push_back(a-1);
    }
    int dist[n]={0};
    for(int i=0;i<n;i++)dist[i]=-1;
    dist[0] = 0;
    queue<int> move;
    move.push(0);
    while(!move.empty())
    {
        int temp = move.front();
        move.pop();
        for(int i=0;i<room[temp].size();i++)
        {
            int see = room[temp][i];
            if(dist[see]==-1)
            {
                dist[see] = temp;
                move.push(see);
            }
        }
    }
    cout<<"Yes"<<endl;
    for(int i=1;i<n;i++)cout<<dist[i]+1<<endl;
    return;
    
}
void e(){
    int n;
    cin >>n;
    vector<int>a;
    a.push_back(0);
    map<int,int>c;
    int vmin = INT32_MAX;
    int vmax = INT32_MIN;
    for(int i=0;i<n;i++)
    {
        int ai;
        cin >>ai;
        a.push_back(ai);
    }
    long long int pcount=0;
    
    for(int i=n-1;i>0;i--)
    {
        if(c.count(-(a[i+1]-(i+1)))==0){
            c[-(a[i+1]-(i+1))]=1;
        }
        else{
            c[-(a[i+1]-(i+1))]=c[-(a[i+1]-(i+1))]+1;
        }
        if(c.count(i+a[i])!=0)
        pcount+= c[i+a[i]];
    }
    cout << pcount;
    return;

}
int main(void){
    //a();
    //b();
    //c();
    d();
    //e();

}

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

#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

int main() {
  long a;
  cin >> a;

  cout << a + a * a + a * a * a << endl;
}


Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
	ll i,j,k,m,n,t,d,s;
	cin>>d>>t>>s;
	double t1=ceil((d*1.0)/(s*1.0));
	ll t2=t1;
	if(t2<=t) cout<<"Yes";
	else cout<<"No";
}

Measured memory_bytes: 3632
N = int(input())
A = list(map(int, input().split()))
a = sum(A) - A[0]
s = A[0]
ans = abs(s - a)
for i in range(1,N-1):
    a -= A[i]
    s += A[i]
    ans = min(ans, abs(s - a))
print(ans)

Measured memory_bytes: 76880
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
struct tv{
   int s,t,c;
   bool operator < (tv &t){
      return c<t.c|| (c==t.c&&s<t.s);
   } 
};
int main(){
  int n,c;
  cin>>n>>c;
  vector<tv>t(n),v;
  rep(i,n)
    cin>>t[i].s>>t[i].t>>t[i].c;
  sort(t.begin(),t.end());
  int chn=0,z=-1,ans=0,time[100001]={};
  rep(i,n)
    if(chn!=t[i].c){
       rep(j,z+1) 
         for(int k=v[j].s;k<=v[j].t;k++){
            time[k]++;
            ans=max(ans,time[k]); 
         }
      v.clear();
      v.push_back(t[i]);
      chn=t[i].c;
      z=0;     
    }else{
       if(v[z].t>=t[i].s) {
          v[z].t=max(v[z].t,t[i].t); 
       }else{
          v.push_back(t[i]);
          z++;
       }
    }
  rep(i,z+1){
     for(int k=v[i].s;k<=v[i].t;k++){
       time[k]++;
       ans=max(ans,time[k]); 
     }
  }
  cout<<ans;
  return 0;
}

Measured memory_bytes: 1920
import sys
input = sys.stdin.readline

s = input()
isMaeMM = False
if (0 < int(s[0:2]) < 13):

    isMaeMM = True
isUshiroMM = False
if (0 < int(s[2:]) < 13):

    isUshiroMM = True
if (isMaeMM):
    if (isUshiroMM):
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if (isUshiroMM):
        print("YYMM")
    else:
        print("NA")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define stop exit(0)
#define pb push_back
int main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    vector<long long>v;
    pair<string, long long> n;
    set<string> y;
    long long a,b,c,d=0,e=0,i,f=0,g=0,j,k=1,l=0,r=0,z,m,h,p[6];
    string t,s,x;
    double q,u;
    cin>>p[1]>>p[2]>>p[3]>>p[4]>>p[5];
    for(i=1;i<=5;i++){
        if(p[i]==0){
            cout<<i;
            stop;
        }
    }
}

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

template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x: vec) is >> x; return is;
}

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;

#define rep(i,n) for(int i=0; i<(n); i++)
#define all(x) (x).begin(), (x).end()
#define dump(x) cout << #x << " = " << (x) << endl

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

    vi m(n);

    // B(1/2)*m=a -> m=B\a : O(n^2)?
    /*
    rep(i,n){
        m[i] = 0;
        rep(j,n){
            if(i<=j){
                if((j-i)%2 == 0) m[i] += a[j];
                else m[i] -= a[j];
            }
            else{
                if((i-j)%2 == 0) m[i] -= a[j];
                else m[i] += a[j];
            }
        }
        cout << m[i] << " ";
    }
    */

   // m[0] = a[0] - a[1] + a[2] - ... +a[n-1]
   // m[i+1] = 2*a[i] - m[i] : O(n)?
    m[0] = 0;
    rep(i,n){
        if(i%2) m[0] -= a[i];
        else m[0] += a[i];
    }
    cout << m[0] << endl;
    rep(i,n-1){
        m[i+1] = 2*a[i] - m[i];
        cout << m[i+1] << endl;
    }

    return 0;
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define X first
#define Y second
#define mkp make_pair
#define pb push_back
#define eb emplace_back
#define pob pop_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

const ll MAXn=5e2+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=0x3f3f3f3f;

int dp[MAXn][MAXn],d[MAXn][MAXn];
int main(){
  IOS();
  int n,m,q;
  cin>>n>>m>>q;
  REP(i,m){
    int l,r;
    cin>>l>>r;
    d[l][r]++;
  }
  for(int i=500;i>=0;i--)REP(j,501)
    dp[i][j] = d[i][j]+dp[i+1][j]+dp[i][j-1]-dp[i+1][j-1];
  while(q--){
    int l,r;
    cin>>l>>r;
    cout<<dp[l][r]<<endl;
  }
}


Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    int n,m,x;
    cin>>n>>m>>x;
    vector<int> a(m);
    for(int i=0;i<m;i++)cin>>a[i];
    int a1=0,a2=0;
    for(int i=0;i<m;i++){
        if(a[i]<x)a1++;
    }
    for(int i=m-1;i>=0;i--){
        if(a[i]>x)a2++;
    }
    if(a1>a2)swap(a1,a2);
    cout<<a1<<endl;
    return 0;
}


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

ab = a + b
cnt = 0
fcnt = 1
for i in range(n):
    if s[i] == 'a' and ab > cnt:
        cnt += 1
        print('Yes')
    elif s[i] == 'b' and (ab > cnt and b >= fcnt):
        cnt += 1
        fcnt += 1
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 4016
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b;
    cin >> a >> b;
    if (a == b)
        cout << "Draw";
    else if (b != 1 && (a == 1 || a > b))
        cout << "Alice";
    else
        cout << "Bob";
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Program
{
	class Program
	{
		static void Main(string[] args)
		{
			var lr = Console.ReadLine().Split(' ');
			long l = long.Parse(lr[0]);
			long r = long.Parse(lr[1]);

			if (r - l >= 2019)
			{
				Console.WriteLine(0);
			}
			else
			{
				long minValue = long.MaxValue;

				for (var i = l; i < r; i++)
				{
					for (var j = i + 1; j <= r; j++)
					{
						long ij = i * j;
						var result = ij % 2019;

						if (minValue > result)
						{
							minValue = result;
						}
					}
				}

				Console.WriteLine(minValue);
			}
		}
	}
}

Measured memory_bytes: 11092
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.LinkedList;
import java.util.PriorityQueue;
 
 
 
public class Main {
  public static void main(String[] args) {
    InputReader sc = new InputReader(System.in);
 
    int n = sc.nextInt();
    int sum = 0;
    for(int i = 0; i < n; i++){
      sum += sc.nextInt() - 1;
    }

    System.out.println(sum);
 
  }
 
 //ここからテンプレ
  static class InputReader {
      private InputStream stream;
      private byte[] buf = new byte[1024];
      private int curChar;
      private int numChars;
      private SpaceCharFilter filter;
 
      public InputReader(InputStream stream) {
          this.stream = stream;
      }
 
      public int next() {
          if (numChars == -1)
              throw new InputMismatchException();
          if (curChar >= numChars) {
              curChar = 0;
              try {
                  numChars = stream.read(buf);
              } catch (IOException e) {
                  throw new InputMismatchException();
              }
              if (numChars <= 0)
                  return -1;
          }
          return buf[curChar++];
      }
 
      public String nextStr() {
        int c = next();
        while(isSpaceChar(c)){c = next();}
        StringBuffer str = new StringBuffer();
        do{
          str.append((char)c);
          c = next();
        }while(!isSpaceChar(c));
        return str.toString();
      }
 
      public char nextChar() {
        int c = next();
        while(isSpaceChar(c)){c = next();}
        char ret;
        do{
          ret = (char)c;
          c = next();
        }while(!isSpaceChar(c));
        return ret;
      }
 
      public int nextInt() {
          int c = next();
          while (isSpaceChar(c))
              c = next();
          int sgn = 1;
          if (c == '-') {
              sgn = -1;
              c = next();
          }
          int res = 0;
          do {
              if (c < '0' || c > '9')
                  throw new InputMismatchException();
              res *= 10;
              res += c - '0';
              c = next();
          } while (!isSpaceChar(c));
          return res * sgn;
      }
 
      public boolean isSpaceChar(int c) {
          if (filter != null)
              return filter.isSpaceChar(c);
          return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
      }
 
      public interface SpaceCharFilter {
          public boolean isSpaceChar(int ch);
      }
  }
}

Measured memory_bytes: 22612
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい

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

//const int MOD=998244353;
const int MOD=1000000007; //10^9+7
const double PI=3.1415926535;

int main(){
    int N;double Nd;
    cin>>N;
    Nd=N;
    Nd/=1.08;
    int Nf=floor(Nd);
    int ans=-1;
    for(int i=Nf-1;i<=Nf+2;i++){
        int p=floor(i*1.08);
        if(p==N){
            ans=i;
        }
    }
    if(ans>=0){
        cout<<ans<<endl;
    }else{
        cout<<":("<<endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define ff first
#define ss second
typedef long long ll;
ll power(ll a, ll b){//a^b
    ll res=1;
    a=a%MOD;
    while(b>0){
        if(b&1){res=(res*a)%MOD;b--;}
        a=(a*a)%MOD;
        b>>=1;
    }
    return res;
}
bool isPalin(string s){
    if (s==string(s.rbegin(),s.rend()))
        return true;
    return false;
}
ll fermat_inv(ll y){return power(y,MOD-2);}
ll gcd(ll a, ll b){return (b==0)?a:gcd(b,a%b);}
int main(){
    ll t=1;
    //cin>>t;
    while(t--){
        ll n,k;
        cin>>n>>k;
        int p[n+1];
        int c[n+1];
        for(int i=1;i<=n;i++)
            cin>>p[i];
        for(int i=1;i<=n;i++)
            cin>>c[i];
        vector <bool> visited(n+1,false);
        ll ans=-1e18;
        ans--;
        for(int i=1;i<=n;i++){
            if(visited[i]==false){
                int j=p[i];
                vector <ll> v;
                ll val=c[i];
                while(j!=i){
                    val+=c[j];
                    visited[j]=true;
                    v.push_back(c[j]);
                    j=p[j];
                }
                visited[i]=true;
                v.push_back(c[i]);
                int s=v.size();
                for(j=0;j<s;j++)
                    v.push_back(v[j]);
                for(int i=1;i<2*s;i++)
                    v[i]+=v[i-1];
                ll l=1;
                ll r=k;
                vector <ll> dp(s+1,-1e18+1);
                for(int j=1;j<=s;j++){
                    for(int i=0;i+j<2*s;i++)
                        dp[j]=max(dp[j],v[i+j]-v[i]);
                }
                for(int j=1;j<=s;j++){
                    if(j<=k){
                        ll v1=(k-j)/s;
                        ans=max(ans,dp[j]);
                        ans=max(ans,dp[j]+v1*val);
                    }
                }
            }
        }
        cout<<ans<<"\n";
    }
    return 0;
}


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

using namespace std;

int n, y[305][4], ta, tb, tc, ans, v[305], dis[305], at[305];
vector< pair< int, pair< int, int > > > x[305];
queue< int > q;

void bd(int a, int b, int c) {
	x[a].push_back(make_pair(b, make_pair(c, x[b].size())));
	x[b].push_back(make_pair(a, make_pair(0, x[a].size() - 1)));
}

int dfs(int a, int b) {
	if (a == n * 2 + 1)
		return b;
	for (int &i = at[a]; i < x[a].size(); i++)
		if (v[x[a][i].first] == ta && x[a][i].second.first && dis[x[a][i].first] == dis[a] + 1) {
			int re = dfs(x[a][i].first, min(x[a][i].second.first, b));
			if (re) {
				b -= re;
				x[a][i].second.first -= re;
				x[x[a][i].first][x[a][i].second.second].second.first += re;
				return re;
			}
		}
	return 0;
}

int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
		scanf("%d%d", y[i], y[i] + 1);
	for (int i = 0; i < n; i++)
		scanf("%d%d", y[i] + 2, y[i] + 3);
	for (int i = 0; i < n; i++) {
		bd(n * 2, i, 1);
		bd(n + i, n * 2 + 1, 1);
	}
	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++)
			if (y[i][0] < y[j][2] && y[i][1] < y[j][3])
				bd(i, n + j, 1);
	for (ta = 1; ; ta++) {
		q.push(n * 2);
		v[n * 2] = ta;
		at[n * 2] = 0;
		dis[n * 2] = 0;
		while (!q.empty()) {
			tb = q.front();
			q.pop();
			for (int i = 0; i < x[tb].size(); i++)
				if (v[tc = x[tb][i].first] != ta && x[tb][i].second.first) {
					v[tc] = ta;
					at[tc] = 0;
					dis[tc] = dis[tb] + 1;
					q.push(tc);
				}
		}
		if (v[n * 2 + 1] != ta)
			break;
		while (tb = dfs(n * 2, INT_MAX))
			ans += tb;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
using namespace std;
int main(){
  int n, k, q, peaple[100000] = {0}, correct = 0;
  cin >> n >> k >> q;
  for(int i = 0; i < q; i++){
    cin >> correct;
    peaple[correct - 1]++;
  }
  for(int i = 0; i < n; i++){
    if((k - (q - peaple[i])) <= 0){
      cout << "No" << endl;
    }else{
      cout << "Yes" << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1024
from collections import defaultdict
import sys
re = sys.stdin
vertice, edge = (int(n) for n in re.readline().split(" "))
connect = defaultdict(list)
indegree = [0 for n in range(vertice)]
for _ in range(edge):
    s, t = (int(n) for n in re.readline().split(" "))
    connect[s].append(t)
    indegree[t] += 1
answer = []
zeroin = []
for i, n in enumerate(indegree):
    if n == 0:
        zeroin.append(i)
while len(zeroin) > 0:
    next_v = zeroin.pop()
    indegree[next_v] -= 1
    answer.append(next_v)
    for c in connect[next_v]:
        indegree[c] -= 1
        if indegree[c] == 0:
            zeroin.append(c)
for a in answer:
    print(a)

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

int main() {
  int n;
  cin>>n;
  int a[n];
  cin>>a[0];
  int res=1;
  int mini=a[0];
  for(int i=1;i<n;i++) {
    cin>>a[i];
    if(mini>=a[i]){
      res++;
      mini=a[i];
    }
  }
  cout<<res<<endl;
  return 0;
}


Measured memory_bytes: 1024
import java.util.Arrays;
import java.util.Scanner;

/**
 *
 * @author lenovo
 */
public class Main {

    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int c = scanner.nextInt();

        int[] array = {a, b, c};
        Arrays.sort(array);
        String s=""+array[0]+" "+array[1]+" "+array[2];
        System.out.println(s);
    }
}

Measured memory_bytes: 26248
s = int(input())

ans = [s]

for i in range(1000001):
    if ans[i] %2 == 0:
        ans.append(int((ans[i])/2))
    elif ans[i] %2 != 0:
        ans.append(int(3*(ans[i])) +1)
    
    if ans.count(ans[i]) == 2:
        print(i+1)
        break

Measured memory_bytes: 3064
using System;
using System.Linq;

class AtCoderCS {
    static void Main(string[] args) {
        long X = long.Parse(Console.ReadLine());

        for (int B = -1000; B <= 1000; B++)
            for(int A = -1000; A <= 1000; A++) {
                if (Math.Pow(A, 5) - Math.Pow(B, 5) == X) {
                    Console.WriteLine("{0} {1}", A, B);
                    return;
                }
            }
    }
}

Measured memory_bytes: 27864
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    char c;
    cin >> n;
    bool f = false;
    rep(i, 0, n){
        cin >> c;
        if(c == 'Y') f = true;
    }
    if(f) cout << "Four" << endl;
    else cout << "Three" << endl;
}

Measured memory_bytes: 256
using System;
using System.Linq;

namespace Number
{
    class Program
    {
        static void Main(string[] args)
        {
            while(true)
            {
                string s = Console.ReadLine().Trim('\n');
                if(s == "0 0") break;
                int[] i = s.Split(' ')
                           .Select(e => int.Parse(e))
                           .ToArray();
                int a = i[0];
                int b = i[1];
                for(int j = 0; j < a; j++)
                     Console.WriteLine(new string('#', b));
                Console.WriteLine();
            }
        }
    }
}

Measured memory_bytes: 9428
public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
/*answer*/
    int m, d;

    for(;;){
      m = sc.nextInt();
      if(m == 0)break;
      d = sc.nextInt();

      if(m == 1)d += 0;
      else if(m == 2) d += 31;
      else if(m == 3) d += 60;
      else if(m == 4) d += 91;
      else if(m == 5) d += 121;
      else if(m == 6) d += 152;
      else if(m == 7) d += 182;
      else if(m == 8) d += 213;
      else if(m == 9) d += 244;
      else if(m == 10) d += 274;
      else if(m == 11) d += 305;
      else if(m == 12) d += 335;

      if(d % 7 == 1)out.println("Thursday");
      else if(d % 7 == 2)out.println("Friday");
      else if(d % 7 == 3)out.println("Saturday");
      else if(d % 7 == 4)out.println("Sunday");
      else if(d % 7 == 5)out.println("Monday");
      else if(d % 7 == 6)out.println("Tuesday");
      else out.println("Wednesday");
    }

    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
}

Measured memory_bytes: 17188
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std; using ll = long long;
using ull = unsigned long long; using P = pair<int, int>;
const int INF = 1e9; const int MOD = 1000000007;
const int dx[] = {-1,0,1,0}; const int dy[] = {0,-1,0,1};
//const int dx[] = {-1,-1,-1, 0, 0, 1, 1, 1}; const int dy[] = {-1, 0, 1,-1, 1,-1, 0, 1};
#define PI 3.14159265358979323846264338327950L //setprecision(15)
#define MAX_N 200000

// n要素で初期化
void init(int n, int par[], int rnk[], int mem[]) {
	for (int i = 0; i < n; i++) {
		par[i] = i; rnk[i] = 0; mem[i] = 1;
	}
}
// 木の根を求める
int find(int x, int par[]) {
	if (par[x] == x) return x;
	else return par[x] = find(par[x], par);
}
// xとyの属する集合を併合
void unite(int x, int y, int par[], int rnk[], int mem[]) {
	x = find(x, par); y = find(y, par);
	if (x == y) return;
	if (rnk[x] < rnk[y]) {
		par[x] = y; mem[y] += mem[x];
	} else {
		par[y] = x; mem[x] += mem[y];
		if (rnk[x] == rnk[y]) rnk[x]++;
	}
}
// xとyが同じ集合に属するか否か
bool same(int x, int y, int par[]) {
	return find(x, par) == find(y, par);
}
// グループのサイズ
int size(int x, int par[], int mem[]) {
	return mem[find(x, par)];
}

int main() {
	int par1[MAX_N];  // 親
	int rnk1[MAX_N];  // 木の深さ
	int mem1[MAX_N];  // グループの要素数
	int par2[MAX_N];  // 親
	int rnk2[MAX_N];  // 木の深さ
	int mem2[MAX_N];  // グループの要素数

	int N, K, L; cin >> N >> K >> L;
	init(N, par1, rnk1, mem1);
	init(N, par2, rnk2, mem2);
	rep(i, K) {
		int p, q; cin >> p >> q;
		unite(p-1, q-1, par1, rnk1, mem1);
	}
	rep(i, L) {
		int r, s; cin >> r >> s;
		unite(r-1, s-1, par2, rnk2, mem2);
	}
	map<P, int> ma;
	rep(i, N) {
		ma[make_pair(find(i, par1), find(i, par2))]++;
	}
	rep(i, N) {
		cout << ma[make_pair(find(i, par1), find(i, par2))];
		if (i == N-1) cout << endl;
		else cout << " ";
	}
}

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

typedef long long ll;

int main(){
    ll X,Y,Z,K; cin >> X >> Y >> Z >> K;
    ll a[X],b[Y],c[Z];
    for(int i=0;i<X;i++) cin >> a[i];
    for(int i=0;i<Y;i++) cin >> b[i];
    for(int i=0;i<Z;i++) cin >> c[i];
    vector<ll> tmp;
    //sort(a,a+X,greater<ll>());
    for(int i=0;i<Y;i++){
        for(int j=0;j<Z;j++){
            tmp.push_back(b[i]+c[j]);
        }
    }
    sort(tmp.begin(),tmp.end(),greater<ll>());
    vector<ll> ans;
    for(int i=0;i<X;i++){
        for(int j=0;j<min(Y*Z,K);j++){
            ans.push_back(a[i]+tmp[j]);
        }
    }
    sort(ans.begin(),ans.end(),greater<ll>());
    for(int i=0;i<K;i++){
        cout << ans[i] << endl;
    }

}

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

int main() {
  string s, t;
  cin >> s >> t;
  
  sort(s.begin(), s.end());
  sort(t.begin(), t.end());
  reverse(t.begin(), t.end());
  
  if (s < t) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

int main() {
	int N;
  	cin>>N;
	double X=double(N)/1.08;
	double f=floor(X)*1.08;
  	f=floor(f);
  	double f2=ceil(X)*1.08;
  	f2=floor(f2);
  
	if(f==N ) cout<<floor(X)<<endl;
  	else if(f2==N) cout<<ceil(X)<<endl;
	else            cout<<":("<<endl;
}

Measured memory_bytes: 256
// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools

#include <bits/stdc++.h>

using namespace std;

using i64 = long long;

const i64 MOD = 1e9 + 7;
const i64 INF = i64(1e18) + 7;


template <typename T>
bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}


void solve(std::vector<long long> a){
    cout << (accumulate(a.begin(), a.end(), 0) >= 22 ? "bust" : "win") << endl;
}


signed main(){
    std::vector<long long> A(3);
    for(int i = 0 ; i < 3 ; i++){
        scanf("%lld",&A[i]);
    }
    solve(std::move(A));
    return 0;
}


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

struct bc{
    int B;
    int C;
    bool operator<(const bc &r) const{
        return C > r.C;
    }
};

int N, M;
vector<int> A;
vector<bc> BC;

void solve(){
    sort(A.begin(), A.end());
    sort(BC.begin(), BC.end());
    long sum = 0;
    int k = 0;
    for(auto i = 0; i < N; ++i){
        int _C = 0;
        if(k < M) _C = BC[k].C;
        sum += max(A[i], _C);
        BC[k].B--;
        if(BC[k].B == 0) k++;
    }
    cout << sum;
}

int main(){
    cin >> N >> M;
    A.resize(N);
    for(auto &x : A){
        cin >> x;
    }
    BC.resize(M);
    for(auto i = 0; i < M; ++i){
        cin >> BC[i].B >> BC[i].C;
    }

    solve();

    return 0;
}

Measured memory_bytes: 1408
#include <stdio.h>
int main()
{
    int n, b, f, r, v;
    int count[4][3][10];
    for (int i = 0; i < 4; i++){
        for (int j = 0; j < 3; j++){
            for (int k = 0; k < 10; k++){
                count[i][j][k] = 0;
            }
        }
    }
    scanf("%d", &n);
    for(int i = 0; i < n; i++){
        scanf(" %d %d %d %d", &b, &f, &r, &v);
        count[b-1][f-1][r-1] += v;
    }
    for (int i = 0; i < 4; i++){
        for (int j = 0; j < 3; j++){
            for (int k = 0; k < 10; k++){
                if (k != 9){
                    printf(" %d", count[i][j][k]);
                }
                else {
                    printf(" %d\n", count[i][j][k]);
                }
            }
        }
        if (i != 3){
            printf("####################\n");
        }
    }
    return 0;
}


Measured memory_bytes: 2108
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
using namespace std;
int dy[]={1,-1,0,0};
int dx[]={0,0,1,-1};
string table[12];

void dfs(int y, int x){
    table[y][x] = '0';
    rep(i,4){
        int px = x + dx[i];
        int py = y + dy[i];
        if (px < 0 || px >= 12 || py < 0 || py >= 12) continue;
        if (table[py][px] == '0') continue;
        dfs(py, px);
    }
}
int main(){
    while(1){
        int cnt = 0;
        rep(i,12){
            cin >> table[i];
            if (cin.eof()) { return 0; }
        }
        rep(i,12){
            rep(j,12){
                if(table[i][j] == '0') continue;
                dfs(i,j);
                cnt++;
            }
        }
        cout << cnt << endl;
    }
    return 0;
}



Measured memory_bytes: 3156
#include <queue>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <map>
#include <stdio.h>
using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for(int i = (a); i < (int)(b); i++)
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vint;
typedef vector<string> vstr;
typedef pair<ll, ll> pint;
unsigned long long inf = (1LL << 62);
ll MOD = (ll)pow(10.0, 9.0) + 7;
pint dx[4] = { {1, 0}, {-1, 0}, {0, 1}, {0, -1} };

ll min(ll a, ll b)
{

	return (a < b) ? a : b;
}
ll max(ll a, ll b) { return (a > b) ? a : b; }



ll N;
ll sum[100005];
vector<ll> A;
int main() {

	cin >> N;
	A.resize(N);
	
	rep(i, N) {
		cin >> A[i];

		if (i != 0)
			sum[i] = sum[i - 1] + 1;
		else
			sum[i] = A[i];
	}
	sort(A.begin(), A.end());

	rep(i, N) {

		if (i != 0)
			sum[i] = sum[i - 1] + A[i];
		else
			sum[i] = A[i];
	}

	ll num = N;
	for(int i = N-2; i >= 0; i--) {
		if (A[i + 1] > 2 * sum[i]) {
			num -= (i + 1);
			break;
		}

	}
	
	cout << num << endl;
	return 0;
}

Measured memory_bytes: 1792