akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(){
    int a,b;
    cin >> a >> b;
    if(a==b){
        cout << "Draw" << endl;
    }
    else if(a==1){
        cout << "Alice" << endl;
    }
    else if(b==1){
        cout << "Bob" << endl;
    }
    else if(a>b){
        cout << "Alice" << endl;
    }
    else{
        cout << "Bob" << endl;
    }
    return 0;
}



Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

const INF: u32 = 1000000000;
const LINF: u64 = 1000000000000000000;

fn main(){
	let (N, d, x): (i32, i32, i32) = (read(), read(), read());
	
	let mut c: i32 = x;
	for i in 0 .. N {
		let a: i32 = read();
		
		c += (d + a - 1) / a;
	}
	
	println!("{}", c);
}


Measured memory_bytes: 4352
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define FOR(i, a, b) for(ll i = a; i < b; i++)
#define rep(i, n) FOR(i,0,n)
#define rFOR(i, a, b) for(ll i = a - 1; i >= b; i--)
#define rrep(i, a) rFOR(i, a, 0)
#define pb push_back
using namespace std;
using ll = long long;
using ld = long double;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<char> vc;
typedef vector<vc> vvc;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
const ld PI = acos(-1);
const ll INF = 1e18;
struct edge{ll to, cost;};

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

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

long long floor_sum(long long n, long long m, long long a, long long b) {
    long long ans = 0;  
    if (a >= m) {
        ans += (n - 1) * n * (a / m) / 2;
        a %= m;
    }
    if (b >= m) {
        ans += n * (b / m);
        b %= m;
    }
    long long y_max = (a * n + b) / m, x_max = (y_max * m - b);
    if (y_max == 0) return ans;
    ans += (n - (x_max + a - 1) / a) * y_max;
    ans += floor_sum(y_max, a, m, (a - x_max % a) % a);
    return ans;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int T;
    cin >> T;
    while(T--){
        ll N,M,A,B;
        cin >> N >> M >> A >> B;
        cout << floor_sum(N,M,A,B) << '\n';
    }
}
/*
overflow checked?
corner case checked?
boundary checked?
not TLE in worst case checked?
Is q inputed?
*/

Measured memory_bytes: 3636
import numpy as np
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**8)
INF = float('inf')
MOD = 10**9+7


def main():
  N = int(readline())
  P = np.array(readline().split(), np.int64)
  A = np.array(range(1,N+1), np.int64)
  B = np.count_nonzero(P-A)
  if B==0 or B==2:
    ans = 'YES'
  else:
    ans = 'NO'
  print(ans)
  
  
  
  
      
if __name__ == '__main__':
  main()

Measured memory_bytes: 20696
using System;
class Program
{
    static void Main(string[] args)
    {
        bool isFirst = true;
        int[] coins = new int[] { 10, 50, 100, 500 };
        int range = 4;
        int bill, ownedMoney, changeMoney;
        int[] ownedCoins = new int[range], changeCoins = new int[range], paymentCoins = new int[range];

        while (true)
        {
            bill = int.Parse(Console.ReadLine());
            if (bill == 0) break;
            if (isFirst) { isFirst = false; } else { Console.WriteLine(); }
            ownedCoins = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);

            ownedMoney = 0;
            for (int i = 3; i >= 0; i--)
                ownedMoney += coins[i] * ownedCoins[i];

            changeMoney = ownedMoney - bill;

            for (int i = 3; i >= 0; i--)
            {
                changeCoins[i] = changeMoney / coins[i];
                changeMoney = changeMoney % coins[i];
                paymentCoins[i] = ownedCoins[i] - changeCoins[i];
            }
            for (int i = 0; i <= 3; i++)
                if (paymentCoins[i] > 0) Console.WriteLine("{0} {1}", coins[i], paymentCoins[i]);
        }
    }
}


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

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

using namespace std;

using ll = long long;
using P = pair<int, int>;

int main() {
  int n;
  cin >> n;
  vector<string> w(n);
  rep(i, n) cin >> w.at(i);
  char end;
  map<string, int> mp;
  bool ok = true;
  rep(i, n) {
    bool startIsOk = true;
    if (i != 0) {
      startIsOk = (end == w.at(i)[0]);
    }
    ok = mp.count(w.at(i)) == 0 && startIsOk;
    if (!ok) {
      break;
    }
    mp[w.at(i)]++;
    end = w.at(i).back();
  }
  cout << (ok ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define y1 zzz
#define fi first
#define se second
#define PII pair<int,int>
#define PII2 pair<int,PII >
#define PII3 pair<PII,int >
#define PII4 pair<PII,PII >
#define all(x) (x).begin(),(x).end()
#define pb push_back
int n,k,p[2000010][70];
int jump(int u,int dis)
{
    for(int i=60;i>=0;i--)
        if((1LL<<i)&dis)u=p[u][i];
    return u;
}
void solve()
{
    cin>>n>>k;
    for(int i=1;i<=n;i++)cin>>p[i][0];
    for(int j=1;j<=64;j++)
    for(int i=1;i<=n;i++)
        p[i][j]=p[p[i][j-1]][j-1];
    cout<<jump(1,k);
}
int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    //freopen("CUBE.inp","r",stdin);
    //freopen("CUBE.out","w",stdout);
    //int t;cin>>t;while(t--)
    solve();
    return 0;
}


Measured memory_bytes: 113036
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
#include <iomanip>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
ll a[100001];
ll b[100001];
ll kai[100001];
int main()
{
	int n;
	ll ans=1;
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>a[i];
	for(int i=0;i<n;i++)
		cin>>b[i];
	kai[0]=1;
	for(int i=1;i<100001;i++)
	{
		kai[i]=kai[i-1]*(ll)i;
		kai[i]%=MOD;
	}
	sort(a,a+n);
	sort(b,b+n);
	a[n]=1e14-1;
	b[n]=1e14-1;
	int acnt=0;
	int bcnt=0;
	int aind=0;
	int bind=0;
	while(!(aind==n && bind==n))
	{
		if(a[aind]<b[bind]){
			aind++;
			if(bcnt>0)
			{
				ans*=(ll)bcnt;
				bcnt--;
				ans%=MOD;
			}else{
				acnt++;
			}
		}else{
			bind++;
			if(acnt>0)
			{
				ans*=(ll)acnt;
				acnt--;
				ans%=MOD;
			}else{
				bcnt++;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

int main() {
  int N,i,s=0;
  cin >> N;
  vector<int> A(N), B(N), C(N-1);
  for(i=0; i<N; i++)
    cin >> A.at(i);
  for(i=0; i<N; i++)
    cin >> B.at(i);
  for(i=0; i<N-1; i++)
    cin >> C.at(i);
  
  for(i=0; i<N; i++) {
    s += B.at(A.at(i)-1);
    if(i!=0 && A.at(i-1)+1==A.at(i))
      s += C.at(A.at(i-1)-1);
  }
  
  cout << s << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>

int main() {

	int X[3]{};
	for (int i{}; i < 3; i++)
		std::cin >> X[i];


	std::sort(std::begin(X), std::end(X));

	std::cout << X[2] * 10 + X[1] + X[0] << "\n";

	return 0;
}

Measured memory_bytes: 256
"""
解説を参考に作成 その3
"""


def solve():
    N, M = map(int, input().split())
    A = [int(i) for i in input().split()]
    A.sort()
    CB = [list(reversed([int(i) for i in input().split()])) for _ in range(M)]
    CB = list(sorted(CB, reverse=True))

    count = 0
    flag = False
    for cb in CB:
        for b in range(cb[1]):
            if A[count] < cb[0]:
                A[count] = cb[0]
            else:
                flag = True
                break
            count += 1
            if count >= N:
                flag = True
                break

        if flag:
            break
    print(sum(A))


if __name__ == '__main__':
    solve()


Measured memory_bytes: 27100
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
using namespace std;
using ll = long long;
using ld = long double;
template<class T> bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<class T> bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}

int main(){
  ios_base::sync_with_stdio(false);cin.tie(0);
  int N,M;
  cin >> N >> M;
  vector<vector<int>> graph(N);
  for(int i=0;i<M;i++){
    int a,b;
    cin >> a >> b;
    a--;
    b--;
    graph.at(a).pb(b);
    graph.at(b).pb(a);
  }

  vector<int> ans(N,-1);
  queue<int> q;
  q.push(0);
  ans.at(0)=0;
  while(!q.empty()){
    int v=q.front();
    q.pop();
    for(int i=0;i<sz(graph.at(v));i++){
      int nv=graph.at(v).at(i);
      if(ans.at(nv)!=-1)  continue;
      ans.at(nv)=v;
      q.push(nv);
    }
  }
  cout << "Yes" << endl;
  for(int i=1;i<N;i++)  cout << ans.at(i)+1 << endl;

  return 0;
}

Measured memory_bytes: 10200
#include <stdio.h>
int main()
{
	int n,k,x,y;
	scanf("%d%d",&n,&k);
	scanf("%d%d",&x,&y);
	int ans = 0;
	for(int i = 0;i < n;i++)
	{
		if(i < k)
			ans += x;
		else
			ans += y;
	}
	printf("%d\n",ans);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
    #define rep(i, n) for (int i = 0; i < (n); ++i)
    using namespace std;
    typedef long long ll;
     
    int main()
    {
        int a, b;
        cin >> a >> b;
        if (b * 2 < a)
        {
            cout << (a - b * 2) << endl;
        }
        else
        {
            cout << 0 << endl;
        }
     
        return 0;
    }

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

struct permutation {
  vector<int> p;
  int n;
  
  void init(int _n) {
    n = _n;
    p.reserve(n + 1);
    for(int i = 1; i <= n; i++) {
      p[i] = i;
    }
  }

  void read(int _n) {
    init(_n);
    for(int i = 1; i <= n; i++) {
      scanf("%d", &p[i]);
    }
  }

  void print(void) {
    for(int i = 1; i <= n; i++) {
      printf("%d%c", p[i], i == n ? '\n' : ' ');
    }
  }

  permutation inverse(void) {
    permutation q;
    q.init(n);
    for(int i = 1; i <= n; i++) {
      q.p[p[i]] = i;
    }
    return q;
  }

  permutation operator * (const permutation &rhs) const {
    permutation q;
    q.init(n);
    for(int i = 1; i <= n; i++) {
      q.p[i] = p[rhs.p[i]];
    }
    return q;
  }
}a[6], t;

permutation operator ^ (permutation p, int y) {
  permutation q;
  q.init(p.n);
  for(; y; y >>= 1, p = p * p) {
    if(y & 1) {
      q = q * p;
    }
  }
  return q;
}

int n, m;

int main(void) {
  scanf("%d%d", &n, &m);
  m--;
  a[0].read(n); a[1].read(n);
  for(int i = 2; i < 6; i++) {
    a[i] = a[i - 1] * a[i - 2].inverse();
  }
  t = (a[3] * a[0]) ^ (m / 6);
  (t * a[m % 6] * t.inverse()).print();
  return 0;
}


Measured memory_bytes: 4728
#include <iostream>
#include <vector>
#include <string>
#include <bits/stdc++.h>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <deque>
#include <tuple>
#include <unordered_set>
#include <array>
#include <string>

using namespace std;
#define ll long long
#define ar array

int main()
{	
	ll s, k, d;
	cin >> s >> k >> d;
	s=abs(s);
	ll times=min(s/d, k);
	ll ans=s-times*d;
	ll rem=k-times;
	if (rem&1) {
		cout << abs(ans-d) << endl;
	} else {
		cout << ans << endl;
	}
	return 0;
}

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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define spa << " " <<
#define MP make_pair
ll MOD = 1e9+7;
//ll MOD = 998244353;
ll INF = 1e18;
void chmin(ll &a, ll b) { if (a > b) a = b; }
void chmax(ll &a, ll b) { if (a < b) a = b; }
void answer1(bool x){
  if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void answer2(bool x){
  if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void answer3(bool x){
  if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void answer(bool x, ll y, ll z){
  if(x) cout<<y<<endl;else cout<<z<<endl;}   


int main(){
  ll i, j;
  //ll n;
  //cin >> n;
  ll n;
  cin >> n;
  //string s; cin >> s;
  ll result = 0;
  bool judge = true;
  
  vector<ll> a(n);
  for(i=0;i<n;i++){
    cin >> a[i];
  }
  sort(ALL(a));
  ll buf = a[0];
  if(a[n-1]%2==0){
    for(i=1;i<n-1;i++){
      if(abs(a[n-1]/2-buf)>=abs(a[n-1]/2-a[i])){
        buf = a[i];
      }
    }
  }
  else{
    for(i=1;i<n-1;i++){
      if(min(abs(a[n-1]/2-buf),abs(a[n-1]/2+1-buf))>=
        min(abs(a[n-1]/2-a[i]),abs(a[n-1]/2+1-a[i]))){
        buf = a[i];
        /*cout<<buf spa 
        min(abs(a[n-1]/2-buf),abs(a[n-1]/2+1-buf)) spa
        min(abs(a[n-1]/2-a[i]),abs(a[n-1]/2+1-a[i]))
        << endl;*/
      }
    }
  }
  cout << a[n-1] spa buf << endl;

  return 0;
}

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

int main()
{   ios::sync_with_stdio(false);
    int k, a, b;

    cin>>k>>a>>b;

    if( a%k&&b%k ){
        if( a/k!=b/k )
            cout<<"OK";
        else
            cout<<"NG";
    }
    else
        cout<<"OK";

	return 0;
}


Measured memory_bytes: 3652
string = input()

length = len(string)
half = length // 2
if length % 2 == 0:
    left = string[:half]
    right = string[half:]
else:
    left = string[:half]
    right = string[half+1:]
assert len(left) == len(right)

diff = 0
for i in range(half):
    if left[i] != right[-1-i]:
        diff += 1
print(diff)

Measured memory_bytes: 3064
import std.stdio;
import std.string;
import std.conv;

void main()
{
	auto X = readln.split.to!(int[]),A = X[0],B = X[1];
	if((A + B) % 2 == 0)
	{
		writeln((A + B) / 2);
}
	else
	{
		writeln((A + B) / 2 + 1);
	}}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
	int n;
	cin >> n;
	if (n == 111) {
		cout << "999" << endl;
	}
	else if (n == 119) {
		cout << "991" << endl;
	}
	else if (n == 191) {
		cout << "919" << endl;
	}
	else if (n == 199) {
		cout << "911" << endl;
	}
	else if (n == 911) {
		cout << "199" << endl;
	}
	else if (n == 919) {
		cout << "191" << endl;
	}
	else if (n == 991) {
		cout << "119" << endl;
	}
	else cout << "111" << endl;
}

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

class Card{
  public:
    string name;
    int number;
};

bool CardsSortPredicate(const Card& c1, const Card& c2)
{
  return c1.number < c2.number;
}

int partition(vector<Card> &A, int p, int last){
  int x = A[last].number;
  int bigger_first_ind = p - 1;
  for(int j = p; j < last; j++){
    if(A[j].number <= x) swap(A[++bigger_first_ind], A[j]);
  }
  swap(A[++bigger_first_ind], A[last]);
  return bigger_first_ind;
}

void quicksort(vector<Card> &A, int p, int r){
  if(p < r){
    int q = partition(A, p, r);
    quicksort(A, p, q-1);
    quicksort(A, q+1, r);
  }
}

int main(){
  int n;
  cin >> n;
  vector<Card> cards1, cards2;
  for(int i = 0; i < n; i++){
    string s;
    int n;
    cin >> s >> n;
    Card c; c.name = s; c.number = n;
    cards1.push_back(c);
    cards2.push_back(c);
  }
  quicksort(cards1, 0, n-1);
  stable_sort(cards2.begin(), cards2.end(), CardsSortPredicate); // stl???????????????????????????????????????
  bool flag = true;

  for(int i = 0; i < n; i++){
    if(cards1[i].name != cards2[i].name || cards1[i].number != cards2[i].number){
      flag = false;
      cout << "Not stable" << endl;
      break;
    }
  }
  if(flag == true) cout << "Stable" << endl;
  for(int i = 0; i < n; i++){
    cout << cards1[i].name << " " << cards1[i].number << endl;
  }

}

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

const int MAXN = 100010;
int h[MAXN];
int main() {
	int n;
	cin>>n;
	for (int i=0; i<n; i++)
		cin>>h[i];

	if (n == 1) {
		cout<<"Yes"<<endl;
		return 0;
	}

	for (int i=n-2; i>=0; i--) {
		if (h[i] > h[i+1])
			h[i]--;
		if (h[i] > h[i+1]) {
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}

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

int main()
{
    string x;

    while (true) {
        cin >> x;

        if (x[0] == '0') {
            return 0;
        }

        int sum = 0;

        for (int i = 0; i < (int)x.size(); i++) {
            sum += (int)x[i] - '0';
        }

        cout << sum << endl;
    }
}

Measured memory_bytes: 1184
#include <stdio.h>
int main(void)
{
    int n;
    scanf("%d",&n);
    long int a[n];
    for(int p=0;p<n;p++)scanf("%ld",&a[p]);
    long int min=0;
    long int max=0;
    int pmax=0;
    int pmin=0;
    int cmax=0;
    int cmin=0;
    for(int q=0;q<n;q++)
    {
        if(a[q]>0)cmax++;
        if(a[q]<0)cmin++;
        if(max<a[q])
        {
            max=a[q];
            pmax=q;
        }
        if(min>a[q])
        {
            min=a[q];
            pmin=q;
        }
    }
    int co;
    if(max+min>=0)co=1;
    else co=0;
    if(co==1)
    {
        printf("%d\n",cmin+n-1);
        for(int r=0;r<n;r++)
        {
            if(a[r]<0)
              printf("%d %d\n",pmax+1,r+1);
        }
        for(int s=0;s<n-1;s++)
          printf("%d %d\n",s+1,s+2);
    }
    else
    {
        printf("%d\n",cmax+n-1);
        for(int t=0;t<n;t++)
        {
            if(a[t]>0)
              printf("%d %d\n",pmin+1,t+1);
        }
        for(int u=n-1;u>0;u--)
          printf("%d %d\n",u+1,u);
    }
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define sz(arr) (int)arr.size()

using namespace std;

int main() {
  vector<string> v(3);
  for (auto &e : v) cin >> e;

  for (int i = 0; i < sz(v) - 1; ++i) {
    if (!(v.at(i).at(sz(v.at(i)) - 1) == v.at(i + 1).at(0))) {
      puts("NO");
      return 0;
    }
  }

  puts("YES");

  return 0;
}

Measured memory_bytes: 256
X = int(input())


def is_prime(n):
    if n < 2:
        return False
    if n == 2:
        return True
    if n % 2 == 0:
        return False
    m = 3
    while m ** 2 <= n:
        if n % m == 0:
            return False
        m += 2
    return True


n = X
while not is_prime(n):
    n += 1
print(n)

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

int main(void) {
  long long n, m;
  string s, t;
  cin >> n >> m;
  cin >> s >> t;

  long long result = 0;
  long long lcd = n * m / __gcd(n, m);
  long long steplcd = (lcd / n) * (lcd / m);

  for (long long i = 0; i < lcd; i += steplcd) {
    if (s[i * n / lcd] != t[i * m / lcd]) {
      result = -1;
      break;
    }
  }
  if (result != -1) result = lcd;

  cout << result << endl;
  return 0;
}

Measured memory_bytes: 3724
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
map<LL, int> cnt;

LL datas[100005];
LL pref[100005];
int main()
{
	int n, m;
	scanf("%d%d", &n, &m);
	for(int a=0;a<n;a++)
	{
		scanf("%lld", &datas[a]);
		datas[a]=datas[a]%m;
	}
	LL total=0;
	for(int a=0;a<n;a++)
	{
//		if(a > 0) cout<<" ";
		total+=datas[a];
		total%=m;
//		cout<<total;
//		pref[a]=total;
		cnt[total]++;
	}
//	cout<<endl;
//	for(int a=0;a<n;a++)
//	{
//		for(int b=a;b<n;b++)
//		{
//			LL total=0;
//			for(int c=a;c<=b;c++)
//			{
//				total+=datas[c];
//			}
//			if(total%m==0)
//			{
//			cout<<total<<endl;
//				cout<<a<<" "<<b<<endl;
//			}
//		}
//	}
	LL hasil=0;
	LL pre=0;
	for(int a=0;a<n;a++)
	{
		LL tmp=m+pre;
		tmp%=m;
//		cout<<a<<" "<<tmp<<" = "<<cnt[tmp]<<endl;
		hasil+=cnt[tmp];
		pre+=datas[a];
		pre%=m;
		cnt[pre]--;
	}
	cout<<hasil<<endl;
	return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
void manager_no(){
    int A[200010]={};
    int ans[200010]={};
    int n; cin >> n;
    int a;
    for(int i=2;i<=n;i++){
        cin >> A[i];
    }
    for(int i=1;i<=n;i++){
        ans[A[i]]++;
    }
    for(int i=1;i<=n;i++){
        cout << ans[i] << endl;
    }
}

int main(){
    manager_no();
    return 0;
}

Measured memory_bytes: 5176
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include<math.h>
#define ll long long

int main(){
  ll int i,N,M,ANS=0;
  scanf("%lld %lld",&N,&M);
  
  ll int H[N+1];
  ll int A[M+1],B[M+1];
  ll int ans[N+1];
  
  for(i=1;i<=N;i++){
    ans[i]=1;
    scanf("%lld",&H[i]);
  }
  for(i=1;i<=M;i++){
    scanf("%lld %lld",&A[i],&B[i]);
    if(H[A[i]]<=H[B[i]]){
     ans[A[i]]=0;
    }
    if(H[A[i]]>=H[B[i]]){
     ans[B[i]]=0;
    }
  }
  
  for(i=1;i<=N;i++){
    if(ans[i]==1){
      ANS+=1;
    }
  }
  printf("%lld",ANS);
  return 0;
}

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

int main() {
    int n, a_max, tmp = 0;
    cin >> n;
    vector<int> vec(n);
    for (int i = 0; i < n; i++) cin >> vec.at(i);
    sort(vec.begin(), vec.end());
    a_max = vec.back();
    vector<bool> bl(a_max + 1, true);
    for (size_t i = 0; i < vec.size(); i++) {
        if (tmp == vec.at(i)) {
            bl.at(vec.at(i)) = false;
        }
        if (bl.at(vec.at(i))) {
            for (int j = 2; j * vec.at(i) <= a_max; j++) {
                bl.at(vec.at(i) * j) = false;
            }
        }
        tmp = vec.at(i);
    }
    int cnt = 0;
    for (size_t x = 0; x < vec.size(); x++) {
        if (bl.at(vec.at(x))) {
            cnt++;
        }
    }
    cout << cnt << endl;
}


Measured memory_bytes: 4320
#pragma GCC optimize ("-O3","unroll-loops")
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m-1;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define pb(a) push_back(a)
#define print(x) cout<<(x)<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define lb(v,n) lower_bound(v.begin(), v.end(), n)
#define ub(v,n) upper_bound(v.begin(), v.end(), n)
#define int long long
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")

template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7; const int MAX = 200050;
const double pi = acos(-1); const double EPS = 1e-12;
const ll INF = 2e18;


vector<int>G[100010];
int dp[100010][2];
bool vis[100010][2];
int func(int n,int pre, bool flag) {
	if (vis[n][flag])return dp[n][flag];
	int deg = G[n].size();
	if (deg == 1) {
		if (flag) {
			dp[n][flag] = 1;
		}
		else dp[n][flag] = 0;
	}
	else if (deg == 2) {
		if (flag) {
			ll res = INF;
			for (auto chi : G[n]) {
				if (chi == pre)continue;
				res = min(res, func(chi,n, 0) + 1);
				res = min(res, func(chi, n, 1));
			}
			dp[n][flag] = res;
		}
		else {
			ll res = INF;
			for (auto chi : G[n]) {
				if (chi == pre)continue;
				res = min(res, func(chi, n, 0));
			}
			dp[n][flag] = res;
		}
	}
	else {
		if (!flag) {
			dp[n][flag] = INF;
			vis[n][flag] = true;
			return INF;
		}
		ll sum = 0;
		for (auto chi : G[n]) {
			if (chi == pre)continue;
			sum += func(chi, n, 1);
		}
		ll res = INF;
		for (auto chi : G[n]) {
			if (chi == pre)continue;
			res = min(res, sum - func(chi, n, 1) + min(func(chi, n, 1), func(chi, n, 0)));
		}
		dp[n][flag] = res;
	}
	vis[n][flag] = true;
	//pe(n); pe(flag); print(dp[n][flag]);
	return dp[n][flag];
}

void solve() {
	int N; cin >> N;
	REP(i, N) {
		dp[i][0] = INF;
		dp[i][1] = INF;
	}
	REP(i, N - 1) {
		int u, v; cin >> u >> v;
		G[u].push_back(v);
		G[v].push_back(u);
	}
	int par = 0;
	int mx = 0;
	REP(i, N) {
		if (G[i].size() > mx) {
			mx = G[i].size();
			par = i;
		}
	}
	ll ans = func(par, par, 1);
	print(ans);
}


signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	solve();
}

Measured memory_bytes: 18304
#include <iostream>
#include <queue>

using namespace std;



int R;
int W1, W2, H1, H2;
int X1, X2, Y1, Y2;
int map1[550][550], map2[550][550];

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

struct Hole {
	int level;
	int x, y;
	
	Hole(int _l, int _x, int _y) : level(_l), x(_x), y(_y) {}
};

bool operator < (const Hole& h1, const Hole& h2) { return h1.level < h2.level; }
bool operator > (const Hole& h1, const Hole& h2) { return h1.level > h2.level; }
bool operator == (const Hole& h1, const Hole& h2) { return h1.level == h2.level; }
bool operator <= (const Hole& h1, const Hole& h2) { return h1.level <= h2.level; }
bool operator >= (const Hole& h1, const Hole& h2) { return h1.level >= h2.level; }

struct Data {
	int need, rooms;
	Data(int _n, int _r) : need(_n), rooms(_r) {}
};

bool operator < (const Data& d1, const Data& d2) { return d1.need < d2.need; }
bool operator > (const Data& d1, const Data& d2) { return d1.need > d2.need; }
bool operator == (const Data& d1, const Data& d2) { return d1.need == d2.need; }
bool operator <= (const Data& d1, const Data& d2) { return d1.need <= d2.need; }
bool operator >= (const Data& d1, const Data& d2) { return d1.need >= d2.need; }

int solver() {
	priority_queue<Hole, vector<Hole>, greater<Hole> > q1, q2;
	q1.push(Hole(1, X1-1, Y1-1)); q2.push(Hole(1, X2-1, Y2-1));
	map1[Y1-1][X1-1] = -1; map2[Y2-1][X2-1] = -1;
	
	vector<Data> v1, v2;
	
	int lev = 0;
	int cnt = 0;
	do {
		Hole h = q1.top(); q1.pop();
		if (h.level <= lev) {
			cnt++;
		} else {
			v1.push_back(Data(lev, cnt));
			lev = h.level;
			cnt++;
		}
		
		for (int d=0; d<4; d++) {
			int x = h.x + dx[d], y = h.y + dy[d];
			if (!(0<=x && x<W1 && 0<=y && y<H1)) continue;
			if (map1[y][x]==-1) continue;
			q1.push(Hole(map1[y][x], x, y));
			map1[y][x] = -1;
		}
		
	} while(!q1.empty());
	v1.push_back(Data(lev, cnt));
	
	lev = 0;
	cnt = 0;
	do {
		Hole h = q2.top(); q2.pop();
		if (h.level <= lev) {
			cnt++;
		} else {
			v2.push_back(Data(lev, cnt));
			lev = h.level;
			cnt++;
		}
		
		for (int d=0; d<4; d++) {
			int x = h.x + dx[d], y = h.y + dy[d];
			if (!(0<=x && x<W2 && 0<=y && y<H2)) continue;
			if (map2[y][x]==-1) continue;
			q2.push(Hole(map2[y][x], x, y));
			map2[y][x] = -1;
		}
		
	} while(!q2.empty());
	v2.push_back(Data(lev, cnt));
	
	int ret = 1e8;
	int i = 0, j = (int)v2.size()-1;
	while (i<(int)v1.size() && j >= 0) {
		Data d1 = v1[i], d2 = v2[j];
		if (d1.rooms + d2.rooms >= R) {
			ret = min(ret, d1.need + d2.need);
			j--;
		} else {
			i++;
		}
	}
	
	return ret;
}

int main() {
	while (1) {
		cin >> R; if (R==0) break;
		cin >> W1 >> H1 >> X1 >> Y1;
		for (int i=0; i<H1; i++) {
			for (int j=0; j<W1; j++) {
				cin >> map1[i][j];
			}
		}
		
		cin >> W2 >> H2 >> X2 >> Y2;
		for (int i=0; i<H2; i++) {
			for (int j=0; j<W2; j++) {
				cin >> map2[i][j];
			}
		}
		
		cout << solver() << endl;
	}
	
	return 0;
}

Measured memory_bytes: 6344
#include <iostream>

using namespace std;

int main()
{
    int l,r,d,i,k=0;
    cin >> l >> r >> d;
    for(i = l;i <= r;i++)
    {
        if(i%d == 0)
            k++;
    }
    cout << k << endl;
    return 0;
}

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

int main () {
  int N;
  string s;
  cin >> N >> s;
  bool ans = true;
  if (N%2 != 0) ans = false;
  else {
    for (int i = 0; i < N/2; i++) {
      if (s.at(i) != s.at(i+N/2)) ans = false;
    }
  }
  if (ans) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cstdio>
 
using namespace std;
using ll = long long;
 
#define rep(i, a) for (int i = 0; (i) < (int) (a); (i)++)
#define reps(i, a, b) for (int i = (int) (a); (i) < (int) (b); (i)++)
#define rrep(i, a) for (int i = (int) a-1; (i) >= 0; (i)--)
#define rreps(i, a, b) for (int i = (int) (a)-1; (i) >= (int) (b); (i)--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x
#define TRUE__  "Yes"
#define FALSE__ "No"
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define RS resize
#define CINV(v, N) do {\
	v.RS(N);\
	rep(i, N) cin >> v[i];\
} while (0);
#define RCINV(v, N) do {\
	v.RS(N);\
	rrep(i, N) cin >> v[i];\
} while (0);
template<typename T>
inline T GET() {
	T val;
	cin >> val;
	return val;
}

void init();
void solve();

signed main()
{
    init();
    solve();
}

int N, W;
vector<vector<ll> > dp;
vector<int> v, w;
const int V = 100100;

void init()
{
	cin >> N >> W;
	dp.RS(N+1, vector<ll>(V, LLONG_MAX));
	rep(i, N) {
		w.PB(GET<int>());
		v.PB(GET<int>());
	}
	dp[0][0] = 0;
}

void solve()
{
	rep(i, N) {
		rep(j, V) {
			dp[i+1][j] = min(dp[i][j], dp[i+1][j]);
			if (dp[i][j] != LLONG_MAX) {
				dp[i+1][j+v[i]] = min(dp[i+1][j+v[i]], dp[i][j] + w[i]);
			}
		}
	}
	ll res = 0;
	rep(i, N+1) {
		rep(j, V) {
			if (dp[i][j] != LLONG_MAX) {
			}
			if (dp[i][j] <= W) res = max(res, (ll)j);
		}
	}
	cout << res << endl;
}



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

int main() {
    int a, b, tmp;
    int cnt = 0;
    int nums[5];
    cin >> a >> b;
    for (int i = a; i <= b; i++) {
        tmp = i;
        for (int j = 0; j < 5; j++) {
            nums[j] = tmp % 10;
            tmp /= 10;
        }
        if (nums[0] == nums[4] && nums[1] == nums[3]) cnt += 1;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();
 
        int[][] list = new int[a][b];
        for (int i = 0; i < a; i++) {
            for (int j = 0; j < b; j++) {
                list[i][j] = scanner.nextInt();
            }
        }
        int[] list2 = new int[b];
        for (int i = 0; i < b; i++) {
            list2[i] = scanner.nextInt();
        }
        int sum;
        for (int i = 0; i < a; i++) {
            sum = 0;
            for (int j = 0; j < b; j++) {
                sum += list[i][j] * list2[j];
            }
            System.out.println(sum);
        }
 
    }
}



Measured memory_bytes: 40504
n, m, x = gets.chomp.split(" ").map(&:to_i)
na = gets.chomp.split(" ").map(&:to_i)

cost_a = 0
cost_b = 0

na.each do |i|
  i > x ? cost_a += 1 : cost_b += 1
end

puts [cost_a, cost_b].min

Measured memory_bytes: 1788
#include<stdio.h>
int main(){
    int S,h,m,s;
    scanf("%d",&S);
    h=S / 3600;
    m=(S - h * 3600) / 60;
    s=S - h * 3600 - m * 60;
    printf("%d:%d:%d\n",h,m,s);
    return 0;
}


Measured memory_bytes: 2088
#include <bits/stdc++.h>
using namespace std;
const int MAXN=100010;
int n,dp[MAXN];
int main () {
	scanf("%d",&n);
	if (n<100) {printf("0\n");return 0;}
	if (n<106) {printf("1\n");return 0;}
	dp[100]=dp[101]=dp[102]=dp[103]=dp[104]=dp[105]=1;
	for (int i=106;i<=n;i++) {
		dp[i]=(dp[i-100]|dp[i-101]|dp[i-102]|dp[i-103]|dp[i-104]|dp[i-105]);
	}
	printf("%d\n",dp[n]);
	return 0;
}

Measured memory_bytes: 640
//abc093_a.cpp
//Sat Apr  7 20:40:04 2018

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
using namespace std;

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

	int aflag = 0;
	int bflag = 0;
	int cflag = 0;

	for (int i=0;i<3;i++){
		if (s[i]=='a'){
			aflag = 1;
		} else if (s[i]=='b'){
			bflag = 1;
		} else if (s[i]=='c'){
			cflag = 1;
		}
	}

	if (aflag == 1 && bflag == 1 && cflag == 1){
		cout << "Yes"<< endl;
	}else{
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        String s=sc.next();
        boolean isTrue=false;
        for(int i=0;i<s.length();i++){
            if(s.charAt(i)=='7'){
                isTrue=true;
                break;
            }
        }

        if(isTrue)
            System.out.println("Yes");
        else
            System.out.println("No");
    }
}


Measured memory_bytes: 35680
def test_case():
    while True:
        a, op, b = map(str, input().split())
        a, b = int(a), int(b)
        if op == '+':
            print(a+b)
        elif op == '-':
            print(a-b)
        elif op == '*':
            print(a*b)
        elif op == '/':
            print(int(a/b))
        elif op == '?':
            break


if __name__ == "__main__":
    test_case()



Measured memory_bytes: 5600
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
using namespace std;
using lint = long long;
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; }

int main()
{
    optimize_cin();

    int N; cin >> N;
    vector<lint> T(N);
    rep (i, N) { cin >> T[i]; }
    lint M; cin >> M;
    vector<lint> P(M);
    vector<lint> X(M);
    rep (i, M) { cin >> P[i] >> X[i]; }

    int sum = 0;
    rep (i, N)
    {
        sum += T[i];
    }

    rep (i, M)
    {
        cout << sum - T[P[i] - 1] + X[i] << "\n";
    }

    return 0;
}


Measured memory_bytes: 256
a,b,c = gets.split.map &:to_i
k = gets.to_i

count = 0

while a >= b
	b = b * 2
	count += 1
end

while b >= c
	c = c * 2
	count += 1
end

if k >= count then
	puts 'Yes'
else
	puts 'No'
end

Measured memory_bytes: 14332
object Main {
  def main(args: Array[String]): Unit = {
    import java.util.Scanner
    val in = new Scanner(System.in)
    val n = in.nextInt()
    val list = List.fill(n)(in.next() -> (in.nextInt() * -1))
    val indexedList = for ((data, i) <- list.zipWithIndex) yield (i, data)
    val sortedList = indexedList.sortBy(_._2._2).sortBy(_._2._1)
    for (i <- (0 until n)) println(sortedList(i)._1 + 1)
    in.close()
  }
}

Measured memory_bytes: 25672
#include <bits/stdc++.h>
using namespace std;
const int maxn=1e5+10;
int dis[maxn];

int main(){
	int a,b;
	cin>>a>>b;
	if((a==1&&b==2)||(a==2&&b==1)) cout<<3;
	if((a==1&&b==3)||(a==3&&b==1)) cout<<2;
	if((a==2&&b==3)||(a==3&&b==2)) cout<<1;
}

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

#define mp make_pair
#define pb push_back
#define repm(i, n, m)  for(int i = n; i < m; ++i)
#define Repm(i, n, m)  for(int i = n; i <= m; ++i)
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repn(i, n) repm(i, 1, n)
#define mod 1000000000+7

int main(){
    int s;  cin >> s;
    vector<int> a;
    a.pb(s);

    while(true) {
			if(s % 2 == 0) {
				s = s/2;
				a.pb(s);
			}else {
				s = 3*s + 1;
				a.pb(s);
			}
			for(int i = 0; i < a.size() - 1; i++) {
				for(int j = i+1; j < a.size(); j++) {
					if(a.at(i) == a.at(j)) {
						cout << (j+1) << endl;
						return 0;
					}
				}
			}
		}
}


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

using namespace std;

int main(){
    int N,M,ans=0;
    cin >> N >> M;
    vector<int> p(N),color(N,-1);
    vector<vector<int>> graph(N);
    for(int i=0;i<N;i++){
        cin >> p[i];
        p[i]--;
    }

    for(int i=0;i<M;i++){
        int x,y;
        cin >> x >> y;
        x--;
        y--;
        graph[x].push_back(y);
        graph[y].push_back(x);
    }

    queue<int> Q;

    for(int i=0;i<N;i++){

        vector<int> state;
        map<int,int> element;

        if(color[i]==-1){
            Q.push(i);
            color[i] = 0;
        }

        while(!Q.empty()){
            int now = Q.front();
            Q.pop();
            state.push_back(now);
            element[p[now]]++;
            for(int j=0;j<graph[now].size();j++){
                if(color[graph[now][j]]==-1){
                    Q.push(graph[now][j]);
                    color[graph[now][j]] = 0;
                }
            }
        }

        for(int j=0;j<state.size();j++){
            ans += element[state[j]];
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 11512
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

const map<int, int> CalcPrimeFactoriation(const int N)
{
    int n = N;
    map<int, int> ans;
    vector<int> primes{ 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97 };
    for (const int p : primes)
    {
        while (n >= p)
        {
            if (n % p == 0)
            {
                ++ans[p];
                n /= p;
            }
            else
            {
                break;
            }
        }
    }
    return ans;
}

// 指数がm以上の素数を探す
const int Num(const map<int, int> &primes, const int m)
{
    int ret = 0;
    for (const auto &kvp : primes)
    {
        if (kvp.second >= m) ++ret;
    }
    return ret;
}

int main()
{
    int N; cin >> N;
    map<int, int> primes;
    // N!の素因数分解を計算
    for (int i = 2; i <= N; ++i)
    {
        for (const auto &kvp : CalcPrimeFactoriation(i))
        {
            primes[kvp.first] += kvp.second;
        }
    }
    // 約数の個数が75となる素因数分解のパターンを列挙
    cout << Num(primes, 74) + Num(primes, 24) * (Num(primes, 2) - 1)
        + Num(primes, 14) * (Num(primes, 4) - 1)
        + Num(primes, 4) * (Num(primes, 4) - 1) * (Num(primes, 2) - 2) / 2 << endl;
}


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

int main()
{
    int n,k; cin>>n>>k;
    int ar[n];
    for(int i = 0;i < n;i++) cin>>ar[i];
    sort(ar,ar+n);
    int sum = 0;
    for(int i = 0;i < k;i++){
        sum += ar[i];
    }
    cout<<sum<<"\n";
	return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
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;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

map<ll, ll> prime_factorization(ll n) {
    map<ll, ll> m;
    ll x = n;
    ll d = 2;
    while (x > 1 && d * d <= n) {
        if (x % d == 0) {
            m[d]++;
            x /= d;
        } else {
            d++;
        }
    }
    if (x != 1) m[x]++;
    return m;
}

void solve() {
    int n;
    cin >> n;

    map<ll, ll> f;
    FOR(i, 2, n + 1) {
        auto x = prime_factorization(i);
        for (auto y : x) f[y.first] += y.second;
    }
    int a75 = 0;
    int a25 = 0;
    int a15 = 0;
    int a5 = 0;
    int a3 = 0;
    for (auto g : f) {
        //cout << g.first << "/" << g.second << endl;
        if (g.second >= 74) a75++;
        if (g.second >= 24) a25++;
        if (g.second >= 14) a15++;
        if (g.second >= 4) a5++;
        if (g.second >= 2) a3++;
    }
    cout << a75 + a25 * (a3 - 1) + a15 * (a5 - 1) + a5 * (a5 - 1) / 2 * (a3 - 2) << endl;
}
// 75 = 3 * 5 * 5


Measured memory_bytes: 256
#include<stdio.h>
 int main(){
   int a[100],N,i,j,k,key;
   scanf("%d",&N);
    for(i=1;i<N+1;i++){
     scanf("%d",&a[i]);
   }
   for(j=1;j<N+1;j++){
     key=a[j];
     i=j-1;
     while( i>0 && a[i]>key){
       a[i+1]=a[i];
       i--;
       a[i+1]=key;
     }
     for(k=1;k<N;k++){
	 printf("%d ",a[k]);
   }
     printf("%d",a[N]);
       printf("\n");
   }
     
     return 0;
 }


Measured memory_bytes: 2760
import sys
input = sys.stdin.readline

N, M = map(int, input().split())
S = [list(map(int, input().split()))[1:] for _ in range(M)]
p = list(map(int, input().split()))
ans = 0
for bit in range(1 << N):
    for i in range(M):
        cnt = 0
        for s in S[i]:
            if bit >> (s-1) & 1:
                cnt += 1
        if cnt % 2 != p[i]:
            break
    else:
        ans += 1
print(ans)



Measured memory_bytes: 40004
#include<stdio.h>
int main(){
  int parent(int);
  int left(int);
  int right(int);
  int H[250];
  int n;
  int i;
  int p;
  int l;
  int r;
  
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%d",&H[i]);
  }
  for(i=1;i<=n;i++){
    p = parent(i);
    l = left(i);
    r = right(i);
    printf("node %d: key = %d, ",i,H[i]);
    if(p > 0) printf("parent key = %d, ",H[p]);
    if(l <= n) printf("left key = %d, ",H[l]);
    if(r <= n) printf("right key = %d, ",H[r]);
    printf("\n");
  }
  return 0;
}

int parent(int i){
  return i/2;
}

int left(int i){
  return 2 * i;
}

int right(int i){
  return 2 * i + 1;
}



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

using namespace std;
int n,k;
int d[11];
int ans;
set<int> s;
void ch(int ca[11]){
	int t[11];
	for(int i = 0;i < k;i++)t[i] = ca[i];
	int kazo = 0;
	sort(t,t+k);
do{
	kazo++;
	int keta[5]={0};
	for(int i = 0;i < k-1;i++){
		keta[i+1] = keta[i];
		keta[i+1]++;
		if(t[i] >= 10)keta[i+1]++;
	}
	int co=0;
	for(int i = 0;i < k;i++){
		int p = t[i];
		while(keta[i]--)p*=10;
		co += p;
	}
	set<int>::iterator it = s.find(co);
	if(it == s.end()){
		ans++;
		s.insert(co);
	}



}while(next_permutation(t,t+k));
return;

}

void dfs(int i,int j,int o[11]){
	int h[11];
	for(int l = 0;l < k;l++) h[l] = o[l];
	if(i == k){
		ch(h);
		return;
	}
	for(int u = j;u < n;u++){
		h[i] = d[u];
		dfs(i+1,u+1,h);
	}
	return;
}



int main(){
	while(1){
	ans = 0;
	s.clear();
	int q[11];
	cin >> n >> k;
	if(n == 0 && k == 0)break;
	for(int i = 0;i < n;i++)cin >> d[i];
	dfs(0,0,q);
	cout << ans << endl;
	}
	return 0;
}


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

bool x5x1(long long N, long long a, long long &x5, long long &x1){
    x1 = -1;
    long long x5max;
    x5max = min(a/5, N);
    for(x5=0; x5<= x5max; x5++){
        if (N-x5 == a-x5*5) {
            x1 = N-x5;
            return true;
        }
    }
    return false;
}

void solve(long long N, long long Y){
    Y /= 1000;
    long long x10, x5, x1;
    long x10max;
    bool success=false;
    x10max = min(Y/10, N);
    for (x10 = 0; x10 <= x10max; x10++){
        success = x5x1(N-x10, Y-10*x10, x5, x1);
        if (success) {
            cout << x10 << ' ' << x5 << ' ' << x1 << endl;
            return;
        }
    }
    cout << "-1 -1 -1" << endl;
}

// Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long Y;
    scanf("%lld",&Y);
    solve(N, Y);
    return 0;
}


Measured memory_bytes: 256
input_data=input().split()
sx=int(input_data[0])
sy=int(input_data[1])
tx=int(input_data[2])
ty=int(input_data[3])

dy = ty - sy
dx = tx - sx

ans=""


ans += 'R' * dx + 'U' * dy + 'L' * dx + 'D' * dy
ans += 'D' + 'R' * (dx + 1) + 'U' * (dy + 1) + 'L'
ans += 'U' + 'L' * (dx + 1) + 'D' * (dy + 1) + 'R'
print(ans)

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

using namespace std;
using llong = long long;
using ldbl = long double;
using lpair = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()

template<typename T>
constexpr T inf = static_cast<T>(pow(10, static_cast<int>(log10(numeric_limits<T>::max())))) + 7;
constexpr llong mod = 1e9+7;

int main() {
  ldbl R;
  cin >> R;

  ldbl pi = 3.1415926535897932384626433l;
  cout << fixed << setprecision(32) << R*2*pi << endl;

  return 0;
}

Measured memory_bytes: 3796
import numpy as np


def solve(string):
    n, m, c, *ba = map(int, string.split())
    b = np.asarray(ba[:m])
    a = np.asarray(ba[m:])
    a.resize((n, m))
    return str(np.sum(np.dot(a,b.T) > -c))


if __name__ == '__main__':
    n, m, o = map(int, input().split())
    print(solve('{} {} {}\n'.format(n, m, o) + '\n'.join([input() for _ in range(n + 1)])))


Measured memory_bytes: 12440
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n) for(int i=1;i<=n;i++)
const ll MOD = 1000000007;
long long modinv(long long a, long long m=MOD) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
    /*MODの割り算の際に
    a/＝b;
    を
    a *= modinv(b,MOD);
    とする。
        */
}
int main(){
    string S,T;cin >> S >> T;
    int len = S.length();
    int count = 0;
    rep(i,len) {
        if(S[i]!=T[i])count++;
    }

    cout << count << endl;
    return 0;
}

Measured memory_bytes: 3832
#include <stdio.h>
 
int main(void) {
    int i;
    char s[1000];
    scanf("%s",s);
    for(i=0;;i++){
        if(s[i]==0){
            break ;
        }
    }
    if(s[i-1]=='s'){
        printf("%ses",s);
    }else{
        printf("%ss",s);
    }
    return 0;
}
 

Measured memory_bytes: 1732
# coding: utf-8
# Your code here!
import math
N=int(input())
ans=float('inf')
for i in range(1,math.ceil(N/2)+1):
    a_=str(i)
    b_=str(N-i)
    a=[int(j) for j in a_]
    b=[int(j) for j in b_]
    a=sum(a)
    b=sum(b)
    ans=min(ans,a+b)
print(ans)

Measured memory_bytes: 43496
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
using namespace std;
using ll = long long;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 3000000000000000000
#define rep(i,n) for(long long i = 0;i < n;++i)    
#define seg_size 524288

int main(){
    int n;
    cin>>n;
    vector<int>a(n);
    rep(i,n)cin>>a[i];
    int s=1;
    int cnt=0,ans=0;
    rep(i,n){
        if(a[i]==s){
            ans+=cnt;
            cnt=0;
            s++;
        }
        else cnt++;
    }
    ans+=cnt;
    if(s==1){
        cout<<-1<<endl;
        return 0;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
//#define int long long
#define forinc(i,a,b) for(int i=a;i<=b;++i)
#define fordec(i,a,b) for(int i=a;i>=b;--i)
#define fi first
#define se second
#define pii pair<int,int>

const int maxn=25010;
int n;
int d[505][505],vis[505][505],ret;
int dk[4]={-1,0,1,0};
int ck[4]={0,1,0,-1};

void bfs(int u,int v){
    int tmp=d[u][v]+vis[u][v];
    forinc(t,0,3){
        int x=u+dk[t],y=v+ck[t];
        if(d[x][y]>tmp){
            d[x][y]=tmp;
            bfs(x,y);
        }
    }
}

main(){
  //  freopen("test.inp","r",stdin);
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    cin>>n;
    forinc(i,1,n) forinc(j,1,n){
        d[i][j]=min(min(i,n-i+1),min(j,n-j+1))-1;
        vis[i][j]=1;
    }
    forinc(i,1,n*n){
        int x;
        cin>>x;
        int u=(x+n-1)/n;
        int v=x%n;
        if(v==0) v=n;
        vis[u][v]=0;
        ret+=d[u][v];
        bfs(u,v);
    }
    cout<<ret;
}



Measured memory_bytes: 20768