akhauriyash/Code-Regression huggingface dataset:
/*
ID: barish21
LANG: C++14
TASK: test
*/

/****Author: Barish Namazov****/
#include <bits/stdc++.h>

using namespace std;

/***TEMPLATE***/
#define intt long long

#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

#define F first
#define S second
#define pb push_back

#define IO ios_base::sync_with_stdio(false);cin.tie();

const intt max1 = 11;
const intt max2 = 102;
const intt max3 = 1003;
const intt max4 = 10004;
const intt maxx = 100005;
const intt max6 = 1000006;
const intt max7 = 10000007;
const intt lg2 = 7;
const intt lg3 = 10;
const intt lg4 = 13;
const intt lg5 = 17;
const intt lg6 = 20;
const intt lg7 = 24;
const intt lg8 = 27;
const intt lg9 = 30;
const intt lg18 = 60;
const intt INF = 2LL * 1000000000;
/***************/

/***Additional Functions***/
intt powmod(intt a,intt b,intt mod){intt res=1;a%=mod;assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
intt gcd(intt a, intt b) { while(b) b ^= a ^= b ^= a %= b; return a;}
intt lcm(intt a,intt b){return a*b/gcd(a,b);}
intt is_prime(intt n){if(n==1)return 0;if(n==2)return 1;if(n%2==0)return 0;for(intt i=3;i<=sqrt(n);i+=2)if(n%i==0)return 0;return 1;}
intt is_integer(double n){if(floor(n)==ceil(n))return 1;return 0;}

intt sto_int(string s){stringstream ss(s);intt n;ss>>n;return n;}
string to_string(intt n){stringstream ss;ss<<n;string s=ss.str();return s;}
/**************************/

intt arr[maxx << 1], p[maxx << 1];
int main() {
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    //ofstream fout ("test.out");
    //ifstream fin ("test.in");
    IO;
    intt n;
    cin >> n;
    intt res = INF + 1;
    for (intt i = 1; i <= n; i++)
        cin >> arr[i], p[i] = p[i - 1] + arr[i];
    for (intt i = 1; i < n; i++)
        res = min (res, abs (p[i] - (p[n] - p[i])));
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 3328
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int w=sc.nextInt();
        int n=sc.nextInt();
        int num[];
        num=new int[w];
        for(int i=0;i<w;i++) num[i]=i+1;
        for(int i=0;i<n;i++){
            String str=sc.next();
            String ab[]=str.split(",");
            int a=Integer.parseInt(ab[0])-1;
            int b=Integer.parseInt(ab[1])-1;
            int c=num[a];
            num[a]=num[b];
            num[b]=c;
        }
        for(int i=0;i<w;i++) System.out.println(num[i]);
    }
}



Measured memory_bytes: 26180
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <set>
#include <iomanip>
#include <stdio.h>
#include <sstream>
#include <string>
using namespace std;
int main(void){
  string s;
  cin>>s;
  long long int k;
  cin>>k;
  vector<int> hoge(1,0);
  int itr=0;
  for(int i=0; i<s.length(); i++){
    if(i==0){
      hoge.at(0)++;
    }else if(s[i]==s[i-1]){
      hoge.at(itr)++;
    }else{
      itr++;
      hoge.push_back(1);
    }
  }
  long long int ans=0;
  bool both=false;
  if(s[0]==s[s.length()-1]){
    both=true;
  }
  for(int i=0; i<hoge.size(); i++){
    if(both&&(i==0||i==hoge.size()-1)){
      ans+=hoge.at(i)/2;
      continue;
    }
    ans+=(hoge.at(i)/2)*k;
  }
  if(s[0]==s[s.length()-1]){
    int sum=hoge.at(0)+hoge.at(hoge.size()-1);
    ans+=(sum/2)*(k-1);
  }
  if(s.length()==1){
    ans=k/2;
  }
  if(hoge.size()==1){
    ans=hoge.at(0)*k/2;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
n = int(input())

counter = 0
a = 0
v = 10000000
for s in input().split():
    i = int(s)
    a += abs(i)
    if i < 0:
        counter += 1
    if abs(i) < v:
        v = abs(i)

if counter & 1:
    a -= v * 2
print(a)

Measured memory_bytes: 11516
# 文字で出力する
a_num_str, operator, b_num_str = map(str, input().split())

# a_num_str と b_num_str を 整数にする。
a_num_int = int(a_num_str)
b_num_int = int(b_num_str)

# operator は 「+」「-」の２つがあるので場合わけし計算する。
if operator == '+':
    sum_a_b = a_num_int + b_num_int
    print(sum_a_b)
elif operator == '-':
    sub_a_b = a_num_int - b_num_int
    print(sub_a_b)

Measured memory_bytes: 9092
#include <bits/stdc++.h>
using namespace std;
using ll= long long ;
using P = pair<ll,ll>;
#define rep(i,n) for (ll i = 0; i<(ll)(n); i++)
#define mod 1000000007
#define pi 3.141592653589793
typedef vector<ll> vcl;

ll gcd(ll a,ll b){
    if(b>a) swap(a,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 rep_jijo(ll n,ll x){
    if(x==0) return 1;
    if(x%2==0){
        ll t =rep_jijo(n,x/2);
        return t*t%mod;
  }
  return n*rep_jijo(n,x-1)%mod;
}
ll c2(ll n){
    return n*(n-1)/2;
}

int main() {
  ll n,k;
  cin>>n>>k;
  vcl s(n+1),d(k+1),a(n+1);
  for(ll i=1;i<=k;i++){
      cin>>d[i];
      for(ll j=1;j<=d[i];j++){
          cin>>a[j];
          s[a[j]]=1;
      }
  }
  ll ans=0;
  for(ll i=1;i<=n;i++){
      if(s[i]==0)ans++;
  }
  cout<<ans<<endl;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,A;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>A;
	N%=500;
	if(N<=A) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 384
using System;
namespace kozaiyApp
{
    public class B
    {
        static void Main()
        {
            string[] input = Console.ReadLine().Split(' ');
            int A = int.Parse(input[0]); // 1
            int B = int.Parse(input[1]); // 0
            int C = int.Parse(input[2]); // -1
            int K = int.Parse(input[3]); // 選ぶ枚数

            int ans = 0;

            if (A >= K)
            {
                Console.WriteLine(K);
            }
            else
            {
                K = K - A;
                ans += A;
                if (B >= K)
                {
                    Console.WriteLine(ans);
                }
                else
                {
                    K = K - B;
                    ans -= K;
                    Console.WriteLine(ans);
                }
            }
        }
    }
}


Measured memory_bytes: 27480
use std::io::{stdin, Read};

macro_rules! parse {
    ($iter: ident) => {
        $iter.next().unwrap().parse().unwrap()
    };
    ($iter: ident,2) => {
        (parse!($iter), parse!($iter))
    };
    ($iter: ident,3) => {
        (parse!($iter), parse!($iter), parse!($iter))
    };
    ($iter: ident,4) => {
        (parse!($iter), parse!($iter), parse!($iter), parse!($iter))
    };
    ($iter: ident, $n: ident) => {
        $iter.take($n).map(|e| e.parse().unwrap()).collect();
    };
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    let mut iter = s.split_whitespace();
    let s = iter.next().unwrap();
    let t: String = s.chars().map(|_| 'x').collect();
    println!("{}", t);
}


Measured memory_bytes: 4352
//start of jonathanirvings' template v3.0.3 (BETA)

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

typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;
typedef pair<string,string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vii;
typedef vector<LL> vl;
typedef vector<vl> vvl;

double EPS = 1e-9;
int INF = 1000000005;
long long INFF = 1000000000000000005LL;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};

#ifdef TESTING
  #define DEBUG fprintf(stderr,"====TESTING====\n")
  #define VALUE(x) cerr << "The value of " << #x << " is " << x << endl
  #define debug(...) fprintf(stderr, __VA_ARGS__)
#else
  #define DEBUG 
  #define VALUE(x)
  #define debug(...)
#endif

#define FOR(a,b,c) for (int (a)=(b);(a)<(c);++(a))
#define FORN(a,b,c) for (int (a)=(b);(a)<=(c);++(a))
#define FORD(a,b,c) for (int (a)=(b);(a)>=(c);--(a))
#define FORSQ(a,b,c) for (int (a)=(b);(a)*(a)<=(c);++(a))
#define FORC(a,b,c) for (char (a)=(b);(a)<=(c);++(a))
#define FOREACH(a,b) for (auto &(a) : (b))
#define REP(i,n) FOR(i,0,n)
#define REPN(i,n) FORN(i,1,n)
#define MAX(a,b) a = max(a,b)
#define MIN(a,b) a = min(a,b)
#define SQR(x) ((LL)(x) * (x))
#define RESET(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ALL(v) v.begin(),v.end()
#define ALLA(arr,sz) arr,arr+sz
#define SIZE(v) (int)v.size()
#define SORT(v) sort(ALL(v))
#define REVERSE(v) reverse(ALL(v))
#define SORTA(arr,sz) sort(ALLA(arr,sz))
#define REVERSEA(arr,sz) reverse(ALLA(arr,sz))
#define PERMUTE next_permutation
#define TC(t) while(t--)

inline string IntToString(LL a){
  char x[100];
  sprintf(x,"%lld",a); string s = x;
  return s;
}

inline LL StringToInt(string a){
  char x[100]; LL res;
  strcpy(x,a.c_str()); sscanf(x,"%lld",&res);
  return res;
}

inline string GetString(void){
  char x[1000005];
  scanf("%s",x); string s = x;
  return s;
}

inline string uppercase(string s){
  int n = SIZE(s); 
  REP(i,n) if (s[i] >= 'a' && s[i] <= 'z') s[i] = s[i] - 'a' + 'A';
  return s;
}

inline string lowercase(string s){
  int n = SIZE(s); 
  REP(i,n) if (s[i] >= 'A' && s[i] <= 'Z') s[i] = s[i] - 'A' + 'a';
  return s;
}

inline void OPEN (string s) {
  #ifndef TESTING
  freopen ((s + ".in").c_str (), "r", stdin);
  freopen ((s + ".out").c_str (), "w", stdout);
  #endif
}

//end of jonathanirvings' template v3.0.3 (BETA)

string s;
int n;
int finis[500005];

int main()
{
  s = GetString();
  n = SIZE(s) + 1;
  LL risan = 0;
  finis[n - 1] = 0;
  FORD(i,n-2,0)
  {
    if (s[i] == '>') finis[i] = finis[i + 1] + 1;
    else finis[i] = 0;
    // risan += finis[i];
    // debug("%d\n",finis[i]);
  }
  int now = finis[0];
  risan = now;
  FOR(i,1,n)
  {
    if (s[i-1] == '<') now = max(finis[i], now + 1);
    else now = finis[i];
    risan += now;
  }
  printf("%lld\n",risan);
  return 0;
}











Measured memory_bytes: 3200
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<queue>
#include<stack>
#include<cmath>	
#include<list>


constexpr auto PI = 3.14159265359;

using namespace std;


int main() {
	long long N, K;
	cin >> N >> K;
	vector<long long> A(N * 2);
	for (long long i = 0; i < N; ++i) {
		cin >> A[i];
		A[i + N] = A[i];
	}
	long long count = 0;
	for (long long i = 0; i < N; ++i) {
		for (long long j = i + 1; j < N; ++j) {
			if (A[j] < A[i]) {
				count += ((K) * (2 * 1 + ((K) - 1) * 1) / 2) % (long long)(pow(10, 9) + 7);
			}
		}
		for (long long j = 0; j <= i; ++j) {
			if (A[j] < A[i]) {
				count += ((K - 1) * (2 * 1 + ((K - 1) - 1) * 1) / 2) % (long long)(pow(10, 9) + 7);
			}
		}
	}
	cout << count % (long long)(pow(10, 9) + 7) << "\n";
	return 0;
}

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

hc = [0] * H
wc = [0] * W
d = {}
for _ in range(M):
    h, w = map(lambda x: int(x) - 1,input().split())
    hc[h] += 1
    wc[w] += 1
    d.setdefault(h, {})
    d[h][w] = 1

result = 0
hm = max(hc)
wm = max(wc)
hi = [i for i in range(H) if hc[i] == hm]
wi = [i for i in range(W) if wc[i] == wm]

for h in hi:
    for w in wi:
        if h in d and w in d[h]:
            result = max(result, hm + wm - 1)
        else:
            result = max(result, hm + wm)
            break
print(result)


Measured memory_bytes: 137540
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using P = pair<ll, ll>;

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n, q;
  cin >> n >> q;
  ll ans = (n-2)*(n-2);
  set<P> stx, sty;
  stx.emplace(n-1, n-1);
  sty.emplace(n-1, n-1);
  rep(_, q) {
    ll que, x;
    cin >> que >> x;
    --x;
    if (que == 1) {
      auto it = sty.lower_bound({x, 0});
      P p = *it;
      ans -= p.second-1;
      stx.emplace(p.second, x);
    } else {
      auto it = stx.lower_bound({x, 0});
      P p = *it;
      ans -= p.second-1;
      sty.emplace(p.second, x);
    }
  }
  cout << ans << endl;
  return 0;
}

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

int main(){
  int n;
  int a[50];
  cin >> n;
  for (int i=0; i<n; i++){
    cin >> a[i];
  }
  sort(a,a+n);
  double s = a[0];
  for (int i=0; i<n; i++){
  s = (s+a[i])/2;
  }
  cout << s;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
    public static void main (String args[]){

        //初期処理
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        sc.nextLine();
        String[] sArray = sc.nextLine().split(" ");
        int[] array=Arrays.stream(sArray).mapToInt(Integer::parseInt).toArray();

        //選択ソート
        int i,j;
        int count=0;
        for(i=0;i<n;i++){
            int minj=i;
            for(j=i;j<n;j++){
                if(array[j]<array[minj]){
                    minj=j;
                }
            }
            if(minj!=i){
                int tmp=array[i];
                array[i]=array[minj];
                array[minj]=tmp;
                count++;
            }
        }
        String[] sArray2 = Arrays.stream(array).mapToObj(Integer::toString).toArray(s->new String[s]);
        System.out.println(String.join(" ", sArray2));
        System.out.println(count);
    }
}


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

using namespace std;

constexpr int MAX = 1000000;

int main()
{
    vector<bool> prime_list(MAX, true);
    prime_list.at(0) = false;
    prime_list.at(1) = false;
    for(int i = 2; i * i < MAX; ++i)
    {
        if(!prime_list.at(i))
            continue;
        for(int j = 2; i * j < MAX; ++j)
            prime_list.at(i * j) = false;
    }

    int num;
    int count;
    while(cin >> num)
    {
        count = 0;
        for(int i = 2; i <= num; ++i)
        {
            if(prime_list.at(i))
                count++;
        }
        cout << count << endl;
    }
}

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

ll M = 1000000007;

vector<ll> fac(200001);
vector<ll> ifac(200001);

ll mpow(ll x, ll n){ //x^n(mod M) ←普通にpow(x,n)では溢れてしまうため，随時mod計算
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % M;
        x = x*x % M;
        n = n >> 1;
    }
    return ans;
}

ll comb(ll a, ll b){ //aCbをmod計算
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0)return 0;
    ll tmp = ifac[a-b]* ifac[b] % M;
    return tmp * fac[a] % M;
}

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
   	int h, w, a, b;cin >> h >> w >> a >> b;
    ll sum = 0;
    
    fac[0] = 1;
    ifac[0] = 1;
    for(ll i = 0; i<200000; i++){
        fac[i+1] = fac[i]*(i+1) % M; // n!(mod M)
        ifac[i+1] = ifac[i]*mpow(i+1, M-2) % M; // k!^{M-2} (mod M) ←累乗にmpowを採用
    }
    int count = 0;
    for(int i = 0; i+1 + a <= h && i+1 + b <= w;i++){
        //uekara h-a-i masu
        count ++;
        //cout <<  count << endl;
        sum += (comb((h-a-i-1)+b+i,b+i) % M) * (comb((a+i)+(w-b-i-1),a+i) % M);
        sum %= M;
    }
    
    /*ul fa[200001];
    fa[0] = 1;
    fa[1] = 1;
    rep(i, 200001){
        if(i==0)continue;//   1000000000;
        fa[i] = fa[i-1]*i % 1000000007;
        cout << fa[i] << endl;
    }
    for(int i = b;i < w;i++){
        ul f = fa[h-a+i-1]/fa[i]/fa[h-a-1];
        ul g = fa[a + w-i-2]/fa[a-1]/fa[w-i-1];
        sum += f*g;
        //cout << g<<endl;
        sum %=   1000000007;
        //if(i % 100 == 0)cout << i << endl;
    }*/
    cout << sum << endl;
	
	return 0;
}
ll fact(int n){
    ll l=1;
    for(int i=2;i <= n; i++){
        l=l*i % 1000000007;
    }return l;
}


Measured memory_bytes: 3328
from fractions import gcd

n=int(input())
a=list(map(int,input().split()))
mod=10**9+7


lcm=1
for i in a:
 lcm=(lcm*i)//gcd(lcm,i)

'''
ans=0
mod=10**9+7
for i in a:
 ans+=lcm//i
 ans%=mod
print(ans)

'''
'''
from functools import reduce
lcm=reduce(lambda x,y :(x*y)//gcd(x,y),a)
'''

'''
ans=0
mod=10**9+7
for i in a:
 ans+=lcm//i
 ans%=mod
'''
ans=sum(lcm//i for i in a)
ans%=mod
print(ans)

Measured memory_bytes: 6072
import numpy as np,sys
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
N,M,X = LI()
CA = np.array([LI() for _ in range(N)])
ans = float('INF')
for i in range(2**N):
    bit = np.array([[i>>j&1 for j in range(N)]]).T
    temp = (CA*bit).sum(axis=0)
    if (temp[1:]>=X).all():
        ans = min(ans,temp[0])
print(ans if ans!=float('INF') else -1)


Measured memory_bytes: 27340
#include <iostream>
#include <algorithm>
#include <climits>
#include <numeric>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <unordered_set>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
 
#define barsik ios::sync_with_stdio(false)
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
typedef long long ll;
typedef std::vector<int> vi;
typedef std::pair <int, int> pii;
typedef std::unordered_set <int> u_si;
const double PI = acos(-1);
const long double EPS = 1e-9;
using namespace std;

void solve(){
    string s;
    cin >> s;
    int pos1 = -1, pos2 = -1;
    for(int i = 0; i < s.size(); i++){
        if(s[i] == 'A' && pos1 == -1) pos1 = i;
        if(s[i] == 'Z') pos2 = i;
    }
    cout << pos2 - pos1 + 1;
}

 
int main() {
    barsik;
    int q = 1;
    //cin >> q;
    while(q--) solve();
}


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

int main()
{
	ios::sync_with_stdio(false);
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	int tak=ceil((double)c/b),aok=ceil((double)a/d);
	//cout<<tak<<" "<<aok<<endl;
	if(tak>aok) cout<<"No"<<endl;
	else cout<<"Yes"<<endl;
}

Measured memory_bytes: 3640
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
mod2 = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    n = I()
    sa = [S() for _ in range(n)]
    e = collections.defaultdict(set)
    for i in range(n):
        s = sa[i]
        for j in range(i+1,n):
            if s[j] == '1':
                e[i].add(j)
                e[j].add(i)

    r = -1
    for i in range(n):
        k = 1
        a = [set(), set([i])]
        u = set([i])
        while len(u) < n:
            k += 1
            v = set()
            for c in a[k-1]:
                v |= e[c]
            v -= a[k-2]
            if len(v & u) > 0:
                k = -1
                break
            vv = set()
            for c in v:
                vv |= e[c]
            if len(vv & v) > 0:
                k = -1
                break
            a.append(v)
            u |= v
        if r < k:
            r = k

    return r


print(main())





Measured memory_bytes: 7248
def main():
    n,x,m = map(int,input().split())
    if m == 0:
        print(0)
        return
    t = [x]
    k = -1
    for _ in range(n-1):
        x = x**2 % m
        if x in t:
            k = x
            break
        t.append(x)
    if k not in t:
        print(sum(t))
        return
    else:
        s = t.index(k)
        ans = sum(t[0:s])
        b = t[s:len(t)]
        n -= s
        ans += sum(b) * (n//len(b))
        ans += sum(b[0:n%len(b)])
        print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 68416
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using ld = long double;
#define ALL(x) x.begin(),x.end()
#define P pair<int,int>
#define mod 1000000007

int main() {
  int n, p;
  int ans = 0;
  cin >> n;
  int min = n + 2;
  rep(i, n) {
    cin >> p;
    if (p < min) {
      ans++;
      min = p;
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using namespace std;
int main() {
  long x;
  cin>>x;
  long n,m;
  for (long i =0; i < 1000; i++){
    for (long j =-1000; j < 1000; j++){
      if(i*i*i*i*i-j*j*j*j*j==x){
       n=i;
        m=j;
      }
    }
  }
  cout<<n<<" "<<m<<endl;
}

Measured memory_bytes: 3648
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    BufferedReader rd;

    Main() throws IOException {
        rd = new BufferedReader(new InputStreamReader(System.in));
        compute();
    }

    private void compute() throws IOException {
        long k = plong();
        long[] res = solve(k);
        out(res.length);
        StringBuilder buf = new StringBuilder();
        for(int i=0;i<res.length;i++) {
            if(i > 0) {
                buf.append(' ');
            }
            buf.append(res[i]);
        }
        out(buf);
    }

    private long[] solve(long k) {
        if(k == 0) {
            return new long[] { 0, 0 };
        } else if(k == 1) {
            return new long[] { 2, 0 };
        } else {
            long[] res = new long[50];
            long h = k / 50;
            int u = (int)(k%50);
            if(u > 0) {
                long base = 100 - u + h;
                for (int i = 0; i < u; i++) {
                    res[i] = base;
                }
                for (int i = u; i < 50; i++) {
                    res[i] = base - 51;
                }
            } else {
                for (int i = 0; i < 50; i++) {
                    res[i] = 49 + h;
                }
            }
            return res;
        }
    }

    private long plong() throws IOException {
        return plong(rd.readLine());
    }

    private long plong(String s) {
        return Long.parseLong(s);
    }

    private static void out(Object x) {
        System.out.println(x);
    }

    public static void main(String[] args) throws IOException {
        new Main();
    }
}


Measured memory_bytes: 22612
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    int one = n%10;
    if(one == 2 || one == 4 || one == 5 || one == 7 || one == 9)
        cout << "hon\n";
    else if(one == 0 || one == 1 || one == 6 || one == 8)
        cout << "pon\n";
    else
        cout << "bon\n";

    return 0;
}


Measured memory_bytes: 3592
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <map>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;

int main(){
  ll n,k;
  cin >> n >> k;
  vector<ll> h;
  REP(i,n){
    ll height;
    cin >> height;
    h.push_back(height);
  }
  sort(h.begin(),h.end());
  ll ans = INF;
  REP(i,n-k+1){
    ans = min(ans,h[i+k-1]-h[i]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1400
nums = gets.chars.map(&:to_i)

%w(+ -).repeated_permutation(3).each do |ops|
  res = nums[0]
  ops.zip(nums[1..-1]) do |op, num|
    res = (op == '+') ? res + num : res - num
  end

  if res == 7
    puts [nums[0], ops[0], nums[1], ops[1], nums[2], ops[2], nums[3], '=7'].join
    break
  end
end

Measured memory_bytes: 1788
<?php
while(1){
    fscanf(STDIN, '%d %d %d', $a, $b, $c);
    if($a+$b+$c==-3){
        break;
    }
    
    if($a==-1||$b==-1){
        echo "F", PHP_EOL;
    }elseif(($a+$b)>=80){
        echo "A", PHP_EOL;
    }elseif(($a+$b)>=65){
        echo "B", PHP_EOL;
    }elseif(($a+$b)>=50){
        echo "C", PHP_EOL;
    }elseif(($a+$b)>=30 && $c>=50){
        echo "C", PHP_EOL;
    }elseif(($a+$b)>=30){
        echo "D", PHP_EOL;
    }else{
        echo "F", PHP_EOL;
    }
}



Measured memory_bytes: 9204
#!/usr/bin/perl

my ($n) = map {$_ - 0} split(/\s+/o,<STDIN>);
my @a = map {$_ - 0} split(/\s+/o,<STDIN>);

push(@a,-10000);

my $t = 0;
my $c = 1;
for(my $i=1;$i<=$n;$i++){
  if( $a[$i-1] == $a[$i] ){
    $c++;
  } else {
    $t += int($c/2);
    $c = 1;
  }
}

print "$t\n";
exit(0);



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

#define ll long long

vector<vector<ll>> adjin ;
vector<vector<ll>> adjout ;
vector<ll> topsort ;
vector<ll> visited ;
vector<ll> dp;

void dfs(ll a ){
    visited[a] = 1;
    for(auto c: adjout[a]){
         if(!visited[c]){
              dfs(c);
         }
    }
    topsort.push_back(a);

}

void solve(){
    adjin.clear(); adjout.clear(); topsort.clear(); visited.clear(); dp.clear();
ll n , m ;
cin >> n>> m;
for(ll i=0; i<n+1;i++){
     vector<ll> v1 , v2 ; adjin.push_back(v1); adjout.push_back(v2); visited.push_back(0);
     dp.push_back(0);
}

for(ll i=0; i<m ; i++){
     ll a , b ; cin >> a >> b; adjin[b].push_back(a); adjout[a].push_back(b);
}

for(ll i=1 ; i<=n ; i++){
    if(!visited[i]){ dfs(i);}
}
ll ans =0;

for(ll i=1; i<n;i++){
 
  ll a = topsort[n-1-i];
  for( auto d : adjin[a]){
     dp[a] = max( dp[a],dp[d]+1 ); ans = max(ans, dp[a]);
  }
}



 cout << ans << endl;


}

int main(){

 ll  n ;
  n=1;
  while(n--){solve();}
   
    return 0;
}

Measured memory_bytes: 19456
# -*- coding: utf-8 -*-
INF = 2**31 -1
n, p = list(map(int, input().split()))

temp = 1
while temp < n:
  temp *= 2

lis = [INF for i in range(2*temp-1)]

def updata(x, y):
  x += temp - 1
  lis[x] = y
  while x > 0:
    x = (x-1) // 2
    #print(x*2+2)
    lis[x] = min(lis[x*2+1], lis[x*2+2])

def findmin(x, y):
  return query(x, y+1, 0, 0, temp)

def query(a, b, k, l, r):
  #print('a,b,l,r:',a,b,l,r)
  if r <= a or b <= l:
    return INF

  if a <= l and r <= b:
    return lis[k]
  
  vl = query(a, b, k*2+1, l, (l+r)//2)
  vr = query(a, b, k*2+2, (l+r)//2, r)
  return min(vl, vr)


for i in range(p):
  oper, x, y = list(map(int, input().split()))
  
  if oper == 0:
    updata(x, y)
  else: 
    print(findmin(x, y))




Measured memory_bytes: 9016
#include<cstdio>
using namespace std;
#define MAX_N 200005
int N,M,Q,a,p;
int l[MAX_N],r[MAX_N];
int ans[MAX_N];
int main(){
  scanf("%d %d %d",&N,&M,&Q);
  for(int i=0;i<N;i++){
    l[i]=(i+N-1)%N;
    r[i]=(i+1)%N;
    ans[i]=1;
  }

  for(int i=0;i<M;i++){
    scanf("%d",&a);
    int* t=(a&1?l:r);
    while(a--)p=t[p];
    ans[p]=0;
    r[l[p]]=r[p];
    l[r[p]]=l[p];
    p=r[p];
  }

  int id;
  while(Q--){
    scanf("%d",&id);
    printf("%d\n",ans[id]);
  }
  return 0;
}

Measured memory_bytes: 3372
/**                                                     **\
 *    created by:   Divianshu Bansal                     *
 *    e-mail id:    god_coder@icloud.com                 *
*                                                        */

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>


using namespace std;
using namespace __gnu_pbds;


typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>new_data_set;
#define MOD 1000000007
#define int long long
#define BIG 998244353
#define pf push_front
#define print(x) for(auto el: x) cout<<el<<" ";cout<<endl
#define bits(x) __builtin_popcount(x)
#define ff first
#define se second
#define pb push_back
#define pii pair<int,int>
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define PSET(x,y) fixed<<setprecision(y)<<x
#define mp make_pair
#define pi 3.141592653589


int power(int x, int y) {
    int r = 1, z = x;
    while (y) {
        if (y & 1)r *= z;
        z *= z; y = y >> 1;
    }
    return r;
}
int powerm(int x, int y, int p) {
    int r = 1;
    while (y) {
        if (y & 1)r = (r * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return r % p;
}
int modinv(int x, int m) {
    return powerm(x, m - 2, m);
}
int logarithm(int a, int b) {
    int x = 0;
    while (a > 1) {
        x++;
        a /= b;
    }
    return x;
}
int max3(int a, int b, int c) {
    return max(a, max(b, c));
}
int min3(int a, int b, int c) {
    return min(a, min(b, c));
}
int32_t main() {
    fast;
    int x, n;
    cin >> x >> n;
    set<int> s;
    int z;
    for (int i = 0; i < n; ++i) {
        cin >> z;
        s.insert(z);
    }
    int lo = x;
    int hi = x;
    while (1) {
        if (!s.count(lo)) {
            cout << lo;
            return 0;
        }
        else {
            --lo;
        }
        if (!s.count(hi)) {
            cout << hi;
            return 0;
        }
        else {
            ++hi;
        }
    }
    return 0;
}

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

#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

int main() {
	int n; scanf("%d", &n);
	int check; bool ok = true;
	scanf("%d", &check); n--; check--;
	while(ok && n--) {
		int input; scanf("%d", &input);
			if(input < check)
				ok = false;
			else
				check = max(input - 1, check);
	}
	ok?printf("%s", "Yes"):printf("%s", "No");
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.math.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] h = new int[n];

    for (int i = 0; i < n; i++) {
      h[i] = sc.nextInt();
    }

    int count = 0;
    int max = h[0];

    for (int i = 0; i < n; i++) {
      if (max-1 > h[i]) {
        count++;
        continue;
      }
      max = Math.max(max,h[i]);
    }

    // System.out.println(count);

    if (count == 0) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }

}


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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
#define ld long double
#define ll long long
#define mod 1000000007
#define IINF INT_MAX
#define INF 1LL << 30


int main() {
    int n, m; cin >> n >> m;
    V<V<int> > v(m);
    for(int i = 0; i < m; i++){
        int k; cin >> k;
        for(int j = 0; j < k; j++){
            int s; cin >> s;
            s--;
            v[i].push_back(s);
        }
    }
    V<int> p(m);
    for(int i = 0; i < m; i++) cin >> p[i];

    int ans = 0;
    for(int bit = 0; bit < (1 << n); bit++){
        bool flag = true;
        for(int i = 0; i < m; i++){
            int cnt = 0;
            for(int k : v[i]){
                if(bit & (1 << k)) cnt++;
            }
            cnt %= 2;
            if(cnt != p[i]){
                flag = false;
                break;
            }
        }
        if(flag) ans++;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <numeric>
#include <iomanip>
#define ll long long int
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
using namespace std;
int mx4[] = {0,1,0,-1};
int my4[] = {1,0,-1,0};
int mx2[] = {1,0};
int my2[] = {0,1};

class AAtCoDeer {
public:
	void solve(istream& in, ostream& out) {
        vector<int> a(3);
        rep(i,3) in >> a[i];
        sort(a.begin(),a.end());
        int ans = 0;
        rep(i,3) {
            if(a[i + 1] != a[i]) ans++;
        }
        out << ans << endl;
	}
};

int main() {
	AAtCoDeer solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Main {

    public static void main(String[] args) throws Exception {

        InputStreamReader is = new InputStreamReader(System.in);
        BufferedReader reader = new BufferedReader(is);

        List<String> mylist = new ArrayList<>();

        // 標準入力からの値を変数strinputに代入
        String strinput = reader.readLine();

        while (strinput != null) {

            mylist.add(strinput);
            strinput = reader.readLine();

        }

        String arr01[] = mylist.get(0).split(" ");
        long n = Long.valueOf(arr01[0]);

        long i = 1;
        long j = n;

        double temp = Math.sqrt(n);
        //        System.out.println((int) temp);

        for (int k = 2; k <= (int) temp; k++) {
            if (n % k == 0) {
                i = k;
                j = n / i;
            }
        }
        //        System.out.println(i + " " + j);
        System.out.println((i - 1) + (j - 1));
    }

}


Measured memory_bytes: 22996
#include <cstdio>
using namespace std;
const int NL = 105;
int N;
char s[NL], t[NL];
int main() {
	scanf("%d%s%s", &N, s + 1, t + 1);
	for (int i = 1; i <= N+1; ++i) {
		bool match = 1;
		for (int j = i; j <= N; ++j)
			if (s[j] != t[j - i + 1]) {
				match = 0;
				break ;
			}
		if (match) {
			printf("%d\n", 2 * N - (N + 1 - i));
			break ;
		}
	}
	return 0;
}

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

using namespace std;
const int N=100003;
int n,m,d[N],par[N],f[N];
vector<int> a[N];
queue<int> q;
int main()
{
   
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    cin>>n>>m;
    m+=n-1;
    for (int i=1;i<=m;i++)
    {
        int u,v;
        cin>>u>>v;
        a[u].push_back(v);
        d[v]++;
    }
    int root;
    for (int i=1;i<=n;i++)
    if (d[i]==0) q.push(i);
    while (!q.empty())
    {
        int u=q.front();
        q.pop();
        for (auto v:a[u])
        {
            if (f[v]<f[u]+1)
            {
                f[v]=f[u]+1;
                par[v]=u;
            }
            d[v]--;
            if (d[v]==0) q.push(v);
        }
    }
    for (int i=1;i<=n;i++) cout<<par[i]<<"\n";
    return 0;
}


Measured memory_bytes: 7424
#include <iostream>

using namespace std;

int main()
{
	char a[1000000] = { 0 }, b[1000000] = { 0 };
	int i,flag=0;
	cin >> b >> a;
	for (i = 0; i<1000000; i++)
	{
		if (a[i]!=b[i])
		{
			flag = flag + 1;
		}
	}
	cout << flag << endl;
}

Measured memory_bytes: 5544
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;

int a[114514];
int mn[114514];

int main() {
	int n, t;
	cin >> n >> t;
	for (int i = 0; i < n; i++)cin >> a[i];
	mn[0] = a[0];
	for (int i = 1; i < n; i++) {
		mn[i] = min(mn[i - 1], a[i]);
	}
	int ri = 0;
	for (int i = 0; i < n; i++) {
		ri = max(ri, a[i] - mn[i]);
	}
	int ans = 0;
	for (int i = 0; i < n; i++) {
		if (a[i] - mn[i] == ri)ans++;
	}
	
	cout << ans << endl;
}

Measured memory_bytes: 1024
import collections as C
H,W,K=map(int,input().split())
A=[list(input())for _ in[0]*H]
for i,a in enumerate(A):
	if"S"in a:j=a.index("S");Q=C.deque([(1,i,j)])
d=1e9
while Q:
	c,i,j=Q.popleft();d=min(d,i,j,H-i-1,W-j-1)
	if c>K:continue
	for h,w in((i+1,j),(i,j+1),(i-1,j),(i,j-1)):
		if 0<=h<H and 0<=w<W and A[h][w]==".":A[h][w]="";Q+=(c+1,h,w),
print(1--d//K)

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

#define DEBUG 0

#if DEBUG
  #define DLOG(...) fprintf(stderr, __VA_ARGS__)
#else
  #define DLOG(...)
#endif

void debug(auto f) {
#if DEBUG
  f();
#endif
}

int main() {
  ll a, b, c;
  cin >> a >> b >> c;
  string ans = a == b && b == c ? "Yes" : "No";
  cout << ans << endl;
  return 0;
}



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

const int maxn = 1e5;

int pos[maxn + 11];

int main(){
	int n;
	scanf("%d",&n);
	for (int i = 1; i <= n; i++) {
		int x;
		scanf("%d",&x);
		pos[x] = i;
	}
	set <int> s;
	set <int> :: iterator itl,itr;
	s.insert(0); s.insert(n + 1);
	ll ans = 0;
	for (int i = n; i >= 1; i--) {
		itl = s.lower_bound(pos[i]); itr = itl--;
		int l = *itl;
		int r = *itr;
		if (l == 0) {
			itr++;
			int R = *itr;
			if (r != n + 1) {
				ans += 1ll * pos[i] * (R - r) * i;
			}
		}
		else if (r == n + 1) {
			itl--;
			int L = *itl;
			ans += 1ll * (l - L) * (n - pos[i] + 1) * i;
		}
		else {
			itl--; itr++;
			int L = *itl; int R = *itr;
			ans += (1ll * (l - L) * (r - pos[i]) + 1ll * (R - r) * (pos[i] - l)) * i;
		}
		s.insert(pos[i]);
	}
	printf("%lld\n" , ans);
}

Measured memory_bytes: 8844
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		@SuppressWarnings("resource")
		Scanner scan = new Scanner(System.in);

		while (true) {
			String ins = scan.nextLine();
			if (ins.equals("0"))
				break;
			int ans = 0;
			for (int i = 0; i < ins.length(); i++)
				ans += (int) (ins.charAt(i) - '0');
			System.out.println(ans);
		}

		System.exit(0);
	}

}

Measured memory_bytes: 26908
#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <string>
#include <cmath>
#include <cstdio>
#include <cctype>
#include <ctime>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <complex>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cwchar>
#include <cwctype>
#include <exception>
#include <locale>
#include <numeric>
#include <new>
#include <stdexcept>
#include <limits>
#include <valarray>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <list>
#include <utility>
#include <bitset>
#include <algorithm>
#include <functional>
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define MP make_pair
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int INF=1e9+7;
int main(){
	int a,b;
	cin>>a>>b;
	if(a==1)a=14;
	if(b==1)b=14;
	if(a>b)cout<<"Alice"<<endl;
	else if(a<b)cout<<"Bob"<<endl;
	else cout<<"Draw"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <string>
#include <algorithm>
using namespace std;

int main(){
    int N;
    cin >> N;
    for(int i=0;i<N;i++){
        string S;
        cin >> S;
        int n = S.size();
        map<string,int> m;
        for(int j=1;j<n;j++){
            string s = S.substr(0,j),t = S.substr(j,n-j);
            string rs = s,rt = t;
            reverse(rs.begin(),rs.end()); reverse(rt.begin(),rt.end());
            m[s+t]++;
            m[s+rt]++;
            m[rs+t]++;
            m[rs+rt]++;
            m[t+s]++;
            m[t+rs]++;
            m[rt+s]++;
            m[rt+rs]++;
        }
        cout << m.size() << endl;
    }
}


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

int main() {
	int n, d, x; cin >> n >> d >> x;
	int a[100];
	for (int i = 0; i < n; i++) cin >> a[i];

	int count = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < d; j++) {
			if((j * a[i] + 1) <= d) count++;
		}
	}

	cout << count + x << endl;

	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdint>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

#define EPS (1e-7)

int main() {
  ll L, R, d;
  cin >> L >> R >> d;
  ll count = 0;
  for (ll i = L; i <= R; i++) {
    if (i % d == 0) {
      count++;
    }
  }

  cout << count << endl;
  return 0;
}



Measured memory_bytes: 3592
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
int INF=1<<29;
int N,M,R,G[205][205],res;
bool b[9]={0};
int r[9]={0};
void dfs(int p,int pp,int c)
{
	if(p==R+1)
	{
		res=min(res,c);
		return;
	}
	for(int i=1;i<=R;i++)
		if(!b[i])
		{
			b[i]=1;
			if(pp==-1)dfs(p+1,i,0);
			else dfs(p+1,i,c+G[r[pp]][r[i]]);
			b[i]=false;
		}
}

int main()
{
	scanf("%d%d%d",&N,&M,&R);
	for(int i=1;i<=N;i++)for(int j=1;j<=N;j++)G[i][j]=i==j?0:INF;
	for(int i=1;i<=R;i++)
	{
		scanf("%d",&r[i]);
	}
	for(int i=0;i<M;i++)
	{
		int a,b,c;
		cin>>a>>b>>c;
		if(G[a][b]>c)
			G[a][b]=G[b][a]=c;
	}
	for(int k=1;k<=N;k++)
		for(int i=1;i<=N;i++)
			for(int j=1;j<=N;j++)
				G[i][j]=min(G[i][j],G[i][k]+G[k][j]);
	res=INF;
	dfs(1,-1,0);
	printf("%d\n",res);
}


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

ll N, M;
const ll MAX_N = 1.0e5 + 100;
ll A[MAX_N];

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

    
    map<ll, ll> cnt;
    cnt[0] = 1;

    ll sum_A[N + 1];
    sum_A[0] = 0;
    for (int i = 1; i <= N; i++) {
        sum_A[i] = sum_A[i-1] + A[i-1];

        cnt[sum_A[i] % M]++;
    }

    ll ans = 0;
    for (auto i = cnt.begin(); i != cnt.end(); i++) {
        //cout << "key=" << i->first << endl;
        //cout << "val=" << i->second << endl;

        ll val = i->second;

        ans += val*(val - 1)/2;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 5760
#include<iostream>
#include<queue>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
/****************************/
#define ll long long
#define vi vector<int>
#define pii pair<int,int>
#define vpii vector<pair<int,int> >
#define qi queue<int>
#define mii map<int,int>
#define msi map<string,int>
#define vs vector<string>
#define vc vector<char>
/****************************/
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep2(i,n) for(ll i=(n)-1;i>=0;i--)
#define rep3(i,a,n) for(ll i=(a);i<(n);i++)
#define mp make_pair
#define pb push_back
#define st first
#define nd second
#define pi 3.1415926535897932384626433832795
#define zero(n) memset(n,0,sizeof(n));
#define SZ(n) n.size()
#define ss st.st
#define sn st.nd 
/****************************/
using namespace std;     
int n,k;
int a[5050]; 
int main()
{
	ios::sync_with_stdio(0);
	cin>>n>>k;
	rep(i,n)
	{
		cin>>a[i];
	}
	sort(a,a+n);
	reverse(a,a+n);
	ll cnt=0;
	int ans=0;
	rep(i,n)
	{
		if(cnt+a[i]>=k)
		{
			ans=0;
		}
		else 
		{
			cnt+=a[i];
			ans++;
		}
	} 
	cout<<ans<<endl;
	return 0;                                                                                                                                     
}


Measured memory_bytes: 384
#include<iostream>
#include<cstring>
using namespace std;
int cnted[22][22];
int h,w;
bool mas[22][22];
int solve();
int main(){
  while(1){
    memset(cnted,0,sizeof(cnted));
    memset(mas,true,sizeof(mas));
    int n;
    cin >> w >> h;
    if(w == 0 && h == 0) break;
    cin >> n;
    for(int i=0,a,b;i<n;i++){
      cin >> a >> b;
      mas[b-1][a-1]=false;
    }
    cout << solve() << endl;
  }
}
int solve(){
  cnted[0][0] = 1;
  for(int i=1;i<w;i++)
    if(mas[0][i]==true) cnted[0][i]=cnted[0][i-1];
  for(int i=1;i<h;i++)
    if(mas[i][0]==true) cnted[i][0]=cnted[i-1][0];
  for(int i=1;i<h;i++)
    for(int j=1;j<w;j++)
      if(mas[i][j]==true) cnted[i][j] = cnted[i-1][j]+cnted[i][j-1];

  return cnted[h-1][w-1];
}

Measured memory_bytes: 1160
# -*- coding: utf-8 -*-
import math
import sys

# N:枚数
# Y:合計金額
N, Y = list(map(int, input().split()))

# 合計金額を10000で割った数値が1万円の最大枚数
max_x = math.floor(Y / 10000)

# xの値を設定（最大枚数から0まで繰り返す）
for i in range(max_x + 1):
    x = max_x - i
    # 5000円札の最大枚数
    max_y = N - x
    for j in range(max_y + 1):
        y = max_y - j
        z = N - x - y
        otoshidama = 10000 * x + 5000 * y + 1000 * z
        if(otoshidama == Y):
            print('{} {} {}'.format(x,y,z))
            sys.exit()

print('{} {} {}'.format(-1,-1,-1))


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

int main() {
    int a,b,c;
    cin >> a >> b >> c;
    vector<int> x = {a,b,c};
    sort(x.begin(),x.end());
    cout << x.at(2)*10+ x.at(1) + x.at(0);
}

Measured memory_bytes: 256
// %%
import java.util.*;
import java.io.PrintWriter;

// %%
public class Main {

    private static int N;
    private static int K;
    private static PrintWriter pw = new PrintWriter(System.out);

    public static void main(String[] args) {
        load();
        solve();
        pw.flush();
    }

    private static void load() {
        Scanner sc = new Scanner(System.in);
        N = sc.nextInt();
        K = sc.nextInt();
    }

    private static void solve() {
        if (K > (N - 1) * (N - 2) / 2) {
            pw.println(-1);
            return;
        }

        int cnt = N - 1 + (N - 1) * (N - 2) / 2 - K;
        pw.println(cnt);

        // for (int v = 1; v <= N; v += 1) {
        //     for (int w = v + 1; w <= N; w += 1) {
        //         pw.print(v);
        //         pw.print(' ');
        //         pw.println(w);
        //         cnt -= 1;
        //         if (cnt == 0) {
        //             return;
        //         }
        //     }
        // }

        int v = 1;
        while (true) {
            for (int w = v + 1; w <= N; w += 1) {
                pw.print(v);
                pw.print(' ');
                pw.println(w);
                cnt -= 1;
                if (cnt == 0) {
                    return;
                }
            }
            v += 1;
        }
    }

}

// %%
// Main.main(new String[0]);

Measured memory_bytes: 21972