akhauriyash/Code-Regression huggingface dataset:
#### import ####
import sys
import math
from collections import defaultdict

#### 設定 ####
sys.setrecursionlimit(10**7)
def input():
  return sys.stdin.readline()[:-1]

#### 定数 ####
mod = 10**9 + 7

#### 読み込み ####
def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
  read_all = [tuple(map(int, input().split())) for _ in range(N)]
  return map(list,zip(*read_all))

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

class UF(object):
  def __init__(self, n=1):
    self.par = [i for i in range(n)]
    self.rank = [0 for _ in range(n)]
    self.size = [1 for _ in range(n)]

  def find(self, x):
    """
    x が属するグループを探索
    """
    if self.par[x] == x:
      return x
    else:
      self.par[x] = self.find(self.par[x])
      return self.par[x]

  def union(self, x, y):
    """
    x と y のグループを結合
    """
    x = self.find(x)
    y = self.find(y)
    if x != y:
      if self.rank[x] < self.rank[y]:
        x, y = y, x
      if self.rank[x] == self.rank[y]:
        self.rank[x] += 1
      self.par[y] = x
      self.size[x] += self.size[y]

  def is_same(self, x, y):
    """
    x と y が同じグループか否か
    """
    return self.find(x) == self.find(y)

  def get_size(self, x):
    """
    x が属するグループの要素数
    """
    x = self.find(x)
    return self.size[x]

N = I()
x = []
y = []

for i in range(N):
  xtemp,ytemp = II()
  x.append([xtemp, i])
  y.append([ytemp, i])

xsort = sorted(x,lambda a:a[0])
ysort = sorted(y,lambda a:a[0])

graph = []
for i in range(N-1):
  graph.append([min(abs(xsort[i][0]-xsort[i+1][0]),abs(y[xsort[i][1]][0]-y[xsort[i+1][1]][0])), \
                xsort[i][1],xsort[i+1][1]])
  graph.append([min(abs(ysort[i][0]-ysort[i+1][0]),abs(x[ysort[i][1]][0]-x[ysort[i+1][1]][0])), \
                ysort[i][1],ysort[i+1][1]])

ans = 0
uf = UF(N)
graph.sort()
for w in graph:
  if not uf.is_same(w[1],w[2]):
    uf.union(w[1],w[2])
    ans += w[0]

print(ans)

Measured memory_bytes: 128988
import java.util.Scanner;
public class Main{
	static boolean[][] rinsetugyouretu; //隣接行列
	static int kosu=0;
	static int M;
	static int N;
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		N=sc.nextInt();
		M=sc.nextInt();
		rinsetugyouretu=new boolean[N+1][N+1];
		for(int i=0; i<M; i++) {
			int from=sc.nextInt();
			int to=sc.nextInt();
			rinsetugyouretu[from][to]=true;
			rinsetugyouretu[to][from]=true;
		}
		int[] ns = new int[N-1];
		for(int i=0; i<N-1; i++) {
			ns[i]=i+2;
		}
		permute(ns, ns.length);
		System.out.println(kosu);
	}
	private static void swap(int[] v, int i, int j) {
		int t = v[i]; v[i] = v[j]; v[j] = t;
	}
	public static void permute(int[] v, int n) {
		if (n == 1) {
			boolean suru=true;
			for(int i=0; i<N-1; i++) {
				if(i==0) {
					if(!rinsetugyouretu[1][v[i]]) {
						suru=false;
						break;
					}
				}
				else if(i!=0) {
					if(!rinsetugyouretu[v[i-1]][v[i]]) {
						suru=false;
						break;
					}
				}
			}
			if(suru==true) {
				kosu++;
			}
		} else {
			for (int i = 0; i < n; i++) {
				permute(v, n-1);
				if (n % 2 == 1) {
					swap(v, 0, n-1);
				} else {
					swap(v, i, n-1);
				}
			}
		}
	}
}

Measured memory_bytes: 22612
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	double a, b, x;
	cin >> a >> b >> x;
	DMP(acos(-1));

	cout << fixed << setprecision(10);

	double half = a * a * b / 2;

	if (half < x) {
		double c = 2 * x / a / a - b;
		double d = a * b / (b - c);
		cout << atan(b / d) * 180.0 / acos(-1) << "\n";
	}
	else {
		double c = 2 * x / a / b;
		cout << atan(b/c)  * 180.0 / acos(-1) << "\n";
	}

	return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef tuple<int, int, int> ti3;

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

int iabs(int x)
{
    if (x > 0) {
        return x;
    } else {
        return -x;
    }
}

int main(int argc, char const* argv[])
{
    int N;
    int p = 0;
    vi vV, vC;
    cin >> N;
    for (size_t i = 0; i < N; i++) {
        int v;
        cin >> v;
        vV.push_back(v);
    }
    for (size_t i = 0; i < N; i++) {
        int c;
        cin >> c;
        vC.push_back(c);
    }

    for (size_t i = 0; i < N; i++) {
        if (vV[i] - vC[i] >= 0) {
            p += vV[i] - vC[i];
        }
    }

    cout << p << "\n";
}


Measured memory_bytes: 256
using System;
namespace AFirstGrader {
	class Program {
		const int Limit = 21;
		const int Sentry = 10;
		static void Main(string[] args) {
			long[] list = new long[Limit + 2 * Sentry];
			long[] list_tmp = new long[Limit];

			int N = int.Parse(Console.ReadLine());
			string[] str = Console.ReadLine().Split(' ');
			
			list[int.Parse(str[0]) + Sentry] = 1;
			for (int n = 1; n < N - 1; n++) {
				int num = int.Parse(str[n]);
				for (int i = 0; i < Limit; i++) list_tmp[i] = list[i - num + Sentry] + list[i + num + Sentry];
				list_tmp.CopyTo(list, Sentry);
			}
			Console.WriteLine(list[int.Parse(str[N-1]) + Sentry]);
		}
	}
}

Measured memory_bytes: 5652
#include<iostream>
#include<vector>
#include<queue>
#include<algorithm>
#include<string>
#include<utility>
#include <cmath>
using namespace std;

int main(){
 
    int a[3];
    cin >> a[0] >> a[1] >> a[2];
    sort(a,a+3);
    cout << a[2]*10 + a[1] + a[0] << endl;

    
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
const int mod= 1e+9+7;


int main(){
    ll n; cin>>n;
    vector<ll>a(n),b(n);
    rep(i,n)cin>>a[i]>>b[i];
    ll cnt=0;

    rep(i,n){
        a[n-1-i]+=cnt;
        ll s=b[n-1-i]-a[n-1-i]%b[n-1-i];
        if(s!=b[n-1-i]){
        cnt+=s;
        }

    }
    cout<<cnt<<endl;
}








Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int main(){
  int q[2][6]={
    {1,-1,1,4,5,2},
    {2,3,-1,5,2,1}
  };
  string s;
  while(cin>>s,s!="#"){
    int n=0;
    rep(i,s.size()){
      int d=q[s[i]-'0'][n];
      if(d==-1)break;
      n=d;
    }
    if(n==5)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }
}

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

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  if(b-a == c-b){
    puts("YES");
  }
  else puts("NO");
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<n; ++i)
#define rep1(i, n) for (int i=1; i<=n; ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
constexpr ll  MOD = (1e9+7);
constexpr int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
constexpr int lcm(int a, int b) { return a / gcd(a, b) * b; }

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;
}
ll factorial(ll n, ll m=2) {
    // calculate n!
    m = max(2LL, m);
    ll rtn = 1;
    for (ll i=m; i<=n; i++) {
        rtn = (rtn * i) % MOD;
    }
    return rtn;
}
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
ll modpow(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1)
            res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll x; cin >> x;
    ll ganpon = 100;
    ll n = 0;
    while (ganpon < x) {
        ganpon *= 1.01;
        n++;
    }
    cout << n << endl;
    return 0;
}

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

class Program {
    static void Main() {
        int[] ans = new int[26];
        string str;
        while((str = Console.ReadLine()) != null) {
            foreach (char c in str) {
                for(int i = 0; i < 26; i++) {
                    if(c == 'a' + i || c == 'A' + i) ans[i]++;
                }
            }
        }
        for(int i = 0; i < 26; i++) Console.WriteLine("{0} : {1}", (char)('a' + i), ans[i]);
    }
}


Measured memory_bytes: 15864
/* 
    Author - linpaws07 
*/
#include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;
#define mod 1000000007
#define mp make_pair
#define pb push_back
#define inf (int)1e9
#define f first
#define s second
#define eps 1e-9
#define PI 3.1415926535897932384626433832795
#define scd(t) scanf("%d",&t)
#define sclld(t) scanf("%lld",&t)
#define scc(t) scanf("%c",&t)
#define scs(t) scanf("%s",t)
#define scf(t) scanf("%f",&t)
#define sclf(t) scanf("%lf",&t)
#define memst(a, b) memset(a, (b), sizeof(a))
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<vi> vvi;
typedef map<int,int> mpii;
typedef set<int> seti;
typedef multiset<int> mseti;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int uint64;
#define FAST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define rp(i,n) for(int i=0;i<(n);i++)
#define fr(i,a,b) for(int i=(a);i<(b);i++)
#define fre(i,a,b) for(int i=(a);i<=(b);i++)
#define frd(i,a,b) for(int i=(a);i>=(b);i--)
inline bool eq(double a, double b) { return fabs(a-b) < 1e-9; }
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
auto start = high_resolution_clock::now();
inline void measure();

int64 h[200002], a[200002];
int64 dp[200002], hans[200002];
void update(int i, int64 v){
    for(int k = i; k < 200002; k += (k & (-k))){
        dp[k] = max(dp[k], v);
    }
}
int64 query(int i){
    int64 ans = 0;
    for(int k = i; k > 0; k -= (k & (-k))){
        ans = max(dp[k], ans);
    }
    return ans;
}
int main(){
    FAST
    //Do awesome things here
    int n;
    cin >> n;
    rp(i, n){
        cin >> h[i];
    }
    rp(i, n){
        cin >> a[i];
    }
    rp(i, n){
        int64 ans = query(h[i] - 1);
        update(h[i], ans + a[i]);
        hans[i] = ans + a[i];
    }
    int64 ans = -1;
    rp(i, n){
        ans = max(ans, hans[i]);
    }
    cout << ans << endl;
    return 0;
}


inline void measure(){
    auto stop = high_resolution_clock::now(); 
    auto duration = duration_cast<milliseconds>(stop - start);
    cout << duration.count() << endl;
}

Measured memory_bytes: 6528
a,b = map(int,input().split())
x1 = int((a-1)/0.08)
x2 = int((a+1)/0.08)
y1 = int((b-1)/0.1)
y2 = int((b+1)/0.1)
x = []
for i in range(x1, x2+1):
    if int(i*0.08) == a:
        x.append(i)
y = []
for i in range(y1, y2+1):
    if int(i*0.1) == b:
        y.append(i)
for i in x:
    if i in y:
        print(i)
        break
else:
    print(-1)


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <time.h>
#define ll long long
#define double long double
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
bool CAN=true;
using namespace std;

int main(){
  ll N,ans=0LL;
  cin>>N;
  ll A[N+1],B[N+1],SUM[N+1];
  A[0]=0LL;
  B[0]=0LL;
  SUM[0]=0LL;
  RREP(i,N){
    cin>>A[i]>>B[i];
    SUM[i]=SUM[i-1]+A[i];
  }
  
  for(ll i=N; i>0; --i){
    ll P=SUM[i]-SUM[i-1]+ans;
    if(P%B[i]==0) continue;
    ans+=(P+B[i])/B[i]*B[i]-P;
  }
  
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

using boost::multiprecision::cpp_int;
using cpp_dec_float_1000 = boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>>;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;
constexpr int MOD = 1000'000'007;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }
template<class T> T modinv(T a, T m) { T b = m, u = 1, v = 0; while (b) { T t = a / b; a -= t * b; boost::swap(a, b); u -= t * v; boost::swap(u, v); } u %= m; if (u < 0) u += m; return u; }

struct Tmp
{
public:
  Tmp(int N);
};

Tmp::Tmp(int N){}

void solve(void)
{
  int N, R; cin >> N >> R;
  auto ans = (N >= 10) ? R : R + (100 * (10 - N));
  cout << ans << CRLF;
  return;
}

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

  solve();

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
#define de(x) cout << #x << "=" << x << endl;
template <class T>
bool maxi(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool mini(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD  1000000007
#define PI (acos(-1))
using namespace std;
using ll = long long;
using ld = long double;
using P  = pair<ld,ll>;
//--GLOBAL---------------------------------

//--MAIN-----------------------------------
void Main() {
    ll N,K; cin>>N>>K;
    vector<ll> A(N);
    rep(i,N) cin>>A[i];
    vector<ll> sei(N+1,0);
    vector<ll> rui(N+1,0);
    rep(i,N){
        rui[i+1]=rui[i]+A[i];
        sei[i+1]=sei[i];
        if(A[i]>0) sei[i+1]+=A[i];
    }
    ll ans=0;
    rep(i,N-K+1){
        ll buf=0;
        buf+=sei[i];
        buf+=sei[N]-sei[i+K];
        ll doti=rui[i+K]-rui[i];
        doti=max(0LL,doti);
        buf+=doti;
        maxi(ans,buf);
    }
    cout<< ans <<"\n";
}
//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


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

#define int long long

using namespace std;

int d[101][100001];

int32_t main() {
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

//  freopen("input.txt", "r", stdin);
//  freopen("output.txt", "w", stdout);

    int n, w, ans = 0;
    cin >> n >> w;

    for(int i = 1; i <= n; i++) {
        int a, b;
        cin >> a >> b;
        for(int j = 1; j <= w; j++)
            d[i][j] = max(d[i-1][j], (j >= a ? d[i-1][j-a]+b : 0)), ans = max(ans, d[i][j]);
    }

    cout << ans;

    return 0;
}


Measured memory_bytes: 81744
package main

import (
	"fmt"
)

func main() {
	var h, n int
	fmt.Scan(&h, &n)
	a := make([]int, n)
	sum := 0
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
		sum += a[i]
	}

	if sum >= h {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 5504
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define RFOR(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define REP(i,n) FOR(i,0,(n))
#define REPS(i,n) FOR(i,1,(n)+1)
#define RREP(i,n) RFOR(i,0,(n))
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define DEBUG(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(ALL(x));
#define RSORT(x) sort(RALL(x));
#define SUM(x) accumulate(ALL(x),0);
#define FI first
#define SE second
#define PB push_back
#define EB emplace_back
#define SZ(x) (int)(x).size()
#define BN(x) ((1<<x)-1)
#define DUP(x,y) (((x)+(y)-1)/(y))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const ll mod = 1e9+7;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

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

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

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

  //vi to[200005];

  int N, Q; cin >> N >> Q;
  vvi to(N,vi());
  REP(i,N-1) {
    int a, b; cin >> a >> b;
    --a; --b;
    to[a].PB(b);
    to[b].PB(a);
  }

  vi ans(N);
  //ans.resize(N);
  REP(i,Q) {
    int p, x; cin >> p >> x;
    --p;
    ans[p] += x;
  }

  vector<bool> checked(N,false);
  queue<int> que;
  que.push(0);
  checked[0] = true;

  while (!que.empty()) {
    int node = que.front();
    que.pop();
    int point = ans[node];
    for (auto &next : to[node]) {
      if (!checked[next]) {
        ans[next] += point;
        que.push(next);
        checked[next] = true;
      }
    }
  }

  /*REP(i,N) {
    cout << ans[i] << endl;
  }*/

  for (auto &a : ans) {
    cout << a << endl;
  }
  
  return 0;
}

Measured memory_bytes: 15604
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
using namespace std;
#define int long long

int n, h[100100], a[100100];
int32_t main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin >> n;
	if (n == 1) {
		cout << "Yes";
		return 0;
	}
	for(int i = 0; i < n; ++i) {
		cin >> h[i];			
	}
	for(int i = 1; i < n; ++i) {
		if (h[i]-1 >= h[i-1]) h[i] = h[i]-1; 
	}
	for(int i = 0; i < n-1; ++i) {
		if (h[i] > h[i+1]) {
			cout << "No";
			return 0;
		}
	}
	cout << "Yes";
}


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

char sta[] = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z' };

void calc(char &c,int key){

	int it = std::find(sta, sta + 52, c) - sta;

	if (it - key < 0)it += 52;
	it -= key;

	c = sta[it];
}

int main(){
	int n;
	while (std::cin >> n, n){

		std::vector<int>k(n);
		for (int i = 0; i < n; i++)std::cin >> k[i];

		std::string str;
		std::cin >> str;


		for (int i = 0, key = 0; i < str.size(); i++, key++){
			if (key == n)key -= n;

			calc(str[i], k[key]);

		}

		std::cout << str << std::endl;
	}
	return 0;
}

Measured memory_bytes: 1208
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<set>
#include<algorithm>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

int main(void) {
    int n;
    vector<int> a;

    cin>>n;
    for(int i = 0;i < n;i++) {
        int temp;
        cin>>temp;
        a.push_back(temp);
    }

    sort(a.begin(),a.end());
    if(n == 2) {
        cout<<a[1]<<" "<<a[0]<<endl;

        return 0;
    }
    int temp = a[n-1]/2;

    int min_diff = 1e9;
    int value = -1;
    for(int i = 0;i < n;i++) {

        if(abs(a[i] - temp) <= min_diff)
        {
            min_diff = abs(a[i] - temp);
           value = a[i];
        }
    }
    cout<<a[n-1]<<" "<<value<<endl;
    

    return 0;
}


Measured memory_bytes: 892
#include <stdio.h>

int main(void){
	long n;
	long a[5];
	long m;
	long max = 0;
	scanf("%ld", &n);
	for(int i = 0; i < 5; i++){
		scanf("%ld", a + i);
		m = n / a[i];
		if(n % a[i])m++;
		if(i + m <= max)max++;
		else max = i + m;
	}
	printf("%ld\n", max);
	return 0;
}


Measured memory_bytes: 128
//(UNCOMMENT WHEN SUBMITTING)
//#pragma GCC optimize("O3")

//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)
// #pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN NEEDED)
// #pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>

// clang-format off
#define range(i) for (int _ = 0; _ < i; _++)
#define vprnt(v) for (auto vi : v) cout << vi << " "; cout << endl;
#define fastio() ios::sync_with_stdio(false); cin.tie(0)
#define ll long long
#define all(x) (x).begin(), (x).end()
using namespace ::std;
int nxt() {int x;cin >> x;return x;}
ll nxtll() {ll x;cin >> x;return x;}
// clang-format on

int main() {
    fastio();
    int N = nxt();

    string c;
    cin >> c;

    int wcount = 0, rcount = 0;
    for (int i = 0; i < N; i++) {
        if (c[i] == 'R') {
            rcount++;
        } else {
            wcount++;
        }
    }

    int rrcount = 0;
    for (int i = N - 1; i >= N - wcount; i--) {
        if (c[i] == 'R') {
            rrcount++;
        }
    }

    int res = min(wcount, rcount);
    res = min(res, rrcount);
    cout << res << endl;

    return 0;
}


Measured memory_bytes: 3688
using System;

public class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        var s = Console.ReadLine().Trim();
        var r = n - s.Replace("R", "").Length;
        var b = n - r;
        Console.WriteLine(r > b ? "Yes" : "No");
    }
}

Measured memory_bytes: 13140
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>
#include <cctype>
#include <ctype.h>
#include <set>
#include <sstream>
#include <time.h>
#include <numeric>
using namespace std;
//#define int long long
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define l1 list[index]
#define l2 list[index - 1]
#define l3 list[index + 1]
#define iif(i,j) ((i<0 && j<0) || (i>0 && j>0)) ? true : false 
typedef long long ll;
typedef pair<int, int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint, int> P1;
typedef pair<int, pint> P2;
typedef pair<pint, pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD = 1000000007;
const ll INF = 1e18;
const double PI = 3.14159265359;
int ca[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };



signed main() {
	ll n, x, sum = 0;
	vector<ll>list;

	cin >> n >> x;

	for (int i = 0; i < n; i++) {
		int num;
		cin >> num;
		list.push_back(num);
	}

	for (int i = 0; i < n - 1; i++) {
		if (list[i] + list[i + 1] >= x) {
			ll num = (list[i] + list[i + 1]) - x;
			if (num > list[i + 1]) {
				ll num2 = num - list[i + 1];
				list[i + 1] = 0;
				list[i] -= num2;
			}
			else {
				list[i + 1] -= num;
			}

			sum += num;
		}
	}

	cout << sum << endl;


	return 0;
}

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

#include <cstdlib>  // abs() for integer 絶対値求めやつ

#include <cmath>    // abs() for float, and fabs()

#include <algorithm>
#include <vector>
#define rep(i,n) for(int i = 0; i< (n);i++)

#define SORT(a) sort((a).begin(),(a).end());

#define che(a,string) cout<<string<<":"<<(a)<<endl;

#define ch(a,string) cout<<string<<":"<<(a)<<" ";

using namespace std;

typedef pair<int,int> p;

int main(){
	int a,b;
	cin>>a>>b;
	if(a+b>=10){
		cout<<"error"<<endl;
	  }	
	  else{
		  cout<<a+b<<endl;
		}
  }


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

int main(){
  ll n, W;
  cin >> n >> W;
  ll v[n], w[n];
  rep(i,n) cin >> v[i] >> w[i];
  vector<P> dp;
  rep(i,1<<(n/2)) {
    ll val = 0, wei = 0;
    rep(j,n/2) {
      if(i & (1<<j)) {
        val += v[j];
        wei += w[j];
      }
    }
    dp.push_back(P(wei,val));
  }
  sort(dp.begin(),dp.end());
  rep(i,dp.size()) {
    if(i > 0) dp[i].second = max(dp[i].second,dp[i-1].second);
  }
  ll ans = 0;
  rep(i,1<<(n-n/2)) {
    ll val = 0, wei = 0;
    rep(j,n-n/2) {
      if(i & (1<<j)) {
        val += v[n/2+j];
        wei += w[n/2+j];
      }
    }
    if(wei <= W) {
      int id = upper_bound(dp.begin(),dp.end(),P(W-wei,INF)) - dp.begin();
      id--;
      if(id >= 0) val += dp[id].second;
      ans = max(ans,val);
    } 
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 19464
#include<bits/stdc++.h>
#define pb push_back
#define all(x) (x).begin(),(x).end()
using namespace  std ;
typedef long l ;
typedef long long ll ;
typedef vector<int>vi ;
typedef vector<l>vl ;
typedef vector<ll>vll ;
typedef vector<vector<ll> >vvl ;
typedef pair<int,int> pii ;
typedef pair<ll,ll> pll ;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    std::cout.unsetf ( std::ios::floatfield );//this and next line for floating precision upto 6
    std::cout.precision(10);
    ll a,b,c,d,e,x,i,j,n,t,m,k,y;
    double p,q,r,w,u ;
    string str = "",str1 = "" ;
    ll a1,a2,b1,b2 ;
    cin>>a>>b>>k ;
    c = min(a,b) ;
    d = max(a,b) ;
    x = 0 ;
    for(i=c ; i>=1 ; i=i-1)
    {
    	if(c%i==0 && d%i==0)
    	{
    		x++ ;
		}
		if(x==k)
		{
			cout<<i ;
			break;
		}
	}
}

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

sum = sum(a) - a[0]

ans = 0
for i in range(n):
  ans += a[i] * sum
  if (i == n-1):
    break
  else:
  	sum -= a[i+1]
  
ans %= 10 ** 9 + 7  
print(ans)

Measured memory_bytes: 31600
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
typedef  long long ll;
using namespace std;

int main(void) {
	ll r, c;
	cin >> r >> c;

	ll sheet[101][101] = {{}};

	for (int i = 0; i < r; i++)
	{
		ll rsum = 0;
		for (int j = 0; j < c; j++)
		{
			cin >> sheet[i][j];
			rsum += sheet[i][j];
			if (j == c - 1)
			{
				sheet[i][c] = rsum;
			}
		}
	}

	for (int i = 0; i <= c; i++)
	{
		ll csum = 0;
		for (int j = 0; j < r; j++)
		{
			csum += sheet[j][i];
			if (j == r - 1)
			{
				sheet[r][i] = csum;
			}
		}
	}

	for (int i = 0; i <= r; i++)
	{
		for (int j = 0; j <= c; j++)
		{
			cout << sheet[i][j];
			if (j != c)
			{
				cout << " ";
			}
		}
		cout << endl;
	}


	return 0;
}


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

int main() {
  int N,ans,x=0;
  string s;
  cin >> N >> s;
  ans=x;
  for(int i=0; i<N; i++) {
    if(s[i]=='I') {
      x++;
      if(ans<x) {
        ans=x;
      }
    }
    else if(s[i]=='D') {
      x--;
    }
  }
    cout << ans << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
public static class P
{
    public static void Main()
    {
        var ab = Console.ReadLine().Split().Select(long.Parse).ToArray();
        Console.WriteLine(ab[0] * ab[1] / GCD(ab[0], ab[1]));

    }

    static long GCD(long a, long b)
    {
        while (true)
        {
            if (b == 0) return a;
            a %= b;
            if (a == 0) return b;
            b %= a;
        }
    }
}

Measured memory_bytes: 28056
#include<bits/stdc++.h>
using namespace std;
int main() {
	unordered_map<string,int>m;
	string s;
	cin>>s;
	m["SUN"]=0;
	m["MON"]=1;
	m["TUE"]=2;
	m["WED"]=3;
	m["THU"]=4;
	m["FRI"]=5;
	m["SAT"]=6;
	cout<<7-m[s]<<endl;
	return 0;
}

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

#define li long long int
#define rep(i, to) for (li i = 0; i < ((li)(to)); i++)
#define repp(i, start, to) for (li i = (li)(start); i < ((li)(to)); i++)
#define allof(v) (v).begin(), (v).end()

inline li lcm(li a, li b) {
	li g = __gcd(a, b);
	return (a / g) * b;
}

int main(void)
{
	li n;
	cin >> n;
	li res = 1;
	rep(i, n) {
		li t;
		cin >> t;
		res = lcm(res, t);
	}
	cout << res << endl;


	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.math.BigInteger;

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

        String units[] = {"Man","Oku","Cho","Kei","Gai","Jo","Jou","Ko","Kan",
                          "Sei","Sai","Gok","Ggs","Asg","Nyt","Fks","Mts"};
        while(sc.hasNext()){
            String m = sc.next();
            int n = sc.nextInt();
            if(n == 0) break;
            BigInteger bi = new BigInteger(m);
            bi = bi.pow(n);
            for(int i = 68; i >= 4; i -= 4){
                BigInteger div = new BigInteger("10");
                if(bi.divide(div.pow(i)).signum() == 1){
                    System.out.printf("%s%s",bi.divide(div.pow(i)),units[i / 4 - 1]);
                    bi = bi.remainder(div.pow(i));
                }
            }
            if(bi.signum() == 1){
                System.out.print(bi);
            }
            System.out.println();
        }
    }
}

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

int main()
{
    int N;
    cin >> N;
    int cnt = 0;
    vector<int> P(N);
    for (int i = 0;i < N;i++) {
        cin >> P[i];
    }
    for(int i = 1;i < N+1;i++){
        if(i != P[i-1]){
            cnt++;
        }
    }
    if(cnt <= 2){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
    return 0;
}


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

int main(){
    long N;
    cin >> N;

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

    for (int i=0; i < N; i++) {
        if (A[i] == 0) {
            cout << 0 << endl;
            return 0;
        }
    }

    long long total = 1;
    for (int i=0; i < N; i++) {
        if (A[i] >= LONG_LONG_MAX / total) {
            cout << -1 << endl;
            return 0;
        }

        total *= A[i];
    }

    if (total > 1000000000000000000)
    {
        cout << -1 << endl;
    }
    else
    {
        cout << total << endl;
    }
} 




Measured memory_bytes: 4416
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++) //for文マクロ
using namespace std;

typedef unsigned long ul;
typedef long long ll;
typedef pair<ul, ul> P; //ペア　タイプでふ

int main()
{
    char a, b, c, d;
    cin >> a >> b >> c >> d;
    if (a == b || b == c || c == d)
    {
        cout << "Bad";
    }
    else
    {
        cout << "Good";
    }
    return 0;
}

Measured memory_bytes: 256
/*input
999
*/

#include <bits/stdc++.h>
#define ll long long

using namespace std;

void run() {
	double l;
	cin >> l;
	double ret = (l/3.0) * (l/3.0) * (l/3.0);
	cout << std::setprecision(30) << ret << endl;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);		
	int t = 1;
	// cin >> t;
	while(t--) {
		run();
	}
}


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

int main() {
  string s;int cnt=0;
  cin>>s;
  rep(i,s.size()-1){
    if(s[i]==s[i+1]){
      cnt++;
      if(s[i]=='0'){
        s[i+1]='1';
      }else{
        s[i+1]='0';
      }
    }
  }
  cout<<cnt<<endl;
}

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

int main(int argc, char const *argv[]) {
    int N;
    cin >> N;
    vector<int> num(N);


    int count = 0;

    for (int i=0; i<N; i++) {
        cin >> num.at(i);
        if (num.at(i) != i+1) {
            count++;
        
            if (count >= 3) {
                break;
            }
        }
    }

    if (count <= 2) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }


    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 m = sc.nextInt();
        int[] a = new int[n];
        for(int i = 0; i < n; ++i) a[i] = sc.nextInt() >> 1;
        
        if(!existX(a, n)) {
            System.out.println(0);
            return;
        }
        
        long minX = findArrayLcm(a, n, m);
        long q = m / minX;
        long ans = q >> 1;
        if(q % 2 == 1) ++ans;
        System.out.println(ans);
    }
    
    static boolean existX(int[] ar, int size) {
        if(size == 1) return true;
        int fact2Count = countFactor(ar[0], 2);
        for(int i = 1; i < size; ++i) {
            if(fact2Count != countFactor(ar[i], 2)) return false;
        }
        return true;
    }
    
    static int countFactor(int num, int factor) {
        int res = 0;
        while(num % factor == 0) {
            ++res;
            num /= factor;
        }
        return res;
    }
    
    static long findGcd(long a, long b) {
        if(a < b) return findGcd(b, a);
        if(b == 0) return a;
        return findGcd(b, a % b);
    }
    
    static long findLcm(long a, long b) {
        long gcd = findGcd(a, b);
        long res = a / gcd * b;
        return res;
    }
    
    static long findArrayLcm(int[] ar, int size, long ub) {
        if(size == 1) return ar[0];
        long res = ar[0];
        for(int i = 1; i < size; ++i) {
            res = findLcm(res, ar[i]);
            if(res > ub) break;
        }
        return res;
    }
}


Measured memory_bytes: 49920
#include <stdio.h>
#include <string.h>
int main()
{
    long int sum ;
    int i , min, max, n;
    char s[100], p[100] ,ss[201] ;



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

	strcat( ss, s );
	strcat( ss, s );


	if ( strstr( ss , p ) != '\0' )
		printf("Yes\n") ;
	else 
		printf("No\n") ;
return 0;
}

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

public class Main {
    private static boolean debug = false;
    private static boolean elapsed = false;

    private static PrintWriter _out = new PrintWriter(System.out);
    private static PrintWriter _err = new PrintWriter(System.err);

    private int n;
    private long a;
    private long b;
    private long[] x;

    private void solve(Scanner sc) {
        n = sc.nextInt();
        a = sc.nextLong();  
        b = sc.nextLong();
        x = new long[n];
        for (int i = 0; i < n; ++i) {
            x[i] = sc.nextLong();
        }

        long cost = 0;
        for (int i = 0; i < n - 1; ++i) {
            if ((x[i + 1] - x[i]) * a > b) {
                cost += b;
            } else {
                cost += (x[i + 1] - x[i]) * a;
            }
        }
        _out.println(cost);
    }
    private long C(long n, long r) {
        long res = 1;
        for (long i = n; i > n - r; --i) {
            res *= i;
        }
        for (long i = r; i > 1; --i) {
            res /= i;
        }
        return res;
    }
    private long P(long n, long r) {
        long res = 1;
        for (long i = n; i > n - r; --i) {
            res *= i;
        }
        return res;
    }
    /*
     * 10^10 > Integer.MAX_VALUE = 2147483647 > 10^9
     * 10^19 > Long.MAX_VALUE = 9223372036854775807L > 10^18
     */
    public static void main(String[] args) {
        long S = System.currentTimeMillis();

        Scanner sc = new Scanner(System.in);
        new Main().solve(sc);
        _out.flush();

        long G = System.currentTimeMillis();
        if (elapsed) {
            _err.println((G - S) + "ms");
        }
        _err.flush();
    }
}

Measured memory_bytes: 34584
import std.stdio;
import std.algorithm;
import std.string;
import std.conv;
import std.math;

void main(){

    while(true){
	int[] cards;
	auto s = readln();
	if(stdin.eof()) break;
	auto s1 = split(chomp(s),',');
	for(int i=0;i<5;i++){
	    cards ~= to!int(s1[i]);
	}
	
	sort(cards);
//	foreach(i;cards) writeln(i);
	bool flg = false;

	int count = 0;
	for(int i=0;i<5;i++){
	    count = 0;
	    for(int j=0;j<5;j++){
		if(cards[i] == cards[j]) count++;
	    }
	    if(count==4) {
		writeln("four card");
		flg = true;
		break;
	    }
	}

	if(!flg){
	    bool three=false, two=false;
	    for(int i=0;i<5;i++){
		count = 0;
		for(int j=0;j<5;j++){
		    if(cards[i]==cards[j]) count++;
		}
		if(count==3) three = true;
		if(count==2) two = true;
		if(three&&two){
		    writeln("full house");
		    flg = true;
		    break;
		}
	    }
	}

	if(!flg){
	    bool st=true;
	    if(cards[0]==1&&cards[1]==10)cards[0]=9;
	    for(int i=0;i<4;i++){
		if(cards[i+1]-cards[i]!=1) st = false;
	    }
	    if(st){
		writeln("straight");
		flg = true;
	    }
	}

	if(!flg){
	    bool three=false;
	    for(int i=0;i<5;i++){
		count = 0;
		for(int j=0;j<5;j++){
		    if(cards[i]==cards[j]) count++;
		}
		if(count==3) three = true;
		if(three){
		    writeln("three card");
		    flg = true;
		    break;
		}
	    }
	}

	if(!flg){
	    int p1,p2;
	    for(int i=0;i<5;i++){
		count = 0;
		for(int j=0;j<5;j++){
		    if(cards[i]==cards[j]&&p1!=cards[i]) count++;
		}
		if(count==2&&p1>0) p2 = cards[i];
		if(count==2) p1 = cards[i];
		if(p1&&p2){
		    writeln("two pair");
		    flg=true;
		    break;
		}
	    }
	    if(p1&&!flg){
		writeln("one pair");
		flg = true;
	    }
	}

	if(!flg) writeln("null");
    }
}

Measured memory_bytes: 2492
mod=10**9+7
g1=[1,1]
g2=[1,1]
inverse=[0,1]
h,w,a,b=map(int,input().split())
n=h+w
for i in range(2,n+1):
    g1.append((g1[-1]*i)%mod)
    inverse.append((-inverse[mod % i]*(mod//i))%mod)
    g2.append((g2[-1]*inverse[-1])%mod)
def cmb(n,r):
    return g1[n]*g2[r]*g2[n-r]%mod

ans=0
while a<h and b<w:
    ans=(ans+cmb(h-1-a+b,b)*cmb(w-1-b+a,a))%mod
    a+=1
    b+=1
print(ans)

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

int main(){
    int a, b;
    cin >> a >> b;
    
    if (a < b){
        cout << "a < b" << endl;
    }
    
    else if (a == b){
        cout << "a == b" <<endl;
    }
    
    else {
        cout <<  "a > b" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
#define int long long
#define FOR(i, begin, end) for(ll i = (begin); i < (end); i++)
#define rep(i, n) FOR(i, 0, n)
using ll = long long;
using ull = unsigned long long;
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using pii = pair<int, int>; using pll = pair<ll, ll>; using vi = vector<int>; using vl = vector<ll>;
template<typename T, typename U> static void chmin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> static void chmax(T &x, U y) { if (x < y) x = y; }
int n;
int c2(int x) {
    return x * (x-1) / 2;
}
signed main() {
    cin>>n;
    vi a(n);
    rep(i,n) cin>>a[i];
    vi b(a), c(n);
    rep(i,n) b[i] -= i;
    rep(i,n) c[i] = -a[i] - i;
    int ans = 0;
    unordered_map<int, int> m;
    rep(i,n) {
        m[b[i]]++;
    }
    rep(j,n) {
        if(b[j]!=c[j])
            ans += m[c[j]];
        else
            ans += m[c[j]] - 1;
    }
    
    // for(auto x : m) {
    //     if(x.second>1)
    //     ans += c2(x.second);
    // }
    cout<<ans<<endl;
    return 0;
}

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

#ifdef DEBUG
#include "../.inc/debug.hpp"
#else
#define debug(...) 42
#define rdfile(...) 42
#endif

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    // rdfile("_input.txt");

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

    long long cnt = 0;
    for (int i=0; i<N; ++i) {
        int t1 = min(A[i], B[i]);
        cnt += t1;
        B[i] -= t1;
        int t2 = min(A[i+1], B[i]);
        cnt += t2;
        A[i+1] -= t2;
        B[i] -= t2;
    }
    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 1024
#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;
	cin >> n;
	rep(i, n) {
		string order;
		string output;
		string tmp,tmp2;
		cin >> order >> output;
		reverse(all(order));
		rep(o, order.size()) {
			switch (order[o]) {
			case 'J':
				tmp = output.substr(0, output.size() - 1);
				output = output[output.size() - 1] + tmp;
				break;
			case 'C':
				tmp = output.substr(1, output.size() - 1);
				output = tmp+output[0];
				break;
			case 'E':
				tmp = output.substr(0, output.size() / 2);
				tmp2= output.substr((output.size() % 2)? output.size() / 2 +1: output.size() / 2, output.size() / 2 );
				if (output.size() % 2) {
					output = tmp2 + output[output.size() / 2] + tmp;
				}
				else {
					output = tmp2 + tmp;
				}
				break;
			case 'A':
				reverse(all(output));
				break;
			case 'P':
				rep(c , output.size()) {
					if (output[c] >= '1'&&output[c] <= '9') {
						output[c]--;
					}
					else if (output[c] == '0') {
						output[c] = '9';
					}
				}
				break;
			case 'M':
				rep(c, output.size()) {
					if (output[c] >= '0'&&output[c] <= '8') {
						output[c]++;
					}
					else if (output[c] == '9') {
						output[c] = '0';
					}
				}
				break;
			defalt:
				break;
			}
		}
		cout << output << endl;
	}

}



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

int main(void){
    int N;
    long long answer;
    cin >> N;
    long long dp[100] = {0};
    dp[0] = 2;
    dp[1] = 1;
    for(int i=2; i<N+1; i++){
        dp[i] = dp[i-1] + dp[i-2];
    }
    answer = dp[N];

    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-


class Prime(object):
    '''Represents a snippet for prime numbers.
    '''

    def __init__(self, number):
        self.number = number
        self._values = []

    def is_included(self) -> bool:
        '''Determine whether it is a prime number.
        Args:
            number: Int of number (greater than 0).
        Returns:
            True if the input number was prime.
            False if the input number was not prime.
        See:
            https://qiita.com/srtk86/items/874639e361917e5016d4
            https://docs.python.org/ja/3/library/2to3.html?highlight=isinstance#2to3fixer-isinstance
        '''

        from math import sqrt

        if (self.number <= 1) or (isinstance(self.number, float)):
            return False

        for i in range(2, int(sqrt(self.number)) + 1):
            if self.number % i == 0:
                return False

        return True

    def generate(self) -> list:
        '''Generate a list of prime numbers using sieve of Eratosthenes.
        Returns:
            A list of prime numbers that is eqaul to or less than the input
            number.
        Landau notation: O(n log log n)
        See:
            https://beta.atcoder.jp/contests/abc110/submissions/3254947
        '''

        if self._values:
            return self._values

        is_met = [True for _ in range(self.number + 1)]
        is_met[0] = False
        is_met[1] = False

        for i in range(2, self.number + 1):
            if is_met[i]:
                self._values.append(i)

                for j in range(2 * i, self.number + 1, i):
                    is_met[j] = False
        return self._values


def main():
    x = int(input())
    ps = Prime(2 * 10 ** 5)

    for pi in ps.generate():
        if pi >= x:
            print(pi)
            exit()


if __name__ == '__main__':
    main()


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

const int N = 2e5+7;
int a[N];

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

    int n, k;
    cin>>n>>k;

    for (int i=1; i<=n; i++) {
        cin>>a[i];
        a[i] += a[i-1];
    }

    int mx = 0;

    for (int l=1; l+k-1<=n; l++) {
        int sum = a[l+k-1] - a[l-1];
        mx = max(mx, sum);
    }

    mx += k;
    cout<<mx/2<<"."<<5*(mx%2)<<endl;
}


Measured memory_bytes: 1024