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

int main() {
    int n; cin >> n;
    vector<vector<int>> ans(n, vector<int>(n, -1));

    int cnt = 0, col = 1;
    while(cnt != n * (n - 1) / 2) {
        vector<int> pari(n, -1);
        for(int v = 0; v < n; ++v) {
            if(pari[v] != -1) continue;
            pari[v] = 0;
            function<void(int)> dfs = [&] (int v) {
                for(int to = 0; to < n; ++to) {
                    if(pari[v] == pari[to] || ans[v][to] != -1) continue;
                    ans[v][to] = ans[to][v] = col;
                    cnt += 1;
                    if(pari[to] == -1) {
                        pari[to] = !pari[v];
                        dfs(to);
                    }
                }
            };
            dfs(v);
        }
        col += 1;
    }

    for(int i = 0; i < n; ++i) {
        for(int j = i + 1; j < n; ++j) {
            cout << ans[i][j] << " ";
        }
        cout << endl;
    }
}


Measured memory_bytes: 1536
#桁dp
N = input()
l = len(N)

ans = sum(map(int,N))
for i in range(l):
    if N[i]=="0":continue
    M=N[:i] + str(int(N[i])-1) + "9"*(l-i-1)
    S = sum(map(int,M))
    ans = max(ans,S)
print(ans)

Measured memory_bytes: 3060
#include <iostream>
using namespace std;
int main() {
    int N, K;
    cin >> N >> K;
    int d, i, j, a, count=N;
    int *snuke = new int[N]{0};

    for(i=0; i<K; i++){
       cin >> d;
       for(j=0; j<d; j++){
           cin >> a;
           if( snuke[a-1] == 0){
               count--;
               snuke[a-1]++;
           }
       }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <set>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

ll pow5(ll n){
    return n * n * n * n * n;
}

int main(){
    ll X;

    cin >> X;

    for(ll i = 0; i <= 200; i++){
        for(ll j = i * (-1); j <= i; j++){
            if(pow5(i) - pow5(j) == X){
                cout << i << " " << j << endl;
                return 0;
            }
        }
    }

    return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

namespace ABC171
{
  class B
  {
  public:
    B() = default;
    ~B() = default;


    void Run()
    {
      int N, K;
      std::cin >> N;
      std::cin >> K;

      std::vector<int> nums = {};
      nums.reserve(N);

      for (int i = 0; i < N; ++i)
      {
        int p = {};
        std::cin >> p;
        nums.push_back(p);
      }
      std::sort(nums.begin(), nums.end());

      int sum = {};
      for (int i = 0; i < K; ++i)
      {
        sum += nums.at(i);
      }

      std::cout << sum << std::endl;
    }
  };

}


int main()
{

  ABC171::B prob;
  prob.Run();

  return 0;
}



Measured memory_bytes: 3192
import sys
input=sys.stdin.readline
import collections
import bisect

def main():
    N = int(input())
    P = list(map(int,input().split()))
    ans = 0
    for i,v in enumerate(P):
        if i < N-1 and i == v-1:
            tmp = P[i+1]
            P[i+1] = v
            P[i] = tmp
            ans += 1
    if P[-1] == N:
        ans += 1
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 52316
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main(){
  string s; cin >> s;
  int a = (s[0] - '0') * 10 + (s[1] - '0');
  int b = (s[2] - '0') * 10 + (s[3] - '0');
  bool flg1 = 0 < a && a <= 12;
  bool flg2 = 0 < b && b <= 12;
  if(flg1 && flg2) cout << "AMBIGUOUS" << endl;
  else if(a == 0 && flg2) cout << "YYMM" << endl;
  else if(b == 0 && flg1) cout << "MMYY" << endl;
  else if(flg1 && !flg2) cout << "MMYY" << endl;
  else if(!flg1 && flg2) cout << "YYMM" << endl;
  else cout << "NA" << endl;
  return 0;
}

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

typedef long long ll;

using namespace std;

int main() {

    string s;
    string t;
    cin >> s;
    cin >> t;

    int ans = 0;
    for (int i = 0; i < s.length(); i++) {
        if (t[i] != s[i]) ans++;
    }

    cout << to_string(ans) << endl;
    
    return 0;
}


Measured memory_bytes: 3928
#include<bits/stdc++.h>
using namespace std;
int main(){
    int h,w;
    cin >> h >> w;
    string c[h];
    for(int i = 0; i < h; i++) cin >> c[i];
    for(int i = 0; i < h; i++){
        cout << c[i] << endl;
        cout << c[i] << endl;
    }

}

Measured memory_bytes: 384
n, k = map(int, input().split())

# 二項係数をたくさん高速で求める方法
# 1<=k<=n<=10*7程度まで
# 前処理 COMinit(): O(n)
# クエリ処理 COM(n, k): O(1)
# https://drken1215.hatenablog.com/entry/2018/06/08/210000

m = 2001
mod = 1000000007

fac = [1] * m
finv = [1] * m
inv = [1] * m


def COMinit():
    for i in range(2, m):
        fac[i] = fac[i - 1] * i % mod
        inv[i] = mod - inv[mod % i] * (mod // i) % mod
        finv[i] = finv[i - 1] * inv[i] % mod


def COM(n, k):
    if n < 0 or k < 0 or n < k:
        return 0
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod


COMinit()
for i in range(k):
    print(COM(n-k+1, i+1) * COM(k-1, i) % mod)


Measured memory_bytes: 3572
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        Map<Integer, ArrayList<Integer>> map = new TreeMap<>();
        for (int i = 0; i < M; i++) {
            int P = sc.nextInt();
            int Y = sc.nextInt();
            map.put(Y, new ArrayList<>(Arrays.asList(P, i)));
        }
        String[] ans = new String[M];
        int[] count = new int[N + 1];
        for (List<Integer> list : map.values()) {
            ans[list.get(1)] = String.format("%06d%06d", list.get(0), ++count[list.get(0)]);
        }
        for (int i = 0; i < M; i++) {
            System.out.println(ans[i]);
        }
    }
}



Measured memory_bytes: 181772
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
const ll mod =1000000007;
int main(){
    int n;
    cin>>n;
    map<pair<int,int> ,int> m;
    vector< queue<int> > q(n+1);
    for(int i=1; i<n; i++){
        int ai,bi;
        cin>>ai>>bi;
        m[make_pair(ai,bi) ] = i;
        m[make_pair(bi,ai) ] = i;
        q.at(ai).push(bi);
        q.at(bi).push(ai);
    }
    vector<int> ans(n,0);
    vector< set<int> > co(n+1);
    int k=0;
    queue<int> s;
    s.push(1);
    while(!s.empty()){
        int t= s.front();
        queue<int> tmp = q.at(t);
        int col =1;
        while(!tmp.empty()){
            int h = tmp.front();
            int hen = m.at(make_pair(t,h));
            if(ans[hen] ==0){
                while(hen>0){
                    if(co.at(t).count(col)){
                        col++;
                    }
                    else{
                        ans[hen]=col;
                        co.at(h).insert(col);
                        co.at(t).insert(col);
                        hen =0;
                    }
                }
                k = max(k,col);
                s.push(h);
            }
            tmp.pop();
        }
        s.pop();
    }
    cout<<k<<endl;
    for(int i=1; i<n; i++){
        cout<<ans[i]<<endl;
    }
}

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

int main() {
    // input
    int N, M;
    string S;
    cin >> N >> M >> S;

    // solve
    reverse(S.begin(), S.end());
    int idx = 0;
    vector<int> ans;
    bool checked[N+1] = {};
    while (idx != N) {
        for (int i = min(M, N - idx); i > 0; i--) {
            int ni = idx + i;
            if (checked[ni]) {
                cout << -1 << endl;
                return 0;
            }

            if (S[ni] == '1') {
                checked[ni] = true;
            } else {
                ans.push_back(i);
                idx += i;
                break;
            }
        }
    }

    // end
    reverse(ans.begin(), ans.end());
    for (int i: ans) cout << i << " ";
    cout << endl;
}

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

int main()
{
    int n;
    cin >> n;
    int v[n],c[n];
    for(int i=0;i<n;++i) cin >> v[i];
    for(int i=0;i<n;++i) cin >> c[i];
    int sum=0;
    for(int i=0;i<n;++i){
        if(v[i]-c[i]>0) sum+=v[i]-c[i];
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <deque>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define rep(i,n) for (int i=0; i<n;++i)
#define rep_itr(it, M) for (auto it = M.begin(); it != M.end(); ++it)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 2e9;
int n;

void dfs(string s, char mx) {
  if (s.length() == n) cout << s << endl;
  else {
    for (char c = 'a'; c <= mx; c++) {
      dfs(s + c, c == mx ? char(mx + 1) : mx);
    }
  }
}
 
int main() {
  cin >> n;
  dfs("", 'a');
  return 0;
}


Measured memory_bytes: 1536
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007

#A
def A():
    return

#B
def B():
    return

#C
def C():
    n, m = LI()
    py = LIR(m)
    pya = py[::1]
    py.sort(key=lambda x: x[1])
    city = [1 for i in range(n)]
    dicity = {}
    for p, y in py:
        dicity[(p,y)] = city[p-1]
        city[p-1] += 1    
    for p, y in pya:
        a = "00000" + str(p)
        a = a[-6:]
        b = "00000" + str(dicity[(p, y)])
        b = b[-6:]
        print(a+b)

    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    C()


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

using namespace std;

#define vi vector<int>
#define pb push_back
#define lli long long int
#define INF 1000000001


void solve() {
	int x, y;
	cin >> x >> y;
	if (x * 4 < y || y & 1 || x * 2 > y) {
		cout << "No" << endl;
		return;
	} else {
		cout << "Yes" << endl;
		return;
	}

}

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

#ifndef ONLINE_JUDGE

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

	freopen("output.txt", "w", stdout);
#endif
	// int t; cin >> t;
	// while (t--)
	solve();



	return 0;

}


Measured memory_bytes: 3628
#pragma comment(linker, "/STACK:102400000,102400000")
#include <bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define SZ(x) (int)(x.size())
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,a,b) for(int i=b-1;i>=a;i--)
#define inf 1000000007
#define mod 1000000007
#define x first
#define y second
#define pi acos(-1.0)
#define DBG(x) cerr<<(#x)<<"="<<x<<"\n";
//#define dprintf(...) 
#define hash _hash
//#define dprintf(...) fprintf(outFile,__VA_ARGS__)
 
#define FOREACH(it,x) for(__typeof(x.begin()) it=x.begin();it!=x.end();it++)
#define ull unsigned long long
#define ll long long
#define N 100010
 
template <class T,class U>inline void Max(T &a,U b){if(a<b)a=b;}
template <class T,class U>inline void Min(T &a,U b){if(a>b)a=b;}
 
//FILE* outFile;
 
inline void add(int &a,int b){a+=b;while(a>=mod)a-=mod;}
 
 
int pow(int a,int b){
    int ans=1;
    while(b){
        if(b&1)ans=ans*(ll)a%mod;
        a=(ll)a*a%mod;b>>=1;
    }
    return ans;
}
 
int f[N],sz[N],a[N];
int find(int a){return a==f[a]?a:f[a]=find(f[a]);}
void merge(int a,int b){
    if(sz[a]<sz[b])swap(a,b);
    sz[a]+=sz[b];
    f[b]=a;
}
vi v[N];
int main(){
   // freopen("read.in","r",stdin);
    //freopen("atlarge.in","r",stdin);
    //freopen("atlarge.out","w",stdout);
    //cout<<setprecision(9)<<fixed;
    int T,j,i,k,ca=0,K=0,n,m;
    scanf("%d%d",&n,&m);
    rep(i,0,n)scanf("%d",&a[i]);
    rep(i,0,n)f[i]=i,sz[i]=1;
    ll s=0;
    while(m--){
        scanf("%d%d",&i,&j);
        i=find(i),j=find(j);
        if(i!=j)merge(i,j);
    }
    m=0;
    rep(i,0,n)if(find(i)==i){
        if(sz[i]==1)K++,s+=a[i];
        else v[i].pb(a[i]),m++;
    }
    else{
        v[find(i)].pb(a[i]);
    }
    if(K>n-K-2*(m-1)){
        puts("Impossible");return 0;
    }
    if(m+K==1){
        puts("0");return 0;
    }
    int rem=K+2*(m-1);
    vi e;
    rep(i,0,n)if(f[i]==i&&sz[i]>1){
        sort(all(v[i]));
        s+=v[i][0];rem--;
        rep(j,1,SZ(v[i]))e.pb(v[i][j]);
    }
    if(rem){
        sort(all(e));
        rep(i,0,rem)s+=e[i];
    }
    printf("%lld\n",s);
    //cerr<<1.*clock()/CLOCKS_PER_SEC<<"ms"<<"\n";
    return 0;
}   


Measured memory_bytes: 4988
#include<iostream>
#include<algorithm>
#define v(i,s,n) for(int i=s;i<n;i++)
#define z while(true)
using namespace std;int n,t[100][100],h[5100][8],w,dp[100][5100],a;void Nh(int n){w=0;int c[7]={0},i;z{c[0]++,i=0;z{if(c[i]==n){if(i==n-1)goto op;c[i+1]++,c[i]=0;}else break;i++;}bool ok=true;v(f,0,n-1)v(g,f+1,n)if(c[f]==c[g])ok=false;if(ok){v(k,0,n)h[w][k]=c[k];w++;}}op:;return;}int main(){cin>>n;v(i,0,n)v(j,0,n)t[i][j]=0;v(i,0,n){cin>>a;v(j,max(0,i-a),min(a+i+1,n))t[i][j]=1;}v(i,0,n){cin>>a;v(j,0,100)t[i][j]*=a;}Nh(min(n,7));v(i,0,n)v(j,0,w)dp[i][j]=0;int ans=0;v(i,0,w){int cnt=0;v(f,0,min(n,7))v(g,0,min(n,7))if(h[i][f]>h[i][g])cnt+=t[g][f];dp[6][i]=cnt,ans=max(ans,cnt);}v(r,7,n)v(i,0,w)v(j,0,8){int cnt=0,c[7];v(k,0,7){c[k]=h[i][k];if(h[i][k]<j)cnt+=t[r-7+k][r];else cnt+=t[r][r-7+k],c[k]++;if(k>0){if(h[i][k]>h[i][0])c[k]--;c[k-1]=c[k];}}c[6]=j;if(h[i][0]<j)c[6]--;int l=0,ri=w,m;z{if(l>=ri-1)break;m=(l+ri)/2;int s=0,q=6;v(k,0,7){if(h[m][q]<c[q]){s=1;break;}if(h[m][q]>c[q]){s=-1;break;}q--;}if(s==0)break;if(s==1)l=m;else ri=m;}dp[r][m]=max(dp[r][m],dp[r-1][i]+cnt);}v(i,0,w)ans=max(ans,dp[n-1][i]);cout<<ans<<endl;return 0;}

Measured memory_bytes: 3348
N = int(input())
sp = [list(map(str, input().split())) for _ in range(N)]

for i in range(N):
    sp[i][1] = int(sp[i][1])
    sp[i].append(i+1)

sp2 = sorted(sp, key=lambda x: x[1], reverse=True)
sp3 = sorted(sp2, key=lambda x: x[0])

for j in range(N):
    print(sp3[j][2])

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

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()



int main() {
    ll n;
    cin >> n;
    vector<ll> divs;
    for (ll i = 1; i * i <= n; ++i) {
        if (n % i == 0) {
            divs.push_back(i);
            if (i * i != n) {
                divs.push_back(n / i);
            }
        }
    }
    ll ans = 0;
    for (auto e: divs) {
        ll m = e - 1;
        ll p = n / e;
        if (m > p) {
            ans += m;
        }
    }
    cout << ans << endl;
}

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

using namespace std;
using ull = unsigned long long;

int main() {
    int X, Y, Z;
    cin >> X >> Y >> Z;

    int rest = X - Z;
    int ans = 0;
    while (true) {
        if (rest - Y - Z >= 0) {
            rest -= Y + Z;
            ++ans;
        } else {
            break;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
/*
	Author: Dinesh Verra
	College: ABV-IIITM
	Date: 20/06/2020
*/
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp> 
// using namespace boost::multiprecision; 
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define cu continue
#define br break
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mod 1000000007
#define inf 1000000000
#define pll pair <ll,ll>
#define min_pq priority_queue <pll> ,vector <pll>, greater <pll> > > 
#define F first
#define S second
#define vll vector <ll>
#define vpll vector <pll>
#define dbg(n) cout<<#n<<' '<<n<<endl;
#define all(v) v.begin(),v.end()
#define nl cout<<'\n'

template <typename A1>
void prn(A1&& arg)
{
	cout<<arg<<'\n';
}
template <typename A1, typename... A>
void prn(A1&& arg, A&&... args)
{
	cout<<arg<<' ';
	prn(args...);
}

#define N 100005

ll f[N];

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


	ll n,s=0;
	cin>>n;
	ll a[n];
	for(ll i=0;i<n;i++)
	{
		cin>>a[i];
		s+=a[i];
		f[a[i]]++;
	}
	ll q,b,c,tmp;
	cin>>q;
	while(q--)
	{
		cin>>b>>c;
		tmp=f[b];
		s-=(tmp*b);
		s+=(tmp*c);
		f[b]=0;
		f[c]+=tmp;
		prn(s);
	}
}



Measured memory_bytes: 5144
#include <cstdio>
#include <string>
#include <iostream>
#include <vector>
using namespace std;

int main(int argc, char const *argv[]) {
  int N,M;
  int a,b;
  int toansnum=0;
  scanf("%d %d",&N,&M);
  vector<vector<int>> to;
  to.resize(N+1);
  for (int i = 0; i < M; i++) {
    scanf("%d %d", &a, &b);
    to[b].push_back(a);
    if(b==N){
      toansnum++;
    }
  }
  for (int i = 0; i < toansnum; i++) {
    b=to[N][i];
    for(auto itr = to[b].begin(); itr != to[b].end(); itr++){
      if((*itr)==1){
        printf("POSSIBLE\n");
        return 0;
      }
    }
  }
  printf("IMPOSSIBLE\n");
  return 0;
}


Measured memory_bytes: 8576
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        
		String[] ss0 = br.readLine().trim().split(" ", 0);

		boolean b = true;
		
		b = (ss0[0].equals("H"));
		
		if (ss0[1].equals("D")) { b = !b;}

		String s = "D";
		if(b) { s = "H"; }

        System.out.println(s);
        return;
    }
    //-----------------------------------------------------------------
    // Debug.Print
    static void dp(String s) {
		System.out.println(s);
	}
    static void dp(StringBuilder s) { dp(s.toString()); }
    static void dp(int i) { dp(String.valueOf(i)); }
    static void dp(long i) { dp(String.valueOf(i)); }


	//-----------------------------------------------------------------
	// 入力値確認
	static void checkInput(int[][] i2) {
		StringBuilder sb = new StringBuilder();
		for(int[] i1: i2){
			for(int i: i1) sb.append("[" + i + "]");
			sb.append(System.getProperty("line.separator"));
		}
		System.out.println(sb);
	}

}

Measured memory_bytes: 21204
// #include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <set>
#include <queue>
#include <cstdio>
using namespace std;
#define rep(i, n) for(int i=0;i<n;i++)
#define irep(i, n) for(int i=n-1;i>=0;i--)
#define lrep(i, n) for(long long i=0;i<n;i++)
typedef long long ll;
typedef vector<long long> llv;
typedef vector<vector<long long> > llvv;
template <class T>
T gcd(T n, T m){
    if (n>m) return gcd(m,n);
    else if(n==0) return m;
    else return gcd(m-n*(m/n), n);
}

int N = 100010;

int main(){
    int n;
    cin >> n;
    int a[N+1];
    for (int i=1;i<=n;i++){
        int num;
        cin >> num;
        a[num] = i;
    }
    for (int num=1;num<=n;num++){
        if(num-1) cout << " ";
        cout << a[num];
    }
    cout << endl;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
using P = pair<int,int>;
const int INF = int(1e9)+5;
int H,W;

bool onBoard(int y,int x){
    if(y>=0 && y<H && x>=0 && x<W){
        return true;
    }else{
        return false;
    }
}

int main() {
    cin >> H >>W;
    int d[H][W];
    for(int i=0;i<H;i++)for(int j=0;j<W;j++){
        d[i][j] = INF;
    }

    int Cy,Cx,Dy,Dx;
    cin >> Cy >> Cx >> Dy >>Dx;
    --Cx;--Cy;--Dx;--Dy;
    vector<string> S(H);
    for(int i=0;i<H;i++){
        cin >> S[i];
    }
    priority_queue<P,vector<P>,greater<P>> pq;
    pq.push(P(0,Cy*W+Cx));
    d[Cy][Cx] == 0;

    int dy[] = {1,0,-1,0};
    int dx[] = {0,1,0,-1};


    while(!pq.empty()){
        P p = pq.top();
        pq.pop();
        int y = p.second/W;
        int x = p.second%W;
        // cerr <<"y=" << y <<"x=" << x << "val=" << p.first << endl;
        if(d[y][x] < p.first){
            continue;
        }
        for(int i=0;i<4;i++){
            int ny = y + dy[i];
            int nx = x + dx[i];
            if(onBoard(ny,nx) && S[ny][nx] == '.'){
                if(d[ny][nx] > p.first){
                    d[ny][nx] = p.first;
                    pq.push(P(p.first,ny*W+nx));
                }
            }
            for(int j=-2;j<3;j++)for(int k=-2;k<3;k++){
                int ny = y + j;
                int nx = x + k;
                if(onBoard(ny,nx) && S[ny][nx] == '.'){
                    if(d[ny][nx] > p.first+1){
                        d[ny][nx] = p.first+1;
                        pq.push(P(p.first+1,ny*W+nx));
                    }
                }

            }
        }
    }
    if(d[Dy][Dx] < INF){
        cout << d[Dy][Dx] << endl;
        return 0;
    }
    cout << -1 <<endl;
    return 0;
}

Measured memory_bytes: 9428
n,k = map(int,input().split())
a = list(map(int,input().split()))

tt = [0] * n
tt[0] = 1
ans_l = [1]
i = 1
c = 0

while True:
    if c == k: #ループに達することができないk回を入力として与えられるとこの条件式がない場合
        break  #ループに達した上で計算されてしまう。これがあるとkが下の式で0として計算される。
    c += 1
    i = a[i-1]
    if tt[i-1] == False:
        tt[i-1] = 1
        ans_l.append(i)
    else:
        break

#print(c,k)
d = ans_l.index(i)
k -= d
ans = k % (len(ans_l)-d)
print(ans_l[ans+d])


Measured memory_bytes: 102544
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
int m[101];
int main(void) {
  int n, t, s;
  for (scanf("%d", &n); n--;) {
    scanf("%d", &t);
    ++m[t];
  }
  for(int i=s=0; i<101; ++i) {
    m[i]!=0?++s:s;
  }
  printf("%d\n", s);
  return 0;
}


Measured memory_bytes: 256
//
// Created by ZEN on 2019/10/20.
//

#include <bits/stdc++.h>

using namespace std;


int main() {
    int a, n;
    cin >> n;
    vector<int> vec(n);
    for (int i = 0; i < n; ++i) {
        cin >> a;
        vec.at(i) = a;
    }
    vector<int> ans(n);
    for (int j = 0; j < n; ++j) {
        ans.at(vec.at(j) - 1) = j + 1;
    }
    for (int k : ans) {
        cout << k << endl;
    }
}


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

int N, M, X;
int C[15];
int A[15][15];

int solve(int i, int c, vector<int> now) {
  if (i == N) {
    bool ok = true;
    rep(j, M) if (now[j] < X) ok = false;
    if (ok)
      return c;
    else
      return INF;
  } else {
    vector<int> next = now;
    rep(j, M) next[j] += A[i][j];
    return min(solve(i + 1, c, now), solve(i + 1, c + C[i], next));
  }
}

int main() {
  cin >> N >> M >> X;
  rep(i, N) {
    cin >> C[i];
    rep(j, M) cin >> A[i][j];
  }
  vector<int> init(M);
  int ans = solve(0, 0, init);
  if (ans == INF)
    cout << -1 << endl;
  else
    cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3636
from collections import defaultdict

d = defaultdict(int)
N = int(input())
for _ in range(N):
    s = str(input())
    d[s] += 1
M = int(input())
for _ in range(M):
    t = str(input())
    d[t] -= 1

print(max(0, max(d.values())))

Measured memory_bytes: 9444
import java.util.Scanner;

public class Main {

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

		// 整数の入力
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int res = 0;

		if(a > b){
			System.out.println(res);
		}else{
			res = b /a ;
			if(res > c){
				res = c;
			}
          System.out.println(res);
		}

		sc.close();
	}
}


Measured memory_bytes: 21844
#include<iostream>


int main(){
int A, B, C;
std::cin >> A >> B >> C;

if(((A != B) && (B != C) && (C !=A)) || ((A==B)&&(B==C)&&(C==A))){
  std::cout << "No" << "\n";
}else{
  std::cout << "Yes" << "\n";
}

return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include<cmath>
#define ll long long
using namespace std; 
 
ll gcdNumber(ll a, ll b)
{
    if(b == 0)
        return a;
    return gcdNumber(b, a % b);
}
int main()  
{  
    ll n1, n2;
    ll count = 0;
    cin>>n1>>n2;
    ll gcdVal = gcdNumber(n1, n2);
    ll flag = 0;
    ll n = gcdVal;
    
	while (n % 2 == 0) 
	{ 
		n = n/2;
		if(flag == 0)
		{
	        if(gcdVal % 2 == 0)
	        {
		      count++;
    		  flag = 1;
	        }
		}
	} 
	for (ll i = 3; i <= sqrt(n); i = i + 2) 
	{
	    flag = 0;
		while (n % i == 0) 
		{ 
			n = n/i;
			if(flag == 0)
		    {
		        if(gcdVal % i == 0)
		        {
    		      count++;
        		  flag = 1;
		        }

		    }
		} 
	} 
	if (n > 2) 
    {
        if(gcdVal % n == 0)
        {
	      count++;
        }
    }
    cout<<count+1;
    return 0;  
}

Measured memory_bytes: 256
n, m = [int(item) for item in input().split()]
ab = [[int(item) for item in input().split()] for _ in range(m)]

ab = sorted(ab, key = lambda x:x[1])

ans = 0
disconnected = [0]
for a, b in ab:
  if disconnected[-1] > a:
    continue
  disconnected.append(b)
  ans += 1
  
print(ans)

Measured memory_bytes: 23588
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define mp          make_pair
#define pll         pair<long long,long long>
#define vll          vector<long long>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (long long)x.size()
#define hell        1000000007
#define lbnd        lower_bound
#define rep(i,a,b)	for(int i=a;i<b;i++)
#define ubnd        upper_bound
#define bs          binary_search
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
int main(){
	ll n;cin>>n;
	n--;
	ll sum=0;
	ll a[n+1]={0};
	for(ll i=1;i<=n;i++)cin>>a[i];
	sum+=a[1];
	sum+=a[n];
     for(ll i=2;i<=n;i++){
     	sum+=min(a[i-1],a[i]);
	 }
	 cout<<sum<<endl;
}

Measured memory_bytes: 256
S = input()
K = int(input())

cont = []
n = 1
t = S[0]
for s in S[1:]:
    if s == t:
        n += 1
    else:
        cont.append(n)
        n = 1
    t = s
else:
    cont.append(n)

C = len(cont)
ans = 0
if C == 1:
    ans += (cont[0]  * K // 2)
else:
    for i in range(1, C-1):
        ans += cont[i] // 2
    ans *= K
    ans += cont[0] // 2
    ans += cont[-1] // 2
    if S[0] == S[-1]:
        ans += ((cont[0] + cont[-1]) // 2) * (K-1)
    else:
        ans += (cont[0] // 2) * (K-1)
        ans += (cont[-1] // 2) * (K-1)

print(ans)


Measured memory_bytes: 3064
num=input()
a=int(num[0])
b=int(num[1])
c=int(num[2])
d=int(num[3])
yn=0
for i in range(2):
    for j in range(2):
        for k in range(2):
            num2=a
            if i==0:
                num2+=b
            else:
                num2-=b
            if j==0:
                num2+=c
            else:
                num2-=c
            if k==0:
                num2+=d
            else:
                num2-=d
            if num2==7:
                yn=1
                break
        if yn==1:
            break
    if yn==1:
        break
ans=""
ans+=str(a)
if i==0:
    ans+="+"
else:
    ans+="-"
ans+=str(b)
if j==0:
    ans+="+"
else:
    ans+="-"
ans+=str(c)
if k==0:
    ans+="+"
else:
    ans+="-"
ans+=str(d)
ans+="=7"
print(ans)


Measured memory_bytes: 3064
N = gets.chomp.to_i
xy = Array.new(N){Array.new(2,0)}
sub = Array.new(N*(N-1)){Array.new(2,0)}

for x in 0...N
  str = gets.split
  xy[x][0],xy[x][1] = str[0].to_i, str[1].to_i
end

if N <= 2
  puts 1
  exit
end

i = 0
for x in 0...N
  for y in 0...N
    if x != y
      sub[i][0],sub[i][1] = xy[x][0]-xy[y][0], xy[x][1]-xy[y][1]
      i += 1
    end
  end
end

sub.sort_by! {|x| [x[0], x[1]]}

max = 0
a = 0
for x in 0...sub.size-1
  if sub[x][0] == sub[x+1][0] && sub[x][1] == sub[x+1][1]
    a += 1
  else
    if a > max
      max = a
    end
    a = 0
  end
end
if a > max
  max = a
end

puts N-max-1

Measured memory_bytes: 1916
#include"bits/stdc++.h"
#define int ll
using namespace std;
using ll = long long ;
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); cout.setf(ios::fixed); cout.precision(20)
//#define endl '\n'
///       Author
///        ::
///    (  NOBODY  )
///   No Copyright .....You can copy and paste it without my permission...................................
///    Another Loser...........
/// !!!!!!!!!!!!!!!
#define pb push_back
#define N 1000020
#define ff first
#define ss second
#define all(x) x.begin(),x.end()

int32_t main()
{


    int a,b=0,c,x;
   cin>>a;
    for(int i=0; i<a; i++)
    {
        cin>>x;
        if(x%2==0){
          if(x%3==0||x%5==0)continue;
          else b=1;
        }
    }
    if(b)cout<<"DENIED"<<endl;
    else cout<<"APPROVED"<<endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
	int a[101] = {0};
	int input;
	while(cin >> input){
		a[input]++;
	}
	int m = 0;
	for(int i = 1; i < 101; i++){
		if(m < a[i]) m = a[i];
		//m = max(m, a[i]);
	}
	for(int i = 1; i < 101; i++){
		if(m == a[i]){
			cout << i << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define pb push_back
#define pf push_front
#define mod 1000000007
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK puts("OK")
#define OK1 puts("OK1")
#define OK2 puts("OK2")
#define SIZE(s) (int)s.size()
#define Cout(n) cout<<(n)<<endl
#define INF 1000000000000000000LL

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;
typedef vector<string> vs;
const double pi = acos(-1.0);

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << ", ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

bool IsPrime(int num){
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2){
        if (num % i == 0){
            return false;
        }
    }
    return true;
}

int main()
{
	ll n,a,b,sa,ans=0;
	cin >> n >> a >> b;
	vll x(n);
	rep(i,n) cin >> x[i];
	rep(i,n-1){
		sa=(x[i+1]-x[i])*a;
		ans+=min(b,sa);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1024
#include<cstdio>
#define ri register int
#define rc register char
#define ll long long int
#define rl register long long int
#define in inline
#define gc getchar
in int read()
{
	ri x=0,p=1;
	rc ch=gc();
	while(ch<'0' || ch>'9')
	{
		if(ch=='-')
		{
			p=-1;
		}
		ch=gc();
	}
	while(ch>='0' && ch<='9')
	{
		x=x*10+ch-'0',ch=gc();
	}
	return x*p;
}
int a[100]={0,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()
{
	ri k=read();
	printf("%d\n",a[k]);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
using namespace std;
#define IOS {ios :: sync_with_stdio(false); cin.tie(0);cout.tie(0); }
#define F first
#define S second
#define pb push_back
typedef long double ld;
#define deci(n) cout << fixed << setprecision(n);
typedef long long ll;

#define mem0(x)  memset(x,0,sizeof(x));
#define mem1(x)  memset(x,1,sizeof(x));
#define memm1(x) memset(x,-1,sizeof(x));
#define all(a) a.begin(), a.end()
#define pll pair<ll, ll>
#define bits(x) __builtin_popcount(x)
#define fori(n)  for (ll i = 0; i < n; i++)
#define fori2(n) for(ll i=1;i<=n;i++)
#define forj(n)  for (ll j = 0; j < n; j++)
#define forj2(n) for(ll j=1;j<=n;j++)
#define fork(n)  for (ll k = 0; k < n; k++)
#define fork2(n) for(ll k=1;k<=n;k++)
#define vll vector <ll>
#define mll map <ll, ll>
#define vpll vector <pll>
const ll md = 1e9 + 7;

#define BSET(a, p) ((a) | (1ll << (p)))
#define BCHK(a, p) ((a) & (1ll << (p)))
#define BXOR(a, p) ((a) ^ (1ll << (p)));
#define BREM(a, p) (BCHK(a, p)?(BXOR(a, p)):(a))
#define BSHO(a, N) (bitset<N>(a))
// const ll N = 100005;
// ll fac[N] = {1};
// #define calfac for(ll i=1  ;i<N;i++) fac[i] = (fac[i-1]*i)%md;
// ll C[N+1][M+1]; 
// void  ncr(){
//     ll n = N,k = M; 
//     for (ll i = 0; i <= n; i++) { 
//         for (ll j = 0; j <= min(i, k); j++) { 
//             if (j == 0 || j == i)  C[i][j] = 1; 
//             else C[i][j] = C[i - 1][j - 1] +  C[i - 1][j]; 
//         } 
//     } 
// } 


#define RBTTYPE int
#define ordered_set tree<RBTTYPE, null_type, less<RBTTYPE>, rb_tree_tag,tree_order_statistics_node_update> 
// Ordered set docs:
// order_of_key (k) : Number of items strictly smaller than k .
// find_by_order(k) : K-th element in a set (counting from zero).
ll modexp(ll x, ll ex) {
    ll ans = 1ll;
    while (ex > 0) {
        if (ex & 1ll) ans = (ans * x) % md;
        ex >>= 1ll;
        x = (x * x) % md;
    }
    return ans;
}
ll modInv(ll a)
{
    return pow(a,md-2);
}
 
// ll nCr(ll n,ll r)
// {
//     return (fac[n]*modInv((fac[r]*fac[n-r])%md))%md;
// }

 
ll po(ll x,ll n){
    if(n==0) return 1;
    if(n%2==1) return (x*po(x,n-1));
    else {
        ll k=po(x,n/2);
        return (k*k);
    }
}
 
ll gcd(ll x, ll y) {
    if (x < y) return gcd(y, x);
    if (y == 0) return x;
    return gcd(y, x % y);
}
 
ll a[100004];

int32_t main(){
    IOS;
    ll i,j,k,m,n,p,q;
    cin >> n;
    m = 102;
    fori2(m){
        forj2(m){
            fork2(m){
                p = i*i + j*j + k*k + i*j + i*k + j*k;
                a[p]++;
            }
        }
    }
    fori2(n) cout << a[i] <<"\n";

} 

Measured memory_bytes: 4152
function Main(input) {
  input=input.split("\n");
  var array=input[1].split(" ");
  var memo=[];
  var counter=0;
  array.forEach(e=>{
    if(memo[e-0]){
      counter++;
    }else{
      memo[e-0]=true;
    }
  });
  console.log(input[0]-Math.ceil(counter/2)*2);
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
  
  


Measured memory_bytes: 39232
import sys

sys.setrecursionlimit(10 ** 7)
INF = 10 ** 18
MOD = 10 ** 9 + 7


def LI():
    return list(map(int, sys.stdin.readline().split()))


def II():
    return int(sys.stdin.readline())


def LS():
    return list(map(list, sys.stdin.readline().split()))


def S():
    return sys.stdin.readline()[:-1]


def main():
    n, k = LI()
    a_s = LI()
    ts = [0 for i in range(n)]
    f_ts = [0 for i in range(n)]
    for i in range(n):
        for j in range(n):
            if a_s[j] < a_s[i]:
                ts[i] += 1
                if j > i:
                    f_ts[i] += 1
    sum_f = sum(f_ts)
    sum_ = sum(ts)
    if (k - 1) % 2 == 0:
        ans = (sum_f + int(sum_ * (k - 1) / 2)) % MOD
        print(int(ans) % MOD * k % MOD)
    else:
        ans = 2 * sum_f + sum_ * (k - 1) % MOD
        print(int(ans) % MOD * int(k / 2) % MOD)


if __name__ == "__main__":
    main()


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

struct Dice {
	int d[6], E, S, U;
	Dice(int a[]) {
		rep(i, 6)d[i] = a[i];
		E = 2; S = 1; U = 0;
	}
	void rotate(char C) {
		int a = E, b = S, c = U;
		switch (C) {
		case'E':E = U; U = 5 - a; break;
		case'N':U = S; S = 5 - c; break;
		case'S':S = U; U = 5 - b; break;
		case'W':U = E; E = 5 - c; break;
		case'R':S = E; E = 5 - b; break;
		case'L':E = S; S = 5 - a; break;
		}
	}
	int rotate(int a, int b) {
		rep(k, 2) {
			rep(i, 4) {
				rep(j, 4) {
					if (a == d[U] && b == d[S])return d[E];
					rotate('E');
				}
				rotate('S');
			}
			rotate('L');
		}
	}
	bool operator==(Dice b) {
		rep(k, 2) {
			rep(i, 4) {
				rep(j, 4) {
					if (b.d[b.U] == d[U] && b.d[b.S] == d[S] && b.d[b.E] == d[E] &&
						b.d[5 - b.U] == d[5 - U] && b.d[5 - b.S] == d[5 - S] && b.d[5 - b.E] == d[5 - E])
						return true;
					rotate('E');
				}
				rotate('S');
			}
			rotate('L');
		}
		return false;
	}
};
int main() {
	int a[6], b[6]; rep(i, 6)cin >> a[i]; rep(i, 6)cin >> b[i];
	Dice d(a), e(b);
	puts(d == e ? "Yes" : "No");
}

Measured memory_bytes: 3080
Q, H, S, D = map(int, input().split())   # 0.25, 0.5, 1.0, 2.0
N = int(input())

if N%2==0:
    kijun1 = min(Q*8, H*4, S*2, D)
    print(N//2 * kijun1)
else:
    kijun1 = min(Q*8, H*4, S*2, D)
    kijun2 = min(Q*4, H*2, S)
    print(N//2 * kijun1 + kijun2)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main() {
int A;
  int B;
  int C;
  cin >>A>>B>>C;
  if((A<=C) &&(C<=B))  {
    cout << "Yes" << endl;
  }
else {
 cout << "No" << endl;
}
}
  

Measured memory_bytes: 256
<?php
  $heights = array();
  for ($i=0; $i<10; $i++) {
    $heights[] = (int)fgets(STDIN);
  }
  rsort($heights);
  echo $heights[0] . PHP_EOL;
  echo $heights[1] . PHP_EOL;
  echo $heights[2] . PHP_EOL;

Measured memory_bytes: 6556
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        final int N = sc.nextInt();
        int H = sc.nextInt();
        int[] B = new int[N];
        int AM = 0;
        for(int i = 0;i < N;i++){
            int ai = sc.nextInt();
            int bi = sc.nextInt();
            AM = Math.max(AM, ai);
            B[i] = bi;
        }
        Arrays.sort(B);
        long ans = 0;
        for(int i = N-1;i >= 0;i--){
            if(B[i] > AM){
                H -= B[i];
                ans++;
                if(H <= 0)  break;
            }
            if(B[i] <= AM || i == 0){
                ans += H/AM;
                if(H%AM != 0)   ans++;
                break;
            }
        }
        System.out.println(ans);
    }
}

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

using namespace std;

#define int long long

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

typedef pair<int, int> PII;

//--------

int B[30];

signed main(){  
    int N, M , C;
    cin >> N >> M >> C;

    REP(i, M){
        cin >> B[i];
    }

    int cou = 0;
    REP(o, N){
        int sum = 0;
        REP(i, M){
            int a;
            cin >> a;
            sum += a * B[i];
        }
        if(sum > (- C)){
            cou++;
        }
    }

    cout << cou << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
signed  main(){
  char b;
  cin>>b;
  if(b=='A'){
    cout<<'T'<<"\n";
  }if(b=='G'){
    cout<<'C'<<"\n";
  }if(b=='T'){
    cout<<'A'<<"\n";
  }if(b=='C'){
    cout<<'G'<<"\n";
  }
}


Measured memory_bytes: 256
class Node():
    def __init__(self, value, parent=None):
        self.value = value
        self.parent = parent
        self.left = None
        self.right = None

class BinaryTree():
    def __init__(self):
        self.root = None
    
    def insert(self, value):
        if self.root == None:
            self.root = Node(value)
        else:
            parentnode = curnode = self.root
            while curnode != None:
                parentnode = curnode
                if curnode.value > value:
                    curnode = curnode.left
                else:
                    curnode = curnode.right
            if value > parentnode.value:
                parentnode.right = Node(value)
            else:
                parentnode.left = Node(value)

    def preorder(self, root):
        if root == None:
            pass
        else:
            print(' %d' % root.value, end='')
            self.preorder(root.left)
            self.preorder(root.right)

    def inorder(self, root):
        if root == None:
            pass
        else:
            self.inorder(root.left)
            print(' %d' % root.value, end='')
            self.inorder(root.right)

if __name__ == '__main__':
    n = int(input())
    binarytree = BinaryTree()
    for _ in range(n):
        common = input()
        if common[0] == 'i':
            binarytree.insert(int(common[7:]))
        else:
            binarytree.inorder(binarytree.root)
            print()
            binarytree.preorder(binarytree.root)
            print()


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

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

    long long sum = 0;
    for (int i = 1; i <= n; i++) {
        if (i % 3 != 0 && i % 5 != 0) sum += i;
    }

    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 3644
#define f(I,H)(p[I]+h[I]*(h[I]-2*H))
long C,h[2<<17],p[2<<17],X,a;
P[2<<17];
s,t=-1,i,x,y;
main(){
	for(scanf("%*d%ld",&C);~scanf("%ld",&a);){
		for(;X=f(P[s],a),s<t&&X>=f(P[s+1],a);s++);
		h[i]=a;
		X=p[i]=i?a*a+C+X:0;
		for(;s<t&&(h[y=P[t]]-h[x=P[t-1]])*(f(y,0)-f(i,0))>=(a-h[y])*(f(x,0)-f(y,0));t--);
		P[++t]=i++;
	}
	printf("%ld",X);
}

Measured memory_bytes: 4608
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i,n) for(int i=0;i<(n);++i)
#define ll long long
const long long INF = 1LL<<60;
const long long mod = 1e9 + 7;
using Graph = vector<vector<int>>;

int main(){
    int M,N;
    cin >> N >> M;
    int s[M],c[M];
    REP(i,M) cin >> s[i] >> c[i];
    REP(i,M) s[i]--;
    int used[N];
    REP(i,N) used[i] = -1;
    bool can = true;
    if(N==1&&M==0) cout << 0 << endl;
    else if(N==1){
        REP(i,M){
            if(used[s[i]]!= -1&& used[s[i]]!=c[i]) can = false;
            else used[s[i]] = c[i];
        }
        if(!can) cout << -1 << endl;
        else cout << used[0] << endl;
    }
    else{
    REP(i,M){
        if(s[i]==0&&c[i]==0) can = false;
        if(used[s[i]] != -1 && used[s[i]]!=c[i]) can = false;
        else used[s[i]] = c[i];
    }
    if(used[0]==-1) used[0] = 1;
    if(!can) cout << -1 << endl;
    else{
        int ans = 0;
        REP(i,N){
            int d = N-i;
            d--;
            if(used[i] == -1) continue;
            else{
                ans += used[i] * pow(10,d);
            }
        }
        cout << ans << endl;
    }
    }
}

Measured memory_bytes: 3732
#include <stdio.h>

#define STRMAX 11

int main(void)
{
  int i;

  int index;
  char c;
  char output[STRMAX];

  for (i = 0; i < STRMAX; i++)output[i] = '\0';

  index = 0;
  while (1) {
    scanf("%c", &c);
    if (c == '0' || c == '1') {
      output[index] = c;
      index++;
    } else if(c=='B'){
      if (index > 0) {
        index--;
        output[index] = '\0';
      }
    } else {
      break;
    }
  }
  printf("%s\n", output);
  return(0);
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
using namespace std;
int n;
int a[100],b[100],c,d;
int m[200],used[200];
vector<int>G[200];
bool dfs(int v)
{
	used[v]=1;
	for(int i=0;i<G[v].size();i++)
	{
		int u=G[v][i];
		int w=m[u];
		if(w<0||!used[w]&&dfs(w))
		{
			m[v]=u,m[u]=v;
			return 1;
		}
	}
	return 0;
}
main()
{
	cin>>n;
	for(int i=0;i<n;i++)cin>>a[i]>>b[i];
	for(int i=0;i<n;i++)
	{
		cin>>c>>d;
		for(int j=0;j<n;j++)
		{
			if(a[j]<c&&b[j]<d)G[j+n].push_back(i),G[i].push_back(j+n);
		}
	}
	int ans=0;
	for(int i=0;i<2*n;i++)m[i]=-1;
	for(int v=0;v<2*n;v++)
	{
		if(m[v]<0)
		{
			for(int j=0;j<2*n;j++)used[j]=0;
			if(dfs(v))ans++;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
import numpy as np

def ii():
    return int(input())


def lii():
    return list(map(int, input().split(' ')))


def lvi(N):
    l = []
    for _ in range(N):
        l.append(ii())
    return l


def lv(N):
    l = []
    for _ in range(N):
        l.append(input())
    return l


A, B, C, K = lii()
if K % 2:
    print(B-A)
else:
    print(A-B)

Measured memory_bytes: 20692
def solve(string):
    n, m, *xyz = map(int, string.split())
    t = [-1] * (n + 1)

    def union(r1, r2):
        if r1 != r2:
            t[max(r1, r2)] = min(r1, r2)

    def find(x):
        if t[x] < 0:
            return x
        t[x] = find(t[x])
        return t[x]

    for x, y, _ in zip(*[iter(xyz)] * 3):
        union(find(x), find(y))
    return str(t.count(-1) - 1)


if __name__ == '__main__':
    n, m = map(int, input().split())
    print(solve('{} {}\n'.format(n, m) + '\n'.join([input() for _ in range(m)])))


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



int main() {
int A, B, K;
cin >> A >> B >> K;
set<int> num;
int count = 0;
for(int i = A; i < A+K; i++){
    if(i <= B){
num.insert(i);
count++;
    }
}

for(int i = B-K+1; i <= B; i++){
if(i >= A){
    num.insert(i);
    count++;
}
}


for (const auto& e : num) {
cout << e << endl;
}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 999999999999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(25) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 1000000007
#define MAX 510000
#define ALL(a)  a.begin(),a.end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli A,B,C,D,E,F,N,M,K,L,X,Y,Z,H,W,sum=0,num=0,flag=0;string S,T;
  cin >> A >> B >> C;
  D=C-A-B;
  if(4*A*B<D*D&&D>0)Out("Yes");
  else Out("No");
}

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

int main(){
      int n;cin >> n;
      for(int i = 0;i <= n / 4;i++){
            for(int j = 0;j <= n / 7;j++){
                  if(4 * i + 7 * j == n)return cout << "Yes", 0;
            }
      }
      cout << "No";
}

Measured memory_bytes: 256