akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
constexpr int MOD = 1000000007;
constexpr int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;
using Graph = vector<vector<int>>;

bool seen[2000000]{};
bool finished[2000000]{};
int d[2000000]{};
int dfs(const Graph &G, int now){
    if(seen[now] == true) return d[now];
    seen[now] = true;
    for(auto e : G[now]){
        if(seen[e] && !finished[e]){
            cout << -1 << endl;
            exit(0);
        }
        if(seen[e]) d[now] = max(d[now], d[e]+1);
        else d[now] = max(d[now], dfs(G, e)+1);
    }
    finished[now] = true;
    return d[now];
}

int encode(int i,int j){
    if(i < j) swap(i, j);
    return i * (i - 1) / 2 + j + 1;
}


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

	int N;
    cin >> N;
    Graph G(N*(N-1)/2+1);
    rep(i,N){
        int now = 0;
        rep(j,N-1){
            int k;
            cin >> k;
            --k;
            int next = encode(i, k);
            G[now].push_back(next);
            now = next;
        }
    }
    cout << dfs(G, 0) << endl;
}

Measured memory_bytes: 35840
#include<stdio.h>

int main() {
	int n, m, x, val, cnt, temp;
	val = scanf("%d%d%d", &n, &m, &x);
	if (val == 0) return 1;
	cnt = 0;
	for (val = 0; val < m; val++) {
		n = scanf("%d", &temp);
		if (n == 0) return 1;;
		if (temp < x) cnt++;
		else break;
	}
	printf("%d", (cnt < m - cnt) ? cnt : m - cnt);
}


Measured memory_bytes: 128
from sys import stdin
N = int(stdin.readline().rstrip())
A = [int(x) for x in stdin.readline().rstrip().split()]
mod = 10**9+7

ans = 1
n = [0,0,0]
for i in A:
    cnt = 0
    for ind ,j in enumerate(n):
        if i == j:
            cnt += 1
    for ind ,j in enumerate(n):
        if i == j:
            n[ind] += 1
            break
    ans = ans*cnt
    ans = ans % mod
print(ans)

Measured memory_bytes: 14396
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#define nmax_def 110000
#define Cmax_def 2200
#define mod 1000000007
using namespace std;
typedef long long ll;

int main() {
	ll i, j;
	ll r, ans;
	cin >> r;
	ans = 3 * r * r;
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main
{
	public static void main(String[] args) throws IOException
	{
		Scanner sc = new Scanner(System.in);

		String s = sc.next();
		int nn = s.length();
		int[] freq = new int[26];
		for(int i=0;i<s.length();i++)
			freq[s.charAt(i)- 'a']++;
		long all = (1l*nn* (nn+1))/2 ;
		for(int x : freq)
			all -=((1l*x*(x+1))/2);
		System.out.println(all + 1);
	}
	static class Scanner{
		StringTokenizer st;BufferedReader br;
		public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}
		public String next() throws IOException 
		{while (st == null || !st.hasMoreTokens()) st = new StringTokenizer(br.readLine());return st.nextToken();}
		public int nextInt() throws IOException {return Integer.parseInt(next());}
		public long nextLong() throws IOException {return Long.parseLong(next());}
		public String nextLine() throws IOException {return br.readLine();}
		public double nextDouble() throws IOException {return Double.parseDouble(next());}
		public boolean ready() throws IOException {return br.ready();}
	}
}


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

using namespace std;

#define MAX_N 100000
const double INF = 1e50;

typedef pair<double,double> P;

int N;
P A[MAX_N];

bool compare_y(const P &a,const P &b){
  return a.second < b.second;
}
//??????????????¨????????§????±?????°???????????????????????????????????????????
//?±????????????????????????????x???????????§d????????¢????°???????????????¨???
//????????????????????§???????±?1000000??§??????????????????????????????
double closest_pair(P *a,int n){
  if(n <= 1) return INF;
  int m = n / 2;
  double x = a[m].first;
  double d = min(closest_pair(a,m),closest_pair(a+m,n-m));
  inplace_merge(a,a+m,a+n,compare_y);
  vector<P> b;
  for(int i = 0 ; i < n ; i++){
    if(fabs(a[i].first - x) >= d) continue;
    for(int j = 0 ; j < (int)b.size() ; j++){
      double dx = a[i].first - b[b.size()-j-1].first;
      double dy = a[i].second - b[b.size()-j-1].second;
      if(dy >= d) break;
      d = min(d,sqrt(dx * dx + dy * dy));
    }
    b.push_back(a[i]);
  }
  return d;
}

void solve(){
  sort(A,A+N);
  printf("%.8f\n",closest_pair(A,N));
}

int main(){
  cin >> N;
  for(int i = 0 ; i < N ; i++){
    scanf("%lf%lf",&A[i].first,&A[i].second);
  }
  solve();
  return 0;
}

Measured memory_bytes: 7924
#include <bits/stdc++.h>
using namespace std;
int main() {
  int64_t n, k, ans;
  cin >> n >> k;
  ans=n+2-k+(n+1)*((n+1)*(n+2)/2-(k-1)*k/2)-(n+1)*(n+2)*(2*n+3)/6+(k-1)*k*(2*k-1)/6;
  ans%=((int)pow(10, 9)+7);
  cout << ans;
  return 0;
}


Measured memory_bytes: 3648
/*  Success may not come to me immediately,
 *  but it will come definitely....
 */
#include <bits/stdc++.h>
//=====================================================================
using namespace std;
//=====================================================================
#define opt ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
//=====================================================================
#define li      int64_t
#define ld      double_t
#define ulli    uint64_t
//=====================================================================
#define rep(i,a,b)  for(i=a;i<b;i++)
#define repr(i,a,b) for(i=a;i>b;i--)
#define repi(i,v)   for(i=v.begin();i!=v.end();i++)
#define repir(i,v)  for(i=v.rbegin();i!=v.rend();i++)
#define elif        else if
#define mset(a,b)   memset(a,b,sizeof(a))
#define nl          cout<<'\n'
//=====================================================================
typedef vector<li>       vli;
typedef vector<string>   vstr;
typedef pair<li,li>      pli;
typedef pair<li,pli >    ppli;
typedef pair<li,ppli >   pppli;
typedef vector<pli >     vpl;
typedef vector<ppli >    vppli;
typedef vector<pppli >   vpppli;
//=====================================================================
#define pb  push_back
#define pob pop_back
#define pf  push_front
#define pof pop_front
#define all(v)  v.begin(),v.end()
#define itr iterator
#define rtr reverse_iterator
#define sz  size()
#define lb  lower_bound
#define ub  upper_bound
#define bs  binary_search
#define mp  make_pair
#define F   first
#define S   second
//=====================================================================
#define mod (li)(1e9+7)
#define inf (li)(1e18)
#define MX1 (li)(1e5+5)
#define MX2 (li)(1e6+5)
#define pi  acos(-1)
//=====================================================================
li power(li a,li b){li ans=1;while(b){if(b&1){ans=(ans*a)%mod;}
a=(a*a)%mod;b>>=1;}return ans;}
//=====================================================================
li mmi(li n){return power(n,mod-2);}
//=====================================================================
li two(li n){return (1LL<<n);}
//=====================================================================
void onbit(li &n,li x){n|=two(x);}
//=====================================================================
void offbit(li &n,li x){n&=~two(x);}
//=====================================================================
li cntbit(li n){li res=0;while(n and ++res)n-=n&-n;return res;}
//=====================================================================
li dx[]={-1,0,1,0},dy[]={0,-1,0,1};
//=====================================================================
/*------------------------MAIN CODE BEGINS NOW!------------------------*/

void solve(){
  string s;cin>>s;
  li n=s.length(),i;
  for(i=0;i<n;i+=2){
    if(i%2==0) cout<<s[i];
  }
}

int main(){
  opt
  #ifndef ONLINE_JUDGE
  #endif
  li t=1;
  //cin>>t;
  while(t--){
    solve();
  }
  return 0;
}

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

using namespace std;

typedef long long llint;

int h, w;
char a[110][110];

int main() {
  cin >> h >> w;
  for (int i = 0; i <= h + 1; i++) {
    for (int j = 0; j <= w + 1; j++) {
      a[i][j] = '#';
    }
  }
  for (int i = 1; i <= h; i++) {
    for (int j = 1; j <= w; j++) {
      cin >> a[i][j];
    }
  }

  for (int i = 0; i <= h + 1; i++) {
    for (int j = 0; j <= w + 1; j++) {
      cout << a[i][j];
    }
    cout << endl;
  }

  return 0;
}

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

int main(void)
{
	string str[8];

	while(cin >> str[0]){

		int c[8][8];
		int p[4];
		int count = 0;

		for(int i=1; i<8; i++)
			cin >> str[i];

		for(int i=0; i<8; i++)
		{
			for(int j=0; j<8; j++)
			{
				c[i][j] = atoi(str[i].substr(j,1).c_str());
				if(c[i][j])
				{
					p[count] = i*10 + j;
					count++;
				}
			}
		}

		if( p[0] + 1 == p[1] && p[0] + 10 == p[2] && p[0] + 11 == p[3] )
			cout << "A" << endl;
		else if( p[0] + 10 == p[1] && p[0] + 20 == p[2] && p[0] + 30 == p[3] )
			cout << "B" << endl;
		else if( p[0] + 1 == p[1] && p[0] + 2 == p[2] && p[0] + 3 == p[3] )
			cout << "C" << endl;
		else if( p[0] + 9 == p[1] && p[0] + 10 == p[2] && p[0] + 19 == p[3] )
			cout << "D" << endl;
		else if( p[0] + 1 == p[1] && p[0] + 11 == p[2] && p[0] + 12 == p[3] )
			cout << "E" << endl;
		else if( p[0] + 10 == p[1] && p[0] + 11 == p[2] && p[0] + 21 == p[3] )
			cout << "F" << endl;
		else if( p[0] + 1 == p[1] && p[0] + 9 == p[2] && p[0] + 10 == p[3] )
			cout << "G" << endl;

	}

	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <stdio.h>
#include <cmath>
#include <cfloat>
#include <algorithm>
#include <functional>
#include <numeric>
#include <vector>
using namespace std;

const double PI=acos(-1);

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

    vector<int> l(n, 0);
    for(int i = 0; i < n; i++){
        cin >> l[i];
    }
    sort(l.begin(), l.end());
    int lm = l[n/2-1], um = l[n/2], ans = um - (lm + 1) + 1;
    if(ans < 0) ans = 0;

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#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;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define pb                push_back
#define int               long long
#define M                 1000000007
#define mod                998244353
#define popf              pop_front
#define popb              pop_back
#define fi                first
#define se                second
#define vc                vector
#define pii               pair<int,int>
#define msi               map<string,int>
#define mii               map<int,int>
#define psi               pair<string,int>
#define pis               pair<int,string>
#define piii              pair<int,pii>
#define f(i,a,b)           for(int i=a;i<b;i++)
#define fd(i,a,b)          for(int i=a;i>=b;i--)
float pd(float n, float a) 
{ 
  
    // Side and side length cannot be negative 
    if (a < 0 && n < 0) 
        return -1; 
  
    // diagonal 
    // degree converted to radians 
    return 2 * a * sin((((n - 2) * 180) / (2 * n)) * 3.14159 / 180); 
} 
      signed main() {
    
           int t=1;
          //cin>>t;
           while(t--)
           {
                   
                        int n,k,w,sum=0,mx=-M;
                     int a1=0,b1=0,xx=0;
                     int n0=0,n1=0,n2=0;
                     string s;
                     cin>>k;
                    cin>>s;
                    n=s.length();
                    if(n<=k)cout<<s;
                    else {
                        for(int i=0;i<k;i++)
                        cout<<s[i];
                        cout<<"...";
                    }



} 



    } 

Measured memory_bytes: 3724
n,m,l=map(int,input().split())
C=[list(map(int,input().split())) for _ in range(n)]
B=[list(map(int,input().split())) for _ in range(m)]

a=[[0]*l for i in range(n)]


for i in range(n):
    for j in range(l):
        for k in range(m):
            a[i][j]+=C[i][k]*B[k][j]

for q in range(n):
    print('%d'%a[q][0],end='')
    for p in range(1,l):
        print(' %d'%(a[q][p]),end='')
    print('')


Measured memory_bytes: 7056
#include <iostream>
#include<vector>
#include<climits>
#include<algorithm>
#include<functional>
#include <numeric>
using namespace std;
using ll = long long;
int main(){
  ll N,M;
  vector<ll> X,X_sub;
  cin>>N>>M;
  for(int i=0;i<M;++i){
    ll tmp;
    cin>>tmp;
    X.push_back(tmp);
  }
  sort(X.begin(),X.end());
  //cout<<X[0];
  for(int i=0;i<M-1;++i){
    X_sub.push_back(X[i+1]-X[i]);
  }
  sort(X_sub.begin(),X_sub.end());
  if(M<=N){
    cout<<0<<endl;
    return 0;
  }
  ll sum=X.back()-X[0]-accumulate(X_sub.end()-(N-1),X_sub.end(),0);
  cout<<sum<<endl;
  return 0;
}

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

int main(){
    i64 n,k,ans=0;
    cin>>n>>k;
    vector<i64> h(n);
    for(int i=0;i<n;i++) cin>>h[i];
    sort(h.begin(),h.end(), greater<int>());
    for(int i=k;i<n;i++){
        ans+=h[i];
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1792
#include<iostream>
using namespace std;
int t=1, n, M[100][100], color[100], d[100], f[100];
void dfs(int u){
	color[u]=1;
	d[u]=t;
	t++;
	for(int v=0; v<n; v++){
		if(M[u][v]==1 && color[v]==0){
			dfs(v);
		}
	}
	color[u]=2;
	f[u]=t;
	t++;
}
int main(){
	cin>>n;
	for(int i=0; i<n; i++){
		color[i]=0;
		d[i]=0;
		f[i]=0;
		for(int j=0; j<n; j++){
			M[i][j]=0;

		}
	}
	for(int i=0; i<n; i++){
		int u, k, child;
		cin>>u>>k;
		for(int j=0; j<k; j++){
			cin>>child;
			M[u-1][child-1]=1;
		}
	}
	for(int i=0; i<n; i++){
		if(color[i]==0)
			dfs(i);
	}
	for(int i=0; i<n; i++)
		cout<<i+1<<" "<<d[i]<<" "<<f[i]<<endl;
	return 0;
}


Measured memory_bytes: 3128
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,x,counter_odd = 0,counter_four = 0,counter_two = 0;
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> x;
        if(x%2==1)counter_odd++;
        else if(x%4==0)counter_four++;
        else if(x%2==0)counter_two++;
    }
    if(counter_two!=0)counter_odd++;
    if(counter_odd-2>=counter_four)cout << "No";
    else cout << "Yes";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
using namespace std;
int main(){
  int a,b;
  cin>>a>>b;
  if(a<10&&b<10){
    cout<<a*b<<endl;
  }
  else{
    cout<<-1<<endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
from collections import deque

n, k = map(int, input().split())
a = list(map(int, input().split()))
queue = deque()
for i in range(n):
    if i <= k - 1:
        queue.append(a[i])
    elif i >= k:
        x = queue.popleft()
        if x < a[i]:
            print("Yes")
        else:
            print("No")
        queue.append(a[i])


Measured memory_bytes: 32396
N,K = map(int,input().split())
A = list(map(int,input().split()))
visited = []
search = set()
now = 1#最初の街にいる
next_town = A[now-1]
count = 1
while(count<=N):
    if next_town in search:#もし次の街が訪れたことがある場合
        break#ループするので抜け出す
    visited.append(now)#今いる街は訪れたこととなるので記録する
    search.add(now)
    next_town = A[now-1]#次に行く街を探す
    now = next_town#次の街に着いたこととして変数を代入
    count += 1

first_roop_city = A[visited[-1]-1]#最初にループした街
first_roop_city_index = visited.index(first_roop_city)#何回目のテレポートにループが始まったか
if K < len(visited):
    print(visited[K])
else:
    visited = visited[first_roop_city_index:]
    L = len(visited)
    print(visited[(K-first_roop_city_index)%L])

Measured memory_bytes: 32456
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>
#include <bitset>
#include <iomanip>
#include <cassert>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'
#define debugArrayP(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i].first<< " " << x[i].second << '\n'

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = INT_MAX;
const ll MOD = 1e9+7;

int main(){
  int N;cin>>N;
  set<int> S;
  repeat(i,N){
    int a;cin>>a;
    if(S.find(a)==S.end()){
      S.insert(a);
    }else{
      S.erase(a);
    }
  }
  cout << S.size()<<endl;
  return 0;
}


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

typedef long long int lli;
const lli mod = 1000000007L;
int main() {
  int n; cin >>n;
  vector<string> add_chs;
  add_chs.push_back("A");
  add_chs.push_back("C");
  add_chs.push_back("G");
  add_chs.push_back("T");
  map<string, lli> memo;
  memo[""] = 1;
  for (int i=0; i < n; i++) {
    map<string, lli> new_memo;
    for (auto it = memo.begin(); it != memo.end(); it++) {
      string tmp = it->first;
      lli num = it->second;

      for (int j = 0; j < add_chs.size(); j++) {
        string next = tmp + add_chs[j];
        if (next.size() == 3 && next == "AGC") {
          continue;
        }
        if (next.size() == 3) {
          if (next[2] == 'C') {
            if (next[0] == 'A' && next[1] == 'G') { continue; }
            if (next[0] == 'G' && next[1] == 'A') { continue; }
          }
          if (next[2] == 'G' && next[0] == 'A' && next[1] == 'C') {continue;}
        }
        if (next.size() == 4) {
          if (next[3] == 'C') {
            if (next[1] == 'A' && next[2] == 'G') { continue; }
            if (next[0] == 'A' && next[2] == 'G') { continue; }
            if (next[1] == 'G' && next[2] == 'A') { continue; }
            if (next[0] == 'A' && next[1] == 'G') { continue; }
          }
          if (next[3] == 'G' && next[1] == 'A' && next[2] == 'C') {continue;}
        }
        if (next.size() == 4) {
          next = next.substr(1, 3);
        }
        if (new_memo.find(next) == new_memo.end()) {
          new_memo[next] = 0;
        }
        new_memo[next] = (new_memo[next] + num) % mod;
      }
    }
    memo = new_memo;
  }

  lli ans = 0;
  for (auto it = memo.begin(); it != memo.end(); it++) {
    ans = (ans + it->second) % mod;
  }

  cout << ans << endl;
  return 0;
}

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

struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* cpp template {{{ */

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define X real()
#define Y imag()

/* REPmacro */
#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define rep(i, n) REPS(i, 0, n)
#define REP0(i,n) for (ll i = 0; i <= (ll)(n); ++i)
#define REP1(i,n) for (ll i = 1; i <= (ll)(n); ++i)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)
#define EACH(i, n) for (auto&& i : n)

/* debug */
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

/* alias */
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using D = double;
using P = complex<D>;
using vs = vector<string>;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; cin >> x; return x;}
inline ll IN() {ll x; cin >> x; return x;}
inline vs split(const string& t, char c) {vs v; stringstream s(t); string b; while(getline(s, b, c)) v.eb(b); return v;}
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
template <typename T, typename S> inline void print(const pair<T, S>& p) {cout << p.first << " " << p.second << endl;}
template <typename T> inline void print(const T& x) {cout << x << '\n';}
template <typename T, typename S> inline void print(const vector<pair<T, S>>& v) {for (auto&& p : v) print(p);}
template <typename T> inline void print(const vector<T>& v, string s = " ") {rep(i, v.size()) cout << v[i] << (i != (ll)v.size() - 1 ? s : "\n");}


signed main() 
{
  int a,b,k; cin>>a>>b>>k;
  for(int i=a;i<=b;++i)
  {
    if(i<a+k) print(i);
    else if(b-k<i) print(i);
  }

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
const ll inf = 1e16;
const ll md = 1000000007;

int n;
vi to[100005];
ll dist[100005];

void dfs0(int u = 0, int pu = -1, int d = 0) {
  dist[u] = d;
  for (int cu : to[u]) {
    if (cu == pu) continue;
    dfs0(cu, u, d + 1);
  }
}

int dfs1(int u, int pu = -1, int d = 0) {
  int res = 0;
  if (d < dist[u]) res++;
  for (int cu : to[u]) {
    if (cu == pu) continue;
    res += dfs1(cu, u, d + 1);
  }
  return res;
}

int main() {
  cin >> n;
  rep(i, n - 1) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    to[a].push_back(b);
    to[b].push_back(a);
  }
  dfs0();
  int s_score = dfs1(n - 1);
  int f_score=n-s_score;
  if (f_score>s_score) puts("Fennec");
  else puts("Snuke");
  return 0;
}

Measured memory_bytes: 12800
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repf(i, j, n) for (int i = (j); i < (n); i++)
#define repr(i, n) for (int i = (n)-1; i >= 0; i--)

signed main() {
  string s;
  cin >> s;

  if (s[0] == s[1] || s[1] == s[2] || s[2] == s[3])
    cout << "Bad" << endl;
  else
    cout << "Good" << endl;
}

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

#define max(x,y) (x>y?x:y)
#define min(x,y) (x<y?x:y)
#define abs(x) (x>0?x:-(x))

int main()
{
	int r, D;
	int num = 0;

	scanf("%d%d%d", &r, &D,&num);

	for (int i = 0; i < 10; i++)
	{
		num = r * num - D;
		printf("%d\n", num);
	}
}

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

int main() {
  int N,Z=0,A=0,B=0;
  cin>>N;
  if(N>23){
    cout<<"0"<<endl;
  }
  else{
    vector<int> p(13);
    p.at(0)++;
    for(int i=0;i<N;i++){
      int b;
      cin>>b;
      p.at(b)++;
    }
    vector<int> iti;
    vector<int> t;
    for(int i=0;i<13;i++){
      if(p.at(i)==1){
        iti.push_back(i);
        B++;
      }
      else if(p.at(i)==2){
        t.push_back(i);
        t.push_back(24-i);
      }
      else if(p.at(i)>2){
        A++;
        break;
      }
    }
    if(A==1){
      cout<<"0"<<endl;
    }
    else{
    for(int j=0;j<(1<<B);j++){
      vector<int> q(N+1);
      for(int i=0;i<B;i++){
        if(j&(1<<i)){
          q.at(i)=iti.at(i);
        }
        else{
          q.at(i)=24-iti.at(i);
        }
      }
      for(int i=B;i<=N;i++){
        q.at(i)=t.at(i-B);
      }
      sort(q.begin(),q.end());
      int a=min(24+q.at(0)-q.at(N),q.at(N)-q.at(0));
      for(int i=0;i<q.size()-1;i++){
        a=min(a,q.at(i+1)-q.at(i));
      }
      Z=max(Z,a);
    }
    cout<<Z<<endl;
    }
  }
}

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

int main(){
    ll n;
    cin >> n;
    ll ans = n / 3;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
#define int long
signed main() {
	int n, k, res = 0;
	cin >> n >> k;
	vector<vector<int>> bboard(2 * k + 1, vector<int>(2 * k + 1, 0));
	vector<vector<int>> wboard(2 * k + 1, vector<int>(2 * k + 1, 0));
	for (int i = 0; i < n; ++i) {
		int x, y;
		char c;
		cin >> x >> y >> c;
		if (c == 'B')bboard[x % (2 * k)][y % (2 * k)]++;
		if (c == 'W')wboard[x % (2 * k)][y % (2 * k)]++;
	}
	for (int i = 0; i <= 2 * k; ++i) for (int j = 1; j <= 2 * k; ++j) bboard[j][i] += bboard[j - 1][i], wboard[j][i] += wboard[j - 1][i];
	for (int i = 0; i <= 2 * k; ++i) for (int j = 1; j <= 2 * k; ++j) bboard[i][j] += bboard[i][j - 1], wboard[i][j] += wboard[i][j - 1];
	auto f = [](vector<vector<int>> & board, int x1, int y1, int x2, int y2) {
		return board[x2][y2] - (x1 ? board[x1 - 1][y2] : 0) - (y1 ? board[x2][y1 - 1] : 0) + (x1 && y1 ? board[x1 - 1][y1 - 1] : 0);
	};
	for (int x = 0; x < k; ++x)for (int y = 0; y < k; ++y) {
		int cnt = 0;
		cnt += f(bboard, x, y, x + k - 1, y + k - 1);
		cnt += f(bboard, x + k, y + k, 2 * k - 1, 2 * k - 1);
		cnt += (x && y ? f(bboard, 0, 0, x - 1, y - 1) : 0);
		cnt += (x ? f(bboard, 0, y + k, x - 1, 2 * k - 1) : 0);
		cnt += (y ? f(bboard, x + k, 0, 2 * k, y - 1) : 0);

		cnt += (y ? f(wboard, x, 0, x + k - 1, y - 1) : 0);
		cnt += (x ? f(wboard, 0, y, x - 1, y + k - 1) : 0);
		cnt += f(wboard, x, y + k, x + k - 1, 2 * k - 1);
		cnt += f(wboard, x + k, y, 2 * k - 1, y + k - 1);
		res = max(res, max(abs(cnt), n - abs(cnt)));
	}
	cout << res;
};

Measured memory_bytes: 62976
#include <iostream>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
using pii = pair<int, int>;
using pll = pair<LL, LL>;


int main()
{
    cin.sync_with_stdio(0);

    char chr;
    cin >> chr;

    cout << (chr >= 'a' ? "a" : "A");
}

Measured memory_bytes: 3668
#ONE TRUTH PREVAILS
import sys
K,N=map(int,input().split())
L=list(map(int,input().split()))
diff=float("inf")
ans=0
mi=float("inf")
for i in range(-200,200):
    if i not in L:
        diff=abs(i-K)
        if diff<mi:
            mi=diff
            ans=i
print(ans)

Measured memory_bytes: 61712
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define INF 1000000000
#define LLINF 10000000000000000ll
#define MOD 1000000007

bool dbgflag = false;

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

  int k;
  string s;
  cin >> k >> s;

  if (k >= s.size()) cout << s << endl;
  else {
    for (int i = 0; i < k; i++) {
      cout << s[i];
    }
    cout << "..." << endl;
  }
} 


Measured memory_bytes: 3648
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
//#include <stdlib.h>

int main(void){
	int n, x;
	int i, j, l;
	int count = 0;

	while (1) {
		scanf("%d %d", &n, &x);
		if (n == 0 && x == 0)
			break;

		count = 0;

		for (i = 1; i <= n; i++) {
			for (j = i + 1; j <= n; j++) {
				for (l = j + 1; l <= n; l++) {
					if (i + j + l == x)
						count++;
				}
			}
		}

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

	}

	

	//system("pause");
	
	return 0;
}


Measured memory_bytes: 2052
#include <bits/stdc++.h>
#define xx first
#define yy second
#define mp make_pair
#define pb push_back
#define fill( x, y ) memset( x, y, sizeof x )
#define copy( x, y ) memcpy( x, y, sizeof x )
using namespace std;

typedef long long LL;
typedef pair < int, int > pa;

inline int read()
{
	int sc = 0, f = 1; char ch = getchar();
	while( ch < '0' || ch > '9' ) { if( ch == '-' ) f = -1; ch = getchar(); }
	while( ch >= '0' && ch <= '9' ) sc = sc * 10 + ch - '0', ch = getchar();
	return sc * f;
}

LL A, B, T = 1LL << 59, C, ans;

int main()
{
#ifdef wxh010910
	freopen( "data.in", "r", stdin );
#endif
	cin >> A >> B;
	if( A == B ) return puts( "1" ), 0;
	while( ( A & T ) == ( B & T ) ) T >>= 1;
	A &= ( T - 1 ); B &= ( T - 1 );
	for( LL k = 1 ; k < T ; k <<= 1 ) if( B & k ) C = k;
	if( C ) C = ( C << 1 ) - 1;
	ans = T + C - A + 1;
	ans += ( T << 1 ) - 1 - max( T + A, T + C + 1 ) + 1;
	cout << ans << endl;
}


Measured memory_bytes: 256
n, m, x = map(int, input().split())
c = [list(map(int, input().split())) for i in range(n)]

ans = 10**7
for i in range(1, 2**n):
    temp = [0] * (m+1)
    for j in range(n):
        if (i >> j) & 1:
            for k, v in enumerate(c[j]):
                temp[k] += v
    if min(temp[1:]) >= x:
        ans = min(temp[0], ans)

print(ans if ans != 10**7 else -1)

Measured memory_bytes: 68528
import java.util.*;

public class Main {
    static Scanner scanner = new Scanner(System.in);

    public static void main(String[]$) {
        long n = scanner.nextInt() - 2, a = scanner.nextInt(), b = scanner.nextInt();
        System.out.println(a == b ? 1 : n == -1 || a > b ? 0 : n * (b - a) + 1);
    }
}

Measured memory_bytes: 21204
n = int(input().strip())
p = [ list(map(int, input().split())) for i in range(n) ]
p.insert(0, [0,0,0])

def check(n,p):
    for i in range(n):
        time = p[i+1][0] - p[i][0]
        dist = sum(p[i+1][1:]) - sum(p[i][1:])

        if time % 2 == 0 and dist % 2 == 0 or time % 2 == 1 and dist % 2 == 1:
            if -(time) <= dist <= time:
                pass
            else:
                return ans(1)
        else:
            return ans(1)

    return ans(0)

def ans(num):
    if num == 1: print("No")
    else: print("Yes")

check(n,p)

Measured memory_bytes: 27380
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <iterator>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>

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

static constexpr ull MOD = 1000000007;
static constexpr double pi = 3.14159265359;

int main() {
    int N;
    cin >> N;
    using T = tuple<int, int, int>;

    vector<T> V;
    for (int i = 0; i < N; ++i) {
        int x, y, h;
        cin >> x >> y >> h;
        V.push_back({x, y, h});
    }
    map<P, vector<int>> Hs;
    for (int cx = 0; cx <= 100; ++cx) {
        for (int cy = 0; cy <= 100; ++cy) {
            int ub = 2000000000;
            set<int> chk;
            for (int i = 0; i < N; ++i) {
                int x = get<0>(V[i]);
                int y = get<1>(V[i]);
                int h = get<2>(V[i]);
                int tmp = abs(x - cx) + abs(y - cy);
                if (h == 0) {
                    ub = min(ub, tmp);
                } else {
                    chk.insert(h + tmp);
                    if (chk.size() > 1) break;
                }
            }
            if (chk.size() == 1 && *(chk.begin()) <= ub) {
                cout << cx << " " << cy << " " << *(chk.begin()) << endl;
                return 0;
            }
        }
    }
}


Measured memory_bytes: 888
#include <algorithm>
#include <complex>
#include <cstdlib>
#include <ctime>
#include <time.h>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <numeric>
#include <limits>
#include <type_traits>
#include <locale>
#include <omp.h>

using namespace std;
#define SAY_YES cout << "YES" << endl;
#define SAY_Yes cout << "Yes" << endl;
#define SAY_NO cout << "NO" << endl;
#define SAY_No cout << "No" << endl;
#define IFYES(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "YES" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "NO" << endl;  \
    }
#define IFYes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "Yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "No" << endl;  \
    }
#define IFyes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "no" << endl;  \
    }
#define DEBUG_OUTPUT_ARRAY(XXX, ONE)                            \
    for (int i = 0; i < (ONE); i++)                             \
    {                                                           \
        cout << "DEBUG: i = " << i << " -> " << XXX[i] << endl; \
    }
#define DEBUG_OUTPUT_ARRAY2(XXX, ONE, TWO)                             \
    for (int i = 0; i < (ONE); i++)                                    \
    {                                                                  \
        cout << "<<< i = " << i << " >>>" << endl;                     \
        for (int j = 0; j < (TWO); j++)                                \
        {                                                              \
            cout << "DEBUG: j = " << j << " -> " << XXX[i][j] << endl; \
        }                                                              \
    }
#define DEBUG_OUTPUT_ARRAY2_BOX(XXX, ONE, TWO) \
    for (int i = 0; i < (ONE); i++)            \
    {                                          \
        cout << i << "  ";                     \
        for (int j = 0; j < (TWO); j++)        \
        {                                      \
            cout << XXX[i][j] << " ";          \
        }                                      \
        cout << endl;                          \
    }

typedef pair<long long int, long long int> pll;
typedef pair<long long int, pll> lpll;

const long long int mod = 1000000007;
const long long int INF = 1e18;
const long double PI=3.14159265358979323; 
//const long long int pl=1000000;

long long int H,W,N,C,K,a[200020],sum[200200]={},now=INF,t=0,bus=0;

int main(){
    cout << fixed << setprecision(18);
    cin>>H>>W>>N;
    cout<<(N+max(H,W)-1)/(max(H,W))<<endl;
}



Measured memory_bytes: 3596
#!/usr/bin/ruby

def solve(_, ls)
  max = -1
  sum = 0
  ls.each do |l|
    sum += l
    if l > max
      max = l
    end
  end
  sum -= max
  if max < sum
    "Yes"
  else
    "No"
  end
end

def each_case(sin)
  while ln = sin.gets
    n = ln.chomp.to_i
    ls = sin.gets.chomp.split(" ").map(&:to_i)
    yield n, ls
  end
end

each_case(STDIN) do |n, ls|
  puts solve(n, ls)
end




Measured memory_bytes: 1788
#ifdef LOCAL
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
#else
#include <bits/stdc++.h>
#endif
using namespace std ;

typedef long long ll ;
#define rep(i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

/*
__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}
*/

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

	string s;
	
	cin >> s;
	bool fail = false;

	for (int i = 0; i < s.size(); i++)
	{
		if ((i+1) % 2)
		{
			if ((s[i] == 'R') || (s[i] == 'U') || (s[i] == 'D') )
			{
				continue;
			}
			else
			{
				//cout << "No" << endl;
				fail = true;
				break;
			}
		}
		else
		{
			if ((s[i] == 'L') || (s[i] == 'U') || (s[i] == 'D') )
			{
				continue;
			}
			else
			{
				//cout << "No" << endl;
				fail = true;
				break;
			}
		}
		
	}

	if (fail)
	{
		cout << "No" << endl;
	}
	else
	{
		cout << "Yes" << endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdlib>
const int maxn = 210;
using namespace std;


int m,n;
int d[15][15],maze[maxn][maxn];

void floy(){
    for(int k = 0 ; k < 10 ; k++){
        for(int i = 0 ; i < 10 ; i++){
            for(int j = 0 ; j < 10 ; j++){
                d[i][j] = min(d[i][j],d[i][k] + d[k][j]);
            }
        }
    }
}

int main(){
    while(~scanf("%d%d",&n,&m)){
        for(int i = 0 ; i < 10 ; i++){
            for(int j = 0 ; j < 10 ; j++){
                scanf("%d",&d[i][j]);
            }
        }
        for(int i = 1 ; i <= n ; i++){
            for(int j = 1 ; j <= m ; j++){
                scanf("%d",&maze[i][j]);
            }
        }
        int sum = 0;
        floy();
        for(int i = 1 ; i <= n ; i++){
            for(int j = 1 ; j <= m ; j++){
                if(maze[i][j] != -1){
                    sum += d[maze[i][j]][1];
                }
            }
        }
        printf("%d\n",sum);
    }
    return 0;
}


Measured memory_bytes: 384
S = input()

if len(S) == 26:
    tmp = S[:-1]
    f = True
    removed = [S[-1]]
    while len(tmp) > 0:
        removed.sort()
        for r in removed:
            if tmp[-1] < r:
                print(tmp[:-1] + r)
                exit()
        removed.append(tmp[-1])
        tmp = tmp[:-1]


alphabet = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k",
            "l", "m", "n", "o", "p", "q", "r", "s", "t", "u",
            "v", "w", "x", "y", "z"]
words = set(alphabet)
input_words = set()

for s in S:
    input_words.add(s)

margin_word = words - input_words
margin_word = list(margin_word)
margin_word.sort()

if len(margin_word) == 0:
    print(-1)
else:
    print(S + margin_word[0])

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<int> VI;
typedef vector<VI> VVI;
const ll MOD = 1000000007;
const ll INF = 1000000007;
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

int main() {
	int n; cin >> n;
	VI a(n); REP(i, n)cin >> a[i];
	int c = 1;
	REP(i, n) if (a[i] == c) c++;
	if (c == 1)
		cout << -1;
	else
		cout << n - c + 1;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <cassert>
using namespace std;

int main(){
	long long N, M;
	cin >> N >> M;
	
	vector<long long> A(N);
	for(int i = 0 ; i < N ; i++) cin >> A[i];
	
	long long lcm = 1;
	for(long long a : A ){
		lcm = a / __gcd(lcm, a) * lcm; 
		if( lcm > 1e10 ){
			cout << 0 << endl;
			return 0;
		}
	}
	
	
	for( auto a : A ){
		if(lcm/a %2==0){
		cout << 0 <<endl;
			return 0;
		}
	}
	
	if( M <	lcm / 2 ) {
		cout << 0 << endl;
		return 0;
	}
	assert(lcm%2==0);
	cout << (M - lcm / 2) / lcm + 1 << endl;
    return 0;
}

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

using namespace std;

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

    int ans = 0;
    for (int i = 0; i < s.size() / 2; i++)
        ans += (s[i] != s[s.size() - i - 1]);

    cout << ans;

    return 0;
}

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

typedef long long ll;

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

    bool ok,ushi=false;
    string s,t;
    cin >> s >> t;
    string uku = s,ans="zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz";
    int size1 = s.size();
    int size2 = t.size();
    for(int i=0;i<size1-size2+1;i++){
        s = uku;
        ok = true;
        for(int j=0;j<size2;j++){
            if(s[i+j]==t[j]) continue;
            else if(s[i+j]=='?') s[i+j] = t[j];
            else{
                ok = false;
                break;
            }
        }
        if(ok){
            ushi = true;
            for(int i=0;i<size1;i++){
                if(s[i]=='?') s[i] = 'a';
            }
            ans = min(ans,s);
        }
    }
    if(ushi) cout << ans << endl;
    else cout << "UNRESTORABLE" << endl;
    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <ccomplex>
#include <unordered_map>
#include <cstring>


using namespace std;
#define MAX 100000

int main(){
    char S[1005];
    int W;
    char ans[1005];

    scanf("%s%d", S, &W);
    int cnt = 0;
    for (int i = 0; i < strlen(S); i += W){
        ans[cnt] = S[i];
        cnt++;
    }
    ans[cnt] = '\0';
    printf("%s", ans);

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
// #include <atcoder/all>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define inrange(a, x, b) (a <= x && x <= b)
#define len(x) ((long long)(x).size())
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
// using namespace atcoder;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using vc = vector<char>;
using pll = pair<ll, ll>;
template<class T> void print(T x,bool cl=1){cout<<(cl?"\x1b[36m":"")<<x<<(cl?"\x1b[39m":"")<<'\n';}
template<class T> void print1d(T x,ll n=-1,bool cl=true){if(n==-1)n=x.size();rep(i,0,n){cout<<(cl?"\x1b[36m":"")<<x[i]<<(i==n-1?'\n':' ');}cout<<(cl?"\x1b[39m":"");}
template<class T> void print2d(T x,ll r=-1,ll c=-1,bool cl=1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c,cl);}
template<class T, class U> bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U> bool isin(T el, U container) { return find(all(container), el) != container.end(); }
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; }
template<class T> bool even(T n) { return ! (n & 1); }
template<class T> bool odd(T n) { return n & 1; }
template<class T> ll rup(T a, T b) { return a % b ? a / b + 1 : a / b; }
template<class T> ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T> ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;
ll intpow(ll a, ll n, ll _mod=numeric_limits<ll>::max()) { ll p=1; while (n) { if (n&1) p=p*a%_mod; a=a*a%_mod; n>>=1; } return p; } 
ll modc(ll a, char op, ll b, ll _mod=mod)
{
        a %= _mod; b %= _mod; ll res = 1;
        switch (op) {
        case '+': res = (a + b) % _mod; break;
        case '-': res = (a - b) % _mod; break;
        case '*': res = a * b % _mod; break;
        case '/': res = modc(a, '*', modc(b, '^', _mod-2, _mod), _mod); break;
        case '^': res = intpow(a, b, _mod); break;
        case 'P': rep(i, a-b+1, a+1) res = modc(res, '*', i, _mod); break;
        case 'C': res = modc(modc(a, 'P', b, _mod), '/', modc(b, 'P', b, _mod)); break;
        } 
        if (res < 0) { res += _mod; } return res;
}



int main()
{
        ll N, A, B;
        cin >> N >> A >> B;
        if (even(B - A)) {
                cout << "Alice" << endl;
        } else {
                cout << "Borys" << endl;
        }
        cerr << 'x' << endl;
}


Measured memory_bytes: 3644
# include <bits/stdc++.h>
using namespace std;
const int N = 1000;
int a[N] , b[N] , c[N] , res; 
int main(){
	int n;
	cin >> n;
	for(int i = 1; i <= n; i ++) cin >> a[i];
	for(int j = 1; j <= n; j ++) cin >> b[j];
	for(int j = 1; j < n; j ++) cin >> c[j];
	for(int i = 1; i <= n; i ++){
		res += b[a[i]];
		if(a[i] == a[i - 1] + 1) res += c[a[i] - 1];
	}
	cout << res << "\n";
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define REP1(i,n) for(int i=1; i<=(int)(n); i++)
#define SORT(v) sort(v.begin(), v.end())
#define REVERSE(v)  reverse(v.begin(), v.end())
using namespace std;

int main() {
  int N,T; cin>>N>>T;
  vector<int> c(N),t(N);
  REP(i,N) cin>>c[i]>>t[i];

  int ans = 10000;
  REP(i,N) {
    if(t[i] > T) continue;
    else ans = min(ans, c[i]);
  }

  if(ans <= 1000) cout<<ans<<endl;
  else cout<<"TLE"<<endl;
}

Measured memory_bytes: 256
/////////////////////////////////////////////////
//                                             //
//                 _ooOoo_                     //
//                o8888888o                    //
//                88" . "88                    //
//                (| -_- |)                    //
//             ____/`---'\\____                //
//           .'  \|     |//  `.                //
//           /  \|||  :  |||// \               //
//          /  _||||| -:- |||||- \             //
//          |   | \\  -  /// |   |             //
//          | \_|  ''\---/''  |  |             //
//          \  .-\__  `-`  ___/-. /            //
//         ___`. .'  /--.--\  `. . __          //
//      ."" '<  `.___\_<|>_/___.'  >'"".       //
//     | | :  `- \`.;`\ _ /`;.`/ - ` : | |     //
//     \  \ `-.   \_ __\ /__ _/   .-` /  /     //
//=====`-.____`-.___\_____/___.-`____.-'=======//
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^//
//.............................................//
/////////////////////////////////////////////////

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll modn=998244353;
const ll INF = 0x3f3f3f3f;
int a[100100];
int inva[100100];
int b[100100];
int aa[100100];
int bb[100100];
int n;
int main(){

    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
        aa[i]=a[i];
    }
    for(int i=0;i<n;i++){
        scanf("%d",&b[i]);
        bb[i]=b[i];
    }
    sort(aa,aa+n);
    sort(bb,bb+n);
    int flag = 0;
    for(int i=0;i<n;i++){
           if(aa[i]>bb[i])
            flag = 1;
    }

    if(flag == 1){
        printf("No\n");
        return 0;
    }
    for(int i=1;i<n;i++){
           if(aa[i]<=bb[i-1]  ||aa[i]==aa[i-1] || bb[i]==bb[i-1])
            flag = 1;
    }
    if(flag == 1){
        printf("Yes\n");
        return 0;
    }
    for(int i=0;i<n;i++){
        a[i]=lower_bound(aa,aa+n,a[i])-aa;
        aa[a[i]]--;
        inva[a[i]]=i;
        b[i]=lower_bound(bb,bb+n,b[i])-bb;
        bb[b[i]]--;
    }

    int cnt = 0;
    for(int i=0;i<n;i++){
        if(a[i]==b[i])continue;
        int t = inva[b[i]];
        cnt++;
        swap(a[t],a[i]);
        inva[a[t]]=t;
        inva[a[i]]=i;
    }
    if(cnt <=n-2)flag = 1;

    if(flag == 1)
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}
/*
5
1 2 3 4 5
5 3 2 1 4
*/


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

int main() {
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    int cnt = 0;
    for (int i = 0; i <= 100; i++){
        if (A <= i && i <= B && C <= i && i <= D){
            cnt++;
        }
    }
    cout << max(0, cnt - 1) << endl;
}


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

int main(){
	int x,y;
	while(cin >> x >> y){
		if(x == 0 && y == 0) break;
		int cnt=0;
		if(x < y){
			x^=y;
			y^=x;
			x^=y;
		}
		while(y){
			x %= y;
			if(x < y){
				x^=y;
				y^=x;
				x^=y;

				cnt++;
			}
		}
		cout << x << " " << cnt << endl;
	}
}

Measured memory_bytes: 1160
import java.util.*;
public class Main{
	public static void main(String[] args){
	  Scanner sc = new Scanner(System.in);
	  int n = sc.nextInt();
      int ans = 1;
	  for(int i = 0;i<3;i++)ans*=n;
	  System.out.println(ans);
    }
}

Measured memory_bytes: 21716