akhauriyash/Code-Regression huggingface dataset:
// May this submission get accepted
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define STEP(i, is, ie, step) for (long long i=(is), i##_end=(ie), i##_step = (step); i<=i##_end; i+=i##_step)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
template<class T> bool chmax(T &a, const T &b) { if (a < b) {a = b; return true;} return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) {a = b; return true;} return false; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) do { cerr << "[DEBUG] " #q ": ["; REP(DUMPALL_ITR, (q).size()) { cerr << (q)[DUMPALL_ITR] << (DUMPALL_ITR == DUMPALL_ITR_len-1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; } while (false)
template<class T> T gcd(T a, T b) { if (a < b) std::swap(a, b); while (b) std::swap(a %= b, b); return a; }
template<class T> T lcm(const T a, const T b) { return a / gcd(a, b) * b; }

// gcc拡張マクロ
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
#define DANCE_ long
#define ROBOT_ unsigned
#define HUMAN_ signed
using  ll = DANCE_ HUMAN_ DANCE_;
using ull = DANCE_ ROBOT_ DANCE_;
using  ld = long double;
using namespace std;

// 標準入出力
struct inp {
    size_t sz;
    inp(size_t _sz = 1) : sz(_sz) {}
    template <typename T> operator T () const { T a; cin >> a; return a; }
    template <typename T> operator vector<T> () const { vector<T> a(sz); for (size_t i = 0; i < sz; i++) cin >> a[i]; return a; }
    template <typename T, typename U> operator pair<T, U> () const { T f; U s; cin >> f >> s; return pair<T, U>(f, s); }
};
inp inp1; // input one
template <typename T> void say(T &x, char end = '\n') { cout << x << end; }
template <typename T> void say(vector<T> &x, char sep = ' ', char end = '\n') { for (size_t i = 0, sz = x.size(); i < sz; i++) { cout << x[i] << (i == sz-1 ? end : sep); } }

// モジュール


// 処理内容
int main() {
    
    ios::sync_with_stdio(false); // stdioを使うときはコメントアウトすること
    cin.tie(nullptr);            // インタラクティブ問題ではコメントアウトすること
    
    ll n = inp1;
    vector<pair<string, ll>> st(n);
    REP(i, n) {
        cin >> st[i].first >> st[i].second;
    }
    string x = inp1;
    ll term = 0;
    ll ans = 0;
    REP(i, n) {
        ans += term * st[i].second;
        if (st[i].first == x) {
            term = 1;
        }
    }
    say(ans);
    
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <queue>

using namespace std;

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15);
  }
} initializer;

template<typename T> istream& operator>>(istream &s, vector<T> &v) {
  for (T &t : v) s >> t;
  return s;
}

template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
  for (const T &t : v) s << t << endl;
  return s;
}

template<typename T> bool chmin(T& a, T b) {return a > b ? a = b, true : false;}

template<typename T> bool chmax(T& a, T b) {return a < b ? a = b, true : false;}

int main() {
  int n;
  cin >> n;
  vector<int> t(n);
  for (int i = 0; i < n - 1; ++i) {
    int c, s, f;
    cin >> c >> s >> f;
    for (int j = 0; j <= i; ++j) {
      for (chmax(t[j], s); t[j] % f; ++t[j]);
      t[j] += c;
    }
  }
  cout << t;
}



Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
typedef long long ll;

int main()
{
  vector<int> w(10), k(10);
  FOR(i,0,10) cin >> w[i];
  FOR(i,0,10) cin >> k[i];
  sort(w.rbegin(), w.rend());
  sort(k.rbegin(), k.rend());
  int a = w[0]+w[1]+w[2];
  int b = k[0]+k[1]+k[2];
  cout << a << " " << b << endl;
  return 0;
}

Measured memory_bytes: 3108
def main():
    N, M = map(int, input().split())

    A = [[] for i in range(N)]
    for i in range(N):
        A[i] = list(map(int, input().split()))

    B = [[0] for i in range(M)]
    for i in range(M):
        B[i] = int(input())

    for row in range(N):
        tmp = 0
        for col in range(M):
            tmp += A[row][col]*B[col]
        print("%d" % (tmp))

if __name__ == '__main__':
  main()



Measured memory_bytes: 6008
N, M = gets.split.map(&:to_i)
x = gets.split.map(&:to_i).sort

if N >= M
  puts 0
  exit
end

diff = []
0.upto(M-2) do |i|
  diff << x[i + 1] - x[i]
end

p diff.sort[0..-N].inject(:+)

Measured memory_bytes: 11248
#include <iostream>
#include <map>
#include <string>
using namespace std;

int main(){
	map<string, int> m;
	char c;
	string s;
	int n;
	while(cin >> n >> c >> s)m[s]++;
	cout << m["A"] << endl;
	cout << m["B"] << endl;
	cout << m["AB"] << endl;
	cout << m["O"] << endl;
	return 0;
}

Measured memory_bytes: 3136
while True:
    m,f,r = map(int,input().split())
    
    if m == f == r == -1:
        break
    elif m==-1 or f==-1: 
        print("F")
    elif m+f >= 80:
        print("A")
    elif 65 <= m+f < 80:
        print("B")
    elif 49 <= m+f < 65:
        print("C")
    elif 30 <= m+f < 50 and r >= 50:
        print("C")
    elif 30 <= m+f < 50:
        print("D")
    elif m+f < 30:
        print("F")



Measured memory_bytes: 5592
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

int gcd(int a, int b){
	if(a < b) swap(a, b);
	if(b == 0) return a;
	return gcd(b, a % b);
}

signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int k;
	cin >> k;
	int ans = 0;
	rep(i, 1, k + 1){
		rep(j, 1, k + 1){
			rep(l, 1, k + 1){
				ans += gcd(i, gcd(j, l));
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3652
n,k=map(int,input().split())
s=input()

list10 = {'0':[],'1':[]}
pre_c='1'
c_c = 0
cur_sum = 0
cur_max = 0
for c in s:
    if c==pre_c:
        c_c += 1
    else:
        list10[pre_c].append(c_c)
        cur_sum += c_c
        c_c = 1
        pre_c = c
    if len(list10['1'])== k+1:
        cur_max = max(cur_max,cur_sum)
        cur_sum -= (list10['0'].pop(0) + list10['1'].pop(0))
print(max(cur_max,cur_sum+c_c))

Measured memory_bytes: 3828
// D
// DeP
#include <cstdio>

typedef long long LL;
const int MAXN = 2e5 + 5;

int n;
int A[MAXN], c[MAXN];

int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i) scanf("%d", A + i), ++c[A[i]];
    LL ans = 0;
    for (int i = 1; i <= n; ++i)
        ans += 1LL * c[i] * (c[i] - 1) / 2;
    for (int i = 1; i <= n; ++i) {
        const int& v = A[i];
        ans -= 1LL * c[v] * (c[v] - 1) / 2;
        --c[v];
        ans += 1LL * c[v] * (c[v] - 1) / 2;
        printf("%lld\n", ans);
        ans -= 1LL * c[v] * (c[v] - 1) / 2;
        ++c[v];
        ans += 1LL * c[v] * (c[v] - 1) / 2;
    }
    return 0;
}

Measured memory_bytes: 3584
# coding: utf-8
# Your code here!

import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline #文字列入力のときは注意

s = int(input())
#a = [int(i) for i in readline().split()]
#s = (10**9-1)**2+1
r = int(s**0.5)

res = r+5

for i in range(10,-10,-1):
    if r+i > 0 and (r+i)**2 >= s:
        res = r+i
    
if res*res-s <= 10**9:
    print(0,0,res,1,res*res-s,res)
else:
    print(0,0,res,1,res*(res-1)-s,res-1)
    

Measured memory_bytes: 3188
n , m , l = map(int,input().split())
A=[]
B=[]
for i in range(n):
    A.append(list(map(int,input().split())))
for j in range(m):
    B.append(list(map(int,input().split())))
for A_r in A:
    print(" ".join(map(str,[sum([x*y for x,y in zip(A_r,[B_r[k] for B_r in B])]) for k in range(l)])))



Measured memory_bytes: 6316
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.SortedMap;
import java.util.TreeMap;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int h = Integer.parseInt(sa[0]);
		int w = Integer.parseInt(sa[1]);
		int[] a = new int[h];
		int[] b = new int[h];
		for (int i = 0; i < h; i++) {
			sa = br.readLine().split(" ");
			a[i] = Integer.parseInt(sa[0]) - 1;
			b[i] = Integer.parseInt(sa[1]);
		}
		br.close();

		TreeMap<Integer, Integer> map = new TreeMap<>();
		MultiTreeSet<Integer> set = new MultiTreeSet<>();
		for (int i = 0; i < w; i++) {
			map.put(i, i);
			set.add(0);
		}

		PrintWriter pw = new PrintWriter(System.out);
		for (int i = 0; i < h; i++) {
			SortedMap<Integer, Integer> sub = map.subMap(a[i], b[i]);
			for (Integer key : sub.keySet()) {
				set.remove(key - sub.get(key));
			}
			if (!map.containsKey(b[i])) {
				if (!sub.isEmpty()) {
					int s = sub.get(sub.lastKey());
					map.put(b[i], s);
					if (b[i] < w) {
						set.add(b[i] - s);
					}
				}
			}
			sub.clear();
			if (set.size == 0) {
				pw.println(-1);
			} else {
				pw.println(set.first() + i + 1);
			}
		}
		pw.flush();
	}

	static class MultiTreeSet<T> {
		TreeMap<T, Integer> map = new TreeMap<>();
		int size = 0;

		void add(T e) {
			if (map.containsKey(e)) {
				map.put(e, map.get(e) + 1);
			} else {
				map.put(e, 1);
			}
			size++;
		}

		void remove(T e) {
			if (e != null && map.containsKey(e)) {
				int val = map.get(e);
				if (val == 1) {
					map.remove(e);
				} else {
					map.put(e, val - 1);
				}
				size--;
			}
		}

		T first() {
			return map.firstKey();
		}
	}
}


Measured memory_bytes: 81504
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int D = Integer.parseInt(sc.next());
        int G = Integer.parseInt(sc.next());
        int[] p = new int[D];
        int[] c = new int[D];
        int INF = 1_000_000_000;
        for (int i=0;i<D;i++) {
            p[i] = Integer.parseInt(sc.next());
            c[i] = Integer.parseInt(sc.next());
        }
        int ans = INF;
        for (int i=0;i<1<<D;i++) {
            int[] flag = new int[D];
            int cnt = 0;
            int sum = 0;
            for (int j=0;j<D;j++) {
                flag[j] = (i>>j&1);
                if (flag[j]==1) {
                    cnt+=p[j];
                    sum+=p[j]*100*(j+1)+c[j];
                    if (sum>=G) {
                        ans = Math.min(ans, cnt);
                    }
                }
                for (int k=D-1;k>=0;k--) {
                    if (flag[k]==0) {
                        if (G>=sum && (G-sum)<(p[k]*100*(k+1))) {
                            cnt+=(G-sum+100*(k+1)-1)/(100*(k+1));
                            ans = Math.min(ans, cnt);
                        }
                        break;
                    }
                }
            }
        }
        System.out.println(ans);
    }
}

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

int main() {
    int N, M, Q;
    cin >> N >> M >> Q;
    vector< vector<int> > trains(N+1, vector<int>(N+1));
    vector<P> query(Q);
    REP(i, M) {
        int p, q;
        cin >> p >> q;
        trains[p][q]++;
    }
    REP(i, Q) cin >> query[i].first >> query[i].second;

    FOR(i, 1, N)
        FOR(j, 1, N) trains[i][j] += trains[i][j-1];
    
    FOR(i, 1, N )
        FOR(j, 1, N)
            trains[i][j] += trains[i-1][j];

    REP(i, Q) {
        int p = query[i].first;
        int q = query[i].second;
        int ans = trains[q][q] - trains[p-1][q];
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 5104
#include <iostream>
using namespace std;
int main(void){
    int n,k,p;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>k>>p;
    if(k<p){
        cout<<k<<endl;
    }
    else if(k==p){
        cout<<k<<endl;
    }
    else if(k%p==0){
        cout<<p<<endl;
    }
    else{
        cout<<k%p<<endl;
    }
    }
}



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

int main() {
  int a, b, c, d;
  int sum = 0;
  for (int i = 0; i < 4; i++) {
    cin >> a >> b >> c >> d;
  }
  sum += (a < b) ? a : b;
  sum += (c < d) ? c : d;
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 3548
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int i = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int i = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define MP make_pair
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1 << 30;
const ll LINF = 1LL << 61;
const int MOD = 1e9 + 7;

int main() {
    string s;
    cin >> s;
    map<char, int> mp;
    rep(i, s.size()) { mp[s[i]]++; }
    for(pair<char, int> x : mp) {
        if(x.second % 2) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"
using namespace __gnu_pbds;
using namespace std;
#define mem(x,y) memset(x,y,sizeof(x))  
#define lli long long int
#define ll long long 
#define ld long double
#define pb push_back
#define mp make_pair
#define F first
#define S second 
#define LB lower_bound
#define UB upper_bound
#define BS binary_search
#define pii pair<lli,lli>
const long long int mod=1000000009;
//const long long int mod=998244353;
const long double PI=3.141592653589793;
const long long int inf=1e18;
const long long int inf2=LLONG_MAX;
#define setBitCount(x) __builtin_popcountll(x)
#define all(a) (a).begin(), (a).end()
#define all_r(a) (a).rbegin(), (a).rend()
lli gcd(lli a,lli b)
{
    if(b==0)
    return a;
    else
    return gcd(b,a%b);
}
// calculating (x^y)%p
lli power(lli x,lli y,lli p)
{
    lli res = 1;      
    x = x % p;  
    while (y > 0)
    {
        if (y & 1) //y is odd  
        res = (res*x) % p;
        y = y>>1; 
        x = ( (x%p)*(x%p) )% p;  
    }
    return res%p;
}
// calculating modular inverse using fermat little theorem
lli modInverse(lli n,lli p) 
{
    return power(n, p-2, p)%p;
}

// policy based data structures !!
#define ordered_set tree<lli, null_type,less<lli>, rb_tree_tag,tree_order_statistics_node_update>
// s.order_of_key (k) : Number of items strictly smaller than k
// *(s.find_by_order(k)) : K-th element in a set (counting from zero)

void solve()
{
   lli n;
   cin>>n;
   lli W;
   cin>>W;
   
   lli sum=0;
   
   lli w[n+5],p[n+5];
   for(lli i=1;i<=n;i++)
   cin>>w[i]>>p[i];
   
   for(lli i=1;i<=n;i++)
   sum+=p[i];
   
   lli dp[n+5][sum+5];
   for(lli i=0;i<=n;i++)
   {
      for(lli j=0;j<=sum;j++)
      {
         dp[i][j]=inf;
      }
   }
   for(lli i=0;i<=n;i++)
   dp[i][0]=0;
   
   for(lli i=1;i<=n;i++)
   {
      for(lli j=1;j<=sum;j++)
      {
         dp[i][j]=dp[i-1][j];
         if(j>=p[i])
         dp[i][j]=min(dp[i][j],dp[i-1][j-p[i]]+w[i]);
      }
   }
   
   for(lli i=sum;i>=0;i--)
   {
      if(dp[n][i]<=W)
      {
         cout<<i;
         return ;
      }
   }
   
}
int main()
{
   
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    lli T;
    //cin>>T;
    T=1;
    while(T--)
    {
        solve();
    }




    return 0;
}

Measured memory_bytes: 80384
import java.util.Scanner;

class Main{



	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);			//文字の入力
		int n = sc.nextInt();
		int h = sc.nextInt();
		int w = sc.nextInt();
		int[] a = new int[n];
		int[] b =new int[n];
		int count = 0;
		for(int i = 0;i < n;i++){
			a[i] = sc.nextInt();
			b[i] = sc.nextInt();
			if(a[i] >= h && b[i] >= w){
				count++;
			}
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 27240
#include <bits/stdc++.h>
using namespace std;
#define MAX 30
#define NIL -1


struct node{
    int p, l, r;
};
node T[MAX];
int n;

void Preorder(int u){
    if(u==NIL) return;
    printf(" %d",u);
    Preorder(T[u].l);
    Preorder(T[u].r);
}

void Inorder(int u){
    if(u==NIL) return;
    Inorder(T[u].l);
    printf(" %d",u);
    Inorder(T[u].r);
}

void Postorder(int u){
    if(u==NIL) return;
    Postorder(T[u].l);
    Postorder(T[u].r);
    printf(" %d",u);
}

int main(){

    scanf("%d",&n);
    for(int i=0;i<n;++i){
        T[i].l = T[i].p = T[i].r = NIL;
    }
    int id, lchild, rchild, root;

    for(int i=0;i<n;++i){
        scanf("%d %d %d",&id,&lchild,&rchild);
        T[id].l = lchild;
        T[id].r = rchild;
        T[lchild].p = id;
        T[rchild].p = id;
    }
    for(int i=0;i<n;++i){
        if(T[i].p==NIL) root=i;
    }
    printf("Preorder\n");
    Preorder(root);
    printf("\n");
    printf("Inorder\n");
    Inorder(root);
    printf("\n");
    printf("Postorder\n");
    Postorder(root);
    printf("\n");

    return 0;
}





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

using namespace std;

typedef long long ll;

constexpr int M = 1000 * 1000 * 1000 + 7;

static int a[2000];
static int b[2000];
static int dp[2001][2001];

int main() {
    std::ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    for (int i = 0; i < m; ++i) {
        cin >> b[i];
    }
    for (int i = 0; i <= n; ++i) {
        dp[i][0] = 1;
    }
    for (int i = 0; i <= m; ++i) {
        dp[0][i] = 1;
    }
    for (int j = 0; j < m; ++j) {
        for (int i = 0; i < n; ++i) {
            dp[i + 1][j + 1] = ((dp[i + 1][j] + dp[i][j + 1] - dp[i][j]) % M + M) % M;
            if (a[i] == b[j]) {
                dp[i + 1][j + 1] += dp[i][j];
                dp[i + 1][j + 1] %= M;
            }
        }
    }
    cout << dp[n][m] << endl;
    return 0;
}


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


 
int main() {
  double l;
  cin >> l;
  double a,b;
  a=l/3;
  b=l/3+(l-a*3);
  double ans=a*a*a;
  printf("%.10f\n",ans);
  return 0;
}


Measured memory_bytes: 256
class NormalInput {
  input: string[];
  pointer: number;
  constructor(raw: string) {
    this.input = raw.split(/ |\n/);
    this.pointer = 0;
  }
  int = (): number => {
    const ret = parseInt(this.input[this.pointer], 10);
    this.pointer++;
    return ret;
  };
  str = (): string => {
    const ret = this.input[this.pointer];
    this.pointer++;
    return ret;
  };
  strs = (length: number): string[] => {
    let ret: string[] = [];
    for (let i = 0; i < length; i++) {
      ret.push(this.str());
    }
    return ret;
  };
  ints = (length: number): number[] => {
    let ret: number[] = [];
    for (let i = 0; i < length; i++) {
      ret.push(this.int());
    }
    return ret;
  };
}
function rep(n: number) {
  let a = [];
  for (let i = 0; i < n; i++) a.push(i);
  return a;
}
function Main({ int, str, strs, ints }: NormalInput) {
  const N = str();
  const solv = () => {
    for (let i = 0; i < 3; i++) {
      if (N[i] === "7") return true;
    }
    return false;
  };
  console.log(solv() ? "Yes" : "No");
}

//DO NOT EDIT
Main(new NormalInput(require("fs").readFileSync("/dev/stdin", "utf8")));


Measured memory_bytes: 29644
#include <bits/stdc++.h>
typedef long long ll;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
using namespace std;
const ll MAX_N=100;
vector<ll> grp[MAX_N];
typedef pair<ll,ll> P;
vector<P> ans;
ll N;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>N;
	ll n2=N/2;
	REP(i,N/2){
		grp[i].push_back(i+1);
	}
	REP(i,N/2){
		grp[N/2-1-i].push_back(N/2+i+1);
	}
	if(N&1){
		grp[N/2].push_back(N);
		n2++;
	}
	REP(i,n2){
		FOR(j,i+1,n2){
			for(ll a:grp[i]){
				for(ll b:grp[j]){
					ans.push_back(P(a,b));
				}
			}
		}
	}
	cout<<ans.size()<<endl;
	for(auto e:ans){
		cout<<e.first<<' '<<e.second<<endl;
	}
	
}

Measured memory_bytes: 764
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
using namespace std;
int n,a[100005],f[100005];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i)
		scanf("%d",a+i);
	f[1]=0;f[2]=abs(a[2]-a[1]);
	for(int i=3;i<=n;++i)
		f[i]=min(f[i-2]+abs(a[i]-a[i-2]),f[i-1]+abs(a[i]-a[i-1]));
	printf("%d\n",f[n]);
	return 0;
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int a[n];
  for(int i=1;i<n;i++)
  cin>>a[i];
  int sum=a[1]+a[n-1];

  for(int j=2;j<n;j++)
  sum+=min(a[j],a[j-1]);
  cout<<sum;
  return 0; 
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

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

const int INF=1001001001001001001ll;

int N,M,T;


vint calc(vint A,vint B){
    vint C(T,-INF);
    rep(i,T)rep(j,T)chmax(C[(i+j)%T],A[i]+B[j]);
    return C;
}

signed main(){
    cin>>N>>M>>T;

    vint v(T,-INF),dp(T,-INF);
    rep(i,N){
        int a;cin>>a;
        chmax(v[a%T],a);
    }

    chmax(v[0],0);
    dp[0]=0;

    rep(i,30){
        if(M>>i&1)dp=calc(dp,v);
        v=calc(v,v);
    }

    for(int i=T-2;i>=0;i--)chmax(dp[i],dp[i+1]);

    int Q;cin>>Q;
    while(Q--){
        int a,b;
        cin>>a>>b;
        if(dp[a%T]>=b*T)cout<<"yes"<<endl;
            else cout<<"no"<<endl;
    }
    return 0;
}

Measured memory_bytes: 3176
H,W = map(int,input().split())
s = [input() for _ in range(H)]

ans = True
for i in range(H):
    for j in range(W):
        b = 0
        if s[i][j] == '#':
            if i-1>=0:
                if s[i-1][j] == '#':
                    b += 1
            if i+1<H:
                if s[i+1][j] == '#':
                    b += 1
            if j-1>=0:
                if s[i][j-1] == '#':
                    b += 1
            if j+1<W:
                if s[i][j+1] == '#':
                    b += 1
            if b == 0:
                ans = False
if ans:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
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;
        InputReader in = new InputReader(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, InputReader in, PrintWriter out) {
            int N = in.nextInt();

            int ans = Integer.MAX_VALUE;

            for (int a = 1; a < N; a++) {
                int b = N - a;

                ans = Math.min(ans, d(a) + d(b));
            }

            out.println(ans);
        }

        private int d(int x) {
            int ans = 0;
            while (x > 0) {
                ans += x % 10;
                x /= 10;
            }
            return ans;
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 21460
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define vi vector<int>
#define vll vector<ll>
#define pll pair<ll,ll>
#define pii pair<int,int>
#define pb  push_back
#define ppb pop_back
#define mp  make_pair
#define SIZE 25
ll H,W;
string arr[SIZE];
ll vis[SIZE][SIZE];
ll bfs(ll a,ll b,ll x,ll y){
	queue<pair<pll,ll> > q;
	q.push(mp(mp(a,b),0));
	for(ll i=0;i<H;++i){
		for(ll j=0;j<W;++j){
			vis[i][j]=false;
			if(arr[i][j]=='#'){
				vis[i][j]=true;
			}
		}
	}
	vis[a][b]=true;
	ll ans=-1;
	while(!q.empty()){
		pair<pll,ll> u=q.front();
		q.pop();
		ll i=u.first.first;
		ll j=u.first.second;
		ll d=u.second;
		// cout<<i<<" "<<j<<" "<<d<<endl;
		if(i==x&&j==y){
			ans=d;
			// cout<<ans<<endl;
			break;
		}
		if(i+1<H&&vis[i+1][j]==false){
			vis[i+1][j]=true;
			q.push(mp(mp(i+1,j),d+1));
		}
		if(j+1<W&&vis[i][j+1]==false){
			vis[i][j+1]=true;
			q.push(mp(mp(i,j+1),d+1));
		}
		if(i-1>=0&&vis[i-1][j]==false){
			vis[i-1][j]=true;
			q.push(mp(mp(i-1,j),d+1));
		}
		if(j-1>=0&&vis[i][j-1]==false){
			vis[i][j-1]=true;
			q.push(mp(mp(i,j-1),d+1));
		}
	}
	return ans;
}
int main(){
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	// #endif
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL);
	cin>>H>>W;
	for(ll i=0;i<H;++i){
		string str;
		cin>>str;
		arr[i]=str;
	}
	ll ans=0;
	for(ll i=0;i<H;++i){
		for(ll j=0;j<W;++j){
			for(ll k=0;k<H;++k){
				for(ll l=0;l<W;++l){
					if(arr[i][j]!='#'&&arr[k][l]!='#'){
						ans=max(ans,bfs(i,j,k,l));
						// cout<<i<<","<<j<<" "<<k<<","<<l<<" "<<ans<<endl;
					}
				}
			}
		}
	}
	cout<<ans<<endl;
}

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

string S;

bool ok() {
  if(S[0] != 'A') return false;

  int ic = -1;
  for(int i = 2; i <= S.size() - 2; i++){
    if(S[i] == 'C') {
      if(ic != -1) return false;
      ic = i;
    }
  }
  if(ic == -1) return false;

  for(int i = 1; i < S.size(); i++) {
    if(i == ic) continue;
    if(!(S[i] >= 'a' && S[i] <= 'z')) return false;
  }

  return true;
}

int main () {

  cin >> S;

  cout << (ok() ? "AC" : "WA") << endl;
  return 0;
}


Measured memory_bytes: 256
open System

let n = stdin.ReadLine() |> int
let [|d; x|] = stdin.ReadLine().Split() |> Array.map int
let a = [ for _ in [1..n] -> stdin.ReadLine() |> int ]

List.sumBy (fun a -> (d+a-1) / a) a
|> (+) x
|> printfn "%d"

Measured memory_bytes: 14044
#include <iostream>
#include <stdio.h>
#include <stdint.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <string>
#include <math.h>
#include <time.h>
#include <algorithm>
#include <deque>

using namespace::std;

int ri()
{
	int x;
	scanf("%d", &x);

	return x;
}

int64_t ri64()
{
	int64_t x;
	scanf("%lld", &x);

	return x;
}

void wi(int x)
{
	printf("%d\n", x);
}

void wvi(vector<int> &v)
{
	for (int i = 0; i < v.size(); i++)
		printf("%d ", v[i]);
	printf("\n");
}

void dbg(string &str, int x)
{
	cout << str << ": ";
	wi(x);
}

void dbg(string &str, vector<int> &x)
{
	cout << str << ": ";
	wvi(x);
}

int64_t mod = 1000000007;

int main()
{
        int N = ri();
        int64_t K = ri();

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

        int64_t x = 0;
        int64_t y = 0;

        for (int i = 0; i < N; i++)
        {
                for (int j = 0; j < N; j++)
                {
                        if (A[i] > A[j])
                        {
                                x++;
                                if (i < j)
                                        y++;
                        }
                }
        }

        int64_t ans = (x * K) % mod;
        ans = (ans * (K - 1)) % mod;
        ans = (ans * ((mod + 1)/2)) % mod;

        ans = (ans + y * K) % mod;
        
        wi(ans);

	return 0;
}


Measured memory_bytes: 256
def cycle_getter(N, start):
    """
    :param N: 移動回数
    :param start:　初期条件
    :return front: cycleまでの要素のリスト
            cycle: cycle内の要素のリスト
            end: cycle後の余った部分の要素のリスト
            cnt: cycle回数
    """
    p = start
    front, cycle, end = [], [], []
    cnt = 0
    visit = {p:0}
    L, R = N, -1
    P = [p]
    for i in range(1,N):
        p = lift(p)
        if p in visit:
            """
            (L, R) = (サイクルに入るまでに移動した回数, サイクルの終端に着くまでに移動した回数)
            [6,2,3,4,0,1,2] ⇒ (L, R) = (1, 6)
            """
            L, R = visit[p], i
            period = R-L
            break
        visit[p] = i
        P.append(p)
    front = P[:L]
    if L != N:
        cycle, end = P[L:R], P[L:L+(N-L)%period]
        cnt = (N-L)//period
    return front, cycle, end, cnt

################################################################################


import sys
input = sys.stdin.readline

def lift(x): return A[x-1]

N, K = map(int, input().split())
A = list(map(int, input().split()))
front, cycle, end, cnt = cycle_getter(K+1,1)
# print(front, cycle, end, cnt)
print((front+cycle+end)[-1])

Measured memory_bytes: 125848
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int i;
    int a[4];
    for(i=0;i<4;i++)
        scanf("%1d",&a[i]);
    if(a[0]+a[1]+a[2]+a[3]==7)
    {printf("%d+%d+%d+%d=7",a[0],a[1],a[2],a[3]);
    return 0;
    }
    if(a[0]+a[1]+a[2]-a[3]==7)
    {printf("%d+%d+%d-%d=7",a[0],a[1],a[2],a[3]);
    return 0;
    }
    if(a[0]+a[1]-a[2]+a[3]==7)
    {printf("%d+%d-%d+%d=7",a[0],a[1],a[2],a[3]);
    return 0;
    }
    if(a[0]+a[1]-a[2]-a[3]==7)
    {printf("%d+%d-%d-%d=7",a[0],a[1],a[2],a[3]);
    return 0;
    }
    if(a[0]-a[1]+a[2]+a[3]==7)
    {printf("%d-%d+%d+%d=7",a[0],a[1],a[2],a[3]);
    return 0;
    }
    if(a[0]-a[1]+a[2]-a[3]==7)
    {printf("%d-%d+%d-%d=7",a[0],a[1],a[2],a[3]);
    return 0;
    }
    if(a[0]-a[1]-a[2]+a[3]==7)
    {printf("%d-%d-%d+%d=7",a[0],a[1],a[2],a[3]);
    return 0;
    }
    if(a[0]-a[1]-a[2]-a[3]==7)
    {printf("%d-%d-%d-%d=7",a[0],a[1],a[2],a[3]);
    return 0;
    }
    return 0;
}

Measured memory_bytes: 256
N,M= gets.split.map(&:to_i)

#Mの約数かつM/N以下で最大のものを求める
max = 1

for i in 0..M/N-1 do
  j =   M/N - i
  if M%j == 0
    max = j
    break
  end
end

puts max


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

int main(){

	string s, t;
	cin >> s >> t;
	sort(s.begin(), s.end());
	sort(t.begin(), t.end());
	reverse(t.begin(), t.end());
	if(s < t) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

typedef struct {
  int node;
  int parent;
  int left;
  int right;
} Node;

Node T[25];

void preorder(int i){
  if(i == -1) return;
  printf(" %d",i);
  preorder(T[i].left);
  preorder(T[i].right);
}

void inorder(int i){
  if(i == -1) return;
  inorder(T[i].left);
  printf(" %d",i);
  inorder(T[i].right);
}

void postorder(int i){
  if(i == -1) return;
  postorder(T[i].left);
  postorder(T[i].right);
  printf(" %d",i);
}

int main(){
  int n,i,num,left,right,root;

  scanf("%d",&n);

  for(i = 0;i < n;i++){
    T[i].parent = T[i].left = T[i].right = -1;
  }

  for(i = 0;i < n;i++){
    scanf("%d%d%d",&num,&left,&right);
    T[num].node = num;
    T[num].left = left;
    T[num].right = right;
    if(left != -1) T[left].parent = num;
    if(right != -1) T[right].parent = num;
  }

  for(i = 0;i < n;i++){
    if(T[i].parent == -1) root = i;
  }

  printf("Preorder\n");
  preorder(root);
  printf("\n");
  printf("Inorder\n");
  inorder(root);
  printf("\n");
  printf("Postorder\n");
  postorder(root);
  printf("\n");

  return 0;
}



Measured memory_bytes: 2140
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;
inline int getInt() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;
typedef v(string) vs;



int main() {
  int n,m;
  scanf("%d%d",&n,&m);
  int h = 1<<n, w = 1<<m;
  vvi a(h,vi(w));
  rep(i,h)rep(j,w) a[i][j] = pcnt(i&j)%2;
  // rep(i,h) cout<<a[i]<<endl;
  vs ans(h-1, string(w-1,'0'));
  drep(i,h-1)drep(j,w) a[i+1][j] ^= a[i][j];
  drep(i,h)drep(j,w-1) a[i][j+1] ^= a[i][j];
  // rep(i,h)rep(j,i) {
  //   int cnt = 0;
  //   rep(k,w) cnt += a[i][k]^a[j][k];
  //   if (cnt != w/2) cout<<i<<" "<<j<<endl;
  // }
  rep(i,h-1)rep(j,w-1) {
    if (a[i+1][j+1]) ans[i][j] = '1';
  }
  rep(i,h-1) cout<<ans[i]<<endl;
  return 0;
}






















Measured memory_bytes: 6528
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

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

#define MOD 1000000007

void solve(int test_case) {//222
	string s;
	cin>>s;
	int a=0,b=0,c=0;
	for(char m:s){
		if(m=='a')a++;
		else if(m=='b')b++;
		else c++;
	}
	if(a==b&&b==c)cout<<"Yes";
	else cout<<"No";
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


Measured memory_bytes: 3656
#include<stdio.h>

int main(void){
    int n,d,x,a,i;
    scanf("%d%d%d",&n,&d,&x);
    for(i=0;i<n;i++){
        scanf("%d",&a);
        x+=(d-1)/a;
        x++;
    }
    printf("%d\n",x);
    return 0;
}


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

const long long mod = 1e9 + 7;

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

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

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

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

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

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

const long long MOD = 1000000007;

int main(){
    int n;
    cin >> n;
    vi a(n);
    rep(i, n) cin >> a[i];
    vll sum(n+1);
    rep(i, n) sum[i+1] = (sum[i] + a[i]) % MOD;
    ll ans = 0;
    rep(i, n) ans = (ans + sum[i] * a[i]) % MOD;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 5556
//#include <boost/multiprecision/cpp_dec_float.hpp>
//#include <boost/multiprecision/cpp_int.hpp>
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <math.h>
#include <algorithm>
#include <bitset>
#include <iomanip>
using namespace std;
//namespace mp = boost::multiprecision;
//using llll = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
//using Real = mp::number<mp::cpp_dec_float<1024>>;
using ll = long long;
const double EPS = 1e-10;
const ll MOD = 7+(1e+9);

int main(){
  //cout<<fixed<<setprecision(10);
  ll n,ans=0;
  cin>>n;
  vector<string>v;
  string s;
  for(ll i=0;i<n;i++){
    cin>>s;
    v.push_back(s);
  }
  sort(v.begin(),v.end());
  ll tt=0;
  ll t=0;
  vector<string>v2,v3;
  for(ll i=1;i<n;i++){
    if(v[i-1]==v[i])t++;
    else{
      if(t==tt){
        v2.push_back(v[i-1]);
        tt=t;
      }
      else if(t>tt){
        v2=v3;
        v2.push_back(v[i-1]);
        tt=t;
      }
      t=0;
    }
  }
  if(t==tt){
    v2.push_back(v[n-1]);
    tt=t;
  }
  else if(t>tt){
    v2=v3;
    v2.push_back(v[n-1]);
    tt=t;
  }
  for(ll i=0;i<v2.size();i++){
    cout<<v2[i]<<endl;
  }
}


Measured memory_bytes: 15984
from itertools import combinations

n = int(input())
ab = [list(map(int, input().split())) for _ in range(n - 1)]
m = int(input())
uv = [list(map(int, input().split())) for _ in range(m)]

adj = [[] for _ in range(n)]
ids = [[-1] * n for _ in range(n)]
for i, (a, b) in enumerate(ab):
    a -= 1
    b -= 1
    adj[a].append(b)
    adj[b].append(a)
    ids[a][b] = i
    ids[b][a] = i


def dfs(s, g):
    d = [-1] * n
    d[s] = 0
    p = [-1] * n
    stack = [s]

    while stack:
        u = stack.pop()
        for v in adj[u]:
            if d[v] == -1:
                d[v] = d[u] + 1
                p[v] = u
                stack.append(v)

    v = g
    ret = 0
    while v != s:
        i = ids[v][p[v]]
        ret += 1 << i
        v = p[v]

    return ret


def bin_count(tpl):
    sm_or = 0
    for e in tpl:
        sm_or |= e

    return bin(sm_or).count("1")


path = [dfs(u - 1, v - 1) for u, v in uv]
ex = 0
for i in range(1, m + 1):
    for tpl in combinations(path, i):
        ex += pow(2, n - 1 - bin_count(tpl)) * (-1) ** (i % 2 + 1)

ans = pow(2, n - 1) - ex
print(ans)


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

int main() {
  int N, i;
  cin >> N;
  string s;
  for(i=0;i<N;i++){
    cin >> s;
    if(s == "Y") break;
  }
  if(s == "Y") cout << "Four" << endl;
  else if(s !="Y") cout << "Three" << endl;
  else cout << "error" << endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

class Main{
  public static int n;
  public static int[] f;
    public static void main(String[] args){
      try{
        BufferedReader fb = new BufferedReader(new InputStreamReader(System.in));
        String s;
        s = fb.readLine();
        n = Integer.parseInt(s);
        f = new int[n+1];
        fb.close();
      }
      catch(IOException e){
        System.out.println(e);
      }
      System.out.println(fib(n));
    }
    public static int fib(int n){
      if(n <= 1){
        return f[n] = 1;
        }
      if(f[n] > 0){
        return f[n];
        }

      return f[n] = fib(n-1) + fib(n-2);
      }

}



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

void swap(int *x, int *y);

int main(){
    int a1, a2, a3;
    cin >> a1 >> a2 >> a3;
    if(a1>a2) swap(&a1,&a2);
    if(a2>a3) swap(&a2,&a3);
    if(a1>a2) swap(&a1,&a2);
    cout << a1 << " " << a2 << " " << a3 << endl;
}

void swap(int *x, int *y) {
    int tmp = *x;
    *x = *y;
    *y = tmp;
}


Measured memory_bytes: 3084
#include <stdio.h>
#include <math.h>

int main(void) {
	int x, h;
	while (1) {
		scanf("%d", &x);
		scanf("%d", &h);
		if (!x && !h)
			break;
		printf("%lf\n", (double)(x*x)+2.0*(double)x*sqrt((double)(h*h)+(double)(x*x)/4.0));
	}
	return 0;
}

Measured memory_bytes: 628
#include<stdio.h>

int H, W, K;
int board[30][31], init[30][31];

int erase(void){
    int i, j, k;
    int ret = 0, combo;
    for(i = 0; i < H; i++){
        combo = 1;
        for(j = 0; j < W; j++){
            if(board[i][j] == board[i][j+1]) combo++;
            else{
                if(combo >= K){
                    for(k = j - combo + 1; k <= j; k++){
                        ret += board[i][k];
                        board[i][k] = 0;
                    }
                }
                combo = 1;
            }
        }
    }
    
    return ret;
}

void fall(void){
    int changeflg, i, j;
    
    do{
        changeflg = 0;
        for(i = H - 2; i >= 0; i--){
            for(j = 0; j < W; j++){
                if(board[i + 1][j] == 0 && board[i][j] != 0){
                    board[i + 1][j] = board[i][j];
                    board[i][j] = 0;
                    changeflg = 1;
                }
            }
        }
    }while(changeflg);
}

int main(void){
    int i, j, ii, jj;
    int maxscore = 0, score, num, power2;
    scanf("%d %d %d", &H, &W, &K);
    
    getc(stdin);
    
    for(i = 0; i < H; i++){
        for(j = 0; j < W; j++){
            init[i][j] = getc(stdin) - '0';
        }
        getc(stdin);
    }
    
    for(i = 0; i < H; i++){
        for(j = 0; j < W; j++){
            for(ii = 0; ii < H; ii++) for(jj = 0; jj < W; jj++) board[ii][jj] = init[ii][jj];

            board[i][j] = 0;
            score = 0;
            
            fall();
            for(power2 = 1; num = erase(); power2 *= 2){
                score += num * power2;
                fall();
            }
            
            if(score > maxscore) maxscore = score;
        }
    }
    
    printf("%ld\n", maxscore);
    
    //system("pause");
    
    return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>

using namespace std;

int dp[1000005];
int dp2[1000005];
int pl[180];

int main() {
	//init
	for (int i = 1; i<=180; i++)pl[i-1] = (i*(i + 1)*(i + 2)) / 6;
	memset(dp, 0x7f, sizeof(dp));
	memset(dp2, 0x7f, sizeof(dp2));
	dp[0] = 0;
	dp2[0] = 0;
	for (int i = 0; i < 1000000; i++) {
		for (int j = 0; j < 180; j++) {
			if(i+pl[j] <= 1000000)dp[i + pl[j]] = min(dp[i] + 1, dp[i + pl[j]]);
			if (i + pl[j] <= 1000000 && pl[j]&1)dp2[i + pl[j]] = min(dp2[i] + 1, dp2[i + pl[j]]);
		}
	}
	while (1) {
		int n;
		scanf("%d", &n);
		if (n == 0)break;
		printf("%d %d\n", dp[n], dp2[n]);
	}
	return 0;
}

Measured memory_bytes: 10380
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <cmath>
#include <algorithm>
using namespace std;
int main(){
    int k;
    int x;
    cin>>k>>x;
    if(500*k<x){
        cout<<"No";
    }else if(x<=500*k){
        cout<<"Yes";
    }
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
template<size_t I,class H,class...T>struct TupleReaderWriter{static tuple<H,T...> r(istream&i){H v;i>>v;return tuple_cat(tuple<H>(v),TupleReaderWriter<sizeof...(T)-1,T...>::r(i));}static void w(ostream&o,tuple<H,T...>&t,string d){TupleReaderWriter<I-1,H,T...>::w(o,t,d);o<<d<<get<I>(t);}};
template<class H,class...T>struct TupleReaderWriter<0,H,T...>{static tuple<H,T...> r(istream&i){H v;i>>v;return tuple<H>(v);}static void w(ostream&o,tuple<H,T...>&t,string d){o<<get<0>(t);}};
template<class...T>istream&operator>>(istream&i,tuple<T...>&t){t=TupleReaderWriter<sizeof...(T),T...>::r(i);return i;}
template<class...T>ostream&operator<<(ostream&o,tuple<T...>&t){string delim=" ";TupleReaderWriter<sizeof...(T)-1,T...>::w(o,t,delim);return o;}
template<class T>istream&operator>>(istream&i,vector<T>&v){for(auto&x:v)i>>x;return i;}
template<class T>ostream&operator<<(ostream&o,vector<T>&v){string delim="";for(auto&x:v)o<<delim<<x,delim=" ";return o;}
template<class T>using rev_priority_queue=priority_queue<T,vector<T>,greater<T>>;
template<class T>using vector2d=vector<vector<T>>;
struct fixprec{int x;fixprec(int d):x(d){}};
ostream&operator<<(ostream&o,fixprec f){return o<<fixed<<setprecision(f.x);}
void R_YESNO(bool p) { cout << (p ? "YES" : "NO") << endl; }
void R_YesNo(bool p) { cout << (p ? "Yes" : "No") << endl; }
/*!* [binsearch] *!*/
/*+* 二分探索 *+*/
// judge を満たすような下限を求める
// l:[X] 定義域外部の上限
// r:[X] 定義域外部の下限
// judge:[X -> bool] X を評価する関数
// lower:[bool] falseにすると代わりに上限を求める
// eps:[X] 終了距離

template <typename X>
X BinSearch(X l, X r, function<bool(X)> judge, bool lower = true, X eps = 1) {
    while (r - l > eps) {
        X m = (r + l) / 2;
        if (judge(m) == lower) {
            r = m;
        } else {
            l = m;
        }
    }
    return lower ? r : l;
}

int main() {
    string S;
    cin >> S;
    int N = S.size();
    vector<int> v(N), s(N);
    for(int i = 0; i < N; i++) {
        s[i] = S[i] == '1';
    }
    int ans = BinSearch<int>(0, S.size() + 1, [&](int L) -> bool {
        int x = 0;
        for(int i = 0; i < N; i++) {
            if(i <= N - L && s[i] ^ x) {
                v[i] = 0;
                x = !x;
            } else {
                v[i] = s[i] ^ x;
            }
        }
        for(int i = N - L; i < L; i++) {
            if(v[i] != v[N - L]) return false;
        }
        return true;
    }, false);
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 1280