akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int x,a,b;
  cin >> x >> a >> b;
  string ans;
  if(a>=b) ans="delicious";
  else {
    if(b-a>=x+1) ans="dangerous";
    else ans="safe";
  }
  cout << ans << endl;
  return 0;
}
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define EB emplace_back
#define int ll

using namespace std;

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

const int INF = 1e9 + 7;

int a[200005], b[200005], c[200005];

int32_t main()
{
	IO_OP;
	
	int n;
	cin >> n;
	for(int i=1;i<=n;i++)
		cin >> a[i];
	for(int i=1;i<=n;i++) {
		b[i] = b[i - 1] + a[i];
		c[i] = c[i - 1] ^ a[i];
	}
	int ans = 0;
	for(int i = 0, j = 1; i < j && j <= n; ) {
		if((b[j] - b[i]) == (c[j] ^ c[i])) {
			j++;
			ans += j-i-1;
		} else {
			i++;
		}
	}
	cout << ans << endl;
}



Measured memory_bytes: 4992
#pragma GCC target("sse,sse2,sse3,sse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")

#include <bits/stdc++.h>

using namespace std;

using ll = long long;

ll mod = 1e9+7;

int main(){
    int N;cin >> N;
    vector<vector<int>> vec(N);
    for(int i = 0;i < N;i++){
        int b;cin >> b;
        for(int j = 0;j < b;j++){
        int q;cin >> q;vec.at(i).push_back(q);
        }
    }
    ll ans = 0;
    priority_queue<int> que;
    reverse(vec.begin(), vec.end());
    for(int i = 0;i < N;i++){
        for(auto a : vec.at(i))que.push(a);
        ans += que.top();
        que.pop();
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 19100
N,P,*as=$<.read.split.map(&:to_i)

A=Array.new(101,0)
n = 1
1.upto(100) do |i|
    n *= i
    A[i] = n
end

e=as.count{|a|a.even?}
o=as.count{|a|a.odd?}

if P==1 && o==0
    puts 0
    exit 0
end

def c(m,n)
    return 1 if A[n]*A[m-n] == 0
    A[m] / (A[n]*A[m-n])
end

r=0
P.step(o,2) do |i|
    r+=2**e*c(o,i)
end
puts r

Measured memory_bytes: 1788
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<utility>
#define gc getchar()
#define fir first
#define sec second
#define N 510
using namespace std;
inline int inn()
{
	int x,ch;while((ch=gc)<'0'||ch>'9');
	x=ch^'0';while((ch=gc)>='0'&&ch<='9')
		x=(x<<1)+(x<<3)+(ch^'0');return x;
}
int fa[N*N],ans[N*N];pair<int,int> x[N];
inline int findf(int x)
{
	int fx=x,y;while(fa[fx]^fx) fx=fa[fx];
	while(x^fx) y=fa[x],fa[x]=fx,x=y;return fx;
}
int main()
{
	int n=inn(),tot=n*n;
	for(int i=1;i<=n;i++) x[i].fir=inn(),x[i].sec=i;
	sort(x+1,x+n+1);for(int i=1;i<=tot;i++) fa[i]=i;
	for(int i=n;i>=1;i--)
	{
		int ps=x[i].fir,t=x[i].sec;ans[ps]=t,fa[ps]=ps-1;
		for(int j=1;j<=n-t;j++)
		{
			int p=findf(tot);
			if(p<ps) return !printf("No\n");
			ans[p]=t,fa[p]=p-1;
		}
	}
	for(int i=n,p;i>=1;i--)
		for(int ps=x[i].fir,t=x[i].sec,j=1;j<t;j++)
			if((p=findf(tot))>ps) return !printf("No\n");
			else ans[p]=t,fa[p]=p-1;
	printf("Yes\n");
	for(int i=1;i<=n*n;i++) printf("%d ",ans[i]);
	return !printf("\n");
}

Measured memory_bytes: 3072
#include <stdio.h>
int main(void){
	int x = 0, j = 0;
	for(int i = 1; j != 1; i++){
		scanf("%d", &x);

		if (x == 0){
			break;
		}
		
		printf("Case %d: %d\n", i, x);
	}
}

Measured memory_bytes: 2708
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

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

    double ans = 0;
    for(int i=0; i<n; ++i){
        double x;
        string u;
        cin >> x >> u;
        if(u == "JPY")
            ans += x;
        else
            ans += x * 380000.0;
    }
    printf("%.10f\n", ans);

    return 0;
}


Measured memory_bytes: 256
n=int(input())
A=[int(_) for _ in input().split()]
full=0
sumsum=0
for a in range(len(A)-1):
    sumsum=(sumsum+A[len(A)-a-1])%(10**9+7)
    full=(full+sumsum*A[len(A)-a-2])%(10**9+7)

print(full)



Measured memory_bytes: 94224
#include <stdio.h>

int main(void){

    int i, x;

    for (i = 1; i <= 10000; i++) {
        scanf("%d", &x);
        if (x == 0) {
            break;
        }

        printf("Case %d: ", i);
        printf("%d\n", x);

    }

    return 0;

}



Measured memory_bytes: 2064
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <iostream>
#include <queue>
#include <stack>
#define lson rt<<1
#define rson rt<<1|1
using namespace std;
typedef long long ll;
typedef pair<int, int>  P;
typedef pair<int, P>  PP;
const int maxn=2e5+10;
int a[33]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int main()
{
    int n;
    cin>>n;
    cout<<a[n-1];
}


Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
typedef vector<int> vi;
typedef vector<ll> vl;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define IN cin >> 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (m-1); i >= (int)(n); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v,c) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////


int main(){
    int a ,b;
    cin >> a >> b;
    P(a+b/2);
    
	return  0;
}

Measured memory_bytes: 256
import sys

S = sys.stdin.readline().strip()
T = sys.stdin.readline().strip()

ls = len(S)
lt = len(T)
match = 0
for i in range(ls - lt + 1):
    tmp = 0
    for j in range(lt):
        if S[i+j] == T[j]:
            tmp += 1
    match = max(match, tmp)

print(lt - match)

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

typedef long long ll;
ll MOD = 1000000007;

struct bit {
	vector<ll> v;
	bit(int n) : v(n + 1) {}
	ll sum(int i) {
		ll res = 0;
		for (; i > 0; i -= i & -i) res += v[i];
		return res;
	}
	void add(int i, ll x) {
		for (i++; i < v.size(); i += i & -i) v[i] += x;
	}
};

int B = 300;

int main() {
	int N; cin >> N;
	vector<int> p(N);
	for (int i = 0; i < N; i++) {
		scanf("%d", &p[i]);
		p[i]--;
	}
	vector<vector<int> > num(N / B + 1, vector<int>(N + 1));
	for (int i = 0; i < N; i++)
		num[p[i] / B][i + 1]++;
	for (int j = 0; j <= N / B; j++)
		for (int i = 0; i < N; i++)
			num[j][i + 1] += num[j][i];
	int Q; cin >> Q;
	vector<vector<int> > query(N);
	vector<int> l(Q), r(Q);
	for (int q = 0; q < Q; q++) {
		scanf("%d%d", &l[q], &r[q]);
		l[q]--; r[q]--;
		query[r[q]].push_back(q);
	}
	vector<int> index(N, -1);
	bit bt(N);
	vector<int> A(N / B + 1);
	vector<vector<int> > v(N / B + 1);
	vector<vector<ll> > sum(N / B + 1, vector<ll>(1));
	ll cur = 0;
	vector<ll> ans(Q);
	for (int i = 0; i < N; i++) {
		for (int x = N - 1; x > p[i];) {
			if (x % B == B - 1 && x - B >= p[i]) {
				A[x / B]++;
				cur += v[x / B].size();
				x -= B;
			}
			else {
				if (index[x] != -1) {
					bt.add(index[x], 1);
					cur++;
				}
				x--;
			}
		}
		int x = p[i];
		index[x] = i;
		ll prev = sum[x / B].back();
		v[x / B].push_back(i);
		sum[x / B].push_back(prev + A[x / B]);
		for (int k = 0; k < query[i].size(); k++) {
			int q = query[i][k];
			ans[q] = cur - bt.sum(l[q]);
			for (int i = 0; i <= N / B; i++) {
				int j = num[i][l[q]];
				ans[q] -= (ll)j * A[i] - sum[i][j];
			}
		}
	}
	for (int q = 0; q < Q; q++)
		printf("%lld\n", ans[q]);
}

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

#define llint long long int

using namespace std;

int main()
{
    int N;
    string c;

    cin >> N >> c;

    int w = 0;
    int r = N - 1;
    int ans = 0;

    while (1)
    {
        for (; c[w] != 'W' && w < N; w++)
        {
        }
        for (; c[r] != 'R' && r >= 0 && w < r; r--)
        {
        }
        if (w < N && r >= 0 && w < r)
        {
            char t = c[w];

            c[w] = c[r];
            c[r] = t;

            ans++;
            w++;
            r--;
        }
        else
        {
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3748
import java.awt.Point;
import java.util.Scanner;

public class Main{

	static final Scanner s=new Scanner(System.in);

	public static void main(String args[]){
		System.out.printf(
				"%.5f",
				Point.distance(
						s.nextDouble(),
						s.nextDouble(),
						s.nextDouble(),
						s.nextDouble()
						)
				);
	}
}

Measured memory_bytes: 28248
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i = a; i < b; i++)
#define REP(i, n) FOR(i, 0, n)
#define INF 999999999
typedef long long ll;
using namespace std;
int main() {
    string n;
    cin >> n;
    ll sum = 0;
    REP(i, n.length()){
        sum += n[i]-'0';
    }
    if(atoi(n.c_str()) % sum == 0) puts("Yes");
    else puts("No");
}

Measured memory_bytes: 256
def is_all(x):
    for i in range(len(x)-1):
        if x[i]!=x[i+1]:
            return False
    return True
s=input()
n=len(s)
dic={}
for i in range(n):
    if not s[i] in dic:
        dic[i]=s[i]
a=n
for i in range(len(dic)):
    t=[s[j] for j in range(n)]
    for j in range(n-1,-1,-1):
        if t[j]==dic[i]:
            ans=n-j-1
            break
        else:
            t[j]=dic[i]
    cnt=0
    while not is_all(t):
        cnt+=1
        for j in range(1,n):
            if t[j]==dic[i]:
                t[j-1]=dic[i]
    a=min(max(cnt,ans),a)
print(a)

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

int main(){
	int n;
	cin >> n;
	map<string, int> mp;
	rep(i, n){
		string s;
		cin >> s;
		mp[s]++;
	}
	
	cout << "AC x " << mp["AC"] << endl;
	cout << "WA x " << mp["WA"] << endl;
	cout << "TLE x " << mp["TLE"] << endl;
	cout << "RE x " << mp["RE"] << endl;
	return 0;
}



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

long nCr(int n, int r)
{
  if (n == 0 || n == 1)
    return 0;
  long ans = 1;
  for (int i = 0; i < r; i++)
  {
    ans *= (n-i);
  }
  for (int i = 1; i <= r; i++)
  {
    ans /= i;
  }
  return ans;
}

int main()
{
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);
  map<int, int> map_A;
  for (int i = 0; i < N; i++)
  {
    if (map_A.count(A.at(i)))
      map_A.at(A.at(i)) += 1;
    else
      map_A[A.at(i)] = 1;
  }
  map<int, pair<long, long> > comb_A;
  long long sum = 0;
  for (auto x : map_A)
  {
    long tmp1 = nCr(x.second, 2);
    long tmp2 = nCr(x.second-1, 2);
    comb_A[x.first] = make_pair(tmp1, tmp2);
    sum += tmp1;
  }
  for (int i = 0; i < N; i++)
  {
    cout << sum - comb_A.at(A.at(i)).first + comb_A.at(A.at(i)).second << endl;
  }
}


Measured memory_bytes: 16256
n = int(input())
h = list(map(int,input().split()))
tmp = h[0]
minused = False
res = True
for i in range(1,n):
    if h[i]>tmp:
        tmp = h[i]
        minused = False
        #print(1)
    elif tmp == h[i]:
        tmp = h[i]
        #print(2)
    else:
        if tmp-1>h[i]:
            res = False
            #print(3)
            break
        else:
            if minused:
                res = False
                #print(4)
                break
            minused = True
            tmp = tmp-1
            #print(5)
if res:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 14252
//#include    <bits/stdc++.h>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <cassert>
#include <iterator>
#include <complex>
#define N  100010
#define mem(a,b) memset(a,b,sizeof(a))
#define IOS ios::sync_with_stdio(false)
#define INF 0x3f3f3f3f
template<typename T> inline T max(T a,T b,T c){
    return max(a,max(b,c));
}
template<typename T> inline T min(T a,T b,T c){
    return min(a,min(b,c));
}
template<typename T> inline T max(T a,T b,T c,T d){
    return max(a,max(b,c,d));
}
template<typename T> inline T min(T a,T b,T c,T d){
    return min(a,min(b,c,d));
}
const int  dx[]={0,1,0,-1,0,1,-1,1,-1};
const int  dy[]={0,0,1,0,-1,1,-1,-1,1};
typedef long long ll;
using namespace std;
char  s[10];
ll a[N];
int main(){
    IOS;
   ll n;
   cin>>n;
   ll sum=0;
   memset(a,0,sizeof(a));
   while (n--)
   {
       cin>>s;
       if (s[0]=='M') a[0]++;
       else if (s[0]=='A') a[1]++;
       else if (s[0]=='R') a[2]++;
       else if (s[0]=='C') a[3]++;
       else if (s[0]=='H') a[4]++;
   }
    for (ll i=0;i<5;i++)
          for (ll j=i+1;j<5;j++)
            for (ll k=j+1;k<5;k++)
              sum+=a[i]*a[j]*a[k];
              cout << sum << endl;
  return 0;
}


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

using namespace std;

using ll = long long;

bool Solve() {
    string s, t;
    cin >> s >> t;

    const int n = s.size();
    vector<bool> used(n, false);
    for (int i = 0; i < n; ++i) {
        if (used[i]) continue;
        set<int> idx_s;
        for (int j = i; j < n; ++j) {
            if (s[i] == s[j]) {
                used[j] = true;
                idx_s.insert(j);
            }
        }

        set<int> idx_t;
        for (int j = 0; j < n; ++j) {
            if (t[i] == t[j])
                idx_t.insert(j);
        }

        if (idx_s != idx_t) return false;
    }

    return true;
}

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

    if (Solve()) cout << "Yes\n";
    else cout << "No\n";

    return 0;
}


Measured memory_bytes: 10004
#include<bits/stdc++.h>
using namespace std;
using i64 = int_fast64_t;
#define rep(i, N) for(i64 i = 0; i < N; i++)
#define Rep(i, k, N) for(i64 i = k; i < N; i++)
#define all(v) v.begin(), v.end()
#define eb emplace_back
#define Cout(s) cout << s << endl
string Yes(bool b) {if(b){return "Yes";} else {return "No";}}
string YES(bool b) {if(b){return "YES";} else {return "NO";}}

int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, N) cin >> A[i];

    vector<int> table(*max_element(all(A)) + 1, 1); 
    sort(all(A));

    int ans = 0;
    for(const auto& a : A){
        if(table[a] == -1){
            ans--;
            table[a] = 0;
        }
        if(table[a]){
            ans++;
            table[a] = -1;
            for(int i = 2*a; i < table.size(); i += a){
                table[i] = 0;
            }
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 8008
#include <iostream>

// 最大公約数
template <typename T>
T gcd(T a, T b) {
  if (b > a) {
    T tmp = a;
    a = b;
    b = tmp;
  }
  // 避け
  if (a <= 0) {
    return -1;
  }

  T r = a % b;
  while (r != 0) {
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}
template <typename T = float>
T gcd(T a, T b);
template <typename T = double>
T gcd(T a, T b);

// 最小公倍数
template <typename T>
T lcm(T a, T b) {
  return a * b / gcd(a, b);
}
template <typename T = float>
T lcm(T a, T b);
template <typename T = double>
T lcm(T a, T b);

int main() {
  uint64_t a, b, c, d;
  std::cin >> a >> b >> c >> d;

  uint64_t cs = ((a % c) == 0) ? (a / c) : (a / c + 1);
  uint64_t ce = b / c;

  uint64_t ds = ((a % d) == 0) ? (a / d) : (a / d + 1);
  uint64_t de = b / d;

  uint64_t l = lcm(c, d);
  uint64_t ls = ((a % l) == 0) ? (a / l) : (a / l + 1);
  uint64_t le = b / l;

  std::cout << b - a + 1 - ((ce - cs + 1) + (de - ds + 1) - (le - ls + 1))
            << std::endl;
  return 0;
}


Measured memory_bytes: 256
/*input
45 1
17 55 85 55 74 20 90 67 40 70 39 89 91 50 16 24 14 43 24 66 25 9 89 71 41 16 53 13 61 15 85 72 62 67 42 26 36 66 4 87 59 91 4 25 26
*/

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

int n, p;
long long dp[N][2];
int main() {
	scanf("%d %d", &n ,&p);
	dp[0][0] = 1;
	for (int i = 1; i <= n; i++) {
		int x; scanf("%d", &x);
		for (int j = 0; j < 2; j++) dp[i][j] = dp[i - 1][j] + dp[i - 1][(j + x) & 1];
	}
	printf("%lld\n", dp[n][p & 1]);
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int i;
  int a, b, n, s;

  while(scanf("%d%d%d", &a, &b, &n) != EOF){
    a %= b;
    s = 0;
    for(i = 0; i < n; i++){
      a *= 10;
      s += a/b;
      a %= b;
    }
    printf("%d\n", s);
  }
  return 0;
}

Measured memory_bytes: 596
target = [5,7,5,7,7]
while True:
    N = int(input())
    if N == 0: break
    src = [len(input()) for i in range(N)]
    ans = -1
    for i in range(N):
        j = i
        _t = target[::-1]
        while True:
            if src[j] > _t[-1]: break
            if src[j] == _t[-1]:
                _t.pop()
                if len(_t) == 0:
                    ans = i+1
                    break
            else:
                _t[-1] -= src[j]
            j += 1
        if ans >= 0:
            print(ans)
            break

Measured memory_bytes: 5612
#include <bits/extc++.h>

#ifndef DUMP
#define DUMP(...) (void)0
#endif

using namespace std;

int main() {
  cin.tie(nullptr)->sync_with_stdio(false);
  int n;
  cin >> n;
  int64_t res = 0;
  int mx = 0;
  while (n--) {
    int a;
    cin >> a;
    mx = max(mx, a);
    res += mx - a;
  }
  cout << res << '\n';
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int, int>> vpii;
typedef pair<int, int> pii;
#define PB push_back
#define EB emplace_back
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

int main(){
	int a, b, c, d; scanf("%d%d%d%d", &a, &b, &c, &d);
	printf("%d\n", (a-c)*(b-d));
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
#define vall(x) (x).begin(), (x).end()
using namespace std;
using lli = long long int;
void YESNO(bool), YesNo(bool);
template <class T1, class T2>
bool chmin(T1 &l, const T2 &r);
template <class T1, class T2>
bool chmax(T1 &l, const T2 &r);
template <class T1, class T2>
void vadd(vector<T1> &v, T2 x);

#define int long long int
lli po[200005] = {};
lli inv(lli p)
{
  lli n = 2017;
  lli ret = 1;
  while (n)
  {
    if (n & 1)
      ret *= p;
    p *= p;
    p %= 2019;
    ret %= 2019;
    n /= 2;
  }
  return ret;
}
void solve(string S)
{
  map<lli, lli> m;
  int n = S.size();
  lli mod = 0;
  po[0] = 1;
  rep(i, n + 1) po[i + 1] = (po[i] * 10) % 2019;
  lli ret = 0;
  rrep(i, n)
  {
    mod += lli(S[i] - '0') * po[n - 1 - i];
    mod %= 2019;
    m[mod]++;
  }
  m[0]++;
  rep(i, 2019)
  {
    ret += m[i] * (m[i] - 1) / 2;
  }
  // lli ret = m[0];
  // lli base = 0;
  // rrep(i, n)
  // {
  //   base += lli(S[i] - '0') * po[n - 1 - i];
  //   base %= 2019;
  //   ret += m[base] * (m[base] - 1) / 2;
  //   // ret += m[inv(po[i + 1])] * m[inv(po[i + 1])];
  // }
  cout << ret;
}

signed main()
{
  string S;
  cin >> S;
  solve(S);
  return 0;
}

// -- lib
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }

template <class T1, class T2>
bool chmin(T1 &l, const T2 &r)
{
  return (l > r) ? (l = r, true) : false;
}

template <class T1, class T2>
bool chmax(T1 &l, const T2 &r)
{
  return (l < r) ? (l = r, true) : false;
}

template <class T1, class T2>
void vadd(vector<T1> &v, T2 x)
{
  for (auto &s : v)
    s += T2(x);
}


Measured memory_bytes: 5292
// -*- coding:utf-8-unix -*-

use proconio::input;

fn main() {
    input! {
        n: usize,
        mut a: [i64; n],
    }

    let mut ans = 0;
    for i in 1..a.len() {
        if a[i] < a[i - 1] {
            ans += a[i - 1] - a[i];
            a[i] = a[i - 1];
        }
    }
    println!("{}", ans);
}


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

typedef long long ll;

#define rep(i, n) for (int i = 0; i < (ll)n; ++i)
#define INF 10e7
#define MOD 1000000000 + 7
#define MAX 51000
#define all(x) (x).begin(), (x).end()
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))
using namespace std;

void solve(void)
{
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    ll money = 1000;
    rep(i, n - 1)
    {
        ll stock = 0;
        if (a[i] < a[i + 1])
            stock = money / a[i];
        money += (a[i + 1] - a[i]) * stock;
    }
    cout << money << endl;
}
int main(void)
{
    solve();
}


Measured memory_bytes: 3564
#include <iostream>
using namespace std;
int main()
 {
  char c;
  cin >> c;
  if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u') {
    cout<<"vowel\n";}
    else {cout<<"consonant\n";}
}

Measured memory_bytes: 3008
#include <math.h>

#include <algorithm>
#include <iostream>
using namespace std;

int main() {
  string s[105], t[105];
  int N, M;
  cin >> N;
  for (int i = 0; i < N; i++) cin >> s[i];
  cin >> M;
  for (int i = 0; i < M; i++) cin >> t[i];

  int ans = 0;
  int score = 0;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      if (s[j] == s[i]) score++;
    }
    for (int j = 0; j < M; j++) {
      if (t[j] == s[i]) score--;
    }
    ans = max(ans, score);
    score = 0;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
fun main(args : Array<String>) {
    val (a, b) = readLine()!!.split(" ").map { it.toLong() }
    val fa = factors(a)
    val fb = factors(b)

    var cnt = 1L
    fa.forEach { m ->
        if (fb[m.key] != null) cnt++
    }

    println(cnt)
}

fun factors(value: Long): Map<Long, Long> {
    val factors = mutableMapOf<Long, Long>()
    val max = Math.sqrt(value.toDouble()).toLong()
    var tmp = value

    for (i in 2..max) {
        while (tmp % i == 0L) {
            tmp /= i
            factors[i] = (factors[i] ?: 0) + 1
        }
    }

    if (tmp != 1L) {
        factors[tmp] = 1
    }

    return factors
}


Measured memory_bytes: 38608
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
int ctoi(char c) {return c-'0';}// char to int
int gcd(ll a,ll b){return b?gcd(b,a%b):a;}//MAX
int lcm(ll a,ll b){return a*b/gcd(a,b);}//MIN
 
int  main(){
string s,t;
cin >> s >> t;
cout << t + s <<endl;
}
 


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

#define NMAX 100001
#define MAX(a, b) (a > b ? a : b)

using namespace std;

//ifstream fin("f.in");
//ofstream fout("f.out");

struct Restaurant {
    char name[11];
    int score;
    int order;
};

int n;
Restaurant restaurants[101];


int main()
{
    cin >> n;
    for(int i = 1; i <= n; i++)
    {
        cin >> restaurants[i].name >> restaurants[i].score;
        restaurants[i].order = i;
    }
    for(int i = 1; i < n; i++)
        for(int j = i + 1; j <= n; j++)
        {
            if(strcmp(restaurants[i].name, restaurants[j].name) == 0)
            {
                if(restaurants[i].score < restaurants[j].score)
                    swap(restaurants[i], restaurants[j]);
            }
            else if(strcmp(restaurants[i].name, restaurants[j].name) > 0)
                swap(restaurants[i], restaurants[j]);
        }
    for(int i = 1; i <= n; i++)
        cout << restaurants[i].order << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <queue>
#include <stack>
#include <deque>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <iomanip>
using namespace std;

int main()
{
    int num, K;
    vector<int> v;
    cin >> num >> K;
    for(int i=0;i<num;i++){
        int current;
        cin >> current;
        v.push_back(current);
    }
    int ans = (num-1)/(K-1);
    if((num-1)%(K-1)!=0){
        ans ++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 892
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ii pair<ll, ll>
#define x first
#define y second

ii a[101], b[101];
ll n, ans = 0;
bool used[101];

bool ss(ii a, ii b){
    return (b.y > a.y);
}

int main(){
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i].x >> a[i].y;
    for (int i = 0; i < n; i++) cin >> b[i].x >> b[i].y;
    sort(a, a+n, greater<ii>());
    sort(b, b+n, ss);
    for (int i = 0; i < n; i++){
        for (int j = 0; j < n; j++){
            if (a[i].x < b[j].x && a[i].y < b[j].y && !used[j]){
                ans++;
                used[j] = true;
                break;
            }
        }
    }
    cout << ans;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <utility>
#include <map>
#include <stack>
#include <set>
#include <vector>
#include <queue>
#include <deque>
#define x first
#define y second
#define mp make_pair
#define pb push_back
#define LL long long
#define Pair pair<int,int>
#define LOWBIT(x) x & (-x)
using namespace std;

const int MOD=2e9;
const long long INF=1e16;
const int magic=348;

vector<int> path;
int n;
vector<int> v[100048];
int fa[100048];
int color[100048];
int cnt1=0,cnt2=0;

void dfs(int cur)
{
	int i,x;
	for (i=0;i<v[cur].size();i++)
	{
		x=v[cur][i];
		if (x!=fa[cur])
		{
			fa[x]=cur;
			dfs(x);
		}
	}
}

void find_path(int cur)
{
	if (cur!=n && cur!=1) path.pb(cur);
	if (cur==1) return;
	find_path(fa[cur]);
}

void dfs1(int cur)
{
	if (color[cur]==0)
	{
		color[cur]=1;
		cnt1++;
	}
	int i,x;
	for (i=0;i<v[cur].size();i++)
	{
		x=v[cur][i];
		if (x!=fa[cur] && color[x]!=2) dfs1(x);
	}
}

void dfs2(int cur)
{
	if (color[cur]==0)
	{
		color[cur]=2;
		cnt2++;
	}
	int i,x;
	for (i=0;i<v[cur].size();i++)
	{
		x=v[cur][i];
		if (x!=fa[cur] && color[x]!=1) dfs2(x);
	}
}

int main ()
{
	int i,j,x,y;
	scanf("%d",&n);
	for (i=1;i<=n-1;i++)
	{
		scanf("%d%d",&x,&y);
		v[x].pb(y);v[y].pb(x);	
	}
	color[1]=1;color[n]=2;
	cnt1=cnt2=1;
	fa[1]=-1;
	dfs(1);
	find_path(n);
	if (path.size()!=0)
	{
		i=0;j=path.size()-1;
		while (i<=j)
		{
			if (i==j)
			{
				color[path[i]]=1;
				cnt1++;
			}
			else
			{
				color[path[i]]=2;
				color[path[j]]=1;
				cnt1++;cnt2++;
			}
			i++;j--;
		}
		i--;
	}
	dfs1(1);
	if (path.size()==0) dfs2(n); else dfs2(path[i]);
	if (cnt1>cnt2) cout<<"Fennec"<<endl; else cout<<"Snuke"<<endl;
	return 0;
}

Measured memory_bytes: 11640
import java.util.Scanner;

public class Main {
	long c[];
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		int beforeOne=0,afterOne=0;
		for(int i=0;i<N;i++) {
			int a=sc.nextInt();
			if (a==1) {
				beforeOne = i;
				afterOne = N-(i+1);
				break;
			}
		}
		int count=0;
		if (beforeOne<K||afterOne<K) {
			count +=(N-K)/(K-1)+1;
			if ((N-K)%(K-1)!=0) {
				count ++;
			}
		} else {
			count = 1000000;
			for (int i=0;i<K;i++) {
				int temp = (beforeOne-i)/(K-1);
				if ((beforeOne-i)%(K-1)>0) {
					temp++;
				}
				temp +=(afterOne-(K-i-1))/(K-1);
				if ((afterOne-(K-i-1))%(K-1)>0) {
					temp++;
				}
				temp++;
				if (temp<count) {
					count =temp;
				}

			}
		}

		System.out.println(count);
 	}
}

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

int main(){
  int n,c,k;
  cin >> n >> c >> k;
  int t[n];
  for(int i=0;i<n;i++) cin >> t[i];
  sort(t,t+n);
  int s[n];
  for(int i=0;i<n;i++) s[i]=t[i]+k;
  int ans=1;
  int last=s[0];
  int people=0;
  for(int i=0;i<n;i++){
    if(t[i]>last||people>=c){
      ans++;
      last=s[i];
      people=1;
    }
    else{
      people++;
    }
    //cout << ans << " " << last << " " << people << endl;
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
 int main(){
   int N;
   cin >> N;
   long long c=0;
   for(int i=0;i<N;i++){
     if((i+1)%3!=0 && (i+1)%5!=0)
       c+=i+1;
   }
   cout << c << endl;
 }

Measured memory_bytes: 3636
while True:
  n = int(input())
  if n == 0:
    break
  c = 0
  l = []
  d = {}
  for i in range(n):
    num,x,y = map(int,input().split())
    if num in d:
      d[num] = d[num] + x*y
    else:
      d[num] = x*y
      l.append(num)
  for i in l:
    if d[i] >= 1000000:
      print(i)
      c += 1
  if c == 0:
    print('NA')

Measured memory_bytes: 7864
// God put a smile upon your face <3

#include <bits/stdc++.h>`

#define slld(longvalue) scanf("%lld", &longvalue)

#define ll long long
#define ull unsigned long long
#define pll pair < long long, long long >

#define fastio ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0)

#define pb push_back

#define bug printf("BUG\n")

#define mxlld LLONG_MAX
#define mnlld -LLONG_MAX

#define mxd 2e8
#define mnd -2e8

#define pi 3.14159265359

#define mod 958585860497

#define base 2001487

using namespace std;

bool check(ll n, ll pos)
{
	return n & (1LL << pos);
}

ll Set(ll n, ll pos)
{
	return n = n | (1LL << pos);
}

ll pw5[5003];

int main()
{
    ll i, j, k, l, m, n, o, r, q;
    ll testcase;
    ll input, flag, tag, ans;

//    freopen("input.txt", "r", stdin);

//    freopen("output.txt", "w", stdout);

    for(i = 0; i <= 5000; i++)
    {
		pw5[i] = 1;

		for(j = 1; j <= 5; j++)
		{
			pw5[i] *= i;
		}
    }

    ll x, y, a, b;

    while(cin >> x)
    {
		a = b = -1;


		for(i = 0; i <= 5000; i++)
		{
			for(j = 0; j <= i; j++)
			{
				y = pw5[i];

				if(y >= x)
				{
					y -= pw5[j];

					b = j;
				}
				else y += pw5[j], b = -j;

				if(y == x)
				{
					a = i;
					break;
				}
			}

			if(a != -1) break;
		}

		printf("%lld %lld\n", a, b);
    }

}





Measured memory_bytes: 3792
import sys
sys.setrecursionlimit(10 ** 7)
mod = 10 ** 9 + 7

def memodp(DPW, DPB, near, x, FLAG):
    if DPW[x] + DPB[x] > 2:
        return (DPB[x] + DPW[x]) % mod
    else:
        for i in near[x]:
            if i not in FLAG:
                FLAG.add(i)
                DPW[x] *= memodp(DPW, DPB, near, i, FLAG)
                DPB[x] *= DPW[i]
        DPW[x], DPB[x] = DPW[x] % mod, DPB[x] % mod
        return (DPW[x] + DPB[x]) % mod


n = int(input())
xy = [list(map(int, input().split())) for i in range(n - 1)]

near = [[] for _ in range(n)]
for x, y in xy:
    near[x - 1].append(y - 1)
    near[y - 1].append(x - 1)

dpw, dpb, flag = [1] * n, [1] * n, set([0])
print(memodp(dpw, dpb, near, 0, flag))


Measured memory_bytes: 135152
n,m,x = map(int,input().split())
c,a = [],[]
ans = float('inf')
for i in range(n):
    y = list(map(int,input().split()))
    c.append(y.pop(0))
    a.append(y)
for i in range(2**n):
    b = [0]*m
    cost = 0
    for j in range(n):
        if i&(1<<j):
            cost+=c[j]
            for k in range(m):
                b[k]+=a[j][k]
    for j in range(m):
        if b[j]<x:
            break
    else:
        ans = min(ans,cost)
if ans==float('inf'): print("-1")
else: print(ans)

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

int main(){
    int count,house,elec,a[100000+10],b[100000+10],i,l;
    cin >> count;
    for(l=0;l<count;l++){
        int dist=0;
        cin >> house >> elec;
        for(i=0;i<house;i++) cin >> a[i];
        for(i=0;i+1<house;i++) b[i]=a[i+1]-a[i];
        sort(b,b+house-1);
        for(i=0;house-elec-i>0;i++) dist+=b[i];
        cout << dist << endl;
    }
}

Measured memory_bytes: 3876
N, K = map(int, input().split())
h = [int(x) for x in input().split()]

INF = float('inf')
dp = [INF] * N
dp[0] = 0

for i in range(1, N):
    if i < K:
        k = i
    else:
        k = K
    for j in range(i-k, i):
        dp[i] = min(dp[i], dp[j] + abs(h[i]-h[j]))

print(dp[-1])

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

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

int main(){
  int k ,a, b;
  cin >> k >> a >> b;
  if(ceil(1.0*a/k)> floor(1.0*b/k))
    cout << "NG" << endl;
  else
    cout << "OK" << endl;
  return 0;
}

Measured memory_bytes: 3632
#include  <iostream>
#include  <stdio.h>
#include  <math.h>
using namespace std;

int A;
int B;
int C;
int N;

int fuctrical(int x){

    if(x <= 1){
        return 1;
    }else{
        return x * fuctrical(x-1);
    }
}
int nCr(int n,int r){
    int ans;
    ans = fuctrical(n);
    ans = ans / fuctrical(r);
    ans = ans / fuctrical(n-r);
    return ans;
}

int get_cost(int l[],int assign[]){
    int length[3];
    int cost = 0;
    for( int li = 0 ; li < 3 ; li++ ){
        length[li] = 0;
    }

    int number;
    for( int ni = 0 ; ni < N ; ni++ ){
        number = assign[ni];
        if(number < 3){
            if(length[number]>0){
                cost = cost + 10;
            }
            length[number] = length[number] + l[ni];
        }
    }
    
    for( int li = 0 ; li < 3 ; li++ )
        if(length[li] == 0) length[li] = 1000000;


    number = 0;
    cost = cost + abs(A - length[number]);
    number = 1;
    cost = cost + abs(B - length[number]);
    number = 2;
    cost = cost + abs(C - length[number]);

    /*
    for( int ni = 0 ; ni < N ; ni++ )
        cout << assign[ni] << " : ";
    cout << " = "<< cost << endl;
    */
    return cost;

}

int calc_cost(int l[],int assign[],int ni){
    int cost;
    int tmp_cost;
    cost = 100000;
    if(ni == N){
        return get_cost(l,assign);
    }else{
        for( int ai = 0 ; ai < 4 ; ai++ ){
            assign[ni] = ai;
            tmp_cost = calc_cost(l,assign,ni+1);
            if( tmp_cost < cost ){
                cost = tmp_cost;
            }
        }
        return cost;
    }
}

int main(){

    cin >> N;
    int cost=10000;

    cin >> A;
    cin >> B;
    cin >> C;

    int l[N];
    int assign[N];
    
    for( int ni = 0 ; ni < N ; ni++ ){
        cin >> l[ni];
        assign[ni] = 0;
    }
    
    cost = calc_cost(l,assign,0);

    cout << cost;

}

Measured memory_bytes: 256
#include <iostream>

int main()
{
  int N;
  std::cin >> N;
  int a[N];
  int v[N] = {0};
  int i = 0;
  v[i]++;
  int cnt = 0;
  for ( int i = 0; i < N; i++ ) std::cin >> a[i];

  bool can = false;
  while(true) {
    std::cerr << "i: " << i << std::endl;
    std::cerr << "a[" << i << "] " << a[i] << std::endl;
    cnt++;
    i = a[i] - 1;
    if ( v[i] == 1 ) {
      break;
    }
    v[i]++;

    if ( i == 1 ) {
      can = true;
      break;
    }
  }
  
  std::cout << (can ? cnt : -1) << std::endl;
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
using namespace std;
long h, w, result;
int main()
{
  cin >> h >> w;
  if (h == 1 || w == 1)
  {
    cout << 1 << endl;
    return 0;
  }

  result = h * (w / 2);
  if (w % 2 == 1)
  {
    result += h / 2;
    if (h % 2 == 1)
    {
      result += 1;
    }
  }
  cout << result << endl;
}

Measured memory_bytes: 256
H, W = map(int, input().split())

MAP = [list(input()) for i in range(H)]
check = ['.' for j in range(W)]
MAP_h = []
MAP_T = []

for i in range(H):
    if check != MAP[i]:
        MAP_h.append(MAP[i])
   
check = ['.' for k in range(len(MAP_h))]   

for i in range(W):
    tmp = [row[i] for row in MAP_h]
    if tmp != check:
        MAP_T.append(tmp)

MAP= map(list, zip(*MAP_T))

for l in MAP:
    print(''.join(l))


Measured memory_bytes: 3188
#include <iostream>

using namespace std;
long main_calc(int r, int c, short **table);
long columns_test(int r, int c, short **table, int pattern);

int main(int argc, char const* argv[])
{
  int r, c;
  short **table;

  while (true) {
    cin >> r >> c;
    if (r == 0 && c == 0) break;

    table = new short*[r];
    
    for (int i = 0; i < r; i++) {
      table[i] = new short[c];
      
      for (int j = 0; j < c; j++) {
        cin >> table[i][j];
      }
    }

    cout << main_calc(r, c, table) << endl;
  }
  return 0;
}

long main_calc(int r, int c, short **table) {
  long max = 0;
  int end_mask = 1 << r;
  int pattern = 0;

  while (true) {
    long count;
    if ((count = columns_test(r, c, table, pattern)) > max) {
      max = count;
    }

    if (++pattern == end_mask) break;
  }

  return max;
}

long columns_test(int r, int c, short **table, int pattern) {
  long count = 0;
  short reverse[r];
  for (int i = 0; i < r; i++) {
    reverse[i] = pattern & 1;
    pattern >>= 1;
  }

  for (int c_i = 0; c_i < c; c_i++) {
    int set_bits = 0;

    for (int r_i= 0; r_i < r; r_i++) {
      set_bits += table[r_i][c_i] ^ reverse[r_i];
    }

    if (set_bits > (r - set_bits)) {
      count += set_bits;
    } else {
      count += r - set_bits;
    }
  }

  return count;
}

Measured memory_bytes: 1488
#include <bits/stdc++.h>
using namespace std;
int func(int N){
    if(N < 10){
        return N;
    }
    return func(N/10) + N%10;
}
int main(){
    int N;
    cin >> N;
    int c;
    c=func(N);
    if(N%c==0){
        cout << "Yes" <<endl;
    }
    else{
        cout << "No" <<endl;
    }
}


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

using namespace std;
const int N=2e5+5;
int a[N];
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    long long n,k;
    cin>>n>>k;
    n%=k;
    cout<<min(n,k-n)<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#define LL long long
using namespace std;

const int maxx=1e6+10;
LL n,m,l,r,ans;
LL a[maxx],f[maxx];

bool cmp(LL x,LL y){
	return x>y;
}

bool check(LL mid){
	LL can=m;
	for(int i=1;i<=n;i++){
		if(a[i]*f[i]>mid){
			can-=(a[i]-(long long)(mid*1.0/f[i]));
			if(can<0) return 0;
		}
	}
	return 1;
}

int main(){
	scanf("%lld%lld",&n,&m);
	for(int i=1;i<=n;i++) scanf("%lld",&a[i]);
	for(int i=1;i<=n;i++) scanf("%lld",&f[i]);
	sort(a+1,a+1+n,cmp); sort(f+1,f+1+n);
	LL mid; l=0; r=a[1]*f[n];
	while(l<=r){
		mid=(l+r)>>1;
		if(check(mid)){
			r=mid-1,ans=mid;
		} 
		else l=mid+1;
	}
	printf("%lld",ans);
	return 0;
} 

Measured memory_bytes: 5888
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < int(n); ++i)
#define REPE(i, a, b) for (int i = (a); i <= int(b); ++i)
#define SZ(x) ((int)(x).size())
#define ALL(x) x.begin(), x.end()
#define PB push_back
#define EB emplace_back
using LL = long long;
using PII = pair<int, int>;
#define F first
#define S second
void R(int &x) { scanf("%d", &x); }
void R(LL &x) { scanf("%lld", &x); }
void R(double &x) { scanf("%lf", &x); }
template <typename T> void R(T &t) { cin >> t; }
template <typename T> void R(vector<T> &ar) {
  for (auto &it : ar)
    R(it);
}
template <typename T, typename... Args> void R(T &t, Args &... args) {
  R(t);
  R(args...);
}

map<PII, int> m;
int add(int x, int y, int v) {
  if (x == 0) y = 1;
  else if (y == 0) x = 1;
  else if (x < 0) x = -x, y = -y;
  int g = __gcd(abs(x), abs(y));
  x /= g, y /= g;
  int r = m[{x, y}];
  m[{x, y}] += v;
  return r;
}

int n, x[22], y[22];
bool v[22];

int sum = 0, ans = 0;
int md;
void dfs(int a, int d) {
  if (d * 2 == n) {
    ans = max(ans, sum);
    return;
  }
  while (v[a]) a++;
  v[a] = true;
  for (int i = a + 1; i < n; ++i) {
    if (v[i]) continue;
    v[i] = true;
    int t = add(x[i] - x[a], y[i] - y[a], 1);
    sum += t;
    dfs(a + 1, d + 1);
    add(x[i] - x[a], y[i] - y[a], -1);
    sum -= t;
    v[i] = false;
  }
  v[a] = false;
}

int main() {
  R(n);
  REP(i, n) R(x[i], y[i]);
  dfs(0, 0);
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 3232
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

a, b, x = rm()
print('YES' if a <= x <= a+b else 'NO')















Measured memory_bytes: 27188
# coding: utf-8
# Your code here!
N,K=map(int,input().split())
MOD=10**9+7
A=[0]
for i in range(1,N+1):
    A.append(A[i-1]+i)
B=[N]
for i in range(N):
    B.append(B[i]+N-(1+i))

ans=0
for i in range(N-K+2):
    k=i+K-1
    ans+=B[k]-A[k]+1
    ans=ans%MOD
print(ans)

Measured memory_bytes: 27096
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()

typedef long long ll;

using namespace std;
//using namespace boost::multiprecision;


int main(){

    int n;
    cin >> n;

    vector<vector<pair<int,int>>> state(n);

    rep(i,n){
        int a;
        cin >> a;

        rep(j,a){
            int x,y;
            cin >> x >> y;

            state[i].pback(mpair(x,y));
        }
    }

    int ans = 0;

    for(int bit = 1; bit < (1<<n); bit++){

        bool correct = true;
        int honest_count = 0;

        for(int i = 0; i < n; i++){
            if(bit & (1<<i)){
                //cerr << bit << " " << (1<<i) << endl;
                honest_count++;
                rep(j, state[i].size()){
                    int h = state[i][j].first - 1;
                    int s = state[i][j].second;

                    if(s == 1){
                        if(bit & (1<<h)){

                        }else{
                            correct = false;
                            break;
                        }
                    }else{
                        if(bit & (1<<h)){
                            correct = false;
                            break;
                        }
                    }
                }
            }
        }

        if(correct){
            ans = max(ans,honest_count);
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
# AtCoder Beginner Contest 111
# C - /\/\/\/
# https://atcoder.jp/contests/abc111/tasks/arc103_a
from collections import Counter

N, *A = map(int, open(0).read().split())

ev = A[0::2]
od = A[1::2]

ev_C = Counter(ev)
od_C = Counter(od)


if ev == od and ev_C.most_common()[0][1] == N//2:
    print(N//2)
else:
    ans = N
    ev_common = ev_C.most_common()
    od_common = od_C.most_common()
    ev_most = ev_common[0][1]
    od_most = od_common[0][1]
    if ev_common[0][0] == od_common[0][0]:
        ev_second = ev_common[1][1]
        od_second = od_common[1][1]
        ans = min(ans, N-ev_most-od_second)
        ans = min(ans, N-ev_second-od_most)
    else:
        ans = min(ans, N-ev_most-od_most)

    print(ans)


Measured memory_bytes: 21732
#include <bits/stdc++.h>
const int MOD=1000000007;
const int INF=1000000000;
using namespace std;
typedef long long ll;
typedef tuple<ll,int,int> tup;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vp;
int n;
int main(int argc,char const* argv[])
{
  int a,b;
  cin >> a >> b;
  int ans=max(a+a-1,b+b-1);
  ans=max(ans,a+b);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
using namespace std;

long long N, D, ans = 0;
int main() {
  cin >> N >> D;
  for (int i = 0; i < N; i++) {
  	long long x, y;
  	cin >> x >> y;
	//if(pow(x,2) + pow(y,2) <= pow(D,2)) ans++;
	if(x*x + y*y <= D*D) ans++;
  }

  cout << ans << endl;

  return 0;
}


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

int main(){
	int T;
	cin >> T;
	while(T--){
		int y,m,d,ans=0;
		cin >> y >> m >> d;
		while(y != 1000 || m != 1 || d != 1){
			d++;
			if( y % 3 ){
				if( d > 20 - (m+1) % 2 ) d = 1 , m++;
				if( m >= 11 ) m = 1 , y++;
			}else{
				if( d >= 21 ) d = 1 , m++;
				if( m >= 11 ) m = 1 , y++;
			}
			ans++;
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 868
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	sc.Split(bufio.ScanWords)

	N, K := getInt(), getInt()

	ans := 0
	for N > 0 {
		ans++
		N = N / K
	}

	out(ans)

}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
 
int main()
{
   string s, t;
  int p = 0;
  cin>>s;
  cin>>t;
  for(int i = 0; i < s.length(); i++)
  {
    if(s[i] != t[i])
    {
      p++;
	  cout<<"No"<<endl;
      break;
    }	
  }
  if(p == 0)
  {	
    cout<<"Yes"<<endl;
  }
 return 0;
}

Measured memory_bytes: 3544
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
typedef long long ll;

ll sqr(ll a)
{
	return (a * a * a * a * a);
}

int main()
{
	ll x;
	scanf("%lld", &x);
	ll a = 0,b ;
	while (a < 1000)
	{
		b = -1 * a;
		while (b < a)
		{
			if (sqr(a) - sqr(b) == x)
			{
				printf("%lld %lld", a,b);
				return 0;
			}
			b++;
		}
		a++;
	}
	return (0);
}


Measured memory_bytes: 2156