akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int n;
vector<int> ans[100000 + 5];

void solve(int k) {
    int cur = 1;
    puts("Yes");
    printf("%d\n", k);

    for(int i = 1; i <= k; ++i) {
        for(int j = i + 1; j <= k; ++j) {
            ans[i].push_back(cur);
            ans[j].push_back(cur ++);
        }
    }

    for(int i = 1; i <= k; ++i) {
        printf("%d ", (int) ans[i].size());
        for(auto v : ans[i]) printf("%d ", v);
        puts("");
    }
    exit(0);
}

int main() {
    scanf("%d", &n);
    for(int i = 1; i <= 1000; ++i) {
        if(1ll * i * (i - 1) / 2 == n) {
            solve(i);
            break;
        }
    }
    return puts("No"), 0;
}


Measured memory_bytes: 4608
#include<bits/stdc++.h>
using namespace std;
inline int read()
{
	register int number_read=0,if_ok_read=1;
	char ch_read=getchar();
	while(ch_read<'0'||ch_read>'9')
	{
		if(ch_read=='-')
			if_ok_read=-1;
		ch_read=getchar();
	}
	while(ch_read>='0'&&ch_read<='9')
	{
		number_read=number_read*10+ch_read-'0';
		ch_read=getchar();
	}
	return number_read*if_ok_read;
}
inline void write(register int x_write)
{
    if(x_write<0)
	{
    	putchar('-');
		x_write=-x_write;
	}
    if(x_write>9)
		write(x_write/10);
    putchar(x_write%10+'0');
    return ;
}
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int a=read(),b=read(),h=read();
	write((a+b)*h/2);
	putchar('\n');
	return 0;
}


Measured memory_bytes: 256
N = int(input())
A = map(int,input().split())

flag = True

for x in A:
    mod2 = x % 2
    if mod2 == 0:
        mod3 = x % 3
        mod5 = x % 5
        if mod3 != 0 and mod5 != 0:
            flag = False
if flag == True:
    print("APPROVED")
else:
    print("DENIED")

Measured memory_bytes: 3060
#include<stdio.h>
int main(){
double a,b[4];
int i,e,j,c[4];
for(i=0;i<4;i++){
b[i]=100;
}
for(j=0;j<3;j++){
for(i=0;i<8;i++){
scanf("%d %lf\n",&e,&a);
if(a<b[0]){
if(b[1]<b[2]){
b[3]=b[2];
c[3]=c[2];
b[2]=b[1];
c[2]=c[1];
}
else if(b[1]<b[3]){
b[3]=b[1];
c[3]=c[1];
}
b[1]=b[0];
c[1]=c[0];
b[0]=a;
c[0]=e;
}
else if(a<b[1]){
if(b[1]<b[2]){
b[3]=b[2];
c[3]=c[2];
b[2]=b[1];
c[2]=c[1];
}
else if(b[1]<b[3]){
b[3]=b[1];
c[3]=c[1];
}
b[1]=a;
c[1]=e;
}
else if(a<b[2]){
b[3]=b[2];
c[3]=c[2];
b[2]=a;
c[2]=e;
}
else if(a<b[3]){
b[3]=a;
c[3]=e;
}
}
printf("%d %.2f\n",c[0],b[0]);
printf("%d %.2f\n",c[1],b[1]);
b[1]=100,b[0]=100;
}
printf("%d %.2f\n%d %.2f\n",c[2],b[2],c[3],b[3]);
return 0;
}


Measured memory_bytes: 1860
#include<bits/stdc++.h>
using namespace std;
#define debug(x) cout << '>' << #x << ':' << x << endl;
#define ll long long
int arr[60];
int n, p;

int main() {

	double w, h, x, y;
	cin >> w >> h >> x >> y;
	cout << setprecision(12) << w * h / 2 << " " << ((2 * x) == w
			&& (2 * y) == h )<< endl;
}


Measured memory_bytes: 3728
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <utility>
#include <algorithm>
#include <string>
#include <queue>
#include <stack>
#include <tuple>
#include <list>
#include <set>
#include <map>
#include <functional>
#include <cmath>
#include <cstring>
#include <cstdlib>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;

#define xx first
#define yy second
#define $1 first
#define $2 second

void solveCase() {
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	ll n; cin >> n;
	ll sum = 0;
	for (int i = 1; i <= n; i++) {
		bool f = false;
		if (i % 3 == 0) { f = true; }
		if (i % 5 == 0) { f = true; }
		if (!f) {
			sum += i;
		}
	}
	cout << sum;
}

int main() {

#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
#endif
	solveCase();
}

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

using namespace std;
int main(){
    long long X, K, D;
    long long ans;
    cin >> X >> K >> D;
    if(X < 0) X = -1 * X;
    long long temp = X / D;
    if(K < X / D){
        ans = X - K * D;
        cout << ans << endl;
        return 0;
    }
    if((K - temp) % 2 == 0) ans = X - D * temp;
    else ans = (X - D * (temp+1)) * -1;
    cout << ans << endl;

    return 0;
}



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

int main()
{
  int n,k,q;
  cin >> n >> k >> q;
  int i;
  int a[q];
  for(i=0;i<q;++i){
    cin >> a[i];
  }
  int p[n];
  for(i=0;i<n;++i){
    p[i]=0;
  }
  
  for(i=0;i<q;++i){
    ++p[a[i]-1];
  }
  
  for(i=0;i<n;++i){
    if(p[i]>(q-k)){
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }
  }
  
  return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N; cin>>N;
  string S; cin>>S;
  vector<int>R(N,0);
  vector<int>G(N,0);
  vector<int>B(N,0);
  int count=0;
  for(int i=0;i<N;i++){
    if(S.at(i)=='R')R[i]=1;
    else if(S.at(i)=='G')G[i]=1;
    else{
      B[i]=1;
      count++;
    }
  }
  long long ans=0;
  for(int i=0;i<N;i++){
    if(R[i]==1){
      for(int j=0;j<N;j++){
        if(G[j]==1){
          ans+=count;
          if(min(i,j)*2-max(i,j)>=0)if(B[min(i,j)*2-max(i,j)]==1)ans--;
          if(max(i,j)*2-min(i,j)<N)if(B[max(i,j)*2-min(i,j)]==1)ans--;
          if((max(i,j)-min(i,j))%2==0&&B[min(i,j)+(max(i,j)-min(i,j))/2]==1)ans--;
        }
      }
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	int n, m; i64 p; scanf("%d%d%lld", &n, &m, &p);
	std::vector<int> loop, a(m), b(m);
	std::vector<i64> c(m);
	std::vector<std::vector<int>> g(n), rg(n);
	for(int i = 0; i < m; i++) {
		scanf("%d%d%lld", &a[i], &b[i], &c[i]);
		a[i]--; b[i]--;
		
		if(a[i] == b[i]) {
			loop.push_back(i);
			continue;
		}
		
		g[a[i]].push_back(b[i]);
		rg[b[i]].push_back(a[i]);
	}

	// s からたどり着けるか
	auto canReach = [](std::vector<std::vector<int>>& g, int s) {
		std::vector<bool> ret(g.size(), false); ret[s] = true;
		std::queue<int> qu; qu.push(s);
		while(!qu.empty()) {
			auto p = qu.front(); qu.pop();

			for(auto e: g[p]) {
				if(ret[e]) continue;
				ret[e] = true;
				qu.push(e);
			}
		}
		return ret;
	};
	std::vector<bool> from1 = canReach(g, 0), fromN = canReach(rg, n - 1);
	
	for(auto i: loop) {
		// 得をする自己ループ
		if(c[i] - p > 0 and from1[a[i]] and fromN[a[i]]) {
			printf("-1\n");
			return 0;
		}
	}

	std::vector<std::vector<std::pair<int, i64>>> G(n);
	for(int i = 0; i < m; i++) {
		if(a[i] == b[i]) continue; // ループは不必要
		if(!from1[a[i]] or !fromN[b[i]]) continue; // 通るとゴールできない
		G[a[i]].push_back({b[i], p - c[i]});
	}
	
	const i64 INF = 1LL << 60;
	std::vector<i64> dist(n, INF); dist[0] = 0;
	for(int i = 0; i < n; i++) {
		for(int v = 0; v < n; v++) {
			for(auto e: G[v]) {
				if(dist[v] != INF and dist[e.first] > dist[v] + e.second) {
					dist[e.first] = dist[v] + e.second;
					if(i == n - 1) {
						printf("-1\n");
						return 0;
					}
				}
			}
		}
	}

	printf("%lld\n", std::max(0LL, -dist[n - 1]));
	return 0;
}


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

using namespace std;

using ll = long long;

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

    int p, q, r; cin >> p >> q >> r;
    cout << min(p + q, min(q + r, r + p)) << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<map>
#include<queue>

using namespace std;

int main(void){
    string S;
    map<char, queue<char>> m;
    for(char c = 'a'; c <= 'c'; c++){
        cin >> S;
        for(auto itr = S.begin(); itr != S.end(); itr++) m[c].push(*itr);
    }
    char c = 'a';
    while(true){
        if(m[c].empty()){
            cout << (char)(c & (0xDF)) << endl;
            return 0;
        }
        char buf = m[c].front();
        m[c].pop();
        c = buf;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
    public class Main {
     
    	public static void main(String[] args) {
    		Scanner scan=new Scanner(System.in);
    		double L=Double.parseDouble(scan.next());
    		
    		double ans=Math.pow(L/3, 3);
    		
    		System.out.print(ans);
    }
    }
// end 

Measured memory_bytes: 22228
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <numeric>
#include <bitset>

using namespace std;
using ll = long long;
using ld = long double;
const ll mod =  1000000007;
const ll inf = 1e18;

#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP_FROM(i, j, n) for (ll i = (j); i < (n); ++i)
#define all(x) (x).begin(),(x).end()

ll power(ll base, ll exponent){ if(exponent % 2){ return power(base, exponent - 1) * base % mod; }else if(exponent){ ll root_ans = power(base, exponent / 2); return root_ans * root_ans % mod; }else{ return 1; }}
ll inverse(ll x){ return power(x, mod - 2);}
ll gcd(ll a, ll b) {if(a < b) gcd(b, a);ll r;while(r=a%b) {a=b;b=r;}return b;}
template<typename T> ll sum(T begin, T end) {return accumulate(begin, end, 0ll);}
struct combination{ vector<ll> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } ll C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };


int bsearch(const vector<ll>& a, ll x){
  int lft = 0;
  int rgt = a.size();
  while (rgt - lft > 1) {
    int mid = (lft + rgt) / 2;
    if(a[mid] < x) {
      lft = mid;
    }
    else {
      rgt = mid;
    }
  }
  return lft;
}

signed main() {
  ios::sync_with_stdio(false);
  ll n;
  cin >> n;
  vector<int> a(n+1);
  vector<int> b(n+1);
  REP(i, n) cin >> a[i+1]; 
  for (int i = n; i > 0; i--){
    b[i] = a[i];
    REP_FROM(j, 2, n+1) {
      if(i*j > n) break;
      b[i] ^= b[i*j];
    }
    // REP_FROM(j, 1, n) {
    //   if(i*j > n) break;
    //   b[i] ^= a[i*j];
    // }
  }
  cout << sum(all(b)) << endl;
  REP(i, n+1) {
    if(b[i]) {
      cout << i << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
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; }
using namespace std;

int main(){
    Init();
    ll n; cin >> n;

    ll cRange = n/4;
    ll dRange = n/7;

    for(ll i=0; i<=cRange; i++){
        for(ll j=0; j<=dRange; j++){
            if(n == 4*i + 7*j){
                Yes();
                return 0;
            }
        }
    }
    No();
}

Measured memory_bytes: 256
//
//
//  ad-algoD.cpp - created by us162022
//
#include <iostream>
using namespace std;
int find(int join[],int x){
  if(x==join[x])
    return x;

  return find(join,join[x]);
}
int main(int argc, char *argv[])
{
  int n,m,join[100000],num[100000],s,t;
  cin >> n >> m;

  for(int i=0; i<n; i++){
    join[i] = i;
    num[i] = 0;
  }

  for(int i=0; i<m; i++){
    cin >> s >> t;
    s = find(join,s);
    t = find(join,t);

    if(s!=t){
      if(num[s] < num[t])
	join[s] = t;
      
      else{
	join[t]=s;
	if(num[s]==num[t])
	  num[s]++;
      }

    }
  }

  int q;
  cin >> q;

  for(int i=0; i<q; i++){
    cin >> s >> t;

    if(find(join,s)==find(join,t))
      cout << "yes\n";

    else
      cout << "no\n";
  }
}

Measured memory_bytes: 3848
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String abc = sc.nextLine();
		int k = Integer.parseInt(sc.nextLine());

		int max = 0;
		int ans = 0;
		for (String s : abc.split(" ")) {
			int i = Integer.parseInt(s);
			if (i > max) {
				ans += max;
				max = i;
			} else {
				ans += i;
			}
		}

		System.out.println(ans + max * ((int) Math.pow(2, k)));

		sc.close();
	}
}

Measured memory_bytes: 21844
#include <stdio.h>


int main(void){
  int a,b,c,w,n1=0,n2=0,n3=0,n=0;

  while(1){
    scanf("%d", &a);
    scanf("%d", &b);
    scanf("%d", &c);

    if(a+b<=c||b+c<=a||c+a<=b){
      break;
    }
    n++;

    if(a>b){
      w=a;
      a=b;
      b=w;
    }
    if(b>c){
      w=b;
      b=c;
      c=w;
    }

    if(b*b+a*a-c*c>0){
      n1++;
    }
    else if(b*b+a*a-c*c<0){
      n2++;
    }
    else{
      n3++;
    }
  }

  printf("%d %d %d %d\n",n,n3,n1,n2);
  return 0;
}



Measured memory_bytes: 2004
#include<iostream>
#include<string>
#include<algorithm>

int main(){
    int n;
    std::string s;

    std::cin >> n >> s;

    for(int a = 0; a < s.size() - 1; a++){
        if(s[a] == s[a + 1]){
            s.erase(s.begin() + a + 1);

            a -= 1;
        }
    }

    std::cout << s.size() << std::endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t,y=1;
    //cin>>t;
    t=1;
    while(t>0)
    {
        t--;
        ll n,i,j,k,flag=0;
        cin>>n;
        ll h[n+1],a[n+1];
        for(i=1;i<=n;i++)
        {
            cin>>h[i];
        }
        a[1]=0;a[2]=abs(h[2]-h[1]);
        for(i=3;i<=n;i++)
        {
            a[i]=min(a[i-1]+abs(h[i]-h[i-1]),a[i-2]+abs(h[i]-h[i-2]));
        }
        cout<<a[n]<<endl;
    }    
	return 0;
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

    private static final Scanner SCANNER = new Scanner(System.in);

    static int readOneInt() {
        String line = SCANNER.nextLine();
        return Integer.parseInt(line);
    }

    public static void main(String[] args) {

//        int tc = Integer.parseInt(SCANNER.nextLine());
        int tc = 1;
        for (int i = 0; i < tc; ++i) {
            String s = SCANNER.nextLine();
            String[] str = s.split(" ");
            int[] ints = new int[str.length];
            for (int j  = 0; j < str.length; ++j) {
                ints[j] = Integer.parseInt(str[j]);
            }
            test(ints[0], ints[1], ints[2], ints[3]);
        }
    }

    private static void test(int a, int b, int h, int m) {
        double full = 2 * Math.PI;

        double ba = full * (m / 60.0);
        double aa = full * (h * 60 + m) / 12.0 / 60.0;

        double ax = a * Math.sin(aa);
        double ay = a * Math.cos(aa);

        double bx = b * Math.sin(ba);
        double by = b * Math.cos(ba);

        double dx = bx - ax;
        double dy = by - ay;

        double d = Math.sqrt(dx*dx + dy*dy);
        System.out.println(d);
    }

}



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

int main()
{
  int n;
  long long K;
  scanf("%d%lld",&n,&K);
  static long long a[100000],b[100000];
  for(int i=0;i<n;i++){
    scanf("%lld%lld",a+i,b+i);
  }
  K++;
  long long ans=0ll;
  for(int t=0;t<32;t++){
    if(!((K>>t)&1)){
      continue;
    }
    long long M=(((K>>t)^1)<<t)|((1<<t)-1);
    long long S=0ll;
    for(int i=0;i<n;i++){
      if((a[i]&M)==a[i]){
	S+=b[i];
      }
    }
    ans=max(S,ans);
  }
  printf("%lld\n",ans);
  return 0;
}


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

int N;
string S;

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

	int ans = 1;
	char c = S[0];
	for(int i = 1; i < N; i++){
		if(S[i] != c){
			ans++;
			c = S[i];
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 512
#2パターンWA

def gcd(x,y):
    while y != 0:
        x,y = y,x%y
    return x
def lcm(x,y):
    return x*y//gcd(x,y)

a, b, c, d = (int(i) for i in input().split())

V = b - a + 1
ans = 0
if V != 1:
    if a%c != 0:
        c_cnt = len(range(a+(c - a%c),b+1,c))
    else:
        c_cnt = len(range(a,b+1,c))

    if a%d != 0:
        d_cnt = len(range(a+(d - a%d),b+1,d))
    else:
        d_cnt = len(range(a,b+1,d))

    cd_lcm = lcm(c,d)
    if a%(cd_lcm) != 0:
        cd_cnt = len(range(a+(cd_lcm - a%(cd_lcm)),b+1,cd_lcm))
    else:
        cd_cnt = len(range(a,b+1,cd_lcm))

    ans = V - (c_cnt + d_cnt - cd_cnt)
else:
    if a%c != 0 and a%d != 0:
        ans = 1
print(ans)

Measured memory_bytes: 38384
#include <iostream>

using namespace std;

using ll = long long;

#define FOR(i, a, b) for(ll i=(a);i<(b);++i)
#define REP(i, n) for(int i=0;i<(n);++i)
#define ALL(v) (v).begin(),(v).end()

const int MOD = (int) 1e9 + 7;

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

    int n, m;
    cin >> n >> m;
    ll x[n + 1], y[m + 1];
    FOR(i, 1, n + 1) cin >> x[i];
    FOR(i, 1, m + 1) cin >> y[i];

    ll xsum = 0;
    FOR(i, 1, n + 1) {
        xsum = (xsum + (i - 1) * x[i] - (n - i) * x[i]) % MOD;
    }
    ll ysum = 0;
    FOR(i, 1, m + 1) {
        ysum = (ysum + (i - 1) * y[i] - (m - i) * y[i]) % MOD;
    }

    ll ans = (xsum * ysum) % MOD;
    cout << ans << endl;
    return 0;
}

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

const ll MAX = 200000;
const ll INF = 1001001001;
const ll MOD = 1000000007;

ll N, ans=0, tmp=0;
vector<ll> A;

signed main(){
    cin >> N;
    for(int i=0;i<2*N;i++) {
        tmp *= 10;
        tmp += 7;
        tmp %= N;
        if(tmp==0) {
            cout << i+1 << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int x,y,z;
    cin>>x>>y>>z;
    swap(x,y);
    swap(x,z);
    cout<<x<<" "<<y<<" "<<z<<"\n";
    return 0;
}

Measured memory_bytes: 256
//Name-Deepesh Bhatt
//Institute-IIT Dhanbad

#include <bits/stdc++.h>
using namespace std;
typedef  long long ll;
#define m 100000000;
ll gcd(ll a,ll b)
{
    if(b==0)
        return a;
    else
        return gcd(b,a%b);
}
ll lcm(ll a ,ll b)
{
    return a/gcd(a,b)*b;
}
ll power(ll a, ll n)
{
    if (n == 0)
        return 1;
    ll p = power(a, n / 2);
    p = (p * p);
    if (n % 2)
        return (p * a);
    else
        return p;
}
bool is_possible(int a){
    int z;
    for(int i=1;;i++){
        z=(power(2,i)-1)*power(2,i-1);
        if(z==a){
            return true;
        }
        if(z>a)
            return false;
    }
    return false;
}
int main()
{
    ios_base::sync_with_stdio(false);    //for fast I/O operation
    cin.tie(NULL);
    int n;
    cin>>n;
    int flag=0;
    while(n){
        int temp=n%10;
        if(temp==7)
            flag++;
        n=n/10;
    }
    if(flag){
        cout<<"Yes";
    } else
        cout<<"No";
    return 0;
}

Measured memory_bytes: 3604
/*
 * If you're not willing to make sacrifices yourself, you'll never be
 * able to change anything. In order to overcome monsters, you must
 * be willing to abandon your own humanity.
 * ~ Arlert
 */

#include <bits/stdc++.h>

using namespace std;

typedef pair<int, int> II;
typedef vector<II> VII;
typedef vector<int> VI;
typedef vector<VI> VVI;

typedef long long int LL;

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(a) (int)(a.size())
#define ALL(a) a.begin(), a.end()
#define SET(a, b) memset(a, b, sizeof(a))
#define si(n) scanf("%d", &n)
#define dout(n) printf("%d\n", n)
#define sll(n) scanf("%lld", &n)
#define lldout(n) printf("%lld\n", n)

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args) {
  const char *comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
#else
#define trace(...)
#endif

#define fast_io                     \
  ios_base::sync_with_stdio(false); \
  cin.tie(NULL)

#define endl '\n'
const int N = 1001, M = 5001;
VI g[N];
int wt[N];
int dp1[M], dp2[M];
int x[N];
void dfs(int u) {
  for (auto c : g[u]) dfs(c), wt[u] += wt[c];
  SET(dp1, 0);
  dp1[0] = 1;
  for (auto c : g[u]) {
    SET(dp2, 0);
    for (int i = 0; i < M; i++)
      if (dp1[i]) {
        if (i + x[c] < M) dp2[i + x[c]] = 1;
        if (i + wt[c] - x[c] < M) dp2[i + wt[c] - x[c]] = 1;
      }
    for (int i = 0; i < M; i++) dp1[i] = dp2[i];
  }
  int i;
  for (i = x[u]; i >= 0; i--)
    if (dp1[i]) {
      wt[u] += x[u] - i;
      return;
    }
  if (i == -1) {
    cout << "IMPOSSIBLE" << endl;
    exit(0);
  }
}
int main() {
  fast_io;
  int n;
  cin >> n;
  for (int i = 2; i <= n; i++) {
    int a;
    cin >> a;
    g[a].PB(i);
  }
  for (int i = 1; i <= n; i++) cin >> x[i];
  dfs(1);
  return 0 * puts("POSSIBLE");
}


Measured memory_bytes: 384
#include<stdio.h>

int main(void){
   int n;
   int max = -1000000000;
   int min = 1000000000;
   for (int i = 1; i <= 3; i++) {
              scanf("%d", &n);
              if(max < n) max = n;
              if(min > n) min = n;
          }
         
       printf("%d %d\n", min,max);
 
   return 0;
}


Measured memory_bytes: 2108
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>

using namespace std;

int main()
{
    int A, B, C, X;
    int num = 0;
    cin >> A;
    cin >> B;
    cin >> C;
    cin >> X;
    for (int i = 0; i <= A; ++i)
    {
        for (int j = 0; j <= B; ++j)
        {
            for (int k = 0; k <= C; ++k)
            {
                if ((500 * i + 100 * j + 50 * k) == X)
                {
                    ++num;
                }
            }
        }
    }
    cout << num << endl;
    return 0;
}

Measured memory_bytes: 256
//#pragma comment(linker, "/stack:200000000") //  (UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")  // $ (UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)\

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define endl "\n"
#define int long long
#define ll long long
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define fi first
#define se second
#define vi vector<int>
#define vii vector< vector<int> >
#define vpi vector< pair<int,int> >
#define pair <int, int> pii

typedef tree< int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update>
    ordered_set;
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the iterator to kth largest element.(0-based)

#define TRACE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << endl;}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<"  ";__f(comma+1, args...);}
#else
#define trace(...)
#endif

template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}

int modpow(int x, int n, int mod)
{
	x %= mod ;
	int res = 1;
	while(n > 0) {
		if(n & 1)
			res = res * x % mod ;
		x = x * x % mod ;
		n >>= 1 ;
	}
	return res;
}

const long long inf = 2e18 ;
const int mod = 1e9+7 ;
// const int mod = 998244353 ;
const int N = 1e5 + 10 ;

typedef long double ld;

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

	int n,m;
	cin>>n>>m;
	int a=0,b=0;
	bool ok[n+10];
	for(int i=0;i<=n;i++) {
		ok[i]=false;
	}
	int w[n+10]={0};
	int ac[n+10]={0};
	for(int i=0;i<m;i++) {
		int x;
		string s;
		cin>>x>>s;
		if(ok[x]==false) {
			if(s[0]=='A') {
				ok[x]=true;
				ac[x]++;
			}
			else {
				w[x]++;
			}
		}
		else {
			// if(s[0]=='A')ac[x]++;
		}
	}
	int ans1=0;
	int ans2=0;
	for(int i=1;i<=n;i++) {
		if(ac[i]>0) {
			ans1+=w[i];
			ans2+=ac[i];
		}
	}
	cout<<ans2<<" "<<ans1<<endl;
return 0 ;
}


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

int main() {
    int X;
    cin >> X;
    if (X/100>19){
        cout << 1 << endl;
        return 0;
    }
    else if ( X/100*5 >= X%100 )
    cout << 1 << endl;
    else 
    cout << 0 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <ctime>
#include <algorithm>
#include <sstream>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <cstdlib>
#include <cstdio>
#include <iterator>
#include <functional>
#include <bitset>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#else
#define eprintf(...)
#endif

#define TIMESTAMP(x) eprintf("["#x"] Time : %.3lf s.\n", clock()*1.0/CLOCKS_PER_SEC)
#define TIMESTAMPf(x,...) eprintf("[" x "] Time : %.3lf s.\n", __VA_ARGS__, clock()*1.0/CLOCKS_PER_SEC)

using namespace std;

#ifdef LOCAL
static struct __timestamper {
  string what;
  __timestamper(const char* what) : what(what){};
  __timestamper(const string& what) : what(what){};
  ~__timestamper(){
    TIMESTAMPf("%s", what.data());
	}
} __TIMESTAMPER("end");
#else 
struct __timestamper {};
#endif

typedef long long ll;
typedef long double ld;

int get_val(int p, int c) {
  p %= c;
  if (p == 0) {
    return 10000;
  } else if (p == c - 1) {
    return -(c - 2 + 10000 + 1);
  } else {
    return 1;
  }
}

int main() {
#ifdef LOCAL
  freopen("c.in", "r", stdin);
  freopen("c.out", "w", stdout);
#endif

  int H, W, h, w;
  while (scanf("%d%d%d%d", &H, &W, &h, &w) == 4) {
    if (H % h == 0 && W % w == 0) {
      printf("No\n");
      continue;
    }
    printf("Yes\n");
    for (int i = 0; i < H; i++) {
      for (int j = 0; j < W; j++) {
        int val;
        if (H % h != 0) {
          val = get_val(i, h);
        } else {
          val = get_val(j, w);
        }
        printf("%d%c", val, " \n"[j == W - 1]);
      }
    }
  }
  return 0;
}


Measured memory_bytes: 1792
#include <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <ctime>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <memory.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <unordered_map>
#include <unordered_set>
using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(i=a;i<(n);i++)
#define all(in) in.begin(),in.end()

typedef long double LD;
typedef long long LL;
typedef pair<LL, LL> pll;
typedef pair<int32_t, int32_t> pii;
typedef vector<int32_t> vi;

int main() {
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cout.precision(10); cout << fixed;

	uint32_t n; cin >> n;
	vector<LL> h(n);
	vector<LL> dp(n);

	dp[0] = 0;
	rep(i, n) {
		cin >> h[i];
		if (i == 1) {
			dp[1] = abs(h[i] - h[i-1]);
		} else if (i > 1) {
			dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]), dp[i-2] + abs(h[i] - h[i-2]));
		}
	}
	

	cout << dp[n-1];
}

Measured memory_bytes: 1792
//大文字->小文字 tolower(),逆はtoupper()
//int a = stoi(c); 文字列をintへ
//途中の出力をそのまま残さない
//数値計算 個数以外はdouble
//map<キー,値> p は辞書。p[キー] = 値
//map 全探索
//auto begin = p.begin(), end = p.end();
//for (auto it = begin; it != end; it++) {}
//mapのキー：it->first mapのバリュー：it->second
//絶対値 abs()
//入力は空白で切れる
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
//while(N)で回すとき、Nはコピーを作っておく
//小文字に対応する文字コード：S[i] - 'a'
//文字コード→小文字：(char)(数字+'a')
//グラフの距離:隣接行列で扱う
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

// K進数でのNの桁数
ll dig(ll N,ll K) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= K;
	}
	return dig;
}
// x,yの最大公約数
ll gcd(ll x, ll y) {
	ll r;
	while (x%y) {
		r = x % y;
		x = y;
		y = r;
	}
	return y;
}

//nC2の計算
ll C(ll N) {
	return N * (N - 1) / 2;
}

//円周率
const double PI = 3.14159265358979323846;

int main() {
	int N; cin >> N;
	if (N / 100 == N % 10)cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;

int main() {
  int n;
  cin >> n;
  vector<vector<int>> a(n + 1, vector<int>(3, 0));
  vector<vector<int>> dp(n + 1, vector<int>(3, 0));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> a[i][j];
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 3; j++) {
      for (int k = 0; k < 3; k++) {
        if (j == k) continue;
        dp[i + 1][k] = max(dp[i + 1][k], dp[i][j] + a[i][k]);
      }
    }
  }
  cout << max({dp[n][0], dp[n][1], dp[n][2]}) << endl;
  return 0;
}

Measured memory_bytes: 11136
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}
struct Combination{
private:
    ll N;
    vector<ll> fac, facinv;

public:
    Combination(ll n){
        N = n;
        fac.push_back(1); fac.push_back(1);
        rep(i,2,N+1) fac.push_back(fac[i-1] * i % MOD);
        rep(i,0,N+1) facinv.push_back(power(fac[i], MOD-2));
    }
    ll power(ll x, ll n){
        if(n == 0) return 1LL;
        ll res = power(x * x % MOD, n/2);
        if(n % 2 == 1) res = res * x % MOD;
        return res;
    }
    ll nck(ll n, ll k){
        if(k == 0 || n == k) return 1LL;
        return fac[n] * facinv[k] % MOD * facinv[n-k] % MOD;
    }
    ll npk(ll n, ll k){
        if(k == 0 || n == k) return 1LL;
        return fac[n] * facinv[n-k] % MOD;
    }
    ll get(ll x){return fac[x];};
    ll getinv(ll x){return facinv[x];};
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,K;
    cin >> N >> K;
    ll A[100010];
    rep(i,0,N) cin >> A[i];
    sort(A, A+N);
    ll ans_minus = 0;
    Combination cb(100010);
    rep(i,0,N){
        ll v = A[i];
        if(N - i - 1 < K-1) continue;
        ans_minus += (v + MOD) % MOD * cb.nck(N-i-1, K-1) % MOD;
        ans_minus %= MOD;
    }
    ll ans_plus = 0;
    rrep(i,N-1,0){
        ll v = A[i];
        if(i < K-1) continue;
        ans_plus += (v + MOD) % MOD * cb.nck(i, K-1) % MOD;
        ans_plus %= MOD;
    }
    ll ans = (ans_plus - ans_minus + MOD) % MOD;
    print(ans); 


    

}

Measured memory_bytes: 3316
#include <iostream>

using namespace std;

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

int main() {
  int n;
  cin >> n;
  Rep(i, n) {
    int a;
    cin >> a;
    if (a % 2 == 0 && a % 3 != 0 && a % 5 != 0) {
      cout << "DENIED" << endl;
      return 0;
    }
  }
  cout << "APPROVED" << endl;
  return 0;
}


Measured memory_bytes: 256
import math

N = int(input())
xy = [map(int ,input().split()) for i in range(N)]
x,y = [list(i) for i in zip(*xy)]
d = 0
for i in range(N-1) :
    for j in range(i+1,N) :
        d += math.sqrt( (x[i]-x[j])**2 + (y[i] - y[j])**2 )

print(d*2/N)


Measured memory_bytes: 3060
#!/usr/bin/python
# coding: UTF-8

from math import *
import os
import sys

#import scipy.optimize
import numpy as np


##################################################################
if __name__ == "__main__":
    Input = [raw_input() for i in range(2)]
    N = Input[0]
    A = list(map(int,Input[1].split()))
    A = np.array(A)
    for ans in range(100):
        temp = A % 2
        if sum(temp) != 0:
            break
        else:
            A = A/2        
    print ans
        
    

Measured memory_bytes: 18808
#include<bits/stdc++.h>
using namespace std;
string s;int ans;
int main()
{
	cin>>s;s='0'+s;
	reverse(s.begin(),s.end());
	for(int i=0;i<s.size();i++)
	{
		if(s[i]-'0'>5||(s[i]=='5'&&s[i+1]>='5'))
		{
			s[i]=(10-(s[i]-'0')+'0');
			s[i+1]++;
		}
	}
	for(int i=0;i<s.size();i++)
	{
		ans+=s[i]-'0';
	}
	cout<<ans;
	return 0;
}

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

int main() {
    int N, K, display = 1;
    cin >> N >> K;

    for (int i = 0; i < N; i++) {
        if (display > K) {
            display += K;
        } else {
            display *= 2;
        }
    }
    cout << display << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<stdlib.h>
#include<cassert>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=500000004;
const double EPS=1e-10;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
char in[210];
int main(){
	scanf("%s",in);
	int n=strlen(in);
	n-=2;
	while(n){
		bool ok=true;
		for(int i=0;i<n/2;i++){
			if(in[i]!=in[i+n/2])ok=false;
		}
		if(ok){
			printf("%d\n",n);
			return 0;
		}
		n-=2;
	}
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, M, C;
  cin >> N >> M >> C;
  //Bを入力
  vector<int> B(M);
  for (int i=0; i<M; i++)
    cin >> B.at(i);
  //Aを入力
  vector<vector<int>> A(N,vector<int>(M));
  for(int i=0; i<N; i++){
    for(int j=0; j<M; j++)
      cin >> A.at(i).at(j);
  }
  int ans=0, score=0;
  for (int i=0; i<N; i++){
    for (int j=0; j<M; j++){
      score += A.at(i).at(j) * B.at(j);
    }
    if(score > -C){
      ans++;
      score =0;
    }
    else
      score = 0;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=n-1;i>=(0);i--)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define eall(v) unique(all(v), v.end())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll INFF = 1e18;

int main(void){
	ll N; cin >> N;
	ll ans = INFF;
	for (ll i = 1; i * i<= N; ++i){
		if(N % i == 0){
			string a = to_string(i), b = to_string(N / i);
			chmin(ans, max((int)a.size(), (int)b.size()));
		}
	}
	printf("%lld\n", ans);
	return 0;
}

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

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

fn main() {
    let s = read::<String>().chars().collect::<Vec<char>>();
    let mut ans = 0;
    'outer_loop: for i in 0..s.len() / 2 {
        for j in 0..i / 2 {
            if s[j] != s[i + j] {
                continue 'outer_loop;
            }
        }
        ans = i * 2;
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<iostream>
#include<cstdio>
using namespace std;
int n,m;
int dp[2][3010][2];
int ans;
const int md=1e9+7;
void add(int &a,int b)
{
	a+=b;
	if(a>=md)a-=md;
}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=0;i<=n;i++)dp[0][i][0]=1;
	for(int i=1;i<=m;i++)
	{
		int ii=i&1;
		for(int j=0;j<=n;j++)
		{
			for(int st=0;st<2;st++)dp[ii][j][st]=0;
		}
		for(int j=0;j<=n;j++)
		{
			for(int st=0;st<2;st++)
			{
				int nst;
				if(j>=1)
				{
					nst=st;
					if(j==1)nst=1;
					add(dp[ii][j-1][nst],dp[ii^1][j][st]);//rr
					add(dp[ii][j][nst],dp[ii^1][j][st]);//rb
				}
				if(j<n)
				{
					nst=st;
					if(!j)nst=1;
					add(dp[ii][j+1][nst],dp[ii^1][j][st]);//bb
					add(dp[ii][j][nst],dp[ii^1][j][st]);//br
				}
			}
		}
	}
	for(int i=0;i<=n;i++)add(ans,dp[m&1][i][1]);
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 256
/*input
3 5
6 9 3
*/

#include <bits/stdc++.h>
 
using namespace std;

#define Fi              first
#define Se              second
#define S(n)            cin >> n
#define P(n)            cout << n
#define pb              push_back
#define pp              pop_back
#define pf              pop_front
#define sp              cout << " "
#define nl              cout << "\n"
#define MIN(con)        (*min_element(ALL(con))) 
#define MAX(con)        (*max_element(ALL(con)))
#define mem(n, a)       memset((n), (a), sizeof(n))
#define ALL(cont)       (cont).begin(),(cont).end()
#define NX(cont)        next_permutation(ALL(cont))
#define PX(cont)        prev_permutation(ALL(cont))
#define F(i, n, r)      for(int i = (n); i < (r); i ++)
#define prec(n)         cout << fixed << setprecision(n)
#define PI              3.14159265358979323846264338327951
#define fast            ios_base:: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define FH(it,c)   for(__typeof((c).begin()) it = (c).begin(); it != (c).end(); ++ it)
 
using ll = long long;
using ss = stringstream;
using ul = unsigned long long;
 
template < typename T > inline T LCM(T a, T b)            { return (a * b) / GCD(a, b); }
template < typename T > inline T GCD(T a, T b)            { ll t; while(a) { t = a; a = b % a; b = t; } return b; }
template < typename T > inline T _max(T a, T b, T c)      { return max( max( a, b ), c ); }
template < typename T > inline T _min(T a, T b, T c)      { return min( min( a, b ), c ); }
template < typename T > inline string toString(T a)       {return to_string(a); }  // Convert int to string
template < typename T > inline void toInt(string s, T &x) { ss str(s); str >> x;}  // Convert string to int

inline void lower(string &s) { 
  FH(it,s) 
    *it = tolower(*it); 
} 
 
inline void upper(string &s) { 
  FH(it,s) 
    *it = toupper(*it); 
}

const ll inf    =  999999999999999999;

bool palin(string s)
{
    string s1 = s;
    reverse(s.begin(), s.end());
    return (s == s1);
} 

ll triangle(ll n)
{
    return (n * (n + 1)) / 2;
}

bool check(ll n) 
{
    if(n == 1) return 0;
    if(n == 2 or n == 3) return 1;
    if(n % 2 == 0 or n % 3 == 0) return 0;

    for(ll i = 5; i * i <= n; i += 6) if(n % i == 0 or n % (i + 2) == 0) return 0;
    return 1;
}

int main ()
{
    fast;
    int n;
    ll k;
    cin >> n >> k;

    vector < ll > v(n);
    ll ma = 0;
    for(int i = 0; i < n; i ++) {
        cin >> v[i];
        ma = max(ma, v[i]);
    }
    
    ll g = v[0];
    for(int i = 1; i < n; i ++) {
        g = __gcd(v[i], g);
    }
    if(k % g == 0 and k <= ma) {
        cout << "POSSIBLE";
    }
    else {
        cout << "IMPOSSIBLE";
    }
    nl;
    return 0;
}



Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <sstream>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
#include <regex>
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
// if ( std::regex_match(S, std::regex("(dream|dreamer|erase|eraser)*")) ) std::cout << "YES" << std::endl;
 
#define rep(i, n) for(int i = 0; i < (int)(n);    i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()

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; }
typedef long long ll;
typedef std::vector<int> vi;
typedef std::vector<std::vector<int>> vvi;

ll gcd ( ll a, ll b ) { if ( b == 0 ) return a; else return gcd ( b, a%b ); }
ll lcm ( ll a, ll b ) { return a * b / gcd(a, b); }

vvi G;
vi has;
std::vector<bool> used;

void bfs(int start) {
  used[start] = true;

  std::queue<int> q;
  q.push(start);
  while(!q.empty()) {
    int cur = q.front(); q.pop();
    for(auto&& n : G[cur]) {
      if ( used[n] ) continue;
      used[n] = true;
      has[n] = has[cur] + 1;
      q.push(n);
    }
  }
  return;
}

int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  int N; std::cin >> N;
  used.resize(N); 
  has.resize(N, 0);
  G.resize(N);
  rep(i,N-1) {
    int a,b; std::cin >> a >> b; a--, b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  // koredato damena hannrei ga aruyo
  // zu no 5 vs 3 notoki
  bfs(0);
  auto res1 = has;

  std::fill( all(used), false);
  std::fill( all(has), 0);

  bfs(N-1);
  auto resN = has;

  int b = 0, w = 0;
  for(int i=0; i<N; i++) {
    if ( res1[i] <= resN[i] ) b++;
    else w++;
  }  
  
  if ( b <= w ) std::cout << "Snuke" << std::endl;
  else std::cout << "Fennec" << std::endl;
  return 0;
}


Measured memory_bytes: 6912
import math
n,k,*a = map(int,open(0).read().split())
a = list(set(a))
if k in a:
  print("POSSIBLE")
elif k>max(a):
  print("IMPOSSIBLE")
else:
  b = max(a)-k
  c = a.pop()
  for i in a:
    c = math.gcd(c,i)
    if c == 1:
      break
  if b%c == 0:
    print("POSSIBLE")
  else:
    print("IMPOSSIBLE")

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

using namespace std;

int main() {
	int h, n; cin >> h >> n;
	int total = 0;
	for (int i = 0; i < n; ++i) {
		int ai; cin >> ai;
		total += ai;
	}
	cout << (total >= h ? "Yes" : "No") << endl;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<" "<<p.se<<endl
#define sar(a,n) cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl
#define svec(v) cout<<#v<<":";rep(pachico,v.size())cout<<" "<<v[pachico];cout<<endl
#define svecp(v) cout<<#v<<":";each(pachico,v)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl
#define sset(s) cout<<#s<<":";each(pachico,s)cout<<" "<<pachico;cout<<endl
#define smap(m) cout<<#m<<":";each(pachico,m)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 4005;

int num[MAX_N][MAX_N];
int sm[MAX_N][MAX_N];

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,m,q;
	cin >> n >> m >> q;
	vs s(n);
	rep(i,n){
		cin >> s[i];
	}
	rep(i,n){
		rep(j,m){
			num[2*i][2*j] = (s[i][j] -'0');
		}
	}
	rep(i,n){
		rep(j,m-1){
			if(s[i][j] == '1' && s[i][j+1] == '1'){
				num[2*i][2*j+1] = -1;
			}
		}
	}
	rep(j,m){
		rep(i,n-1){
			if(s[i][j] == '1' && s[i+1][j] == '1'){
				num[2*i+1][2*j] = -1;
			}
		}
	}
	rep(i,2*n){
		rep(j,2*m){
			sm[i+1][j+1] = sm[i+1][j] + num[i][j]; 
		}
	}
	rep(j,2*m+1){
		rep(i,2*n+1){
			sm[i+1][j] += sm[i][j];
		}
	}
	rep(i,q){
		int a,b,c,d;
		cin >> a >> b >> c >> d;
		--a,--b,--c,--d;
		cout << sm[2*c+1][2*d+1] - sm[2*a][2*d+1] - sm[2*c+1][2*b] + sm[2*a][2*b] << "\n";
	}
	return 0;
}

Measured memory_bytes: 131200
N = int(input())

target = N
out = 0
while target > 2:
    if target % 2 == 0:
        mueikyo_start = 1
        mueikyo_end = target-1
        out += ( (mueikyo_start + mueikyo_end) * (mueikyo_end - mueikyo_start+1) // 2 )
        break
    else:
        mueikyo_start = (target // 2) + 1
        mueikyo_end = target - 1
        out += ( (mueikyo_start + mueikyo_end) * (mueikyo_end - mueikyo_start+1) // 2 )
        out += ( target % mueikyo_start)
        target = target // 2
        #print("target", target, "cur out", out)

if target == 2:
    out += (1+0)
elif target == 1:
    out += 0

print(out)

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

priority_queue<pair<int, bool> > q;

int main(void)
{
    int n, h;
    scanf("%d%d", &n, &h);
    for (int i = 0; i < n; i++) {
        int a, b;
        scanf("%d%d", &a, &b);
        q.push(make_pair(a, 1));
        q.push(make_pair(b, 0));
    }
    int ans = 0;
    while (h > 0) {
        int attack = q.top().first;
        bool multi_attack = q.top().second;
        q.pop();
        if (multi_attack) {
            int cnt = h / attack;
            if (h % attack) cnt++;
            h -= attack * cnt;
            ans += cnt;
        }
        else {
            h -= attack;
            ans++;
        }
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 3444
/*************************************
 * problem:      AT2164 Rabbit Exercise.
 * user ID:      63720.
 * user name:    Jomoo.
 * time:         2019-08-14.
 * language:     C++.
 * upload place: Luogu.
*************************************/ 

#include <bits/stdc++.h>
using namespace std;
#define puts_return(x) { puts(x); return 0; }
#define write_return(x) { write(x); return 0; }

typedef signed char          int8;
typedef unsigned char       uint8;
typedef short                int16;
typedef unsigned short      uint16;
typedef int                  int32;
typedef unsigned            uint32;
typedef long long            int64;
typedef unsigned long long  uint64;

template <typename Int>
inline Int read()       
{
    Int flag = 1;
    char c = getchar();
    while ((!isdigit(c)) && c != '-') c = getchar();
    if (c == '-') flag = -1, c = getchar();
    Int init = c & 15;
    while (isdigit(c = getchar())) init = (init << 3) + (init << 1) + (c & 15);
	return init * flag;
}

template <typename Int>
inline void write(Int x)
{
    if (x < 0) putchar('-'), x = ~x + 1;
    if (x > 9) write(x / 10);
    putchar((x % 10) | 48);
}  

template <typename Int>
inline void write(Int x, char nextch)
{
    write(x);
    putchar(nextch);
}

uint64 n, m, k;
vector<int32> x, a, to, ans;
vector<bool> vis;

int main()
{
    n = read<uint64>();
    x.resize(n);
    to.resize(n);
    ans.resize(n);
    vis.resize(n);
    for (size_t i = 0; i < n; i++) x[i] = read<int32>(), to[i] = i;
    for (size_t i = n - 1; i > 0; i--) x[i] -= x[i - 1];
    m = read<uint64>();
    a.resize(m);
    k = read<uint64>();
    for (auto num : a) num = read<int32>(), swap(to[num], to[num - 1]);
    for (size_t i = 0; i < n; i++) 
        if (!vis[i]) {
            vector<int32> s;
            for (int j = i; !vis[j]; j = to[j]) s.push_back(j), vis[j] = true;
            for (size_t j = 0; j < s.size(); j++) ans[s[j]] = x[s[(j + k) % s.size()]];
        }
    // ans[0] = x[0];
    // ans[n - 1] = x[n - 1];
    int64 tot = 0;
    for (auto answer : ans) write(tot += answer, 10);
    return 0;
}

Measured memory_bytes: 2932