akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1<<30;
using P=pair<int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};

int MAX=100000;
vector<int> x(MAX,0);//関係分け
vector<vector<int>> frien(MAX,vector<int>(0));

int cnt=1;


void dfs(int i){
    if(x[i]) return;
    x[i]=cnt;
    for(auto a : frien[i]) dfs(a);
    return;
}

int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n,m,k;
    cin>>n>>m>>k;
    int f,g;
    vector<P> enemy(k);
    rep(i,m){
        cin>>f>>g;
        f --;
        g --;
        frien[f].push_back(g);
        frien[g].push_back(f);
    }
    rep(i,k){
        cin>>f>>g;
        f --;
        g --;
        enemy[i]=P(f,g);
    }
    
    rep(i,n){
        if(x[i]) continue;
        dfs(i);
        cnt ++; 
    }
    vector<int> w(n);
    rep(i,n) w[i]=x[i];
    sort(all(w));//数えるた
    vector<int> z(cnt+1,0);
    REP(i,1,cnt+1){
        f=upper_bound(all(w),i)-lower_bound(all(w),i);
        z[i]=f;
    }
    
    rep(i,n){
        w[i]=z[x[i]]-1;
    }//x:組み合わせ、w:人数
    rep(i,k){
        f=enemy[i].first;
        g=enemy[i].second;
        if(x[f]==x[g]) {w[f] --;w[g] --;}
    }
    //すでにfriend
    rep(i,n){
        w[i] -= frien[i].size();
    }
    rep(i,n) cout<<w[i]<<" ";
    cout<<endl;
}


Measured memory_bytes: 8320
#include <bits/stdc++.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>
#include <bitset>
#include <cassert>
#include <queue>
#include <random>
#include <stack>
#include <iomanip>
#include <math.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define repf(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define repr(i, a, b) for (ll i = (ll)a; i > (ll)b; i--)
#define repv(x, arr) for (auto &x : arr)
#define all(v) (v).begin(), (v).end()
#define vec(name, num) vector<ll> name((num), 0);
#define mp(a, b) make_pair(a, b)
#define pb(x) push_back(x)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int infi = 2147483600;
const ll infl = 1e17;


void getZarr(string str,int Z[]){
    int n = str.size();
    int l, r, k;
    l = r = 0;
    repf(i,1,n){
        if (i>r){
            l = r = i;
            while (r<n && str[r]==str[r-l]){
                r++;
            }
            Z[i] = r - l;
            r--;
        }
        else{
            k = i - l;
            if (Z[k]<r-i+1){
                Z[i] = Z[k];
            }
            else {
                l = i;
                while (r<n && str[r]==str[r-l]){
                    r++;
                }
                Z[i] = r - l;
                r--;
            }
        }
    }
}



int main()
{
    string s, t;
    cin >> s >> t;
    string ss = s;
    int x = s.size() + t.size();
    while (ss.size()<x){
        ss += s;
    }
    string tar = t + '$' + ss;
    int Z[tar.size()];
    getZarr(tar, Z);
    vii edges(s.size(),-1);
    rep(i,tar.size()){
        if (Z[i]==t.size()){
            //cout << i << " " << (i - t.size() - 1)%s.size() << " " << (i - 1)%s.size() << endl;
            edges[(i - t.size() - 1)%s.size()]=(i-1)%s.size();
        }
    }
    /*
    cout << "Z : ";
    rep(i, tar.size()) cout << Z[i] << " ";
    cout << endl;
    cout << "edges : ";
    rep(i, s.size()) cout << edges[i] << " ";
    cout << endl; */
    vii res(s.size(), -1);
    vector<bool> visited(s.size(), false);
    rep(i,s.size()){
        if (visited[i])
            continue;
        visited[i] = true;
        if (edges[i]==-1)
            continue;
        res[i] = 0;
        int now = i;
        while (edges[now]>-1){
            if (edges[now]==i){
                cout << -1 << endl;
                return 0;
            }
            if (res[edges[now]]<res[now]+1){
                res[edges[now]] = res[now] + 1;
                now = edges[now];
                visited[now] = true;
            }
            else{
                break;
            }
        }
    }
    int ans = 0;
    rep(i, s.size()){ ans = max(ans, res[i]);
        //cout << res[i] << " ";
    }
    //cout << endl;
    cout << ans << endl;
}


Measured memory_bytes: 16896
#include<iostream>
#include<unordered_map>
#include<bitset>
#include<math.h>
#include<vector>
#include<set>
#include<algorithm>
#include<ctype.h>
#include<unordered_set>
#include<string>
#include<iomanip>
#include<queue>
#include<limits>
#include<map>
#include<stack>
#include<iterator>
#include<cstring>
 
#include<deque>
#define pi 3.141592653589793238
#include<chrono>
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define MOD 1000000007
#define INF 999999999999999999 
#define pb push_back
#define ff first
#define ss second
 
#define mt make_tuple
#define ll long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
 
 
typedef tree<ll, null_type, less_equal<ll>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
 
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    fast;
    ll T = 1, i, j;
    
    //cin >> T;
    while (T--) {
        ll n;
        cin >> n;
        vector<ll> v(n);
        for(i = 0; i < n; i++){
            cin >> v[i];
        }
        //dp[i][j]  is max money left if he has j stocks on the ith day
        vector<vector<ll>> dp(n + 1, vector<ll>(2, -INF));
        dp[1][0] = 1000;
        dp[1][1] = 1000 - (1000 / v[0]) * v[0];
        for(i = 1; i < n; i++){
            ll prev = dp[i][0];
            ll prevstocks = dp[i][0] / v[i - 1];
            dp[i + 1][0] = max(dp[i][0], dp[i][1] + prevstocks * v[i]);
            dp[i + 1][1] = dp[i + 1][0] - (dp[i + 1][0] / v[i]) * v[i];
        }   
        cout << dp[n][0];
    }
    return 0;
}

Measured memory_bytes: 3588
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int (i)=(n); (i)>=(0); (i)--)
#define SIZE(x) ((int)(x).size())
#define GCD(a, b) int gcd(int a,int b){return b?gcd(b,a%b):a;}
#define QP(a, b) int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define all(v) (v).begin(),(v).end()


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 chadd(T &a, T b) {a = a + b;}
template<typename A, size_t N, typename T>
void FILL(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

typedef vector<int, int> vint;
typedef pair<int,int> pint;
typedef vector<pint>vpint;
typedef long long ll;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1LL << 60;
const ll MOD = 1000000007LL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int k, a, b; cin >> k >> a >> b;
    if((b/k - (a-1)/k) >= 1) cout << "OK";
    else cout << "NG";
    cout << endl;
    return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <string>

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	string str;
	cin >> str;
	if (str[2] == str[3] && str[4] == str[5]) {
		cout << "Yes\n";
	}
	else {
		cout << "No\n";
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#define _ ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

using namespace std;

int main()
{_
    int n; cin >> n;
    long long ans = 0;
    string s; cin >> s;
    string ss = s;
    sort (ss.begin(), ss.end());
    for (int i = 0; i < s.size(); ++i)
    {
        if (s[i] == 'W' && ss[i] == 'R') ++ans;
    }
    cout << ans;
}


Measured memory_bytes: 3352
#include <iostream>

using namespace std;

int main() {
    string s;
    cin >> s;
    bool good = true;
    for (int i = 0; i < 3; ++i) {
        if (s[i] == s[i + 1]) good = false;
    }
    cout << (good ? "Good" : "Bad") << endl;
}


Measured memory_bytes: 256
#include <cstdio>

int main(int argc,char **argv){
	char s[4];
	std::fgets(s,4,stdin);
	if(s[0]=='7'||s[1]=='7'||s[2]=='7') std::fwrite("Yes\n",1,4,stdout);
	else std::fwrite("No\n",1,3,stdout);
	return 0;
}


Measured memory_bytes: 1516
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

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

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

    int t[n];
    for (int i = 0; i < n; i++) cin >> t[i];

    sort(t, t+n);

    int idx = 0;
    int lim = t[0] + k;
    int cnt = 0;
    int ans = 0;
    while (true) {
        if (idx >= n) {
            if (cnt) ans++;
            break;
        }

        if (cnt == c) {
            ans++;
            cnt = 0;
            lim = t[idx] + k;
        }

        if (t[idx] <= lim) {
            cnt++;
        } else {
            ans++;
            lim = t[idx] + k;
            cnt = 1;
        }
        idx++;
    }

    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 888
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] nums = new int[3];
		for(int i=0; i<3; i++)
			nums[i]=sc.nextInt();
		Arrays.sort(nums);
		if(nums[0]==nums[1]) {
			if(nums[1]!=nums[2])
				System.out.println("Yes");
			else
				System.out.println("No");
		}else {
			if(nums[1]==nums[2])
				System.out.println("Yes");
			else
				System.out.println("No");
		}
	}

}


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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n; cin>>n;
	vector<int>p(n); for(auto&&i:p)cin>>i;
	vector<int>v=p;
	sort(v.begin(),v.end());
	int diff=0;
	for(int i=0;i<n;++i){
		if(p.at(i)!=v.at(i))++diff;
	}
	cout<<(diff==2||diff==0?"YES"s:"NO"s)<<"\n"s;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        // int n = Integer.parseInt(sc.next());
        String s = sc.next();
        // int[] a = new int[n];
        // for (int i = 0; i < n; i++) {
        // a[i] = Integer.parseInt(sc.next());
        // }

        if (s.charAt(0) == '7' || s.charAt(1) == '7'|| s.charAt(2) == '7') {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }

        // System.out.println(s);
        sc.close();
    }
}

Measured memory_bytes: 35812
<?php
$loop = trim(fgets(STDIN));
$nums_input = trim(fgets(STDIN));

$nums = explode(" ", $nums_input);
$result = 1;
$max_num = 1000000000000000000;

for ($i = 0;$i < $loop;$i++) {
    if ($nums[$i] == 0) {
        $result = 0;
        break;
    }
}

if ($result !== 0) {
    for ($i = 0;$i < $loop;$i++) {
        $result = $result * $nums[$i];
        if ($result > $max_num) {
            $result = -1;
            break;
        }
    }
}

print $result;

Measured memory_bytes: 25496
import sys

N=int(sys.stdin.readline())

A=[int(i) for i in sys.stdin.readline().split()]

A.sort(reverse=True)

ans=0
ctr=0
i=0

while(ctr<N-1):
	if(i==0):
		ans+=A[i]
		i+=1
		ctr+=1
	else:
		ans+=A[i]
		ctr+=1
		if(ctr<N-1):
			ans+=A[i]
			ctr+=1
			i+=1

print(ans)


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

const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

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

int main(){
    int x;
    cin >> x;
    int t2 = x;
    while (1) {
        bool ok = true;
        for (int i=2; i*i<=t2; ++i) {
            if (t2%i==0) {
                ok = false;
                break;
            }
        }
        if (ok) {
            cout << t2 << endl;
            break;
        }
        ++t2;
    }
    return 0;
}


Measured memory_bytes: 3616
#include<stdio.h>
int main(){
  int a,b,c,d;
    scanf("%d%d%d",&a,&b,&c);
    while(1){
    if(b<a){
      d=a;
      a=b;
      b=d;}
    else if(c<b){
      d=b;
      b=c;
      c=d;}
    else break;}
  printf("%d %d %d\n",a,b,c);
  return 0;
}
   

Measured memory_bytes: 596
from collections import deque

N, M = map(int, input().split())
friends = [[] for _ in range(N+1)]
for __ in range(M):
  a, b = map(int, input().split())
  friends[a].append(b)
  friends[b].append(a)
checked = [0 for ___ in range(N+1)]
answer = 1
for i in range(1, N+1):
  friend = deque(friends[i])
  cnt = 0
  while(len(friend) > 0):
    f = friend.popleft()
    if checked[f] != 0:
      continue
    else:
      checked[f] = 1
      cnt += 1
      for ff in friends[f]:
        friend.append(ff)
  answer = max(answer, cnt)
print(answer)
  

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

int main() {
	int n,k; string s;
	cin >> n >> s >> k;
	for(int i=0; i<n; i++){
		if(s[i]==s[k-1]){
			cout << s[k-1];
		}else{
			cout << '*';
		}
	}

}


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

#define sz(x) (int)(x.size())
#define FOR(i,L,R) for(int i = L; i <= R; i++)
#define int long long

const int N = 2e5 + 2, inf = 1e18;

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

    int n;
    cin >> n;
    int a[n + 2] = {};
    FOR(i,1,n) {
        cin >> a[i];
    }
    int ans = 0;
    FOR(i,2,n) {
        if(a[i - 1] <= a[i]) continue;
        int diff = a[i - 1] - a[i];
        a[i] += diff;
        ans += diff;
    }
    cout << ans;
}


Measured memory_bytes: 5176
// Last Change: 04/05/2019 03:20:10.
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

namespace NS {
void LoopUntilZeroInpput() {
  int hogegegege = 0;
  while (cin >> hogegegege && hogegegege != 0) {
  }
}
} // namespace NS

ll N, M;
vector<ll> x;
vector<ll> y;
vector<ll> z;

ll Cal(ll depth, int pos) {
  if (depth == 3) {
    vector<ll> tmp(N, 0);
    for (ll i = 0; i < N; ++i) {
      if (pos & (1 << 2)) {
        tmp[i] += x[i];
      } else {
        tmp[i] -= x[i];
      }
      if (pos & (1 << 1)) {
        tmp[i] += y[i];
      } else {
        tmp[i] -= y[i];
      }
      if (pos & 1) {
        tmp[i] += z[i];
      } else {
        tmp[i] -= z[i];
      }
    }
    sort(tmp.begin(), tmp.end(), std::greater<ll>());

    ll ans = 0;
    for (ll i = 0; i < M; ++i) {
      ans += tmp[i];
    }
    return ans;
  }
  ll ans = Cal(depth + 1, (pos << 1));
  ans = max(ans, Cal(depth + 1, (pos << 1) | 1));
  return ans;
}

int main() {
  cin >> N >> M;
  x.resize(N);
  y.resize(N);
  z.resize(N);
  for (ll i = 0; i < N; ++i) {
    cin >> x[i] >> y[i] >> z[i];
  }

  ll ans = Cal(0, 0);
  cout << ans << endl;

  //NS::LoopUntilZeroInpput();
}


Measured memory_bytes: 1016
S = input()

mm = ['0' + str(x) for x in range(1,10)] + ['10','11','12']

mmyy = (S[:2] in mm)
yymm = (S[2:] in mm)

answer = 'NA'
if yymm and mmyy:
  answer = 'AMBIGUOUS'
elif yymm:
  answer = 'YYMM'
elif mmyy:
  answer = 'MMYY'
  
print(answer)


Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
    while (1) {
        int n, r; cin >> n >> r;
        if (n == 0 && r == 0) break;
        int a[n];
        for (int i = 0; i < n; ++i) {
            a[i] = n - i;
        }
        for (int i = 0; i < r; ++i) {
            int p, c; cin >> p >> c;
            rotate(a, a + (p - 1), a + (p - 1) + c);
            /*
            for (int j = 0; j < n; ++j) {
                cout << a[j] << " ";
                if (j == n - 1) cout << endl;
            }
             */
        }
        cout << a[0] << endl;
    }
    return 0;
}



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

#define fs first
#define se second
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)

using pii = pair<int, int>;
using vi = vector<int>;
using lint = long long;

const int inf = 1001001001;
const lint linf = 1001001001001001001ll;
const int mod = 1e9 + 7;
const int dx[]{0, 1, 0, -1, -1, -1, 1, 1}, dy[]{1, 0, -1, 0, -1, 1, -1, 1};

template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; } return a > b; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; } return a < b; }
template<typename T> inline void print(const T &x, string s = "\n") { cout << x << s; }
template<typename T> inline void print(const vector<T> &v, string s = " ") 
{ rep(i, v.size()) cout << v[i] << (i + 1 == v.size() ? "\n" : s); }
inline bool inside(int y, int x, int H, int W) { return 0 <= y && y < H && 0 <= x && x < W; }
inline lint in() { lint x; std::cin>>x; return x; }

int main() {
	int h = in(), w = in();
	char po[128][128];

	rep(i, h) rep(j, w) cin >> po[i][j];

	rep(i, 2 * h) { 
		rep(j, w) {
			printf("%c", po[i / 2][j]);
		}
		puts("");
	}
}



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

int main(void){
    long long n,ans=1,k=1;
    scanf("%lld",&n);
    long long count[n];
    for (int i=0; i<n; i++){
        count[i]=0;
    }
    
    for (int i=1; i<=n; i++){
        k=i;
        for (int j=2; j<=k; j++){
            while (k%j==0){
                count[j-1]++;
                k/=j;
                }
        }
    }
    for (int i=0; i<n; i++){
        ans=(ans*(count[i]+1))%1000000007;
        
    }
    printf ("%lld\n",ans);
	return 0 ;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int q,x,y;
long long mx1=INT_MIN,mx2=INT_MIN,mn1=INT_MAX,mn2=INT_MAX;
int main()
{
    cin >> q;
    while(q--)
    {   cin>>x>>y;
        if(y+x>mx1)mx1=y+x;
        if(y-x>mx2)mx2=y-x;
        if(y+x<mn1)mn1=y+x;
        if(y-x<mn2)mn2=y-x;
    }
    cout<< max(abs(mx1-mn1), abs(mx2-mn2));
}
 

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

int main(){
  int n, s, total;
  cin >> n >> s;
  int count = 0;
  
  for(int i = 0; i<=n; i++){
    for(int j = 0; j<=n; j++){
      total = s-i-j;
      if(0 <= total && total <= n)
        count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int q,n;
  cin>>q;
  while(q--){
    cin>>n;
    int c=0;
    while(n/10&&c<1000000){
      c++;
      int a=-1;
      for(int i=10;i<n;i*=10)a=max(a,(n/i)*(n%i));
      n=a;
    }
    if(c==1000000)cout<<-1<<endl;
    else cout<<c<<endl;
  }
  return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, k, n) for (int i = k; i < (int)(n); i++)
#define RRep(i, k, n) for (int i = k; i > (int)(n); i--)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define ALL(a)  (a).begin(),(a).end()
#define rALL(a)  (a).rbegin(),(a).rend()
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 long long INF = 1LL << 60;
const int MOD = 1000000007;
const double PI = acos(-1); //3.14~
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

long long oddsolve(long long a) { return (a+1)/2 % 2; }
long long solve(long long a) {
    if (a % 2 == 1) return oddsolve(a);
    else return oddsolve(a+1) ^ (a+1);
}

int main()
{
    ll a, b; cin >> a >> b;
    cout << (solve(b) ^ solve(a - 1)) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<double> vd;
typedef pair<double,double> PD;
typedef pair<int,P> ed;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  int N,M;
  cin >> N >> M;
  vi G(M,0);
  rep(i,M) {
    int k;
    cin >> k;
    rep(j,k) {
      int x;
      cin >> x;
      x--;
      G[i] |= 1<<x;
    }
  }
  vi p(M);
  rep(i,M) {
    cin >> p[i];
  }
  int ans = 0;
  rep(i,1<<N) {
    int cnt = 0;
    rep(j,M) {
      int s = G[j]&i;
      int c = __builtin_popcountll(s);
      if((c&1)==p[j]) {
        cnt++;
      }
    }
    if(cnt==M) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
H,W=[int(x) for x in str(input()).split()]
A=[]
for i in range(H):
  A.append([int(x) for x in str(input()).split()])


ANS=[]
count=0
for i in range(H):
  for j in range(W-1):
    if A[i][j]%2==1:
      count+=1
      A[i][j+1]+=1
      ANS.append(str(i+1)+" "+str(j+1)+" "+str(i+1)+" "+str(j+2))
for i in range(H-1):
  if A[i][-1]%2==1:
    count+=1
    A[i+1][-1]+=1
    ANS.append(str(i+1)+" "+str(W)+" "+str(i+2)+" "+str(W))


print(count)
for i in ANS:
  print(i)

Measured memory_bytes: 63580
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int N,M;
    cin >> N;
    while(N){
        set< P >st;
        int used = (1 << (N+1)) - 1;
        rep(i,0,N){
            int x,y;
            cin >> x >> y;
            st.insert(P(x,y));
        }
        cin >> M;
        int nx = 10,ny = 10;
        rep(i,0,M){
            char c;
            int num;
            cin >> c >> num;
            rep(j,0,num){
                if(c == 'N')ny++;
                if(c == 'S')ny--;
                if(c == 'E')nx++;
                if(c == 'W')nx--;
                if(st.count(P(nx,ny))){
                    st.erase(P(nx,ny));
                }   
            }
        }
        if(st.size() == 0) cout << "Yes" << endl;
        else               cout << "No" << endl;
        cin >> N;
    }
}


Measured memory_bytes: 2992
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;

void solve(){

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

    string s;
    cin >> s;
    int n = s.size();

    // cout << n << endl;
    
    double cent;
    cent = (double) (n+1)/2;

    // cout << cent <<endl;

    // 0 count |index-center|
    rep(i,n){
        if(s[i]=='0'){
            if(i==n-1){
                cout << n << endl;
                return 0;
            }
            continue;
        }
        else{
            break;
        }
    }
    rep(i,n){
        if(s[i]=='1'){
            if(i==n-1){
                cout << n << endl;
                return 0;
            }
            
            continue;
        }
        else{
            break;
        }
    }

    double res1=n,res2=n;
    rep(i,n){
        if(s[i]=='0'){
            double m = abs(i+1-cent);
            res1 = min (res1,m);
            // cout << m << endl;
        }
        else{
            double m = abs(i+1-cent);
            res2 = min (res2,m);
            // cout << m << endl;
        }
    }

    // cout << cent <<endl;

    // cout << res1 << endl;
    // cout << res2 << endl;

    double ans = max(res1,res2);

    // cout << ans << endl;

    int a = ans + cent;

    // if(n%2==0){
    //     cout << a <<endl;
    // }
    // else{
    //     cout << a-1 <<endl;
    // }
    cout << a-1 << endl;

    return 0;
}

Measured memory_bytes: 512
#include<stdio.h>
#define NUM 13
#define SIZE 101
int main()
{
  int mat[NUM],count[SIZE];
  int ans,judge;
  int i,n;
  while(1)
    {
      scanf("%d",&n);
      if(n==0) break;
      for(i=0;i<SIZE;i++) count[i]=0;
      for(i=0;i<n;i++)
	{
	  scanf("%d",&mat[i]);
	  count[mat[i]]++;
	}
      judge=n;
      for(ans=0;judge>0;ans++)
	{
	  judge=n;
	  for(i=0;i<n;i++)
	    {
	      if(mat[i]==count[mat[i]]) judge--;
	      mat[i]=count[mat[i]];
	    }
	  for(i=0;i<SIZE;i++) count[i]=0;
	  for(i=0;i<n;i++) count[mat[i]]++;
	}
      printf("%d\n",ans-1);
      for(i=0;i<n-1;i++) printf("%d ",mat[i]);
      printf("%d\n",mat[n-1]);
    }
  return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
ll inf =  1e9;
ll mod = 1e9 + 7;

int main(){
    int n;
    cin>>n;
    vector<vector<ll> > a(n,vector<ll>(n,0) );
    vector<ll> dp( 1<<n ,0 ) ;
    dp[0] = 1;
    for(int i=0;i<n;i++)
	for(int j=0;j<n;j++)cin>>a[i][j];

    for(int i=1;i<(1<<n);i++){//ビットが立っている女性が0~(j-1)番目までの男性とマッチングしている個数 
	int j = __builtin_popcount(i);
	for(int k = 0;k<n;k++){//(j-1)番目の男性とk番目の女性がマッチする
	    if( ((i>>k)&1) == 1 &&  a[j-1][k] == 1 ) dp[i] += dp[ i^(1<<k)] ,dp[i]%=mod;
	}
    }
    cout<< dp[ (1<<n)-1 ] << endl;
    return 0;
}


Measured memory_bytes: 16640
#include <iostream>
#include <vector>
#include <string>
 
using namespace std;
 
int main() {
    int N, K;
    cin >> N >> K;
 
    string S;
    cin >> S;
 
    vector<int> cum_sum;
    cum_sum.push_back(0);
 
    int counter = 0;
    char tmp_char = S[0];
    if (tmp_char == '0') cum_sum.push_back(0);
 
    for (int i = 0; i < N; i++) {
        if (tmp_char == S[i]) {
            counter++;
            if (i == (N-1)) cum_sum.push_back(cum_sum.back()+counter);
        } else {
            cum_sum.push_back(cum_sum.back() + counter);
            counter = 1;
            tmp_char = S[i];
            if (i == (N-1)) cum_sum.push_back(cum_sum.back()+1);
 
            //cout << S[i] << endl;
        }
        //cout << cum_sum.back() << endl;
    }
 
    if (S[N-1] == '0') cum_sum.push_back(cum_sum.back());
 
    //for (int i = 0; i != cum_sum.size(); ++i) {
    //    cout << cum_sum[i] << endl;
    //}
    int max_1 = 0; 
    counter = 0;
  
       if (K==0) {
        for (int i = 0; i < N; i++) {
            if (S[i]=='1') counter++;
            else {
                max_1 = max(max_1, counter);
                counter = 0;
            }
        }
        max_1 = max(max_1, counter);
        cout << max_1 << endl;
        return 0;
    }
    
    int ans = 1;
    int ind = 0;
    for (int i = 0; i < cum_sum.size(); i+=2) {
        ind = min((2*K+1) + i, int(cum_sum.size()) - 1);
        ans = max(ans, cum_sum[ind] - cum_sum[i]);
    }
 
    cout << ans << endl;
    return 0;
}

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

// lib/square.hpp
#ifndef SQUARE_HPP
#define SQUARE_HPP

/*
usage:

tools::square(5) => 25
*/

namespace tools {
  template <typename T>
  constexpr T square(const T x) {
    return x * x;
  }
}

#endif

// main.cpp

int main() {
  std::string a, b;
  std::cin >> a >> b;
  std::cout << (tools::square<std::int_fast64_t>(std::sqrt(std::stoi(a + b))) == std::stoi(a + b) ? "Yes" : "No") << std::endl;
  return 0;
}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;

bool iskaibun(string s){
	int sz = s.size();
  	rep(i,sz){
      	if(s[i] != s[sz-1-i]) return false;
    }
  	return true;
}

void Main()
{
	string s;
	cin >> s;
	int m = s.size()/2;
  	string s1 = s.substr(0,m);
  	string s2 = s.substr(m+1);
  	// cout << s1 << " " << s2 << endl;
	if(s1 != s2) {
      	puts("No");
      	return;
    };
	if(!iskaibun(s1)) {
        puts("No");
      	return;
    }
    puts("Yes");
    return;
}

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

Measured memory_bytes: 256
#!/usr/bin/env python3

# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    n = int(input())
    F = []
    for i in range(n):
        F.append(list(map(int, input().split())))
    P = []
    for i in range(n):
        P.append(list(map(int, input().split())))
    mx = -1e12
    for i in range(1, 1 << 10):
        benefit = 0
        for j in range(n):
            f = F[j]
            counter = 0
            for k in range(10):
                if (i >> k & f[k]) == 1:
                    counter += 1
            benefit += P[j][counter]
        mx = max(mx, benefit)
    print(mx)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
import java.io.IOException;
import java.util.Scanner;

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

        int r = input.nextInt();
        int g = input.nextInt();
        int b = input.nextInt();

        int newNum = r * 100 + g * 10 + b;

        if (newNum % 4 == 0)
        {
                System.out.println("YES");
        }
        else
        {
                System.out.println("NO");
        }
        input.close();
    }
}


Measured memory_bytes: 21844
var
 i,n,m,j,y,k,x:longint;
 s,s1:string;
begin
 readln(n,m);
 for i:=1 to n do
  begin
   readln(s);
   for j:=1 to m-1 do
    begin
     x:=pos(' ',s);
     s1:=copy(s,1,x-1);
     if s1='snuke' then begin y:=i;k:=j; end;
     delete(s,1,x);
    end;
   if s='snuke' then begin y:=i;k:=j; end;
  end;
 writeln(chr(k+64),y);
end.

Measured memory_bytes: 128
import numpy as np
n, a, b = map(int, input().split())
a, b = min(a, b), max(a, b)
MOD = 10**9 + 7
v = pow(2, n, MOD) - 1


def cumprod(arr, MOD):
    L = len(arr)
    Lsq = int(L**.5 + 1)
    arr = np.resize(arr, Lsq**2).reshape(Lsq, Lsq)
    for n in range(1, Lsq):
        arr[:, n] *= arr[:, n - 1]
        arr[:, n] %= MOD
    for n in range(1, Lsq):
        arr[n] *= arr[n - 1, -1]
        arr[n] %= MOD
    return arr.ravel()[:L]


def make_fact(U, MOD):
    x = np.arange(U, dtype=np.int64)
    x[0] = 1
    fact = cumprod(x, MOD)
    x = np.arange(U, 0, -1, dtype=np.int64)
    x[0] = pow(int(fact[-1]), MOD - 2, MOD)
    fact_inv = cumprod(x, MOD)[::-1]
    return fact, fact_inv


# a / b = (a % N * pow(b, N - 2, N)) % N(mod=N)
fact, fact_inv = make_fact(2 * 10**5 + 1, MOD)
# print(fact)
a_fact = fact[a]
b_fact = fact[b]

n_fact = [n % MOD] * (b + 1)
for i in range(1, b + 1):
    n_fact[i] = (n_fact[i - 1] * (n - i)) % MOD
an_fact = n_fact[a - 1]
bn_fact = n_fact[b - 1]


def f(a, b, MOD):
    a, b = int(a), int(b)
    return (a % MOD * pow(b, MOD - 2, MOD)) % MOD


ca = f(an_fact, a_fact, MOD)
cb = f(bn_fact, b_fact, MOD)

print((v - ca - cb) % MOD)


Measured memory_bytes: 26144
def permutation(index, n): # せっかくなので実装
  if index == 1:
    new_box = []
    for i in range(n):
      new_box.append([i])
    return new_box
  
  curr_box = permutation(index - 1, n)
  new_box = []
  for fact_list in curr_box:
    for i in range(n):
      if i in fact_list:
        continue
      new_box.append(fact_list + [i])
  return new_box

def distance(p1, p2, xy):
  return ((xy[p1][0] - xy[p2][0]) ** 2 + (xy[p1][1] - xy[p2][1]) ** 2) ** (1 / 2)

n = int(input())
xy = [[int(i) for i in input().split()] for _ in range(n)]
per = permutation(n, n)
nway = len(per)
sum_dist = 0
for l in per:
  for i in range(len(l) - 1):
    sum_dist += distance(l[i], l[i + 1], xy)
print(sum_dist / nway)


Measured memory_bytes: 14420
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    string s;
    cin>>s;
    int cnt=0;
    for(int i=0;i<s.length();i++)
    {
        if(s[i]=='1')
            cnt++;
    }
    cout<<cnt<<endl;

    return 0;
}


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

#define Online 1
// #define multitest 1
#define Debug 1
void ControlIO();
void TimerStart();
void TimerStop();
#ifdef Debug
#define db(...) ZZ(#__VA_ARGS__, __VA_ARGS__);
template <typename Arg1>
void ZZ(const char *name, Arg1 &&arg1)
{
	std::cerr << name << " = " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void ZZ(const char *names, Arg1 &&arg1, Args &&... args)
{
	const char *comma = strchr(names + 1, ',');
	std::cerr.write(names, comma - names) << " = " << arg1;
	ZZ(comma, args...);
}
#else
#define db(...)
#endif
typedef long long ll;
typedef long double ld;
#define f first
#define s second
#define pb push_back
const long long mod = 1000000007;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void solve()
{
	int n, u, v;
	cin >> n;
	vector<vector<int>> G(n);
	vector<int> Degree(n);
	for (int i = 1; i < n; ++i)
	{
		cin >> u >> v;
		--u;
		--v;
		G[u].pb(v);
		G[v].pb(u);
		Degree[u]++;
		Degree[v]++;
	}
	vector<int> s(n);
	vector<int> vis(n);
	vector<int> value(n);
	for (auto &x : s)
		cin >> x;
	sort(s.begin(), s.end());
	reverse(s.begin(),s.end());
	queue<int> Q;
	for (int i = 0; i < n; ++i)
		if (Degree[i] == 1)
			Q.push(i);
	while (!Q.empty())
	{
		auto t = Q.front();
		Q.pop();
		value[t] = s.back();
		s.pop_back();
		for (auto x : G[t])
		{
			if (!vis[x])
			{
				Degree[x]--;
				if (Degree[x] == 1)
				{
					vis[x] = true;
					Q.push(x);
				}
			}
		}
	}
	ll max = 0,i=0;
	for (auto x : G)
	{
		for (auto y : x)
			max += min(value[i],value[y]);
		++i;
	}
	cout << max/2 << '\n';
	for(auto x:value)
		cout << x << ' ';
}

int main()
{
	ControlIO();
	int t = 1;
#ifdef multitest
	cin >> t;
#endif
	TimerStart();
	while (t--)
		solve();
	TimerStop();
	return 0;
}

void ControlIO()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
#ifndef Online
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

auto TimeStart = chrono::steady_clock::now();
auto TimeEnd = chrono::steady_clock::now();

void TimerStart()
{
#ifndef Online
	TimeStart = chrono::steady_clock::now();
#endif
}

void TimerStop()
{
#ifndef Online
	TimeEnd = chrono::steady_clock::now();
	auto ElapsedTime = TimeEnd - TimeStart;
	cout << "\n\nTime elapsed: " << chrono::duration<double>(ElapsedTime).count() << " seconds.\n";
#endif
}

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

#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
#define INF 2000000000
typedef long long ll;
bool compare(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}
// 入力



int main() {
    
    ll N ;
    string S;
    cin >>N>>S;
    ll now,cnt = 0;
    for(char i = '0';i<='9';i++ ){
        for(char j = '0';j<='9';j++ ){
            for(char k = '0';k<='9';k++ ){
                now = 0;
                rep(m,N){
                    if(now == 0){
                        if(S[m] == i){
                            now = 1;
                        }
                    }else if(now == 1){
                        if(S[m] == j){
                            now = 2;
                        }
                    }else if(now == 2){
                        if(S[m] == k){
                            now = 0;
                            cnt++;
                            break;
                        }
                    }
                }
            }    
        }
    }
    cout << cnt << endl;
    
    
    
    return 0;
    

}

Measured memory_bytes: 3676
//#include"pch.h"
//#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<algorithm>
#include<iostream>
using namespace std;

int main() {
	int A, B, sum = 0;
	cin >> A >> B;
	for (int i = 1; i <= B - A; i++) {
		sum += i;
	}
	printf("%d\n", sum - B);

	return(0);
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;
const int MOD = 998244353;

int main()
{
	int N;
	cin >> N;
	cout << "ABC" << N << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <iterator>
#define loop(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;

using namespace std;
using LL = long long;
using ULL = unsigned long long;

int main() {
    int n; cin >> n;
    set<LL> st;
    rep(i, n) {
        LL a; cin >> a;
        if (st.find(a) != st.end()) {
            st.erase(a);
        } else {
            st.insert(a);
        }
    }
    cout << st.size() << endl;
}


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

#ifdef DEBUG
#define PRINT(x)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#x<<" = "<<(x)<<endl;
#define PRINTA(a,first,last)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<(first)<<", "<<(last)<<")"<<endl;\
    for (int i=(first);i<(last);++i){cout<<#a<<"["<<i<<"] = "<<(a)[i]<<endl;}
#define PRINTP(p)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#p<<" = ("<<(p.first)<<", "<<(p.second)<<")"<<endl;
#define PRINTI(a,i)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<#i<<"] = "<<#a<<"["<<(i)<<"] = "<<(a)[i]<<endl;
#else
#define PRINT(x)
#define PRINTA(a,first,last)
#define PRINTP(p)
#define PRINTI(a,i)
#endif

#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);--i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

template <class T, class U> void amax(T& x, U y) {if (x < y) x = y;}
template <class T, class U> void amin(T& x, U y) {if (x > y) x = y;}

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<pii> BA(N);
    REP(i, N) {
        int A, B;
        cin >> A >> B;
        BA[i] = pii(B, A);
    }
    sort(all(BA));
    ll A_sum = 0;
    bool flag = true;
    REP(i, N) {
        A_sum += BA[i].second;
        if (A_sum > BA[i].first) {
            flag = false;
            break;
        }
    }
    cout << (flag ? "Yes" : "No") << endl;

    return 0;
}



Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll>pi;
const int MAXN=200005;
const int MOD=1000000007;
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define DEC(i,a,b) for(int i=(a);i>=(b);i--)
#define fst first
#define snd second
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define db(x) cerr<<#x<<" = "<<x<<"\n"
#define LOW(v,x) (lower_bound(all(v),(x))-(v).begin())

int N,M;
int A[MAXN];
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	cin>>N>>M;
	FOR(i,1,M){
		int a,b;cin>>a>>b;
		A[b]++;
		A[a-1]--;
	}
	DEC(i,N,1){
		A[i]+=A[i+1];
	}
	int ans=0;
	FOR(i,1,N)if(A[i]==M)ans++;
	cout<<ans<<"\n";
}
/*
1 3
#.#


2 3
#.#
..#

3 3
##.
#.#
..#

3
2 5
6 1
3 7
Ans:6

4
3 7
2 9
8 16
10 8
Ans:9
*/


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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pow(x) x*x
#define ll long long
static const int MAX = 10000;
static const ll INFTY = 1e12;

struct edge {
    ll to, cost;
};

using Graph = vector<vector<int>>;
using _Graph = vector<vector<edge>>;
// 入力
int H, W;
vector<vector<char>> field;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

// 深さ優先探索
vector<bool> seen;
vector<int> colors;

int main() {

  int A[3][3];
  REP(i, 3)REP(j, 3) cin >> A[i][j];
  int N; cin >> N;
  vector<int> b(N);
  REP(i, N) cin >> b[i];
  int flag = 0;

  REP(i, N){
    REP(j, 3){
      REP(k, 3){
        if(A[j][k] == b[i]){
          A[j][k] = -1;
        }
      }
    }
  }

  if(A[0][0] == -1 && A[0][1] == -1 && A[0][2] == -1) flag = 1;
  if(A[1][0] == -1 && A[1][1] == -1 && A[1][2] == -1) flag = 1;
  if(A[2][0] == -1 && A[2][1] == -1 && A[2][2] == -1) flag = 1;
  if(A[0][0] == -1 && A[1][0] == -1 && A[2][0] == -1) flag = 1;
  if(A[0][1] == -1 && A[1][1] == -1 && A[2][1] == -1) flag = 1;
  if(A[0][2] == -1 && A[1][2] == -1 && A[2][2] == -1) flag = 1;
  if(A[0][0] == -1 && A[1][1] == -1 && A[2][2] == -1) flag = 1;
  if(A[0][2] == -1 && A[1][1] == -1 && A[2][0] == -1) flag = 1;

  if(flag == 1){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

    
}
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/


Measured memory_bytes: 256
// Problem : B - Substring
// Contest : AtCoder - AtCoder Beginner Contest 177
// URL : https://atcoder.jp/contests/abc177/tasks/abc177_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
ordered_set;	

#define FOR(i,a,b) for(int i = (a); i <= (b); ++i)
#define FORD(i,a,b) for(int i = (a); i >= (b); --i)
#define RI(i,n) FOR(i,1,(n))
#define REP(i,n) FOR(i,0,(n)-1)
#define mini(a,b) a=min(a,b)
#define maxi(a,b) a=max(a,b)
#define pb push_back
#define st first
#define nd second
#define sz(w) (int) w.size()
typedef vector<int> vi;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<pii, int> para;
const ll inf = 1e18 + 7;
const ll maxN = 1e6 + 5;
const ll MOD = 1e9 + 7;

// sprawdz MODULO!
int main() {
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	string s, t;
	cin >> s >> t;
	int ans = 100000;
	REP(i, sz(s) - sz(t) + 1) {
		int cnt = 0, tmp = 0;
		FOR(j, i, i + sz(t) - 1) {
			if (s[j] != t[cnt++]) tmp++;
		}
		ans = min(ans, tmp);
	}
	cout << ans;
	return 0;
}
 


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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define _USE_MATH_DEFINES
#define f first
//#define s second
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define INF 1000000000000000000
#define MAXN (int)(1e7)+1
#define MOD 1000000007

using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,int> pwi;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< vector<pair<ll,ll > > > wGraph;
typedef vector<vector<ll> > graph;
//typedef vector<vector<ll> > matrix;



int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout<<std::fixed;
    cout<<std::setprecision(2);

    int x;
    cin>>x;
    if(x>=30) cout<<"Yes\n";
    else cout<<"No\n";

    return 0;
}

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

using ll=long long; 

void solve(){
	int x,y,z;
	cin>>x>>y>>z;
	int sum=x/(y+z);
	if((sum*(y+z))+z>x){
		sum--;
	}
	cout<<sum<<endl;
}

signed main(){
	//while(1)
	solve();
}

Measured memory_bytes: 256
#include <set>
#include <map>
#include <math.h>
#include <vector>
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
const double eps = 1e-8;
using namespace std;
const int maxn = 1e5+555;
map<int,int>mp;
int num[maxn];
int p[maxn];
int main()
{
	int n;
	scanf("%d",&n);
	int cnt=0;
	for(int i=1;i<=n;i++){
		int x;scanf("%d",&x);
		if(mp[x]==0){
			mp[x]=++cnt;
			num[cnt]=x;
		}
		p[mp[x]]++;
	}
	int ans = 0;
	for(int i=1;i<=cnt;i++){
		if(p[i]<num[i]){
			ans+=p[i];
		}else{
			ans+=p[i]-num[i];
		}
	}
	printf("%d\n",ans);
}


Measured memory_bytes: 5504
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

ans = 0

for i in range(N):
    ans += B[A[i]-1]
    if i != 0:
        if A[i-1] + 1 == A[i]:
            ans += C[A[i-1]-1]

print(ans)

Measured memory_bytes: 3064