akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

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

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
#define INF 1LL<<60
ll mod = 1e9 + 7;

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

ll comb(ll n, ll r){
        ll num = 1;
        for(ll i = 1; i <= r; i++){
            num = (num * (n - i + 1) % mod) * modinv(i, mod);
            num %= mod;
        }
        return num;
    }

int main() {
    
    ll N, K;
    cin >> N >> K;

    for(ll i=1; i<=K; ++i) {
        // cerr << "i: " << i << endl;
        if(N-K-i+1<0){
            cout << 0 << endl;
            continue;
        }
        ll tmp1 = comb(K-1, i-1);
        ll tmp2 = 1;
        // cerr << "N-K-(i-1) = " << N-K-(i-1) << " i+1 = " <<  (i+1) << endl;
        if(N-K-i+1>=0) tmp2 = comb(N-K-(i-1) + (i + 1) - 1, i);
        // cerr << "tmp1: " << tmp1 <<" tmp2: " << tmp2 << endl;
        ll ans = (tmp1 * tmp2) % mod;
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 384
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;
ll INF = 1e18;

vl divisor(ll n) {
  vl ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

bool ok(const vl& aa, ll d, ll k) {
  vl a;
  rep(i, aa.size()) if (aa[i] % d) a.push_back(aa[i]);
  ll n = a.size();
  if (n == 0) return true;

  rep(i, n) a[i] = a[i] % d;
  sort(ALL(a));
  vl p(n), m(n);
  m[0] = a[0];
  p[n - 1] = d - a[n - 1];
  REP(i, 1, n) m[i] = m[i - 1] + a[i];
  for (int i = n - 2; i >= 0; i--) p[i] = p[i + 1] + (d - a[i]);
  ll kmin = INT_MAX;
  rep(i, n - 1) {
    if (m[i] == p[i + 1]) {
      kmin = min(kmin, m[i]);
    }
  }
  return (kmin <= k);
}

int main() {
  //
  ll n, k;
  cin >> n >> k;
  vl a(n);
  ll sum = 0;
  rep(i, n) {
    cin >> a[i];
    sum += a[i];
  }
  vl divisors = divisor(sum);
  ll ans = 1;
  for (auto& d : divisors) {
    if (d == 1) continue;
    if (ok(a, d, k)) ans = max(ans, d);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main()
{
    int H, W, a=0, b=0;
    while(1){
        scanf("%d %d", &H, &W);
        if(H==0 && W==0){
            break;
        }
        for(a=0; a<H; a++){
            if(a==0 || a==H-1){
                for(b=0; b<W; b++){
                    printf("#");
                }
                printf("\n");
            } else {
                for(b=0; b<W; b++){
                    if(b==0 ||  b==W-1){
                        printf("#");
                    } else {
                        printf(".");
                    }
                }
                printf("\n");
            }
        }
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 1000
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define rrep(i, n) for (int i = (int)n-1; i >= 0; --i)
using namespace std;
using ll = long long;
template<typename T>
inline bool chmax(T& a, const T& b) {
    if (a < b){
        a = b;
        return true;
    }
    return false;
}
template<typename T>
inline bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T> vector<T> make_vec(size_t n) { return vector<T>(n); }
template<typename T, typename... Args> auto make_vec(size_t n, Args... args) {
    return vector<decltype(make_vec<T>(args...))>(n, make_vec<T>(args...));
}
template<typename T, typename U, typename... V>
typename enable_if<is_same<T, U>::value>::type fill_v(U& u, const V... v) { u = U(v...); }
template<typename T, typename U, typename... V>
typename enable_if<!is_same<T, U>::value>::type fill_v(U& u, const V... v) {
    for (auto& e : u) fill_v<T>(e, v...);
}

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

    string s;
    cin >> s;

    int n = s.size();
    auto dp = make_vec<int>(20, n);
    rep(i, n) dp[0][i] = (s[i] == 'R' ? i+1 : i-1);
    for (int i = 1; i < 20; ++i) {
        rep(j, n) {
            dp[i][j] = dp[i-1][dp[i-1][j]];
        }
    }

    int k = 100000;
    vector<int> ans(n);
    rep(i, n) {
        int now = i;
        rep(j, 20) {
            if (k >> j & 1) now = dp[j][now];
        }
        ans[now]++;
    }
    rep(i, n) cout << ans[i] << (i == n-1 ? '\n' : ' ');
}


Measured memory_bytes: 11688
#include<bits/stdc++.h>
#define ll long long
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define pb push_back
#define MAX 1000000007
using namespace std;
int main()
{
 	speed_up
 	ll n,d;
	cin>>n>>d;
	ll i=1,flag=1;
	while(flag)
	{
		ll a=2*d*i+i;
		if(n<=a)
		break;
		i++;
	}
	cout<<i;
	
	
	
	
	
 return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.util.NoSuchElementException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		Scanner in = new Scanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskA solver = new TaskA();
		solver.solve(1, in, out);
		out.close();
	}

	static class TaskA {
		public void solve(int testNumber, Scanner sc, PrintWriter out) {

			int n = sc.nextInt();

			out.println(n / 3);

		}

	}

	static class Scanner {
		private final InputStream in;
		private final byte[] buffer;
		private int ptr;
		private int buflen;

		public Scanner(InputStream in) {
			this.in = in;
			this.buffer = new byte[1024];
			this.ptr = 0;
			this.buflen = 0;
		}

		private boolean hasNextByte() {
			if (ptr < buflen) return true;
			else {
				ptr = 0;
				try {
					buflen = in.read(buffer);
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (buflen <= 0) return false;
			}
			return true;
		}

		private byte readByte() {
			if (hasNextByte()) return buffer[ptr++];
			return -1;
		}

		private boolean isPrintableChar(byte c) {
			return '!' <= c && c <= '~';
		}

		private void skipUnprintable() {
			while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
				ptr++;
			}
		}

		public boolean hasNext() {
			skipUnprintable();
			return hasNextByte();
		}

		public int nextInt() {
			if (!hasNext()) throw new NoSuchElementException();
			int n = 0;
			boolean minus = false;
			byte b = readByte();
			if (b == '-') {
				minus = true;
				b = readByte();
			}
			if (b < '0' || '9' < b) throw new NumberFormatException();
			while (true) {
				if ('0' <= b && b <= '9') {
					n *= 10;
					n += b - '0';
				} else if (b == -1 || !isPrintableChar(b)) {
					return minus ? -n : n;
				} else {
					throw new NumberFormatException();
				}
				b = readByte();
			}
		}

	}
}



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

using namespace std;

int main()
{
  long H, W;
  cin >> H >> W;
  
  vector<string> s(H);
  for (long h = 0; h < H; ++h) {
    cin >> s[h];
  }
  
  for (long h = 0; h < H; ++h) {
    for (long w = 0; w < W; ++w) {
      if (s[h][w] == '.') {
        continue;
      }
      
      long dy[] = {+1, -1,  0,  0};
      long dx[] = { 0,  0, +1, -1};
      bool flag = false;
      for (unsigned i = 0; i < 4; ++i) {
        long x = w + dx[i], y = h + dy[i];
      	if (0 <= x && x < W && 0 <= y && y < H) {
          if (s[y][x] == '#') {
          	flag = true;
          }
        }
      }
      if (!flag) {
      	cout << "No" << endl;
        return 0;
      }
    }
  }
  
  cout << "Yes" << endl;
  return 0;
}

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

#pragma region Macro
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define SORT(v) sort(v.begin(), v.end())
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define vi vector<int>
#define vvi vector<vector<int>>
#define chmax(x,y) (x = max(x,y))
#define chmin(x,y) (x = min(x,y))

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#pragma endregion

void solve(){
	#define int ll
	// ここに処理を記述
	// コンパイル時はエイリアス「gpp」--> c++17でコンパイル
	int x;
	cin >> x;

	int fix = x-400;
	cout << 8-(fix/200) << endl;
}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	
	solve();
	return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N, M;
    cin >> N >> M;
    vector<vector<int>> edges(N, vector<int>());
    for (int i = 0; i < M; i++)
    {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        edges[a].push_back(b);
        edges[b].push_back(a);
    }
    stack<pair<int, int>> dfs;
    int count = 0;
    dfs.emplace(0, 1);
    while (!dfs.empty())
    {
        auto d = dfs.top();
        dfs.pop();
        auto current = d.first;
        auto visited = d.second;
        if (visited == pow(2, N) - 1)
        {
            count++;
            continue;
        }
        for (auto target : edges[current])
        {
            if (visited & 1 << target)
            {
                continue;
            }
            dfs.emplace(target, visited | 1 << target);
        }
    }
    cout << count  << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define Int int64_t
#define ll long long
#define pb push_back
using namespace std;
const Int MAXN=200005;
const int ALPHA=26;

Int N,K,M;
Int X,Y,Z;Int C;
vector<Int> ID;
vector<Int> SZ;
string S;
int find(int x){
    if(ID[x]==x) return x;
    return find(ID[x]);
}
void Union(int x,int y){
    x=find(x);y=find(y);
    if(x==y) return;
    if(SZ[x]>SZ[y]){
        ID[y]=x;
        SZ[x]+=SZ[y];
    }
    else{
        ID[x]=y;
        SZ[y]+=SZ[x];
    }
    return;
}
string common_prefix(string s,string t){
    string ans="";
    for(int i=0;i<min(s.length(),t.length());++i){
        if(s[i]==t[i]) ans.pb(s[i]);
        else break;
    }
    return ans;
}
string LCP(vector<string> A,int l,int r){
    if(l>r) return "";
    if(l==r) return A[l];
    int mid=(l+r)/2;
    string left=LCP(A,l,mid);
    string right=LCP(A,mid+1,r);
    return common_prefix(left,right);
}

long long ModExpo(long long x,unsigned long long y,long long M){
    Int ans=1;
    ans=(long long)ans;
    
    while(y>0){
        if(y&1) ans=((ans%M)*(x%M))%M;
        y>>=1LL;
        x=((x%M)*(x%M))%M;
    }
    return ans%M;
}
Int LCM(Int x,Int y){
    return (x*y)/__gcd(x,y);
}

using D=long double;
vector<Int> A,B;

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(0);
    int t;
    t=1;
    while(t--){
        cin>>K;
        
            Int x=7%K;Int ans=1;
            bool notFound=false;
            while(true){
                if(!x) break;
                x=(x*10+7)%K;
                ++ans;
                if(ans>1e7) {
                    notFound=true;break;
                }
            }
            cout<<(!notFound ? ans:-1)<<"\n";

    
    }
}

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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin>>n;
    vector<int> vec(n),vec1(n),vec2(n);
    for(int i=0;i<n;++i)
    {
        cin>>vec[i];
        vec1[i]=i-vec[i];
        vec2[i]=i+vec[i];
    }
    
    map<int,int> ma;
    ll ans=0;
    for(int i=0;i<n;++i)
    {
        if(ma.find(vec1[i])!=ma.end())
        {
            ans+=ma[vec1[i]];
        }
        ma[vec2[i]]++;
    }
    cout<<ans<<"\n";

}


Measured memory_bytes: 14824
#include "bits/stdc++.h"
using namespace std;
#define mod 1000000007
using ll = long long;
int dd[] = { 0, 1, 0, -1, 0 }; //→↓←↑

void solve()
{
	double a, b;
	cin >> a >> b;
	if (a < b)swap(a, b);
	if (a - b < 360 + b - a)
	{
		cout << (a + b) / 2 << endl;
	}
	else
	{
		double c = (360 + b - a) / 2 + a;
		if (c >= 360)c -= 360;
		cout << c << endl;
	}
}

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


Measured memory_bytes: 3296
#include <iostream>
#include <list>
#include <stdio.h>
#define MAX 1001

using namespace std;

int main()
{
    int n, query;
    scanf("%d %d", &n, &query);
    list<int> List[MAX];

    int comment, index, indexSplice, num;
    list<int>::iterator itr;
    for (int i = 0; i < query; i++)
    {
        scanf("%d", &comment);
        switch (comment)
        {
        case 0:
            scanf("%d %d", &index, &num);
            List[index].push_back(num);;
            break;
        case 1:
            scanf("%d", &index);
            if (!List[index].empty())
            {
                itr = List[index].begin();
                printf("%d", *itr++);
                while (itr != List[index].end())
                {
                    printf(" %d", *itr++);
                }
            }
            printf("\n");
            break;
        case 2:
            scanf("%d %d", &indexSplice, &index);
            List[index].splice(List[index].end(), List[indexSplice]);
            break;
        default:
            break;
        }
    }
    return 0;
}



Measured memory_bytes: 18768
import collections
import sys
input = sys.stdin.readline
H, W = map(int, input().split())
A = [list(input()) for i in range(H)]
dp = [[-1]*W for i in range(H)]

q = collections.deque()
for i in range(H):
    for j in range(W):
        if A[i][j] == "#":
            dp[i][j] = 0
            q.append([i, j])


while(q):
    x, y = q.popleft()
    if x > 0:
        if dp[x-1][y] == -1:
            dp[x-1][y] = dp[x][y]+1
            q.append([x-1, y])
    if x < H-1:
        if dp[x+1][y] == -1:
            dp[x+1][y] = dp[x][y]+1
            q.append([x+1, y])
    if y > 0:
        if dp[x][y-1] == -1:
            dp[x][y-1] = dp[x][y]+1
            q.append([x, y-1])
    if y < W-1:
        if dp[x][y+1] == -1:
            dp[x][y+1] = dp[x][y]+1
            q.append([x, y+1])
ans = 0
for i in range(H):
    ans = max(ans, max(dp[i]))
print(ans)


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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;


int N;
int x[10], y[10];

double dist(int i, int j) {
    double dx = x[i] - x[j];
    double dy = y[i] - y[j];
    return pow(dx * dx + dy * dy, 0.5);
}

int main() {
    cin >> N;
    rep(i,N) cin >> x[i] >> y[i];

    double sum = 0.0;
    vector<int> v(N);
    rep(i,N) v[i] = i;
    do {
        rep(i,N-1) sum += dist(v[i], v[i+1]); 
    } while (next_permutation(v.begin(), v.end()));
    
    int factorial = 1;
    repr(i, 2, N+1) factorial *= i;

    cout << fixed << setprecision(10) << sum / factorial << endl;
    return 0;
}

Measured memory_bytes: 384
//#include <stdio.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <queue>
#include <map>
#include <utility>
#include <iomanip>

using namespace std;

#define ll long long

void solve()
{
    ll N;
    cin >> N;
    vector<ll> A(N);
    vector<vector<pair<ll, ll>>> xy(N);
    for (ll i = 0; i < N; i++)
    {
        cin >> A.at(i);

        xy.at(i) = vector<pair<ll, ll>>(A.at(i));
        for (ll j = 0; j < A.at(i); j++)
        {
            ll x, y;
            cin >> x >> y;
            xy.at(i).at(j) = make_pair(--x, y);
        }
    }

    ll maxc = 0;
    for (ll i = 0; i < (2 << (N - 1)); i++)
    {
        vector<ll> cond;
        ll bit = i;
        ll count = 0;
        for (ll j = 0; j < N; j++)
        {
            ll dition = bit & 1;
            count += dition;
            cond.push_back(dition);
            bit >>= 1;
        }

        bool isOK = true;
        for (ll j = 0; j < N; j++)
        {
            if (cond.at(j) == 1)
            {
                for (ll k = 0; k < A.at(j); k++)
                {
                    auto c = xy.at(j).at(k);
                    if (cond.at(c.first) != c.second)
                    {
                        isOK = false;
                        break;
                    }
                }

                if (!isOK)
                {
                    break;
                }
            }
        }

        if (isOK)
        {
            maxc = max(maxc, count);
        }
        cout << endl;
    }

    cout << maxc << endl;

    return;
}

int main()
{
    solve();
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define mod 1000000007
int main() {

	ll n;
	cin>>n;

	ll a[n+5];

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

	unordered_map<ll,ll> mp;
	for(ll i=0;i<n;i++)
	{
		mp[a[i]+i]++;
	}

	ll count=0;
	for(ll j=0;j<n;j++)
	{
		if(mp.find(j-a[j])!=mp.end())
		{
			//cout<<j<<" "<<mp[j-a[j]]<<endl;
			count+=mp[j-a[j]];
		}
	}
	cout<<count<<endl;


    
    return 0;
}

Measured memory_bytes: 12940
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <iomanip>
#include <map>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
#define pie 3.141592653589793238462643383279
#define inf 1000000007;
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}

int n, a[200000], ta;

signed main() {
	cin >> n;
	rep(i, n)cin >> a[i];
	if (a[0] != 0) { cout << -1 << endl; return 0; }
	rep(i, n - 1) {
		if (a[i] + 2 <= a[i + 1]) { cout << -1 << endl; return 0; }
		if (a[i] + 1 != a[i + 1])ta += a[i];
	}
	ta += a[n - 1];
	cout << ta << endl;
	getchar(); getchar();
	return 0;
}

Measured memory_bytes: 1792
fun main(){

    var acCount = 0;
    var waCount = 0;
    var tleCount = 0;
    var reCount = 0;

    val input = readLine()!!.toInt()


    var array = arrayListOf<String>()

    var map = hashMapOf<String,Int>()

    for (i in 1..input){
        var str = readLine()!!
        array.add(str)
    }

    for (str in array){

        when(str){
            "AC" -> {
                acCount++
            }
            "WA" -> {
                waCount++
            }
            "TLE" -> {
                tleCount++
            }
            "RE" -> {
                reCount++
            }
        }
    }

    println("AC x " + acCount)
    println("WA x " + waCount)
    println("TLE x " + tleCount)
    println("RE x " + reCount)

}


Measured memory_bytes: 60300
def myAnswer(S: list) -> int:
    ans = [S.pop(0)]
    flag = False
    for s in S:
        if(flag):
            ans[-1] += s
            flag = False
        elif(ans[-1] == s):
            flag = True
            ans.append(s)
        else:
            ans.append(s)
   
    return len(ans)-1 if(flag==True) else len(ans)


def modelAnswer():
    tmp = 1


def main():
    S = list(input())
    print(myAnswer(S[:]))


if __name__ == '__main__':
    main()


Measured memory_bytes: 10940
#include <iostream>
#include <cstdio>
#include <cstring>

using namespace std;

const int N = 100010;

int n;
int tot = -1, head[N];
struct Edge {
    Edge(int p = 0, int next = 0) : p(p), next(next) {}
    int p, next;
} edge[N << 1];
inline void Add(int u, int v) {
    edge[++tot] = Edge(v, head[u]);
    head[u] = tot;
    return;
}

int fa[N], dep[N], size[N];
void DFS(int u) {
    size[u] = 1;
    for (int i = head[u]; ~i; i = edge[i].next) {
        int v = edge[i].p;
        if (v != fa[u]) {
            fa[v] = u;
            dep[v] = dep[u] + 1;
            DFS(v);
            size[u] += size[v];
        }
    }
    return;
}

int main() {
    scanf("%d", &n);
    memset(head, -1, sizeof(head));
    for (int i = 1; i < n; ++i) {
        int u, v;
        scanf("%d%d", &u, &v);
        Add(u, v);
        Add(v, u);
    }
    DFS(1);
    int j = n;
    for (int i = ((dep[n] - 1) >> 1); i; j = fa[j], --i);
    if (n - size[j] > size[j]) puts("Fennec");
    else puts("Snuke");
    return 0;
}

Measured memory_bytes: 8064
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <climits>
#include<string>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

#define INF INT_MAX/3
#define REP(i,n) for(int i=0;i<n;i++)

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

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

}



Measured memory_bytes: 256
#include <stdio.h>
int h, w, x, y;
char s[105][105];
int a[100][100];
int main() {
	scanf("%d%d", &h, &w);
	for (int i = 0; i < h; i++) {
		scanf(" %s", s[i]);
	}
	if (s[0][0] == '#')x++;
	if (s[h - 1][w - 1] == '#')x++;
	a[0][0] = 0;
	for (int i = 1; i < h + w - 1; i++) {
		for (int j = 0; j < h + w - 1;j++) {
			if (0 <= j && j < h && 0 <= i - j && i - j < w) {
				a[j][i - j] = 10000;
				if (j > 0) {
					y = a[j - 1][i - j];
					if (s[j][i - j] != s[j - 1][i - j])y++;
					if (a[j][i - j] > y)a[j][i - j] = y;
				}
				if (i - j > 0) {
					y = a[j][i - j - 1];
					if (s[j][i - j] != s[j][i - j - 1])y++;
					if (a[j][i - j] > y)a[j][i - j] = y;
				}
			}
		}
	}
	x += a[h - 1][w - 1];
	x++;
	printf("%d\n", x / 2);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF 1e18L
#define INF 1e9L
#define EPS 1e-9
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define pb push_back
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
typedef long long ll;
typedef pair<int, int> pii;

int main(void)
{
    int n,a;
    cin >> n >> a;
    n %= 500;
    Yes(n <= a);
}

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

int N;
vector<int> a;

int main(void) {
	cin >> N;
	a.resize(N);
	for (int i = 0; i < N; ++i)
		cin >> a[i];

	sort(a.begin(), a.end(), greater<int>());
	int pos = N - 1;
	for (int i = 0; i < N; ++i) {
		if (i >= a[i]) {
			pos = i - 1;
			break;
		}
	}
	int x = N - 1;
	for (int i = N - 1; i >= 0; --i) {
		if (a[i] > pos) {
			x = i;
			break;
		}
	}
	x -= pos;
	int y = a[pos] - pos - 1;

	if (x % 2 == 0 && y % 2 == 0)
		cout << "Second\n";
	else
		cout << "First\n";
	return 0;
}


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

#define REP(i, b) for(int i = 0; i < (b); i++)
#define REPS(i, b) for(int i = 1; i <= (b); i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

using ll = long long;
using ld = long double;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vd = vector<double>;
using vs = vector<string>;
using vb = vector<bool>;
using vpi = vector<pi>;
using vpl = vector<pl>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using vvb = vector<vb>;

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

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

signed main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    int H, W, K; cin >> H >> W >> K;
    vs s(H); REP(i, H) cin >> s[i];
    vvi ans(H, vi(W));
    int c = 0;
    REP(i, H)
    {
        REP(j, W)
        {
            if(s[i][j] == '#')
            {
                c++;
                ans[i][j] = c;
            }
        }
    }

    REP(i, H)
    {
        for(int j = 1; j < W; j++)
        {
            if(ans[i][j] == 0) ans[i][j] = ans[i][j-1];
        }
        for(int j = W-2; j >= 0; j--)
        {
            if(ans[i][j] == 0) ans[i][j] = ans[i][j+1];
        }
    }
    REP(j, W)
    {
        for(int i = 1; i < H; i++)
        {
            if(ans[i][j] == 0) ans[i][j] = ans[i-1][j];
        }
        for(int i = H-2; i >= 0; i--)
        {
            if(ans[i][j] == 0) ans[i][j] = ans[i+1][j];
        }
    }

    REP(i, H)
    {
        REP(j, W)
        {
            cout << ans[i][j] << " ";
        }
        cout << endl;
    }
}

Measured memory_bytes: 1280
a,b = map(int, input().split())
s = input()
for i,j in enumerate(s):
  if i == a:
    if j != "-":
      print("No")
      exit()
  else:
    if ord("0") <= ord(j) <= ord("9"):
      continue
    else:
      print("No")
      exit()
print("Yes")

Measured memory_bytes: 3060
#include <cstdio>

int pri[101000], tot = 0;
bool is[101000];

void init()
{
	for(int i = 2; i <= 100000; i++)
	{
		if(!is[i]) pri[++tot] = i;
		for(int j = 1; j <= tot && i * pri[j] <= 100000; j++)
		{
			is[i * pri[j]] = 1;
			if(i % pri[j] == 0) break;
		}
	}
}
long long m[1010][1010];

long long gcd(long long a, long long b) {return b == 0 ? a : gcd(b, a % b);} 
void lcm(long long &a, long long b)
{
	a = a / gcd(a, b) * b; 
}
int main()
{
	int n; scanf("%d", &n);
	if(n == 2)
	{
		printf("4 7\n23 10");
		return 0;
	}
	init();
	int j = 2;
	for(int i = 2; i <= 2 * n; i += 2)
	{
		for(int k = 0; k <= n; k++)
		{
			if(k + 1 >= 1 && k + 1 <= n && i - k >= 1 && i - k <= n) m[k + 1][i - k] = pri[j];
		}
		j++;
	}
	
	for(int i = (n / 2 * 2); i >= - n; i -= 2)
	{
		for(int k = 0; k <= n; k++)
		{
			if(k + 1 >= 1 && k + 1 <= n && i + k >= 1 && i + k <= n) m[k + 1][i + k] *= pri[j];
		}
		j++;
	}
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= n; j++)
		{
			if(!m[i][j])
			{
				m[i][j] = 1;
				if(i != 1) lcm(m[i][j], m[i - 1][j]);
				if(j != 1) lcm(m[i][j], m[i][j - 1]);
				if(i != n) lcm(m[i][j], m[i + 1][j]);
				if(j != n) lcm(m[i][j], m[i][j + 1]);
				m[i][j]++;
			}
		}
	for(int i = 1; i <= n; i++, puts(""))
		for(int j = 1; j <= n; j++) printf("%lld ",m[i][j]);
	return 0;
}

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

int h, w, f[110][110][2];
char s[110][110];

int main() {
    scanf("%d %d", &h, &w);
    for (int i = 1; i <= h; i++) {
        scanf("%s", s[i] + 1);
    }
    memset(f, 0x3f, sizeof(f));
    f[1][1][s[h][w] == '.'] = (s[h][w] == '#');
    for (int i = 1; i <= h; i++) {
        for (int j = 1; j <= w; j++) {
            if (i == 1 && j == 1) continue;
            for (int k = 0; k < 2; k++) {
                int l = (s[i][j] == '.');
                int t = !l && (l ^ k);
                if (i > 1) f[i][j][l] = min(f[i][j][l], f[i - 1][j][k] + t);
                if (j > 1) f[i][j][l] = min(f[i][j][l], f[i][j - 1][k] + t);
            }
        }
    }
    printf("%d\n", min(f[h][w][0], f[h][w][1]));
    return 0;
}

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

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

    std::vector<long long> A(N);
    for (int i = 0; i < N; i++) std::cin >> A[i];

    std::sort(std::begin(A), std::end(A));

    std::cout << (A.back() - A.front()) << std::endl; 
    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
#include <random>
#include <unordered_set>
using namespace std;

#define rep(i, N) for (int i = 0; i < N; i++)
#define pb push_back

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
int INF = INT_MAX / 10;
double EPS = 1e-10;

bool solve() {
	int N; cin >> N;
	vector<int> a(N);
	rep(i, N) scanf("%d", &a[i]);
	ll sum = 0;
	rep(i, N) sum += a[i];
	ll M = (ll)N * (N + 1) / 2;
	if (sum % M) return false;
	ll T = sum / M;
	vector<ll> da(N);
	rep(i, N) da[i] = a[(i + 1) % N] - a[i];
	rep(i, N) da[i] -= T;
	ll cnt = 0;
	rep(i, N) {
		if (da[i] > 0) return false;
		if ((-da[i]) % N) return false;
		cnt += (-da[i]) / N;
	}
	return cnt == T;
}

int main() {
	cout << (solve() ? "YES" : "NO") << endl;
}


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

int main(){
  int n;
  cin >> n;
  int s[51];
  for(int i=0; i<n; i++) cin >> s[i];
  
  bool flag1 = 0;
  bool flag2 = 0;
  bool flag3 = 0;
  //int num = 0;
  for(int i=0; i<n; i++) {
    /*
    if (flag1 ==0 && num>s[i]) flag1 = 1;
    else if (flag1 ==1 && num>s[i]) flag2 = 1;
    else if (flag1 ==1 && flag2 ==1
             && flag3 == 0 && num>s[i])
      flag3 = 1;
      */
    if (!flag1 && i+1!=s[i]) flag1 = 1;
    else if (flag1 && !flag2 && i+1!=s[i]) flag2 = 1;
    else if (flag1 && flag2 
             && !flag3 && i+1!=s[i])
      flag3 = 1;
    //num = s[i];
  }
  
  if ((flag1&& !flag2) ||
      flag3)
    cout << "NO" << endl;
  else cout << "YES" << endl;
  
  //cout << flag1 << " " << flag2 << " " << flag3 << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <list>
#include <map>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define LT(a,b,c,d) (((a)<(c))||((a)==(c)&&(b)<(d)))
#define INF 114514


int view[100][100];
int pict[50][50];
int supX,supP;
int mendoP,mendoQ;
int resX,resY;


bool rotPict(){
	int buf[50][50];
	FOR(p,0,supP) FOR(q,0,supP) buf[p][q] = pict[supP-1-q][p];
	FOR(p,0,supP) FOR(q,0,supP) pict[p][q] = buf[p][q];
}

bool findMendo(){
	FOR(p,0,supP) FOR(q,0,supP) if(pict[p][q]!=-1){ mendoP=p; mendoQ=q; return true; }
	return false;
}

bool match(int offX, int offY){
	FOR(p,0,supP) FOR(q,0,supP) if(pict[p][q]!=-1 && pict[p][q]!=view[offX+p][offY+q]) return false;
	return true;
}

bool letMatch(){
	FOR(offX,0,supX-supP+1) FOR(offY,0,supX-supP+1){
		if(match(offX,offY)){
			if(LT(offX+mendoP, offY+mendoQ, resX, resY)){
				resX = offX+mendoP;
				resY = offY+mendoQ;
			}
			return true;
		}
	}
}

int main(){
	while(true){
		cin >> supX >> supP;			if(!supX&&!supP) return 0;

		FOR(x,0,supX) FOR(y,0,supX) cin >> view[x][y];
		//FOR(x,0,supX) {FOR(y,0,supX) cout << view[x][y] << " "; cout << endl;}

		FOR(p,0,supP) FOR(q,0,supP) cin >> pict[p][q];

		resX=INF; resY=INF;
		REP(i,4){
			//cout << endl;
			//FOR(p,0,supP) {FOR(q,0,supP) cout << pict[p][q] << " "; cout << endl;}
			findMendo();
			letMatch();
			rotPict();
		}

		if(resX==INF&&resY==INF){cout << "NA" << endl;}
		else{cout << resY+1 << " " << resX+1 << endl;}

	}
}

Measured memory_bytes: 1216
#[allow(unused_imports)]
use std::{cmp::Reverse, collections::*};

#[allow(unused_imports)]
use proconio::{
    fastout, input,
    marker::{Chars, Usize1},
};

#[allow(unused_imports)]
use itertools::Itertools;

#[allow(unused_imports)]
use num::Integer;

#[fastout]
pub fn main() {
    input! {
        s: Chars,
    }

    let mut count = 0;
    let mut max = 0;
    for c in s {
        if c == 'R' {
            count += 1;
        } else {
            max = max.max(count);
            count = 0;
        }
    }
    if max < count {
        max = count;
    }

    println!("{}", max);
}


Measured memory_bytes: 2192
n = int(input())
x = [0] * n
y = [0] * n
for i in range(n):
    [x[i], y[i]] = [int(x) for x in input().split()]

dist = 0
for i in range(n):
    for j in range(n):
        if i == j:
            continue
        dist += (((x[i]-x[j])**2) + ((y[i]-y[j]) ** 2)) ** 0.5
print(dist/n)

Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
const int INF = 2147483647;
const ll MOD = 1000000007;

using namespace std;

int main() {
  int n, q;
  cin >> n >> q;
  vl a(n), x(q);
  REP(i, n) { cin >> a[i]; }
  REP(i, q) { cin >> x[i]; }

  vl cum(n + 1), cumtobi(n + 1);
  cum[0] = 0;
  cumtobi[0] = 0;
  cum[1] = a[0];
  cumtobi[1] = a[0];
  FOR(i, 2, n + 1) {
    cum[i] = cum[i - 1] + a[i - 1];
    cumtobi[i] = cumtobi[i - 2] + a[i - 1];
  }

  vector<pair<ll, ll>> map;

  for (int i = 1; i <= (n + 1) / 2; i++) {
    if (n - 2 * i - 1 < 0) {
      ll tx = 0;
      ll v = cum[n] - cum[n / 2];
      map.push_back(make_pair(tx, v));
    } else {
      ll tx = (a[n - i - 1] + a[n - 2 * i - 1]) / 2;
      ll v = cum[n] - cum[n - i] + cumtobi[n - 2 * i];
      map.push_back(make_pair(tx, v));
    }
  }

  sort(map.begin(), map.end());

  REP(i, q) {
    int idx = (upper_bound(map.begin(), map.end(), make_pair(x[i], 0LL)) -
               map.begin()) -
              1;
    cout << map[idx].second << endl;
  }
}


Measured memory_bytes: 5748
x, k, d = map(int, input().split())
x = abs(x)
if x > k*d:
    print(x-k*d)
else:
    p = x//d
    c = k-p
    if (c%2 == 0):
        print(abs(x-p*d))
    else:
        print(abs(d-abs(x-p*d)))


Measured memory_bytes: 9204
import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  #空白なし
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  #空白あり
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし


N,M,X = MI()
A = LI()
a = sum(A[i] < X for i in range(M))
print(min(a,M-a))


Measured memory_bytes: 62072
#include<bits/stdc++.h>
using namespace std;
int gcd(int a, int b){
        if(a < b) return gcd(b, a);
        int r;
        while ((r = a % b)){
                a = b;
                b = r;
        }
        return b;
}
int gcd3(int a, int b, int c){
        int d = gcd(a, b);
        return gcd(d, c);
}
int main(){
        int k;
        cin >> k;
        int ans = 0;

        for(int i = 1; i <= k; i++){
                for(int j = 1; j <= k; j++){
                        for(int l = 1; l <= k; l++){
                                //cout << i << " " << j << " " << l << endl;
                                ans += gcd3(i, j, l);
                        }
                }
        }

        cout << ans << endl;



}


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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

bool isin(int x, int y, VS& a, VS& b){
  REP(dy,2) REP(dx,2)
	if(a[y+dy][x+dx] != b[dy][dx])
	  return false;
  return true;
}

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

  int H, W;
  cin >> H >> W;

  VS vs(H);
  REP(y,H) cin >> vs[y];

  VS flag(2);
  REP(y,2) cin >> flag[y];

  int sum = 0;
  REP(y,H-1) REP(x,W-1){
	if(isin(x, y, vs, flag))
	  ++sum;
  }

  const string JOI = "JOI";
  
  int ans = sum;
  REP(y,H) REP(x,W){
	char orig = vs[y][x];
	REP(i,3){
	  int tmp = sum;
	  FOR(ty,y-1,y+1) FOR(tx,x-1,x+1)
		if(0 <= ty && ty+1 < H && 0 <= tx && tx+1 < W){
		  if(isin(tx, ty, vs, flag)) --tmp;
		}
	  vs[y][x] = JOI[i];
	  FOR(ty,y-1,y+1) FOR(tx,x-1,x+1)
		if(0 <= ty && ty+1 < H && 0 <= tx && tx+1 < W){
		  if(isin(tx, ty, vs, flag)) ++tmp;
		}
	  vs[y][x] = orig;
	  maxi(ans, tmp);
	}
  }
  cout << ans << endl;

  return 0;
}

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

#define endl '\n'
#define lfs cout<<fixed<<setprecision(10)
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define test cout<<"test"<<endl;
#define fi first
#define se second
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
void chmin(T &a,T b){if(a>b)a=b;}
template<typename T>
void chmax(T &a,T b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}
ostream &operator<<(ostream &os, pair<ll, ll>&p){
  return os << p.first << " " << p.second;
}  
template<typename T>
void pr(T a){
  cout<<a<<endl;
}
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ll res=0,buf=0;
  bool judge = true;
  //ll a;cin>>a;
  ll a,b;cin>>a>>b;
  //ll a,b,c;cin>>a>>b>>c;
  //ll a,b,c,d;cin>>a>>b>>c>>d;
  //string s;cin>>s;
  //ll n;cin>>n;string s;cin>>s;
  ans1(500*a>=b);
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if(a * b % 2 == 0) {
            System.out.println("Even");
        }else {
            System.out.println("Odd");
        }
    }
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
#include <stdio.h>
typedef long long int LL;
#define fr(i,p,n) for(LL i=p;i<n;i++)
#define fr1(i,p,n) for(LL i=p;i>=n;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define PI 3.14159265358979323846
#define MOD 1000000007
#define MOD1 998244353
#define INF 1e18
#define precise cout << std::setprecision(10) << std::fixed;

using namespace std;
 
int main()
{
    int x;
	cin>>x;
	int rating;
	
	if(x>=400 && x<=599)
	  rating=8;
	else if(x>=600 && x<=799)
	  rating=7;
	else if(x>=800 && x<=999)
	  rating=6;
	else if(x>=1000 && x<=1199)
	  rating=5;
	else if(x>=1200 && x<=1399)
	  rating=4;
	else if(x>=1400 && x<=1599)
	  rating=3;
	else if(x>=1600 && x<=1799)
	  rating=2;
	else
	  rating=1;  
	 
	cout<<rating<<endl;  
    return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <vector>
#include <cstring>

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

   std::vector<int> A[N];
   for(int i=0; i<N; ++i){
      A[i].resize(N-1);
      for(int j=0; j<N-1; ++j){
	 std::cin >> A[i][j];
      }
   }

   long long ans = 0;
   while(true){
      bool update = false;
      bool remain = false;
      bool flag[N];
      memset(flag, true, N);
      for(int i=0; i<N; ++i){
	 if(A[i].size()==0 || !flag[i]) continue;
	 remain = true;
	 int op = A[i][0] - 1;
	 if(i+1==A[op][0] && flag[op]){
	    A[i].erase(A[i].begin());
	    A[op].erase(A[op].begin());
	    flag[i] = false;
	    flag[op] = false;
	    update = true;
	 }
      }

      if(update) ++ans;
      else if(remain) {
	 std::cout<< -1 << std::endl;
	 return 0;
      }else break;
   }
   std::cout << ans << std::endl;

   return 0;
}


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

int cnt;

int gcd(int a,int b){ 
  if(a==0 || b==0) return 0;
  if(a<b) swap(a,b);
  while(b!=0) {
    a%=b;
    swap(a,b);
    cnt++;
  }
  return a;
}

int main() {
  int a,b;
  while(cin >> a >> b && (a!=0 || b!=0)) {
    cnt=0;
    int g=gcd(a,b);
    cout << g << " " << cnt << endl;
  }
  return 0;
}


Measured memory_bytes: 1160
import sys
sys.setrecursionlimit(10**7)
N=int(input())

NODES={}
for i in range(N-1):
    a,b,c=map(int,input().split())
    if not a in NODES: NODES[a] = []
    if not b in NODES: NODES[b] = []
    NODES[a].append((b, c))
    NODES[b].append((a, c))

Q,K=map(int,input().split())
MP=[-1]*(N+1)
MP[K]=0
def dfs(k):
    for i, c in NODES[k]:
        if MP[i] == -1:
            MP[i] = MP[k] + c
            dfs(i)

dfs(K)
# print(MP)
for l,r in [tuple(map(int,input().split())) for _ in range(Q)]:
    print(MP[l]+MP[r])


Measured memory_bytes: 138016
import fractions

n = int(input())
a = list(map(int, input().split()))
tmp = a[0]
ans = 0

for i in range(1, n):
    tmp = tmp * a[i] // fractions.gcd(tmp, a[i])

for i in a:
    ans += tmp // i

print(ans % (10 ** 9 + 7))


Measured memory_bytes: 6200
def main():
  import sys
  n,s,_,*t=sys.stdin.buffer.read().split()
  n=int(n)
  d=[0]*n+[1<<c-97for c in s]
  for i in range(n-1,0,-1):d[i]=d[i+i]|d[i-~i]
  r=[]
  for q,a,b in zip(*[iter(t)]*3):
    i,s=int(a)+n-1,0
    if q<b'2':
      d[i]=1<<b[0]-97
      while i>1:
        i//=2
        d[i]=d[i+i]|d[i-~i]
      continue
    j=int(b)+n
    while i<j:
      if i&1:
        s|=d[i]
        i+=1
      if j&1:
        j-=1
        s|=d[j]
      i//=2
      j//=2
    r+=bin(s).count('1'),
  print(' '.join(map(str,r)))
main()

Measured memory_bytes: 45556
#include "bits/stdc++.h"
using namespace std; 
#define LIM 100003
#define M 1000000007
#define inf 99999999999999999LL	//long long inf
typedef long long ll;

#define sc(x) scanf("%d",&x);
#define sc2(x,y) scanf("%d%d",&x,&y);
#define sc3(x,y,z) scanf("%d%d%d",&x,&y,&z);
#define scl(x) scanf("%lld",&x);
#define scl2(x,y) scanf("%lld%lld",&x,&y);
#define scl3(x,y,z) scanf("%lld%lld%lld",&x,&y,&z);

#define pb push_back
#define mp make_pair
#define fi first
#define se second 
ll power(ll x,ll y,ll z) {	ll ret = 1;	while(y > 0) {	if(y & 1) ret = (ret*x)%z;x = (x*x)%z;y >>= 1;}return ret;}


#define debug(x) cerr<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cerr<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cerr<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";
#define debug4(x,y,z,a) cerr<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\t"<<#a<<" :: "<<a<<"\n";



ll n, w, dp[102][100020], weight[102], value[102], answer = 0 ;
int main() {
	ll i, j, t;
	scl2(n, w) ;
	for(i=1; i<=n; i++)	scl2(weight[i], value[i]) ;
	dp[0][0] = 0 ;
	for(i=1; i<LIM; i++)
		dp[0][i] = inf ;
	
	for(i=1; i<=n; i++) {

		for(j=1; j<=100000; j++) {
			if( j - value[i] >= 0)
				dp[i][j] = min(dp[i-1][j], weight[i] + dp[i-1][j-value[i]]) ;
			else
				dp[i][j] = dp[i-1][j];
			if(dp[i][j] <= w)
				answer = max(answer, j) ;
			//debug(answer);
		}
	}
	
	cout << answer << endl ;
	return 0;
}




Measured memory_bytes: 79232
s = input()

od = ["R","U","D"]
ev = ["L","U","D"]

b = False
for i in range(len(s)):
  if i%2==1 and (s[i] not in ev):
      b = True
      break
  elif i%2==0 and (s[i] not in od):
      b = True
      break

if b:
  print("No")
else:
  print("Yes")


Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
#define pb         push_back

const int N = 300;
const double inf = 1000;
const double eps=1e-10;

double cost[N][N];
double dp[N][N];

double le(vector<double> &tmp,double tar){
  int l=0,r=tmp.size()-1;
  double ret=-inf;
  while(l <= r){
    int mid=(l+r)/2;
    if (fabs(tmp[mid]-tar)<eps)return tmp[mid];
    else if (tmp[mid] > tar)r=mid-1;
    else l=mid+1,ret=tmp[mid];
  }
  return ret;
}

double ge(vector<double> &tmp,double tar){
  int l=0,r=tmp.size()-1;
  double ret=inf;
  while(l <= r){
    int mid=(l+r)/2;
    if (fabs(tmp[mid]-tar)<eps)return tmp[mid];
    else if (tmp[mid] > tar)r=mid-1,ret=tmp[mid];
    else l=mid+1;
  }
  return ret;
}

void pre(int n,double *in,double div,int L){
  rep(i,n){
    REP(j,i+1,n){
      double maxi=0;
      double mini=10000000;
      cost[i][j]=0;
      for(int k=i;k<=j;k++){
	mini=min(mini,in[k]);
	maxi=max(maxi,in[k]);
      }
      double tmp=(maxi-mini)/div;
      vector<double> hoge;
      REP(k,1,(1<<L)+1){
	hoge.pb(mini+(k-1)*tmp);
      }
      sort(hoge.begin(),hoge.end());
      for(int k=i;k<=j;k++){
	double a=le(hoge,in[k]);
	double b=ge(hoge,in[k]);
	a=(a-in[k])*(a-in[k]);
	b=(b-in[k])*(b-in[k]);
	cost[i][j]+=min(a,b);
      }
    }
  }
}

double solve(int n,int M){
  rep(i,n+1){
    rep(j,M+1)dp[i][j]=inf;
  }
  dp[0][0]=0;
  REP(i,2,n+1){
    REP(j,1,M+1){
      rep(k,i-1){
	dp[i][j]=min(dp[i][j],dp[k][j-1]+cost[k][i-1]);
      }
    }
  }
  return dp[n][M];
}

main(){
  //test();
  int n,M,L;
  double in[N];
  while(cin>>n>>M>>L && n){
    rep(i,n)cin>>in[i];
    pre(n,in,(1<<L)-1,L);
    printf("%.7lf\n",solve(n,M));
  }
  return false;
}

Measured memory_bytes: 2192