akhauriyash/Code-Regression huggingface dataset:
def main():
    n = int(input())
    dss = [list(map(int, input().split())) for _ in range(n)]

    ans = "No"
    Count = 0
    for ds in dss:
        if ds[0] == ds[1]:
            Count += 1
        else:
            Count = 0
        if Count == 3:
            ans = "Yes"

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9020
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPLL(i, n) for (ll i = 0; i < (ll)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int R; cin >> R;
  if(R < 1200){
    cout << "ABC" << endl;
  }else if(R < 2800){
    cout << "ARC" << endl;
  }else{
    cout << "AGC" << endl;
  }
}


Measured memory_bytes: 3580
#include <iostream>
#include <cstdio>

using namespace std;

int main()
{
    int n,k,x,y,s;
    while(scanf("%d%d%d%d",&n,&k,&x,&y)==4)
    {
        s=0;
        if(k<n)
        {
            s=s+x*k;
            s=s+y*(n-k);
        }
        else
        {
            s=s+x*n;
        }
        printf("%d\n",s);
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

int main() {
    int m1, d1, m2, d2;
    cin >> m1 >> d1 >> m2 >> d2;

    if(d2 == 1) {
        cout << 1;
    }
    else {
        cout << 0;
    }

    cout << endl;
    return 0;
}

Measured memory_bytes: 256
let n, d, x = Scanf.scanf " %d %d %d" @@ fun a b c -> a, b, c
let a_s = Array.init n @@ fun _ -> Scanf.scanf " %d" @@ (+) 0
let _ = Array.fold_left (fun c a -> c + 1 + (d - 1) / a) x a_s |> Printf.printf "%d\n"

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

using namespace std;

int main() {
  int n;
  cin >> n;
  int arr[200];
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  int answer = 0;
  while (true) {
    bool all_even = true;
    for (int i = 0; i < n; i++) {
      if (arr[i] % 2 != 0) {
        all_even = false;
        break;
      }
      arr[i] /= 2;
    }
    if (!all_even) {
      break;
    }
    answer++;
  }
  cout << answer << '\n';
  return 0;
}


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

dmap = [list(map(int, input().split())) for _ in range(c)]
cmap = [list(map(int, input().split())) for _ in range(n)]

d1 = {}
d2 = {}
d3 = {}

for i, clist in enumerate(cmap):
  for j, _c in enumerate(clist):
    if (i + j + 2) % 3 == 2:
      if _c-1 in d1:
        d1[_c-1] += 1
      else:
        d1[_c-1] = 1
    elif (i + j + 2) % 3 == 0:
      if _c-1 in d2:
        d2[_c-1] += 1
      else:
        d2[_c-1] = 1
    else:
      if _c-1 in d3:
        d3[_c-1] += 1
      else:
        d3[_c-1] = 1

minc = None
for c1 in range(c):
  for c2 in range(c):
    for c3 in range(c):
      tmp = 0
      if c1 == c2 or c2 == c3 or c3 == c1:
        continue
      for _c, cn in d1.items():
        tmp += dmap[_c][c1] * cn
      for _c, cn in d2.items():
        tmp += dmap[_c][c2] * cn
      for _c, cn in d3.items():
        tmp += dmap[_c][c3] * cn
      if minc is None:
        minc = tmp
      elif minc > tmp:
        minc = tmp

print(minc)


Measured memory_bytes: 5620
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(ll i = (m); i >= (n); i--)
#define ALL(c) (c).begin(), (c).end()
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll h,w;
    cin >> h >> w;
    if (h==1 || w==1)
    {
        cout << 1 << endl;
    }
    else
    {
        cout << (h * w + 1) / 2 << endl;

    }
    
    
}




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

namespace AtCoder2
{
	class Program
	{
		static void Main(string[] args)
		{
			var s = Console.ReadLine();
			var l = s.Length;
			var b = Enumerable.Repeat(1, l).ToArray();

			for (int i = 0; i < l - 2; i++)
			{
				if (s[i] == 'R' && s[i + 1] == 'R')
				{
					b[i + 2] += b[i];
					b[i] = 0;
				}
			}

			for (int i = l - 1; i > 1; i--)
			{
				if (s[i] == 'L' && s[i - 1] == 'L')
				{
					b[i - 2] += b[i];
					b[i] = 0;
				}
			}

			Console.WriteLine(String.Join(' ', b));
		}
	}
}


Measured memory_bytes: 21840
def common_divisor(a, b):
  ans = []
  mn = min(a, b)
  mx = max(a, b)
  for i in range(1, min(a, b) + 1):
    if a % i == 0 and b % i == 0 :
      ans.append(i)
  
  return ans

a, b, c = [int(x) for x in input().split()]
kys = common_divisor(a, b)
print(kys[len(kys) - c])

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

int main(void){
    double x1,y1,x2,y2;
    cin >> x1 >> y1;
    cin >> x2 >> y2;
    double d = pow(x1-x2, 2) + pow(y1-y2, 2);
    cout << fixed << setprecision(5) << sqrt(d);
    cout << endl;
    
}



Measured memory_bytes: 3268
#include<bits/stdc++.h>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<algorithm>
#include<map>
#include<cmath>
#include<complex>
using namespace std;

typedef complex<double> P;

#define X real()
#define Y imag()
typedef int kz;

kz gcd(kz a,kz b) { if(b==0) return a; else gcd(b,a%b); }

int main(){
    //int mod=1000000007;
    int mod=1003199;
    int n;
    for (;;) {
        scanf("%d",&n);
        if (n==0) break;
        int ans=0;
        while (n) {
            n/=5;
            ans+=n;
        }
        printf("%d\n",ans);
    }
    return 0;
}

Measured memory_bytes: 3136
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
using namespace std;
int ans[100005];
int main(){
    int n;
    while(~scanf("%d",&n)){
        int i,x;
        int ma,mi;
        ma=0;
        mi=100005;
        memset(ans,0,sizeof(ans));
        for(i=0;i<n;i++){
            scanf("%d",&x);
            ans[x]++;
            ma=max(ma,x);
            mi=min(mi,x);
        }
        int pos=ans[mi]+ans[mi+1];
        for(i=mi+1;i<ma;i++){
            pos=max(pos,ans[i-1]+ans[i]+ans[i+1]);
        }
        pos=max(pos,ans[ma]+ans[ma-1]);
        printf("%d\n",pos);
    }
return 0;}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ll long long int
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
signed main()
{
    int n;
    cin >> n;
    vector<string> s(n);
    vector<int> p(n);
    rep(i, n) cin >> s[i] >> p[i];

    vector<int> v(n);
    rep(i, n) v[i] = i;
    sort(all(v), [s, p](auto const& lhs, auto const& rhs) {
        if (s[lhs] == s[rhs]) {
            return p[lhs] > p[rhs];
        }
        return s[lhs] < s[rhs];
    });

    rep(i, n) cout << 1 + v[i] << endl;
    
    return 0;
}

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

const ll INF = 1001001001;

const double PI=3.141592653;

const ll sosu = 1000000007;//大きい素数

//提出のときに言語がc＋＋似合っていることを確認する

// lからrまでの和
ll sum(ll l,ll r){
  return ((l+r)*(r-l+1))/2;
}

int main(){
      ll x; cin>>x;
      ll ans1=0;
      ll ans2=0;
      bool flag=true;
      for(ll a=-118;a<=119;a++){
        if(flag==false){
          break;
        }
        for(ll b=-119; b<=118;b++){
          if(a*a*a*a*a-b*b*b*b*b==x){
            ans1=a;
            ans2=b;
            break;
          }
        }
      }
      cout<<ans1<<" "<<ans2<<endl;
    
    return 0;
}       

       

Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <string>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <sstream>
#include <algorithm>
#include <cmath>

using namespace std;

int main()
{
	int N = 0;
	cin >> N;
	vector<int> vctX(N);
	
  for (int i = 0; i < N; ++i) {
		int n = 0;
		cin >> n;
		vctX[i] = n;
	}
	vector<int> sortedX = vctX;
	sort(sortedX.begin(), sortedX.end());
	
	int centLeft = sortedX[N / 2 - 1];
	int centRight = sortedX[N / 2];

  for (const auto& elem : vctX) {
		if (elem <= centLeft) {
			cout << centRight;
		}
		else {
			cout << centLeft;
		}
		cout << endl;
	}
	return 0;
}

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

#define int long long

int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

/*
#define cin ifs
#define cout ofs
ifstream ifs("in.txt");
ofstream ofs("out.txt");
//*/

signed main() {
    int N, M;
    cin >> N >> M;
    if (N == 1 && M == 1) {
        cout << 1 << endl;
        return 0;
    }
    if (N == 1) {
        cout << M - 2 << endl;
        return 0;
    }
    if (M == 1) {
        cout << N - 2 << endl;
        return 0;
    }
    cout << (N - 2) * (M - 2);
    return 0;
}

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

#ifdef LOCAL
#include "dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

#define rep(i, n) for (int i = 0; i < (n); i++)
#define mins(x, y) (x = min(x, y))
#define maxs(x, y) (x = max(x, y))
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using P = pair<int, int>;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

void solve() {
  ll n;
  cin >> n;
  string ans = "";
  ll cnt = 1;
  ll add = 26;
  ll num = 1;
  rep(i, 1000) {
    dump(cnt, add, num, n);
    if (cnt <= n && n < cnt + add) {
      break;
    }
    cnt += add;
    add *= 26;
    num++;
  }
  n -= cnt;
  char buf[1000];
  int x = num - 1;
  rep(i, num) {
    char c = 'a' + (n % 26);
    dump(c);
    buf[x] = c;
    x--;
    n /= 26;
  }
  buf[num] = '\0';
  cout << buf << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  // freopen("temp.1", "r", stdin);
  solve();
  return 0;
}

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

int dp[10010];
int main() {
    int N, W; cin >> N >> W;
    fill(dp + 1, dp + W + 1, -1);
    for(int i=0; i<N; i++) {
        int v, w; cin >> v >> w;
        for(int j=W; j>=w; j--) {
            if(dp[j-w] >= 0) dp[j] = max(dp[j], dp[j-w] + v);
        }
    }
    cout << *max_element(dp, dp + W + 1) << endl;
    return 0;
}


Measured memory_bytes: 3140
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
using namespace std;

int main()
{
    fastio;
    string S;
    cin >> S;
    set<char> ss(S.begin(), S.end());

    for (char ch = 'a'; ch <= 'z'; ++ch)
    {
        if (ss.find(ch) == ss.end())
        {
            cout << ch << endl;
            break;
        }
        if (ch == 'z')
        {
            cout << "None" << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 512
// {{{
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <complex>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define FOR(i, a, b) for(ll i = static_cast<ll>(a); i < static_cast<ll>(b); i++)
#define FORR(i, a, b) for(ll i = static_cast<ll>(a); i >= static_cast<ll>(b); i--)
#define REP(i, n) for(ll i = 0ll; i < static_cast<ll>(n); i++)
#define REPR(i, n) for(ll i = static_cast<ll>(n); i >= 0ll; i--)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> IP;
typedef pair<ll, LP> LLP;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, 1, -1};

constexpr int INF = 100000000;
constexpr ll LINF = 10000000000000000ll;
constexpr int MOD = static_cast<int>(1e9 + 7);
constexpr double EPS = 1e-9;

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

// }}}

ll N, C, x[100000], v[100000];
ll dl[100000], dr[100000];
ll sl[100000], sr[100000];
ll msl[100000], msr[100000];

void solve()
{
    REP(i, N){
        //dr[i] = (i > 0 ? dr[i-1] : 0) + x[i];
        dr[i] = x[i];
        dl[i] = (i > 0 ? dl[i-1] : 0) + (C-x[N-1-i]) - (i > 0 ? (C - x[N-1-i+1]) : 0);
        sr[i] = (i > 0 ? sr[i-1] : 0)
                    + v[i]
                    - (x[i] - (i > 0 ? x[i-1] : 0));
        sl[i] = (i > 0 ? sl[i-1] : 0)
                    + v[N-1-i]
                    - ((C-x[N-1-i]) - (i > 0 ? (C-x[N-1-i+1]) : 0));
    }
    ll ans = 0;
    REP(i, N){
        msr[i] = max((i > 0 ? msr[i-1] : 0), sr[i]);
        msl[i] = max((i > 0 ? msl[i-1] : 0), sl[i]);
        ans = max(ans, max(sr[i], sl[i]));
    }
    REP(i, N-1){
        ans = max(ans, sr[i] - dr[i] + msl[N-1-i-1]);
        ans = max(ans, sl[i] - dl[i] + msr[N-1-i-1]);
    }
    cout << ans << endl;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> C;
    REP(i, N) cin >> x[i] >> v[i];
    solve();
    return 0;
}

// vim:set foldmethod=marker:


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

int main() {
	int n, k, d;
	scanf("%d %d", &n, &k);
	vector<int> a(d);
	vector<int> v(n);
	for(int i = 0; i < k; i++) {
		scanf("%d", &d);
		for(int j = 0; j < d; j++) {
			scanf("%d", &a[j]);
			v[a[j] - 1] += 1;
		}
	}
	int ans = 0;
	for(int i = 0; i < n; i++) {
		if(v[i] == 0) {
			ans++;
		}
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 3852
import java.util.*;
public class Main {
	
	static int MOD = 1_000_000_007;
	static int MAX = 500_000;
	static long[] fac = new long[MAX+1];
	static long[] finv = new long[MAX+1];
	static long[] inv = new long[MAX+1];
	
	static void COMinit() {
		fac[0] = fac[1] = 1;
		finv[0] = finv[1] = 1;
		inv[1] = 1;
		for(int i = 2; i <= MAX; i++) {
			fac[i] = fac[i-1] * i % MOD;
			inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
			finv[i] = finv[i-1] * inv[i] % MOD;
		}
	}
	
	static long cmb(int n, int k){
		if(n < k || k < 0) return 0;
		return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
	}
	
	static long perm(int n, int k) {
		if(n < k || k < 0) return 0;
		return fac[n] * finv[n-k] % MOD;
	}

	public static void main(String[] args) {
		COMinit();
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		long ans = 0;
		for(int i = 0; i <= N; i++)
			ans = (long) ((ans + cmb(N, i) * perm(M, i) % MOD * perm(M-i, N-i) % MOD * perm(M-i, N-i) % MOD * Math.pow(-1, i) + MOD) % MOD);
		System.out.println(ans);
	}

}

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

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

int main() {
    int N, D;
    cin >> N >> D;
    int kansi = 2 * D + 1;

    cout << ((N + kansi - 1) /kansi) << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	Scanner sc = new Scanner(System.in);
	
	public static void main(String[] args) {
		Main m = new Main();
		m.run();
	}
	
	void run() {
		int n = sc.nextInt();
		int k  =sc.nextInt();
		char prev = ' ';
		int init = 0;
		for(char ch : sc.next().toCharArray()) {
			if(ch == prev) {
				init++;
			}
			prev = ch;
		}
		
		System.out.println(Math.min(n-1, init+2*k));
		
	}
}


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

int main(){
  int h, w, a, b; cin >> h >> w >> a >> b;
  a--; b--;
  vector<vector<int>> s(h, vector<int>(w, 0));
  rep(i, h){
    rep(j, w){
      if(i <= b && j <= a) s[i][j] = 1;
      if(i > b && j > a) s[i][j] = 1;
    }
  }

  rep(i, h){
    rep(j, w) cout << s[i][j];
    cout << endl;
  }


  return 0;
}


Measured memory_bytes: 7520
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define INF int(1e9)
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define REPONE(i, n) for(int i = 1; i <= (int)(n); i++)
#define EACH(i, mp) for(auto i:mp)
#define FOR(i, m, n) for(int i = m;i < n;i++)
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

int N, K;
const int MAX_K = 10, MAX_N = 10000;
int D[MAX_K];
bool is_d[MAX_K];


// 1234 -> 4 3 2 1
vector<int> each_digit(int S) {
    int n_len = 0, n_dig[MAX_N];
    while (S > 0) {
        n_dig[n_len++] = S % 10;
        S /= 10;
    }
    vector<int> ret(n_dig, n_dig + n_len);
    return ret;
}

void solve() {
    each_digit(N);
    FOR(n, N, 100 * N) {
        vector<int> dig = each_digit(n);
        bool out = false;
        EACH(d, dig) {
            REP(i, K) {
                if (d == D[i]) {
                    out = true;
                    break;
                }
            }
            if (out) break;
        }
        if (out) continue;
        cout << n << endl;
        return;
    }
}

int main() {
    cin >> N >> K;
    REP(i, K) cin >> D[i];
    solve();
    return 0;
}

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

int main(){
  int n;
  int arr[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
};
  cin>>n;
  cout<<arr[n-1];
  
  
}


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

vector<vector<int> > V;
int vnum = 0;
int e = 0;
int color[10000];
int indeg[10000];


void bfs(int s){
    queue<int> Q;
    Q.push(s);
    color[s] = 1;
    
    while(!Q.empty()){
        int u = Q.front();
        Q.pop();
        
        cout << u << endl;
        
        for(int v = 0; v < V[u].size(); v++){
            indeg[V[u][v]]--;
            if(indeg[V[u][v]] == 0 && color[V[u][v]] == 0){
                color[V[u][v]] = 1;
                Q.push(V[u][v]);
            }
        }
    }
}

void topologicalSort() {
    for(int i = 0; i < vnum; i++) {
        color[i] = 0;
        indeg[i] = 0;
    }
    
    for(int i = 0; i < vnum; i++){
        for(int j = 0; j < V[i].size(); j++){
            indeg[V[i][j]] += 1;
        }
    }
    
    for(int u = 0; u < vnum; u++){
        if(indeg[u] == 0 && color[u] == 0) {
            bfs(u);
        }
    }
}




int main(void){
    // Your code here!
    cin >> vnum >> e;
    V.resize(vnum);
    
    int s, t;
    for(int i = 0; i < e; i++){
        cin >> s >> t;
        V[s].push_back(t);
    }
    
    topologicalSort();
    return 0;
}



Measured memory_bytes: 3588
from collections import Counter
n,m=map(int,input().split())
l=[list(map(int,input().split())) for _ in range(n)]
res = n
for _ in range(m-1):
    tl = [l[i][0] for i in range(n)]
    cmns = Counter(tl).most_common()[0]
    res = min(res,cmns[1])
    for i in range(n):
        l[i].remove(cmns[0])
print(res)

Measured memory_bytes: 45148
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int l[105],d[105];
int main(){
	int n,x,num=0;
	cin>>n>>x;
	for(int i=1;i<=n;i++){
		cin>>l[i];
	}
	for(int i=2;i<=n+1;i++){
		d[i]=d[i-1]+l[i-1];
	}
	for(int i=1;i<=n+1;i++){
		if(d[i]<=x) num++;
	}
	cout<<num<<endl;
}

Measured memory_bytes: 256
#
# File    : B.rb
# Author  : Kazune Takahashi
# Created : 2018-9-8 21:01:53
# Powered by Visual Studio Code
#

n = gets.to_i
w = []
n.times{
  w << gets.chomp
}
dic = {}
dic[w[0]] = true
for i in 0...(n-1)
  if dic[w[i+1]].nil? && w[i][-1] == w[i+1][0]
    dic[w[i+1]] = true
  else
    puts "No"
    exit
  end
end
puts "Yes"


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

int main() {
 
  string c1, c2;
  cin >> c1 >> c2;

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

  if (c1 == c2) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << "\n";
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (int i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
const ll MOD = 10007;

template <typename T>
struct Prim {
    typedef pair<T, int> P;

    int n;
    vll used;
    vector<vector<P>> E; // cost, to

    Prim(int n): n(n), used(n, false), E(n) {};

    void add_edge(int s, int t, T w) {
        // Undirected link
        E[s].eb(w, t);
        E[t].eb(w, s);
    }

    T operator()() {
        used.assign(n, false);

        // {cost, node}
        priority_queue<P, vector<P>, greater<P>> q;
        q.emplace(T(0), 0); // cost, cur

        T ret = T();
        while(!q.empty()) {
            auto p = q.top(); q.pop();
            T cost = p.fi, cur = p.se;

            if (used[cur]) continue;
            used[cur] = true;
            ret += cost;

            for (auto e: E[p.se]) {
                if(used[e.se]) continue;
                q.emplace(e.fi, e.se);
            }
        }

        return ret;
    }
};

struct station {
    double x, y, z, r;
    station(double x, double y, double z, double r) : x(x), y(y), z(z), r(r) {}
};

double p2(double x) {
    return x * x;
}

double dist(station& s1, station& s2) {
    double d = sqrt(p2(s1.x - s2.x) + p2(s1.y - s2.y) + p2(s1.z - s2.z));

    if (d < s1.r + s2.r) return 0;
    return d - s1.r - s2.r;
}


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

    while(1) {
        int n; cin >> n;
        if (n == 0) break;

        vector<station> s;
        REP(i, n) {
            double x, y, z, r;
            cin >> x >> y >> z >> r;
            s.eb(x, y, z, r);
        }

        Prim<double> g(n);

        REP(i, n) REP(j, n) {
            double w = dist(s[i], s[j]);
            g.add_edge(i, j, w);
        }

        print(g());
    }
}


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

int main(){
  int A,B,H,M;
  cin >> A >> B >> H >> M;
  double C=acos(-1)*(60*H+M)/360-acos(-1)*M/30;
  double D=sqrt(A*A+B*B-2*A*B*cos(C));
  cout <<fixed << setprecision(15) << D << endl;
}
  

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

ll ans = 0;
int n, m, q;
vector<int> a, b, c, d;

void dfs(string s, int moji){

    if(moji == n){
        ll anstmp = 0;

        rep(i,q){
            if((s[b[i]] - '0') - (s[a[i]] - '0') == c[i]) anstmp += d[i];
        }

        ans = max(ans, anstmp);
        //cout << s << endl;

        return;
    }


    int simo = s[moji -1] - '0';
    for(int i = simo; i<= m-1; i++){
        string tmp = to_string(i);
        string ns = s + tmp;

        dfs(ns, moji + 1);
    }

    return;

}

int main(){
    cin >> n >> m >> q;
    a.resize(q);
    b.resize(q);
    c.resize(q);
    d.resize(q);

    rep(i,q){
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        a[i]--; b[i]--;
    }

    rep(i,m){
        string s = to_string(i); 
        dfs(s, 1);
    }

    cout << ans << endl;

}



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

using namespace std;



int main()
{
	int n, contador = 1, max_altura;
	
	cin >> n;
	int altura[n];
	
	for ( int i = 0; i < n; ++i ) cin >> altura[i];
	max_altura = altura[0];
	for ( int i = 1; i < n; ++i )
	{
		if ( altura[i] >= max_altura )
		{
			max_altura = altura[i];
			contador++;
		}
	}
	
	cout << contador;
	return 0;
}

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

#define REPI(i, n) for(int i = 0; i < n; i++)
#define REPJ(j, n) for(int j = 0; j < n; j++)

using ll = long long;
using namespace std;

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

    int n; cin >> n;
    int array[n]; REPI(i, n) cin >> array[i];
    int ans = 0, count = 0;

    REPI(i, n - 1){
        if(array[i] >= array[i + 1]) count++;
        else{
            ans = max(ans, count);
            count = 0;
        }
    }cout << max(ans, count);
}


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

using namespace std;

using ll = long long;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

#define input(...) __VA_ARGS__; in(__VA_ARGS__)

template<class T>
void print(vector<T> a) {
  cout << "[ ";
  REP(i, a.size()) cout << a[i] << " ";
  cout << "]" << endl;
}

void print() {
  std::cout << std::endl;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  std::cout << head << " ";
  print(std::forward<Tail>(tail)...);
}

void in() { }

template <class Head, class... Tail>
void in(Head&& head, Tail&&... tail) {
  cin >> head;
  in(std::forward<Tail>(tail)...);
}

vector<vector<ll>> table(100 + 1, vector<ll>(10000 + 1, -1));
ll N, W;
vector<ll> v, w;
ll dfs(ll i, ll weight) {
  if (i == N) return 0;
  if (table[i][weight] != -1) return table[i][weight];

  if (weight + w[i] <= W) {
    return table[i][weight] = max(dfs(i + 1, weight), dfs(i, weight + w[i]) + v[i]);
  } else {
    return table[i][weight] = dfs(i + 1, weight);
  }
}

int main() {
  ll input(n, bag);
  v = vector<ll>(n);
  w = vector<ll>(n);
  REP(i, n) cin >> v[i] >> w[i];
  N = n;
  W = bag;

  cout << dfs(0, 0) << endl;
}



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

#define DIV 998244353

using namespace std;
using ll = long long;
using ldb = long double;

int main() {
    int N; cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++) cin >> A[i];

    map<ll, ll> L, R;
    for (int i = 0; i < N; i++) {
        L[i + A[i]]++;
        R[i - A[i]]++;
    }
    ll cnt = 0;
    for (auto x : L) {
        cnt += x.second * R[x.first];
    }
    cout << cnt << endl;
}


Measured memory_bytes: 38156
#include<iostream>
#include<vector>
#include<cmath>
#include<string>
#include<bitset>
#include <sstream>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
int main()
{
    int a,b;
    cin>>a>>b;
    cout<<(a-1)*(b-1)<<endl;
}

Measured memory_bytes: 256
L, R = map(int, input().split())

# max_loop = 2019 * 2 + 1
max_loop = 2019 ** 2
count = 0
ans = 2019
for i in range(L, R + 1):
    for j in range(i + 1, R + 1):
        x = (i * j) % 2019
        ans = min(ans, x)
        if ans == 0:
            print(0)
            exit()
print(ans)


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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};

// Problem Specific Parameter:

ll a[200010],b[200010];

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

	rep(i,n) cin >> a[i] >> b[i];

	ll ans = 0LL,total = 0LL;
	rep(i,n) total += b[i];
		
	rep(i,n){
		if(a[i] > b[i]){
			chmax(ans, total - b[i]);
		}
	}

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

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

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define forin(in) for(int i=0; i<(int)in.size(); i++) cin>>in[i]
#define forout(out) for(int i=0; i<(int)out.size(); i++) cout<<out[i]<<endl
#define rep(i, n) for(int i=0; i<(n); i++)
int main(){
    int d, t, s; cin>> d >> t >> s;
    if(d > t*s) cout<< "No" << endl;
    else cout << "Yes" << endl;
}


Measured memory_bytes: 3632
#include <iostream>
#include <map>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

long long gcd(long long a, long long b)
{
	return b == 0 ? a : gcd(b, a % b);
}

struct rational
{
	rational(long long n, long long d) {
		if (n == 0 && d == 0) {
			num = 0;
			den = 0;
		}
		else if (n == 0) {
			num = 0;
			den = 1;
		}
		else if (d == 0) {
			num = 1;
			den = 0;
		}
		else {
			if (d < 0) {
				n *= -1;
				d *= -1;
			}
			long long g = gcd(abs(n), abs(d));
			num = n / g;
			den = d / g;
		}
	}

	bool operator<(const rational& other) const {
		return tie(num, den) < tie(other.num, other.den);
	}

	long long num;
	long long den;
};

const int MOD = 1000000007;

int addm(int a, int b)
{
	return (0LL + a + b) % MOD;
}

int subm(int a, int b)
{
	return addm(a, MOD - b);
}

int mulm(int a, int b)
{
	return (1LL * a * b) % MOD;
}

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

	vector<int> pow2(N + 1);
	pow2[0] = 1;
	for (int i = 1; i <= N; ++i) {
		pow2[i] = mulm(2, pow2[i - 1]);
	}

	map<rational, int> m;
	set<rational> used;

	for (int i = 0; i < N; ++i) {
		long long A, B;
		cin >> A >> B;
		rational r(A, B);
		++m[r];
	}

	int ans = 1;
	for (const auto& e : m) {
		rational r1 = e.first;
		rational r2(0, 0);
		int c1 = e.second;
		int c2;

		if (r1.num == 0 && r1.den == 0) {
			continue;
		}
		
		r2 = rational(-r1.den, r1.num);

		used.insert(r1);
		if (used.count(r2)) {
			continue;
		}
		if (m.count(r2) == 0) {
			c2 = 0;
		}
		else {
			c2 = m.at(r2);
		}
		int tmp = 0;
		tmp = addm(tmp, pow2[c1]);
		tmp = addm(tmp, pow2[c2]);
		tmp = subm(tmp, 1);

		ans = mulm(ans, tmp);
	}

	ans = subm(ans, 1);
	ans = addm(ans, m[rational(0, 0)]);

	cout << ans << endl;
}

Measured memory_bytes: 28936
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <iomanip>
using namespace std;
#define all(x) x.begin(), x.end()
typedef vector <int> vi;
typedef pair<int,int> ii;
typedef long long ll;
typedef long double ld;
const int mod = 1e9 + 7;
const ll inf = 3e18 + 5;
int add(int a, int b) { return (a += b) < mod ? a : a - mod; }
int mul(int a, int b) { return 1LL * a * b % mod; }

const int MAXN = 1 << 18; // 2.6e5
const int N = 200000;
int h[MAXN], b[MAXN];
ll seg[2 * MAXN]; // root is seg[1]

void update(int p, ll val)
{
    for (seg[p += N] = val; p > 0; p >>= 1)
        seg[p >> 1] = max(seg[p], seg[p ^ 1]);
}

ll query(int l, int r) // [l, r]
{
    ll res = 0;
    for (l += N, r += N; l <= r; l >>= 1, r >>= 1)
    {
        if (l & 1)
            res = max(res, seg[l++]);
        if (!(r & 1))
            res = max(res, seg[r--]);
    }
    return res;
}

int main(){
	ios_base::sync_with_stdio(false); cin.tie(0);
  
	int n;
	cin >> n;
	for(int i = 0; i < n; i++)
		cin >> h[i];
	for(int i = 0; i < n; i++)
		cin >> b[i];
	for(int i = 0; i < n; i++)
		update(h[i], query(1, h[i] - 1) + b[i]);
	cout << query(1, MAXN);
}

Measured memory_bytes: 6400
#include <iostream>
using namespace std;
 
int main() {
 
  while(1) {
    int x,y,s;
    cin >> x >> y >>s;
    if(x == 0 && y == 0&&s==0) break;
 
    int maxab = 0;
    int maxy = 0;
    for(int i=1;i<s;i++){
      int a = i*(100.0+x)/100;
      for(int j=1;j<s;j++){
    int b = j*(100.0+x)/100;
    if(a+b==s && maxab <= a+b) {
      maxab = a+b;
      int ya = i*(100.0+y)/100;
      int yb = j*(100.0+y)/100;
      if(ya+yb > maxy) maxy = ya+yb;//,cout << i << " "<<j<<endl;
    }
      }
    }
    cout << maxy<<endl;
     
  }
       
  return 0;
}

Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using Edge = pair<int, ll>;
using Graph = vector<vector<int>>;
using WeightedGraph = vector<vector<Edge>>;
const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

const int CASES = 3;

void solve() {
    ll N;
    cin >> N;
    vector<long long> A(N);
    for (int i = 0; i < N; ++i) cin >> A[i];

    long long res = 0;
    for (ll d = 60; d >= 0; --d) {
        vector<ll> sum(N+1);
        long long mask = 1LL<<d;
        for (int i = 0; i < N; ++i){
            sum[i+1] = sum[i];
            if (A[i] & mask){
                sum[i+1] += 1;
            }
        }

        for (int i = 0; i < N-1; ++i){
            if((A[i] & mask) != 0 ){

                ll tmp = ((mask%MOD) * ((N-i-1) - (sum[N] - sum[i+1]))) % MOD;
                res += tmp;
                res %= MOD;
            }
            else{
                ll tmp = ((mask%MOD) * (sum[N] - sum[i+1])) % MOD;
                res += tmp;
                res %= MOD;
            }
        }
    }
    cout << res%MOD << endl;
}

int main() {
#ifdef MYLOCAL
    vector<string> filenames {"input1.txt", "input2.txt", "input3.txt", "input4.txt"};
    cout << "------------\n";
    for(int i = 0; i < CASES; ++i){
        ifstream in(filenames[i]);
        cin.rdbuf(in.rdbuf());
        solve();
        cout << "------------\n";
    }
#else

    solve();

#endif
    return 0;
}


Measured memory_bytes: 4952
#include<bits/stdc++.h> 
using namespace std;
long long n,ans;
int s;
int main(){
    scanf("%lld",&n);
    for(int i=sqrt(n);i>0;--i)
        if(n%i==0){
            ans=n/i;
            break;
        }
    while(ans>0){
        ++s;
        ans/=10;
    }
    printf("%d\n",s);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

// UnionFindの実装
struct UnionFind {
    vector<int> data;
    UnionFind(int size) : data(size, -1) { }

    // 集合をマージする
    // すでに同じ集合ならfalseが返る
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if(x == y) return false;
        //要素数の少ない方を多い方に繋げる
        if(data.at(y) < data.at(x)) swap(x, y);
        data.at(x) += data.at(y);
        data.at(y) = x;
        return true;
    }

    // ある要素がどの集合に属しているかを返す
    int root(int x) {
        // 根に直接つなぎ直す
        return data.at(x) < 0 ? x : (data.at(x) = root(data.at(x)));
    }

    // ある集合の大きさを答える
    int size(int x) {
        return -data.at(root(x));
    }

    // ある二つの要素が同じ集合か判定
    bool same(int x, int y) {
        x = root(x); y = root(y);
        return x == y;
    }
};

long long n, m;
vector<long long> a(100100, 0);
vector<long long> b(100100, 0);
vector<long long> ans;

int main() {
    cin >> n >> m;
    UnionFind tree(n);
    for(int i = 0; i < m; ++i) {
        cin >> a.at(i) >> b.at(i);
        a.at(i)--; b.at(i)--;
    }

    long long now = n*(n-1)/2;
    ans.push_back(now);
    for(int i = m-1; i >= 0; --i) {
        long long anow = a.at(i); long long bnow = b.at(i);
        if(!tree.same(anow, bnow)) {
            now -= (tree.size(anow) * tree.size(bnow));
        }
        ans.push_back(now);
        tree.merge(anow, bnow);
    }

    for(int i = m-1; i >= 0; --i) {
        cout << ans.at(i) << endl;
    }
}

Measured memory_bytes: 4212
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <climits>
#include <map>
#include <set>
const int mod = 1e9 + 7;
const int inf = 1 << 20;
const long long INF = 1LL << 60;
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int main()
{
    int r;
    cin >> r;
    cout << r * r * 3 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int M=100001;
int n,A[M],ans;
multiset<int>s;
multiset<int>::iterator it;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&A[i]);
	for(int i=1;i<=n;i++){
		if(!s.size()){
			s.insert(A[i]);
			ans++;
			continue;
		}
		it=s.lower_bound(A[i]);
		if(it==s.begin()){
			s.insert(A[i]);
			ans++;
		}else{
			it--;
			s.erase(it);
			s.insert(A[i]);
		}
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 5376
#include <cstdio>
#include <iostream>
#include <string.h>
#include <string> 
#include <map>
#include <queue>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <cmath>
#define mem0(a) memset(a,0,sizeof(a))
#define meminf(a) memset(a,0x3f,sizeof(a))
using namespace std;
typedef long long ll;
typedef long double ld;
const int maxn=200005,inf=0x3f3f3f3f;
const ll llinf=0x3f3f3f3f3f3f3f3f; 
int depth[maxn],visit[maxn],head[maxn],son[maxn];
bool connect[maxn];
int num;
int b,w,n;
 
struct Edge{
	int to,pre;
};
Edge edge[maxn*2];
 
void addedge(int from,int to) {
	edge[num].to=to;
	edge[num].pre=head[from];
	head[from]=num++;
	edge[num].to=from;
	edge[num].pre=head[to];
	head[to]=num++;
}
 
void dfs(int now,int step) {
	visit[now]=1;
	depth[now]=step;
	son[now]=1;
	if (now==n) connect[now]=1;
	for (int i=head[now];i!=-1;i=edge[i].pre) {
		int to=edge[i].to;
		if (!visit[to]) {
			dfs(to,step+1);
			son[now]+=son[to];
			connect[now]=connect[now]|connect[to];
		}
	}
}
 
void dfs2(int now) {
	visit[now]=1;
	bool IsBlack;
	int p;
	if (depth[now]<=depth[n]/2) IsBlack=1; else IsBlack=0;
	for (int i=head[now];i!=-1;i=edge[i].pre) {
		int to=edge[i].to;
		if (!visit[to]&&connect[to]) {
			dfs2(to);
			p=to;
		}
	}
	if (now!=n&&now!=1) 
		if (IsBlack) {
			b+=son[now]-son[p];
		} else w+=son[now]-son[p];
}
 
int main() {
	int i,j,k,x,y;
	mem0(visit);
	mem0(son);
	mem0(connect);
	num=0;
	scanf("%d",&n);
	memset(head,-1,sizeof(head));
	for (i=1;i<n;i++) {
		scanf("%d%d",&x,&y);
		addedge(x,y);
	}
	dfs(1,0);
	int r;
	for (int i=head[1];i!=-1;i=edge[i].pre) {
		if (connect[edge[i].to]) {
			r=edge[i].to;
			break;
		}
	}
	b=n-son[r];
	w=son[n];
	mem0(visit);
	dfs2(1);
	if (b>w) printf("Fennec"); else printf("Snuke");
	return 0;
}


Measured memory_bytes: 12160
while True:
    s = str(input())
    
    if s == 'END OF INPUT':
        break
    
    S = []
    l = s.split(' ')
    S.extend(l)
    m = len(S)
    
    A = []
    for i in range(m):
        L = len(S[i])
        A.append(L)
    
    
    print(*A,sep='')



Measured memory_bytes: 5556
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N=200005;
int sum1[N],sum2[N];
signed main(){
    ios::sync_with_stdio(0);
    int n,t;
    cin>>n>>t;
    sum1[1]=sum2[1]=t;
    for(int i=2;i<=n;i++){
        cin>>t;
        sum1[i]=sum1[i-1]+t;
        sum2[i]=sum2[i-1]^t;
    }
    int l=1,ans=0;
    for(int r=1;r<=n;r++){
        while((sum1[r]-sum1[l-1])!=(sum2[r]^sum2[l-1]))l++;
        ans+=r-l+1;
    }
    cout<<ans<<endl;
    return 0;
}

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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int n;
    cin >> n;
    map<string, int> sm;
    rep(i, n) {
        string s;
        cin >> s;
        sort(all(s));
        sm[s]++;
    }
    auto sigma = [&](int n) {
        ll ans = 0;
        rep1(i, n) ans += i;
        return ans;
    };
    ll ans = 0;
    for (pair<string, int> num : sm) {
        ans += sigma(num.second-1);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 11136
N,M = list(map(int,input().split()))
A = list(map(int,input().split()))
ans = []
r = sum(A) / (4 * M)

for i in A:
    if i < r:
        pass
    else:
        ans.append(i)
if len(ans) < M:
    print('No')
else:
    print('Yes')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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; }
const ll INF = 1LL << 60;
const ll MOD = 1000000007;

int main() {
    int N, M; cin >> N >> M;
    vector<vector<int>> G(N);
    vector<int> deg(N, 0);
    for (int i = 0; i < M; i++) {
        int a, b; cin >> a >> b;
        G[b].push_back(a);
        deg[a]++;
    }

    queue<int> que;
    for (int v = 0; v < N; v++) {
        if (deg[v] == 0) que.push(v);
    }

    vector<int> order;
    while(!que.empty()) {
        int v = que.front();
        que.pop();
        order.push_back(v);

        for (auto nv : G[v]) {
            deg[nv]--;
            if (deg[nv] == 0) que.push(nv);
        }
    }

    reverse(order.begin(), order.end());
    for (int v : order) {
        cout << v << "\n";
    }
    return 0;
}


Measured memory_bytes: 3812
#include<cstdio>
#include<cstring>
#include<algorithm>
#define ll long long
using namespace std;
ll n,a,s;
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
int main()
{
	int n;
	scanf("%lld%lld",&n,&s);
	for(int i=2;i<=n;i++)
	{
		scanf("%lld",&a);
		s=s/gcd(s,a)*a;
	}
	printf("%lld",s);
	return 0;
}

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

template <typename Container, class T>
bool contains(const Container& c, T v)
{
  return std::find(c.begin(), c.end(), v) != c.end();
}

int main()
{
  int M, K;
  std::cin >> M >> K;

  if(std::pow(2, M) <= K) {
    std::cout << -1 << std::endl;
    return 0;
  }
  if(M==1 && K==1) {
    std::cout << -1 << std::endl;
    return 0;
  }

  std::vector<int> ret2;
  ret2.assign(std::pow(2, M), -1);

  // K in the middle
  int j = ret2.size() - 1;
  ret2[j] = K;
  j--;

  // let K sandwitched between i and K^i
  int max_i = std::pow(2, M);

  for(int i=0; i<max_i; i++) {
    if(i == K || (K^i) < i) continue;

    // std::cout << "i = " << i
    //           << "K^i = "  << (K^i)
    //           << std::endl;

    ret2[j] = i;
    j--;

    if((K^i) == K || (K^i) == i) continue;
    ret2[j] = K^i;
    j--;
  }
  // std::cout << "j: " << j << std::endl;

  for(auto &c: ret2) {
    std::cout << c << " ";
  }
  if(K==0) {
    std::cout << K << " ";
  }
  for(auto it=ret2.rbegin() + 1; it !=ret2.rend(); it++) {
    std::cout << *it << " ";
  }
  if(K!=0) {
    std::cout << K << " ";
  }

  std::cout << std::endl;

  return 0;
}


Measured memory_bytes: 4160
function main(input){
  const lines = input.split('\n');
  const NW = lines.shift().split(' ').map(x => parseInt(x));
  const N = NW[0]
  const W = NW[1]
  const items = lines.map(line => line.split(' ').map(x => parseInt(x)) );

  dp = []
  for(var i=0;i<W+1;i++){
    dp.push( Array(N+1).fill(0) );
  }

  var result = 0;
  for(var i=0;i<N;i++){
    for(var w=0;w<=W;w++){

      var weight = items[i][0]
      var value = items[i][1]

      if(weight <= w){
        dp[w][i+1] = Math.max(dp[w][i], dp[w-weight][i] + value);
      }else{
        dp[w][i+1] = dp[w][i];
      }

      if(dp[w][i+1] > result){result = dp[w][i+1];}

    }
  }

  console.log(result);

}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));



Measured memory_bytes: 198688
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>
#include <limits.h>
int max(int a, int b){return a>b?a:b;}
int min(int a, int b){return a<b?a:b;}
int gcd(int a, int b){return min(a,b)==0?max(a,b):gcd(min(a,b),max(a,b)%min(a,b));}
long long llmax(long long a, long long b){return a>b?a:b;}
long long llmin(long long a, long long b){return a<b?a:b;}
long long llgcd(long long a, long long b){return min(a,b)==0 ?llmax(a,b):llgcd(llmin(a,b),llmax(a,b)%llmin(a,b));}
int assort(const void *a, const void *b){return *(int*)a-*(int*)b;}
int dessort(const void *a, const void *b){return *(int*)b-*(int*)a;}
int llassort(const void *a, const void *b){return *(long long*)a-*(long long*)b;}
int lldessort(const void *a, const void *b){return *(long long*)b-*(long long*)a;}
int charassort(const void *a, const void *b){return strcmp((char*)a ,(char*)b);}
int chardessort(const void *a, const void *b){return strcmp((char*)b ,(char*)a);}
int ntoi(char c){return c-'0';}
int ltoi(char c){return c-'a';}
int utoi(char c){return c-'A';}

char lowcmp[26]="abcdefghijklmnopqrstuvwxyz";
char upcmp[26]="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
long long mod=1000000007;

int main(void){
    int n,T,ans=1e9;
    scanf("%d%d",&n,&T);
    int c[n],t[n];
    for (int i=0; i<n; i++){
        scanf("%d%d",&c[i],&t[i]);
        if (t[i]<=T){
            if (ans>c[i]){
                ans=c[i];
            }
        }
        
        
    }
    
    
    
    
    if (ans==1e9){
        printf("TLE\n");
    }else{
    printf("%d\n",ans);
    }
	return 0 ;
}

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

int main() {
  int N, K;
  scanf("%d %d", &N, &K);
  int ans = 0;
  for (int i = 0; i < N; ++i) {
    int h;
    scanf("%d", &h);
    if (h >= K) ++ans;
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 256
a,b,c,d = gets.chomp.split(' ').map(&:to_i)

count_t = c % b == 0 ? c/b : c/b + 1
count_a = a % d == 0 ? a/d : a/d + 1

if count_t <= count_a
    puts "Yes" 
else
    puts "No"
end

Measured memory_bytes: 14184
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(a) (a).begin(),(a).end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
double EPS=1e-8;
int INF = 2e9;
ll dp[1010][1010];
int main(){
	int m,n;
	int c[1010],d[1010];
	memset(dp,-1,sizeof(dp));
	cin>>n>>m;
	REP(i,n)cin>>c[i+1];
	REP(i,m)cin>>d[i+1];
	dp[0][0]=0;
	for(int i=1;i<=m;i++){
		for(int j=0;j<=min(i,n);j++){
			if(j==0)dp[i][j]=dp[i-1][j];
			else{
				if(dp[i-1][j]==-1&&dp[i-1][j-1]==-1)continue;
				else if(dp[i-1][j]==-1)dp[i][j]=dp[i-1][j-1]+c[j]*d[i];
				else if(dp[i-1][j-1]==-1)dp[i][j]=dp[i-1][j];
				else dp[i][j]=min(dp[i-1][j],dp[i-1][j-1]+c[j]*d[i]);
			}
		}
	}
	cout<<dp[m][n]<<endl;
}

Measured memory_bytes: 9140