akhauriyash/Code-Regression huggingface dataset:
/**
*    author:  Dooloper
*    created: 13.09.2020 20:59:03
**/

#pragma region Macros
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
using P = pair<int,int>;
using ll = long long;

#define rep(i,n) for(int i = 0; i < (n); i++)
#define repn(i,n) for(int i = 1; i <= (n); i++)
#define pb push_back
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

const double PI = acos(-1);
const int mod = 1000000007;
class mint {
   long long x;
public:
   mint(long long x=0) : x((x%mod+mod)%mod) {}
   mint operator-() const {
     return mint(-x);
   }
   mint& operator+=(const mint& a) {
       if ((x += a.x) >= mod) x -= mod;
       return *this;
   }
   mint& operator-=(const mint& a) {
       if ((x += mod-a.x) >= mod) x -= mod;
       return *this;
   }
   mint& operator*=(const  mint& a) {
       (x *= a.x) %= mod;
       return *this;
   }
   mint operator+(const mint& a) const {
       mint res(*this);
       return res+=a;
   }
   mint operator-(const mint& a) const {
       mint res(*this);
       return res-=a;
   }
   mint operator*(const mint& a) const {
       mint res(*this);
       return res*=a;
   }
   mint pow(ll t) const {
       if (!t) return 1;
       mint a = pow(t>>1);
       a *= a;
       return a;
   }
   // for prime mod
   mint inv() const {
       return pow(mod-2);
   }
   mint& operator/=(const mint& a) {
       return (*this) *= a.inv();
   }
   mint operator/(const mint& a) const {
       mint res(*this);
       return res/=a;
   }

   friend ostream& operator<<(ostream& os, const mint& m){
       os << m.x;
       return os;
   }
};
#pragma endregion

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  ll n;
  cin >> n;
  mint ans = 1, rec = 1, cnt = 1;
  for(int i = 0; i < n; i++){
    ans *= 10;
  }
  for(int i = 0; i < n; i++){
    rec *= 8;
  }
  for(int i = 0; i < n; i++){
    cnt *= 9;
  }
  ans -= cnt * 2;
  ans += rec;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3644
x, y, a, b, c = map(int, input().split())
red = [int(x) for x in input().split()]
green = [int(x) for x in input().split()]
red.sort()
green.sort()
candidates = [int(x) for x in input().split()] + red[-x:] + green[-y:]
candidates.sort()
print(sum(candidates[-x-y:]))

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

using namespace std;

int main(void) {
	int num, q, a, b, i, ok = true;
	cin >> num >> q;
	vector<int> d(num + 1, 0);
	for (i = 0; i < q; i++) {
		scanf("%d%d", &a, &b);
		d[a]++;
		d[b]--;
	}
	a = 0;
	for (i = 1; i < num; i++) {
		a += d[i];
		if (a & 1) {
			ok = false;
			break;
		}
	}
	if (ok)
		printf("YES\n");
	else
		printf("NO\n");
	return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main{
  public static void main(String args[]){
try(Scanner sc =new Scanner(System.in)){
 int w = sc.nextInt();
 int n =sc.nextInt();
 int[] values =new int[w];
 for(int i=0;i<values.length;i++){
     values[i]=i+1;
 }
 for(int i=0;i<n;i++){
     String str=sc.next();
     String[] ab=str.split(",");
     int a =Integer.parseInt(ab[0])-1;
     int b =Integer.parseInt(ab[1])-1;
     int x= values[a];
     values[a]=values[b];
     values[b]=x;
 }
 for(int i=0;i<values.length;i++){
    System.out.println(values[i]);  
   }
  
}
    }
}




Measured memory_bytes: 25928
#include <algorithm>
#include <array>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define REP(X, Y, Z) for (ll(X) = (Y); (X) < (Z); (X)++)
#define REV(X, Y, Z) for (ll(X) = (Y); (X) > (Z); (X)--)

using namespace std;
using ll = long long;
using dll = deque<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using usll = unordered_set<ll>;
using umll = unordered_map<ll, ll>;
using sll = stack<int>;
using vll = vector<ll>;
using vvll = vector<vll>;

constexpr ll kMod = 1e9 + 7;

ll gcd(ll a, ll b) {
  if (a < b) {
    return gcd(b, a);
  }
  ll c = a % b;
  while (c != 0) {
    a = b;
    b = c;
    c = a % b;
  }
  return b;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

int main() {
  init();

  ll N, M;
  cin >> N >> M;
  vll W(N, 0);
  vll D(N, 0);
  REP(i, 0, M) {
    ll a;
    string b;
    cin >> a >> b;
    bool q = false;
    if (b == "AC") {
      q = true;
    }
    a--;

    if (D[a] == 0) {
      if (q) {
        D[a] = 1;
      } else {
        W[a]++;
      }
    }
  }
  ll wcnt = 0;
  REP(i, 0, N) {
    if (D[i] == 1) {
      wcnt += W[i];
    }
  }
  cout <<
       accumulate(D.begin(), D.end(), 0) <<
       " " <<
       wcnt <<
       endl;

  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 999999999999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(25) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 998244353
#define MAX 10000000
#define ALL(a)  a.begin(),a.end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli A,B,C,D,E,F,N,M,K,L,X,Y,Z,H,W,sum=0,num=0,flag=0;string S,T;
  cin >> N >> M;
  int a=1,b=N;
  Vec(isusedv,int,N,0);
  Vec(isusedd,int,N,0);
  rep(i,0,M){
    if(b-a==a-b+N)b--;
    if(isusedd[b-a]||isusedd[a-b+N])b--;
    cout << a << " " << b << endl;
    isusedd[b-a]=true;
    isusedd[a-b+N]=true;
    a++;b--;
  }
}


Measured memory_bytes: 4348
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
bool isPalindrome(string s)
{
 string v;
  int n=s.length();
  for(int i=n-1;i>=0;--i)
  {
    v[i]=s[i];
  }
  for(int i=0;i<n;++i)
  {
    if(v[i]!=s[i])
      return false;
  }
  return true;
}
int main(){
  string s;
  cin>>s;
  int hugs=0,i,j;
  int n=s.length();
  for(i=0;i<n;++i)
  {
    if(s[i]!=s[n-1-i]) hugs++;
  }
       cout<<hugs/2<<endl;
 /* if(isPalindrome(s))
    cout<<hugs<<endl;
  else 
  {
    for(i=0,j=n;i<n/2,j>n/2;++i,--j)
    {
      if(s[i]!=s[j]) hugs++;
    }
        cout<<hugs<<endl;
  }*/
  return 0;
}


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

/*selection sort ?????????????????¨????§????????????????????????¨????????¨??????????????¨????????????????????????*/

int main() {
	int n, a[10000];

	cin >> n;

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

	int minj, k = 0, c;

	for (int i = 0; i < n - 1; i++) {
		minj = i;

		for (int j = i + 1; j < n; j++) {
			if (a[j] < a[minj]) {
				minj = j; //????°????????´??????????????¨????????????????
			}
		}

		if(a[i]!=a[minj])
			k++; //????????????????????°

		c = a[minj];	//a[i]???a[i]??????a??¢n-1]????????§????°????????´?????¨????
		a[minj] = a[i];	//????????????a[i-1]??????a[i-1]??????a[n-1]????????§????°??????°???a[i-2]??????a[i-2]??????a[n-1]...
		a[i] = c;		//?????????n-1?????§n?????°?????????
	}

	for (int i = 0; i < n; i++) {
		cout << a[i];

		if (i == n - 1) cout << endl;
		else cout << " ";
	}

	cout << k << endl;

	return 0;
}
	

Measured memory_bytes: 1168
#include<cstdio>
#include<cmath>

double v;//球が割れる最低速度

int main()
{
	while(scanf("%lf",&v)!=EOF)
	{
		double date = v*v/19.6;
		int N=ceil(date/5)+1;
		printf("%d\n",N);
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define LL long long
#define PII pair<int,int>
#define PIL pair<int,LL>
#define PLI pair<LL,int>
#define PIII pair<int,PII>
#define PLL pair<LL,LL>
#define PLII pair<LL,PII>
#define VI vector<int>
#define VVI vector<VI>
#define VL vector<LL>
#define VVL vector<VL>
#define VPII vector<PII>
#define FF first
#define SS second
#define MP make_pair
#define PB push_back
#define all(x) x.begin(),x.end()
#define watch(x) cout<<(#x)<<" = "<<(x)<<'\n'
#define mset(a,v) memset(a,v,sizeof(a))
#define setp(x) cout<<fixed<<setprecision(x)
#define EPS 0.00000000001
#define PI acos(-1)
#define loop(i,b,n) for(int i=b;i<n;++i)
#define rev_loop(i,b,n) for(int i=b;i>=n;--i)
using namespace std;

const int MOD = 1e9 + 7;
const LL MX = 1e9;
const LL INF = 1e9;

void print_a(VI v)
{
    if(v.size()) cout<<v[0];
    loop(i,1,v.size()) cout<<' '<<v[i];
    cout<<'\n';
}

VVI init_vvi(int n, int m, int val)
{
    return VVI(n,VI(m,val));
}

VVL init_vvl(int n, int m, LL val)
{
    return VVL(n,VL(m,val));
}

int main()
{
    //ofstream out("output.txt");
    //ifstream in("input.txt");
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

    int n,m,k;
    cin>>n>>m>>k;
    VL a(n), b(m);
    loop(i,0,n)
    {
        cin>>a[i];
        if(i) a[i] += a[i-1];
    }

    int ans = 0;

    loop(i,0,m)
    {
        cin>>b[i];
        if(i) b[i] += b[i-1];
        if(b[i] <= k) ans = i+1;
    }

    int k1;
    loop(i,0,n)
    {
        if(k < a[i]) break;
        k1 = max((LL)0, k - a[i]);
        int it = upper_bound(all(b),k1) - b.begin();
        ans = max(ans,i+1+it);
    }

    cout<<ans<<'\n';

    /*
    int t,n;
    cin>>t;
    while(t--)
    {
        cin>>n;
        int a[n];
        loop(i,0,n) cin>>a[i];
    }
    */

    /*
    int n;
    cin>>n;
    int a[n];
    loop(i,0,n) cin>>a[i];
    */

    /*
    cout<<ans<<'\n';

    if(f) cout<<"YES\n";
    else cout<<"NO\n";

    if(f) cout<<"Yes\n";
    else cout<<"No\n";
    */

    return 0;
}


Measured memory_bytes: 6364
#include <bits/stdc++.h>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
#define sz(s) (int)(s.size())
#define vecprint(v) rep(i,0,v.size()-1)cout << v[i] << " ";cout << endl;

using namespace std;
typedef long long ll;
const ll M = 1000000007;

vector<long long> fac(3000001); //n!(mod M)
vector<long long> ifac(3000001); //k!^{M-2} (mod M)

long long fact(long long n,long long g){
    if(n==g)return 1;
    return(((long long) n*fact(n-1,g)));
}

ll mpow(ll x, ll n){ //x^n(mod M) ←普通にpow(x,n)では溢れてしまうため，随時mod計算
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % M;
        x = x*x % M;
        n = n >> 1;
    }
    return ans;
}

ll comb(ll a, ll b){ //aCbをmod計算
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0)return 0;
    ll tmp = ifac[a-b]* ifac[b] % M;
    return tmp * fac[a] % M;
}

int main(){
    int x,y;
    long long a,b,ans;
    cin >> x >> y;

    if((2*x-y)%3!=0 || (2*y-x)%3!=0){
        puts("0");
        return 0;
    }
    b = (long long)(2*x-y)/3;
    a = (long long)(2*y-x)/3;
  if(a==0 || b==0){
    puts("1");
    return 0;
  }

    fac[0] = 1;
    ifac[0] = 1;
    for(ll i = 0; i<3000000; i++){
        fac[i+1] = fac[i]*(i+1) % M; // n!(mod M)
        ifac[i+1] = ifac[i]*mpow(i+1, M-2) % M; // k!^{M-2} (mod M) ←累乗にmpowを採用
    }
    ans = comb(a+b, max(a,b))%M;
//cout << fac[b]<< endl;cout << fac[a]<< endl;
    cout << ans << endl;
//  printf("%.10f\n",ans);

    return 0;
}

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

int main(void){
    // Your code here!
    string s; cin >> s;
    ll length = s.size();
    bool res = true;
    rep(i,length){
        if ( s[i] != s[length - i-1])res = false;
    }
    for ( int i = 0 ; i < (length-1)/2 - i-1;i++){
        if (s[i] != s[(length-1)/2 - i-1]) res = false;
    }
    for ( int i = 0 ; i+(length+3)/2-1< length- i-1;i++){
        if (s[i+(length+3)/2-1] != s[length- i-1]) res = false;
    }

    cout << (res? "Yes" : "No") << endl;
}


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

int dp[40];

int main(void) {
    int n;
    dp[0] = 1;
    dp[1] = 2;
    dp[2] = 4;
    for (int i = 3; i < 40; i++) {
        dp[i] += (dp[i-1]+dp[i-2]+dp[i-3]);
    }
    while (cin >> n, n) {
        int year = 1;
        while (year*365*10 < dp[n-1]) {
            year++;
        }
        cout << year << endl;
    }

    return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
//#include<tr1/unordered_map>
#pragma GCC optimize ("Ofast")
#define ll long long
#define pll pair<long long,long long>
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define forn(i, n) for(int i=0; i<int(n); i++)
#define Forn(i, n) for(int i=1; i<=int(n); i++)

using namespace std;

int n, k;
string s;


int main()
{
    cin.tie(0); ios_base::sync_with_stdio(false);
    cin >> n >> k >> s;
    int run = 1;
    char now = s[0];
    for(int i=1; i<n; i++)
    {
        if(s[i]!=now) run++;
        now = s[i];
    }
    forn(i, k) run = max(run-2, 1);
    cout << n-run << endl;

}


Measured memory_bytes: 512
def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a%b)
while True:
	try:
		a, b = map(int, raw_input().strip().split(' '))
		print "%d %d" % (gcd(a, b), a*b/gcd(a, b))
	except EOFError:
		break

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

int main() {
  int a,b,c;
  cin>>a>>b>>c;
  int maximum =max(max(a,b),c);
  int minimax =min(max(a,b),c);
  int minimum =min(min(a,b),c);
  cout<<abs(maximum-minimax)+abs(minimax-minimum)<<endl;
}

Measured memory_bytes: 256
def main():
    import sys
    n = int(input())
    a, b, c = 0, 0, 0
    for x in sys.stdin.readlines():
        aa, bb, cc = map(int, x.split())
        if a == b == c == 0:
            a, b, c = aa, bb, cc
        else:
            a, b, c = aa+max(b, c), bb+max(a, c), cc+max(a, b)

    print(max(a, b, c))

if __name__ == '__main__':
    main()

Measured memory_bytes: 11052
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			if (n <= 999) {
				System.out.println("ABC");
			} else {
				System.out.println("ABD");
			}
		}

	}

}

Measured memory_bytes: 23636
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
#define int long long
#define pb push_back
#define fi first
#define se second
#define fr(i, a, b) for(int i = a; i <= b; i++)
#define all(x) x.begin(), x.end()
#define IO ios :: sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define pii pair<int,int>
#define sz(x) (int)x.size()
const int mod = 1e9 + 7;
const int mod1 = 998244353;
typedef long double f80;

#ifndef LOCAL
#pragma GCC optimize ("O2")
#define endl '\n'
#endif

template<typename T>
using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rand(int l, int r){
    uniform_int_distribution<int> uid(l, r);
    return uid(rng);
}

ll pwr(ll a,ll b, ll mod){
    a %= mod;
    int ans = 1;
    while(b){
        if(b & 1) ans = (ans * a) % mod;
        a = (a * a) % mod;
        b >>= 1;
    }
    return ans;
}

string to_string(string s) {
  return '"' + s + '"';
}

string to_string(const char* s) {
  return to_string((string) s);
}

string to_string(bool b) {
  return (b ? "true" : "false");
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

const int N = 2e5 + 5;
int a[N];
void solve(){
	int n;
	cin >> n;
	fr(i, 1, n){
		cin >> a[i];
		a[i] += a[i - 1];
	}
	int pt1 = 1, pt2 = 2;
	int ans = 1e18;
	fr(i, 2, n - 2){
		assert(pt1 <= i);
		assert(pt2 >= i);
		while(abs(a[pt1] - (a[i] - a[pt1])) > abs(a[pt1 + 1] - (a[i] - a[pt1 + 1])))
			pt1++;
		while(abs(a[pt2] - a[i] - (a[n] - a[pt2])) > abs(a[pt2 + 1] - a[i] - (a[n] - a[pt2 + 1])))
			pt2++;
		ans = min(ans, max({a[pt1], a[i] - a[pt1], a[pt2] - a[i], a[n] - a[pt2]}) - min({a[pt1], a[i] - a[pt1], a[pt2] - a[i], a[n] - a[pt2]}));
	}
	cout << ans;
}
signed main(){
    IO;
    #ifdef LOCAL
        freopen("inp.txt","r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    cout << setprecision(10) << fixed;
    int t = 1;
    // cin >> t;
    fr(tt, 1, t){
        solve();
    }
    return 0;
}

Measured memory_bytes: 1792
n=int(input())
a=list(map(int, input().split()))
ans=0

s=sum(a)

for i in range(1,len(a)+1):
    ans += a[i-1] * (s-a[i-1])
    s = s-a[i-1]
    ans = ans % (10 ** 9 + 7)

print(ans)

Measured memory_bytes: 31460
#include<bits/stdc++.h>
using namespace std;
int main(){
  int64_t n,k,r,s,p,i,j,cnt,ans=0;
  string t;
  cin>>n>>k>>r>>s>>p>>t;
  vector<int> c(n);
  for(i=0;i<n;i++){
    if(t.at(i)=='r') ans+=p;
    else if(t.at(i)=='s') ans+=r;
    else if(t.at(i)=='p') ans+=s;
  }
  for(i=0;i<n-k;i++){
    if(c.at(i)==0){
      c.at(i)=1;
      j=i+k;
      cnt=1;
      while(j<n && t.at(i)==t.at(j)){
        cnt++;
        c.at(j)=1;
        j+=k;
      }
      if(cnt>=2){
        j=cnt/2;
        if(t.at(i)=='r') ans-=p*j;
        else if(t.at(i)=='s') ans-=r*j;
        else if(t.at(i)=='p') ans-=s*j;
      }
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 896
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define MT make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define RT return
#define vv(a,b,c,d) vector<vector<a> >(b,vector<a>(c,d))
#define vvv(a,b,c,d,e) vector<vector<vector<a> > >(b,vv(a,c,d,e))
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;

class UnionFind {
    int cnt;
    vector<int> par, rank, size;
public:
    UnionFind() {}
    UnionFind(int _n) :cnt(_n), par(_n), rank(_n), size(_n, 1) {
        for (int i = 0; i<_n; ++i) par[i] = i;
    }
    int find(int k) {
        return (k == par[k]) ? k : (par[k] = find(par[k]));
    }
    int operator[](int k) {
        return find(k);
    }
    int getSize(int k) {
        return size[find(k)];
    }
    void unite(int x, int y) {
        x = find(x); y = find(y);
        if (x == y) return;
        --cnt;
        if (rank[x] < rank[y]) {
            par[x] = y;
            size[y] += size[x];
        } else {
            par[y] = x;
            size[x] += size[y];
            if (rank[y] == rank[x]) ++rank[x];
        }
    }
    int count() {
        return cnt;
    }
};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    int N, M;
    while (cin >> N >> M) {
        vi P(N);
        rep(i, N) {
            cin >> P[i];
            --P[i];
        }
        UnionFind uf(N);

        vi X(M), Y(M);
        rep(i, M) {
            cin >> X[i] >> Y[i];
            --X[i];
            --Y[i];
            uf.unite(X[i], Y[i]);
        }
        int re = 0;
        rep(i, N) {
            if (uf[i] == uf[P[i]]) {
                re++;
            }
        }
        cout << re << endl;
    }
}

Measured memory_bytes: 2560
n = int(input())
X = list(map(int, input().split()))
Y = list(map(int, input().split()))
# p=1,2,3
for p in range(1, 4):
    print("{0:.6f}".format(sum([abs(a-b)**p for a, b in zip(X, Y)])**(1/p)))
# p=infinity
print("{0:.6f}".format(max([abs(a-b) for a, b in zip(X, Y)])))
    
    



Measured memory_bytes: 5652
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#define _ << " " <<
#define all(v) v.begin(), v.end()
#define sp(n) fixed << setprecision(n)

using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;


int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin >> n;
	vector<int> p(n);
	for (int& i : p) cin >> i;
	sort(all(p));
	cout << p[n / 2] - p[n / 2 - 1] << endl;
	return 0;
}

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

using namespace std;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(0);
    int k;
    string s, c = "...";
    cin >> k >> s;
    if (s.length() > k) {
        cout << s.substr(0, k)+ c;
    }
    else
        cout << s;

}

Measured memory_bytes: 3640
#include <iostream>

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    int n, a, cnt = 1;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> a;
        if (a == cnt) ++cnt;
    }
    cout << (cnt == 1 ? -1 : n - (cnt - 1)) << endl;
    return 0;
}


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

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

    bool ans = true;
    for (int i = 0; i < n; i++) {
        if (a[i]%2 == 0) {
            if (a[i]%3 != 0 && a[i]%5 != 0) {
                ans = false;
                break;
            }
        }
    }
    
    if (ans) cout << "APPROVED" << endl;
    else cout << "DENIED" << endl;
}

Measured memory_bytes: 3572
a=list(map(int,input().split()))
b=[input() for i in range(a[0])]

for i in range(a[0]-1):
    for j in range(a[0]-1):
        if (b[a[0]-1-j]<b[a[0]-2-j]):
            temp=b[a[0]-j-1]
            b[a[0]-j-1]=b[a[0]-2-j]
            b[a[0]-2-j]=temp

for i in range(a[0]):
    print(b[i], end='')

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define hell (int)(1e9+7)
#define int long long int
#define inf 1000000000000

using namespace std;

void solve(){
    int a,b;
    cin>>a>>b;
    for(int i=1;i<1000005;i++){
        int ta,tb;
        ta=(8*i)/100;
        tb=(10*i)/100;
        if(ta==a&&tb==b){
            cout<<i;
            return;
        }
    }
    cout<<-1;
}

signed main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t,c;
	//cin>>t;
	t=1;
	while(t--){
		solve();
	}
	return 0;
}


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

using namespace std;
typedef long long ll;
#define debug(x) cerr << x << "\n"
#define all(x) (x).begin(),(x).end()
#define exist(s, e)((s).find(e) != (s).end())

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string s;
    cin >> s;
    int ans = 0;
    int a,z;
    for (int i=s.size();i>=0;i--) {
        if (s[i] == 'Z') {
            z = i;
            break;
        }
    }
    for (int i=0;i<s.size();i++) {
        if (s[i] == 'A') {
            a = i;
            break;
        }
    }
    cout << z - a + 1<< '\n';
    
    return 0;
}

Measured memory_bytes: 720
#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)

template<class T> inline void chmin(T& a, T b) {if (a > b) a = b;}
template<class T> inline void chmax(T& a, T b) {if (a < b) a = b;}

int main() {
  int N,K;
  cin >> N >> K;
  ll x0,x1,y0,y1;
  vector<ll> X(N),Y(N);
  rep(i,N){
    cin >> X[i] >> Y[i];
  }
  ll ans=8*1e18;
  rep(i,N)rep(j,N)rep(k,N)rep(l,N) {
    x0 = min({X[i],X[j],X[k],X[l]});
    x1 = max({X[i],X[j],X[k],X[l]});
    y0 = min({Y[i],Y[j],Y[k],Y[l]});
    y1 = max({Y[i],Y[j],Y[k],Y[l]});
    int cnt=0;
    rep(m,N) {
      if (x0<=X[m]&&X[m]<=x1&&y0<=Y[m]&&Y[m]<=y1) cnt++;
    }
    // cout << cnt << endl;
    if (cnt>=K) chmin(ans,(x1-x0)*(y1-y0));
  }
  cout << ans << endl;
} 

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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 (a>b) { a=b; return 1; } return 0; }

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,X,T; cin>>N>>X>>T;
    cout<<(N+X-1)/X*T<<endl;
    return 0;
}


Measured memory_bytes: 3608
#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>
#include <cstring>
#include <utility>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <bitset>
#include <stack>
#include <deque>
using namespace std;
typedef pair<int, int> pii;
typedef long long LL;
const int MAXN = 123456;
int par[MAXN], indeg[MAXN];
vector<int> G[MAXN];
bool visit[MAXN];

int main() {
    int N, M;
    scanf("%d %d", &N, &M);
    for (int i = 0; i < N + M - 1; i++) {
        int a, b;
        scanf("%d %d", &a, &b);
        G[a].push_back(b);
        indeg[b]++;
    }
    priority_queue<pii, vector<pii>, greater<pii>> pq;
    for (int i = 1; i <= N; i++)
        pq.push(make_pair(indeg[i], i));
    while (!pq.empty()) {
          auto tmp = pq.top();
          pq.pop();
          int cur = tmp.second;
          if (visit[cur]) continue;
          if (!indeg[cur]) visit[cur] = true;
          for (auto i : G[cur]) {
              if (indeg[i] == 1) par[i] = cur;
              indeg[i]--;
              pq.push(make_pair(indeg[i], i));
          }
    }
    for (int i = 1; i <= N; i++)
        printf("%d\n", par[i]);
    return 0;
}


Measured memory_bytes: 8688
#include <bits/stdc++.h>
#define debug(x) cerr << #x << ": " << x << '\n';
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = (int)1e9;

#ifndef UNION_FIND_TREE
#define UNION_FIND_TREE
class UnionFindTree{
	private:
		int N;
		unique_ptr<int[]> parent;
		unique_ptr<int[]> rank;
		unique_ptr<int[]> size;
	public:
		UnionFindTree(int N){
			this -> N = N;
			this -> parent = make_unique<int[]>(N);
			this -> rank = make_unique<int[]>(N);
			this -> size = make_unique<int[]>(N);
			for(int i = 0; i < (int) N; i++){
				parent[i] = i; rank[i] = 0; size[i] = 1;
			}
		}
		void init(){
			for(int i = 0; i < (int) N; i++){
				parent[i] = i; rank[i] = 0; size[i] = 1;
			}
		}
		int find(int x){
			if(parent[x] == x) return x;
			else return parent[x] = find(parent[x]);
		}
		void unite(int x, int y){
			x = find(x); y = find(y);
			if(x == y) return;

			if(rank[x] < rank[y]){
				parent[x] = y;
				size[y] += size[x];
			}else{
				parent[y] = x;
				size[x] += size[y];
				if(rank[x] == rank[y]) rank[x]++;
			}
		}
		bool same(int x, int y){
			return find(x) == find(y);
		}
		int count(int x){
			return size[find(x)];
		}
};
#endif

int N, K, L;
int res[200000];

int main(void){
    cin >> N >> K >> L;
    UnionFindTree road(N), railway(N);
    for(int i = 0; i < K; i++){
        int a, b; cin >> a >> b;
        road.unite(--a, --b);
    }
    for(int i = 0; i < L; i++){
        int a, b; cin >> a >> b;
        railway.unite(--a, --b);
    }

    map<P, int> mp;
    for(int i = 0; i < N; i++){
        mp[P(road.find(i), railway.find(i))]++;
    }

    for(int i = 0; i < N; i++){
        cout << mp[P(road.find(i), railway.find(i))] << '\n';
    }

    return 0;
}

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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var s = Console.ReadLine();

            var item = s.Take(N);
            if (item.Count(a => a == 'R') > item.Count(a => a == 'B'))
                Console.WriteLine("Yes");
            else
                Console.WriteLine("No");
           
        }
    }
}


Measured memory_bytes: 11220
class Fixnum
	%w( + - * / % ).each do |op|
		orig = "orig_" + op
		alias_method orig, op
		define_method op do |other|
			return send(orig, other).send("orig_%", 256) if other.class == Fixnum	
			other.map{|x| send(orig, x).send("orig_%", 256)}.uniq
		end
	end
end

class Array
	%w( + - * / % ).each do |op|
		define_method op do |other|
			if other.class == Fixnum
				return map{|x| x.send(op, other)}.uniq
			end

			map{|x| x.send(op, other)}.flatten.uniq 
		end
	end
end

n = gets.to_i
var = {}
n.times do
	name, l, u = gets.chomp.split
	var[name] = (l.to_i..u.to_i).to_a
end

gets
stack = []

begin 
	gets.chomp.split.each do |x|
		case x
		when /[+-\/*%]/
			rhs, lhs = stack.pop, stack.pop
			stack << lhs.send(x, rhs)
		when /^\d+$/
			stack << x.to_i
		else
			stack << var[x]
		end
	end	
	puts 'correct'
rescue
	puts 'error'
end

Measured memory_bytes: 10432
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {

	public static void main(String[] args) {
		//		new Main().solveA();
		new Main().solveB();
		// new Main().solveC();
		// new Main().solveD();
		//		new Main().solveE();
		//		new Main().solveF();
	}

	private void solveA() {
		Scanner scanner = null;
		int numN = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();

			System.out.println(numN / 3);

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveB() {
		Scanner scanner = null;
		int numN = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();

			Set<String> wkSet = new HashSet<String>();
			for (int i = 0; i < numN; i++) {
				wkSet.add(scanner.next());
			}

			System.out.println(wkSet.size() == 3 ? "Three" : "Four");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveC() {
		Scanner scanner = null;
		int numN = 0;
		int numK = 0;
		int numS = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveD() {
		Scanner scanner = null;
		int numN = 0;
		int numK = 0;
		int numS = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveE() {
		Scanner scanner = null;
		int numN = 0;
		int numK = 0;
		int numS = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveF() {
		Scanner scanner = null;
		int numN = 0;
		int numK = 0;
		int numS = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}
}

Measured memory_bytes: 21460
fun main(args: Array<String>) {
    val n = readInt()
    val a = readIntList()

    val d = mutableListOf<Boolean>()
    var i = 0
    while (i < n - 1) {
        if (a[i + 1] - a[i] > 0) d.add(true)
        if (a[i + 1] - a[i] < 0) d.add(false)
        i++
    }

    if (d.size == 0) {
        println(1)
        return
    }
    var ans = 1
    var b = d[0]
    for (i in 1 until d.size) {
        if (d[i] != b) {
            ans++
            if (i + 1 < d.size) b = d[i + 1]
        }
    }
    println(ans)
}

// Tools
fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)

Measured memory_bytes: 53356
n,m=map(int,input().split())
A=[int(input()) for i in range(n)]
B=[int(input()) for i in range(m)]
I=[0 for i in range(n)]
for i in range(m):
    for j in range(n):
        if B[i]>=A[j]:
            I[j]+=1
            break
print(I.index(max(I))+1)


Measured memory_bytes: 5628
// abc156_b
#include <iostream>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>

#define US unsigned short
#define UI unsigned int
#define UC unsigned char
#define UL unsigned long
#define ULL unsigned long long
using namespace std;

int main(int argc, char const *argv[])
{
    UI n, k;
    cin >> n >> k;
    cout << floor(log(n) / log(k)) + 1 << endl;
}


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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

bool is_prime(long long n) {
    if (n == 1) {
        return false;
    }
    for (long long i=2; i*i<=n; i++) {
        if (n%i == 0) {
            return false;
        }
    }
    return true;
}

int main() {
    ll x;
    cin >> x;
    while (!is_prime(x)) {
        x++;
    }
    cout << x << endl;
    return 0;
}


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

int main() {
  string a, b, c;
  cin >> a >> b >> c;
  if (a.at(a.size()-1) == b.at(0) && b.at(b.size()-1) == c.at(0)) cout << "YES" << endl;
  else cout << "NO" << endl;
}


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

struct Prime{

  vector<int> prime; // 2,3,5,7,11...
  vector<bool> is_prime; // 素数=1,合成数=0
  void eratos(int n){
    is_prime.resize(n+1,true);
    is_prime[0] = is_prime[1] = false;
    for(int i = 2; i <= n; i++){
      if(is_prime[i]){
        prime.push_back(i);
        for(int j = i; j <= n; j+=i){
          is_prime[j] = false;
        }
      }
    }
  }

  //因数分解
  map<int,int> prime_factor(int n){
    map<int,int> mp; //{約数,個数}
    for(int i = 2; i*i <= n; i++){
      while(n%i == 0){
        mp[i]++;
        n /= i;
      }
    }
    if(n != 1) mp[n] = 1; //n=素数
    return mp;
  }

  //mpから作れる、約数をちょうどn個もつ数の個数
  int factor_cnt(map<int,int> mp,int n){
    vector<int> dp(n+2); //約数がちょうどi個の数の個数
    dp[1] = 1;
    for(auto p : mp) {
      for(int i = n; i > 0; i--) {
        for(int j = p.second; j > 0; j--) {
          dp[ min(n+1,i*(j+1)) ] += dp[i];
        }
      }
    }
    return dp[n];
  }

}prime;

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

  int n; cin >> n;
  map<int,int> mp;
  for(int i = 2; i <= n; i++){
    auto p = prime.prime_factor(i);
    for(auto x : p){
      mp[x.first] += x.second;
    }
  }

  cout << prime.factor_cnt(mp,75) << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
  int n,k;
  cin>>n>>k;
  vector<int> l(n);
  rep(i,n){
    cin>>l[i];
  }
  sort(l.begin(),l.end());
  reverse(l.begin(),l.end());
  int ans=0;
  rep(i,k){
    ans+=l[i];
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<endl;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b){ a = b; return 1; } return 0; }

ll f(ll x) {
     switch (x % 4) {
         case 0:
             return x;
         case 1:
             return 1;
         case 2:
             return x + 1;
         case 3:
             return 0;
     }
     return 0;
}

int main(int argc, char const *argv[]) {
  ll a, b;
  cin >> a >> b;
  if (a != 0) a--;
  ll ans = f(a) ^ f(b);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
int INF = 100000;
long long N, W;
int main(){
    cin >> N >> W;
    std::vector<int> w(N, 0);
    std::vector<int> value(N, 0);
    for (int i = 0; i < N; ++i){
        cin >> value[i] >> w[i];
    }
    vector<vector<int> > dp(N + 1, vector<int>(W + 1, 0));
    
    for (int i = 0; i < N; ++i){
        for (int j = 1; j <= W; ++j){
            if (j - w[i] >= 0){
                dp[i + 1][j] = max(dp[i + 1][j - w[i]] + value[i], dp[i][j]);
            }else{
                dp[i + 1][j] = dp[i][j];
            }
        }
    }
    cout << dp[N][W] << endl;
}


Measured memory_bytes: 6840
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Random;
import java.util.StringTokenizer;

public class Main {

	static int h, w;
	static char[][] board;
	
	public static void main(String[] args) {
		FastScanner fs=new FastScanner();
		h=fs.nextInt(); w=fs.nextInt();
		int sy=fs.nextInt()-1, sx=fs.nextInt()-1;
		int ey=fs.nextInt()-1, ex=fs.nextInt()-1;
		ArrayDeque<Integer> xs=new ArrayDeque<>(), ys=new ArrayDeque<>();
		board=new char[w][h];
		for (int y=0; y<h; y++) {
			char[] line=fs.next().toCharArray();
			for (int x=0; x<w; x++) {
				board[x][y]=line[x];
			}
		}
		xs.add(sx);
		ys.add(sy);
		int[][] dist=new int[w][h];
		for (int x=0; x<w; x++) Arrays.fill(dist[x], 1_000_000_000);
		dist[sx][sy]=0;
		int[] dx= {-1, 1, 0, 0};
		int[] dy= {0, 0, -1, 1};
		while (!xs.isEmpty()) {
			int curX=xs.removeFirst(), curY=ys.removeFirst();
			for (int d=0; d<4; d++) {
				int nx=curX+dx[d], ny=curY+dy[d];
				if (!legal(nx, ny)) continue;
				if (dist[nx][ny]>dist[curX][curY]) {
					dist[nx][ny]=dist[curX][curY];
					xs.addFirst(nx);
					ys.addFirst(ny);
				}
			}
			for (int x=curX-2; x<=curX+2; x++) {
				for (int y=curY-2; y<=curY+2; y++) {
					if (!legal(x, y)) continue;
					if (dist[x][y]>dist[curX][curY]+1) {
						dist[x][y]=dist[curX][curY]+1;
						xs.addLast(x);
						ys.addLast(y);
					}
				}
			}
		}
		System.out.println(dist[ex][ey]>1e7?-1:dist[ex][ey]);
	}

	static boolean legal(int x, int y) {
		if (x<0||y<0||x>=w||y>=h || board[x][y]=='#') return false;
		return true;
	}
	
	static final Random random=new Random();
	
	static void ruffleSort(int[] a) {
		int n=a.length;//shuffle, then sort 
		for (int i=0; i<n; i++) {
			int oi=random.nextInt(n), temp=a[oi];
			a[oi]=a[i]; a[i]=temp;
		}
		Arrays.sort(a);
	}
	
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		
		int nextInt() {
			return Integer.parseInt(next());
		}
		int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
		}
		long nextLong() {
			return Long.parseLong(next());
		}
	}

	
}


Measured memory_bytes: 64216
require 'pp'

def gets; ARGF.gets; end

class Solver

  def main
    n = gets.chomp.to_i
    ary = gets.split.map(&:to_i)

    streak = -1
    max_streak = 0
    pre_h = 1000000001
    n.times do |i|
      if ary[i] <= pre_h
        streak += 1
        max_streak = streak if max_streak < streak
      else
        streak = 0
      end
      pre_h = ary[i]
    end

    puts max_streak
  end
end

if __FILE__ == $0
  Solver.new.main
end


Measured memory_bytes: 8840
#include <iostream>
#include <fstream>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <stack>

#define rep(i,x) for(int i=0;i<x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rep_to(a,i,x) for(int i=a;i<x;i++)

using namespace std;

int main()
{
	int n;
	int y,m,d;
	
	cin >> n;
	
	rep(i,n)
	{
		int pre_day=196471;
		int day=0;

		cin >> y >> m >> d;

		for(int i=1;i<y;i++)
		{
			if(i%3==0)day+=200;
			else day+=195;
		}
		for(int i=1;i<m;i++)
		{
			if(y%3!=0)
			{
				if(i%2!=0)day+=20;
				else day+=19;	
			}
			else day+=20;
		}
		day+=d;

		cout << pre_day-day << endl;
	}

	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,M,X,Y;cin>>N>>M;
  vector<int>A(N,1);
  vector<bool>B(N,false);
  B.at(0)=true;
  for(int i=0;i<M;i++){
    cin>>X>>Y;X--;Y--;
    A.at(X)--;A.at(Y)++;
    if(B.at(X)){
      B.at(Y)=true;
      if(A.at(X)==0)B.at(X)=false;
    }
  }
  cout<<count(B.begin(),B.end(),true)<<endl;
}

Measured memory_bytes: 640
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <fstream>
#include <vector>
#include <set>
#include <algorithm>
#include <queue>
#include <string> 
#include <map>
#include <iomanip>

using namespace std;


typedef int INT;
#define int long long

INT main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);

	vector <int> g[100001];

	int n, m;
	cin >> n >> m;
	vector <int> a(n);
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		a[i]--;
	}

	int b, c;
	for (int i = 0; i < m; i++)
	{
		cin >> b >> c;
		g[b - 1].push_back(c - 1);
		g[c - 1].push_back(b - 1);
	}
	vector <bool> used(n);
	int sum = 0;
	for (int i = 0; i < n; i++)
	{

		if (!used[i])
		{
			vector <int> pos, in;
			used[i] = true;
			queue <int> q;
			q.push(i);
			while (!q.empty())
			{
				int v = q.front();
				q.pop();
				pos.push_back(v);
				in.push_back(a[v]);
				for (int j = 0; j < g[v].size(); j++)
				{
					if (!used[g[v][j]])
					{
						used[g[v][j]] = true;
						q.push(g[v][j]);
					}
				}
			}

			sort(in.begin(), in.end());
			for (int j = 0; j < pos.size(); j++)
			{
				sum += upper_bound(in.begin(), in.end(), pos[j]) - lower_bound(in.begin(), in.end(), pos[j]);
			}
		}
	}
	cout << sum;
	return 0;
}

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

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

    int ans = 1e9;
    rep(i, n-1)
    {   
        int leftSum = 0, rightSum = 0;
        rep(j, i+1)
        {
            leftSum += w[j];
        }
        for(int k = i + 1; k < n; ++k)
        {
            rightSum += w[k];
        }
        //cout << leftSum << " " << rightSum << endl;
        ans = min(ans, abs(leftSum - rightSum));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int MOD = 1000000007;

int main() {
  int N, M; cin >> N >> M;

  string result;
  if (N==M) result = "Draw";
  else if (N==1 && M==13) result = "Alice";
  else if (N==13 && M==1) result = "Bob";
  else if (N>M) result = "Alice"; else result = "Bob";
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
	#include <cstdio>
	#include <cstring>
	#include <cmath>
	#include <cstring>
	#include <chrono>
	#include <complex>
	#define endl "\n"
	#define ll long long int
	#define vi vector<int>
	#define vll vector<ll>
	#define vvi vector < vi >
	#define pii pair<int,int>
	#define pll pair<long long, long long>
	#define mod 1000000007
	#define inf 1000000000000000001;
	#define all(c) c.begin(),c.end()
	#define mp(x,y) make_pair(x,y)
	#define mem(a,val) memset(a,val,sizeof(a))
	#define eb emplace_back
	#define f first
	#define s second
	
	using namespace std;
	int main()
	{
		int n;
		cin>>n;
		cout<<ceil(n/2.0)<<endl;	
		return 0;
	}


Measured memory_bytes: 256
// Author: Vamsi Krishna Reddy Satti
// With love for Competitive Programming!
 
// #pragma GCC optimize ("Ofast,unroll-loops,-ffloat-store")
// #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")

#include <bits/stdc++.h>
using namespace std;

string to_string(const string& s) { return '"' + s + '"'; }
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cout << " " << to_string(H);
    debug_out(T...);
}
#ifdef LOCAL
    #define debug(...) cout << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
    #define debug(...) 3
#endif
 
#define cin_exception cin.exceptions(cin.failbit);
#define cout_precision cout.setf(ios::fixed); cout.precision(15);
#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
using ld = long double; using vi = vector<int>;
using ll = int_fast64_t; using ull = uint_fast64_t;
using vl = vector<ll>; using vul = vector<ull>;

// -----------------------------------------------------------------------------

const int N = 1e6 + 5;
int n;
string s;
int a[N];
int cn[N];

void preprocess() {
    for (int i = 1; i < N; ++i) {
        if (i & 1) continue;
        cn[i] = cn[i >> 1] + 1;
    }
    for (int i = 1; i < N; ++i) {
        cn[i] += cn[i - 1];
    }
}

int ln_nCr(int n, int r) {
    assert(n >= r);
    return cn[n] - cn[n - r] - cn[r];
}

void solve() {
    cin >> n >> s;
    for (int i = 0; i < n; ++i) {
        a[i] = s[i] - '1';
    }
    int k = 1;
    while (1) {
        int p = 0;
        for (int i = 0; i < n; ++i) {
            if (!(a[i] & 1)) continue;
            p ^= (ln_nCr(n - 1, i) == 0);
        }
        if (p) {
            cout << k << '\n';
            return;
        }
        int oe = 0, te = 0;
        for (int i = 0; i < n; ++i) {
            if (a[i] == 1) oe = 1;
            if (a[i] == 2) te = 1;
        }
        if (oe || (!te)) {
            cout << 0 << '\n';
            return;
        }
        for (int i = 0; i < n; ++i) {
            a[i] >>= 1;
        }
        ++k;
    }
}

int main() {
    fast_io; cin_exception;
    preprocess();
    int t = 1;
    // cin >> t;
    for (int i = 1; i <= t; ++i) {
        solve();
    }
}

Measured memory_bytes: 9116
#include <bits/stdc++.h>
#define INF 1000000000
#define LINF 1000000000000000000
#define MOD 1000000007
#define mod 1000007
#define INF63 1061109567
#define INF127 9187201950435737471
#define UINF 18446744073709551615
#define F first
#define S second
#define ll long long
using namespace std;
ll n,sum=0;
int main(){
	ll i;
	cin>>n;
	for(i=1;i<=n;i++)
	{
		if(i%3!=0&&i%5!=0)
		{
			sum+=i;
		}
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 3632