akhauriyash/Code-Regression huggingface dataset:
import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def v(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")
al = "abcdefghijklmnopqrstuvwxyz"

d,t,s = I()

a = d/s

if a <= t:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 10500
#include <string>
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <math.h>
 
using namespace std;
int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
 
	string S,T;
    int s,sum;
	cin >> S >> T;
    s = S.size();
    for(int i=0; i<s;i++){
      if(S[i]==T[i]){
        sum++;
      }
    }
    if(sum==s){
      cout << "Yes" << "\n";
    }else{
      cout << "No" << "\n";
    }
  
}

Measured memory_bytes: 3608
fn input() -> String {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    buf.trim().to_string()
}

fn main() {
    let line = &input();
    let seg: Vec<i32> = line
        .split_whitespace()
        .map(|s| s.parse::<i32>().unwrap())
        .collect();
    divide(seg);
}

fn divide(v: Vec<i32>) {
    println!("{} {} {}", v[0] / v[1], v[0] % v[1], v[0] as f64 / v[1] as f64)
}


Measured memory_bytes: 5048
#include<bits/stdc++.h>
/*
g++ -std=c++11 -Wall -g -fsanitize=undefined -D_GLIBCXX_DEBUG abc/abc100/c.cpp
*/
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define SZ(x) ((int)(x).size())
#define INF (1e16)
typedef long long ll;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);//おまじないでcin, cout早くする
    int N;
    cin >> N;
    ll a[N];
    rep(i, N){
        cin >> a[i];
    }
    ll cnt = 0;
    rep(i, N){
        while(a[i] % 2 == 0){
            cnt++;
            a[i] /= 2;
        }
    }
    cout << cnt << "\n";
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <math.h>
#include <algorithm>
#include <queue>
#include <map>
#include <list>
//#include <bits/stdc++.h>


using namespace std;

#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)
typedef long long ll;

main(){
    int n, a, b;
    cin >> n >> a >> b;
    if(n*a <= b){cout << n*a << endl;}
    else {cout << b << endl;} 
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<tuple>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
typedef pair<P,int> PP;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define Per(i,sta,n) for(int i=n-1;i>=sta;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
int dx[2]={1,0};
int dy[2]={0,1};

int h,w;
string s[110];
int S[110][110];
int d[110][110];

void solve(){
    cin >> h >> w;
    rep(i,h){
        cin >> s[i];
    }
    Rep(i,1,w) S[0][i]=-1;
    rep(i,h){
        rep(j,w){
            if(s[i][j]=='#') S[i+1][j]=1;
        }
    }
    rep(i,h+1){
        rep(j,w){
            d[i][j]=mod;
        }
    }
    deque<PP> que={};
    que.push_back(PP(P(0,0),0));
    while(!que.empty()){
        int y=que[0].first.first,x=que[0].first.second,l=que[0].second;
        que.pop_front();
        if(d[y][x]!=mod) continue;
        d[y][x]=l;
        //cout << y << " " << x << " " << d[y][x] << endl;
        rep(k,2){
            int ny=y+dy[k],nx=x+dx[k];
            if(ny>=h+1 && nx>=w) continue;
            if(S[ny][nx]==-1) continue;
            if(S[y][x]==0 && S[ny][nx]==1){
                //cout << "a " << ny << " " << nx << endl;
                que.push_back(PP(P(ny,nx),l+1));
            } 
            else{
                //cout << "b " << ny << " " << nx << endl;
                que.push_front(PP(P(ny,nx),l));
            }
        }
    }
    // rep(i,h+1){
    //     rep(j,w){
    //         cout << d[i][j] << " ";
    //     }
    //     cout << "" << endl;
    // }
    cout << d[h][w-1] << endl;
}

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

Measured memory_bytes: 384
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] p = new int[n];
        int max = 0;
        int sum = 0;
        for (int i = 0; i < n; i++) {
            p[i] = sc.nextInt();
            max = Math.max(max, p[i]);
            sum += p[i];
        }

        System.out.println(sum - max / 2);
    }
}


Measured memory_bytes: 21844
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    //入力受け取り
    int n = sc.nextInt();
    String s = sc.next();
    char[] c = s.toCharArray();
    
    //アルファベット生成
    char[] alpha = new char[26];
    char fir = 'A';
    for(int i=0; i<26; i++){
      alpha[i] = fir++;
    }
    
    for(int i=0; i<s.length(); i++){
      for(int j=0; j<26; j++){
        if(c[i] == alpha[j]){
          if(j + n < 26){
            c[i] = alpha[j+n];
            break;
          }else{
            int k = (j+n) - 26;
            c[i] = alpha[k];
            break;
          }
        }
      }
    }
    
    for(int i=0; i<s.length(); i++){
      System.out.print(c[i]);
    }
  }
}


Measured memory_bytes: 27860
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,i;
  string G;
  G="A";
  cin>>N;
  for (i=0;i<N;i++){
    string S;
    cin>>S;
    if (S=="P")
      continue;
    if (S=="W")
      continue;
    if (S=="G")
      continue;
    if (S=="Y"){
      G="Y";
      continue;
    }
  }
  
  if (G=="A")
    cout<<"Three"<<endl;
  if (G=="Y")
    cout<<"Four"<<endl;
}
  
    

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <random>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <sstream>
#include <bitset>
#include <cassert>
#include <fstream>
#include <queue>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
	#define DBG(X) cout << #X << "=" << (X) << '\n';
	#define SAY(X) cout << (X) << '\n';
#else
	#define DBG(X)
	#define SAY(X)
#endif
 
using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld  = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF  = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for(auto el: v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for(auto& elem: ret) cin >> elem; return ret; }

const int MAXN = (int)1e5 + 777;
string S;
int n, m;

pii tree[2 * MAXN];
int pa[MAXN];

void build() {
	for(int i = 0; i < n; ++i) {
		tree[n + i] = make_pair(INT_INF, -i);
	}

	for(int i = n - 1; i > 0; --i) {
		tree[i] = min(tree[2 * i], tree[2 * i + 1]);
	}
}

void change(int pos, pii val) {
	pos += n;
	tree[pos] = val;

	for(; pos > 1; pos /= 2) {
		tree[pos / 2] = min(tree[pos], tree[pos ^ 1]);
	}
}

pii get(int l, int r) {
	l += n;
	r += n + 1;
	pii rez = make_pair(INT_INF, INT_INF);

	while(l < r) {
		if(l & 1) {
			rez = min(rez, tree[l++]);
		}

		if(r & 1) {
			rez = min(rez, tree[--r]);
		}

		l /= 2;
		r /= 2;
	}

	return rez;
}

void solve() {
	cin >> n >> m >> S;
	reverse(S.begin(), S.end());

	++n;
	build();
	change(0, make_pair(0, 0));
	DBG(get(0, 1));

	for(int i = 0; i < n; ++i) {
		pa[i] = -INT_INF;
	}

	for(int i = 1; i < n; ++i) {
		if(S[i] == '0') {
			int j = max(0, i - m);
			auto best = get(j, i);
			int old = tree[i + n].first;

			DBG(j); DBG(i);
			DBG(best);

			if(best.first + 1 < old) {
				change(i, make_pair(best.first + 1, -i));
				pa[i] = -best.second;
			} else if(best.first + 1 == old) {
				pa[i] = max(pa[i], -best.second);
			}
		}
	}

	if(get(n - 1, n - 1).first < INT_INF) {
		vector<int> answ;
		int cur = n - 1;

		while(cur != 0) {
			answ.push_back(cur - pa[cur]);
			DBG(pa[cur]);
			cur = pa[cur];
		}

		cout << answ << '\n';
	} else {
		cout << NIL << '\n';
	}
}

int main() {
	fast_io();
	solve();

	return 0;
}


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

ll dp[100100];
bool vis[100100];
ll n, k, h[100100];

int main() {
    ios::sync_with_stdio(false);
    cin >> n >> k;
    for (int i = 1; i <= n; ++i) cin >> h[i];

    dp[1] = 0;
    for (int pos = 2; pos <= n; ++pos) {
        ll p = 2e9;
        for (int j = pos - 1; j >= 1 && j >= pos - k; --j)
            p = min( p, dp[j] + abs(h[pos] - h[j]) );
        dp[pos] = p;
    }

    cout << dp[n] << endl;
    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
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; }
// ---------------------------------------------------------------------------
 
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N,M,L;
    cin >> N >> M >> L;
    vector<vector<ll>> dist(N,vector<ll> (N,INF));
    for(int i=0; i<N; i++){
        dist[i][i] = 0;
    }
    for(int i=0; i<M; i++){
        int A,B,C;
        cin >> A >> B >> C;
        A--;
        B--;
        dist[A][B] = C;
        dist[B][A] = C;
    }
    for(int k=0; k<N; k++){
        for(int i=0; i<N; i++){
            for(int j=0; j<N; j++){
                chmin(dist[i][j],dist[i][k]+dist[k][j]);
            }
        }
    }
    vector<vector<int>> fuel(N, vector<int> (N,inf));
    for(int i=0; i<N; i++){
        for(int j=0; j<N; j++){
            if(i == j) fuel[i][j] = 1;
            else if(dist[i][j] <= L) fuel[i][j] = 1;
        }
    }
    for(int k=0; k<N; k++){
        for(int i=0; i<N; i++){
            for(int j=0; j<N; j++){
                chmin(fuel[i][j],fuel[i][k]+fuel[k][j]);
            }
        }
    }
    int Q;
    cin >> Q;
    for(int i=0; i<Q; i++){
        int s,t;
        cin >> s >> t;
        s--;
        t--;
        if(fuel[s][t] == inf){
            cout << -1 << enld;
        }else{
            cout << fuel[s][t] - 1 << enld;
        }
    }
    return 0;
}

Measured memory_bytes: 1664
package main

import (
	"fmt"
)

func main() {
	var W, H, x, y float64
	fmt.Scan(&W, &H, &x, &y)

	result := W * H / 2
	resultCut := 0
	if x == W/2 && y == H/2 {
		resultCut = 1
	}

	fmt.Println(result, resultCut)

}


Measured memory_bytes: 512
#include <stdio.h>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cassert>

using namespace std;
typedef long long LL;
typedef pair<int,int> pii;

const int MAXN = 1e5+1;
const int MOD = 1e9 + 7;
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define FAILNO {cout << "NO\n"; return 0;}
#define FAIL1 {cout << "-1\n"; return 0;}

int N;
int A[MAXN];
int ans;

int main() {
#ifdef OJ
	freopen("input.txt", "rt", stdin);
	//freopen("output.txt", "wt", stdout);
#endif
	ios::sync_with_stdio(false);
    cin.tie(0);

	cin >> N;
	for (int i = 0; i < N; i++) cin >> A[i];
	sort(A,A+N);

	int a = A[N/2-1];
	int b = A[N/2];

	cout << b-a << endl;

	return 0;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int n;
int main()
{
    cin>>n;
    bool f=false;
    for(int i=0;i<=25;i++){
        for(int j=0;j<=14;j++){
            if(4*i+7*j==n){
                f=true;
                break;
            }
        }
    }
    if(f)
        cout<<"Yes";
    else
        cout<<"No";
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define ld  long double
#define endl '\n'
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const ll MOD = (ll)1e9+7;
const double PI = 3.141592653589793238463;
const int MAXN = 1000030;
int main() {
   int x;
   cin>>x;
   if(x==1)
   cout<<0<<endl;
   else{
       cout<<1<<endl;
   }
    return 0;
}

Measured memory_bytes: 3612
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>

using namespace std;
 
typedef pair<int, int> paii;
typedef long long ll;

bool cmpr(char l, char r){
	if( abs(l-r) == abs('('-')') )
		return true;
	if( abs(l-r) == abs('{'-'}') )
		return true;
	if( abs(l-r) == abs('['-']') )
		return true;
	if( l==r && (l == 'i' || l == 'w') )
		return true;
	
	return false;
}

int main(){
	
	string str;
	cin >> str;
	
	int n = str.size();
	int ppvt = n/2;
	int npvt = ppvt+(n%2==0?-1:0);
	int res = 0;
	
	for(; npvt >= 0; --npvt){
		
		if( !cmpr(str[ppvt], str[npvt]) )
			res++;
		
		ppvt++;
	}
	
	cout << res << endl;
	
	return 0;
}

Measured memory_bytes: 1180
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <climits>
#include <cmath>
#include <utility>
#include <iomanip>
#include <string>
#include <cstdlib>

using namespace std;

const int maxn = 10002;
const int maxd = 102;
const int mo = 1e9 + 7;

string K;

int n, D, f[maxn][maxd][2];

void add(int &a, int b) {
	a += b;
	a %= mo;
}

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	cin >> K;
	cin >> D;

	n = K.length();
	reverse(K.begin(), K.end());

	int sum = 0;

	f[0][0][0] = f[0][0][1] = 1;
	for (int i = 1; i <= n; ++i) {
		int cur = K[i-1] - '0';
		sum += cur;

		for (int j = 0; j < D; ++j) {
			for (int t = 0; t <= 9; ++t) {
				add(f[i][(j+t)%D][0], f[i-1][j][0]);

				if (t < cur)
					add(f[i][(j+t)%D][1], f[i-1][j][0]);
				else
					if (t == cur)
						add(f[i][(j+t)%D][1], f[i-1][j][1]);
			}
		}
	}

	cout << (f[n][0][1]-1+mo)%mo << endl;

	return 0;
}

Measured memory_bytes: 8192
#include <iostream>
using namespace std;
#define MAX 500000
#define SENTINEL 2000000000

int L[MAX / 2 + 2], R[MAX / 2 + 2];
int cnt;

void merge(int A[], int n, int left, int mid, int right)
{
    int n1 = mid - left;
    int n2 = right - mid;
    for (int i = 0; i < n1; i++)
        L[i] = A[left + i];
    for (int i = 0; i < n2; i++)
        R[i] = A[mid + i];

    L[n1] = R[n2] = SENTINEL;
    int i = 0, j = 0;
    for (int k = left; k < right; k++)
    {
        cnt++;
        if (L[i] <= R[j])
        {
            A[k] = L[i++];
        }
        else
        {
            A[k] = R[j++];
        }
    }
}

void mergeSort(int A[], int n, int left, int right)
{
    if (left + 1 < right)
    {
        int mid = (left + right) / 2;
        mergeSort(A, n, left, mid);
        mergeSort(A, n, mid, right);
        merge(A, n, left, mid, right);
    }
}

int main()
{
    int A[MAX], n, i;
    cnt = 0;

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

    mergeSort(A, n, 0, n);

    for (i = 0; i < n; i++)
    {
        if (i)
            cout << " ";
        cout << A[i];
    }
    cout << endl;
    cout << cnt << endl;
    return 0;
}


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

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

int main()
{
    int h, w, k;
    cin >> h >> w >> k;
    int sy, sx;
    vector<vector<int>> a(h, vector<int>(w, -1));
    for(int i = 0; i < h; i++) {
        for(int j = 0; j < w; j++) {
            char c;
            cin >> c;
            if(c == 'S') sy = i, sx = j;
            if(c == '#') a[i][j] = -2;
        }
    }
    vector<pair<int, int>> memo;
    queue<pair<int, int>> q;
    q.push({sy, sx});
    memo.push_back({sy, sx});
    a[sy][sx] = 0;
    while(!q.empty()) {
        int y = q.front().first;
        int x = q.front().second;
        q.pop();
        for(int i = 0; i < 4; i++) {
            int ny = y + dy[i];
            int nx = x + dx[i];
            if(ny < 0 || ny >= h || nx < 0 || nx >= w || a[ny][nx] != -1) continue;
            a[ny][nx] = a[y][x] + 1;
            if(a[ny][nx] <= k) {
                memo.push_back({ny, nx});
                q.push({ny, nx});
            }
        }
    }
    int ans = 1001001001;
    for(auto e : memo) {
        int d = min({e.first, e.second, h - 1 - e.first, w - 1 - e.second});
        ans = min(ans, (d + k - 1) / k + 1);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 14004
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define WHATIS(x) cout << #x << " is " << x << endl;
#define ERROR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, int> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}

const ll MODBASE = 1000000007LL;
const int MAXN = 200010;
const int MAXM = 200010;
const int MAXK = 110;
const int MAXQ = 200010;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    int k, x;
    cin >> k >> x;
    FOR(i,x-k+1,x+k-1) cout << i << ' ';
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long int LLI;
int main()
{
  	int n, m, tmp, next;
  	cin >> n >> m;
  	int arr[50]{};
  	for(int i = 0; i < m; i++)
    {
      cin >> tmp >> next;
      arr[tmp-1]++;
      arr[next-1]++;
    }
  	for(int i = 0; i < n; i++)
      cout << arr[i] << "\n";
  
	return 0;
}

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

#define rep(i, a, b) for (ll i = (a); i < (b); i++)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;

ll N;
vector<vector<ll>> edges;
vector<ll> dist_fenn, dist_sunu;

void dfs_fenn(ll cur, ll d){
    if (dist_fenn[cur] != -1)
        return;
    dist_fenn[cur] = d;
    for (auto e: edges[cur]){
        dfs_fenn(e, d+1);
    }
}

void dfs_sunu(ll cur, ll d){
    if (dist_sunu[cur] != -1)
        return;
    dist_sunu[cur] = d;
    for (auto e: edges[cur]){
        dfs_sunu(e, d+1);
    }
}

signed main() {
    cin>>N;
    edges.resize(N);
    dist_sunu.resize(N, -1);
    dist_fenn.resize(N, -1);
    rep(i,0,N-1){
        ll a,b;
        cin>>a>>b;
        a--;
        b--;
        edges[a].push_back(b);
        edges[b].push_back(a);
    }

    dfs_fenn(0, 0);
    dfs_sunu(N-1, 0);

    ll r = 0;
    rep(i,0,N){
        if (dist_fenn[i] <= dist_sunu[i])
            r++;
    }

    if (r > N/2)
        cout<<"Fennec"<<endl;
    else
        cout<<"Snuke"<<endl;

    return 0;
}


Measured memory_bytes: 10368
#include<stdio.h>
using namespace std;
#include <bits/stdc++.h>
int main()
{
    int n,m,i,j=0,k=0,l,p=0;
    scanf("%d %d",&n,&m);
    int a[m],b[m],c[m],d[m];
    for(i=0;i<m;i++)
    {
        scanf("%d %d",&a[i],&b[i]);
        if(a[i]==1)
        {
            c[k]=b[i];
             k++;
        }
       if(b[i]==n)
       {
           d[j]=a[i];
           j++;
       }
    }
    set<int>s;
    for(i=0;i<j;i++)
    {
        s.insert(d[i]);
    }
    set<int>::iterator it;
     //qsort(c, k, sizeof(int), cmpfunc);
     //qsort(d, j, sizeof(int), cmpfunc);
     for(i=0;i<k;i++)
     {
            it=s.find(c[i]);
            if(it!=s.end()){
            printf("POSSIBLE\n");
            return 0;}
     }
    printf("IMPOSSIBLE\n");
 return 0;
}


Measured memory_bytes: 7936
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<queue>
#include<set>
#include<map>
#include<stack>
using namespace std;
typedef long long LL;
const int N=1e6;
int gi() {
	int w=0;bool q=1;char c=getchar();
	while ((c<'0'||c>'9') && c!='-') c=getchar();
	if (c=='-') q=0,c=getchar();
	while (c>='0'&&c <= '9') w=w*10+c-'0',c=getchar();
	return q? w:-w;
}
int main()
{
	int n=gi();
	long double ans=0,a=gi(),b=gi();
	while (n) {
		ans+=a+(n-0.5)*b;
		if (n--) {
			a+=(a+2.5*b)/(n+1);
			b+=b*2/(n+1);
		}
	}
	printf("%.10Lf\n",ans);
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <string>
#include <utility>
#include <vector>
#define REP(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;
const ll MOD = 1000000007;
using namespace std;

int main(){
    int n; cin >> n;
    int ans = n;
    REP(i, n+1){  // i円を6^p N-i円を9^pで出す
        int t = i, cnt = 0;
        while(t){cnt += t%6; t /= 6;}
        t = n-i;
        while(t){cnt += t%9; t /= 9;}
        ans = min(ans, cnt);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(100002)
input=sys.stdin.readline
n=int(input())
graph=[{} for i in range(n)]
visited=[False]*n
for i in range(n-1):
    a,b,c=map(int,input().split())
    a-=1;b-=1
    graph[a][b]=c
    graph[b][a]=c
q,k=map(int,input().split())
dist=[0]*n
def dfs(chi,par,cost):
    dist[chi]=cost
    for i in graph[chi].keys():
        if visited[i]:continue
        if i==par:continue
        visited[i]=True
        dfs(i,chi,cost+graph[i][chi])
    return
dfs(k-1,-1,0)
for i in range(q):
    x,y=map(int,input().split())
    x-=1;y-=1
    print(dist[x]+dist[y])


Measured memory_bytes: 141044
import sys
sys.setrecursionlimit(10 ** 7)

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


N = int(input())
A = [[int(x) for x in input().split()] for _ in range(N)]

A = [[-1]] + A


def check(a, q=[]):
    if not A[a]:
        return False

    b = A[a][-1]
    b_op = A[b][-1]

    ok = False
    if a == b_op:
        ok = True

        if b < a:
            a, b = b, a
        q.append((a, b))

    return ok


q = []
for i in range(1, N + 1):
    check(i, q)

q = list(set(q))

day = 0
while q:
    nq = []
    for a, b in q:
        A[a].pop()
        A[b].pop()
        check(a, nq)
        check(b, nq)

    day += 1
    q = list(set(nq))

for i in range(1, N + 1):
    if len(A[i]) != 0:
        print(-1)
        exit()

print(day)
exit()


Measured memory_bytes: 37612
#define _USE_MATH_DEFIMES
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

const int MOD = 1'000'000'007;
const int INF = 1'000'000'000; //1e9
const int NIL = -1;
const long long LINF = 1'000'000'000'000'000'000; // 1e18
const long double EPS = 1E-10;

template<class T, class S> inline bool chmax(T &a, const S &b){
    if(a < b){
        a = b; return true;
    }
    return false;
}
template<class T, class S> inline bool chmin(T &a, const S &b){
    if(b < a){
        a = b; return true;
    }
    return false;
}






std::map<long long, int> primeFactorisation_Map(long long n){
    std::map<long long, int> mp;
    for(long long i(2); i * i <= n; ++i)
        while(!(n % i)){
            ++mp[i]; n /= i;
        }
    if(n > 1) ++mp[n];
    return mp;
}

int main(){
    int N; std::cin >> N;
    long long ans(0);
    for(int i(1); i < N; ++i){
        long long a(1);
        auto pr(primeFactorisation_Map(N-i));
        for(auto [p, id]: pr){
            a *= id + 1;
        }
        ans += a;
    }
    std::cout << ans << std::endl;
    return 0;
}


Measured memory_bytes: 3628
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<utility>
#include<numeric>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<tuple>
#include<stack>
#include<queue>
#include<functional>
#include<iterator>
#include<cmath>
#include<cctype>

using namespace std;

typedef long long ll;
typedef pair<int,int> P;

const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = INF+7;

struct edge{int to,cost;};
	

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

	int n;
	cin >> n;

	bool so[n+1];
	for(int i=2;i<=n;i++){
		so[i]=true;
	}
	for(int i=2;2*i<=n;i++){
		so[2*i]=false;
	}
	for(int i=3;i<=n;i+=2){
		if(so[i]){
			for(int j=2;i*j<=n;j++){
				so[i*j] = false;
			}
		}
	}
	ll ans=1;
	ll beki=0;
	ll num = n/2;
			
//	cout << "prime:2" << "\n";
//	cout << n/2;
	
	for(int i=2;;i++){
		beki=pow(2,i);
		if(beki<=n){
			num += n/beki;
	
//			cout << " + " << n/beki;
		
		}else{
//			cout << " + 1 = " << num+1 << "\n";
			ans *= (num+1);
			ans %= MOD;
			break;
		}
	}
	for(int i=3;i<=n;i+=2){
		if(so[i]){

//			cout << "prime:" << i << "\n";
			
			num = n/i;
//			cout << num;
			for(int j=2;;j++){
				beki=pow(i,j);
				if(beki<=n){
					num+=n/beki;

//					cout << " + " << n/beki;

				}else{
					
//					cout << " + 1 = " << num+1 << "\n";
					ans *= (num+1);
					ans %= MOD;
					break;
				}
			}
		}
	}

	cout << ans << "\n";
	return 0;
}

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

#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,n) for(int i = 1; i < n; i++)
#define repll(i,n) for(ll i = 0; i < n; i++)
#define REPll(i,n) for(ll i = 1; i < n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl "\n"
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll a, const ll b){return ((a)+(b)-1)/b;}


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

  string o, e;
  cin >> o >> e;
  rep(i,min(sz(o), sz(e))) {
    cout << o[i] << e[i];
  }
  if(sz(o)-sz(e)) cout << o[sz(o)-1] << endl;
}

Measured memory_bytes: 256
#include <cstdio>
inline int getInt(){ int s; scanf("%d", &s); return s; }

#include <set>

using namespace std;

int main(){
  const int a = getInt();
  const int b = getInt();
  const int c = getInt();
  printf("%d\n", min(c, b/a));

  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iomanip>
#include <float.h>
#include <math.h>
using namespace std;
using ll = long long;


unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

class UnionFind {
public:
    vector <ll> par;
    vector <ll> siz;
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

int main() {
    ll n,kk;
    cin >> n >> kk;
    vector<pair<ll,ll>> z(n);
    for (int i = 0; i < n; i++) {
        cin >> z[i].first >> z[i].second;
    }
    ll ans = 0;
    for (int i = 0; i < 32; i++) {
        ll k = kk;
        if (!(k & (1 << i)))continue;
        k &= ~(1 << i);
        for (int j = 0; j < i;j++) {
            k |= (1 << j);
        }
        ll zans = 0;
        for (int i = 0; i < n; i++) {
            if ((k | z[i].first) == k)zans += z[i].second;
        }
        ans = max(ans, zans);
    }
    ll zans = 0;
    for (int i = 0; i < n; i++) {
        if ((kk | z[i].first) == kk)zans += z[i].second;
    }
    ans = max(ans, zans);
    cout << ans << endl;
}

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

long long maxVal(long long a, long long b){
	if(a>b) return a ; 
	return b ; 
}

int main() {
	// your code goes here
	
	long long n;
	
	cin>>n;
	
	long long  arr[n][3];
	
	for(long long  i=0;i<n;i++)
	{
		for(int j=0;j<3;j++)
		{
			cin>>arr[i][j];
		}
	}
	

	
	long long  val=0;
	
	long long ti=0;
	
	long long tv=0;
	
	for(long long i=0;i<3;i++)
	{
		long long tv=arr[0][i];
		
		if(tv>val)
		{
			val=tv;
			ti=i;
		}
	}
	

	
	for(long long i=1;i<n;i++)
	{
		
		arr[i][0]=arr[i][0]+max(arr[i-1][1],arr[i-1][2]);
		
		arr[i][1]=arr[i][1]+max(arr[i-1][0],arr[i-1][2]);
		
		arr[i][2]=arr[i][2]+max(arr[i-1][0],arr[i-1][1]);
		
	}
	
	int ans=arr[n-1][0];
	
	if(ans<arr[n-1][1])
	ans=arr[n-1][1];
	
	if(ans<arr[n-1][2])
	ans=arr[n-1][2];
	
	cout<<ans;
	
	return 0;
}

Measured memory_bytes: 2560
n, k = map(int, input().split())
a = list(map(int, input().split()))

idx = a[0]
hist = [1]
passed = [0] * n
flag = 0
for i, _ in enumerate(range(k), start=1):
    if passed[idx-1] == 1:
        hist.append(idx)
        passed[idx-1] = 1
        flag = 1
        break
    hist.append(idx)
    passed[idx-1] = 1
    idx = a[idx-1]
    
    
if flag:
    l_start, l_end = hist.index(idx), i
    surplus = (k - l_start) % (l_end - l_start)
    print(hist[l_start + surplus])
else:
    print(hist[-1])

Measured memory_bytes: 32328
// atcoder/m-solutions2020/E/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; for (auto& i: v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { for (auto& i: v) is >> i; return is; }
template<typename T> ostream& operator << (ostream& os, set<T> s) { os << "#{"; for (auto& i: s) os << i << ","; os << "}"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; for (auto& i: m) os << i << ","; os << "}"; return os; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

using lli = long long int;
using ull = unsigned long long;
using point = complex<double>;
using str = string;
template<typename T> using vec = vector<T>;

constexpr array<int, 8> di({0, 1, -1, 0, 1, -1, 1, -1});
constexpr array<int, 8> dj({1, 0, 0, -1, 1, -1, -1, 1});
constexpr lli mod = 1e9 + 7;

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.setf(ios_base::fixed);
  cout.precision(15);


  int n;
  while (cin >> n) {
    lli x[n], y[n], u[n];
    for (int i = 0; i < n; ++i) {
      cin >> x[i] >> y[i] >> u[i];
    }

    const int N = 16;
    const int BIT = 1 << N;
    const lli inf = 1LL << 60;

    static lli mnx[BIT][N];
    static lli mny[BIT][N];

    for (int bit = 0; bit < (1 << n); ++bit) {
      for (int i = 0; i < n; ++i) {
        if (bit & (1 << i)) mnx[bit][i] = mny[bit][i] = 0;
        else {
          mnx[bit][i] = abs(x[i]);
          mny[bit][i] = abs(y[i]);
        }
      }

      for (int i = 0; i < n; ++i) {
        if (bit & (1 << i)) {
          for (int j = 0; j < n; ++j) {
            unless (bit & (1 << j)) {
              setmin(mnx[bit][j], abs(x[i] - x[j]));
              setmin(mny[bit][j], abs(y[i] - y[j]));
            }
          }
        }
      }
    }

    lli mn[N];
    fill(mn, mn + N, inf);

    for (int bit = 0; bit < (1 << n); ++bit) {
      const int pc = __builtin_popcount(bit);
      for (int A = bit; 0 <= A; --A) {
        A = A & bit;
        int B = bit - A;

        lli sum = 0;
        for (int i = 0; i < n; ++i) {
          sum += min(mnx[A][i], mny[B][i]) * u[i];
        }

        setmin(mn[pc], sum);
      }
    }

    for (int i = 0; i <= n; ++i) {
      cout << mn[i] << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 11840
var lines =[];


var readline = require("readline");
var rl = readline.createInterface({
  input:  process.stdin,
  output: process.stdout
});

rl.on('line',function(x){
  lines.push(x);
});

rl.on('close',function(){

  var tmp = lines[0].split(" ");
  
  var a = Number(tmp[0]);
  var b = Number(tmp[1]);
  var k = Number(tmp[2]);
  var counter = 0;


    for(var i=100;i>=1;i--){
        if(a%i === 0 && b%i === 0){counter++;}
        if(counter === k){console.log(i); break;}
    }

});

Measured memory_bytes: 11596
val = []
val = [int(x) for x in input().split()]
for i in range(2):
    for y in range(len(val)-1):
        if val[y] > val[y+1]:
            tmp = val[y]
            val[y] = val[y+1]
            val[y+1] = tmp
print(val[0],val[1],val[2])


Measured memory_bytes: 5604
package main
import "fmt"
func main() {
  var r,g,b,n,m int
  fmt.Scan(&r,&g,&b,&n)
  if r < g { r,g = g,r }
  if r < b { r,b = b,r }
  if g < b { g,b = b,g }
  for i:=0;i<=n/r;i++ {
    for j:=0;j<=(n-i*r)/g;j++ {
      if (n-i*r-j*g)%b == 0 { m++ }
    }
  }
  fmt.Println(m)
}

Measured memory_bytes: 512
//#include <bits/stdc++.h>
#include <unordered_set>
#include <map>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <iostream>
#include <istream>
#include <ostream>
#include <sstream>

using namespace std;

/* macros */
#define all(v)			((v).begin()), ((v).end())
#define SIZE(v)			((int)((v).size()))
#define LOG(x)			log((double)x)
#define TOLOWER(x)          transform(all(x),x.begin(),::tolower)
#define TOUPPER(x)          transform(all(x),x.begin(),::toupper)
#define ROUND(x,m)			(round((double)x/m)*m)
#define DIGITS(x)			(floor(log10((double)x))+1)
#define READSTR(x)			getline(cin,x)
#define sort_g(a,b)              sort(a, b, greater<int>());
#define IOS() ios_base::sync_with_stdio(0);cin.tie(NULL);
#define REP(i, n) for (int i = 0; i < n; i++)
#define FILE_INPUT() 	freopen( "input.txt", "r", stdin)
#define FILE_OUTPUT()   freopen( "output.txt", "w", stdout)

/*typedefs*/
typedef long long ll;

/*functions*/
bool myCmp(pair<int,int> &p1 , pair<int,int>&p2)
{
    return p1.first > p2.first;
}
unsigned long long
choose(unsigned long long n, unsigned long long k) {
    if (k > n) {
        return 0;
    }
    unsigned long long r = 1;
    for (unsigned long long d = 1; d <= k; ++d) {
        r *= n--;
        r /= d;
    }
    return r;
}
int toInt(string str) {
    int num;
    istringstream iss(str); //put string in input stream
    iss>>num; return num; //read from stream as integer
}

template <class T> string toStr(T par) {
    ostringstream oss;  //output stream string
    oss<<par;    //write par to the stream
    return oss.str(); //return string of output
}

const int MAXN = 10;
int arr[MAXN][MAXN] = {0};
bool lut[101] = {0};
int prei[3] = {0};
int prej[3] = {0};
int diag1 = 0;
int diag2 = 0;
int main() {
    IOS();
    REP(i,3)
    {
        REP(j,3)
        {
            cin>>arr[i][j];
        }
    }
    int n;
    cin>>n;
    for(int i = 0 ; i < n ; ++i)
    {
        int b;
        cin>>b;
        lut[b] = true;
    }
    for(int i = 0 ; i < 3 ; ++i)
    {
        for(int j = 0 ; j < 3 ; ++j)
        {
            if(!lut[arr[i][j]])
            {
                prei[i]++;
                prej[j]++;
                if(i == j )diag1++;
                if(abs(i-2) == j) diag2++;
            }
        }
    }
    for(int i = 0 ; i < 3 ; i++)
    {
        if( ( prei[i] == 0 ) || ( prej[i] == 0))
        {
            cout<<"Yes\n";
            return 0;
        }
    }
    if( (diag1 == 0) || (diag2 ==0) )
    {
        cout<<"Yes\n";
    }
    else
    {
        cout<<"No\n";
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define mkp(a, b) make_pair(a, b)
#define pb(t) push_back(t)
#define ft first
#define sc second
#define pt(num) cout << num << "\n"
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define chmax(a, b) (a<b ? a=b : 0)
#define chmin(a, b) (a>b ? a=b : 0)
#define INF 1000000000000000000
#define MOD 1000000007LL
#define MAX 101010
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef map<ll, ll> Map;




int main(void) {
    ll N;
    cin >> N;
    double ans=0;
    
    for(ll i=0; i<N; i++) {
        double x;
        string u;
        cin >> x >> u;
        
        if(u=="BTC") {
            ans+=380000*x;
        }else {
            ans+=x;
        }
    }
    
    printf("%.8f\n", ans);
    
}




Measured memory_bytes: 256
def judge(r):
  pa = pb = 0
  for c in r[1:]:
    if c == "A":
      pa += 1
    else:
      pb += 1
  if pa < pb:
    print(pa, pb + 1)
  else:
    print(pa + 1, pb)
while True:
  r1 = input()
  if r1 == "0":
    break
  judge(r1)
  judge(input())
  judge(input())


Measured memory_bytes: 5556
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<cmath>
#include<ctime>
#include<complex>

using namespace std;

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

int main(){

	signed long int N,a,c=0;
	cin >> N;
	rep(i,N){
		cin >> a;

			for(signed long int j=1;2*j*j+2*j<=a;j++){
				if((a-j)%(2*j+1)==0){
					c++; break;
				}
			}
	}

	cout << N-c << endl;

	return 0;
}

Measured memory_bytes: 1160
#include <cstdio>
#include <string>

using namespace std;

int main() {
    char buf[1<<7];
    scanf("%s", buf);
    string s(buf); s+=s;

    scanf("%s", buf);
    string p(buf);

    printf("%s\n", s.find(p)!=string::npos? "Yes":"No");
    return 0;
}

Measured memory_bytes: 2764
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);
static const int INF = 1e9+7;
#define REP(i,n) for (int i = 0; i <(n); ++i)
//debug 
#ifdef _DEBUG
#define debug(var)  do{cout << #var << " :";view(var);}while(0)
#else
#define debug(...)
#endif
template<typename T> void view(T e){cout << e << endl;}
template<typename T> void view(const vector<T>& v){for(const auto& e : v){ cout << e << " "; } cout << endl;}
template<typename T> void view(const vector<vector<T> >& vv){ for(const auto& v : vv){ view(v); } }


int main(){
  string s, t;
  cin >> s >> t;
  sort(ALL(s));
  sort(RALL(t));
  if(s < t) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

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

using namespace std;
using ll = long long;

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << #x << ": " << x << endl;

int H, W;
int d[]={1, 0, -1, 0, 1};

bool ok(int y, int x) {
    return y >= 0 and y < H and x >= 0 and x < W;
}

int main() {
    cin >> H >> W;
    vector<string> grid(H);
    for (int i = 0; i < H; i++)cin >> grid[i];
    vector<vector<int>> cnt(H, vector<int>(W, 0));

    queue<pair<int, int>>q;
    ll ans = 0;
    for (int y = 0; y < H; y++) {
        for (int x = 0; x < W; ++x) {
            if(grid[y][x]=='#') {
                cnt[y][x]=-1;
                for (int i = 0; i < 4; ++i) {
                    int ny = y + d[i], nx = x + d[i + 1];
                    if (!ok(ny, nx))continue;
                    if(grid[ny][nx]=='.'){
                        if(cnt[ny][nx]==0){
                            cnt[ny][nx]=1;
                            q.push({ny, nx});
                        }
                    }
                }
            }
        }
    }

    while(!q.empty()){
        auto p = q.front();
        q.pop();
        int y = p.first, x=p.second;
        for (int i = 0; i < 4; ++i) {
            int ny = y + d[i], nx = x + d[i + 1];
            if (!ok(ny, nx))continue;
            if(grid[ny][nx]=='.'){
                if(cnt[ny][nx]==0){
                    cnt[ny][nx]=cnt[y][x]+1;
                    q.push({ny, nx});
                }
            }
        }
    }

    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            if(cnt[i][j]!=-1)ans=max(ans, (ll)cnt[i][j]);
        }
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 9216
#逆にしないと別の組み合わせができてしまう．（動的計画法はかしこい）
S = input()
word = ["dream","dreamer","erase","eraser"]

S = S[::-1] #入力文字を反転
for i in range(len(word)): word[i] = word[i][::-1] #4つのワードを反転

while True:
    for i in range(len(word)):
        flag2 = False
        if word[i] == S[:len(word[i])]:
            flag2 = True
            S = S[len(word[i]):]
            break
    if S == "":
        print("YES")
        break #全て一致して空文字になる
    elif flag2 == False:
        print("NO")
        break #一致しなかったとき

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define im 2147483647
#define lm 9223372036854775807
#define ll long long
#define vb vector<bool>
#define vi vector<int>
#define vl vector<long long>
#define vvi vector<vector<int>>
#define ii pair<int, int>
#define ff first
#define ss second
#define _graph map<int, vector<int>>
#define lower_str(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
#define upper_str(s) transform(s.begin(), s.end(), s.begin(), ::toupper)
#define debug(index, num) cout << "Case #" << index << ": " << num << endl
#define nmax(an, na) an = max(an, na)
#define nmin(an, na) an = min(an, na)
#define rep(i, a, b) for (int i = a; i < b; i++)
#define rep2(i, a, b) for (int i = a; i <= b; i++)
#define repp(i, a, b) for (int i = a; i >= b; i--)
#define repp2(i, a, b) for (int i = a-1; i >= b; i--)
#define be(x) x.begin(), x.end()
#define rbe(x) x.rbegin(), x.rend()
#define pb push_back
#define IO                           \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL)

int main () {
    IO;
    int a, b, c, d;
    cin >> a >> b;
    c = a + b;
    d = a;
    cout << floor((c-3)/(d-1)); 
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <assert.h>
#include <algorithm>

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

    int32_t H,W;
    std::cin >> H >> W;
    char cells[H][W];
    for(int32_t h = 0; h < H; h++){
        for(int32_t w = 0; w < W; w++){
            std::cin >> cells[h][w];
        }
    }
    
    for(int32_t h = 0; h < H; h++){
        for(int32_t w = 0; w < W; w++){
            if(cells[h][w] == '#'){
                if(h > 0 && cells[h-1][w] == '#') continue;
                if(h < H - 1 && cells[h+1][w] == '#') continue;
                if(w > 0 && cells[h][w-1] == '#') continue;
                if(w < W - 1 && cells[h][w+1] == '#') continue;
                std::cout << "No" << std::endl;
                return 0;
            }
        }
    }
    std::cout << "Yes" << std::endl;


    return 0;

}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<algorithm>
#include<cmath>
#include<math.h>
#include<iomanip>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<utility>
#include<stack>
#include<queue>
#include<sstream>
#include<bitset>
#include<cstdio>
#include<stdio.h>
#include<cstring>
#include <stdio.h>
#include <math.h>
#include <cmath>
#include <unordered_map>
using namespace std;
void fast()
{
	std::ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
}
void in_out_txt()
{
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
}
int main()
{
	//in_out_txt();
	fast();
	int a,b,c;
	cin>>a>>b>>c;
	if(a+b>=c)
		cout<<"Yes\n";
	else
		cout<<"No\n";
	//system("pause");
	return 0;
}

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

int p[14][14];

int main()
{
  int x, y, s;

  while (scanf("%d,%d,%d", &x, &y, &s) != EOF){
    p[x + 2][y + 1] += 1;
    p[x + 1][y + 2] += 1;
    p[x + 2][y + 2] += 1;
    p[x + 3][y + 2] += 1;
    p[x + 2][y + 3] += 1;

    if (s >= 2){
      p[x + 1][y + 1] += 1;
      p[x + 3][y + 1] += 1;
      p[x + 1][y + 3] += 1;
      p[x + 3][y + 3] += 1;
    }

    if (s == 3){
      p[x][y + 2] += 1;
      p[x + 2][y] += 1;
      p[x + 4][y + 2] += 1;
      p[x + 2][y + 4] += 1;
    }
  }

  int cnt, max;

  cnt = max = 0;

  for (int i = 2; i < 12; i++){
    for (int j = 2; j < 12; j++){
      if (p[i][j] == 0){
        cnt++;
      }
      if (max < p[i][j]){
        max = p[i][j];
      }
    }
  }
  cout << cnt << endl << max << endl;
}

Measured memory_bytes: 1208