akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int main(void)
{
	int x, y, h, w, n;
	int i, j, l, cost, W, L;
	
	while (1){
		
		scanf("%d", &n);
		cost = 0;
		
		if (n == 0){
			break;
		}
		
		for (i = 0; i < n; i++){
			
			scanf("%d %d %d %d", &x, &y, &h, &w);
			l = x + y + h;
			W = 2;
			L = 60;
			
			for (j = 0; j < 6; j++){
				
				if (l <= L && w <= W){
					cost += 600 + 200 * j;
					break;
				}
				if (j == 0){
					W += 3;
				}
				else{
					W += 5;
				}
				L += 20;
			}
		}
		printf("%d\n", cost);
	}
	
	return (0);
}

Measured memory_bytes: 600
#include <stdio.h>
int main (){
  int n,count=1;
  scanf("%d",&n);
  while (1){
    if(n<4)break;
    count++;

    if(n%3==0){
      n=n/3;
    }else{
      n=n/3+1;
    }
  }
  printf("%d\n",count);

  return 0;
}

Measured memory_bytes: 596
N=int(input())
def dfs(n):
  if N<int(n):
    return 0
  if all(n.count(c)>0 for c in '753'):
    res=1
  else:
    res=0
  for c in '753':
    res+=dfs(n+c)
  return res
print(dfs('0'))

Measured memory_bytes: 3188
from itertools import*
from math import*
from collections import*
from heapq import*
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf = float("inf")
mod = 10**9+7
from functools import reduce
import sys
sys.setrecursionlimit(10**7)

class UnionFind():
    def __init__(self, N):
        self.rank = [0] * N
        self.par = [i for i in range(N)]
        self.counter = [1] * N

    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x != y:
            z = self.counter[x] + self.counter[y]
            self.counter[x], self.counter[y] = z, z
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    def size(self, x):
        x = self.find(x)
        return self.counter[x]

    def same(self, x, y):
        return self.find(x) == self.find(y)

N = int(input())
uf = UnionFind(N)
x_dict={}
y_dict={}

xy = []
for i in range(N):
    x,y = map(int,input().split())
    if x in x_dict:
        uf.unite(i,x_dict[x])
    else:
        x_dict[x]=i
    if y in y_dict:
        uf.unite(i,y_dict[y])
    else:
        y_dict[y]=i
    xy.append((x,y))
unite_dict={}
for i in range(N):
    ur = uf.find(i)
    unite_dict.setdefault(ur,[set(),set()])
    unite_dict[ur][0].add(xy[i][0])
    unite_dict[ur][1].add(xy[i][1])

p = 0
for k,v in unite_dict.items():
    p +=len(v[0])*len(v[1])
print(p-N)

Measured memory_bytes: 118688
H, W = map(int, input().split())
a=[]
for _ in range(H):
    a.append(input())

delete_y=[]
for y in range(H):
    count=0
    for x in range(W):
        if a[y][x]=='.':
            count+=1
    if count==W:
        delete_y.append(y)

delete_x=[]
for x in range(W):
    count=0
    for y in range(H):
        if a[y][x]=='.':
            count+=1
    if count==H:
        delete_x.append(x)
#print(delete_x, delete_y)

for y in range(H):
    if y not in delete_y:
        row=''
        for x in range(W):
            if x not in delete_x:
                row+=(a[y][x])
        print(row)


Measured memory_bytes: 3064
n=gets.to_i
s=gets
min=s[1..n].split("").count('E')
c=min
for i in 1..n do
  if s[i]=='E' then 
    c-=1
  end
  if s[i-1]=='W' then
    c+=1
  end
  if min>c then min=c end
end
puts min

Measured memory_bytes: 30724
#include <bits/stdc++.h>
#include<iostream> 
using namespace std; 
#define ll long long
int countP(int n, int k) 
{ 
    // Base cases 
    if (n == 0 || k == 0 || k > n) 
        return 0; 
    if (k == 1 || k == n) 
        return 1; 

    // S(n+1, k) = k*S(n, k) + S(n, k-1) 
    return k*countP(n-1, k) + countP(n-1, k-1); 
} 
void test(){
    ll n;
	cin>>n;
	ll ans=1LL<<62;
	for(ll i=1;i<=sqrt(n);i++){
		if(n%i==0){
			ans=min(ans,n/i+i-2);
		}
	}
	cout <<ans;
}
// Driver program 
int main() 
{ 
    test();
    return 0; 
} 

Measured memory_bytes: 384
fun main(args: Array<String>) {
  val N = readString()

  val O = Array(N.length + 1) { 0 }
  val P = Array(N.length + 1) { 0 }
  val Q = Array(N.length + 1) { 0 }
  for (i in N.indices) O[i + 1] = N[i].toString().toInt()
  var f = 0
  for (i in N.length downTo 0) {
    val n = O[i] + f
    if (n == 5) {
      if (O[i - 1] >= 5) {
        f = 1
        P[i] = 0
      } else {
        f = 0
        P[i] = n
      }
    } else if (n > 5) {
      f = 1
      P[i] = 0
    } else {
      f = 0
      P[i] = n
    }
  }
  var g = 0
  for (i in N.length downTo 0) {
    val p = P[i] + g
    val o = O[i]
    if (p >= o) {
      Q[i] = p - o
      g = 0
    } else {
      Q[i] = p - o + 10
      g = -1
    }
  }
//  println(P.joinToString(""))
//  println(O.joinToString(""))
//  println(Q.joinToString(""))
  println(P.sum() + Q.sum())
}

fun readString() = readLine()!!
fun readStrings() = readString().split(" ")
fun readInt() = readString().toInt()
fun readInts() = readStrings().map { it.toInt() }
fun readLong() = readString().toLong()
fun readLongs() = readStrings().map { it.toLong() }


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


int main(){
    int64_t N, K;
    cin >> N >> K;
    int64_t cnt = 0;
    for(int i=K; i<=N+1; i++){
        cnt += (N - i + 1) * i + 1;
        cnt %= (int64_t)pow(10, 9) + 7;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long int a,b,c,d,p,q,r,s;
  cin>>a>>b>>c>>d;
    p=a*c;
  q=a*d;
  r=b*c;
  s=b*d;
 long long int t=max(p,q);
 long long  int g=max(r,s);
  cout<<max(t,g);
    
}


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

#define int long long

#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint,int> P1;
typedef pair<int,pint> P2;
static const ll maxLL = (ll)1 << 62;
const ll MOD=1000000007,INF=1e18;
int dy[]={-1,0,1,0};
int dx[]={0,1,0,-1};

int n,x,a[100010],ans=0;

signed main() {
    cin>>n>>x;
    rep(i,0,n){
        cin>>a[i];
        if(x<a[i]){
            ans+=a[i]-x;
            a[i]=x;
        }
    }
    
    rep(i,0,n-1){
        if(a[i]+a[i+1]>x){
            int tabeta=(a[i]+a[i+1])-x;
            ans+=tabeta;
            a[i+1]-=tabeta;
        }
    }
    cout<<ans<<endl;
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    return 0;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
void Say(bool say, string a = "Yes", string b = "No"){cout << (say ? a : b) << endl;};

ll calc(ll R0, ll W0, ll C, ll R){
    for(ll x = 0; ; x++){
        if(R0 + x * R >= W0 * C)return x;
    }
}

int main(){
    for(ll R0, W0, C, R; cin >> R0 >> W0 >> C >> R, R0;){
        cout << calc(R0, W0, C, R) << endl;
    }
    return 0;
}


Measured memory_bytes: 3004
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 1010


int solve(){
vector<pair<int,string> > way[SIZE];
  int n, m, s, g;

  scanf("%d%d%d%d", &n, &m, &s, &g);
  if(n == 0) return false;
  
  for(int i=0;i<m;i++){
    int x, y;
    string lab;
    cin >> x >> y >> lab;
    way[x].push_back({y, lab});
  }

  string dp[40 * 6 * 2 + 10][41];

  int maxlen = n*6*2;
  
  for(int i=0;i<n*6*2;i++){
    for(int j=0;j<n;j++){
      if(!dp[i][j].size() && !(i==0 && j == s)) continue;
      
      for(int k=0;k<way[j].size();k++){
        int newlen = i + way[j][k].second.size();
        if(newlen > maxlen) continue;
        if(dp[newlen][way[j][k].first].size())
          dp[newlen][way[j][k].first] = min(dp[newlen][way[j][k].first], dp[i][j] + way[j][k].second);
        else
          dp[newlen][way[j][k].first] = dp[i][j] + way[j][k].second;
      }
    }
  }

  string ans = "";

  for(int i=1;i<=n*6;i++){
    if(dp[i][g].size() && (ans.size() == 0 || ans > dp[i][g])) ans = dp[i][g];
  }
  
  for(int i=n*6+1;i<=2*n*6;i++){
    if(dp[i][g].size() && ans > dp[i][g]) ans = "";
  }

  if(ans.size())
    cout << ans << endl;
  else
    cout << "NO" << endl;

  return true;
}

int main(){
  while(solve());
  
  return 0;
}



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

typedef long long ll;

#define rep(i, n) for (int i = 1; i <= (int)(n); i++)

int main() { 
    ll N, B, C, cnt=0;
    cin >> N;
    for(int A = 1; A <= N; ++A) {
        // cout << A << " : ";
        if (N % A == 0) {
            B = (N / A) - 1;
            // cout << B << endl;
            cnt += B;
        } else {
            B = N / A;
            // cout << B << endl;
            cnt += B;
        }
    }

    cout << cnt <<"\n";
    return 0;
}


Measured memory_bytes: 3600
def get_input():
    while True:
        try:
            yield ''.join(input())
        except EOFError:
            break

N = list(get_input())
maxi = 0
nums = [0 for i in range(101)]
for l in range(len(N)):
    k = int(N[l])
    nums[int(N[l])] += 1
    maxi = max(maxi, nums[k])

for i in range(101):
    if nums[i] == maxi:
        print(i)



Measured memory_bytes: 5600
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{

    ll N,A,B;
    cin>>N>>A>>B;
    string s;
    cin>>s;
    vector<string>v;
    ll sum=A+B;
    ll cnt=0;
    ll cntb=0;
    for(int i=0;i<s.size();i++)
    {
        if(s[i]=='c')
        {
            v.push_back("No");
        }
        else if(s[i]=='a' and cnt<sum)
        {
            v.push_back("Yes");
            cnt++;
        }
        else if(s[i]=='b' and cntb<B and cnt<sum)
        {
            v.push_back("Yes");
            cntb++;
            cnt++;
        }
        else
        {
            v.push_back("No");
        }
    }
    for(auto x:v)
    {
        cout<<x<<endl;
    }
}



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

int main(){
    int N;
    string S;
    cin >> N >> S;
    int max_count = 0;
    bool left = false;
    bool right = false;
    for (int i = 1; i < N; i++){
        int count = 0;
        for (char c = 'a'; c <= 'z'; c++){
            for (int j = 0; j < i; j++){
                if (S.at(j) == c){
                    left = true;
                }
            }
            for (int j = i; j < N; j++){
                if (S.at(j) == c){
                    right = true;
                }
            }
            if (left && right){
                count++;
            }
            left = false;
            right = false;
        }
        max_count = max(max_count,count);
    }
    cout << max_count << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,a, b) for(int i = a; i <= b; i++)
using namespace std;
typedef long long ll;

int main(){
    int n, cnt = 1;
    cin >> n;
    ll a[n];
    REP(i,n) cin >> a[i];
    int flag = 2;
    REP(k,n-1){
        if(flag == 2){
            if(a[k] < a[k+1]){
                flag = 1;
            }else if(a[k] > a[k+1]){
                flag = 0;
            }
        }else{
            if(a[k] < a[k+1]){
                if(flag == 0){
                    flag = 2;
                    cnt++;
                }
            }else if(a[k] > a[k+1]){
                if(flag == 1){
                    flag = 2;
                    cnt++;
                }
            }
        }
    }
    cout << cnt << endl;

}

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

//#define mod 1000000007

using namespace std;

int N, a[300000];
 
int main(void){
	
	//int N;
	
	int64_t count=0;
	
	cin >> N;
	
	//int a[N];
	
	for(int i=0; i<3*N; i++)
		cin >> a[i];
	
	sort(a, a+3*N, greater<int>());
	
	for(int i=1; i<N*2; i+=2)
		count += a[i];
	
	cout << count;
	
	return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define pb(a) push_back(a)
#define all(a) (a).begin(), (a).end()
#define debug(x) cout << "debug " << x << endl;
#define INF (1 << 31 - 1)
using namespace std;

typedef struct{
    string name;
    int time;
}s;

int main(){
    int n, t, h, m;
    string name;
    char g;
    map<string, int> sta;
    vector
 v;

    cin >> n >> t;
    rep(i,n * 2){
        cin >> h >> g >> m >> name;
        int time = h * 60 + m;
        if(sta[name] == 0) sta[name] = time;
        else{
            int a = time - sta[name];
            if(a >= t){
                s temp;
                temp.name = name;
                temp.time = a;
                v.pb(temp);
            }
        }
    }
    cout << v.size() << endl;
    rep(i,v.size()){
        if(v[i].time >= t){
            cout << v[i].name << ' ' << v[i].time << endl;
        }
    }
}

Measured memory_bytes: 1228
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <cfloat>

using std::cerr;
using std::cin;
using std::cout;
using std::endl;

int main(void){
  cout << std::fixed << std::setprecision(16);
  cin.tie(0);
  std::ios::sync_with_stdio(false);

  int64_t n,k;
  cin>>n>>k;
  std::vector<int64_t> a(n),f(n);
  int64_t sigma_a=0;
  for(int64_t i=0;i<n;i++){
    cin>>a[i];
    sigma_a+=a[i];
  }
  for(int64_t i=0;i<n;i++){
    cin>>f[i];
  }
  int64_t left=0;
  int64_t right=std::pow(10,12)+1;
  int64_t mid=(left+right)/2;
  int64_t need_distrib=sigma_a-k;
  std::sort(f.begin(), f.end());
  std::sort(a.begin(), a.end(), std::greater<>());
  int itr=0;
  if(need_distrib<=0){
    cout<<0<<endl;
    return 0;
  }
  while(right-left>1){
    int64_t distributed=0;
    for(int i=0;i<n;i++){
      distributed+=std::min(a[i],mid/f[i]);
    }
    if(distributed<need_distrib){
      left=mid;
    }else{
      right=mid;
    }
    mid=(right+left)/2;
  }
  cout<<right<<endl;







  return 0;
}


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

int main(){
    int n, k;
    cin >> n >> k;
    vector<int> h(n);
    for(int i = 0; i < n; i++){
        cin >> h[i];
    }
    int count = 0;
    for(int i = 0; i < n; i++){
        if(h[i] >= k) count += 1;
    }

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

Measured memory_bytes: 3596
import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
void main(string[] args){ if(args.length > 1) if(args[1] == "-debug") DEBUG = 1; solve(); }
void log()(){ writeln(""); } void log(T, A ...)(T t, lazy A a){ if(DEBUG) write(t, " "), log(a); } bool DEBUG = 0; 
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
// ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- //

void solve(){
	int n = read.to!int;
	
	long[] as, bs;
	foreach(i; 0 .. n) as ~= read.to!long;
	foreach(i; 0 .. n) bs ~= read.to!long;
	
	X[] xs;
	foreach(i; 0 .. n) xs ~= new X(i, as[i], bs[i]);
	
	foreach(i; 0 .. n - 1){
		xs[i].next = xs[i + 1];
		xs[i + 1].prev = xs[i];
	}
	xs[n - 1].next = xs[0];
	xs[0].prev = xs[n - 1];
	
	auto xh = new RedBlackTree!(X, "a.isLargerThan(b)", true);
	
	foreach(x; xs){
		if(x.b > x.a && x.prev.a + x.next.a > x.b - x.a){
			"-1".writeln;
			return;
		}
		if(x.b > x.a){
			xh.insert(x);
		}
	}
	log("xh:", xh[], "xs:", xs);
	
	long ans = 0;
	while(xh.length > 0){
		X x = xh.front;
		xh.removeFront;
		long bsum = x.prev.b + x.next.b;
		long bmax = max(x.prev.b, x.next.b);
		if(bsum > x.b - x.a){
			"-1".writeln;
			return;
		}
		if(x.a >= bmax){
			if((x.b - x.a) % bsum == 0){
				ans += (x.b - x.a) / bsum;
				x.b = x.a;
			}
			else{
				"-1".writeln;
				return;
			}
		}
		else{
			long k = (x.b - bmax + bsum - 1) / bsum;
			long b2 = x.b - k * bsum;
			if(b2 < x.a){
				"-1".writeln;
				return;
			}
			else{
				ans += k;
				x.b = b2;
				if(x.a < x.b) xh.insert(x);
			}
		}
		log("xh:", xh[], "xs:", xs, "ans:", ans);
		
	}
	
	ans.writeln;
	
	
	
	

}

class X{
	int id;
	long a;
	long b;
	X prev, next;
	this(int id, long a, long b){
		this.id = id;
		this.a = a;
		this.b = b;
	}
	bool isLargerThan(X y){
		if(this.b > y.b) return 1;
		if(this.b < y.b) return 0;
		return this.id > y.id;
	}
	override string toString(){
		return b.to!string ~ "(" ~ a.to!string ~ ")";
	}
}


Measured memory_bytes: 74472
#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;
using P = pair<int, int>; 
using ll = long long;

int main()
{

  int n;
  cin >> n;
  int ans = 0;
  for(int i = 1; i <= n; i++){
    if(i >= 1 && i <= 9) ans++;
    else if(i >= 100 && i <= 999) ans++;
    else if(i >= 10000 && i <= 99999) ans++;
    else if(i == 1000000) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3612
#include <stdio.h>
#include <string.h>
#include <ctype.h>

int main(){
    char word_W[10000];
    char text_T[10000];
    int i;
    int ans = 0;

    scanf("%s", word_W);
    for(i=0; word_W[i]!='\0'; i++)
        word_W[i] = tolower(word_W[i]);
    
    while(1){
        scanf("%s", text_T);
        if(!strcmp(text_T, "END_OF_TEXT")) break;
        for(i=0; text_T[i]!='\0'; i++)
            text_T[i] = tolower(text_T[i]);
        if(strcmp(text_T, word_W) == 0){
            ans++;
        }
    }
    printf("%d\n", ans);
}



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

typedef long long ll;

int main(){
    int N;
    cin>>N;
    
    vector<ll> T(N),A(N);
    
    for(int i=0;i<N;i++){
        cin>>T[i]>>A[i];
    }
    

    ll t=T[0],a=A[0];
    
    for(int i=0;i<N;i++){
        ll k;
        k=max((t+T[i]-1)/T[i],(a+A[i]-1)/A[i]);

        t=T[i]*k;
        a=A[i]*k;
    }
    
    ll sum=a+t;
    cout<<sum<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main () {
    int x, a, b;
    cin >> x >> a >> b;
    if (-a+b <= 0) {
        puts("delicious");
    }
    else if (-a+b <= x) {
        puts("safe");
    }
    else {
        puts("dangerous");
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define SORT(v) sort(v.begin(), v.end());
#define RSORT(v) sort(v.rbegin(), v.rend());
#define REVERSE(v) reverse(v.begin(), v.end());

template <typename T>
void printlnVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << endl;
  }
}

template <typename T>
void printVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << " ";
  }
  cout << endl;
}

int main()
{
  int N;
  cin >> N;
  for (long long n = 1; n <= 3500; n++)
  {
    for (long long w = 1; w <= 3500; w++)
    {
      long long a = 4 * n * w - (N * w) - (N * n);
      if (a < 1 || (n * w) % a != 0)
        continue;
      long long h = n * w / a;
      h *= N;
      cout << h << " " << n << " " << w << endl;
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 256
let rec power ( * ) e m n =
  if n <= 0 then e
  else power ( * ) (if n land 1 = 0 then e else m * e) (m * m) (n lsr 1)

let m = 998244353
let ( +^ ) x y = (x + y) mod m
let ( *^ ) x y = (x * y) mod m
let inv = Fun.flip (power ( *^ ) 1) (m - 2)

let () = Scanf.scanf "%d %d %d" @@ fun n m k ->
  let comb = Array.make n 1 in
  for i = 0 to n - 2 do
    comb.(i + 1) <- comb.(i) *^ (n - 1 - i) *^ inv (i + 1)
  done;
  Printf.printf "%d\n" @@
  List.fold_left ( +^ ) 0 @@
  List.init (k + 1) @@ fun k ->
    power ( *^ ) (m *^ comb.(k)) (m - 1) (n - 1 - k)





Measured memory_bytes: 16196
//written by libra9z
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <valarray>
#include <utility>
#include <numeric>
#include <memory>
#include <functional>
#include <stdexcept>
#include <typeinfo>
#include <limits>
#include <complex>
#include <locale>
#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;
#define Debug(x) cerr << #x << " = " << x << endl
#define Debug22(x,y) cerr<<#x<<" = "<<x<<" , "<<#y<<" = "<<y<<endl;
#define Debug2(x, y) cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n";
#define Debug3(x,y,z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = ("<<x<<", "<<y<<", "<<z<<")\n";
#define Debug_arr(v,n) for(int i=0;i<n;++i) cerr<<#v<<"["<<i<<"]"<<" = "<<v[i]<<endl;
#define SET(p,v) fill((__typeof(**p)*)p,(__typeof(**p)*)p+sizeof(p),v);
#define eprintf(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define prl cerr << "called: " << __LINE__ << endl
#define all(s) s.begin(),s.end()
int n,m;
vector <int> v[55];
bool u[55][55];
int cnt[55][55];
bool used[55];
void dfs(int f,int x)
{
	used[x]=true;
	cnt[f][x]++;
	for (auto y:v[x])
	{
		if (!used[y])
		{
			dfs(f,y);
		}
	}
	used[x]=false;
}
int main()
{
	scanf("%d%d",&n,&m);
	for (int i=0;i<m;++i)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		x--,y--;
		v[x].push_back(y);
		v[y].push_back(x);
		u[x][y]=u[y][x]=true;
	}
	for (int i=0;i<n;++i)
	{
		memset(used,0,sizeof(used));
		dfs(i,i);
	}
	int ans=0;
	for (int i=0;i<n;++i)
	{
		for (auto j:v[i])
		{
			if (cnt[i][j]==1)
			{
				ans++;
			}
		}
	}
	cout<<ans/2<<endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
p_list = list(map(int, input().split()))
count = 0
for i in range(len(p_list)-2):
	if (p_list[i]<p_list[i+1] and p_list[i+1]<p_list[i+2]) or (p_list[i]>p_list[i+1] and p_list[i+1]>p_list[i+2]):
		count += 1
print(count)

Measured memory_bytes: 3060
#include<stdio.h>
int main ()
{
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    if(a==7&&b==5&&c==5)
        printf("YES");
    else if(a==5&&b==5&&c==7)
        printf("YES");
    else if(a==5&&b==7&&c==5)
        printf("YES");
    else
        printf("NO");
}

Measured memory_bytes: 1680
#include<bits/stdc++.h>
using namespace std;
int main(){
	char character;
    cin>>character;
    if(character=='a'||character=='i'||character=='u'||character=='e'||character=='o'){
    	cout<<"vowel"<<endl;
    }
    else{
    	cout<<"consonant"<<endl;
    }
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(x) x.begin(),x.end()
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

int h1,m1,h2,m2,k;
ll solve(){
   ll ans=0;
   int s=h1*60+m1;
   int e=h2*60+m2;
   int l=e-k;
   ans= l-s;

   return ans<0?0:ans;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    cin>>h1>>m1>>h2>>m2>>k;
    cout<<solve()<<endl;
    return 0;
}

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

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = long long;
using P = std::tuple<int,int>;

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

int H, W;
string sky[110];
int ts[110][110];

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

    std::cin >> H >> W;

    for(int i=0;i<H;++i){
        std::cin >> sky[i];
    }

    for(int i=0;i<H;++i){
        for(int j=0;j<W;++j){
            if(sky[i][j] == 'c'){
                ts[i][j] = 0;
            }else if(j > 0 && ts[i][j-1] >= 0){
                ts[i][j] = ts[i][j-1] + 1;
            }else{
                ts[i][j] = -1;
            }

            std::cout << ts[i][j] << " \n"[j+1==W];
        }
    }
}



Measured memory_bytes: 3300
#include<stdio.h>
int main()
{
  int N,i=0;
  double T,sum=0;
  double x[10];
  char u[10][4];
  
  scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf("%lf %s",&x[i],u[i]);
  }
  
  for(i=0;i<N;i++){
    if(u[i][0] == 'J'){
      sum = sum + x[i];
    }else{
      T = x[i] * 380000;
      sum = sum + T;
    }
  }
  
  printf("%lf",sum);
  
  return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    int N,M; cin >> N >> M;
    if(N == M) return "Yes";
    else return "No";
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<string>() << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
  char s[3];
  for(int i=0;i<3;i++)
    scanf("%s",&s[i]);
  
  if(s[0]==s[1]&&s[1]==s[2])
    puts("No");
  else
    puts("Yes");
  
  return 0;
}

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

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

int main() {
    int K; cin >> K;
    if (K % 2 == 0 || K % 5 == 0) {
        cout << -1 << endl;
        return 0;
    }
    int remain = 0;
    int idx = 0;
    do {
        remain = (remain * 10 + 7) % K;
        idx++;
    } while(remain != 0);
    cout << idx << endl;
    return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;
typedef pair<int, int> pint;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m ; cin>>n>>m;
    int ans=0;
    vector<vector<int>> edge(n,vector<int>());
    for(int i=0; i<m; i++){
        int a,b; cin>>a>>b;
        a--; b--;
        edge[a].push_back(b);
        edge[b].push_back(a);
    }
    vector<int> path;
    for(int i=1; i<=n; i++ ) path.emplace_back(i);

    do{
        bool ok=true;
        if (path[0]!=1) ok=false;

        for(int i=0; i<n-1; i++){
            bool c=false;
            for(int j=0; j<edge[path[i]-1].size(); j++){
                if(edge[path[i]-1][j]==path[i+1]-1) c=true;
            }
            if(!c) ok=false; 
        }

        if(ok) ans++;
    }
    while(next_permutation(path.begin(),path.end()));
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3668
#include<bits/stdc++.h>
using namespace std;
int n,a[100005];
int main() {
	scanf("%d",&n);
	for (int i=1;i<=n;++i) scanf("%d",a+i);
	sort(a+1,a+n+1,greater<int>());
	int p=1;
	while (p<n&&a[p+1]>=p+1) ++p;
	int q=p;
	while (q<n&&a[q+1]==p) ++q;
	if ((q-p&1)||(a[p]-p&1)) puts("First");
	else puts("Second");
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <cstring>
#include <set>
#include <map>
#include <cstdio>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define F first
#define S second
int n,a,b;
vector<int>ans;
int main(void){
    cin>>n>>a>>b;
    if(n+1<a+b||((n+a-1)/a>b&&(n+b-1)/b>a)){
        cout<<-1<<endl;
        return 0;
    }
    if(a==1){
        for(int i=n;i>=1;i--)ans.push_back(i);
    }else if(b==1)for(int i=1;i<=n;i++)ans.push_back(i);
    else if((n+a-1)/a<=b){
        int o=1;
        for(int i=o+b-1;i>=o;i--)ans.push_back(i);
        o+=b;
        int s=(n-o+1);
        a--;
        b=s/a;
        for(int i=0;i<s%a;i++){
            for(int j=o+b;j>=o;j--)ans.push_back(j);
            o+=b+1;
        }
        for(int i=0;i<a-s%a;i++){
            for(int j=o+b-1;j>=o;j--)ans.push_back(j);
            o+=b;
        }
    }else{
        int o=n;
        for(int i=o-b+1;i<=o;i++)ans.push_back(i);
        o-=b;
        int s=(n-o+1);
        a--;
        b=s/a;
        for(int i=0;i<s%a;i++){
            for(int j=o-b;j<=o;j++)ans.push_back(j);
            o-=(b+1);
        }
        for(int i=0;i<a-s%a;i++){
            for(int j=o-b+1;j<=o;j++)ans.push_back(j);
            o-=b;
        }
    }
    for(int i=0;i<ans.size();i++){
        if(i!=0)cout<<' ';
        cout<<ans[i];
    }
    cout<<endl;
    return 0;
}


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

int a[52];
int main()
{
	long long n,k,sum;
    cin>>n>>k;
    for(int i=1;i<=n;i++)
        cin>>a[i];
    sort(a+1,a+1+n);
    for(int i=n;i>=n-k+1;i--)
        sum+=a[i];
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 256
// 方針
/*
 * 1.   まだ登録されていない経路のうち，最も距離が小さい経路をグラフから取り出す．
 * 2.   既に決定されたグラフ上で，その経路の距離をダイクストラ法で計算する
 * 3.   計算された距離を，1で取り出した経路の距離と比較
 * 4-a. 取り出した経路のほうが短ければ，短い経路をグラフに登録する
 * 4-b. グラフから得た経路のほうが短ければ，スキップ
 * 5.   1に戻る
 *
 * O(N*N) * O(N*N + NlogN) = O(N^2) * O(N^2) = O(N^4)
 * N=300=10^2 -> 10^8 ... TLE
 */

#include <iostream>
#include <vector>

#include <tuple>
#include <queue>
#include <algorithm>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ALL(a) (a).begin(), (a).end()

#define INF (1<<(sizeof(int)*8-2))

using namespace std;

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

    vector<vector<int>> A(N, vector<int>(N));
    vector<vector<int>> B(N, vector<int>(N));

    REP(i, N)
    {
        REP(j, N)
        {
            cin >> A[i][j];
            B[i][j] = A[i][j];
        }
    }

    REP(i, N)
    {
        REP(j, N)
        {
            REP(k, N)
            {
                auto distance = B[j][i] + B[i][k];

                B[j][k] = min(distance, B[j][k]);
            }
        }
    }

    unsigned long long sum = 0;
    REP(i, N)
    {
        REP(j, N)
        {
            if( B[i][j] < A[i][j])
            {
                cout << -1 << endl;
                return 0;
            }

            bool need = true;
            auto direct = B[i][j];

            REP(k, N)
            {
                if( k == i || k == j ) continue;

                auto via = B[i][k] + B[k][j];
                if( via == direct ) need = false;
            }

            if( need ) sum += direct;
        }
    }

    cout << sum / 2 << endl;

    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<string.h>
#include <algorithm>
using namespace std;

int main(){
    int n;
    cin >>n;
    if(0<=n&&n<2)cout << 1 <<endl;
    if(2<=n&&n<4)cout << 2 <<endl;
    if(4<=n&&n<8)cout << 4 <<endl;
    if(8<=n&&n<16)cout << 8 <<endl;
    if(16<=n&&n<32)cout << 16 <<endl;
    if(32<=n&&n<64)cout << 32 <<endl;
    if(64<=n&&n<101)cout << 64 <<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
#define int long
#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define pb push_back
#define fi first
#define se second
const int INF = 1e9;
using namespace std;

struct UnionFind{
   vector<int> par;
   UnionFind(int n):par(n,-1){}
   int find(int x){
       if(par[x]<0)return x;
       return par[x]=find(par[x]);
   }
   bool unite(int x,int y){
       x=find(x);
       y=find(y);
       if(x==y)return false;
        par[x]+=par[y];
        par[y]=x;
       return true;
   }

   bool same(int x,int y){
       return find(x)==find(y);
   }
   int size(int x){
       return -par[find(x)];
   }
};

signed main() {
    int N,M; cin >> N >> M;
    int A[N];
    rep(i,N) {cin >> A[i]; A[i]--;}
    UnionFind uf(N+1);
    rep(i,M){
        int a,b; cin >> a >> b;
        a--; b--;
        uf.unite(A[a],A[b]);
    }
    int ans=0;
    rep(i,N){
        if(uf.same(i,A[i])) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include<cstdio>
#include<algorithm>
#include<cstring>
#define rep(i, s, t) for(i = s; i <= t; ++i)
#define dep(i, s, t) for(i = s; i >= t; --i)

using namespace std;

typedef long long LL;
const int N = 1e5 + 10;
int m;
int a[N];

int main() {
	int i; LL l, r;
	scanf("%d", &m);
	rep(i, 1, m) scanf("%d", &a[i]);
	l = 2; r = 2;
	dep(i, m, 1) {
		r = r / a[i] * a[i] + a[i] - 1;
		l = ((l-1) / a[i] + 1) * a[i];
		if(l > r) {puts("-1"); return 0;}
//		printf("%d %d\n", l, r);
	} 
	printf("%lld %lld\n", l, r);
	return 0;
}

Measured memory_bytes: 512
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<functional>
using namespace std;
int main(void)
{
	int n,date[3],i;
	scanf("%d",&n);
	for(i=0;i<n;i++) {
		scanf("%d %d %d",&date[0],&date[1],&date[2]);
		sort(date,date+3);
		if(date[2]*date[2]==(date[0]*date[0])+(date[1]*date[1])) printf("YES\n");
		else printf("NO\n");
	}
	return 0;
}
		
	

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

using namespace std;

int main()
{
  int W, H, N;

  cin >> W >> H >> N;

  int a = 0, b = W, c = 0, d = H;
  while(N--) {
    int x, y, z;
    cin >> x >> y >> z;
    if(z == 1) a = max(a, x);
    else if(z == 2) b = min(b, x);
    else if(z == 3) c = max(c, y);
    else d = min(d, y);
  }
  cout << max(0, max(0, d - c) * (b - a)) << endl;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
req = [list(map(int, input().split())) for i in range(m)]
for i in range(10000):
	st = str(i)
	if len(st) != n:
		continue
	ok = True
	for s, c in req:
		if int(st[s-1]) != int(c):
			ok = False
	if ok:
		print(st)
		exit(0)

print(-1)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;
ll MOD=1000000007;
int main(){
  ll n,h;
  cin>>n>>h;
  vector<ll> a(n);
  vector<ll> b(n);
  rep(i,n) cin>>a[i]>>b[i];
  sort(all(a));
  sort(all(b));
  reverse(all(b));
  ll amax=a[n-1];
  ll count=0;
  rep(i,n){
    if(b[i]>amax&&h>0){
      h-=b[i];
      count++;
    }
  }
  if(h>0){
  cout<<count+(h+amax-1)/amax;
    return 0;
  }
else cout<<count;
return 0;
}

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

int main(){
	int n,i,max = 0, semimax = 0;

	cin >> n;

	int a[n];
	for(i = 0; i < n; i++){
		cin >> a[i];
		if(a[i] > max){
			max = a[i];
		}
		else if(a[i] > semimax){
				semimax = a[i];
		}
	}

	for(i = 0; i < n; i++){
		if(a[i] != max){
			cout << max <<"\n";
		}
		else if(a[i] == max){
			cout << semimax <<"\n";
		}
	}
	return 0;

}


Measured memory_bytes: 2432
//gauravsinghh
#pragma GCC optimize("O3", "unroll-loops")
#pragma GCC target("avx2")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long int
#define ld long double
#define db double
#define pii pair<int,int>
#define pll pair<long long,long long>
#define sii set<int>
#define sll set<long long>
#define vii vector<int> 
#define vll vector<long long>
#define mii map<int,int>
#define mll map<long long, long long>
#define lob lower_bound
#define upb upper_bound
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define pf push_front
#define ins insert
#define mp make_pair
#define w(t) cin >> t;while(t--)
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define os cout<<" "
#define bitcount __builtin_popcount
#define gcd __gcd
#define endl "\n"
#define present(s,x) (s.find(x) != s.end()) 
#define cpresent(s,x) (find(all(s),x) != s.end()) 
#define ford(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++) 
#define fors(container, it, a, b) for(__typeof(container.begin()) it = a; it != b; it++) 
#define EPSILON 1e-9
#define PI 3.14159265358979323846
#define inf 1000000000
#define lim 100005
#define fbo find_by_order
#define ook order_of_key
#define sz(s) (int)s.size()
#define mem(n,m) memset(n,m,sizeof(n))
#define deb(x) cout << #x << " " << x << endl;
#define rep(i,n) for(ll i = 0; i < n; i++)
#define ren(i,n) for(ll i = n-1; i >= 0; i--)
#define all(x) x.begin(),x.end()
#define fo(i, a, b) for(ll i = a; i <= b; i++)
#define ffo(i, a, b) for(ll i = a; i >= b; i--)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;
 
void io_set() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}
 
int main(){
    IOS
    //io_set();
   	ll a, b;
   	cin >> a >> b;
   	b*=2;
   	cout << max(0ll, a-b) << endl;
    return 0;
} 

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


int main(){
    int n;
    int ans=0;
    cin >> n;
    map<int,int>mp;
    rep(i,n){
        int x;
        cin >> x;
        mp[x]++;
    }
    for(auto &p:mp) ans++;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <bitset>
using namespace std;

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

    vector<int> A(N);

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

    long long int l = 0, r = 0, p = 0, answer = 0;

    while (r < N) {
        if ((p ^ A[r]) == p + A[r]) {
            p += A[r];
            r++;
            answer += r - l;
        } else if (l == r) {
            r++;
        } else {
            p -= A[l];
            l++;
        }
    }

    cout << answer << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
// #include <iostream>
// #include <vector>
// #include <map>
// #include <algorithm>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

template<typename T>
T mod(T a, T b){
    return (a + b) % b;
}

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

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

// n を素因数分解
map<ll, ll> factor(ll n){
    map<ll, ll> mp;
    for (ll i = 2; i*i <= n; i++) {
        while (n % i == 0) {
            mp[i]++;
            n /= i;
        }
    }

    if (n > 1) {
        mp[n]++;
    }

    return mp;
}

// 文字列に "hoge" が含まれているか
// string str = "hogepiyo";
// if (str.find("hoge") != string::npos) {
//     cout << "文字列が含まれています" << endl;
// }

// char to string
// char c = 'a';
// string str = {c};

void solve(){
    ll N, M;
    cin >> N >> M;

    vector<pair<ll,ll>> drink;
    for (int i = 0; i < N; i++) {
        ll A, B;
        cin >> A >> B;
        drink.push_back(make_pair(A,B));
    }
    sort(all(drink));

    ll honsu = 0;
    ll ans = 0;
    ll idx = 0;
    ll price = 0, shophonsu = 0;

    while (honsu < M) {
        price = drink[idx].first;
        shophonsu = drink[idx].second;
        if (shophonsu <= M - honsu) {
            ans += price * shophonsu;
            honsu += shophonsu;
            idx++;
        } else {
            ans += price * (M - honsu);
            honsu = M;
        }
    }

    cout << ans << endl;


    return;
}

int main(int argc, char const* argv[])
{
    solve();
    return 0;
}


Measured memory_bytes: 2420
N=int(input())
a=[]
for i in range(N):
  a.append(int(input())-1)
flg=False
s=0
ans=0
for i in range(N):
  ans+=1
  if a[s]==1:
    flg=True
    break
  s=a[s]
if flg: print(ans)
else: print(-1)

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

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

    char n;
    for(int i=0;i<3;i++) {
        cin >> n;
        if(n=='7') {
            cout << "Yes\n";
            return 0;
        }
    }
    cout << "No\n";

    return 0;
}

Measured memory_bytes: 3612
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>

using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()
// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return;std::cout << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class X> void DEBUG(X d, T e){if(DEBUG_OUT == false)return;std::cout <<d<<" ";DEBUG(e);};
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }



void solve(void)
{
  int N;
  cin>>N;
  vector<int> vec(N);
  for (int i = 0; i < N; i++)
  {
    cin>>vec[i];
  }
  int ANS = 0;
  for (int i = 0; i < N; i++)
  {
    if(i+1 == vec[i])
    {
      if(i+2 == vec[i+1])
      {
        i++;
      }
      else
      {
        //NOP;
      }
      ANS++;
      
    }
  }
  cout<<ANS<<endl;
  
  
  return;
}


int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();
  

 
  return 0;
}


Measured memory_bytes: 1024
#pragma region _head

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<iomanip>
#include<queue>
#include<stack>
#include<numeric>
#include<utility>
#include<regex>

#pragma region _define

#define int LL
#define f(i,a,b) for(LL i=a;i<b;i++)
#define f_vI(v,n) f(i,0,n)cin>>v[i]
#define f_v2I(v1,v2,n) f(i,0,n)cin>>v1[i]>>v2[i]
#define f_v3I(v1,v2,v3,n) f(i,0,n)cin>>v1[i]>>v2[i]>>v3[i]
#define f_vO(v,n) f(i,0,n)cout<<v[i]<<endl
#define ei else if
#define all(a) a.begin(),a.end()
#define size(s) ((LL)s.size())
#define F first
#define S second
#define check() cout<<"! ! !"
#define endl "\n"
#define _y() cout<<"Yes"<<endl
#define _Y() cout<<"YES"<<endl
#define _n() cout<<"No"<<endl
#define _N() cout<<"NO"<<endl
#define INF 1<<29
#define MOD 1000000007

#pragma endregion

#pragma region _using

using namespace std;

using LL = long long;
using st = string;
using vi = vector<LL>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vc = vector<char>;
using vs = vector<st>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvvb = vector<vvb>;
using qi = queue<LL>;
using qc = queue<char>;
using qs = queue<st>;
using si = stack<LL>;
using sc = stack<char>;
using ss = stack<st>;
using pi = pair<LL, LL>;
using vpi = vector<pi>;

#pragma endregion

#pragma region _graph

#define node 50  //グラフの最大位数　適宜変更
//bool graph[node][node]; bool visited[node] = { false };
#define link(a,b,m) f(i,0,m){cin>>a[i]>>b[i]; a[i]--; b[i]--; graph[a[i]][b[i]]=graph[b[i]][a[i]]=true;}

#pragma endregion

LL gcd(LL a, LL b) {
	LL r;
	while ((r = a % b) != 0) {
		a = b;
		b = r;
	}
	return b;
}
LL lcm(LL a, LL b) {
	return (a / gcd(a, b) * b);
}

//素数判定
bool is_prime(int n) {
	for (int i = 2; i*i <= n; i++) {
		if (n % i == 0) {
			return false;
		}
	}
	return true;
}

//階乗計算
LL factorial(LL n) {
	LL a = 1, ret = 1;
	while (a < n) {
		a++;
		ret *= a;
		ret %= MOD;
	}
	return ret;
}

#pragma endregion 



/*****************************************************************************/

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

	int n, m;
	cin >> n >> m;
	vi a(m), b(m);
	f_v2I(a, b, m);
	vb fa(n,false), fb(n,false);
	f(i, 0, m) {
		if (a[i] == 1) {
			fa[b[i]] = true;
		}
		if (b[i] == n) {
			fb[a[i]] = true;
		}
	}
	f(i, 0, n) {
		if (fa[i] && fb[i]) {
			cout << "POSSIBLE";
			return 0;
		}
	}
	cout << "IMPOSSIBLE";
	return 0;
}

Measured memory_bytes: 3456