akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<queue>
#define ll long long
#define N 1010
using namespace std;

ll n,m,ans=-1e15;
struct Jg {
  ll a,b,c;
  bool operator < (const Jg &u) const {
    return a+b+c>u.a+u.b+u.c;
  }
} num[N],tmp[N];
priority_queue<ll>pq;

int main() {
  ll i,j,k,t;
  cin>>n>>m;
  for(i=1; i<=n; i++) scanf("%lld%lld%lld",&num[i].a,&num[i].b,&num[i].c);
  for(i=0; i<=7; i++) {
    for(j=1; j<=3; j++) {
      if(i&(1 << (j-1))) t=1;
      else t=-1;
      for(k=1; k<=n; k++) {
        if(j==1) tmp[k].a=num[k].a*t;
        if(j==2) tmp[k].b=num[k].b*t;
        if(j==3) tmp[k].c=num[k].c*t;
      }
    }
    for(; !pq.empty(); pq.pop());
    for(k=1; k<=n; k++) {
      pq.push(tmp[k].a+tmp[k].b+tmp[k].c);
    }
    t=0;
    for(k=1; k<=m; k++) t+=pq.top(),pq.pop();
    ans=max(ans,t);
//		cout<<t<<endl;
  }
  cout<<ans;
}

Measured memory_bytes: 896
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <stack>
#include <queue>

using namespace std;

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

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

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

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;
typedef pair<pair<double, double >, double > pdd;
typedef pair<double, double > pd;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll MOD = 1000000007;
ll INF = 1145141919454519;

int main(){
    
    ll K, N;
    cin >> K >> N;
    
    //vec.push_back(0);
    for(ll i = 0; i < N; i++){
        ll t; cin >> t;
        vec.push_back(t);    
    }

    ll ans = INF;

    for(ll i = 0; i < N; i++){
        ll r, l;
        if(i == 0){
            r = vec.back()-vec[i];
            l = vec[i] + K - vec[i+1]; 
        }else if(i == N-1){
            r = K - vec[i] + vec[i-1];
            l = vec[i] - vec.front();
        }else{
            r = K - vec[i] + vec[i-1];
            l = vec[i] + K - vec[i+1];
        }
        ans = min(ans, min(r, l));
        //cout << r << " " << l << endl;
    }

    cout << ans << endl;

}

Measured memory_bytes: 2420
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<math.h>
#define rep(i,n) for(ll i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
int main(){
    string c[] = {"SUN","MON","TUE","WED","THU","FRI","SAT"};
    string s;
    cin >> s;
    rep(i,7){
        if(c[i] == s)
            cout << 7-i << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

def input():
    return sys.stdin.readline().strip()

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行またはスペース区切りの入力をすべて読み込んでイテレータを返します。
def get_all_int():
    return map(int, open(0).read().split())

def log(*args):
    print("DEBUG:", *args, file=sys.stderr)

def main():
    INF = 999999999999999999999999
    MOD = 10**9+7

    n,*A = get_all_int()

    ma = A[0]
    ans = 0

    for i in range(1,n):
        a = A[i]
        if ma > a:
            ans += ma - a
        ma = max(ma, a)
    
    print(ans)

main()

Measured memory_bytes: 103860
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <unordered_map>
#include <deque>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }
template<typename S, typename T> istream& operator>>(istream &is, pair<S, T> &p){ return is >> p.first >> p.second; }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T> &p){ return os << "[" << p.first << ", " << p.second << "]"; }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define For1(i, n) for(int i = 1; i <= (n); i ++)
#define Rof(i, n) for(int i = (n)-1; i >= 0; i --)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << " "; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define vc vector
#define Mini(a, x) a = min(a, x)
#define Maxi(a, x) a = max(a, x)
#define Return(x) { Cout(x); return 0; }

// constexpr int MOD = 1e9+7;

int main(void){
    Cin(int, n);
    Cins(int, n, a);

    ll ans = 0;
    int lb = 1;
    For(i, n){
        int k = (a[i]-1) / lb;
        ans += k;
        if(k > 0) a[i] = 1;
        lb = max(lb-1, a[i]) + 1;

        // printf("(%d +%d) ", lb, k);
        // Couts(a);
    }
    Cout(ans);
}


Measured memory_bytes: 640
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<iostream>
#include<string.h>     
#include<algorithm>
#define ll long long
using namespace std;
#define hengheng main()
#define mem(a,b) memset(a,b,sizeof(a))
char a[100020];
int x[100020];
int main()
{
	int n,m,t,k,i,j; int sum=0;
	scanf("%s",a);
	n=strlen(a);
	int a1=0,a2=0;
	for(i=0;i<n;i++)
	{
		if(a[i]=='0')
		a1++;
		else
		a2++; 
	}
//for(i=1;i<=n;i++) printf("%d\n",x[i]);
	
    sum=min(a1,a2);
	printf("%d\n",sum*2);
	
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

bool cmp(const string &s, const string &t) {
    int n = s.length();
    int m = t.length();
    if (n < m) return true;
    else if (n > m) return false;
    rep(i,n) {
        if (s[i] < t[i]) return true;
        else if (s[i] > t[i]) return false;
    }
    return false;
}

int main(int argc, char const *argv[]) {
    int n,m; cin>>n>>m;
    vector<int> a(m);
    rep(i,m) cin>>a[i];
    
    const int costs[10] = {INF,2,5,5,4,5,6,3,7,6};
    vector<string> dp(n+1, "$");
    dp[0] = "";
    for (int i = 1; i <= n; ++i) {
        for (auto &&e: a) {
            int cost = costs[e];
            if (i-cost < 0) continue;
            if (dp[i-cost] == "$") continue;
            string t = dp[i-cost];
            char c = e+'0';
            t.push_back(c);
            if (cmp(dp[i], t)) dp[i] = t;
            /*
            cout << "t = " << t << '\n';
            cout << "dp[" << i << "] = " << dp[i] << '\n';
            */
        }
    }

    cout << dp[n] << '\n';

    return 0;
}

Measured memory_bytes: 51292
import java.awt.Point;
import java.io.PrintWriter;
import java.util.*;

public class Main {
    static Scanner scanner = new Scanner(System.in);
    static PrintWriter out = new PrintWriter(System.out, false);

    static Set<Point> set = new HashSet<>();
    static List<List<Integer>> edge = new ArrayList<>();
    static boolean[] visited;
    public static void main(String[]$) {
        int n = scanner.nextInt();
        int m = scanner.nextInt();
        visited = new boolean[n];
        for (int i = 0; i < n; i++) {
            edge.add(new ArrayList<>());
        }
        for (int i = 0; i < m; i++) {
            int a = scanner.nextInt() - 1;
            int b = scanner.nextInt() - 1;
            edge.get(a).add(b);
            edge.get(b).add(a);
        }
        if (m % 2 == 1) {
            System.out.println(-1);
        } else {
            dfs(-1, 0);
        }
        out.flush();
    }

    static boolean dfs(int parent, int node) {
        visited[node] = true;
        int use = 0;
        for (int i : edge.get(node)) {
            if (i != parent && !set.contains(new Point(node, i)) && (visited[i] || dfs(node, i))) {
                set.add(new Point(i, node));
                out.println((node + 1) + " " + (i + 1));
                use++;
            }
        }
        if (use % 2 == 1 && parent != -1) {
            out.println((node + 1) + " " + (parent + 1));
        }
        return use % 2 == 0;
    }
}

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

int main(){
	int n,m,l,i,j,k,x;
	cin >> n >> m >> l;
	long a[n][m]={},b[m][l]={},c[n][l]={};
	for(i=0;i<n;i++){
		for(j=0;j<m;j++){
			cin >> x;
			a[i][j] = x;
		}
	}
	for(i=0;i<m;i++){
		for(j=0;j<l;j++){
			cin >> x;
			b[i][j] = x;
		}
	}
	for(i=0;i<n;i++){
		for(j=0;j<l;j++){
			for(k=0;k<m;k++){
			c[i][j] += a[i][k]*b[k][j];
			}
		}
	}
	for(i=0;i<n;i++){
		for(j=0;j<l;j++){
			cout << c[i][j];
			if(j<l-1){
				cout << ' ';
			}
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3348
#include <algorithm>
#include <array>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <utility>
#include <vector>

int main()
{
    int n, s;
    long long ans;
    const long long mod = 998244353;
    std::cin >> n >> s;
    std::vector<int> as(n);
    int sum = 0;
    for (auto& e : as) {
        std::cin >> e;
        sum += e;
    }
    std::vector<std::vector<int>> dp(n + 1, std::vector<int>(s + 1));
    dp[0][0] = 1;
    for (size_t i = 0; i < n; i++) {
        for (size_t j = 0; j <= s; j++) {
            int ps = as[i] + j;
            dp[i + 1][j] += dp[i][j] * 2 % mod;
            dp[i + 1][j] %= mod;
            if (ps <= s) {
                dp[i + 1][ps] += dp[i][j] % mod;
                dp[i + 1][ps] %= mod;
            }
        }
    }

    std::cout << dp[n][s] << "\n";
    return 0;
}


Measured memory_bytes: 38268
if __name__ == "__main__":
    n, k = map(lambda x: int(x), input().split())
    a = [1, 0]
    for i in range(n):
        a = [0] + [a[i - 1] + i * a[i] for i in range(1, len(a))] + [0]
    print(sum(a[:k + 1]) % (10 ** 9 + 7))



Measured memory_bytes: 7044
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

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

const int mod = 1e9+7;
const int MAX = 2000100;

ll fc[MAX]; // fc[i] := iの階乗
ll fci[MAX]; // fci[i] := iの階乗の逆元

ll modpow(ll a, ll b) {
    if ( ! b) return 1;
    if (b % 2) return (a * modpow(a, b-1)) % mod;
    ll t = modpow(a, b/2);
    return (t * t) % mod;
}

void init_fact() {
    fc[0] = fc[1] = 1;
    for (int i=2; i<MAX; ++i) {
        fc[i] = (fc[i-1] * i) % mod;
    }
    fci[0] = fci[1] = 1;
    for (int i=2; i<MAX; ++i) {
        fci[i] = (fci[i-1] * modpow(i, mod-2)) % mod;
    }
}

ll sum(int r, int c) {
    if (r < 0 || c < 0) return 0;
    ll res = 0;
    for (int i=1; i<=r+1; ++i) {
        ll x = 1;
        x *= fc[i+c];
        x %= mod;
        x *= fci[i];
        x %= mod;
        x *= fci[c];
        x %= mod;
        res += x;
        res %= mod;
    }
    return res;
}

int main() {
    init_fact();

    ll r1, c1, r2, c2;    
    cin >> r1 >> c1 >> r2 >> c2;

    ll ans = 0;
    ans += sum(r2, c2);
    ans %= mod;
    ans += mod - sum(r2, c1-1);
    ans %= mod;
    ans += mod - sum(r1-1, c2);
    ans %= mod;
    ans += sum(r1-1, c1-1);
    ans %= mod;
    cout << ans << endl;

    return 0;
}

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

int ctoi(char c) {
    int n = c - '0';
    return n;
}

int pow_int(int x, int n) {
    if (n == 0) {
        return 1;
    }else {
        int y = x;
        for (int i = 0; i < n-1; i++) {
            x *= y;
        }
        return x;
    }
}

int main() {
    long int h, w, ans;
    cin >> h >> w;
    if (h == 1 || w == 1) {
        cout << 1 << endl;
    }else {
        ans = ((h+1)/2)*((w+1)/2) + (h/2)*(w/2);
        cout << ans << endl;
    }
}


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

int main(){
    int n,m;
    cin >> n >> m;
    
    if(n>=m){
        cout << 0 << endl;
        return 0;
    }
    
    vector<int> x(m);
    rep(i,m) cin >> x[i];
    
    sort(x.begin(),x.end());
    int total = abs(x[m-1] - x[0]);
    
    vector<int> diff(m-1);
    rep(i,m-1){
        diff.push_back(abs(x[i]-x[i+1]));
    }
    
    sort(diff.begin(),diff.end());
    reverse(diff.begin(), diff.end());
    
    rep(i,n-1){
        total -= diff[i];
    }
    
    cout << total << endl;
}

Measured memory_bytes: 1408
#include<iostream>
#include<atcoder/all>
using namespace std;
typedef long long li;
#define binom2(n) ((n)*(n-1)/2)
#define rep(i,n) for(int i=0;i<(n);i++)
#define df 0
template<class T> void print(const T& t){ cout << t << "\n"; }
template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); }

struct mono{
  li v,c0,c1;
  mono(bool x){ v=0; c0=(!x); c1=x; };
  mono(){ v=0; c0=0; c1=0; };
  mono(li a,li b,li c){ v=a; c0=b; c1=c; };
  mono operator*(mono m){ return {v+m.v+c1*m.c0, c0+m.c0, c1+m.c1}; };
};
mono e(){return mono();}
mono op(mono m1, mono m2){ return m1*m2; }

std::ostream& operator<<(std::ostream& os, const mono& m){
  // ここでストリームに obj を書き込みます。
  cout << m.v;
  return os;
}

std::istream& operator>>(std::istream& os,mono& m){
  // ここでストリームに obj を書き込みます。
  int a; cin >>a;
  m=a;
  return os;
}

struct gr{
  bool flag;
  gr(bool x=0){ flag=x; };
  gr operator*(gr g){ return flag^g.flag; };
  mono operator*(mono m){
    li n=m.c0+m.c1;
    if(flag){
      m.v=binom2(n)-m.v-binom2(m.c0)-binom2(m.c1);
      swap(m.c0,m.c1);
    }
    return m;
  };
};
mono sayo(gr g,mono m){ return g*m; }
gr comp(gr a,gr b){return a*b;}
gr id(){return gr();}


int main(){
  int n,q; cin >>n >>q;
  vector<mono> vec(n); rep(i,n) cin >>vec[i];
  atcoder::lazy_segtree<mono,op,e,gr,sayo,comp,id> lz(vec);
  rep(_,q){
    int t,l,r; cin >>t >>l >>r; l--;
    if(t==1) lz.apply(l,r,1);
    else print(lz.prod(l,r));
  }
}


Measured memory_bytes: 20368
def bubble_sort(nums, n):
    count = 0
    flag = True
    while flag:
        flag = False
        for i in reversed(range(1, n)):
            if nums[i] < nums[i-1]:
                tmp = nums[i]
                nums[i] = nums[i-1]
                nums[i-1] = tmp
                count += 1
                flag = True

    nums_str = map(str, nums)
    print(" ".join(nums_str))
    print(count)

if __name__=="__main__":
    n = int(input())
    nums = list(map(int, input().split()))
    bubble_sort(nums, n)



Measured memory_bytes: 5600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> VI;

int main() {
  int n,d;
  cin >> n >>d;
 if(n%(2*d+1)==0) cout << n/(2*d+1) <<endl;
  else cout << n/(2*d+1)+1 << endl;
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MSET(x,y) memset(x,y,sizeof(x))
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define SZ size()
#define M 200005
#define ll long long
#define ld long double
#define INF 1e18
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define vll vector<ll>
#define sorrt(a) sort(a.begin(), a.end())
using namespace std;
ll MOD = 1000000007;
string yes = "YES\n";
string no = "NO\n";
#define PI 3.1415926535 


ll pre[M];


ll power(ll x, ll y, ll p) {
    ll res = 1;
    x = x % p; 
    while (y > 0) { 
      if (y & 1) 
            res = (res*x) % p; 
        y = y>>1;
        x = (x*x) % p; 
    } 
    return res; 
} 

int32_t main() {
  fastio;
  pre[0] =0,pre[1]=1,pre[2]=1;
  for(ll i=3;i<M;i++) {
    ll setBits = __builtin_popcount(i);
    if(i%setBits == 0) pre[i] = 1;
    else pre[i] = pre[i%setBits]+1;
  }
  ll n;
  cin>>n;
  string s;
  cin>>s;
  ll bits = 0;
  for(ll i=0;i<n;i++) {
    if(s[i] == '1') bits++;
  }
  ll s1=0,s2=0;
  if(bits>1) {
    for(ll i=0;i<n;i++) {
      if(s[i] == '1') {
        s1 = (s1 + power(2, n-1-i, bits-1)) % (bits-1);
        s2 = (s2 + power(2, n-1-i, bits+1)) % (bits+1);
      }
    }
    for(ll i=0;i<n;i++) {
      if(s[i] == '1') {
        ll f0 = pre[(bits-1+s1 - power(2, n-1-i, bits-1)) % (bits-1)] + 1;
        cout<<f0<<endl;
      } else {
        ll f1 = pre[(bits+1+s2 + power(2, n-1-i, bits+1)) % (bits+1)] + 1;
        cout<<f1<<endl;
      }
    }
  }
  if(bits == 1) {
    for(ll i=0;i<n;i++) {
      if(s[i] == '1') {
        s2 = (s2 + power(2, n-1-i, bits+1)) % (bits+1);
      }
    }
    for(ll i=0;i<n;i++) {
      if(s[i] == '1') {
        cout<<0<<endl;
      } else {
        ll f1 = pre[(2+s2+power(2, n-1-i, 2))%2]+1;
        cout<<f1<<endl;
      }
    }
  }
  if(bits == 0) {
    for(ll i=0;i<n;i++) {
      cout<<1<<endl;
    }
  }
}


Measured memory_bytes: 5340
c = str( input() )

abc = [ "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z" ]

print( abc[ abc.index( c ) + 1 ] )

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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) scanf("%d", &a[i]);
    vector<int> cnt(1000005);
    vector<int> m(1000005);
    rep(i,n) m[a[i]]++;
    bool flag = true;
    for(int i = 2; i <= 1000000; i++){
        int t = 0;
        if(cnt[i] != 0) continue;
        for(int j = i; j <= 1000000; j+=i){
            t += m[j];
            cnt[j]++;
        }
        if(t >= 2){
            flag = false;
            break;
        }
    }
    if(flag){
        cout << "pairwise coprime" << endl;
        return 0;
    }
    int g = a[0];
    rep(i,n) g = __gcd(g, a[i]);
    if(g == 1) cout << "setwise coprime" << endl;
    else cout << "not coprime" << endl;
}


Measured memory_bytes: 14848
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define all(a) (a).begin(), (a).end()


int main(){
    int K, X;
    cin >> K >> X;
    if(500 * K >= X) puts("Yes");
    else puts("No");
}


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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

#define ll long long
#define db double
#define el "\n"
#define ld long double
#define rep(i,n) for(int i=0;i<n;i++)
#define rev(i,n) for(int i=n;i>=0;i--)
#define rep_a(i,a,n) for(int i=a;i<n;i++)
#define tr(ds, it) for(auto it=ds.begin(); it!=ds.end(); it++)
#define rtr(ds, it) for(auto it=ds.rbegin(); it!=ds.rend(); it--)
#define all(ds) ds.begin(), ds.end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
typedef priority_queue <int> pq;
typedef vector< long long > vi;
typedef pair<long long, long long> ii;
#define o_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define graph vector<vi>

const ll mod = 1000000007;
ll po(ll x, ll n ){ 
    ll ans=1;
     while(n>0){
         if(n&1) ans=(ans*x)%mod;
         x=(x*x)%mod;
         n/=2;
     }
     return ans;
}



int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int T=1;
    //cin >> T;
    while(T--){
        int h,w;
        cin>>h>>w;
        int a[h][w];
        string s;
        rep(i,h){
            cin>>s;
            rep(j,w){
                if(s[j]=='#') a[i][j]=1;
                else a[i][j]=0;
            }
        }
        int dp[h][w]={};
        if(a[0][0]) dp[0][0]=1;
        rep_a(j,1,w){
            if(a[0][j]){
                if(a[0][j-1]) dp[0][j]=dp[0][j-1];
                else dp[0][j]=dp[0][j-1]+1;
            }
            else dp[0][j]=dp[0][j-1];
        }
        rep_a(i,1,h){
            if(a[i][0]){
                if(a[i-1][0]) dp[i][0]=dp[i-1][0];
                else dp[i][0]=dp[i-1][0]+1;
            }
            else dp[i][0]=dp[i-1][0];
        }
        rep_a(i,1,h){
            rep_a(j,1,w){
                if(a[i][j]){
                    if(a[i-1][j]) dp[i][j]=dp[i-1][j];
                    else dp[i][j]=dp[i-1][j]+1;
                    if(a[i][j-1]) dp[i][j]=min(dp[i][j], dp[i][j-1]);
                    else dp[i][j]=min(dp[i][j], dp[i][j-1]+1);
                }
                else{
                    dp[i][j]=min(dp[i-1][j], dp[i][j-1]);
                }
            }
        }
        // rep(i,h){
        //     rep(j,w) cout<<dp[i][j]<<" ";
        //     cout<<el;
        // }
        cout<<dp[h-1][w-1]<<el;

    }

    return 0;
}

Measured memory_bytes: 384
n = int(input())
s = list(input())
mod = 10**9+7
alp = [0] * 26

for i in range(n):
    alp[ord(s[i]) - ord("a")] += 1

ans = 1
for c in alp:
    if (c != 0):
        ans *= (c+1)

print((ans - 1) % mod)


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

#ifdef LOCAL
#include "../lib/dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

typedef long long ll;
typedef pair<int, int> P;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

void solve()
{
  int N, M;
  cin >> N >> M;
  vector<P> v;
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    v.push_back(P(a * 2 + 1, i)); // start
    v.push_back(P(b * 2, i)); // end
  }
  sort(v.begin(), v.end());
  dump(v);
  vector<int> used(M);
  int stamp = 1;
  int cnt = 0;
  for (int i = 0; i < v.size(); i++) {
    if (used[v[i].second] < stamp) {
      used[v[i].second] = stamp;
    } else {
      stamp++;
      cnt++;
    }
  }
  cout << cnt << endl;
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  // freopen("temp.1", "r", stdin);
  solve();
  return 0;
}

Measured memory_bytes: 2420
#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};

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

template <unsigned mod>
struct RollingHash
{
    vector<unsigned> hashed, power;

    inline unsigned mul(unsigned a, unsigned b) const
    {
        unsigned long long x = (unsigned long long)a * b;
        unsigned xh = (unsigned)(x >> 32), xl = (unsigned)x, d, m;
        asm("divl %4; \n\t"
            : "=a"(d), "=d"(m)
            : "d"(xh), "a"(xl), "r"(mod));
        return m;
    }

    RollingHash(const string &s, unsigned base = 10007)
    {
        int sz = (int)s.size();
        hashed.assign(sz + 1, 0);
        power.assign(sz + 1, 0);
        power[0] = 1;
        for (int i = 0; i < sz; i++)
        {
            power[i + 1] = mul(power[i], base);
            hashed[i + 1] = mul(hashed[i], base) + s[i];
            if (hashed[i + 1] >= mod)
                hashed[i + 1] -= mod;
        }
    }

    unsigned get(int l, int r) const
    {
        unsigned ret = hashed[r] + mod - mul(hashed[l], power[r - l]);
        if (ret >= mod)
            ret -= mod;
        return ret;
    }

    unsigned connect(unsigned h1, int h2, int h2len) const
    {
        unsigned ret = mul(h1, power[h2len]) + h2;
        if (ret >= mod)
            ret -= mod;
        return ret;
    }

    int LCP(const RollingHash<mod> &b, int l1, int r1, int l2, int r2)
    {
        int len = min(r1 - l1, r2 - l2);
        int low = -1, high = len + 1;
        while (high - low > 1)
        {
            int mid = (low + high) / 2;
            if (get(l1, l1 + mid) == b.get(l2, l2 + mid))
                low = mid;
            else
                high = mid;
        }
        return (low);
    }
};

using RH = RollingHash<1000000007>;

bool check(ll x, string &s, RH &rh, int n)
{
    for (int i = 0; i < n - x + 1; i++)
    {
        auto hash1 = rh.get(i, i + x);
        for (int j = i + x; j < n - x + 1; j++)
        {
            auto hash2 = rh.get(j, j + x);
            if (hash1 == hash2)
            {
                return true;
            }
        }
    }
    return false;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    string s;
    cin >> n >> s;
    RH rh(s);
    int ng = n / 2 + 1;
    int ok = 0;
    while (abs(ok - ng) > 1)
    {
        int mid = (ok + ng) / 2;
        if (check(mid, s, rh, n))
        {
            ok = mid;
        }
        else
        {
            ng = mid;
        }
    }
    cout << ok << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, s, n) for(int i = s; i < n; i++)

int main() {
    ll x, y;
    cin >> x >> y;
    ll ans = 1000000100;

    ll x_inv = -x, y_inv = -y;
    if(x_inv <= y) {
        ans = min(1+y-x_inv, ans);
    }
    if(x <= y) {
        ans = min(y-x, ans);
    }
    if(x <= y_inv) {
        ans = min(y_inv-x+1, ans);
    }
    if(x_inv <= y_inv) {
        ans = min(y_inv-x_inv+2, ans);
    }
    cout << ans << endl;
    
    return 0;
}

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

int main(){
  int n;
  cin >> n;
  ll ans = 0;
  for(int i=1;i<=n;i++){
    if(i%3==0 || i%5==0)continue;
    ans += i;
  }
  cout << ans << endl;
}

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

#define int long long
#define pii pair<int,int>
#define vi vector<int>
#define pb push_back
#define f first
#define s second
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

using namespace std;

signed main(){
	
	string s, t, u;
	int a, b;
	cin >> s >> t >> a >> b >> u;

	if (strcmp(s.c_str(),u.c_str()) == 0){
		a -= 1;
	}
	else{
		b -= 1;
	}
	
	cout << a << " " << b << endl;
	return 0;
}



/*

*/

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

int main()
{
    int N, K;
    cin >> N >> K;
    int Ai;
    vector<int> A;
    for(int i=0;i<N;i++){
        cin >> Ai;
        A.push_back(Ai);
    }
    {
        int nmin = INT_MAX;
        auto itr_min = min_element(A.begin(), A.end());
        auto nleft  = distance(A.begin(), itr_min);
        auto nright = distance(itr_min, A.end())-1;
        for(int i=0;i<K;i++){
            if(nleft  - i       < 0) continue;
            if(nright - (K-1-i) < 0) continue;
            auto n = 1;
            n += (nleft  - i       + (K-2))/(K-1);
            n += (nright - (K-1-i) + (K-2))/(K-1);
            if(n<nmin) nmin = n;
        }
        cout<<nmin<<endl;
    }
    return 0;
}


Measured memory_bytes: 892
/* be name Khoda */
#include <bits/stdc++.h>
using namespace std;

const int N = 200 * 1001;
int n, k, l, a[2][N], cnt;
vector<int> adj[2][N];
bool mark[2][N];
map<pair<int, int>, int> m;

void dfs(int u, int par, int kind) {
	mark[kind][u] = true;
	a[kind][u] = cnt;
	for (auto v : adj[kind][u]) {
		if (!mark[kind][v]) {
			dfs(v, u, kind);
		}
	}
}
int main() {
	cin >> n >> k >> l;
	for (int i = 0; i < k; i++) {
		int u, v;
		cin >> u >> v;
		u--, v--;
		adj[0][u].push_back(v);
		adj[0][v].push_back(u);
	}
	for (int i = 0; i < l; i++) {
		int u, v;
		cin >> u >> v;
		u--, v--;
		adj[1][u].push_back(v);
		adj[1][v].push_back(u);
	}
	for (int i = 0; i < n; i++) {
		if (!mark[0][i]) {
			dfs(i, -1, 0);
			cnt++;
		}
	}
	cnt = 0;
	for (int i = 0; i < n; i++) {
		if (!mark[1][i]) {
			dfs(i, -1, 1);
			cnt++;
		}
	}
	for (int i = 0; i < n; i++)
		m[{a[0][i], a[1][i]}]++;
	for (int i = 0; i < n; i++) 
		cout << m[{a[0][i], a[1][i]}] << " ";
}


Measured memory_bytes: 28288
def searchMaxIndex(arr):
    if len(arr) == 0:
        return -1

    result = 0
    for i in range(len(arr)):
        if arr[i] > arr[result]:
            result = i

    return result

def pullValueBiIndex(arr, index):
    result = arr[index]
    arr.pop(index)
    return result

card_count = int(input())
cards = input()
cards = [int(value) for value in cards.split(' ')]

alice = 0
bob = 0

while len(cards) > 0:
    index = searchMaxIndex(cards)
    alice += pullValueBiIndex(cards, index)

    index = searchMaxIndex(cards)
    if index == -1:
        break
    bob += pullValueBiIndex(cards, index)

print(alice - bob)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define MOD 1000000007

int main(){
  int N, M;
  cin >> N >> M;
  vector<int> k(M), p(M);
  vector<vector<int>> s(M);
  for (int i = 0; i < M; i++) {
      cin >> k.at(i);
      for (int j = 0; j < k.at(i); j++) {
          int tmp;
          cin >> tmp;
          tmp--;
          s.at(i).push_back(tmp);
      }
  }
  for (int i = 0; i < M; i++) cin >> p.at(i);

  vector<int> sw;
  ll ans = 0;
  bool flag = true;
  // bit全探索
  for (int bit = 0; bit < (1 << N); ++bit) {
      flag = true;
      sw = vector<int>(N, 0);
      //cout << bit << endl;
      for (int i = 0; i < N; i++) {
          if (bit & (1 << i)) sw.at(i) = 1;
      }
      for (int j = 0; j < M; j++) {
          int sum = 0;
          for (int l = 0; l < k.at(j); l++) {
              if (sw.at( s.at(j).at(l) )) sum++;
          }
          if (sum % 2 != p.at(j)) flag = false;
      }
      if (flag) ans++;
  }
  cout << ans << endl;
  return 0;
}


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

int main(){
  int N;
  cin >> N;
  
  vector<int> W(N);
  rep(i,N){
    cin >> W.at(i);
  }
  
  int min = 10000;
  rep(i,N){
    int S1,S2;
    S1 = S2 = 0;
    rep(j,N){
      if(i > j) S1 += W.at(j);
      else S2 += W.at(j);
    }
    int sub = abs(S1-S2);
    if(min > sub) min = sub;
  }
  
  cout << min << endl;
  
}

Measured memory_bytes: 256
N = input('')
N=int(N)
fizzbuzz = list(range (1, N+1))
fizzbuzz = fizzbuzz 
sumnum = 0

for i in range (len(fizzbuzz)):
    if fizzbuzz[i]%3==0  and fizzbuzz[i]%5==0:
        fizzbuzz[i] = "FizzBuzz"
    elif fizzbuzz[i]%3==0:
        fizzbuzz[i] = "Fizz"
    elif fizzbuzz[i]%5==0:
        fizzbuzz[i] = "Buzz"
    else:
        sumnum +=  fizzbuzz[i]

print(sumnum)


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

typedef vector<int> vi;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n,m,c;
    while(cin >> n >> m >> c) {
        vi b(m);
        for(int i = 0; i < m; i++) {
            cin >> b[i];
        }
        int ans = 0;
        for(int i = 0; i < n; i++) {
            int s = c;
            for(int i = 0; i < m; i++) {
                int a; cin >> a;
                s += a*b[i];
            }
            ans += (s > 0);
        }
        cout << ans << '\n';
    }
    return 0;
}

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

int main(){
  int N, M;
  cin>>N>>M;
  map<int, int> suki;
  int K;
  cin>>K;
  for(int j=0; j<K; j++){
    int a;
    cin>>a;
    suki[a]=1;
  }
  for(int i=1; i<N; i++){ //i番目の人
    int K;
    cin>>K; //答えた品数
    for(int j=0; j<K; j++){
        int a;
        cin>>a;
        if(suki.count(a)) suki[a]++;
    } //j
  } //i
  int count=0;
  for (auto p : suki) {
  auto v = p.second;
  if(v==N) count++;
}
  cout<<count<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int n , count = 0 , inning = 0 , point = 0 , base = 0;
	char s[10];
	scanf("%d" , &n);
	while(inning!=n){
		scanf("%*c%s" , s);
		if(s[0] == 'H' && s[1] == 'I'){
			base++;
			if(base>3){
				point++;
				base--;
			}
		}else if(s[0] == 'O'){
			count++;
		}else{
			point += base + 1;
			base = 0;
		}

		if(count == 3){
			printf("%d\n" , point);
			count = base = point = 0;
			inning++;
		}
	}
	return 0;
}

Measured memory_bytes: 0
N,x=map(int, input().split())
a=list(map(int, input().split()))
ans = 0
for i in range(N-1):
 if a[i]+a[i+1]>x:
  ans+=a[i]+a[i+1]-x
  if a[i] > x:
   a[i+1] = 0
  else:
   a[i+1] -= a[i] + a[i+1] - x

print(ans)


Measured memory_bytes: 14132
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define show(x) cout << #x << " = " << (x) << endl;
using namespace std;
using ll = long long;
using pii = pair<int,int>;
//参考: http://kmjp.hatenablog.jp/entry/2018/11/26/0900
ll m[1234567];
ll c[1234567];
ll mc[1234567];
int main(){
    int n;
    string s;
    int q;
    cin >> n >> s >> q;
    rep(i,n){
        if(s[i] == 'M')m[i]++;
        if(s[i] == 'C')c[i]++;
    }
    rep(i,n){
        m[i+1] += m[i];
        c[i+1] += c[i];
    }
    rep(i,n){
        if(s[i] == 'C'){
            mc[i] = m[i];
        }
    }
    rep(i,n){
        mc[i+1] += mc[i];
    }
    while(q--){
        int k;
        cin >> k;
        k--;
        ll ans = 0;
        rep(i,n){
            if(s[i] == 'D'){
                int pos = min(n,i+k);
                ans += mc[pos]-mc[i] - m[i]*(c[pos]-c[i]);
            }
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 29956
import math
class Test:
    pass
n, x = map(int, input().split())
l = []
lose = 0
for _ in range(n):
    t = Test()
    t.b, t.l, t.u = map(int, input().split())
    t.total = t.b * t.l + (x - t.b) * t.u
    l.append(t)
    lose += t.b * t.l
l = sorted(l, key=lambda t: t.total, reverse=True)

sum_upto_i = 0
for i, ti in enumerate(l):
    sum_upto_i += ti.total
    if sum_upto_i >= lose:
        break

min_needed = x
for j, tj in enumerate(l):
    if j <= i:
        lose_left = lose - (sum_upto_i - tj.total)
    else:
        lose_left = lose - (sum_upto_i - ti.total)
    if tj.b * tj.l < lose_left:
        lose_left -= tj.b * tj.l
        if (x - tj.b) * tj.u < lose_left:
            continue
        else:
            needed = tj.b + math.ceil(lose_left / tj.u)
    else:
        needed = math.ceil(lose_left / tj.l)
    if min_needed > needed:
        min_needed = needed
print(x * i + min_needed)

Measured memory_bytes: 45612
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define r0 return 0;
#define f(k,i,n,j) for(ll k=i;k<=n;k=k+j)
#define cin(a) cin>>a;
#define loop while(t--)
#define vi vector<int>
#define vii vector<long long int>
#define crap ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define mod 1000000007
#define SORT(v) sort(v.begin(),v.end());
int main()
{
    int k,x;
    cin>>k>>x;
    if((k*500)>=x)
    cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

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

using namespace std;

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

    vector<int> cnt(100002, 0);

    for(int i = 0; i < N; i++) {
    	cnt[A[i]]++;
    	cnt[A[i] + 1]++;
    	cnt[A[i] + 2]++;
    }

    int ret = 0;
    for (int i = 0; i < 100002; i++) {
    	ret = max(ret, cnt[i]);
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, l[101];
  cin >> n;
  int cnt = 0;
  for (int i = 0; i < n; i++) cin >> l[i];
  sort(l, l+n);
  for (int i = 0; i < n-2; i++) {
    for (int j = i+1; j < n-1; j++) {
      if (l[j] == l[i]) continue;
      for (int k = j+1; k < n; k++) {
        if (l[k] == l[j]) continue;
        if (l[i] + l[j] > l[k]) cnt++;
      }
    }
  }
  cout << cnt;
  return 0;
}

Measured memory_bytes: 3664
#include <stdio.h>

int main(void){
	int n, p, c[50], i, count, sum;
	scanf("%d%d",&n,&p);
	while(n != 0 || p != 0){
		for(i = 0;i < n;i++)
			c[i] = 0;
		sum = p; count = 2;
		while(count != 1 || sum != 0){
			for(i = 0;i < n;i++){
				if(sum == 0){
					sum = c[i];
					c[i] = 0;
				}
				else{
					sum--;
					c[i]++;
				}
			}
			for(i = 0, count = 0;i < n;i++)
				if(c[i] != 0) count++;
		}
		for(i = 0;i < n;i++)
			if(c[i] != 0) printf("%d\n",i);
		scanf("%d%d",&n,&p);
	}
	return 0;
}

Measured memory_bytes: 1028
# -*- coding: utf-8 -*-
s = input()
s = s.replace("BC", "X")
count = 0
a_stack = 0
for idx, char in enumerate(s):
    if char == "A":
        a_stack += 1
    elif char == "X":
        count += a_stack
    else:
        a_stack = 0
print(count)

Measured memory_bytes: 3628
#include <iostream>
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

int n, m, x, y;
int a[100];
int b[100];

int main() {
	int i, j;
	
	cin >> n >> m >> x >> y;
	rep(i, n) cin >> a[i];
	rep(i, m) cin >> b[i];
	
	for (i = x + 1; i < y; i++) {
		rep(j, n) if (a[j] >= i) break;
		if (j < n) continue;
		rep(j, m) if (b[j] < i) break;
		if (j < m) continue;
		cout << "No War" << endl;
		return 0;
	}
	
	cout << "War" << endl;
	return 0;
}

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

int n;
vector<ll> A;
ll sum;

void input() {
    cin >> n;
    A = vector<ll>(n);
    sum = 0;
    rep(i, n) {
        cin >>A[i];
        sum += A[i];
    }
}

int main() {
    input();
    ll ans = sum;
    ll x = 0;
    rep(i, n) {
        x += A[i];
        ans = min(ans, abs(sum - 2 * x));
    }
    cout << ans << endl;
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#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 mp make_pair
#define ins insert

using namespace std;

int dfs(int v, int p, vector<vi> &G, vi &ord, vi &low, vi &depth, int &idx)
{
    int cnt=0;
    ord[v] = low[v] = idx++;
    for(auto u:G[v]){
        if (u==p) continue;
        if (ord[u]!=-1){
            chmin(low[v],ord[u]);
            continue;
        }
        cnt++;
        depth[u] = depth[v]+1;
        dfs(u,v,G,ord,low,depth,idx);
        chmin(low[v],low[u]);
    }
    return cnt;
}

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,M; cin>>N>>M;
    vector<vi> G(N);
    rep(i,M){
        int a,b; cin>>a>>b;
        G[a].pb(b);
        G[b].pb(a);
    }
    vi ord(N,-1),low(N),depth(N);
    int idx=0;
    int dim0 = dfs(0,-1,G,ord,low,depth,idx);
    vi ans;
    if (dim0>1) ans.pb(0);
    FOR(v,1,N-1){
        bool yes=false;
        for(auto u:G[v]){
            if (ord[v]<=low[u] && depth[v]+1==depth[u]){
                yes = true;
                break;
            }
        }
        if (yes) ans.pb(v);
    }
    for(auto e:ans) cout<<e<<"\n";
    return 0;
}



Measured memory_bytes: 5008
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000000000000
#define MOD 1000000007
typedef pair<int, int> P;

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int mod_pow(int n, int p, int m) {
	if (p == 0) return 1;
	if (p % 2 == 0) {
		int t = mod_pow(n, p / 2, m);
		return (t * t) % m;
	}
	return n * mod_pow(n, p - 1, m) % m;
}
int extGCD(int a, int b, int& x, int& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}
int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int digit(int x) {
	int cnt = 0;
	while (x > 0) {
		cnt += x % 10;
		x /= 10;
	}
	return cnt;
}
int read() {
	int tmp;
	cin >> tmp;
	return tmp;
}
int xor128() {
	static int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
	int t = (x xor (x << 11));
	x = y; y = z; z = w;
	return (w = (w xor (w >> 19)) xor (t xor (t >> 8)));
}

class UnionFind {
private:
	vector<int>par;
public:
	//宣言
	UnionFind(int n) {
		for (int i = 0; i < n; i++) par.push_back(-1);
	}

	//根を求める
	int root(int x) {
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

	//同じグループか
	bool same(int x, int y) {
		return root(x) == root(y);
	}

	//併合
	void unite(int x, int y) {
		x = root(x), y = root(y);
		if (x == y) return;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return;
	}

	//連結成分のサイズ
	int size(int x) {
		return -par[root(x)];
	}
};

signed main() {
	int n;
	cin >> n;
	P p[55];
	rep(i, n) {
		cin >> p[i].first >> p[i].second;
	}
	int mi = n;
	rep(i, n) {
		for (int j = i + 1; j < n; j++) {
			int a = p[j].first - p[i].first, b = p[j].second - p[i].second;
			//cout << a << " " << b << endl;
			UnionFind uf(n);
			int cnt = 0;
			rep(k, n) {
				rep(l, n) {
					//cout << p[k].first << " " << p[k].second << " " << p[l].first << " " << p[l].second << " " << endl;
					//cout<<p[l].first-p[k].first<<" "<<p[l].second-p[]
					if (p[l].first - p[k].first == a && p[l].second - p[k].second == b) {
						if (!uf.same(k, l)) {
							cnt++;
						}
						uf.unite(k, l);
					}
				}
			}
			mi = min(mi, n - cnt);
		}
	}
	cout << mi << endl;
		
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <unordered_map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e15;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
typedef pair<ll,ll> P;
typedef pair<double,double> point;
const ll MAX = 200005;
constexpr ll nx[8] = {1,0,-1,0,1,-1,1,-1};
constexpr ll ny[8] = {0,1,0,-1,1,1,-1,-1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    vector<ll> a(100001,0);
    ll b;
    ll ans = 0;
    rep(i,n){
        cin >> b;
        a[b]++;
        ans += b;
    }
    ll q;
    cin >> q;
    ll c,d;
    rep(i,q){
        cin >> c >> d;
        ans -= a[c]*c;
        ans += a[c]*d;
        a[d] += a[c];
        a[c] = 0;
        PRINT(ans);
    }
}


Measured memory_bytes: 3972
import typing
n = int(input())

res = 0
str_num = ""


def dfs(str_num: str, i: int, finish:int):
    global res
    if i == finish:
        # print(str_num)
        if str_num and int(str_num) <= n and len(set(str_num)) == 3:
            res += 1
            # print(res, str_num)
        return 0
    dfs(str_num + "3", i + 1, finish)
    dfs(str_num + "5", i + 1, finish)
    dfs(str_num + "7", i + 1, finish)
    # dfs(str_num, i + 1)


if __name__ == "__main__":
    for i in range(3, 10):
        dfs(str_num, 0, i)
    print(res)


Measured memory_bytes: 10256
n = int(input())
a = list(map(int, input().split()))
b = 0
even = 0
for i in a:
  if i % 2 == 0:
    even += 1
  if i % 2 == 0 and (i % 3 == 0 or i % 5 ==0):
    b += 1
if b == even:
  print("APPROVED")
else:
  print("DENIED")

Measured memory_bytes: 9080