akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MAXN 1010
#define MAXH 10001
#define rep(i,n) for (int i = 0; i < (n); ++i)
const ll mod = 1e9+7;
const ll inf = 1e9;

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

bool pairCompare(const P& firstElof, const P& secondElof)
{
    return firstElof.second < secondElof.second;
}

int h, n;
int a[MAXN], b[MAXN];
ll dp[MAXN][MAXH*2+10];

void solve() {

    rep(i, n+1) {
        rep(k, h+MAXH+10) {
            dp[i][k] = inf;
        }
    }

    dp[0][0] = 0;
    rep(i, n) {
        rep(k, h+MAXH) {
            if (k < a[i]) {
                dp[i+1][k] = dp[i][k];
            } else {
                dp[i+1][k] = min(dp[i][k], dp[i+1][k-a[i]] + b[i]);
            }
        }
    }
}

int main() {
    cin >> h >> n;
    rep(i, n) {
        cin >> a[i] >> b[i];
    }

    solve();

    ll ans = (ll) mod;
    for(int k=h; k<h+MAXH; ++k) ans = min(ans, dp[n][k]);
    

    cout << ans << endl;

}



Measured memory_bytes: 157952
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int max = 1;
        if (n < 4) {
            max = 1;
        } else {
            for (int i = 2; i < 34; i++) {
                int b = 2;
                while (Math.pow(i, b) <= n) {
                    if (max < (int) Math.pow(i, b)) {
                        max = (int) Math.pow(i, b);
                    }
                    b++;
                }
            }
        }
        System.out.println(max);
    }
}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int (i)=(int)(m);(i)<(int)(n);++(i))
#define rREP(i,m,n) for(int (i)=(n)-1;(i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;

template<class T>inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T>inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();

	int N; cin >> N;
	cout << (N - 2) * 180 << "\n";

	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true) {
			final int N = sc.nextInt();
			if(N == 0) break;

			Map<String, Long> cost = new HashMap<String, Long>();
			for(int i = 0; i < N; i++) {
				cost.put(sc.next(), sc.nextLong());
			}

			final int M = sc.nextInt();

			Map<String, List<String> > recipe = new HashMap<String, List<String> >();
			for(int i = 0; i < M; i++) {
				String name = sc.next();
				int k = sc.nextInt();

				ArrayList<String> al = new ArrayList<String>();
				for(int j = 0; j < k; j++)
					al.add(sc.next());

				recipe.put(name, al);
			}

			while(true) {
				boolean f = false;
				for(String to : recipe.keySet()) {
					long sum = 0L;
					for(String from : recipe.get(to)) {
						if(cost.get(from) == null) {
							sum += (int)1e9;
						}
						else {
							sum += cost.get(from);
						}
					}


					if(cost.get(to) == null || cost.get(to) > sum) {
						cost.put(to, sum);
						f = true;
					}
				}
				if(f == false) break;
			}

			String want = sc.next();
			System.out.println(cost.get(want));
		}
	}
}

Measured memory_bytes: 12000
// #include "pch.h"
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <climits>
#include <string>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <ctime>
#include <cassert>
#include <fstream>
#include<unordered_map>
#include <stack>
#include <random>

typedef long long ll;
typedef std::pair<int, int> Pii;
typedef std::pair<long long, long long> Pll;
typedef std::pair<double, double> Pdd;

#define rip(i, n, s) for (int i = (s);i < (int)( n ); i++)
#define mapa make_pair
#define all(a) a.begin(), a.end()
#define MM << " " <<

template<typename T>
using MaxHeap = std::priority_queue<T>;
template<typename T>
using MinHeap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

template<typename T>
void vdeb(std::vector<T> &da) {
    for (int i = 0;i < da.size();i++) {
        if (i == da.size() - 1) std::cout << da[i];
        else std::cout << da[i] << ' ';
    }
    std::cout << std::endl;
}
template<typename T>
void vdeb(std::vector<std::vector<T>> &da) {
    for (int i = 0;i < da.size();i++) vdeb(da[i]);
    std::cout << std::endl;
}

using namespace std;

int main(){
    ll n, a, b; cin >> n >> a >> b;
    if(a*b < n || a+b-1 > n){
        cout << -1 << endl;
        return 0;
    }
    vector<int> ans(n);
    rip(i,b,0) ans[i] = b-i-1;
    int now = b, lam = n-a-b+1;
    while(now < n){
        int nxt = 1 + min((int)b-1, lam);
        lam -= nxt-1;
        now += nxt;
        rip(i,nxt, 0){
            ans[now-i-1] = now-nxt+i;
        }
    }
    rip(i,n,0) ++ans[i];
    vdeb(ans);
}


Measured memory_bytes: 3456
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
typedef int ll;
int n,q,v,w;
ll fa(ll x){return (x + n - 2) / n;}
int main(){
    cin>>n>>q;
    for(int i = 0; i < q; i++){
        cin>>v>>w;
        if(n == 1){
            cout<<min(v,w)<<endl;
            continue;
        }
        ll a = v,b = w;
        while(a != b){
            if(a < b)b = fa(b);
            else a = fa(a);
        }
        cout<<a<<endl;
    }
    return 0;
}


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

using namespace std;

using ll = long long;
const ll INF = 1LL << 60;

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

vector<ll> dp;
vector<ll> h;
int n;
ll memo(int i) {
    if (dp[i] < INF) return dp[i];
    if (i == 0) return 0;
    ll res = INF;
    chmin(res, memo(i - 1) + abs(h[i] - h[i - 1]));
    if (i > 1) chmin(res, memo(i - 2) + abs(h[i] - h[i - 2]));
    dp[i] = res;
    return dp[i];
}

int main(void) {
    cin >> n;
    h.assign(n, 0);
    dp.assign(n, INF);
    for (int i = 0; i < n; i++) {
        cin >> h[i];
    }
    memo(n - 1);

    cout << dp[n - 1] << endl;
}


Measured memory_bytes: 6528
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<map>
#include<vector>
#include<queue>
#define lson (rt << 1)
#define rson (rt << 1 | 1)
#define gmid ((l+r) >> 1)
#define ll long long
using namespace std;

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


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

K = [*0...M].map{ gets.split.map(&:to_i).drop(1) }
P = gets.split.map(&:to_i)

zipper = K.zip(P)

count = 0
for i in 0...(2**N) do
    s = i.to_s(2)
    s = "0"*(N - s.size) + s
    count += 1 if zipper.all?{|k, n| k.count{|j| s[j - 1] == '1'}%2 == n}
end

p count


Measured memory_bytes: 3836
use std::io::*;

fn main() {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    let nums: Vec<&str> = buf.trim_right().split(" ").collect();

    let n: i32 = nums[0].parse().unwrap();
    let a: i32 = nums[1].parse().unwrap();
    let b: i32 = nums[2].parse().unwrap();

    let mut total = 0;

    for i in 1..n+1 {
        let sum: i32 = i.to_string().chars().map(|c| c as i32 - 48).sum();
        if sum >= a && sum <= b {
            total += i;
        }
    }

    let out = stdout();
    let mut out = out.lock();
    writeln!(out, "{}\n", total).unwrap();

}


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

#define rep(i,s,n) for(ll i = (s); i < (n); i++)
#define rep0(i,n) rep(i,0,n)
#define rep1(i,n) rep(i,1,n+1)

#define BR "\n"
#define SP " "

int main() {

  int N;
  cin >> N;

  vector<vector<ll>> G(N, vector<ll>(N, 0));

  rep0(i, N) {
    int u, k;
    cin >> u >> k;
    rep0(j, k) {
      int v;
      cin >> v;
      G[i][v - 1] = 1;
    }
  }

  rep0(i, N) {
    rep0(j, N - 1) {
      cout << G[i][j] << SP;
    }
    cout << G[i][N - 1] << BR;
  }
  return 0;
}


Measured memory_bytes: 3220
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;

int u[61][100010];

signed main(){
    int n;
    cin >> n;
    vector<int> x(n);
    rep(i, 0, n){
        cin >> x[i];
    }    
    int m, k;
    cin >> m >> k;
    vector<int> a(m);
    rep(i, 0, m){
        cin >> a[i];
        a[i]--;
    }
    vector<int> d(n - 1);
    rep(i, 0, n - 1){
        d[i] = i;
        u[0][i] = i;
    }
    rep(i, 0, m){
        swap(u[0][a[i] - 1], u[0][a[i]]);
    }
    rep(i, 1, 61){
        rep(j, 0, n - 1){
            u[i][j] = u[i - 1][u[i - 1][j]];
        }
    }
    for(int i = 60; i >= 0; i--){
        if(k >= ((int)1 << i)){
            k -= ((int)1 << i);
            rep(j, 0, n - 1){
                d[j] = u[i][d[j]];
            }
        }
    }
    int now = x[0];
    cout << x[0] << endl;
    rep(i, 0, n - 1){
        now += x[d[i] + 1] - x[d[i]];
        cout << now << endl;
    }
}

Measured memory_bytes: 51328
import sys
import math
from fractions import gcd
# import queue
from collections import Counter
# from itertools import accumulate
# from functools import reduce

def lcm(a, b):
    return a * b // gcd(a, b)

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

big_prime = 1000000007

"""
# 標準入力取得
## 文字列
 =  sys.stdin.readline().rstrip()
 =  list(sys.stdin.readline().rstrip())

## 数値
 =  int(sys.stdin.readline())
 =  map(int, sys.stdin.readline().split())
 =  list(map(int, sys.stdin.readline().split()))
 =  [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)]
"""

# 奇数側と偶数側でリストを分ける
# それぞれの最大値で置き換える
# 数値が一致してしまった時にどうするか
# 出現数順にソート、辞書を持つ
# 一致している場合とそうでない場合で分ける
# 療法試してmax取る


N =  int(sys.stdin.readline())
L =  list(map(int, sys.stdin.readline().split()))

E = L[::2]
O = L[1::2]

ce = Counter(E)
co = Counter(O)

cem = ce.most_common()
com = co.most_common()

if cem[0] != com[0]:
    print(N - cem[0][1] - com[0][1])
else:
    if len(cem) == 1 or len(com) == 1:
        print(N // 2)
    else:
        print(min(N - (cem[0][1] + com[1][1]), N - (cem[1][1] + com[0][1])))

Measured memory_bytes: 90108
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
int id[5000000],p[5000000],n;
using namespace std;
int main() 
{
    int n,ans=-1,sum=1;
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%d",&p[i]),id[p[i]]=i;
    for(int i=1;i<=n;i++)
    {
    	if(id[i]-id[i-1]>0 && i!=1) sum++;
    	else sum=1;
    	ans=max(ans,sum);
    }
    printf("%d\n",n-ans);
    return 0;
}

Measured memory_bytes: 3072
import java.util.Scanner;

public class Main {

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

		int n = sc.nextInt();
		long[] a = new long[n];
		for (int i=0;i<n;i++) {
			a[i]=sc.nextLong();
		}

		System.out.println(check(a)? "YES" : "NO");

	}

	static boolean check (long[] a) {
		int n = a.length;

		long sum = 0;
		for (int i=0;i<n;i++) {
			sum+=a[i];
		}

		if (sum%((long)n*(n+1)/2) != 0) {
			return false;
		} else {
			long step = sum/((long)n*(n+1)/2);
			long count = 0;
			for (int i=0;i<n-1;i++) {
				if ((a[i]-a[i+1]+step)%n != 0 || a[i]-a[i+1]+step < 0) {
					return false;
				}
				count += (a[i]-a[i+1]+step)/n;
			}

			if((a[n-1]-a[0]+step)%n != 0 || a[n-1]-a[0]+step < 0) {
				return false;
			} else {
				count += (a[n-1]-a[0]+step)/n;
			}

			return count==step;
		}
	}

}


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

int main() {
  int n, b, c = 100000000, r;
  cin >> n;
  long double a = 0.0, tmp = 10000;
  vector<int> v(n);
  rep(i, n){
    cin >> v[i];
    a += v[i];
  }
  a /= n;
  rep(i, n){
    if(tmp > abs(a-v[i])){
      tmp = abs(a-v[i]);
      r = i;
    }
  }
  cout << r << endl;
  return 0;
}

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

typedef long long ll;

#define REP(i, n) for(int i=0; i<(n); i++)
#define REPS(i, n) for(int i=0; i<=(n); i++)
#define FOR(i, a, b) for(int i=a; i<(b); i++)
#define FORS(i, a, b) for(int i=a; i<=(b); i++)
// for container x
#define ALL(v) (v).begin(),(v).end()
#define RALL(v) (v).rbegin(),(v).rend()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) *max_element(ALL(v))
#define MIN(v) *min_element(ALL(v))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;

int main(){
    int h1, m1, h2, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;

    m1 += h1*60;
    m2 += h2*60;

    int ans = 0;
    ans = m2-m1;
    ans -=k;

    cout << ans << endl;

    return 0;
}

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

typedef long long ll;
ll n, m, mx, a[105];
bool v[105];
void f(ll p, ll q) {
	ll i;
	bool t[105];
	for (i = 1; i <= n; i++) t[i] = v[i];
	if (p > n / 2) {
		for (i = p; i <= n; i++) if (a[i] > 0 && !v[i]) q += a[i];
		mx = max(mx, q);
		return;
	}
	if (v[p]) {
		f(p + 1, q);
		return;
	}
	if (a[p] > 0) {
		f(p + 1, q + a[p]);
	} else {
		f(p + 1, q + a[p]);
		for (i = p; i <= n; i += p) v[i] = 1;
		f(p + 1, q);
		for (i = 1; i <= n; i++) v[i] = t[i];
	}
}
int main()
{
	ll i;
	cin >> n;
	for (i = 1; i <= n; i++) {
		scanf ("%lld", &a[i]);
	}
	f(1, 0);
	cout << mx;
    return 0;
}


Measured memory_bytes: 256
n = gets.chomp.to_i
flag=0
9.times {|ii|
  i=ii+1
  9.times {|jj|
    j=jj+1
    if(i*j == n) then
      flag = 1; break
    end
  }
  if(flag==1) 
    break
  end
}

if(flag==1)
  puts "Yes"
else 
  puts "No"
end

Measured memory_bytes: 1788
from collections import deque
N = int(input())
uvw = [[]for i in range(N)]
for i in range(N-1):
    u,v,w = list(map(int,input().split()))
    uvw[u-1].append([v-1,w%2])
    uvw[v-1].append([u-1,w%2])    
color = [-1 for i in range(N)]
color[0] = 0
que = deque()
que.append(0)
while que:
    q = que.popleft()
    colorq = color[q]
    for i in uvw[q]:
        if color[i[0]] == -1:
            que.append(i[0])
            if i[1] == 0:
                color[i[0]] = colorq
            else:
                color[i[0]] = abs(colorq-1)
for i in color:
    print(i)

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

int main(void) {
	int N; cin >> N;
	bool Ans = false;
	for (int i = 1; i < 10; i++) {
		for (int j = 1; j < 10; j++) {
			if (N == i * j) {
				
				Ans = true;
				
			}
			
		}
	}
	if (Ans == true) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cmath>
#include<cstdio>
#include<algorithm>
using namespace std;
const int maxn=100010,inf=1000000000;
int n,a[maxn],maxa,mina,tot;
int main(){
	cin>>n;mina=inf;
	for(int i=1;i<=n;++i){
		scanf("%d",&a[i]);
		maxa=max(maxa,a[i]);
		if(a[i]<mina)mina=a[i],tot=0;
		if(a[i]==mina)tot++;
	}
	//cout<<mina<<' '<<tot<<' '<<maxa<<endl;
	if(maxa-mina>1)puts("No");
	else{
		if(maxa==mina){
			if(maxa<=n/2||maxa==n-1)puts("Yes");
			else puts("No");
		}
		else{
			if((maxa-tot>0)&&(maxa-tot)<=(n-tot)/2)puts("Yes");
			else puts("No");
		}
	}
	//system("pause");
	return 0;
}


Measured memory_bytes: 640
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String input = scanner.nextLine();
        String[] array = input.split(" ");

        int a = Integer.parseInt(array[0]) * Integer.parseInt(array[1]);
        int b = Integer.parseInt(array[2]) * Integer.parseInt(array[3]);

        if (a > b) {
            System.out.println(a);
        } else {
            System.out.println(b);
        }
    }
}


Measured memory_bytes: 23252
def abc121_d():
    a, b = map(int, input().split())
    ans = 0
    if b - a < 8:
        for k in range(a, b+1):
            ans ^= k
    else:
        low = (a + 3) // 4
        up = b // 4
        for k in range(a, 4*low):
            ans ^= k
        for k in range(4*up, b+1):
            ans ^= k
    print(ans)

if __name__ == '__main__':
    abc121_d()

Measured memory_bytes: 9104
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double D;
typedef complex<D> P;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;

template<typename T,typename U>istream & operator >> (istream &i,pair<T,U> &A){i>>A.F>>A.S; return i;}
template<typename T>istream & operator >> (istream &i,vector<T> &A){for(auto &I:A){i>>I;} return i;}
template<typename T,typename U>ostream & operator << (ostream &o,const pair<T,U> &A){o<<A.F<<" "<<A.S; return o;}
template<typename T>ostream & operator << (ostream &o,const vector<T> &A){ll i=A.size(); for(auto &I:A){o<<I<<(--i?" ":"");} return o;}
template<typename T>vector<T> & cset(vector<T> &A,T e=T()){for(auto &I:A){I=e;} return A;}

ll p;

ll order(ll a){
  ll ret=1,k=a;
  while(k!=1){
    ret++;
    (k*=a)%=p;
  }
  return ret;
}

ll mod_pow(ll a,ll x){
  ll ret=1;
  while(x>0){
    if(x&1){(ret*=a)%=p;}
    (a*=a)%=p;
    x>>=1;
  }
  return ret;
}


int main(){
  cin>>p;
  vector<ll> A(p);
  vector<ll> B(p-1);
  cin>>A;
  ll pr=1;
  while(order(pr)!=p-1){pr++;}
  ll k=1;
  for(int i=0;i<p-1;i++){
    B[i]=A[k];
    (k*=pr)%=p;
  }
  ll inv=mod_pow(pr,p-2);
  ll n=mod_pow(p-1,p-2);
  vector<ll> ans(p,0);
  k=1;
  for(int i=0;i<p-1;i++){
    ll l=1;
    for(int j=0;j<p-1;j++){
      ans[i]+=B[j]*l%p;
      ans[i]%=p;
      (l*=k)%=p;
    }
    (k*=inv)%=p;
  }
  for(auto &I:ans){I%=p; I*=n; I%=p;}
  ans[p-1]=ans[0]+p-A[0];
  ans[0]=A[0];
  for(auto &I:ans){I%=p;}
  cout<<ans<<endl;
  

  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
ll c[10][10];
ll ans;
int main(void){
    ll n; cin>>n;
    for(int i=1;i<=n;i++){
        ll k=i%10;
        ll l=i;
        while(l>=10){
            l=l/10;
        }
        c[k][l]++;
    }
    for(int i=1;i<=9;i++){
        for(int j=1;j<=9;j++){
            ans+=c[i][j]*c[j][i];
        }
    }
    cout<<ans<<endl;
    
}



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

typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
#define MP make_pair
#define PB push_back
#define X first
#define Y second

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ITER(it, a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))
#define debug(a) cout << #a << " = " << a << endl;

const double PI = acos(-1.0);
const LL INF = 1e9;
const LL LINF = INF * INF;

const int MAX = 1 << 17;
int n, m;
VI g[MAX];
int dp[MAX];
char u[MAX];

void dfs(int v)
{
	u[v] = 1;
	for(auto i: g[v])
	{
		if (!u[i])
			dfs(i);
		dp[v] = max(dp[v], dp[i] + 1);
	}
}

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//freopen("In.txt", "r", stdin);
	//freopen("In.txt", "w", stdout);

	int u1, v;
	cin >> n >> m;
	FOR(i, 0, m)
	{
		cin >> u1 >> v;
		g[u1].PB(v);
	}
	
	FOR(i, 1, n + 1)
		if (!u[i])
			dfs(i);
	
	int ans = 0;
	FOR(i, 1, n + 1)
		ans = max(ans, dp[i]);
	cout << ans << endl;
	cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
	return 0;
}


Measured memory_bytes: 8960
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <cmath>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define ITER( c ) __typeof( c ).begin()
#define REP( i, m, n ) for ( int i = m; i < n; i++ )
#define UREP( i, m, n ) for ( unsigned int i = m; i < n; i++ )
#define IREP( c, it ) for ( ITER(c) it = c.begin(); it != c.end(); ++it )
#define ALL( c ) c.begin(), c.end()
#define PB( n ) push_back( n );
#define MP( a, b ) make_pair( a, b )
#define fst first
#define snd second

int main()
{
	string word;
	int page;
	map<string, vector<int> > index;

	while ( cin >> word >> page )
	{
		index[ word ].PB( page );
	}
	
	IREP( index, it )
	{
		cout << (*it).fst << endl;

		sort( ALL( (*it).snd ) );

		REP( i, 0, (*it).snd.size() )
		{
			cout << (*it).snd[i] << ( i + 1 == (*it).snd.size() ? '\n' : ' ' );
		}
	}

	return 0;
}

Measured memory_bytes: 0
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cmath>
#define SIZE 105
#define PI 3.1415926535897932384626
#define EPS 1e-10

using namespace std;
typedef pair <int,int> P;

P pt[SIZE];

int main()
{
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		int x,y;
		scanf("%d %d",&x,&y);x--,y--;
		pt[i]=P(x,y);
	}
	for(int i=0;i<n;i++)
	{
		vector <double> vec;
		for(int j=0;j<n;j++)
		{
			if(j!=i)
			{
				double a=atan2(pt[j].second-pt[i].second,pt[j].first-pt[i].first);
				vec.push_back(a);
			}
		}
		sort(vec.begin(),vec.end());
		double ans=vec[0]+2.0*PI-vec[vec.size()-1];
		for(int j=0;j+1<vec.size();j++) ans=max(ans,vec[j+1]-vec[j]);
		if(ans+EPS<PI)
		{
			puts("0");
		}
		else
		{
			ans=2.0*PI-ans;
			printf("%.10f\n",0.5-ans/(2.0*PI));
		}
	}
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const int MOD = (int)1e9 + 7;
const int MAX_N = (int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>& p) { os << p.first << " " << p.second; return os; }
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) { for(int i = 0; i < (int) v.size(); i++) os << v[i] << (i + 1 != v.size() ? " " : ""); return os; }

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    vector<int> v(10, 0);
    for(int i = 0; i < 3; i++)
    {
        int x; cin >> x;
        v[x]++;
    }
    for(int i = 0; i < v.size(); i++)
    {
        if(v[i] == 2)
        {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
solve :: String -> String -> String
solve "1" "2" = "3"
solve "2" "1" = "3"
solve "1" "3" = "2"
solve "3" "1" = "2"
solve "2" "3" = "1"
solve "3" "2" = "1"
solve _ _     = "otherwise"

main = do
    a <- getLine
    b <- getLine
    let ans = read $ solve a b :: Int
    print ans

Measured memory_bytes: 508
#include<bits/stdc++.h>
using namespace std;
long long n;
int main(){
    cin>>n;
    for(int i=sqrt(n);i>=1;i--)
    {
        if(n%i==0){
            int l=n/i;
            int s=1;
            while(l>=10){
                s++;
                l/=10;
            }
        cout<<s;
        return 0;
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
const ll INF = 1e18;
#define print(x) cout << (x) << endl;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    cout << n*n*n << endl;
}

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

int main() {
    int N, M, X, Y;
    cin >> N >> M >> X >> Y;
    bool frag = true;
    int x, y, maxx, miny;
    maxx = -100;
    miny = 100;
    rep (i, N) {
        cin >> x;
        maxx = max(maxx, x);
    }
    rep(i, M) {
        cin >> y;
        miny = min(miny, y);
    }

    if (maxx < miny) {
        int Z = maxx + 1;
        while (Z <= miny) {
            if (X < Z && Z <= Y) {
                cout << "No War" << endl;
                frag = false;
                break;
            }
            Z++;
        }
    }
    if (frag) {
        cout << "War" << endl;
    }
}

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

using namespace std;

int main() {
  int N, K;
  cin >> N >> K;
  int T = 4 * K + 10;
  vector<vector<int>> ruiseki(T, vector<int>(T, 0));

  int con = 2 * K;
  for (int i = 0; i < N; i++) {
    int x, y;
    string c;
    cin >> x >> y >> c;
    x %= con;
    y %= con;
    if (c == "W") x += K;
    x %= con;
    ruiseki[x][y]++;
    ruiseki[x + con][y + con]++;
    ruiseki[x + con][y]++;
    ruiseki[x][y + con]++;
  }

  for (int i = 1; i < T; i++)
    for (int j = 1; j < T; j++)
      ruiseki[i][j] +=
          ruiseki[i - 1][j] + ruiseki[i][j - 1] - ruiseki[i - 1][j - 1];

  int ans = 0;
  for (int i = 0; i < con; i++)
    for (int j = 0; j < con; j++) {
      int tmp = ruiseki[i + 2 * K][j + 2 * K] - ruiseki[i + K][j + 2 * K] -
                ruiseki[i + 2 * K][j + K] + ruiseki[i + K][j + K];
      tmp += ruiseki[i + K][j + K] - ruiseki[i + K][j] - ruiseki[i][j + K] +
             ruiseki[i][j];
      ans = max(ans, tmp);
    }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 63232
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

int main(int argc, const char * argv[]) {
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N, M;
    cin >> N >> M;
    
    vector<bool> broken(N);
    rep(i, M)
    {
        int idx;
        cin >> idx;
        broken[idx] = true;
    }
    
    vector<int> dp(N+1);
    
    auto isOkInt = [&](int i)
    {
        if (broken[i]) return 0;
        else return 1;
    };
    
    dp[0] = 1;
    dp[1] = 1 * isOkInt(1);
    for(int i = 2; i <= N; ++i)
    {
        dp[i] = ( dp[i - 1] + dp[i - 2] ) * isOkInt(i);
        dp[i] %= 1000000007;
    }
    
    cout << dp[N] << endl;
    
    return 0;
}

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

#define ll long long int
const ll sz=1e4+100;;
const ll mod=1e9+7;
ll n;
struct node{;
    ll ara[55][55];
};

node Inp, Idn;

node Mul(node A, node B)
{
    node temp;
    for(ll i=1;i<=n;i++){
        for(ll j=1;j<=n;j++){
            temp.ara[i][j]=0;
            for(ll k=1;k<=n;k++){
                temp.ara[i][j]=(temp.ara[i][j] + (A.ara[i][k] * B.ara[k][j])%mod)%mod;
            }
        }
    }

    return temp;
}

node Bigmod(ll pr)
{
   // cout<<pr<<endl;
    if(pr==0) return Idn;
    else if(pr==1) return Inp;
    node temp=Bigmod(pr/2ll);

    temp=Mul(temp,temp);
    if(pr & 1ll) temp=Mul(temp, Inp);
    return temp;
}

int main()
{
    ll m,p,q,x,y,i,j,k,l,t;

    memset(Idn.ara,0,sizeof Idn.ara);

    cin>>n>>k;
    for(i=1;i<=n;i++){
        for(j=1;j<=n;j++){
            cin>>Inp.ara[i][j];
        }
    }

    for(i=1;i<=n;i++) Idn.ara[i][i]=1;


    node temp=Bigmod(k);

    ll ans=0;
    for(i=1;i<=n;i++){
        for(j=1;j<=n;j++){
            ans=(ans + temp.ara[i][j])%mod;
        }
    }

    cout<<ans<<'\n';
}




Measured memory_bytes: 9244
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s,t;
  cin >> s >> t;
  int sz = s.size();
  for(int i = 0; i<sz;++i){
    if(s.substr(i)==t){
      cout << "Yes" << endl;
      return 0;
    }
    s += s[i];
  }
  cout << "No" << endl;
}



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

#define REP(i,n) for(int i = 0; i < n; i++)
#define ll long long
#define PI 3.141592653589

int main(void){
    int a, b;
    scanf("%d %d",&a, &b);
    
    if((a*b) % 2){
        printf("Odd\n");
    } else{
        printf("Even\n");
    }
    return 0;
}

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

int main(void) {
    int N, M, X;
    cin >> N >> M >> X;

    int C[15] = {0};
    long long A[15][15] = {0};
    long long lowest = -1;
    for (int i=0; i<N; i++) {
        cin >> C[i];
        for (int j=0; j<M; j++) {
            cin >> A[i][j];
        }
    }

    for (int bit=0; bit<(1 << N); bit++) {
        vector<int> S;
        long long sum[15] = {0};
        long long cost = 0;
        for (int i=0; i<N; i++) {
            if (bit & (1<<i)) {
                S.push_back(i);
            }
        }
        /* 今回のパターンの各スキルの合計値を出す. */
        for (int i=0; i<S.size(); i++) {
            cost += C[S[i]];
            for (int j=0; j<M; j++) {
                sum[j] += A[S[i]][j];
            }
        }
        /* スキル習得済みかチェック. */
        bool judge = true;
        for (int j=0; j<M; j++) {
            if (sum[j] < X) judge = false;
        }
        /* 習得済みの場合、費用が最小値かどうか計算. */
        if (judge == true) {
            if ((cost < lowest) || (lowest == -1)) lowest = cost;
        }
    }

    cout << lowest << endl;

    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
int main() {
  int h, w, n, l, a;
  scanf("%d\n%d\n%d", &h, &w, &n);
  l = max(h, w);
  a = n % l;
  l = (n - a) / l;
  if (a > 0) l += 1;
  printf("%d\n", l);
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

const int N=9e5+5,mo=1e9+7;

typedef long long LL;

int n,m,K,ans,Fac[N],Inv[N],p[N];

int C(int n,int m)
{
    return (LL)Fac[n]*Inv[m]%mo*Inv[n-m]%mo;
}

int main()
{
    p[0]=Fac[0]=Inv[0]=Fac[1]=Inv[1]=1; p[1]=3;
    for (int i=2;i<N;i++) Inv[i]=(LL)Inv[mo%i]*(mo-mo/i)%mo;
    for (int i=2;i<N;i++)
    {
        p[i]=p[i-1]*3ll%mo; Fac[i]=(LL)Fac[i-1]*i%mo; Inv[i]=(LL)Inv[i-1]*Inv[i]%mo;
    }
    scanf("%d%d%d",&n,&m,&K); n--;
    if (m<K) swap(m,K);
    for (int i=0,j=1;i<=m+K;i++)
    {
        ans=(ans+(LL)C(n+i,n)*p[m+K-i]%mo*j)%mo;
        if (i<K) j=j*2%mo;
        else if (i>=m) j=(j*2ll-C(i,K)-C(i,i-m))%mo;
        else j=(j*2ll-C(i,K))%mo;
    }
    if (ans<0) ans+=mo;
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 10752
n = int(input())
a = list(map(int,input().split()))
x = 1000
z = 0

if a == sorted(a,reverse=True):
    print(x)

else:
    for i in range(n-1):
        if a[i] <= a[i+1]:
            y = x//a[i]
            x = x -y*a[i]
            z = z+y
        elif a[i] > a[i+1]:
            x = z*a[i]+x
            z = 0
    x = x + z*a[n-1]
    print(x)

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

int g[100005], k[100005], n, ans;
int main(){
    cin >> n;
    n /= 2;

    int maxk=0, maxg=0;
    for(int i=0; i<n; ++i){
        int w1, w2;
        cin >> w1 >> w2;
        ++k[w1]; ++g[w2];
        if(k[maxk] < k[w1]){ maxk = w1; }
        if(g[maxg] < g[w2]){ maxg = w2; }        
    }

    sort(g, g+100001);  reverse(g, g+100001);
    sort(k, k+100001);  reverse(k, k+100001);


    if(maxk == maxg){
        int w1 = n - g[0] + n - k[1];
        int w2 = n - g[1] + n - k[0];
        cout << min(w1, w2) << endl;
    }else{
        ans = n - g[0] + n - k[0];
        
        cout << ans << endl;
    }

}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define ll long long int
#define vi vector<int>
#define vl vector<ll>
#define ppi pair<int,int>
#define ppl pair<ll,ll>
#define all(x) x.begin(),x.end()
#define ii int,int 
#define mm map<ii>
#define ff first    
#define ss second
#define forn(i,a,b) for(int i=a;i<b;i++)
#define forr(i,a,b) for(int i=a;i>=b;i--)
#define forv(i,m) for(auto i : m)
#define imx INT_MAX
#define imn INT_MIN
#define inf LONG_MAX
#define minf LONG_MIN
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define sze size()
#define rvs reverse 
#define itr iterator 

/*
#define MODM(a,b,md) ((a%md)*(b%md))%md
#define MODA(a,b,md) ((a%md)+(b%md))%md
#define ull unsigned long long int
#define si short int
*/

/*
bool compare(int a,int b) {return a > b;}
bool compare1(ppi a,ppi b) {return a.ff > b.ff;}
bool compare2(ppi a,ppi b) {return a.ss < b.ss;}
ll Npower(ll a,ll b) {ll product = 1; while(b){if(b&1){product = product*a;}a = a*a;b = b>>1;} return product;}
ll power(ll a,ll b,ll md) {ll product = 1; while(b){if(b&1){product = MODM(product,a,md);}a = MODM(a,a,md);b = b>>1;} return product%md;}
ll GCD(ll a,ll b) {return b==0 ? a:GCD(b,a%b);}
ll LCM(ll a,ll b) {return (a/GCD(a,b))*b; }
*/


int main()
{
	fast

	int a;
	string str;
	cin>>a>>str;

	if(a < 3200)
	{
		cout<<"red";
	}
	else
	{
		cout<<str;
	}


	return 0;
}

Measured memory_bytes: 256
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.util.InputMismatchException;
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);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int[] a = in.nextIntArray(n);

            int max = a[0];
            int min = a[0];
            for (int i = 0; i < n; i++) {
                max = Math.max(max, a[i]);
                min = Math.min(min, a[i]);
            }

            out.println(max - min);
        }

    }

    static class InputReader {
        BufferedReader in;
        StringTokenizer tok;

        public String nextString() {
            while (!tok.hasMoreTokens()) {
                try {
                    tok = new StringTokenizer(in.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return tok.nextToken();
        }

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

        public int[] nextIntArray(int n) {
            int[] res = new int[n];
            for (int i = 0; i < n; i++) {
                res[i] = nextInt();
            }
            return res;
        }

        public InputReader(InputStream inputStream) {
            in = new BufferedReader(new InputStreamReader(inputStream));
            tok = new StringTokenizer("");
        }

    }
}



Measured memory_bytes: 21332
n,m=map(int,input().split())
h=list(map(int,input().split()))
edges=[[] for i in range(n)]
ans=0
for  i in range(m):
    a,s=map(int,input().split())
    edges[a-1].append(s-1)
    edges[s-1].append(a-1)
for  i in range(n):

    if edges[i]!=[]:
        now=h[i]
        for ii in edges[i]:
            if h[ii]>=now:break
        else:ans+=1
    else:ans+=1
print(ans)

Measured memory_bytes: 29472
fn read_stdin() -> String {
    use std::io::Read;
    let mut input = String::new();
    std::io::stdin().read_to_string(&mut input).unwrap();
    input
}

fn scan<'a, I: Iterator<Item = &'a str>, T: std::str::FromStr>(tokens: &mut I) -> T {
    tokens.next().unwrap().parse().ok().unwrap()
}

fn vec<T, F: FnMut(usize) -> T>(n: usize, mut f: F) -> Vec<T> {
    (0..n).map(|i| f(i)).collect()
}

fn main() {
    let input = read_stdin();
    let tokens = &mut input.split_whitespace();
    let na: usize = scan(tokens);
    let nb: usize = scan(tokens);
    let m: usize = scan(tokens);
    let a: Vec<usize> = vec(na, |_| scan(tokens));
    let b: Vec<usize> = vec(nb, |_| scan(tokens));
    let mut min: usize = a.iter().min().unwrap() + b.iter().min().unwrap();
    for _ in 0..m {
        let x: usize = scan(tokens);
        let y: usize = scan(tokens);
        let c: usize = scan(tokens);
        let (x, y) = (x - 1, y - 1);
        min = std::cmp::min(min, a[x] + b[y] - c);
    }
    println!("{}", min);
}


Measured memory_bytes: 10360
main :: IO ()
main = do
  [a, b, k] <- map read . words <$> getLine
  putStrLn $ unwords $ map show $ solve a b k

solve :: Int -> Int -> Int -> [Int]
solve 0 b k
  | b > k     = [0, b - k]
  | otherwise = [0, 0]
solve a b k
  | a > k     = [a - k, b]
  | otherwise = solve 0 b (k - a)

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

using namespace std;
using ll = long long;

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

    int n, q, a;
    cin >> n;
    map<int, int> num;
    ll s = 0;
    for(int i = 0; i < n; ++i) {
        cin >> a;
        s += a;
        num[a]++;
    }
    cin >> q;
    int b, c;
    for(int i = 0; i < q; ++i) {
        cin >> b >> c;
        if(num[b] != 0) {
            s += (c - b) * num[b];
            num[c] += num[b];
            num[b] = 0;
        }
        printf("%lld\n", s);
    }


    return 0;
}

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

int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}

int main(){
	int a;
    int b[100];
	int i,k,result;
	result = 0;
	scanf("%d",&a);
	for(i=0;i<a;i++){
     scanf("%d",&b[i]);
	}
	qsort(b, a, sizeof(int), compare_int);
	for(k=1;k<a;k++){
		result = result + (b[k] - b[k-1]);
	}
	printf("%d",result);
return 0;
}

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define all(x) (x).begin(),(x).end()
#define int long long
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;

signed main(){
    int a,b,c;
    cin >> a >> b >> c;
    if(c-(a-b) < 0) cout << 0 << '\n';
    else cout << c-(a-b) << '\n';   
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<math.h>
#include<set>
#include<map>
#include<time.h>
#include<cstring>
#include<iomanip>
#include<numeric>
#include<list>
#define lli long long int
#define h 10000
#define pf push_front
#define pb push_back
#define ub upper_bound
#define lb lower_bound
using namespace std;
int main() 
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL) ;
  lli x;
  cin>>x;
  cout<<(!x)<<endl;
  return 0;
} 


Measured memory_bytes: 3604
#include <iostream>
using namespace std;
int main() {
	int n; cin >> n;
	bool flag = false;
	for (int i = 0; i < n; i++) {
		int x; cin >> x;
		if (x % 2 == 1)flag = true;
	}
	puts(flag ? "first" : "second");
}

Measured memory_bytes: 256
# include <bits/stdc++.h>
# define ll long long
using namespace std;
const int N = 2e5 + 10, mod = 1e9 + 7;
ll n, dp[N][2];
vector < int > edges[N];
void dfs(int x, int p){
    dp[x][0] = dp[x][1] = 1;
    for(int i : edges[x]){
        if(i != p){
            dfs(i, x);
            dp[x][0] *= (dp[i][1] + dp[i][0]) % mod;
            dp[x][1] *= dp[i][0];
            dp[x][0] %= mod;
            dp[x][1] %= mod;
        }
    }
}
int main(){
    cin >> n;
    for(int i = 1; i < n; i++){
        int a, b;
        cin >> a >> b;
        edges[a].push_back(b);
        edges[b].push_back(a);
    }
    dfs(1, 0);
    cout << (dp[1][0] + dp[1][1]) % mod << endl;
}

Measured memory_bytes: 16512
#include<bits/stdc++.h>
using namespace std;
#define COST_MAX 1000000000
int main(){
  long N,M;cin>>N>>M;
  vector<long>A(M),C(M,0);
  for(long i=0;i<M;i++){
    long b;cin>>A[i]>>b;
    for(long j=0;j<b;j++){long c;cin>>c;C[i]|=(1<<(c-1));}
  }
  vector<long>DP(1<<N,COST_MAX);DP[0]=0;
  for(long i=0;i<M;i++){
    for(long b=0;b<(1<<N);b++){
      DP[b|C[i]]=min(DP[b|C[i]],DP[b]+A[i]);
    }
  }
  if(DP[(1<<N)-1]==COST_MAX)DP[(1<<N)-1]=-1;
  cout<<DP[(1<<N)-1]; 
}

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

#define all(x) x.begin(),x.end()
#define pb push_back
#define ss second
#define ff first

int main(){
	int n, m, cnt=0;	cin>>n>>m;
	vector<int>A(n),B(n);
	for(int i=0;i<m;i++){
		int l,r;	cin>>l>>r;
		l--;r--;
		A[l]++;
		if(r<n-1)	A[r+1]--;
	}
	B[0] = A[0];
	for(int i=1;i<n;i++)
	B[i] = B[i-1] + A[i];
	for(int i=0;i<n;i++)
	if(B[i] == m)
	cnt++;
	cout<<cnt<<endl;
	
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
const int N=100010,M=1000010,P=1e9+7;
const int inf=0x3f3f3f3f;
const int INF=0xcfcfcfcf;
const db eps=1e-9,pi=asin(1)*2;
inline ll read();
#define cmax(a,b) a=max(a,b)
#define cmin(a,b) a=min(a,b)
inline int ADD(int a,int b) { return a+b>=P?a+b-P:a+b; }
inline int MINUS(int a,int b) { return a-b<0?a-b+P:a-b; }
#define plus(a,b) a=ADD(a,b)
#define minus(a,b) a=MINUS(a,b)
#define mul(a,b) a=(1ll*a*(b))%P
#define mem(a,b) memset(a,b,sizeof(a))
#define pii pair<int,int>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define pll pair<ll,ll>
#define mp(x,y) make_pair(x,y)
#define lowbit(x) ((x)&-(x))

int n,k;

#ifdef FILE
const int RS=1<<20;
char buf[RS],*p1=buf,*p2=buf;
#define getchar() p1==p2&&(p2=(p1=buf)+fread(buf,1,RS,stdin),p1==p2)?EOF:*p1++
#endif
inline ll read()
{
	ll s=0;
	bool flag=false;
	char ch=getchar();
	for(;ch<'0'||ch>'9';ch=getchar()) if(ch=='-') flag=true;
	for(;'0'<=ch&&ch<='9';ch=getchar()) s=(s<<3)+(s<<1)+(ch^'0');
	if(flag) return -s;
	return s;
}

int main()
{
#ifdef FILE
	freopen(FILE ".in","r",stdin);
	freopen(FILE ".out","w",stdout);
#endif
	n=read();
	if(lowbit(n)==n)
	{
		printf("No\n");
		return 0;
	}
	printf("Yes\n");
	if(n==3)
	{
		printf("1 2\n2 3\n3 4\n4 5\n5 6\n");
		return 0;
	}
	for(k=1;(k<<1)<=n;k<<=1);
	for(int i=1;i<k-1;i++) printf("%d %d\n",i,i+1);
	printf("%d %d\n",k-1,n+1);
	for(int i=1;i<k-1;i++) printf("%d %d\n",n+i,n+i+1);
	printf("%d %d\n",n+k,1);
	printf("%d %d\n",n+k,k+1);
	printf("%d %d\n",n+k+1,1);
	printf("%d %d\n",k,n+k+1);
	for(int i=k+2;i<=n;i++)
	{
		printf("%d %d\n",i,n+i-1);
		printf("%d %d\n",n+i,i-k);
	}
	return 0;
}

Measured memory_bytes: 2688
kingaku, n = input().split()
no_num = input().split()
ok_num = [str(i) for i in range(10) if not str(i) in no_num]
result = []
 
for i in kingaku:
    for j in ok_num:
        if i == j:
            result.append(j)
            break
        elif i < j:
            result.append(j)
            print("".join(result).ljust(len(kingaku), ok_num[0]))
            exit()
            break
    else:
        n = 1 if ok_num[0] == '0' else 0
        print(ok_num[n].ljust(len(kingaku)+1, ok_num[0]))
        exit()
 
print(''.join(result))

Measured memory_bytes: 61964
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

namespace MyProgram{
    public class Program
    {	
        public static void Main(string[] args)
    	{
            char turn = 'A';
            List<char> sa = new List<char>();
            List<char> sb = new List<char>();
            List<char> sc = new List<char>();
            
            string s = Console.ReadLine();
            for(int i = 0 ; i < s.Length ; i++) sa.Add(s[i]);
            s = Console.ReadLine();
            for(int i = 0 ; i < s.Length ; i++) sb.Add(s[i]);
            s = Console.ReadLine();
            for(int i = 0 ; i < s.Length ; i++) sc.Add(s[i]);
            
            
            while(true)
            {
                if(turn == 'A')
                {
                    if(sa.Count == 0) break;
                    else
                    {
                        turn = char.ToUpper(sa[0]);
                        sa.RemoveAt(0);
                    }
                }
                else if(turn == 'B')
                {
                    if(sb.Count == 0) break;
                    else
                    {
                        turn = char.ToUpper(sb[0]);
                        sb.RemoveAt(0);
                    }
                }
                else
                {
                    if(sc.Count == 0) break;
                    else
                    {
                        turn = char.ToUpper(sc[0]);
                        sc.RemoveAt(0);
                    }
                }
            }
            Console.WriteLine(turn);
    	}
    }
}

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

int main() {
  int a,b;
  cin >> a >> b;
  
  int pro; //product
  pro = a*b;  

  if (pro%2 == 0) {
    cout << "Even" << endl;
  }
  else {
    cout << "Odd" <<endl;
  }
}

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

int main() {
	int i,a,b,c,n;
	
	cin >> a >> b >> c;
	n=0;
	for(i=a; i<=b; i++){
		if(c%i == 0){
			n++;
		}
	}
	cout << n << endl;
	return 0;
}

Measured memory_bytes: 1164
import java.util.Scanner;
public class Main {
 
	public static void main(String[] args) {
		  Scanner sc = new Scanner(System.in);
	         
          int X = sc.nextInt();
     	  int Y = sc.nextInt();
      	  int Z = sc.nextInt();
      
      System.out.println(Z+" "+X+" "+Y);
    }
}

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


int main()
{
  int n;
  cin >> n;
  vector<queue<int>> a(n);
  rep(i, n)
    rep(j, n - 1)
    {
      int ipt;
      cin >> ipt;
      ipt--;
      a[i].push(ipt);
    }
  set<pair<int, int>> s;
  rep(i, n - 1)
  {
    int op = a[i].front();
    if (i == a[op].front() && i < op)
      s.emplace(i, op);
  }
  int ans = 0;
  while (!s.empty())
  {
    ans++;
    set<pair<int, int>> s2;
    while (!s.empty())
    {
      auto p = *s.begin();
      s.erase(s.begin());
      a[p.first].pop();
      a[p.second].pop();
      if (!a[p.first].empty())
      {
        int op = a[p.first].front();
        if (!a[op].empty() && p.first == a[op].front())
          s2.emplace(min(p.first, op), max(p.first, op));
      }
      if (!a[p.second].empty())
      {
        int op = a[p.second].front();
        if (!a[op].empty() && p.second == a[op].front())
          s2.emplace(min(p.second, op), max(p.second, op));
      }
    }
    s.swap(s2);
  }
  rep(i, n)
    if (!a[i].empty())
    {
      puts("-1");
      return 0;
    }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4736