akhauriyash/Code-Regression huggingface dataset:
# -*- coding: utf-8 -*-

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
#from math import gcd
import bisect
from collections import defaultdict
from collections import deque
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]

######OUTPUT######
def Yes(): print("Yes"); return
def No(): print("No"); return

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    return arr

#####MakeDivisors######
def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors

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

#####BitCount#####
def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count

#####ChangeBase#####
def Base_10_to_n(X, n):
  if (int(X/n)):
    return Base_10_to_n(int(X/n), n)+[X%n]
  return [X%n]


#############
# Main Code #
#############

N = inputI()
if N < 4:
  print(1)
  exit()

M = 0
for i in range(2,N+1):
  f = factorization(i)
  shisuu = [q for p,q in f]
  m = min(shisuu)
  if m != 1:
    r = [i%m for i in shisuu]
    if sum(r) == 0:
      M = i
    
print(M)

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

int main() {
  int h, w;
  cin >> h >> w;
  vector<vector<int>> a(h, vector<int>(w)), b(h, vector<int>(w));
  for (auto& v : a) {
    for (auto& e : v) cin >> e;
  }
  for (auto& v : b) {
    for (auto& e : v) cin >> e;
  }

  constexpr int S = 80 * 80;
  vector<vector<bitset<2 * S + 1>>> s(h + 1, vector<bitset<2 * S + 1>>(w + 1));
  s[0][0].set(S);
  s[0][1].set(S);
  s[1][0].set(S);
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      int d = abs(a[i][j] - b[i][j]);
      s[i + 1][j + 1] |= s[i][j + 1] << d;
      s[i + 1][j + 1] |= s[i][j + 1] >> d;
      s[i + 1][j + 1] |= s[i + 1][j] << d;
      s[i + 1][j + 1] |= s[i + 1][j] >> d;
    }
  }
  string ss = (s[h][w] >> S).to_string();
  cout << find(ss.rbegin(), ss.rend(), '1') - ss.rbegin() << endl;
}


Measured memory_bytes: 10752
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <cmath>
#include <cstdio>

using namespace std;

typedef long long ll;

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

int main(int argc, char **argv)
{
    int a, b, c;
    cin >> a >> b >> c;
    cout << a * b / 2 << endl;
    return 0;
}


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

int main(){
	int K,S;
	cin>>K>>S;
	int ans=0;
	int total;
	for(int x=0;x<=K;++x){
		for(int y=x;y<=K;++y){
			for(int z=y;z<=K;++z){
				total=x+y+z;
				if (total==S){
					if((x!=y) && (y!=z)) ans+=6;
					else if((x==y) && (y==z)) ans+=1;
					else ans+=3;
				}
			}
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define eps LDBL_EPSILON
#define moder 1000000007
#define int long long
#define ll long long
#define INF ((ll)1<<31)-1
#define P std::pair<int,int>
#define prique priority_queue<int,vector<int>,greater<int>>
using namespace std;
int gcd(int a,int b){
	if(!a)return b;
	return gcd(b%a,a);
}
int lcm(int a,int b){
	return a/gcd(a,b)*b;
}
signed main(){
	int n,a[110],sum=0;
	cin>>n;
	rep(i,n){
		cin>>a[i];
		sum+=a[i];
	}
	if(sum%2==0)cout<<sum/2<<endl;
	else{
		sort(a,a+n);
		rep(i,n){
			if(a[i]%2){
				cout<<(sum-a[i])/2<<endl;
				return 0;
			}
		}
	}
    return 0;
}




Measured memory_bytes: 3144
N = int(input())
reds = sorted([tuple(map(int, input().split())) for _ in range(N)], reverse=True, key=lambda x: x[1])
blues = sorted([tuple(map(int, input().split())) for _ in range(N)])
# print(reds)
# print(blues)
ans = 0
for b in blues:
    for r in reds:
        if r[0] < b[0] and r[1] < b[1]:
            ans += 1
            reds.remove(r)
            break
print(ans)


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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
using ld = long double;
ll INF = LLONG_MAX;

using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;

namespace output {
	void pr(int x) { cout << x; }
	void pr(long x) { cout << x; }
	void pr(ll x) { cout << x; }
	void pr(unsigned x) { cout << x; }
	void pr(unsigned long x) { cout << x; }
	void pr(unsigned long long x) { cout << x; }
	void pr(float x) { cout << x; }
	void pr(double x) { cout << x; }
	void pr(ld x) { cout << x; }
	void pr(char x) { cout << x; }
	void pr(const char* x) { cout << x; }
	void pr(const string& x) { cout << x; }
	void pr(bool x) { pr(x ? "true" : "false"); }
	template<class T> void pr(const complex<T>& x) { cout << x; }
	
	template<class T1, class T2> void pr(const pair<T1,T2>& x);
	template<class T> void pr(const T& x);
	
	template<class T, class... Ts> void pr(const T& t, const Ts&... ts) { 
		pr(t); pr(ts...); 
	}
	template<class T1, class T2> void pr(const pair<T1,T2>& x) { 
		pr("{",x.f,", ",x.s,"}"); 
	}
	template<class T> void pr(const T& x) { 
		pr("{"); // const iterator needed for vector<bool>
		bool fst = 1; for (const auto& a: x) pr(!fst?", ":"",a), fst = 0; 
		pr("}");
	}
	
	void print() { pr("\n"); } // print w/ spaces
	template<class T, class... Ts> void print(const T& t, const Ts&... ts) { 
		pr(t); if (sizeof...(ts)) pr(" "); print(ts...); 
	}
}

using namespace output;

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int X; cin >> X;
	print(10 - X / 200);
}

Measured memory_bytes: 3640
#include <stdio.h>

main(){
  int data[102];
  int count1, count2, sum, a, b,i,t=0;

  while(1){
    for(i=0;i<102;i++){
      data[i]=0;
    }
    
    while(1){
      if(scanf("%d %d", &a, &b)==EOF){
	t=1;
	break;
      }
      if(a==0 && b==0) break;

	data[b]++;
	data[a]--;
    }

    if(t==1) break;

    count1=count2=0;
    for(i=0;i<102;i++){
      if(data[i]==1) count1++;
      else if(data[i]==-1) count2++;
    }

    if(count1==1 && count2==1) printf("OK\n");
    else printf("NG\n");
  }
  return 0;
}

Measured memory_bytes: 0
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln = '\n';
constexpr long long MOD = 1000000007;
//constexpr long long MOD = 998244353;
template<class T1, class T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return true;} return false; }
template<class T1, class T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return true;} return false; }
inline int popcount(int x) {return __builtin_popcount(x);}
inline int popcount(long long x) {return __builtin_popcountll(x);}
void print() { cout << "\n"; }
template<class T, class... Args>
void print(const T &x, const Args &... args) {
    cout << x << " ";
    print(args...);
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    auto solve=[](vector<string> S) {
        int N = S.size();
        int M = S[0].size();
        int ret = 0;
        vector<vector<int>> A(N, vector<int>(M-1,1));
        rep(i,N-1) {
            rep(j,M-1) {
                int a = S[i][j]==S[i][j+1];
                int b = S[i+1][j]==S[i+1][j+1];
                if (a^b) continue;
                A[i+1][j] = A[i][j]+1;
            }
        }
        rep(i,N) {
            vector<pii> sta;
            rep(j,M-1) {
                int pos = j;
                if (!sta.empty() and A[i][j] < sta.back().first) {
                    while (!sta.empty() and sta.back().first >= A[i][j]) {
                        auto[h,x] = sta.back(); sta.pop_back();
                        chmax(ret,h*(j-x+1));
                        pos = x;
                    }                
                }
                if (sta.empty() or A[i][j] > sta.back().first) {
                    sta.emplace_back(A[i][j],pos);
                }
            }
            while (!sta.empty()) {
                auto[h,x] = sta.back(); sta.pop_back();
                chmax(ret,h*(M-1-x+1));
            }
        }

        return ret;
    };

    int N,M; cin >> N >> M;
    vector<string> S(N);
    rep(i,N) cin >> S[i];

    int ans = solve(S);
    vector<string> T(M, string(N,' '));
    rep(i,N) rep(j,M) T[j][i] = S[i][j];
    chmax(ans,solve(T));

    cout << ans << ln;
}


Measured memory_bytes: 31208
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD (ll)(1E9+7)
#define PI 3.1415926535897932384

template <class T>ostream &operator<<(std::ostream &o, const vector<T> &v)
{
	rep(i, v.size()) {
		o << (i > 0 ? " " : "") << v[i];
	}
	return o;
}

int main() {
	int n, ma = -1;
	string str;
	cin >> n >> str;
	if (n == 2&&str[0]==str[1]) {
		cout << 1 << endl;
		return 0;
	}
	else if (n == 2 && str[0] != str[1]) {
		cout << 0 << endl;
		return 0;
	}
	for (int i = 1; i < n - 1; i++) {
		int count = 0;
		string tmp1 = str.substr(0, i+1);
		string tmp2 = str.substr(i + 1);
		//cout << tmp1 << "  " << tmp2 << endl;
		sort(all(tmp1));
		sort(all(tmp2));
		for (int j = 0; j < tmp1.size(); j++) {
			if (j != 0 && tmp1[j] == tmp1[j - 1])	continue;
			for (int k = 0; k < tmp2.size(); k++) {
				if (k != 0 && tmp2[k] == tmp2[k - 1]) continue;
				if (tmp1[j] == tmp2[k]) count++;
			}
		}
		ma = max(ma, count);
	}
	cout << ma << endl;
}


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


int main(){
  int p,sp,n;
  sp=n=0;
  float s,ss;
  ss=0.0;
  while(scanf("%d,%f",&p,&s)>0){
      n++;
      sp+=p*s;
      ss+=s;
  }
  printf("%d\n%.0f\n",sp,roundf(ss/n));
  return 0;
}

Measured memory_bytes: 1076
N,M,X,Y = map(int,input().split())
x = list(map(int,input().split()))
y = list(map(int,input().split()))
a = max(x)
b = min(y)
flag = 0
for i in range(X+1,Y+1):
    if a < i <= b:
        flag = 1
        break
print("No War" if flag == 1 else "War")

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
#include<string.h>
#include <iomanip>
#include <sstream>
using namespace std;

int main() {
  double T, X;
  int ans = 0;
  string s;

  cin >> T >> X;

  //小数点以下指定
  cout << fixed;
  cout << setprecision(5) << T/X << endl;


}


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

long long C[51][51];

void comb_table(int N) {
  for (int i = 0; i <= N; i++) {
    for (int j = 0; j <= i; j++) {
      if (j == 0 || j == i) {
        C[i][j] = 1;
      } else {
        C[i][j] = C[i - 1][j - 1] + C[i - 1][j];
      }
    }
  }
}

void Main() {
  int N, A, B;
  cin >> N >> A >> B;
  vector<long long> v(N);
  for (int i = 0; i < N; i++) {
    cin >> v[i];
  }

  sort(v.rbegin(), v.rend());

  double ansMax = 0;
  for (int i = 0; i < A; i++) {
    ansMax += v[i];
  }
  cout << ansMax / A << endl;

  comb_table(N);

  int num = 0, pos = 0;
  for (int i = 0; i < N; i++) {
    if (v[i] == v[A - 1]) {
      num++;
      if (i < A) pos++;
    }
  }

  long long cnt = 0;
  if (pos == A) {
    for (pos = A; pos <= B; pos++) {
      cnt += C[num][pos];
    }
  } else {
    cnt += C[num][pos];
  }

  cout << cnt << endl;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}



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

using ll = long long;

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

	if (s.size() >= 4 && s.substr(0, 4) == "YAKI") {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}


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

#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define reps(i,n) for (int i = 1; i <= (int)(n); ++i)
#define repd(i,n) for (int i = (int)(n - 1); i >= 0; --i)
#define repds(i,n) for (int i = (int)(n); i > 0; --i)
#define loop(i,x,n) for (int i = (int)(x); i < (n); ++i)
#define loops(i,x,n) for (int i = (int)(x); i <= (n); ++i)
#define loopd(i,x,n) for (int i = (int)(x); i > (n); --i)
#define loopds(i,x,n) for (int i = (int)(x); i >= (n); --i)
#define itrep(i,a) for (auto i = begin(a); i != end(a); ++i)
#define itrepd(i,a) for (auto i = rbegin(a); i != rend(a); ++i)
#define all(f,x,...) [&](decltype(x)& whole) { return (f)(begin(whole), end(whole), ##__VA_ARGS__); }(x)
using namespace std;
using ll = long long;
using ld = long double;
template<class T> using priority_queuel = priority_queue<T, vector<T>, greater<T>>;
constexpr ll inf = static_cast<ll>(1e18);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e18;
constexpr double eps = 1e-10;
ll mod = static_cast<ll>(1e9 + 7);
template<class T> constexpr int sz(const T& a) { return (int)a.size(); }
template<class T> constexpr T pow2(const T a) { return a * a; }
template<class T, class ... Args> constexpr void mins(T& a, Args... args) { a = min<T>({ a, args... }); }
template<class T, class... Args> constexpr void maxs(T& a, Args... args) { a = max<T>({ a,args... }); }
template<class A, int N, class T>
void fillArray(A(&array)[N], const T& val) { std::fill((T*)array, (T*)(array + N), val); }


int n;
ll ans = 0;
int a[55], b[55];
int d[51];
bool check(int idx) {
    vector<vector<int>> g(51);
    reps(i, 50) {
        vector<bool> used(51, false);
        reps(j, 50) {
            if (!used[i % j] && (j <= idx || (ans >> j) & 1)) {
                used[i % j] = true;
                g[i].push_back(i % j);
            }
        }
    }
    priority_queuel<pair<int, int>> que;
    rep(k, n) {
        fillArray(d, iinf);
        d[a[k]] = 0;
        que.emplace(0, a[k]);
        while (!que.empty()) {
            auto p = que.top(); que.pop();
            int v = p.second;
            if (d[v] < p.first) continue;
            rep(i, sz(g[v])) {
                auto nv = g[v][i];
                if (d[nv] > d[v] + 1) {
                    d[nv] = d[v] + 1;
                    que.emplace(d[nv], nv);
                }
            }
        }
        if (d[b[k]] >= iinf) return false;
    }
    return true;
}
void solve() {
    cin >> n;
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> b[i];
    rep(i, n) if (a[i] < b[i]) { cout << -1 << endl; return; }

    if (!check(51)) { cout << -1 << endl; return; }
    repd(i, 51) {
        if (!check(i)) ans |= 1LL << (i + 1);
    }
    cout << ans << endl;
}

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


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int x[] = new int[n];
        
        int min = Integer.MAX_VALUE;
        for (int i=0; i<n; i++) {
            x[i] = sc.nextInt();
            if (i >= k-1) {
                int total = x[i] - x[i-k+1] + minAbs(x[i], x[i-k+1]);
                if (total < min) {
                    min = total;
                }
            }
        }
        System.out.println(min);
    }

    private static int minAbs(int a, int b) {
        int min = Math.abs(a);
        if (Math.abs(b) < min) { min = Math.abs(b); } 
        return min;
    }
}


Measured memory_bytes: 52616
N, M  = map(int, input().split())
S = [list(map(int, input().split())) for _ in range(M)]
P = list(map(int, input().split()))
count = 0
for i in range(2**N):
    bit = format(i, 'b').zfill(N)
    light = [0] * M
    for j in range(M):
        num = 0
        for k in range(S[j][0]):
            num += int(bit[S[j][k+1]-1])
        if num % 2 == P[j]:
            light[j] = 1
    if all([on == 1 for on in light]):
        count += 1
print(count)


Measured memory_bytes: 3064
#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>;
vector<int> to[100005];
vector<bool> visited(100005);
vector<int> h;
bool dfs(int cur) {
    bool ok = true;
    for(auto v : to[cur]) {
        if (h[cur] > h[v]) {
            visited[v] = true;
        } else {
            ok = false;
        }
    }
    return ok;
}
int main() {
    int n, m; cin >> n >> m;
    h.resize(n);
    rep(i, n) cin >> h[i];
    rep(i, m) {
        int a, b; cin >> a >> b;
        a--; b--;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    int cnt = 0;
    rep(i, n) {
        if(visited[i]) continue;
        if (dfs(i)) {
            cnt++;
        }
    }
    cout << cnt;
}


Measured memory_bytes: 8752
#include <iostream>
#include <string>
using namespace std;
 
int main() {
    int n;
    double ttl;
    double *a_heap;
    bool bRet;
    ttl = 0.0;

    bRet = true;

    cin >> n;

    a_heap = new double[n];

    for(int i = 0; i < n; i++){
        cin >> a_heap[i];
        ttl = ttl + 1 / a_heap[i];
    }
    cout << 1 / ttl << endl;
    delete[] a_heap;
}

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

    int n;
    cin >> n;
    int ary[n];
    rep(i,n) cin >> ary[i];
    int now_n = 1;
    int ans = 0;
    rep(i,n)
    {
        if (ary[i] == now_n)
        {
            now_n++;
        }
        else
        {
            ans++;
        }
    }
    if  (ans == n)
    {
        cout << -1 << endl;
    }
    else
    {
        cout << ans << endl;
    }
    
    
    
}




Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main()
{
    int n, x, y, i, t, s, sp = 0;
    bool ok = 1;
    cin >> n;
    for (i = 1; i <= n; ++i)
    {
        cin >> t >> x >> y;
        s = x + y;
        if (s > t)
            ok = 0;
        else
        {
            if (t % 2 != s % 2)
                ok = 0;
        }
    }
    if (ok == 0)
        cout << "No ";
    else if (ok == 1)
        cout << "Yes ";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;

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

const int MAX = 510000;
const ll MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

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

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

    sort(A, A+N);

    COMinit();

    ll mn = 0;
    ll mx = 0;
    for(int i=0; i<N; i++){
        if(i >= K-1) mx += A[i]*COM(i, K-1);
        if(N-i-1 >= K-1) mn += A[i]*COM(N-i-1, K-1);
        mx %= MOD;
        mn %= MOD;
    }

    ll ans = MOD + mx - mn;
    cout << ans % MOD << endl;

    return 0;
}


Measured memory_bytes: 12544
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
#define FOR(i,a,n) for(ll i=(ll)a;i<(ll)n;i++)
#define RFOR(i,a,n) for(ll i=(ll)n-1;i >= (ll)a;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,0,n)
#define ALL(v) v.begin(), v.end()
#define bra(first,second) '(' << first << ',' << second << ')'
//constexpr ll MOD = 1000000007;
constexpr ll MOD = 998244353;
ll INF = 6001001001001001001;
long double EPS = 1e-6;
long double PI = 3.141592653589793238;
template<typename T>
void remove(std::vector<T>& vector, unsigned int index){
    vector.erase(vector.begin() + index);
}

using Graph = vector<vector<ll>>;

ll dy[2]{1,0};
ll dx[2]{0,1};

ll H,W;
char field[110][110];
ll d[110][110];
bool done[110][110];

priority_queue<tuple<ll,ll,ll>> Q;

void dijkstra(){
    rep(j,110) rep(k,110){
        d[j][k] = INF;
        done[j][k] = false;
    }
    if(field[0][0] == '#'){
        d[0][0] = 1;
        Q.emplace(-1,0,0);
    }else{
        d[0][0] = 0;
        Q.emplace(0,0,0);
    }
    while(Q.size()){
        ll c,y,x;
        tie(c,y,x) = Q.top();
        Q.pop();
        done[y][x] = 1;
        rep(i,2){
            ll ny = y + dy[i],nx = x + dx[i];
            if(0 > ny || ny >= H || 0 > nx || nx >= W || done[ny][nx]) continue;
            if(field[y][x] == '#'){
                if(field[ny][nx] == '#'){
                    if(d[ny][nx] > d[y][x]){
                        d[ny][nx] = d[y][x];
                        Q.emplace(-d[y][x],ny,nx);
                    }
                }else{
                    if(d[ny][nx] > d[y][x]){
                        d[ny][nx] = d[y][x];
                        Q.emplace(-d[y][x],ny,nx);
                    }
                }
            }else{
                if(field[ny][nx] == '#'){
                    if(d[ny][nx] > d[y][x]){
                        d[ny][nx] = d[y][x] + 1;
                        Q.emplace(-d[ny][nx],ny,nx);
                    }
                }else{
                    if(d[ny][nx] > d[y][x]){
                        d[ny][nx] = d[y][x];
                        Q.emplace(-d[y][x],ny,nx);
                    }
                }
            }
        }
    }
}

int main(){
    cin >> H >> W;
    rep(i,H) rep(j,W) cin >> field[i][j];
    ll ans = 0;
    /*if(field[0][0] == '#'){
        ans++;
        field[0][0] = '.';
    }
    if(field[H-1][W-1] == '#'){
        ans++;
        field[H-1][W-1] = '.';
    }*/
    dijkstra();
    cout << ans + d[H-1][W-1] << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    long long a, b, c, d, x, y;
    cin >> a >> b >> c >> d;
    long long ara[5];
    ara[0] = a*c, ara[1] = a*d, ara[2] = b*c, ara[3] = b*d;
    long long maxi = ara[0];
    for(int i=0; i<4 ; i++){
        if(maxi < ara[i]) maxi = ara[i];
    }
    cout << maxi << endl;
    return 0;
}


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

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s); i<(long long)(n);i++)
#define mod 1000000007
typedef long long ll;

int main() {
    int n;cin>>n;
    bool jdg=true;
    vector<string>w(n);

    rep(i,n){
        cin>>w[i];
    }
    rep(i,n-1){
        if(w[i].back()!=w[i+1].front()){
            jdg=false;
        }
    }
    sort(w.begin(),w.end());
    rep(i,n-1){
        if(w[i]==w[i+1]){
            jdg=false;
        }
    }

    if(jdg){
        cout<<"Yes"<<endl;
        return 0;
    }
    cout<<"No"<<endl;
}


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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll N, M;
    ll temp;
    ll count = 0;
    cin >> N >> M;
    temp = max(0LL, min(N, M / 2));
    count += temp;
    M -= 2 * temp;
    cout << count + M / 4 << endl;
    return 0;
}


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

typedef pair <int, int> ii;

const int Maxn = 200005;

int n, k;
int P[Maxn];
int nxt[Maxn];
set <int> S;
int mn[Maxn], mx[Maxn];
set <ii> R;

int main()
{
    scanf("%d %d", &n, &k);
    for (int i = 1; i <= n; i++) {
        scanf("%d", &P[i]);
        S.insert(i);
        mn[i] = Maxn;
    }
    nxt[n] = n + 1;
    for (int i = n - 1; i >= 1; i--) {
        nxt[i] = i + 1;
        while (nxt[i] <= n && P[i] < P[nxt[i]])
            nxt[i] = nxt[nxt[i]];
    }
    for (int i = 1; i <= n; i++) {
        int lef = nxt[i] - k + 1;
        int rig = i;
        if (lef <= rig) {
            auto it = S.lower_bound(lef);
            while (it != S.end() && *it <= rig) {
                mn[*it] = i; S.erase(it++);
            }
        }
    }
    for (int i = 1; i <= n; i++) {
        S.insert(i);
        mx[i] = -Maxn;
    }
    nxt[1] = 0;
    for (int i = 2; i <= n; i++) {
        nxt[i] = i - 1;
        while (nxt[i] > 0 && P[nxt[i]] < P[i])
            nxt[i] = nxt[nxt[i]];
    }
    for (int i = n; i >= 1; i--) {
        int lef = i - k + 1;
        int rig = nxt[i];
        if (lef <= rig) {
            auto it = S.lower_bound(lef);
            while (it != S.end() && *it <= rig) {
                mx[*it] = i; S.erase(it++);
            }
        }
    }
    for (int i = 1; i + k <= n + 1; i++)
        if (mn[i] > mx[i]) R.insert(ii(Maxn, -Maxn));
        else R.insert(ii(mn[i], mx[i]));
    printf("%d\n", int(R.size()));
    return 0;
}


Measured memory_bytes: 12800
#include <iostream>
#include<queue>
#include<stack>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<unordered_map>

using namespace std;

#define MOD 1000000007
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep(i,j,n) for(ll (i)=(j);(i)<(n);(i)++)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
typedef pair<ll, ll> P;
const long long INF = 1LL << 60;
typedef vector<ll> Array;
typedef vector<Array> Matrix;


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

//グラフ関連
struct Edge {//グラフ
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
		to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}


//nCr,nPr,modの逆元
class Combination {
public:
	Array fact;//n！
	Array inv;//n!の逆元
	ll mod;
	Combination(ll n, ll _mod) {
		mod = _mod;
		fact.resize(n + 1);
		fact[0] = 1;
		REP(i, n) {
			fact[i + 1] = (fact[i] * (i + 1LL)) % mod;
		}
		inv.resize(n + 1);
		inv[n] = mod_inv(fact[n]);
		for (int i = n; i > 0; i--) {
			inv[i - 1] = inv[i] * i % mod;
		}
	}
	//modの逆元
	ll mod_inv(ll x) {
		ll n = mod - 2;
		ll res = 1LL;
		while (n > 0) {
			if (n & 1) res = res * x % mod;
			x = x * x % mod;
			n >>= 1;
		}
		return res;
	}
	ll nCr(ll n, ll r) {
		return ((fact[n] * inv[r] % mod) * inv[n - r]) % mod;
	}
	ll nPr(ll n, ll r) {
		return (fact[n] * inv[n - r]) % mod;
	}
	ll nHr(ll n, ll r) {
		//重複組み合わせ：n種類のものからr個取り出す組み合わせ
		return nCr(r + n - 1, r);
	}
};


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

	ll n, m;
	cin >> n >> m;
	Array x(n, 0), y(m, 0);
	REP(i, n) cin >> x[i];
	REP(i, m) cin >> y[i];

	ll sumy = 0;
	Array dy(m+1, 0);
	REP(i, m-1) {
		dy[i + 1] = dy[i] + (i + 1) * (y[i + 1] - y[i]) % MOD;
		dy[i + 1] %= MOD;
		sumy += dy[i+1];
		sumy %= MOD;
	}

	ll sumx = 0;
	Array dx(n + 1, 0);
	REP(i, n - 1) {
		dx[i + 1] = dx[i] + (i + 1) * (x[i + 1] - x[i]) % MOD;
		dx[i + 1] %= MOD;
		sumx += dx[i + 1];
		sumx %= MOD;
	}

	cout << (sumy*sumx)%MOD << endl;

	return 0;
}

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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e13 + 5);

const int MAX_N = (int)(2e5 + 5);

int n;
ll k;

ll a[MAX_N];
ll f[MAX_N];

bool check(ll x) {
  ll tmp_k = k;

  for (int i = 0; i < n; ++i) {
    ll aifi = a[i] * f[i];

    if (aifi <= x) continue;  // already satisfied

    // if (tmp_k == 0 && aifi > x) return false;

    ll times = ((aifi - x) - 1) / f[i] + 1L;

    ll actual_times = min(times, tmp_k);

    aifi -= actual_times * f[i];  // sum_i ((ai - ki) x fi_ = sum_i (ai x fi - ki x fi)
    tmp_k -= actual_times;

    if (aifi > x) {
      return false;
    }
  }

  return true;
}

int main(void) {
  // Here your code !
  scanf("%d %lld", &n, &k);

  for (int i = 0; i < n; ++i) {
    scanf("%lld", &(a[i]));
  }

  for (int i = 0; i < n; ++i) {
    scanf("%lld", &(f[i]));
  }

  sort(a, a + n);
  sort(f, f + n, greater<ll>());

  ll ok = INF;
  ll ng = -1L;

  while (abs(ok - ng) > 1) {
    ll next = (ok + ng) / 2L;

    if (check(next)) {
      ok = next;
    } else {
      ng = next;
    }
  }

  ll ans = ok;

  printf("%lld\n", ans);

  return 0;
}


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

int main(){
    int h, w, k;
    cin >> h >> w >> k;

    vector<vector<long long int>> item(h, vector<long long int>(w));
    for(int i=0; i<k; i++){
        int r, c, v;
        cin >> r >> c >> v;
        r -= 1;
        c -= 1;
        item[r][c] = v;
    }

    vector<vector<vector<long long int>>> dp(h, vector<vector<long long int>>(w, vector<long long int>(4)));
    if(item[0][0] != 0) dp[0][0][1] = item[0][0];

    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            for(int l=0; l<=3; l++){
                if(i+1<h){
                    dp[i+1][j][0] = max(dp[i+1][j][0], dp[i][j][l]);
                    if(item[i+1][j] != 0) dp[i+1][j][1] = max(dp[i+1][j][1], dp[i][j][l] + item[i+1][j]);
                }
                if(j+1<w){
                    dp[i][j+1][l] = max(dp[i][j+1][l], dp[i][j][l]);
                    if(item[i][j+1] != 0 && l+1 <= 3) dp[i][j+1][l+1] = max(dp[i][j+1][l+1], dp[i][j][l] + item[i][j+1]);
                }
            }
        }
    }

    long long int ans = 0;
    for(int k=0; k<=3; k++){
        ans = max(ans, dp[h-1][w-1][k]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 706720
#include <iostream>
#include <cmath>
#include <algorithm>
#include <bitset>
#include <iomanip>
#include <cstdio>
#include <new>
#include <vector>
#include <cstdlib>
#include <string>
#include <set>
#include <tuple>
#include<map>

using namespace std;
int main() {
	int x, a, b;
	cin >> x >> a >> b;

	if (abs(a - x) > abs(b - x)) {
		cout << "B" << endl;
	}
	else cout << "A" << endl;
}

Measured memory_bytes: 3556
#include<stdio.h>

int main()
{
    int A,B;
    scanf("%d %d",&A,&B);
    if( (A==1) && (B==2) )
        printf("3\n");
    else if( (A==1) && (B==3) )
        printf("2\n");
    else if((A==2)&&(B==1))
        printf("3\n");
     else if( (A==3) && (B==1) )
        printf("2\n");
    else
        printf("1");
}


Measured memory_bytes: 128
package main

import (
    "bufio"
    "fmt"
    "os"
    "strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
    sc.Scan()
    i, e := strconv.Atoi(sc.Text())
    if e != nil {
        panic(e)
    }
    return i
}

var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

func readLine() string {
    buf := make([]byte, 0, 1000000)
    for {
        l, p, e := rdr.ReadLine()
        if e != nil {
            panic(e)
        }
        buf = append(buf, l...)
        if !p {
            break
        }
    }
    return string(buf)
}

func nextLine() string {
    sc.Scan()
    return sc.Text()
}


func main(){
	var s,ans string
	var sl []string
	s=nextLine()
	for _, r:=range s{
	    sl=append(sl,string(r))
        }
	for i:=0;i<len(sl);i++ {
		if((i+1)%2 == 1){
			if(sl[i]=="R" || sl[i]=="U" || sl[i]=="D"){
				ans="Yes"
			}else{
				ans="No"
				goto LABEL
			}
		}else{
			if(sl[i]=="L" || sl[i]=="U" || sl[i]=="D"){
				ans="Yes"
			}else{
				ans="No"
				goto LABEL
			}
		}
	}
	LABEL:
	fmt.Println(ans)
}


Measured memory_bytes: 640
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

func main() {
	var n, sum, former, latter int
	var mid float64

	fmt.Scanln(&n)

	Ws := make([]int, n)

	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	for i := range Ws {
		sc.Scan()
		Ws[i], _ = strconv.Atoi(sc.Text())
		sum += Ws[i]
	}

	mid = float64(sum) / 2.0

	var balance int
	for i := range Ws {
		if float64(former+Ws[i]) >= mid {
			balance = i
			break
		}
		former += Ws[i]
	}

	for i := balance + 1; i < n; i++ {
		latter += Ws[i]
	}

	if former <= latter {
		former += Ws[balance]
	} else {
		latter += Ws[balance]
	}

	fmt.Println(math.Abs(float64(former - latter)))
}


Measured memory_bytes: 640
program hrn;
 var
  a,b,c,d:longint;
 begin
  read(a,b,c,d);
  case a+b-c-d of
   -maxlongint..-1:writeln('Right');
   0:writeln('Balanced');
   1..maxlongint:writeln('Left');
  end;
 end.

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

#define MAX 100005
#define N -1

struct Node{
  int p,l,r;
};

struct Node T[MAX];
int n,D[MAX];

void p(int u){

  int i,c;

  printf("node %d: ",u);
  printf("parent = %d, ",T[u].p);
  printf("depth = %d, ",D[u]);

  if( T[u].p == N )
    printf("root, ");
  else if( T[u].l == N )
    printf("leaf, ");
  else
    printf("internal node, ");

  printf("[");

  for( i=0,c=T[u].l; c!=N; i++,c=T[c].r ){
    if(i)
      printf(", ");
    printf("%d",c);
  }
  printf("]\n");
}

void rec(int u,int p){
  D[u]=p;

  if( T[u].r != N )
    rec( T[u].r,p );
  if( T[u].l != N )
    rec( T[u].l,p+1 );
}

int main(){
  int i,j,d,v,c,l,r;

  scanf("%d",&n);

  for( i=0; i<n; i++ )
    T[i].p = T[i].l = T[i].r = N;

  for( i=0; i<n; i++ ){
    scanf("%d%d",&v,&d);

    for( j=0; j<d; j++ ){
      scanf("%d",&c);

      if( j==0 )
	T[v].l=c;
      else
	T[l].r=c;
      l=c;
      T[c].p=v;
    }
  }

  for( i=0; i<n; i++ ){
    if( T[i].p == N )
      r=i;
  }

  rec(r,0);

  for( i=0; i<n; i++ )
    p(i);

  return 0;
}
    



Measured memory_bytes: 6396
#include <iostream>

using namespace std;

int main(void)
{
  int S[13] = {}, H[13] = {}, C[13] = {}, D[13] = {};
  int n,number;
  char c;
  cin >> n;
  for(int i = 0; i < n; i++) {
    cin >> c >> number;
    if(c == 'S')
      S[number - 1] = 1;
    else if(c == 'H')
      H[number - 1] = 1;
    else if(c == 'C')
      C[number - 1] = 1;
    else
      D[number - 1] = 1;
  }
  for(int i = 0; i < 13; i++) {
    if(S[i] == 0)
      cout << 'S' << ' ' << i + 1 << endl;
  }
  for(int i = 0; i < 13; i++) {
    if(H[i] == 0)
      cout << 'H' << ' ' << i + 1 << endl;
  }
  for(int i = 0; i < 13; i++) {
    if(C[i] == 0)
      cout << 'C' << ' ' << i + 1 << endl;
  }
  for(int i = 0; i < 13; i++) {
    if(D[i] == 0)
      cout << 'D' << ' ' << i + 1 << endl;
  }
  return 0;
}

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

int main() {
  int N,num;
  cin >> N;
  num=0;
  // ここにプログラムを追記
  for(int i=0; i<N; i++){
      string S;
      cin >> S;
      if(S=="Y"){
          cout << "Four" << endl;
          num++;
          break;
      }
  }
  if(num==0){
      cout << "Three" << endl;
  }
}


Measured memory_bytes: 3532
# frozen_string_literal: true

n, q = gets.split.map(&:to_i)
ab = (n - 1).times.map { gets.split.map(&:to_i) }.sort_by { |e| e[0] }
px = q.times.map { gets.split.map(&:to_i) }

s = Array.new(n) { 0 }

px.each do |e|
  p = e[0]
  x = e[1]
  s[p - 1] += x
end

ab.each do |e|
  a = e[0]
  b = e[1]
  s[b - 1] += s[a - 1]
end

puts s


Measured memory_bytes: 39944
N = int(input())
A = list(map(int, input().split()))
mod = 10**9 + 7

cum = [0 for _ in range(N)]
cum[0] = A[0]
for i in range(N - 1):
    cum[i + 1] = (cum[i] + A[i + 1]) % mod

ans = 0
for i in range(N - 1):
    ans += (A[i] * (cum[N - 1] - cum[i])) % mod
print(ans % mod)

Measured memory_bytes: 31524
#include <bits/stdc++.h>
using namespace std;
int a,b;
string s,t,u;
int main()
{
  cin>>s>>t;
  cin>>a>>b;
  cin>>u;
  if(u==s) cout<<a-1<<" "<<b;
  else cout<<a<<" "<<b-1;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int p[168], q[168], mod = 1000000007;
int primecheck(int n) {
    int d = 0;
    for (int i = 1; i <= sqrt(n); i++)
    {
        if (n % i == 0) d++;
        if (d == 2) break;
    }
    if (d > 1) return 0;
    else return 1;
}
int main() {
    int k = 0, n, l;
    long long f = 1;
    for (int i = 0; i < 168; i++) q[i] = 0;
    for (int i = 2; i <= 997; i++)
    {
        if (primecheck(i) == 1)
        {
            p[k] = i;
            k++;
        }
    }
    cin >> n;
    for (int i = 2; i <= n; i++)
    {
        k = 0, l = i;
        while (l != 1)
        {
            if (l % p[k] == 0)
            {
                l /= p[k];
                q[k]++;
            }
            else k++;
        }
    }
    for (int i = 0; i < 168; i++)
    {
        f *= (q[i] + 1);
        f %= mod;
    }
    cout << f;
}

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

int main(){
    string s,t;
    cin >> s >> t;
    int n = s.size();
    string ans = "Yes";
    for(int i = 0; i < n; i++){
        if(s[i] != t[i]) ans = "No";
    }
    cout << ans << endl;
}

Measured memory_bytes: 3600
#![allow(non_snake_case)]

use std::cmp;

#[allow(dead_code)]
pub struct Scanner<'a> {
    _buf: &'a str,
    iter: ::std::str::SplitWhitespace<'a>,
}

#[allow(dead_code)]
impl<'a> Scanner<'a> {
    pub fn new(buf: &'a str) -> Self {
        Scanner {
            _buf: buf,
            iter: buf.split_whitespace(),
        }
    }

    pub fn array<T>(&mut self, n: usize) -> Vec<T>
        where T: ::std::str::FromStr,
              T::Err: ::std::fmt::Debug,
    {
        let mut res = Vec::with_capacity(n);
        for _ in 0..n {
            res.push(self.value());
        }
        res
    }

    pub fn value<T>(&mut self) -> T
        where T: ::std::str::FromStr,
              T::Err: ::std::fmt::Debug,
    {
        self.next().parse().unwrap()
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.next().chars().collect()
    }

    fn next(&mut self) -> &str {
        self.iter.next().unwrap()
    }
}

const INF: i64 = 1_010_000_000_000_000_000;

struct Solver {
    W: Vec<i64>,
    V: Vec<i64>,
    memo: Vec<Vec<Option<i64>>>,
}

impl Solver {
    fn new(W: Vec<i64>, V: Vec<i64>) -> Self {
        Solver {
            W: W,
            V: V,
            memo: vec![vec![None; 100001]; 101],
        }
    }

    /// i 個までで価値 j を実現する最小の重さ(不可能なら INF)
    fn f(&mut self, i: i64, j: i64) -> i64 {
        if i == 0 && j == 0 { return 0; }
        if i == 0 && j >  0 { return INF; }

        if self.memo[i as usize][j as usize].is_none() {
            let w = self.W[(i-1) as usize];
            let v = self.V[(i-1) as usize];

            let mut res = self.f(i-1,j);
            if v <= j {
                res = cmp::min(res, w + self.f(i-1,j-v));
            }
            self.memo[i as usize][j as usize] = Some(res);
        }
        self.memo[i as usize][j as usize].unwrap()
    }
}

fn main() {
    let mut _input = String::new();
    {
        use ::std::io::Read;
        ::std::io::stdin().read_to_string(&mut _input).unwrap();
    }
    let mut sc = Scanner::new(&_input);

    let N    = sc.value::<i64>();
    let WMAX = sc.value::<i64>();
    let mut W = Vec::with_capacity(N as usize);
    let mut V = Vec::with_capacity(N as usize);
    for _ in 0..N {
        W.push(sc.value::<i64>());
        V.push(sc.value::<i64>());
    }

    let mut sol = Solver::new(W, V);
    let mut ans = 0;
    for j in 0..100001 {
        if sol.f(N,j) <= WMAX {
            ans = j;
        }
    }

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


Measured memory_bytes: 211196
M, D = map(int, input().split())
total = 0
for d in range(1, D + 1):
    for m in range(1, M + 1):
        if d >= 20:
            d1 = d // 10
        else:
            break
        if d % 10 < 2:
            break
        else:
            d2 = d % 10
        if d1 * d2 == m:
            total += 1
print(total)


Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long a,b,c,k,sum=0;
	cin>>a>>b>>c>>k;
	if(k>=a)
	{
		k-=a;
		sum+=a;
	}
	else
	{
		cout<<k<<endl;
		return 0;
	}
	if(k>=b)
		k-=b;
	else
	{
		cout<<sum<<endl;
		return 0;
	}
	if(c>0)
		cout<<sum-k<<endl;
	else
		cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
#define isIn(x,y,h,w) (x >= 0 && x < h && y >= 0 && y < w)

#define int long long
//using ll = long long;
using P = pair<int,int>;

ostream &operator<<(ostream &os,const P &p){ return os << "(" << p.first << "," << p.second << ")"; }
template<class T>
ostream &operator<<(ostream &os,const vector<T> &v){
	for(int i = 0;i < v.size();i++) os << (i ? "," : "[") << v[i];
	os << "]";
	return os;
}

template<class T> T &chmin(T &a,const T &b){ return a = min(a,b); }
template<class T> T &chmax(T &a,const T &b){ return a = max(a,b); }

const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

vector<vector<int>> primeFactorTable(int n){
	vector<vector<int>> ret(n + 1);
	for(int i = 2;i <= n;i++){
		if(ret[i].size()) continue;
		for(int j = i;j <= n;j += i) ret[j].push_back(i);
	}
	return ret;
}

template<class T> T gcd(T a,T b){ return b ? gcd(b,a % b) : a; }

signed main(){
	int n,a[1000100];
	auto pft = primeFactorTable(1000100);
	cin >> n;
	map<int,int> mp;
	for(int i = 0;i < n;i++){
		cin >> a[i];
		for(int p : pft[a[i]]){
			mp[p]++;
		}
	}
	bool isPC = true;
	for(auto p : mp){
		if(p.second >= 2) isPC = false;
	}
	int g = a[0];
	for(int i = 1;i < n;i++) g = gcd(g,a[i]);
	if(isPC) cout << "pairwise coprime" << endl;
	else if(g == 1) cout << "setwise coprime" << endl;
	else cout << "not coprime" << endl;
}

Measured memory_bytes: 85812
#include <iostream>
#include <vector>
using namespace std;
int n, m, p[10], res;
vector<int> vec[10];
void dfs (int pos, int mask) {
    if (pos == n) {
        int ans = 0;
        for (int i = 1; i < n; i++) {
            for (int j = 0; j < vec[p[i - 1]].size(); j++) {
                if (vec[p[i - 1]][j] == p[i]) ans++;
            }
        }
        if (ans == n - 1) res++;
        return;
    }
    for (int i = 1; i < n; i++) {
        if (mask & (1 << i)) {
            p[pos] = i;
            dfs(pos + 1, mask ^ (1 << i));
        }
    }
}
int main(void){
    // Your code here!
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        vec[a - 1].push_back(b - 1);
        vec[b - 1].push_back(a - 1);
    }
    dfs(1, (1 << n) - 2);
    cout << res << endl;
}


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

#define FOR(i, j, n) for (int i(j); i < n; ++i)
#define FORR(v, c) for (auto &v : c)
#define F first
#define S second
#define SQ(x) (x)*(x)
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define dbg(x) cerr<<#x<<" = " << (x) << endl
#define pnl(x) cout << x << '\n'
#define pns(x) cout << x << ' '
#define read(x) cin >> x
#define read2(x,y) cin >> x >> y
#define read3(x, y, z) cin >> x >> y >> z
#define read4(a, b, c, d) cin >> a >> b >> c >> d
#define readv(v) FORR(c,v) read(c)

struct Arrete { int v, c;};
struct Point {int x, y; double distance(Point other) const {return sqrt(SQ(x-other.x)+SQ(y-other.y));}};

typedef	vector<int>	vi;
typedef pair<int,int>	ii;
typedef vector<string>	vs;
typedef vector<ii>	vii;
typedef vector<Arrete>	vg;
typedef vector<long long>	vl;
typedef	long long ll;

const int	NB_D = 4;
const int	DY[] = {-1, 1, 0, 0};
const int	DX[] = {0, 0, -1, 1};

int		main(void)
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	
	ll n;
	read(n);

	ll best(n);

	for (ll i(1); i*i <= n; ++i)
		if (n%i == 0)
			best = min(best, i+ n/i - 2);
	pnl(best);
}



Measured memory_bytes: 256