akhauriyash/Code-Regression huggingface dataset:
fn solve(rs: Vec<(i64, i64, i64)>) -> String {
    for i in 0..rs.len() - 1 {
        let (t1, x1, y1) = rs[i];
        let (t2, x2, y2) = rs[i + 1];
        let t = t2 - t1;
        let dist = (x2 - x1).abs() + (y2 - y1).abs();

        if t % 2 != dist % 2 || t < dist {
            return "No".to_string();
        }
    }
    "Yes".to_string()
}

fn main() {
    let n = read_1();
    let mut rs = vec!((0, 0, 0));
    rs.append(&mut read_tup3_n(n));

    println!("{}", solve(rs));
}

fn read_1<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_tup3_n<T: std::str::FromStr + Copy>(n: usize) -> Vec<(T, T, T)> {
    let mut ss = String::new();
    for _ in 0..n {
        std::io::stdin().read_line(&mut ss).ok();
    }
    let mut v = ss.split("\n").collect::<Vec<&str>>();
    v.pop();
    v.iter()
        .map(
            |s| {
                let v = s.trim().split_whitespace()
                    .map(|c| c.parse().ok().unwrap())
                    .collect::<Vec<T>>();
                (v[0], v[1], v[2])
            }
        )
        .collect()
}


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

using namespace std;

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

    int n;

    cin >> n;
    vector<vector<int>> a(2, vector<int>(n));
    for (int i = 0; i < 2; ++i)
        for (int j = 0; j < n; ++j) cin >> a[i][j];
    for (int i = 1; i < n; ++i) {
        a[0][i] += a[0][i - 1];
        a[1][n - i - 1] += a[1][n - i];
    }

    int ans = 0;
    for (int i = 0; i < n; ++i)
        ans = max(ans, a[0][i] + a[1][i]);
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<fstream>
#include<vector>
#include<cmath>//ceil
#include <algorithm> //sort,min_element,next_permutation,__gcd
using namespace std;

int distans_time(int r,int l,int k){
  int ans=0;
  int dis=abs(r-l);
  dis -= k;
  ans++;
  k--;
  while(dis>0){
    ans++;
    dis-=k;
  }
  return ans;
}


int main(){
  //ifstream in("input.txt");
  //cin.rdbuf(in.rdbuf());

  double N,K;
  cin>>N>>K;

  vector<int> A(N);
  for(int i=0;i<N;i++) cin>>A.at(i);

  double ans=0;
  N -= K;
  ans++;
  K--;
  ans+=ceil(N/K);
  cout<<ans<<endl;

}

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

typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vpi;

const int MX = 2e5 + 5;
const int INF = 1e9;
const int MOD = 1e9 + 7;

#define F0R(i, n) for (int i = 0; i < n; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define re(x) cin >> x
#define ps(x) cout << x << "\n";
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) begin(x), end(x)
#define sz(x) (int)x.size()
#define len(x) (int)x.length()
#define rall(x) (x).rbegin(), (x).rend() 
#define rsz resize
#define ins insert 

void setIn(string s) { freopen(s.c_str(),"r",stdin); }
void setOut(string s) { freopen(s.c_str(),"w",stdout); }
void setIO(string s = "") {	
		ios_base::sync_with_stdio(0); cin.tie(0); // fast I/O
		// cin.exceptions(cin.failbit); 
		// throws exception when do smth illegal
		// ex. try to read letter into int
		if (sz(s)) { setIn(s+".in"), setOut(s+".out"); } // for USACO
}

ll N;
map<ll, ll> cnt;

int main() {
	cin >> N;

	while (N % 2 == 0) {
		cnt[2]++;
		N /= 2;
	}

	for (int i = 3; i <= sqrt(N); i += 2) {
		while (N % i == 0) {
			cnt[i]++;
			N /= i;
		}
	}
	if (N > 2) cnt[N]++;

	int ans = 0;
	FOR(i, 1, 45) {
		for (auto &x: cnt) {
			if (x.s >= i) {
				//cout << x.f << " " << x.s << " " << i << "\n" ; 
				ans++;
				x.s -= i;
			}
		}
	}
	ps(ans);
}	







Measured memory_bytes: 3640
N = 26
D = gets.to_i
C = Array.new(N + 1, 0)
S = Array.new(D + 1){ Array.new(N + 1, 0) }

gets.split.map(&:to_i).each_with_index do |c, i|
  C[i + 1] = c
end

D.times do |i|
  gets.split.map(&:to_i).each_with_index do |s, j|
    S[i + 1][j + 1] = s
  end
end

def score(ans)
  last = Array.new(N + 1, 0)
  s = 0
  scores = Array.new(D + 1, 0)
  (1 .. D).each do |d|
    c = ans[d]
    last[c] = d
    s += S[d][c]
    (1 .. N).each do |c_|
      s += C[c_] * (last[c_] - d)
    end
    scores[d] = s
  end
  scores
end


A = Array.new(D + 1, 0)
(1 .. D).each do |d|
  A[d] = gets.to_i
end


puts score(A)[1,D]


Measured memory_bytes: 14328
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:https://arc060.contest.atcoder.jp/tasks/arc060_c>
 問題文============================================================
 N 軒のホテルが一直線上に並んでいます。i (1≤i≤N) 番目のホテルは、座標 xi に位置しています。
 
 旅行者である高橋君には、次の 2 つの信念があります。
 
 高橋君の 1 日の移動距離は L を超えない。
 高橋君は野宿をしない。すなわち、1 日の終わりには必ずいずれかのホテルにいなければならない。
 
 Q 個のクエリが与えられます。j (1≤j≤Q) 番目のクエリとして、異なる 2 つの整数 aj, bj が与えられます。
 各クエリについて、前述の信念をともに守った上で、
 高橋君が aj 番目のホテルから bj 番目のホテルに移動するために必要な最小日数を求めてください。
 なお、高橋君が aj 番目のホテルから bj 番目のホテルに移動できることは保証されます。
 =================================================================
 解説=============================================================
 ================================================================
 */

void solve(){
    ll N; cin >> N;
    vector<ll> x(N); for(auto& in:x) cin >> in;
    ll L; cin >> L;
    ll Q; cin >> Q;
    vector<ll> a(Q),b(Q);
    for(int i = 0; i < Q;i++){
        cin >> a[i] >> b[i];
        a[i]--; b[i]--;
        if(a[i] > b[i]) swap(a[i],b[i]);
    }
    
    ll LOG_N = floor(log2(N));
    vector<vector<ll>> next(LOG_N+1,vector<ll>(N));
    for(int i = 0; i < N;i++){
        next[0][i] = upper_bound(x.begin(), x.end(), x[i]+L) - x.begin() - 1;
    }
    for(int k = 0; k < LOG_N; k++){
        for(int i = 0; i < N;i++){
            next[k+1][i] = next[k][next[k][i]];
        }
    }
    for(int i = 0; i < Q;i++){
        ll _a = a[i], _b = b[i];
        
        ll l = 0, r = N;
        while(r-l>1){
            ll m = (l+r)/2;
            
            // a番目の要素のm個次の要素を求める
            ll p = _a;
            for(ll k = LOG_N; k>=0; k--){
                if(p == LINF){
                    break;
                }
                if((m>>k)&1){
                    p = next[k][p];
                }
            }
            
            
            if(p >= _b){
                r = m;
            }else{
                l = m;
            }
        }
        cout << r << endl;
    }
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    solve();
    return 0;
}


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

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

int MOD=1e9+7;
ll INF=1e18;

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

int main(){
    int n, k, s;
    while(cin>>n>>k>>s, n){
        int dp[25][15][400];
        memset(dp, 0, sizeof(dp));

        dp[1][0][0]=1;
        for(int i=1; i<=n; i++){
            for(int j=0; j<=k; j++){
                for(int l=0; l<=s; l++){
                    if(l+i<=s && j+1<=k) dp[i+1][j+1][l+i]+=dp[i][j][l];
                    dp[i+1][j][l]+=dp[i][j][l];
                }
            }
        }
        cout << dp[n+1][k][s] << endl;
    }
}


Measured memory_bytes: 3704
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt"
int main() {
	while (1) {
		int N, M, Q; cin >> N >> M >> Q;
		if (!N)break;
		vector<set<int>>kouhos(M);
		for (int i = 0; i < M; ++i) {
			for (int j = 0; j < N; ++j) {
				kouhos[i].emplace(j);
			}
		}
		string pre;
		for (int i = 0; i < M; ++i) {
			pre.push_back('0');
		}
		for (int i = 0; i < Q; ++i) {
			string s, b; cin >> s >> b;
			vector<int>pushed(N);
			for (int j = 0; j < N; ++j) {
				pushed[j] = s[j] == '1';
			}

			for (int j = 0; j < M; ++j) {
				if (pre[j] == b[j]) {
					for (int k = 0; k < N; ++k) {
						if (pushed[k]) {
							kouhos[j].erase(k);
						}
					}
				}
				else {
					for (int k = 0; k < N; ++k) {
						if (!pushed[k]) {
							kouhos[j].erase(k);
						}
					}
				}
			}
			pre = b;
		}
		for (int i = 0; i < M; ++i) {
			if (kouhos[i].size() == 1) {
				int ans = *kouhos[i].begin();
				char out = ans < 10 ? ans + '0' : ans + 'A' - 10;
				cout << out;
			}
			else {
				cout << "?";
			}
		}
		cout << endl;
	}
	
	return 0;
}

Measured memory_bytes: 4872
#include<cstdio>
#include<cstring>
#define MN 100005
int cnt1[MN],cnt2[MN]; 
char s1[MN],s2[MN];int q;
inline void pre(){
	memset(cnt1,0,sizeof(0));memset(cnt2,0,sizeof(0));
	for(int i=1;s1[i];i++) cnt1[i]=cnt1[i-1]+s1[i]-'A'+1;
	for(int i=1;s2[i];i++) cnt2[i]=cnt2[i-1]+s2[i]-'A'+1;
}
int main(){
	scanf("%s%s%d",s1+1,s2+1,&q);pre();
	for(int w=1;w<=q;w++){
		int a,b,c,d;scanf("%d%d%d%d",&a,&b,&c,&d);
		if((cnt1[b]-cnt1[a-1])%3==(cnt2[d]-cnt2[c-1])%3) printf("YES\n");
		else printf("NO\n");
	}
} 

Measured memory_bytes: 1408
import java.util.Scanner;
import java.util.Stack;

public class Main {
   public static Scanner sc=new Scanner(System.in);
  
       public static void main(String[] args) {
           String s;
           s=sc.nextLine();
           String a[]=s.split(" ");
           Stack<Integer> st=new Stack<>();
           for(int i=0;i<a.length;i++) {
               boolean numeric = true;
                try {
                    int num = Integer.parseInt(a[i]);
                } catch (NumberFormatException e) {
                    numeric = false;
                }
               if(numeric) {
                   st.push(Integer.parseInt(a[i]));
               }else {
                   int val1=st.pop();
                   int val2=st.pop();
                   switch(a[i]) {
                   case "+":
                       st.push(val2+val1);
                       break;
                   case "-":
                       st.push(val2-val1);
                       break;
                   case "*":
                       st.push(val2*val1);
                       break;
                   case "/":
                       st.push(val2/val1);
                       break;
                   }
               }
           }
          
           System.out.println(st.pop());
          
       }
}


Measured memory_bytes: 26280
N,M = map(int,input().split())
L = []
R = []
for _ in range(M):
    l,r = map(int,input().split())
    L.append(l)
    R.append(r)
L = sorted(L)
R = sorted(R)
Lmax = L[-1]
Rmin = R[0]
if Rmin<Lmax:
    print(0)
else:
    print(Rmin-Lmax+1)

Measured memory_bytes: 12192
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rep1(i, n) FOR(i, 1, n+1)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define rwhole(x) (x).rbegin(), (x).rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define P pair<int, int>
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


int main(){
    char c;
    cin >> c;
    string s = "aiueo";
    for (char x: s) {
        if (c==x) {
            cout << "vowel" << endl;
            return 0;
        }
    }
    string ans = "consonant";
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3600
import java.util.*;
import java.io.*;
public class Main {
    static class Scan {
        private byte[] buf=new byte[1024];
        private int index;
        private InputStream in;
        private int total;
        public Scan()
        {
            in=System.in;
        }
        public int scan()throws IOException
        {
            if(total<0)
            throw new InputMismatchException();
            if(index>=total)
            {
                index=0;
                total=in.read(buf);
                if(total<=0)
                return -1;
            }
            return buf[index++];
        }
        public int scanInt()throws IOException
        {
            int integer=0;
            int n=scan();
            while(isWhiteSpace(n))
            n=scan();
            int neg=1;
            if(n=='-')
            {
                neg=-1;
                n=scan();
            }
            while(!isWhiteSpace(n))
            {
                if(n>='0'&&n<='9')
                {
                    integer*=10;
                    integer+=n-'0';
                    n=scan();
                }
                else throw new InputMismatchException();
            }
            return neg*integer;
        }
        public double scanDouble()throws IOException
        {
            double doub=0;
            int n=scan();
            while(isWhiteSpace(n))
            n=scan();
            int neg=1;
            if(n=='-')
            {
                neg=-1;
                n=scan();
            }
            while(!isWhiteSpace(n)&&n!='.')
            {
                if(n>='0'&&n<='9')
                {
                    doub*=10;
                    doub+=n-'0';
                    n=scan();
                }
                else throw new InputMismatchException();
            }
            if(n=='.')
            {
                n=scan();
                double temp=1;
                while(!isWhiteSpace(n))
                {
                    if(n>='0'&&n<='9')
                    {
                        temp/=10;
                        doub+=(n-'0')*temp;
                        n=scan();
                    }
                    else throw new InputMismatchException();
                }
            }
            return doub*neg;
        }
        public String scanString()throws IOException
        {
            StringBuilder sb=new StringBuilder();
            int n=scan();
            while(isWhiteSpace(n))
            n=scan();
            while(!isWhiteSpace(n))
            {
                sb.append((char)n);
                n=scan();
            }
            return sb.toString();
        }
        private boolean isWhiteSpace(int n)
        {
            if(n==' '||n=='\n'||n=='\r'||n=='\t'||n==-1)
            return true;
            return false;
        }
    }
    public static void main(String args[]) throws IOException {
        Scan input=new Scan();
        int indx=-1;
        for(int i=1;i<=5;i++) {
            int tmp=input.scanInt();
            if(tmp==0) {
                indx=i;
            }
        }
        System.out.println(indx);
    }
}


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

int n, m;
vector <int> adjList[200005];
bool visited[200005];
queue <int> bfs;
int ans = 1;

int main() {
	scanf("%d%d", &n, &m);
	for (int i = 0; i < m; i++) {
		int a, b; scanf("%d%d", &a, &b);
		adjList[a].push_back(b);
		adjList[b].push_back(a);
	}
	for (int i = 1; i <= n; i++) {
		if (visited[i]) continue;
		int cnt = 1;
		visited[i] = true;
		bfs.push(i);
		while (!bfs.empty()) {
			int u = bfs.front(); bfs.pop();
			for (int v : adjList[u]) {
				if (visited[v]) continue;
				visited[v] = true;
				cnt++;
				bfs.push(v);
			}
		}
		ans = max(ans, cnt);
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 15348
#include <bits/stdc++.h>
using namespace std;
int main() {
  string o,e;
  cin >> o >> e;
  for(int i = 0;i < o.size() + e.size();i++) {
    if(i % 2 == 0) {
      cout << o.at(i / 2);
    }else {
      cout << e.at(i / 2);
    }
  }
  cout << endl;
}

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

using ll=long long;

int main(){
  int n; cin >> n;
  int ans = 0;
  rep(i,n){
    int A;
    cin >> A;
    while(!(A%2)){
        A /= 2;
        ans++;
    }
  }
  cout << ans << endl;
      
}

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

int main() {
  long long A, B, C, K;
  long long counter = 0;
  cin >> A >> B >> C >> K;
  if (A >= K) {
    cout << K << endl;
  } else {
    counter += A;
    K = K - A;
    if (B >= K) {
      cout << counter << endl;
    } else {
      K = K - B;
      if (C >= K) {
        counter -= K;
        cout << counter << endl;
      } else {
        counter = counter - 1 * K;
        cout << counter << endl;
      }
    }
  }
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
    ll n;
    scanf("%lld",&n);
    ll m = n,k=0;
    while(m)
    {
        m/=10;
        k++;
    }
    //cout<<k<<endl;
    int t;
    int flag = 0;
    for(int i=2;i<=sqrt(n);i++)
    {
        if(n%i == 0){
            t = n/i;
            flag = 1;
        }
    }
    if(flag){
        int t2 = n/t;
        int cnt1= 0,cnt2=  0;
        //cout<<t<<" "<<t2<<endl;
        while(t){
            t/=10;
            cnt1++;
        }
        while(t2){
            t2/=10;
            cnt2++;
        }
        printf("%d\n",max(cnt1,cnt2));
    }else{
        cout<<k<<endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <cstring>
#include <queue>
#define myfor(i,N) for(i=0;i<N;i++)
#define myforFL(i,f,l) for(i=f;i<l;i++)
#define myforInv(i,N) for(i=N;i>=0;i--)
#define myforFLInv(i,f,l) for(i=f;i>l;i--)
#define INF pow(10,9)
using namespace std;


typedef struct Node{
	vector<int> edges_to;
}Node_t;

vector<Node_t> node(100000);
vector<bool>done(100000,false);
vector<int>michishirube(100000,INF);


int main(){
	int i,j,ind,pre_ind;
	int N,M;
	cin >> N >> M;
	vector <int> A(M),B(M);
	myfor(i,M){
		cin >> A[i] >> B[i];
		node[A[i]-1].edges_to.push_back(B[i]-1);
		node[B[i]-1].edges_to.push_back(A[i]-1);
	}
	queue<pair<int,int> >q;
	q.push(pair<int,int>(0,0));
	while(!q.empty()){
		ind = q.front().first;
		pre_ind = q.front().second;
		q.pop();
		if(done[ind])continue;
		done[ind] = true;
		michishirube[ind] = pre_ind;
		myfor(i,node[ind].edges_to.size())q.push(pair<int,int>(node[ind].edges_to[i],ind));
	}
	myfor(i,N)if(done[i] == false){
		cout << "No" << endl;
		return 0;
	}
	cout << "Yes" << endl;
	myforFL(i,1,N){
		cout << michishirube[i]+1 << endl;
	}


	return 0;
}

Measured memory_bytes: 13204
#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

vector<int> toposort(vector<vector<int>> &g, vector<int> &h) {
    int n = g.size();
    stack<int> st;
    for(int i = 0; i < n; i++) {
        if(h[i] == 0) {
            st.push(i);
        }
    }
    vector<int> toposorted;
    while(st.size()) {
        int u = st.top();
        st.pop();
        toposorted.emplace_back(u);
        for(auto v : g[u]) {
            h[v]--;
            if(h[v] == 0) {
                st.push(v);
            }
        }
    }
    return toposorted;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    vector<int> a(n - 1 + m), b(n - 1 + m);
    vector<vector<int>> g(n);
    // 入次数
    vector<int> h(n, 0);
    for(int i = 0; i < n - 1 + m; i++) {
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
        g[a[i]].emplace_back(b[i]);
        h[b[i]]++;
    }
    auto sorted = toposort(g, h);
    // 振り直した頂点番号
    vector<int> rev(n);
    for(int i = 0; i < n; i++) {
        rev[sorted[i]] = i;
    }

    vector<int> ans(n, sorted[0]);
    ans[sorted[0]] = -1;
    for(int i = 0; i < n - 1 + m; i++) {
        if(ans[b[i]] == -1) {
            continue;
        }
        if(rev[ans[b[i]]] < rev[a[i]]) {
            ans[b[i]] = a[i];
        }
    }
    for(int i = 0; i < n; i++) {
        cout << ans[i] + 1 << ' ';
    }
    cout << endl;
}


Measured memory_bytes: 8824
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
/////////

typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;

////定数
const int INF = (int)1e9 + 10;
const LL MOD = (LL)1e9 + 7;
const LL LINF = (LL)4e18 + 20;
const LD PI = acos(-1.0);
const double EPS = 1e-9; 
/////////
using namespace::std;
template<typename T>
void chmax(T& a, T b) {
	a = max(a, b);
}

template<typename T>
void chmin(T& a, T b) {
	a = min(a, b);
}

template<typename T>
void IN(vector<T> &A,int N=-1) {
	if (N == -1) {
		N = A.size();
	}
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
	}
}

template<typename T>
void SO(vector<T> &A,bool F=false) {
	sort(A.begin(), A.end());
	if (F) {
		reverse(A.begin(), A.end());
	}
}
//////////////

void solve() {
	int HP1, A1, HP2, A2;
	cin >> HP1 >> A1 >> HP2 >> A2;
	bool t = false;
	while (true) {
		if (t == false) {
			HP2 -= A1;
			if (HP2 <= 0) {
				cout << "Yes" << endl;
				return;
			}
		}
		else {
			HP1 -= A2;
			if (HP1 <= 0) {
				cout << "No" << endl;
				return;
			}
		}
		t ^= 1;
	}
}

signed main(void) {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}

Measured memory_bytes: 3648
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<queue>
#define LL long long
#define inl inline
#define re register
#define MAXN 200100
using namespace std;
int n;
int p[MAXN];
int t[MAXN];
int f[MAXN];
int ans;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&p[i]),t[p[i]]=i;
	for(int i=1;i<=n;i++)
	{
		if(t[p[i]-1]<t[p[i]])f[p[i]]=f[p[i]-1]+1;
		else f[p[i]]=1;
	}
	for(int i=1;i<=n;i++)ans=max(ans,f[i]);
	cout<<n-ans;
	return 0;
}



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

#define INF (1 << 29)
#define MAX_N 100000
#define MAX_V 100000

int v[MAX_N];

int cnt[2][MAX_V + 1];

int main()
{
	int n;

	cin >> n;
	for( int i = 0; i < n; i++ ) {
		cin >> v[i];
	}

	for( int i = 0; i < n; i++ ) {
		if( i % 2 ) {
			cnt[1][v[i]]++;
		}
		else {
			cnt[0][v[i]]++;
		}
	}
	int ma0 = 0, ma0last = 0, ma1 = 0, ma1last = 0;
	int mai0, mai1;
	for( int i = 0; i < MAX_V + 1; i++ ) {
		if( cnt[0][i] > ma0 ) {
			mai0 = i;
			ma0last = ma0;
			ma0 = cnt[0][i];
		}
		else if( cnt[0][i] > ma0last ) {
			ma0last = cnt[0][i];
		}
		if( cnt[1][i] > ma1 ) {
			 mai1 = i;
			ma1last = ma1;
			ma1 = cnt[1][i];
		}
		else if( cnt[1][i] > ma1last ) {
			ma1last = cnt[1][i];
		}
	}
	int ans = n - ma0 - ma1;
	if( mai0 == mai1 ) {
		if( ma0 + ma1last < ma1 + ma0last ) {
			ans = n - ma1 - ma0last;
		}
		else {
			ans = n - ma0 - ma1last;
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <climits>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <string>
#include<vector>
#include <set>
#define rep(i,n) for(i=0;i<n;i++)
#define P pair<int,int>
using namespace std;



int main()
{
	int a, b, c, d, e, f, i, j, n, m, s, t ;		
	int dist[300000] = {};
	rep(i, 300000)dist[i]--;

	cin >> n >> m;
	vector<vector<int>> v(3*n);
	rep(i, m) {
		cin >> a >> b;
		a--; b--;
		v[a].push_back(b+n);
		v[a+n].push_back(b + n*2);
		v[a+2*n].push_back(b);
	}
	cin >> s >> t;
	s--; t--;
	queue<P > q;
	q.push(P(s, 0));
	dist[s]=0;

	while (q.size()) {
		int now = q.front().first;
		int step = q.front().second;
		q.pop();

		rep(i, v[now].size()) {
			int next = v[now][i];
			if (dist[next] != -1)continue;
			q.push(P(next, step + 1));
			dist[next] = dist[now] + 1;
		}
	}

	e = dist[t];
	if (e != -1)e = e / 3;
	cout << e;




	return 0;
}

Measured memory_bytes: 17792
N = int(input())
X_list = [int(e) for e in input().split()]

ans = 10**100

for P in range(min(X_list),max(X_list)+1):
    temp_ans = 0
    
    for X in X_list:
        temp_ans += (X - P)**2
        
    if temp_ans < ans:
        ans = temp_ans
        
print(ans)

Measured memory_bytes: 3060
N,M = map(int,input().split())
A = [list(input()) for _ in range(N)]
B = [list(input()) for _ in range(M)]
ans = False

for ly in range(N):
    for lx in range(N):
        if N - M + 1 <= lx:
            continue
        if N - M + 1 <= ly:
            continue
        flag = True
        for y in range(M):
            for x in range(M):
                if B[y][x] != A[ly+y][lx+x]:
                    flag = False
        if flag:
            ans = True

print('Yes' if ans else 'No')

Measured memory_bytes: 9152
// https://atcoder.jp/contests/abc051/tasks/abc051_d
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int mod = 1000 * 1000 * 1000 + 7;
const int INF = 1000 * 1000 * 1000;
const ll LINF = (ll)INF * INF;

#define dbg(x) cerr << #x << " = " << (x) << endl;
#define dbg2(x, y) cerr << '{' << #x << ", " << #y << "} = {" << (x) << ", " << (y) << '}' << endl;
#define dbgp(x) cerr << #x << " = {" << (x).first << ", " << (x).second << '}' << endl;
#define dbgr(s, f) {cerr << #s << ": "; for (auto _ = (s); _ != (f); _++) { cerr << *_ << ' '; }; cerr << endl;}
#define dbgv(x) {cerr << #x << ": "; for (auto _ = (x).begin(); _ != (x).end(); _++) { cerr << *_ << ' '; }; cerr << endl;}
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define fast_io ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define fr first
#define sc second

#define MAXN 150
#define MAXM 1050

int n;
vector<int> adj[MAXN];
int eto[MAXM], efrom[MAXM], ew[MAXM];
set<pii> s;
int dist[MAXN];

void dij(int r)
{
	fill(dist, dist + n + 10, INF);
	dist[r] = 0;
	FOR(i, 1, n + 1)
	{
		s.insert({dist[i], i});
	}
	while (!s.empty())
	{
		int v = s.begin() -> second;
		s.erase(s.begin());
		for (int e : adj[v])
		{
			int u = eto[e] ^ efrom[e] ^ v;
			auto it = s.find({dist[u], u});
			if (it == s.end())
				continue;
			int nd = dist[v] + ew[e];
			if (nd < dist[u])
			{
				s.erase(it);
				dist[u] = nd;
				s.insert({dist[u], u});
			}
		}
	}
}

int main(void)
{
	int m;
	cin >> n >> m;
	FOR(i, 0, m)
	{
		int ai, bi, ci;
		cin >> ai >> bi >> ci;
		adj[ai].pb(i);
		adj[bi].pb(i);
		eto[i] = bi;
		efrom[i] = ai;
		ew[i] = ci;
	}
	int ans = 0;
	FOR(i, 0, m)
	{
		// clearing stuff

		int w = ew[i];
		ew[i] = INF;
		dij(eto[i]);
		ew[i] = w;
		if (dist[efrom[i]] < w)
		{
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 3620
#include<iostream>

using namespace std;

int a[50001];

int main(void)
{
	a[0]=a[1]=1;
	for(int i=2;i<=50000;i++)
	{
		for(int j=i+i;j<=50000;j+=i)
		{
			a[j]=1;
		}
	}
	while(1)
	{
		int n;
		cin>>n;
		if(n==0)break;
		int ans=0;
		for(int i=2;i<=n/2;i++)
		{
			if(a[i]==0&&a[n-i]==0)
				ans++;
		}
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 1356
n = int(input())

ls = list(map(int, input().split()))

b = [0,0,0,0]

for x in ls:
    if x % 4 == 0:
        b[3] += 1
    elif x % 2 == 0:
        b[1] += 1
    else:
        b[0] += 1

if b[1] == 0:
    if b[0] <= b[3]+1:
        print('Yes')
    else:
        print('No')
else:
    if b[0] <= b[3]:
        print('Yes')
    else:
        print('No')


Measured memory_bytes: 14252
import numpy as np
n, m = map(int, input().split())

lmax, rmin = 1, n
for i in range(m):
    l, r = list(map(int, input().split()))
    if l > lmax :
        lmax = l
    if r < rmin:
        rmin = r
    if lmax > rmin:
        print(0)
        break
else :
    print(rmin-lmax+1)

Measured memory_bytes: 12504
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <queue>
#include <set>
#include <tuple>
#include <iomanip>
using namespace std;
typedef long long ll;

int main() {
    ll n, m, a[100010];
    cin >> n >> m;
    for (int i = 0; i < n; i++) cin >> a[i];
    sort(a, a + n, greater<int>());

    ll ok = 1e6, ng = 0;
    while (ok - ng > 1) {
        ll mid = (ok + ng) / 2;
        ll can = 0;
        for (int i = 0; i < n; i++) {
            int l = -1, r = n;
            while (r - l > 1) {
                int mm = (l + r) / 2;
                if (a[i] + a[mm] >= mid) l = mm;
                else r = mm;
            }
            can += l + 1;
        }
        if (can <= m) ok = mid;
        else ng = mid;
    }

    cerr << ok << " " << ng << endl;
    
    ll ans = 0, s[100010], data = 0;
    s[0] = 0;
    for (int i = 0; i < n; i++) s[i + 1] = s[i] + a[i];
    
    for (int i = 0; i < n; i++) {
        int l = -1, r = n;
        while (r - l > 1) {
            int mm = (l + r) / 2;
            if (a[i] + a[mm] < ok) r = mm;
            else l = mm;
        }
        cerr << l << " " << r << endl;
        ans += (l + 1) * a[i] + s[l + 1];
        data += l + 1;
        cerr << ans << endl;
    }

    cout << ans + (m - data) * ng << endl;



}

Measured memory_bytes: 1920
def gcd(a,b):
	x,y = max(a,b), min(a,b)
	while x % y > 0:
		tmp = x % y
		x = y
		y = tmp
	return y

A,B = map(int,input().split())
G = gcd(A,B)
prime = [i % 2 == 1 for i in range(10**6 + 1)]
prime[1] = False
prime[2] = True
p = 3
while p <= 10**6:
	if prime[p]:
		for i in range(2*p, 10**6+1, p):
			prime[i] = False
	p += 2
P = [i for i in range(10**6+1) if prime[i]]

ans = 1
for p in P:
	if G % p != 0:
		continue
	ans += 1
	while G % p == 0:
		G = G // p
	if G == 1:
		break
if G > 1:
	ans += 1
print(ans)

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

int N, X, a[100006], ans;

int abs(int x) {
	return x >= 0? x: -x;
}

int gcd(int a, int b) {
	return a == 0? b: gcd(b % a, a);
}

int main(){
	scanf("%d %d", &N, &X);
	for (int i = 0; i < N; i++) {
		scanf("%d", &a[i]);
		a[i] = abs(a[i] - X);
	}
	for (int i = 0; i < N; i++) {
		ans = gcd(ans, a[i]);
	}
	printf("%d\n", ans);
	return 0;
}

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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++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 irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

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

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

ll n,m;
vector<tuple<ll,ll,ll>> es;
const ll MAXN=1005;

vll G[MAXN];
bool visited[MAXN];
void dfs(ll v){
  if(visited[v]) return;
  visited[v]=true;
  for(auto nv: G[v]){
    dfs(nv);
  }
}

vll rG[MAXN];
bool rvisited[MAXN];
void rdfs(ll v){
  if(rvisited[v]) return;
  rvisited[v]=true;
  for(auto nv: rG[v]){
    rdfs(nv);
  }
}

bool ok[MAXN];

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n,m; cin>>n>>m;
  rep(i,m){
    ll a,b,c; cin>>a>>b>>c;
    a--,b--;
    es.emplace_back(a,b,-c);
    G[a].push_back(b);
    rG[b].push_back(a);
  }
  dfs(0);
  rdfs(n-1);
  rep(i,n) ok[i]=visited[i]&&rvisited[i];
  
  bool update=true;
  
  vll dist(n,LINF);
  dist[0]=0;
  ll cnt=0;
  while(update){
    update=false;
    rep(i,m){
      ll a,b,c;
      tie(a,b,c)=es[i];
      if(!ok[a] || !ok[b]) continue;
      if(dist[b]>dist[a]+c){
        update=true;
        dist[b]=dist[a]+c;
      }
    }
    if(cnt>=n){
      puts("inf");
      return 0;
    }
    cnt++;
  }
  cout<<-dist[n-1]<<endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <climits>
#include <map>
#include <queue>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)

int main() {
    int n;
    cin >> n;
    while (n > 0) {
        if (n % 10 == 7) {
            cout << "Yes\n";
            return 0;
        }
        n /= 10;
    }
    cout << "No\n";
    return 0;
}


Measured memory_bytes: 3600
// " --- IN THE NAME OF ALLAH --- " // ;)
// ------------sphr_agz------------ // ;)

//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp> 
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <math.h>
#include <cmath>
#include <list>
#include <stack>
#include <bitset>
#include <ctime>
using namespace std;
 
typedef long double ld;
typedef long long int lli;
typedef pair <lli, pair <lli, lli> > pii;
#define pb(x) push_back(x)
#define recout(x) return cout << (x), 0
#define f first
#define s second
#define fast ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define stp(x) cout << setprecision(x) << fixed
#define mk make_pair
const lli N = 1e6 + 10, N2 = 5e3 + 10, delta = 46639, mod = 1e9 + 7, oo = 1e16, LOG = 20;
const ld PI = 3.141592653589793;

int main(){
	stp(6);
	ld n;
	cin >> n;
	n /= 3;
	cout << n * n * n;
}


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

#define f first
#define s second

#define pb push_back
#define pp pop_back
#define mp make_pair

#define sz(x) (int)x.size()
#define sqr(x) ((x) * 1ll * (x))
#define all(x) x.begin(), x.end()
#define clr(a,v) memset(a, v, sizeof(a))

#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, l, r) for (int i = (l); i >= (r); i--)
#define reflex ios_base::sync_with_stdio(false)

#define nl '\n'
#define ioi exit(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int N= (int)2e5 + 7;
const int inf = (int)1e9 + 7;
const int mod = (int)1e9 + 7;
const ll linf = (ll)1e18 + 7;

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

string conv(int a){
	stringstream ss;
	ss << a;
	string str = ss.str();
	return str;
}


string conv(char a){
	stringstream ss;
	ss << a;
	string str = ss.str();
	return str;
}

int conv(string a){
    stringstream geek(a); 
    int x = 0; 
    geek >> x;   
	return x;
}


string cad;
char s[N];

int memoA[N];
int memoB[N];

int B(int i){
	int &m = memoB[i];
	if(m != -1)
		return m;
	if(i == 0)
		return 0;
	if(s[i] == '.'){
		m = B(i-1);
		return m;
	}
	else{
		m = B(i-1) + 1;
		return m;
	}
}

int A(int i){
	int &m = memoA[i];
	if(m != -1)
		return m;
	if(i == 0)
		return inf;
	if(s[i] == '.'){
		m = min(A(i-1),B(i-1)) + 1;;
		return  m;
	}
	else{
		m = min(A(i-1),B(i-1));
		return m;
	}
}

int v[N];
int main(void) 
{	
	double a, b, t;
	cin>> a >> b >> t;
	double ac = a;
	int cont = 0;
	int i = 2;
	while(ac<= t+0.5){
		cont += b;
		ac = i*a;
		i++;
	}
	cout<< cont;
	return 0;
} 



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

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

  int n, m;
  cin >> n >> m;
  int suki[40] = {};
  for(int i = 0; i < n; i++) {
    int a;
    cin >> a;
    for(int j = 0; j < a; j++) {
      int b;
      cin >> b;
      suki[b]++;
    }
  }

  int count = 0;
  for(int i = 0; i < 40; i++) {
    if(suki[i] == n) count++;
  }
  cout << count << endl;
}


Measured memory_bytes: 384
#include <stdio.h>
#include <math.h>
int main(void){
    int N;
    scanf("%d", &N);

    int ans = 1;
    int tmp = sqrt(N);
    for (int i = 0; i <= tmp; i++){
        if (i * i <= N){
            ans = i * i;
        }
    }
    printf("%d\n", ans);

    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+10;

ll lcm(ll x,ll y){
    return x/__gcd(x,y)*y;
}

int a[N];
int main()
{
    ll n,m,x=1;
    cin>>n>>m;
    m<<=1;

    for(int i=1;i<=n;++i){
        cin>>a[i];
        x=lcm(x,a[i]);
        if(x>m){cout<<0;return 0;}
    }
    for(int i=1;i<=n;++i)
        if(!((x/a[i])&1)){
            cout<<0;return 0;
        }
    cout<<(m/x+1)/2;
    return 0;
}
/*
1 1
2
*/


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

int main()
{
    int participant, days, remain;
    cin>>participant>>days>>remain;
    vector<int> ai(participant);
    for(int i=0 ; i<participant ; ++i)
    {
        cin>>ai[i];
    }
    for(int i=0 ; i<days; ++i)
    {
        for(int j=0 ; j<participant ; ++j)
        {
            if(i%ai[j]==0)
            ++remain;
        }
    }
    cout<<remain<<endl;
	return 0;
}

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

int n;
string s;

vector<int> operator*(const vector<int> &f, const vector<int> &g) {
    vector<int> h(n * n);
    for (int i = 0; i < n * n; i++) h[i] = g[f[i]];
    return h;
}
vector<int> operator^(vector<int> f, int n_) {
    vector<int> res(n * n);
    iota(res.begin(), res.end(), 0);
    while (n_ > 0) {
        if (n_ & 1) res = res * f;
        f = f * f;
        n_ >>= 1;
    }
    return res;
}
vector<int> inv(vector<int> f) {
    vector<int> res(n * n);
    for (int i = 0; i < n * n; i++) res[f[i]] = i;
    return res;
}

vector<int> sequence(int &idx);
vector<int> repetition(int &idx);
vector<int> operation(int &idx);
int number(int &idx);

// <sequence> := <sequence><repetition> | <sequence><operation> |
//               <repetition> | <operation>
vector<int> sequence(int &idx) {
    vector<int> f(n * n);
    iota(f.begin(), f.end(), 0);
    while (idx < s.length() && s[idx] != ')') {
        if (s[idx] == '(') {
            f = f * repetition(idx);
        } else {
            f = f * operation(idx);
        }
    }
    return f;
}

// <repetition> := '('<sequence>')'<number>
vector<int> repetition(int &idx) {
    idx++;      // skip '('
    vector<int> f = sequence(idx);
    idx++;      // skip ')'
    int num = number(idx);
    return f ^ num;
}

// <operation> := <shift><number>
// <shift> := 'L' | 'R' | 'U' | 'D'
vector<int> operation(int &idx) {
    char op = s[idx++];
    int num = number(idx); num--;
    vector<int> f(n * n);
    iota(f.begin(), f.end(), 0);
    if (op == 'L') {
        int tmp = f[num * n + n - 1];
        for (int i = n - 1; i > 0; i--) f[num * n + i] = f[num * n + i - 1];
        f[num * n + 0] = tmp;
    } else if (op == 'R') {
        int tmp = f[num * n + 0];
        for (int i = 0; i < n - 1; i++) f[num * n + i] = f[num * n + i + 1];
        f[num * n + n - 1] = tmp;
    } else if (op == 'U') {
        int tmp = f[(n - 1) * n + num];
        for (int i = n - 1; i > 0; i--) f[i * n + num] = f[(i - 1) * n + num];
        f[0 * n + num] = tmp;
    } else if (op == 'D') {
        int tmp = f[0 * n + num];
        for (int i = 0; i < n - 1; i++) f[i * n + num] = f[(i + 1) * n + num];
        f[(n - 1) * n + num] = tmp;
    }
    return f;
}

// <number> := <nonzero_digit> | <number><digit>
// <digit> := '0' | <nonzero_digit>
// <nonzero_digit> := '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9'
int number(int &idx) {
    int res = 0;
    while (idx < s.length() && isdigit(s[idx])) {
        res = res * 10 + s[idx++] - '0';
    }
    return res;
}

int main() {
    int _; cin >> n >> _;
    cin >> s;
    int idx = 0;
    vector<int> res = inv(sequence(idx));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            cout << res[i * n + j] + 1 << " \n"[j == n - 1];
        }
    }
    return 0;
}


Measured memory_bytes: 16120
from collections import defaultdict
n, m = map(int, input().split())
switch = defaultdict(list)
for i in range(m):
    s = list(map(int, input().split()))[1:]
    switch[i] = s
p = list(map(int, input().split()))

output = 0
for h in range(2**n):
    flag = 1
    padding = '0{}b'.format(n)
    bit = format(h, padding)
    for i, v in enumerate(p):
        cnt = 0
        for j in switch[i]:
            if bit[j-1] == '1':
                cnt += 1
        if cnt % 2 != v:
            flag = 0
    if flag == 1:
        output += 1
print(output)


Measured memory_bytes: 3444
#include<iostream>
#include <stdio.h>
using namespace std;
int main() {
	int n;
	cin >>n;
	long int array[n];
	long int max, min, sum = 0;
	int temp;
	cin >> temp;
	max = min = array[0] = temp;
	for (int i = 1; i < n; i++) {
		cin >> array[i];
	}
	for (int i = 0; i < n; i++) {
		if (array[i] > max) max = array[i];
		if(array[i] < min) min = array[i];
		sum += array[i];
	}
	cout << min << " " << max << " " << sum << endl;
	//printf("%d %d %d\n", min, max, sum);
}

Measured memory_bytes: 1240
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <cmath>
#include <numeric>
#include <iomanip>

using namespace std;

long long x[200000];
long long y[200000];
int main(){
    int N;
    cin >> N;

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

    long long ans = 0;
    long long less_sum = 0;
    long long less_min = INT_MAX;
    for(int i = 0; i < N; i++){
      if(x[i] < y[i]){
        ans += y[i];
      }
      if(x[i] > y[i]){
        less_sum += y[i];
        less_min = min(less_min, y[i]);
      }
    }
    if(ans != 0) {
      for(int i = 0; i < N; i++){
        if(x[i] == y[i]){
          ans += x[i];
        }
      }
      ans += (less_sum - less_min);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 512
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce


sys.setrecursionlimit(2147483647)
INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007



def mat_mul(a, b) :
    I, J, K = len(a), len(b[0]), len(b)
    c = [[0] * J for _ in range(I)]
    for i in range(I) :
        for j in range(J) :
            for k in range(K) :
                c[i][j] += a[i][k] * b[k][j]
            c[i][j] %= m
    return c


def mat_pow(x, n):
    y = [[0] * len(x) for _ in range(len(x))]

    for i in range(len(x)):
        y[i][i] = 1

    while n > 0:
        if n & 1:
            y = mat_mul(x, y)
        x = mat_mul(x, x)
        n >>= 1

    return y


l, a, b, m = LI()
d0 = 0
ret = [[0], [a], [b]]
for i in range(1, 19):
    if 10 ** i - 1 - a < 0:
        continue
    d1 = min((10 ** i - 1 - a) // b + 1, l)
    mat = [[10 ** i, 1, 0], [0, 1, 1], [0, 0, 1]]
    ret = mat_mul(mat_pow(mat, d1 - d0), ret)
    if d1 == l:
        break
    d0 = d1


print(ret[0][0])


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

typedef long long int ll;
typedef long double ld;





int main()
{
	ll n,ans=0;
	cin>>n;
	vector<ll>a(n);
	map<ll,ll>m;
	for(ll i=0;i<n;i++)
        {cin>>a[i];
        m[a[i]]++;}
    for(ll i=0;i<n;i++)
        ans+=a[i];
    ll q;
    cin>>q;
    for(ll i=0;i<q;i++){
        ll b,c;
    cin>>b>>c;
    ans-=(m[b]*b);
    ans+=(m[b]*c);
    m[c]+=m[b];
    m[b]=0;
    cout<<ans<<endl;
    }
	return 0;
}


Measured memory_bytes: 10040
import java.util.Scanner

object Main {
  def solve(N: Int, e: Array[Array[Boolean]]): Int = {
    permutation((2 to N).toArray, 0){ (p, acc) =>
      val path = 1 +: p
      val legit = path zip path.drop(1) forall { case (i, j) =>
        e(i)(j)
      }
      acc + (if(legit) 1 else 0)
    }
  }

  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val N = sc.nextInt()
    val M = sc.nextInt()
    val e = Array.ofDim[Boolean](N + 1, N + 1)
    (0 until M) foreach { _ =>
      val a = sc.nextInt()
      val b = sc.nextInt()
      e(a)(b) = true
      e(b)(a) = true
    }
    println(solve(N, e))
  }

  @specialized
  def permutation[A, B](a: Array[A], z: B)(f: (Array[A], B) => B): B = {
    def swap(i: Int, j: Int): Unit = {
      val temp = a(i)
      a(i) = a(j)
      a(j) = temp
    }

    def step(n: Int, acc: B): B = n match {
      case 1 => f(a, acc)
      case _ =>
        val acc2 = (0 until n - 1).foldLeft(acc) { (acc0, i) =>
          val acc1 = step(n - 1, acc0)
          if (n % 2 == 0) {
            swap(i, n - 1)
          } else {
            swap(0, n - 1)
          }
          acc1
        }
        step(n - 1, acc2)
    }

    step(a.length, z)
  }
}


Measured memory_bytes: 31884
#include <algorithm>
#include <bits/stdc++.h>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <iostream>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdio.h>
#include <string>
#include <utility>
#include <vector>

#define REP(i, n) for(int i = 0; i != n; ++i)
#define REPR(i, n) for(int i = n - 1; i != -1; --i)
#define FOR(i, a, b) for(int i = a; i != b; ++i)
#define RBF(i, n) for(auto &i : n)
#define ABS(n) (n < 0 ? -n : n)
#define MIN(a, b) (a < b ? a : b)
#define MAX(a, b) (a > b ? a : b)
#define IN(n) (cin >> n)
#define OUT(n) (cout << n << "\n")
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()

using namespace std;
using ll = long long;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int N, K, Q;
  cin >> N >> K >> Q;
  vector<int> X(N,K-Q);
  int win;
  REP(i,Q){
    cin >> win;
    X[win-1] =X[win-1] +1;
  }
  REP(i,N){
    if(X[i] >0) OUT("Yes");
    else OUT("No");
  }
}

Measured memory_bytes: 1024