akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <iostream>
#include<algorithm>
using namespace std;
int main()
{
    int k,a,b;
    scanf("%d%d%d",&k,&a,&b);
    int flag=0;
    for(int i=a; i<=b; i++)
    {
        if(i%k==0)
        {
            printf("OK\n");
            flag=1;
            break;
        }
    }
    if(flag==0)
        printf("NG\n");
    return 0;
}


Measured memory_bytes: 3688
from sys import stdin
import math
import fractions
from collections import deque
from collections import Counter
import itertools

INF = 10 ** 10

N, D = [int(x) for x in stdin.readline().rstrip().split()]

X = [list(map(int, stdin.readline().rstrip().split())) for _ in range(N)]

cnt = 0

for i in range(N):
    for j in range(i+1, N):
        dist = 0.0
        for k in range(D):
            dist += abs(X[i][k] - X[j][k]) * abs(X[i][k] - X[j][k])
        dist = math.sqrt(dist)

        if dist.is_integer():
            cnt += 1

print(cnt)



Measured memory_bytes: 66156
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<double> vec(N);
  double answer;
  double warukazu;
  warukazu =1;
  // ここにプログラムを追記
  for(int i=0; i<vec.size();i++){
   cin >> vec.at(i);
    answer += warukazu/vec.at(i);
}
 answer = warukazu/answer;
  std::cout << std::setprecision(10) << answer;
}
  

Measured memory_bytes: 256
#include<cstdio>
using namespace std;
int main(void)
{
	int a,b;
	scanf("%d %d",&a,&b);
	if(a<10&&b<10){
		printf("%d\n",a*b);
	}
	else{
		printf("-1\n");
	}
	return 0;
}
	

Measured memory_bytes: 128
N = int(input())
L = [0 for i in range(60)]
As = list(map(int, input().split()))
mod = 1000000007
ans = 0

for A in As:
    for i in range(60):
        if A >> i & 1 == 1:
            L[i] += 1

acc = 1
tmps = []
for i in range(60):
    tmps.append(acc)
    acc = acc * 2 % mod

for i in range(60):
    tmp = tmps[i]
    a = L[i] % mod
    b = (N - a) % mod
    ans += (tmp * a * b) % mod

ans = ans % mod
print(ans)

Measured memory_bytes: 125748
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define SIZE(x) ((int)(x).size())
#define UQ(v) v.erase(unique(v,begin(),v,end()),v.end());
ll INF = 1LL <<61;
#define pb push_back 
int dxy4[5] = { 0,1,0,-1,0 };
int dxy8[9] = { 0,1,1,0,-1,1,-1,-1,0 };
int gcd(int a, int b) { return min(a,b) ? gcd(min(a,b), max(a,b)%min(a,b)) : max(a,b); }
ll mod7 = 1000000007;
ll mod9 = 1000000009;
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define FOR(i,x,n) for(int i=x;i<n;++i)
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define print(x) cout<<x<<endl;
#define wait int xxxxxxx;cin>>xxxxxxx;

//vector< vector<int> > v (max1, vector<in t>(max2) );
int main() {

	string s;
	cin >>s;
	int n;
	cin >> n;
	rep(i, SIZE(s)) {
		if (i%n == 0)cout << s[i];
	}
	cout << endl;
	wait
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
using namespace std;
///////////////////library zone!!!!!!!!!!!!!!!!!!!!!!!!!!!!
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
#define EPS (1e-5)
#define bit(n,k) ((n>>k)&1)
const ll Mod = 1000000007;
const ll mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H& b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H & b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H & b) const { return x == b.x && y == b.y; }
	bool operator!=(const H & b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P& b) const { return cost < b.cost; }
	bool operator>(const P& b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E& b) const { return cost < b.cost; }
	bool operator>(const E& b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T & a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T & a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	ll k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j % i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
int n, m;
int pa[200000];
int root(int x) {
	if (pa[x] == x) return x;
	return pa[x] = root(pa[x]);
}
void unite(int x, int y) {
	x = root(x), y = root(y);
	pa[x] = y;
}
signed main() {
	cin >> n >> m;
	for (int i = 1; i <= n; i++) {
		pa[i] = i;
	}
	for (int i = 0; i < m; i++) {
		unite(read(), read());
		int u = read();
	}
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		if (pa[i] == i) ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <utility> 
#include <unordered_set>
#include <vector>
#include <list> 
#include <string>
#include <iterator> 
#include <deque>
#include <array>
#include <forward_list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <climits>
#include <bitset>
#include <numeric>
using namespace std;


const long double PI = 3.14159265358979323846264338327950;
const int N = 2*1e5;

template <class T>
T gcd(T a, T b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

int arr[N];

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	int n, k;
	cin >> n >> k;
	for (int i = 0; i < n; ++i)
		cin >> arr[i];
	if (k >= n) {
		cout << 0 << '\n';
	} else {
		sort(arr, arr + n);
		long long ans = 0;
		for (int i = 0; i < n - k; ++i) {
			ans += arr[i];
		}
		cout << ans << '\n';

	}
}


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

using namespace std;

const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
const char dir[] = "RDLU";

int main()
{
    string input;

    while (cin >> input) {
        bool map[5][5][4];

        // Initialization
        for (int i = 0; i < 5; i++)
            for (int j = 0; j < 5; j++)
                for (int k = 0; k < 4; k++)
                    map[i][j][k] = false;

        // Input (0,0) - (0,4)
        for (int i = 0; i < 4; i++) 
            if (input[i] == '1') {
                map[0][i][0] = true;
                map[0][i + 1][2] = true;
            }

        // Input Others
        for (int i = 0; i < 8; i++) {
            cin >> input;
            int lim;
            (i % 2) ? (lim = 4) : (lim = 5);

            for (int j = 0; j < lim; j++)
                if (input[j] == '1') {
                    if (i % 2) {
                        map[(i + 1) / 2][j][0] = true;
                        map[(i + 1) / 2][j + 1][2] = true;
                    }
                    else {
                        map[i / 2][j][1] = true;
                        map[(i / 2) + 1][j][3] = true;
                    }
                }
        }

        // algorithm
        int x, y, d;

        x = y = d = 0;
        do {
            int del = (d + 3) % 4;
            for (int i = 0; i < 4; i++) 
                if (map[y][x][(del + i) % 4]) {
                    d = (del + i) % 4;
                    break;
                }
            x += dx[d];
            y += dy[d];
            cout << dir[d];
        } while (x || y);

        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 1172
#include <iostream>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>

using namespace std;

int main(void){
  long long n;
  cin >> n;
  vector<long long> x(n),y(n);
  vector<pair<pair<long long,long long>,long long> > data;
  for(long long i = 0;i < n;i++){
    cin >> x[i] >> y[i];
    if(y[i]>x[i]){
      swap(x[i],y[i]);
    }
    data.push_back(make_pair(make_pair(y[i],x[i]),i));
  }
  sort(data.begin(),data.end());
  long long xmax=x[0],xmin=x[0],ymax=y[0],ymin=y[0];
  long long xmaxi=0,xmini=0,ymaxi=0,ymini=0;
  for(long long i = 1;i < n;i++){
    if(xmax<x[i]){
      xmax = x[i];
      xmaxi = i;
    }
    if(xmin>x[i]){
      xmin = x[i];
      xmini = i;
    }
    if(ymax<y[i]){
      ymax = y[i];
      ymaxi = i;
    }
    if(ymin>y[i]){
      ymin = y[i];
      ymini = i;
    }
  }
  long long ans = (xmax-xmin)*(ymax-ymin);
  long long now = ymax-ymin;
  long long ya=ymax,yi=ymin,ne;
  long long fx = xmax-ymin;
  long long yza=ymax,yzi=ymax;
  long long xi;
  for(long long i = 0;i < n-1;i++){
    xi = data[i+1].first.first;
    ne = data[i].first.second;
    if(ne > yza) yza = ne;
    if(ne < yzi) yzi = ne;
    if(xi < yzi){
      yi = xi;
    }
    else{
      yi = yzi;
    }
    if((yza-yi)*fx < ans) ans = (yza-yi)*fx;
  }
  cout << ans << endl;
}


Measured memory_bytes: 11504
import bisect
 
N=int(input())
L=list(map(int,input().split()))
 
L.sort()
count=0
for i in range(N):
  for j in range(i+1,N):
    index=bisect.bisect_left(L,L[i]+L[j])
    count+=max(0,index-j-1)
print(count)

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

vector<vector<vector<double>>> dp(301,vector<vector<double>> (301, vector<double>(301,-1)));
int n;

double res(int num1, int num2,int num3) {
  if(dp.at(num1).at(num2).at(num3)>-1) {
    return dp.at(num1).at(num2).at(num3);
  }
  else {
    dp.at(num1).at(num2).at(num3)=double(n);
    if(num3>0) {
      dp.at(num1).at(num2).at(num3)+=res(num1,num2+1,num3-1)*num3;
    }
    if(num2>0) {
      dp.at(num1).at(num2).at(num3)+=res(num1+1,num2-1,num3)*num2;
    }
    if(num1>0) {
      dp.at(num1).at(num2).at(num3)+=res(num1-1,num2,num3)*num1;
    }
    dp.at(num1).at(num2).at(num3)*=1.0/(num1+num2+num3);
    return dp.at(num1).at(num2).at(num3);
  }
}

int main() {
  dp[0][0][0]=0.0;
  cin >> n;
  vector<int> num(3,0);
  for(int i=0;i<n;i++) {
    int temp;
    cin >> temp;
    num.at(temp-1)++;
  }
  cout << fixed << setprecision(10) << res(num.at(0), num.at(1), num.at(2)) << endl;
}

Measured memory_bytes: 216960
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<string>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<iomanip>

#define REP(i,n) for(int i=0;i<(n);i++)
#define EPS (1e-7)
#define INF (2e9)
// cout << setprecision(10)

using namespace std;
typedef long long int ll;

int N;
int A[200001];
vector<int> v;
int ball[200001];
int main(void){
    cin >> N;
    REP(i,N){
        cin >> A[i];
        if(ball[A[i]] == 0) v.push_back(A[i]);
        ball[A[i]]++;
    }
    ll total = 0;
    REP(i, v.size()){
        ll num = ball[v[i]];
        total += num*(num-1)/2;
    }
    REP(i, N){
        ll num = ball[A[i]];
        cout << total - num + 1 << endl;
    }
    return 0;
}



Measured memory_bytes: 3832
n, m = [ int(v) for v in input().split() ]
first_ship = []
second_ship = []

for i in range(m):
	start, end = [ int(v) for v in input().split() ]
	if start == 1:
		first_ship.append(end)
	if end == n:
		second_ship.append(start)

if len(set(first_ship+second_ship)) == len(first_ship) + len(second_ship):
	print("IMPOSSIBLE")
else:
	print("POSSIBLE")

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}


const int INF=1001001001;

struct edge{
    int to,cap,rev;
    edge(int a,int b,int c):to(a),cap(b),rev(c){}
};

int N,E,Q;

const int MAX_V=5555;
vector<edge>G[MAX_V];
bool used[MAX_V];

void add_edge(int from,int to,int cap){
    G[from].pb(edge(to,cap,G[to].size()));
    G[to].pb(edge(from,cap,G[from].size()-1));
}

int dfs(int v,int t,int f){
    if(v==t)return f;
    used[v]=true;
    for(int i=0;i<G[v].size();i++){
        edge &e=G[v][i];
        if(used[e.to]||e.cap==0)continue;
        int d=dfs(e.to,t,min(f,e.cap));
        if(d==0)continue;
        e.cap-=d;
        G[e.to][e.rev].cap+=d;
        return d;
    }
    return 0;
}

int max_flow(int s,int t,int lim){
    int f=0;
    while(lim){
        memset(used,0,sizeof(used));
        int ff=dfs(s,t,lim);
        if(ff==0)return f;
        f+=ff;
        lim-=ff;
    }
    return f;
}


int f;
void q1(int a,int b){
    add_edge(a,b,1);
    f+=max_flow(0,N-1,INF);
}

void q2(int a,int b){
    bool f1=false,f2=false;

    for(auto &e:G[a]){
        if(e.to!=b||e.cap==0)continue;
        if(e.cap==2)f2=true,e.cap=0;
    }
    for(auto &e:G[b]){
        if(e.to!=a||e.cap==0)continue;
        if(e.cap==2)f1=true,e.cap=0;
    }
    if(!f1&&!f2)return;

    if(f2)swap(a,b);


    int tmp=max_flow(a,b,1);

    if(tmp)return;

    add_edge(0,N-1,1);
    tmp=max_flow(a,b,1);
    assert(tmp);
    G[0].pop_back();
    G[N-1].pop_back();
    f--;
}

signed main(){

    cin>>N>>E;
    vpint lis;
    rep(i,E){
        int a,b,c;
        cin>>a>>b>>c;
        if(c==1)lis.pb({a,b});
        add_edge(a,b,c);
    }

    f=max_flow(0,N-1,INF);

    int ans=f;
    rep(i,lis.size()){
        int a=lis[i].fi,b=lis[i].se;
        q2(a,b);
        chmin(ans,f);
        q1(a,b);
    }
    if(ans>10000)cout<<-1<<endl;
    else cout<<ans<<endl;
    return 0;
}

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

const double PI = 3.14159265359;

int main() {
  double a, b, h, m;
  cin >> a >> b >> h >> m;

  double x = 2.0 * PI * (h * 60.0 + m) / (12.0 * 60.0), y = 2.0 * PI * m / 60.0;

  double ans = sqrt(a * a + b * b - 2.0 * a * b * cos(x - y));

  cout << fixed << setprecision(15);
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 4228
using System;
using System.Diagnostics;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        int[] h = Console.ReadLine().Split().Select(i => int.Parse(i)).ToArray();

        int cur = h[0];
        int ans = 0;
        for (int i = 0; i < n; i++)
        {
            if (cur <= h[i])
            {
                cur = h[i];
                ans++;
            }
        }
        Console.WriteLine(ans);
    }
}

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

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using mii = map<int, int>;
using msi = map<string, int>;
using pii = pair<int, int>;

struct Edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    Edge(int t, int w) : to(t), weight(w) { }
};
using Graph = vector<vector<Edge>>;

int main()
{
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;

    vector<pair<int, string>> v(M);
    REP(i, M) {
        cin >> v[i].first;
        cin >> v[i].second;
    }
    int ans1 = 0, ans2 = 0;
    bool ac[N+1];
    int wa[N+1];
    REP(i, N+1) {
        ac[i] = false;
        wa[i] = 0;
    }

    REP(i, M) {
        if(v[i].second == "WA") {
            wa[v[i].first]++;
        } else {
            if(ac[v[i].first] == false) {
                ac[v[i].first] = true;
                ans1++;
                ans2 += wa[v[i].first];
            }
        }
    }

    cout << ans1 << " " << ans2 << endl;

    return 0;
}

Measured memory_bytes: 7040
#include <bits/stdc++.h>
typedef long long int LL;
typedef unsigned long long int ULL;
using namespace std;

// 插入此處
namespace Number {
    typedef long long int LL;
    // 求取 a, b 的最大公因數
    LL gcd(LL a, LL b) {
        if (a % b == 0) {
            return b;
        }
        return gcd(b, a % b);
    }
    // 求取 a, b 的最大公因數 gcd
    // 以及 x, y 使得 a*x + b*y = gcd
    LL gcd_extend(LL a, LL b, LL *x, LL *y) { 
        if (a == 0) { 
            *x = 0, *y = 1; 
            return b; 
        } 
    
        LL x1, y1; // To store results of recursive call 
        LL gcd = gcd_extend(b%a, a, &x1, &y1); 
    
        *x = y1 - (b/a) * x1; 
        *y = x1; 
    
        return gcd; 
    }
    // 求 a_inv 使得 (a * a_inv) % m = gcd(a, m)
    // 若 a, m 互質，即求 a 在 mod m 群的反元素 a_inv 
    LL mod_inv(LL a, LL m) { 
        LL x, y; 
        LL g = gcd_extend(a, m, &x, &y); 
        // 處理 x 爲負的情形 
        LL a_inv = (x%m + m) % m; 
        return a_inv;
    }
    // 求 x^n % m
    LL mod_pow(LL x, LL n, LL m) {
        if (n == 0) {
            return 1;
        } else if (n & 1) {
            LL half = mod_pow(x, n/2, m);
            return (half * half % m) * x % m;
        } else {
            LL half = mod_pow(x, n/2, m);
            return half * half % m;
        }
    }
    // 連乘
    LL mul(LL from, LL to, LL m) {
        LL ret = 1;
        for (LL i = from; i <= to; i++) {
            ret *= i;
            ret %= m;
        }
        return ret;
    }
    // 求 (C n 取 k) % m
    LL mod_comb(LL n, LL k, LL m) {
        LL mi = k < n-k ? k : n-k;
        LL up = mul(n - mi + 1, n, m);
        LL down = mul(1, mi, m);
        return (up * mod_inv(down, m)) % m;
    }
}
  

int main() {
    int k;
    scanf("%d", &k);
    int ans = 0;
    for (int i = 1; i <= k; i++)
    {
        for (int j = 1; j <= k; j++)
        {
            for (int q = 1; q <= k; q++)
            {
                int tmp = Number::gcd(i, j);
                ans += Number::gcd(tmp, q);
            }
        }
    }
    printf("%d\n", ans);
}


Measured memory_bytes: 3832
#include<stdio.h>
int main(void){
  int h,n;
  scanf("%d %d",&h,&n);
  int a[n];
  for(int i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  for(int j=0;j<n;j++){
    h = h - a[j];
  }
  if(h <= 0)printf("Yes");
  else printf("No");
  return 0;
}

Measured memory_bytes: 512
#include<cstdio>
#include<algorithm>

using namespace std;

typedef long long ll;

int main(){
   int N, A[200000], B[200000];
   scanf("%d", &N);
   for(int i = 0; i < N; i++){ scanf("%d", &A[i]); B[i] = A[i]; }
   sort(B, B + N);
   for(int i = 0; i < N; i++){
      if(A[i] <= B[N/2-1]) printf("%d\n",B[N/2]);
      else printf("%d\n",B[N/2-1]);
   }
}

Measured memory_bytes: 3712
S = input()
T = input()

if T in S:
    print(0)
else:
    min = 1000
    for i in range(len(S)-len(T)+1):
        tmp = 0
        for j in range(len(T)):
            if S[i+j] != T[j]:
                tmp += 1
        if tmp < min:
            min = tmp
    print(min)

Measured memory_bytes: 8976
from math import gcd

n = int(input())
MOD = 10**9 + 7
cnt = {}
zero_cnt = 0
ans = 1

for i in range(n):
    a, b = map(int, input().split())
    if (a,b) == (0,0):
        zero_cnt += 1
        continue
    g = gcd(abs(a), abs(b))
    a //= g
    b //= g
    rotate = 0
    while not (a >= 0 and b > 0):
        a,b = -b,a
        rotate += 1
    if (a,b) not in cnt:
        cnt[(a,b)] = [0,0]
    cnt[(a,b)][rotate % 2] += 1
 
for key in cnt:
    A, B = cnt[key]
    ans *= 1 + pow(2, A, MOD) - 1 + pow(2, B, MOD) - 1
    ans %= MOD
 
ans += zero_cnt
ans -= 1
print(ans % MOD)




Measured memory_bytes: 60268
n, q = map(int, input().split())
s = input()
li = [list(input().split()) for _ in range(q)]
l, r = 0, n
while r - l > 1:
    m = (l + r) // 2
    i = m
    for t, d in li:
        if i < n and s[i] == t:
            if d == 'L':
                i -= 1
            else:
                i += 1
        if i < 0:
            l = m
            break

    else:
        r = m
ans1 = r
l, r = 0, n
while r - l > 1:
    m = (l + r) // 2
    i = m
    for t, d in li:
        if s[i] == t:
            if d == 'L':
                i -= 1
            else:
                i += 1
        if i >= n:
            r = m
            break
    else:
        l = m
ans2 = l
print(max(0, ans2 - ans1 + 1))


Measured memory_bytes: 88780
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <iomanip>

using namespace std;

int main() {
    int k, s;
    cin >> k >> s;
    int c = 0;

    for (int x = 0; x <= k; ++x) {
        for (int y = 0; y <= k; ++y) {
            int z = s - x - y;
            if (0 <= z && z <= k) ++c;
        }
    }

    cout << c << endl;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
lis = [0] * (n *3)
for i in range(n):
    lis[a[i]] += 1
#print(lis)
cum = [0] * len(lis)
for i in range(n*3):
    cnt = (lis[i] * (lis[i]-1)) // 2
    cum[i] = cnt
ans = sum(cum)
cum2 = [0] * len(lis)
for i in range(2,(n*3)):
    cum2[i] = (i * (i-1)) // 2
#print(cum)
#print(cum2)
#cum2がiに対しての組み合わせ
#cumが要素数に対しての組み合わせ
#lisがiの数
#print(ans)
for i in range(n):
    print(ans - (cum2[lis[a[i]]]-cum2[lis[a[i]]-1]))

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

const int MAXN = 200005;

vector<int> c[MAXN];

int start[MAXN];

int main() {

	int h, w, n;
	cin >> h >> w >> n;

	for (int i = 0; i < n; i++) {
		int x, y;
		cin >> x >> y;

		c[y].push_back(x);
	}

	for (int i = 1; i <= w; i++) {
		sort(c[i].begin(), c[i].end());
	}

	int ans = h;

	for (int i = 1; i <= w; i++) {
		start[i] = start[i-1] + 1;
		for (int r : c[i]) {
			if (r == start[i]) {
				start[i]++;
			} else if (r > start[i]) {
				ans = min(ans, r - 1);
				break;
			}
		}

		// cout << i << " " << start[i] << endl;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
#define why(n,x) int n;while(cin >>n,n!=x)
#define iFOR(i,x,n)for(int i=x;i<n;i++)
#define unless(flg) if ( !(flg) )
#define read cin<<
#define echo cout<<
#define fin <<'\n'
#define __ <<" "<<
#define bash push_back
#define alles(x) x.begin(),x.end()
#define SWAP(a,b) ((a != b) && (a += b,b = a - b,a -= b))
int dx[]={1,0,-1,0,1,1,-1,-1};
int dy[]={0,-1,0,1,-1,1,-1,1};
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;

bool inside(int x,int y,int w,int h){
  return (x>=0 && y>=0 && x<w && y<h);}
typedef long long ll;
typedef pair < int , int >  pii;
typedef vector < int > vit;
typedef map < string , int > mstit;
typedef vector < pii > vpi ;
typedef greater < pii > gpi;
typedef priority_queue < pii , vpi , gpi > dijk ;


int n,h[100005],dp[100005];


int main(){
  cin.tie(0), ios::sync_with_stdio(false);
  cin >>n;
  iFOR(i,1,n+1) cin >>h[i];
  iFOR(i,2,n+1){
    dp[i]=abs(h[i-1]-h[i])+dp[i-1];
    if (i > 2) dp[i]=min(dp[i],abs(h[i-2]-h[i])+dp[i-2]);
  }
  cout <<dp[n] fin;
 
  return 0;
}



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

#ifdef DBG
void debug_(){ cout << endl; }
template<typename T, typename... Args>
void debug_(T&& x, Args&&... xs){
	cout << x << " "; debug_(forward<Args>(xs)...);
}
#define dbg(...) debug_(__VA_ARGS__);
#else
#define dbg(...) 
#endif

int main() {
	ios_base::sync_with_stdio(false);
	int K, A, B;
	cin >> K >> A >> B;
	for(int i=A; i<=B; i++){
		if(i%K==0){
			cout << "OK" << endl;
			return 0;
		}
	}
	cout << "NG" << endl;
	return 0;
}


Measured memory_bytes: 3640
n,k,q = map(int,input().split())
tokuten = [(k-q) for i in range(n+1)]
tokuten[0]=0
for i in range(q):
    a = int(input())
    tokuten[a]+=1
for i in range(1,n+1):
    if tokuten[i]>0:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 13004
# ENV[Z = 'RUBY_THREAD_VM_STACK_SIZE'] || exec( { Z => '50000000' },'ruby',$0)
# readlines.map(&:chomp!).map { |e| e.split.map(&:to_i) }
# gets.split.map(&:to_i)
#

s = gets.chomp

t = gets.chomp

if s == t.slice(0, t.length-1)
  puts "Yes"
else
  puts "No"
end


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

int main()
{

int N;cin>> N;
int K;cin >> K;
int Tab[N];
for(int i=0;i<N;i++)
    cin >> Tab[i];

int DP[N];
DP[0]=0;

for(int i=1;i<N;i++)
{
    int deb=max(0,i-K);
    int cur=1000000000;
    for(int j=deb;j<i;j++)
        cur=min(DP[j]+abs(Tab[j]-Tab[i]),cur) ;
    DP[i]=cur;
}

cout<<DP[N-1];
}

Measured memory_bytes: 1024
#include <algorithm>
#include <cassert>
#include <set>
#include <iostream>
#include <vector>

using namespace std;

#define rep(i, a, b) for (auto i = (a); i < (b); ++i)
#define per(i, a, b) for (auto i = (b) - 1; i >= (a); --i)
#define trav(x, v) for (auto &x : v)

#define sz(x) int((x).size())
#define eb(x...) emplace_back(x)
#define ff first
#define ss second

using ll = int64_t;
const ll inf = 2e18;

template<class T> bool ckmin(T& a, const T& b) { return a > b ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

struct Line {
	mutable ll k, m, p;
	bool operator<(const Line& o) const { return k < o.k; }
	bool operator<(ll x) const { return p < x; }
};
struct LineContainer : multiset<Line, less<>> {
	ll div(ll a, ll b) { return a / b - ((a ^ b) < 0 && a % b); }
	bool isect(iterator x, iterator y) {
		if (y == end()) { x->p = inf; return false; }
		if (x->k == y->k) x->p = x->m > y->m ? inf : -inf;
		else x->p = div(y->m - x->m, x->k - y->k);
		return x->p >= y->p;
	}
	void add(ll k, ll m) {
		auto z = insert({k, m, 0}), y = z++, x = y;
		while (isect(y, z)) z = erase(z);
		if (x != begin() && isect(--x, y)) isect(x, y = erase(y));
		while ((y = x) != begin() && (--x)->p >= y->p)
		isect(x, erase(y));
	}
	ll query(ll x) {
		assert(!empty());
		auto l = *lower_bound(x);
		return l.k * x + l.m;
	}
};

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

	int n; ll c; cin >> n >> c;
	ll h[n], f[n]; rep(i, 0, n) cin >> h[i];
	f[0] = 0;
	LineContainer L; L.add(2 * h[0], -f[0] - h[0] * h[0]);
	rep(j, 1, n) {
		f[j] = c + h[j] * h[j] - L.query(h[j]);
		L.add(2 * h[j], -f[j] - h[j] * h[j]);
	}
	cout << f[n - 1];
}

Measured memory_bytes: 15872
#include <stdio.h>
int parent(int i){
        return i/2;
}
int left(int i){
        return 2*i;
}
int right(int i){
        return 2*i+1;
}
int main(){
        int n,i;
        scanf("%d",&n);
        int A[100000];
        for(i=1; i<=n; i++) {
                scanf("%d",&A[i]);
        }
        for(i=1; i<=n; i++) {

                printf("node %d: key = %d, ",i,A[i]);
                if(parent(i)>=1) {
                        printf("parent key = %d, ",A[parent(i)]);
                }
                if(left(i)<=n) {
                        printf("left key = %d, ",A[left(i)]);
                }
                if(right(i)<=n) {
                        printf("right key = %d, ",A[right(i)]);
                }

                printf("\n");
        }
        return 0;
}

Measured memory_bytes: 608
#include <stdio.h>
#include <vector>

using namespace std;

int l;

struct edges{
	bool next;
	int weight;
};

vector<edges> edge_arr;

int main(){
	scanf("%d",&l);

	int n = 1;
	int m = 0;

	while(l>1) {
		//printf("%d\n",l);
		if(l%2==1) {
			edge_arr.push_back((edges){true,l});
			n += 1;
			m += 3;
		}else {
			edge_arr.push_back((edges){false,l});
			n += 1;
			m += 2;
		}
		l /= 2;
	}

	printf("%d %d\n",n,m);

	for(int i = 1; i <= edge_arr.size(); i++) {
		edges es = edge_arr[i-1];
		if(es.next) {
			printf("%d %d %d\n",i,n,es.weight-1);
			printf("%d %d %d\n",i,i+1,0);
			printf("%d %d %d\n",i,i+1,es.weight/2);
		}else {
			printf("%d %d %d\n",i,i+1,0);
			printf("%d %d %d\n",i,i+1,es.weight/2);
		}
	}
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,P;
  cin >> N >> P;
  vector<int> A(N);
  int E = 0;
  int O = 0;
  for (int i = 0; i < N; i++){
    cin >> A[i];
    if (A[i] % 2 == 0) E++;
    if (A[i] % 2 == 1) O++;
  }
  long long ans = 1;
  for (int i = 0; i < E; i++) ans*=2;
  //Calculate binomial coefficients
  vector<vector<long long>> B(O + 1,vector<long long>(O + 1));
  for (int i = 0; i <= O; i++){
    B[i][0] = 1;
    B[i][i] = 1;
    for (int j = 1; j < i; j++){
      B[i][j] = B[i - 1][j] + B[i - 1][j - 1];
    }
  }
  long long p = 0;
  for (int i = 0; i <= O; i++){
    if (i % 2 == P) p += B[O][i];
  }
  cout << ans * p;
}

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

using namespace std;

int main()
{
    int n, k;
    cin >> n >> k;
    int a[n], sums[n + 1], curr_sum = 0;
    for(int i = 0; i < n; i++)
    {
        cin >> a[i];
        curr_sum += a[i];
        sums[i + 1] = curr_sum;
    }
    sums[0] = 0;
    int max1 = -1;
    for(int i = k; i <= n; i++)
    {
        max1 = max(max1, sums[i] - sums[i - k]);
    }
    cout.precision(16);
    cout << fixed << (long double)(max1 + k) / 2 << endl;
    return 0;
}


Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int t = sc.nextInt();
        sc.close();

        int ans = t / a * b;
        System.out.println(ans);
    }
}


Measured memory_bytes: 23124
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <string>
using namespace std;
long long mod=1e9+7;
struct all{
	vector<long long> kai,gya,nck;
	all(long long n){
		kai.resize(n+1);
		gya.resize(n+1);
		nck.resize(n+1);
	}
	long long pow(long long x,long long n){
		long long ret=1;
		if(n>0){
			ret=pow(x,n/2);
			if(n%2==0){
				(ret=(ret*ret))%=mod;
			}else{
				(ret=((ret*ret)%mod)*x)%=mod;
			}
		}
		return ret;
	}
	long long inv(long long n){
		return pow(n,mod-2);
	}
	vector<long long> cul(long long n){
		kai[n]=n;
		for(int i=n-1;i>0;i--){
			(kai[i]=kai[i+1]*i)%=mod;
		}
		gya[1]=inv(1);
		for(int i=2;i<=n;i++){
			(gya[i]=gya[i-1]*inv(i))%=mod;
		}
		for(int i=1;i<=n;i++){
			(nck[i]=kai[n+1-i]*gya[i])%=mod;
		}
		nck[0]=1;
		nck[n]=1;
		return nck;
	}
};
int main(){
	long long n,k;
	cin>>n>>k;
	if(k>=n-1){
		all nii(2*n-1);
		vector<long long> hoge=nii.cul(2*n-1);
		cout<<hoge[n]<<endl;
	}else{
		long long ans=0;
		all nii(n);
		all mii(n-1);
		vector<long long> hogen=nii.cul(n);
		vector<long long> hogenn=mii.cul(n-1);
		for(int i=0;i<=k;i++){
			(ans+=(hogen[i]*hogenn[i]))%=mod;
		}
		cout<<ans<<endl;
	}
	return 0;
}


Measured memory_bytes: 12800
#include <algorithm>
#include <array>
#include <vector>
#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <functional>
#include <queue>
#include <random>
#include <map>
#include<iomanip>

//AtCoderC++.cpp

using namespace std;


#define rep(i,from,to) for(int i=from;i<to;i++)
#define ints(name,n) vector<int> name;name.resize(n)

template<typename T> void Show(vector<vector<T>> v, string delimiter = " ") {
	for (int i = 0; i < v.size(); i++) {
		for (int j = 0; j < v[i].size(); j++) {
			cout << v[i][j];
			if (j != v[i].size() - 1) {
				cout << delimiter;
			} else {
				cout << endl;
			}
		}
	}
}
template<typename T> void Show(vector<T> v, string delimiter = " ") {
	for (int i = 0; i < v.size(); i++) {
		cout << v[i];
		if (i != v.size() - 1) {
			cout << delimiter;
		} else {
			cout << endl;
		}
	}
}
template<typename T> vector<T> getUniform(T value, int n) {
	vector<vector<T>> ts;
	ts.resize(n);
	for (int i = 0; i < n; i++) {
		ts[i] = value;
	}
	return ts;
}
template<typename T> vector<vector<T>> getUniform(T value, int row, int col) {
	vector<vector<T>> ts;
	ts.resize(row);
	for (int i = 0; i < row; i++) {
		ts[i].resize(col);
		for (int j = 0; j < col; j++) {
			ts[i][j] = value;
		}
	}
	return ts;
}
bool All(vector<vector<bool>> ts) {
	int h = ts.size();
	int w = ts[0].size();
	rep(i, 0, h) {
		rep(j, 0, w) {
			if (!ts[i][j])return false;
		}
	}
	return true;
}


int main() {
	int a, e, k;
	cin >> a >> e >> e >> e >> e >> k;
	cout << ((e - a > k) ? ":(" : "Yay!") << endl;
}




Measured memory_bytes: 256
from copy import deepcopy
from sys import exit,setrecursionlimit
import math
from collections import defaultdict,Counter,deque
from fractions import Fraction as frac
import fractions
from functools import reduce
from operator import mul
import bisect
import sys
import logging
import heapq
import itertools

logging.basicConfig(level=logging.ERROR)

input = sys.stdin.readline

setrecursionlimit(1000000)


def main():
    a,b = map(int,input().split())
    for i in range(1,100000):
        if int(i*0.08) == a and int(i*0.1) == b:
            print(i)
            return
    print(-1)

main()

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

#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << " = " << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define SP << " " <<

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
typedef vector<int> vec;
typedef vector<P> pvec;
typedef vector<vector<int>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<int> PQI;
typedef priority_queue<P> PQP;
typedef priority_queue<int,vector<int>,greater<int>> PQIG;
typedef priority_queue<P,vector<P>,greater<P>> PQPG;

const vector<int> DX = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> DY = {1, 0, -1, 0, 1, -1, 1, -1};
constexpr int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30); // 1073741824
const ll INF = (1LL << 60); // 1152921504606846976
const double PI = (3.141592653589794);
const double EPS = (0.0000000001); // 10^(-10)

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> inline T ceil(T a, T b) {return T((a + b - 1) / b);}
template<class T> inline T round(T a, T b) {return T(a / b);}
template< typename T1, typename T2 > istream &operator>>(istream &is, pair< T1, T2 > &p) { is >> p.first >> p.second; return is; }
template <class T> inline void out(T &a) { bool flag=true; for(auto&x:a){if(flag) {flag=false;} else{ cout << ' '; } cout<<x; } cout << endl; }



//----------------------------------------------------------------
int nmax=200000; // 2*(10^5)
vvec G(nmax);





void solve4ts()
{
    
    string s;
    string t;
    cin>>s>>t;
    int ng=0;
    rep(i,s.size()) if(s[i]!=t[i]) ng++;
    if(ng==0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    
}
//-----------------------------------------------------------------

signed main(){ ios::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(15);
    int repeat = 1;
    // cin >> repeat;
    while(repeat--) solve4ts();
}

Measured memory_bytes: 7808
a, b, x = list(map(float, input().split()))

import math
if x / a <= a * b / 2:
  print(math.atan(a * b ** 2 / 2 / x) * (180 / math.pi))
else:
  print(math.atan(2 * (a**2 * b - x) / a**3) * (180 / math.pi))


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define rfor(i,a,b) for(ll (i) = (a); (i) > (b); --(i))
#define ll long long
#define mod (1000000007)
#define pf(a) cout << (a) << endl;
#define all(x) (x).begin(),(x).end()

ll gcd(ll a,ll b){
    if(b == 0) return a;
    return gcd(b,a%b);
}

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b;
}

ll factorial(ll n){
    ll t = 1;
    rep1(i, n)t *= i;
    return t;
}

ll combinations(ll n, ll k) {
    ll r = 1;
    for (ll d = 1; d <= k; ++d) {
        r *= n--;
        r /= d;
    }
    return r;
}

int main()
{
    ll n,c,k,ans = 0,T = 0,rest = 0;
    cin >> n >> c >> k;
    priority_queue<ll,vector<ll>,greater<ll>> q;
    rep0(i, n){
        ll t;
        cin >> t;
        q.push(t);
    }
    while (!q.empty()) {
        if(q.top() > T || rest == 0){
            ++ans;
            rest = c - 1;
            T = q.top() + k;
        }else{
            --rest;
        }
        q.pop();
    }
    pf(ans);
    return 0;
}


Measured memory_bytes: 1400
N, M = map(int, input().split())
K = [0] * N 
A = [0] * N 
KA = [0] * N
for i in range(N):
    KA[i] = list(map(int, input().split()))
    K[i] = KA[i][0]
    A[i] = KA[i][1:]

count = [0] * M 

for i in range(N):
    for j in range(K[i]):
        tmp = A[i][j]
        count[tmp-1] += 1

print(count.count(N))

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

int main(){
    ios::sync_with_stdio(false);

    int a, b, c, k, r;

    cin>>a>>b>>c>>k;

    r = a+b+c;
    r += max(a, max(b, c))*(pow(2, k)-1);

    cout<<r<<endl;

    return 0;
}

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

int main() {

	int n;
	scanf("%d", &n);
	vector<int> a(n);
	for(int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
	}
	bool jud = true;
	int ans = 0;
	while(true) {
		for(int i = 0; i < n; i++) {
		    if(a[i] % 2 != 0) {
			   jud = false;
			   break;
			}
		}
		if(jud == false) {
		   break;
		}
		for(int i = 0; i < n; i++) {
			a[i] = a[i] / 2;
		}
		ans++;
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 256
def main():
	N = int(input())
	d_i, d_div = 0, 0
	sqrt = int(N**0.5)
	for i in range(1, sqrt+1):
		div, mod = divmod(N, i)
		if mod == 0:
			d_i = i
			d_div = div
	ans = 0
	while d_div != 0:
		ans += 1
		d_div //= 10
	print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
program atcoder
    implicit none
    integer(8) :: i,j,n,m,ans=0,k
    integer(8),allocatable,dimension(:) :: a,sum
    read*,n,m
    allocate(a(m))
    allocate(sum(m))
    sum = 0
    do i=1,n
        a = 0
        read(*,*)k,(a(j),j=1,k)
        do j=1,k
            sum(a(j)) = sum(a(j)) + 1
        enddo
    enddo
    do i=1,m
        if(sum(i)==n)then
            ans = ans + 1
        endif        
    enddo
    write(*,'(i0)')ans
    stop 
contains
end program atcoder

Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
int main() {
	string S;
	cin >> S;
	string T = "keyence";
	int len = S.size();
	if (S == T) {
		cout << "YES" << endl;
		return 0;
	}
	for (int i = 0; i < len; i++) {
		for (int j = i; j < len; j++) {
			string A = "";
			for (int k = 0; k < len; k++) {
				if (i <= k && k <= j) continue;
				else A.push_back(S.at(k));
			}
			if (A == T) {
				cout << "YES" << endl;
				return 0;
			}
		}
	}
	cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256
from collections import Counter
N, K = map(int,input().split())
A = list(map(int,input().split()))
i = k = 0
B = [1]
for i in range(N):
    B.append(A[B[i]-1])

S = Counter(B)
idx = S.most_common(1)[0][0]
i = k = cnt = 0
k_s = None

while k < N:
    if B[k] == idx and cnt == 1:
        k_s = k
        break
    elif B[k] == idx:
        k_f = k
        cnt += 1
    k += 1
if k_s and k_s < K:
    k_max = (K - B.index(idx)) % (k_s - k_f) + B.index(idx)
else:
    k_max = K
i = k = 0
while k < k_max:
    i = A[i] - 1
    k += 1
print(i + 1) 

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

using namespace std;

//#define FILE_IO

int N, M;
int f[100005];

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

    scanf("%d%d", &N, &M);
    for(int i = 1; i <= M; i++)
    {
        int x, y;
        scanf("%d%d", &x, &y);
        f[x] ^= 1; f[y] ^= 1;
    }

    for(int i = 1; i <= N; i++)
        if(f[i])
        {
            printf("NO\n");
            return 0;
        }
    printf("YES\n");
    return 0;
}


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

#define MAX_N 10005

int prime[MAX_N]; // i番目の素数
bool is_prime[MAX_N + 1]; // is_prime[i]がtrueならiは素数
// n以下の素数の数を返す
int sieve(int n) {
	int p = 0;
	for (int i = 0; i <= n; i++){
		is_prime[i] = true;
	}
	is_prime[0] = is_prime[1] = false;
	for (int i = 2; i <= n; i++) {
		if (is_prime[i]) {
			prime[p++] = i;
			for (int j = 2 * i; j <= n; j += i) is_prime[j] = false;
		}
	}
	return p;
}

long long N;

int main(){
	cin >> N;

	sieve(10000);
	long long num = 0;
	vector<long long>ans;
	for(long long i = 0; i <10000; i++){
		if(is_prime[i] && i%5 == 1){
			ans.push_back(i);
		}
	}

	for(long long i = 0; i < N; i++){
		cout << ans[i];
		if(i != N-1)
			cout << " ";
		else
			cout << endl;
	}
}

Measured memory_bytes: 256
import sys
import math
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0

a,b,h,m = map(int,readline().split())

degree = abs(h*30+30*(m/60) - m*6)
degree = min(degree,360-degree)
print(math.sqrt(a**2+b**2-2*a*b*math.cos(math.radians(degree))))

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

using namespace std;

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

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

	int N, K; cin >> N >> K;
	vector<int> a(N, 0);
	rep (i, N){
		cin >> a[i];
	} // end rep

	sort(ALL(a));
	
	int M = a[N - 1];

	int G = __gcd(a[0], a[1]);
	for (int i = 2; i < N; ++i){
		G = __gcd(G, a[i]);
	} // end for

	if (K <= M && K % G == 0){
		cout << "POSSIBLE" << endl;
	}else{
		cout << "IMPOSSIBLE" << endl;
	} // end if

	return 0;
}

Measured memory_bytes: 768
n,k=map(int,input().split())
l=list(map(int,input().split()))
double=[[0]*(n+1) for i in range(61)]
for i in range(1,n+1):
    double[0][i]=l[i-1]
for i in range(1,61):
    for j in range(n+1):
        double[i][j]=double[i-1][double[i-1][j]]
ans=1
for i in range(61):
    if k>>i&1:
        ans=double[i][ans]
print(ans)

Measured memory_bytes: 173616
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<set>
#include<map>

using namespace std;

int main(void) {
	int w, a, b;
	cin >> w >> a >> b;
	if (b > a + w) {
		cout << b - (a + w);
	}
	else if (b + w < a) {
		cout << a - (b + w);
	}
	else {
		cout << 0;
	}
	return 0;
}

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

int main(void) {
  int N;
  scanf("%d", &N);
  int six[] = {1, 6, 36, 216, 1296, 7776, 46656};
  int nine[] = {1, 9, 81, 729, 6561, 59049};
  int min = N;
  for (int s1 = 0; s1 < 6; s1++)
    for (int s2 = 0; s2 < 6; s2++)
      for (int s3 = 0; s3 < 6; s3++)
        for (int s4 = 0; s4 < 6; s4++)
          for (int s5 = 0; s5 < 6; s5++)
            for (int s6 = 0; s6 < 3; s6++)
              for (int n1 = 0; n1 < 9; n1++)
                for (int n2 = 0; n2 < 9; n2++)
                  for (int n3 = 0; n3 < 9; n3++)
                    for (int n4 = 0; n4 < 9; n4++)
                      for (int n5 = 0; n5 < 2; n5++) {
                        int t = s1*six[1]+s2*six[2]+s3*six[3]+s4*six[4]+s5*six[5]+s6*six[6]+
                          n1*nine[1]+n2*nine[2]+n3*nine[3]+n4*nine[4]+n5*nine[5];
                        int t2 = N-t+s1+s2+s3+s4+s5+s6+n1+n2+n3+n4+n5;
                        if (t <= N && t2 < min) {
                          min = t2;
                        }
                      }
  printf("%d\n", min);

  return 0;
}

Measured memory_bytes: 128
n,a,b = map(int,input().split())
mod = 10**9+7
def combmod(n,k,mod):
    x = y = 1
    for i in range(min(k,n-k)):
        x = x*(n-i)%mod
        y = y*(i+1)%mod
    return x * pow(y, mod-2, mod) % mod
ans = (((pow(2, n, mod) - 1)%mod - combmod(n, a, mod))%mod - combmod(n, b, mod))%mod
print(ans)

Measured memory_bytes: 3064
n = int(input())
s = input()
first = set([])
ans = 0
for i in range(n - 2):
    if s[i] not in first:
        first.add(s[i])
        second = set([])
        for j in range(i + 1, n - 1):
            if s[j] not in second:
                second.add(s[j])
                ans += len(set(list(s[j + 1:])))
print(ans)

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

using namespace std;

#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long LL;
typedef pair<int, int> PII;

int n;
int a[100005];


int main() {
    scanf("%d", &n);
    forn(i, n) scanf("%d", a + i);
    sort(a, a + n);
    if (a[0] >= 0) {
        int ans = -a[0];
        for (int i = 1; i < n; ++i) {
            ans += a[i];
        }
        printf("%d\n", ans);

        ans = a[0];
        for (int i = 1; i < n - 1; ++i) {
            printf("%d %d\n", ans, a[i]);
            ans -= a[i];
        }
        printf("%d %d\n", a[n - 1], ans);
        return 0;
    }
    if (a[n - 1] <= 0) {
        int ans = a[n - 1];
        forn(i, n - 1) {
            ans -= a[i];
        }
        printf("%d\n", ans);

        ans = a[n - 1];
        forn(i, n - 1) {
            printf("%d %d\n", ans, a[i]);
            ans -= a[i];
        }
        return 0;
    }
    int ans = 0;
    forn(i, n) {
        ans += abs(a[i]);
    }
    printf("%d\n", ans);

    forn(i, n - 1) if (a[i] >= 0) {
        printf("%d %d\n", a[0], a[i]);
        a[0] -= a[i];
    }
    forn(i, n - 1) if (a[i] < 0) {
        printf("%d %d\n", a[n - 1], a[i]);
        a[n - 1] -= a[i];
    }
    return 0;
}


Measured memory_bytes: 2304
n,m,*t=map(int,open(0).read().split())
e=[[]for _ in range(n)]
for a,b in zip(*[iter(t)]*2):
  e[a-1]+=b-1,
  e[b-1]+=a-1,
o=[]
s=[0]
f=[1]*n
for v in s:
  o+=v,
  f[v]=0
  t=[]
  for w in e[v]:
    if f[w]:
      s+=w,
      t+=w,
  e[v]=t
dp1=[0]*n
c=[[]for _ in range(n)]
for v in o[::-1]:
  x,y=[1],[1]
  for w in e[v]:x+=x[-1]*(dp1[w]+1)%m,
  for w in e[v][::-1]:y+=y[-1]*(dp1[w]+1)%m,
  dp1[v]=x[-1]
  c[v]=x,y[-2::-1]
dp2=[1]+[0]*n
for v in o:
  for w,x,y in zip(e[v],*c[v]):dp2[w]=(dp2[v]*x*y+1)%m
for x,y in zip(dp1,dp2):print(x*y%m)

Measured memory_bytes: 126568
#include <iostream>
#include <vector>
#include <algorithm>
#define ll long long int
#define pb push_back
#define mp make_pair

using namespace std;

int main(){

    int N;
    cin >> N;

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

    ll ans = 0;
    ll sum = 0;
    int t = -1;

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

        for(t++;t<N;t++){

            if((sum & vec[t]) == 0){
                sum^=vec[t];
            }
            else{
                break;
            }
        }
        t -= 1;

        ans += t - i + 1;

        sum^=vec[i];

    }

    cout << ans << endl;

    return 0;
}

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

//何が違うか全くわからない

int main() {
    int N,M;
    cin >> N >> M;
    vector<pair<int,string>> VP(M,pair<int,string>(0,""));
    vector<int> Rslt(N+1,0); //もう正解していたら-1に。番号はそのままでok
    //不正解ごとにカウントを1ずつ増やしていく。
    int miss=0;

    rep(i,M){
        cin >> VP.at(i).first >> VP.at(i).second;
    }

    rep(i,M){
        int now=VP.at(i).first;
        string res=VP.at(i).second;
        if(Rslt.at(now)!=-1){
            if(res=="WA") Rslt.at(now)++;
            else if(res=="AC") {
                miss+=Rslt.at(now);
                Rslt.at(now)=-1;
            }
        }
    }

    int cr=0;
    rep(i,N+1){
        if(Rslt.at(i)==-1) cr++;
    }

    cout << cr << " " << miss << endl;
}

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


int main() {
    int N, X;
    cin >> N >> X;
    vector <int> L(N);
    for (int i=0; i<N; i++) cin >> L.at(i);
    int ans=1;
    int D=0;
    for (int i=0; i<N; i++) {
        D=D+L.at(i);
        if (D>X) {
            cout << ans;
            return 0;
        }
        ans++;
    }
    cout << ans;
}

Measured memory_bytes: 256