akhauriyash/Code-Regression huggingface dataset:
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using namespace std;
using uint = unsigned int;
using ll = long long;
const int M = 1e9 + 7;
const ll MLL = 1e18L + 9;
#pragma unused(M)
#pragma unused(MLL)
#ifdef LOCAL
#include"rprint.hpp"
#else
template <ostream& out = cout, class... T> void prints(T&&...){ }
template <ostream& out = cout, class... T> void printd(T&&...){ }
template <ostream& out = cout, class... T> void printde(T&&...){ }
template <ostream& out = cout, class... T> void printb(T&&...){ }
template <ostream& out = cout, class... T> void printArr(T&&...){ }
#endif

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    cout << (n % 10 == 9 || n / 10 == 9 ? "Yes" : "No") << '\n';
    return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n,k;
  cin >> n >> k;
  long long sum = 0;
  for(long long i = k; i <= n; i++) {
    sum += i*(n-i+1LL) + 1LL;
  }
  sum += 1LL;
  cout << sum%1000000007LL << endl;
}


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

int main(int argc, char *argv[])
{
    int n;
    cin >> n;

    map<int, int> counts;
    for(int i = 0; i < n; ++i)
    {
        int x;
        cin >> x;
        counts[x] += 1;
    }

    long long l1 = -1;
    long long l2 = -1;
    bool done = false;
    for(auto it = counts.rbegin(); !done && it != counts.rend(); ++it)
    {
        int len = it->first;
        int& amount = it->second;
        while(amount >= 2)
        {
            amount -= 2;
            if(l1 == -1) l1 = len;
            else if(l2 == -1) l2 = len;
            else
            {
                done = true;
                break;
            }
        }
    }

    if(l1 == -1 && l2 == -1)
    {
        cout << 0 << endl;
    }
    else
    {
        cout << l1 * l2 << endl;
    }
}


Measured memory_bytes: 4992
import math
import sys,collections
from sys import stdin, stdout  
#MAXN = 10000001

def get_ints(): return map(int, sys.stdin.readline().strip().split())
def get_array(): return list(map(int, sys.stdin.readline().strip().split()))
def get_string(): return sys.stdin.readline().strip() 
def input(): return sys.stdin.readline().strip()
#spf = [0 for i in range(MAXN)] 
def file():
	sys.stdin = open('input.py', 'r')
	sys.stdout = open('output.py', 'w') 
def is_subsequence(x, y):
    """Test whether x is a subsequence of y"""
    x = list(x)
    for letter in y:
        if x and x[0] == letter:
            x.pop(0)

    return not x    
def sieve(): 
	spf[1] = 1
	for i in range(2, MAXN): 
		spf[i] = i 
	for i in range(4, MAXN, 2): 
		spf[i] = 2

	for i in range(3, mt.ceil(mt.sqrt(MAXN))): 
		if (spf[i] == i): 
			for j in range(i * i, MAXN, i): 
				if (spf[j] == j): 
					spf[j] = i 
def getFactorization(x): 
	ret = list() 
	while (x != 1): 
		ret.append(spf[x]) 
		x = x // spf[x] 

	return ret 
def getFloor(A, x):

    (left, right) = (0, len(A) - 1)

    ind,floor = -1,-1
    while left <= right:
        mid = (left + right) // 2
        '''if A[mid] == x:
            return mid'''
        if x < A[mid]:
            right = mid - 1
        else:
            floor = A[mid]
            ind=mid
            left = mid + 1
            
    return ind
def check(st) : 
  
    # Compute sum of digits 
    n = len(st) 
    digitSum = 0
      
    for i in range(0,n) : 
        digitSum = digitSum + (int)(st[i]) 
  
    # Check if sum of digits 
    # is divisible by 9. 
    return (digitSum % 9 == 0)     
def isPowerOfTwo(n): 
    if (n == 0): 
        return False
    while (n != 1): 
            if (n % 2 != 0): 
                return False
            n = n // 2
            
              
    return True
def kitte(n):
	c=0
	while(n!=0):
		n=n//2
		c+=1
	return c	
def aa(b,c):
	m=min(b,c)
	b-=m
	c-=m
	if(c>0 and b>0):
		return(m+((b+c)//3))
	else:
		return(m)
def bb(a,c):
	m=min(a,c)
	a-=m
	c-=m
	if(c>0 and a>0):
		return(m+((a+c)//3))
	else:
		return(m)
def cc(b,a):
	m=min(b,a)
	b-=m
	a-=m
	if(a>0 and b>0):
		return(m+((b+a)//3))
	else:
		return(m)		
#file()
#sieve() 
mod=(10**9)+7	
def main():
	s=input()
	t=input()
	m=float('inf')
	ans=[]
	for i in range(len(s)-len(t)+1):
		c=0
		ind=i
		for j in range(len(t)):
			#print(s[ind],t[j])
			if(s[ind]==t[j]):
				c+=1
			ind+=1	
		#print(c)
		ans.append(c)
	print(len(t)-max(ans))	


	



	

	
			


		




		






		







			



	

	




	





















	




















		
			


		

			

		





			

	























				

	















	

	










if __name__ == '__main__':
    main()

Measured memory_bytes: 9440
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG_ 
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
const ll INF = 1LL<<60;

int main(void) {
    ll n;
    cin >> n;
    vector<vector<ll>> x(n), y(n);
    REP(i, n) {
        ll a;
        cin >> a;
        x[i].resize(a);
        y[i].resize(a);
        REP(j, a) cin >> x[i][j] >> y[i][j], x[i][j]--;
    }

    ll ret = 0;
    REP(i, 1LL<<n) {
        bool ok = true;
        REP(j, n) if(i&1LL<<j) {
            bool flag = true;
            REP(k, x[j].size()) {
                if(y[j][k] == 0 && (i&1LL<<x[j][k])) flag = false;
                if(y[j][k] == 1 && !(i&1LL<<x[j][k])) flag = false;
            } 
            if(!flag) ok = false;
        }
        if(ok) chmax(ret, (ll)__builtin_popcountll(i));
    }
    
    cout << ret << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000000
ll gcd(ll a,ll b)
{
    if(b==0) return a;
    else return gcd(b,a%b);
}
int main()
{
     ll a,b;
     cin>>a>>b;
     ll gc=gcd(a,b);
     ll ans=(a*b)/gc;
     cout<<ans;
 return 0;
}


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

using Int = int;
using namespace std;

#define ARC(i, a, b) for(Int i = (a); i < (b); ++i)
#define RC(i, n) ARC(i, 0, n)
#define ARCH(i, a, b) for(Int i = (a) - 1; i >= (b); --i)
#define RCH(i, n) ARCH(i, n, 0)
template<class T> T ant(const T &a, const T &b){ return a > b ? a : b; };
template<class T> T ont(const T &a, const T &b){ return a < b ? a : b; };
template<class T> T th(T &a, const T &b, T (*f)(const T &, const T &)){ a = f(a, b); }
#define anth(a, b) th(a, b, ant)
#define onth(a, b) th(a, b, ont)

int main(){
	int n, r;
	cin >> n >> r;
	if(n >= 10){
		cout << r << endl;
	}else{
		cout << r + 100 * (10 - n) << endl;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define FOR(i,j,n,m) for(int i=j;i<n;i+=m)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define pob pop_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.F<<","<<_p.S<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}

template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

const ll MAXn=1e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=(ll)1e18;

vector<ll> v;
ll dp[MAXn];
int main(){
  IOS();
  ll n;
  cin>>n;
  REP(i,n+1) dp[i] = INF;
  v.pb(1);
  for(int i=1;;i++){
    ll a = (ll)pow(6,i),b = (ll)pow(9,i);
    if(a>n) break;
    if(a<=n) v.pb(a);
    if(b<=n) v.pb(b);
  }
  sort(ALL(v));
  REP(i,6) dp[i] = i;
  for(int i=6;i<=n;i++)REP(j,SZ(v)){
    if(i-v[j]<0) break;
    dp[i] = min(dp[i-v[j]] + 1,dp[i]);
  }
  cout<<dp[n]<<endl;
}


Measured memory_bytes: 1024
<?php
  fscanf(STDIN, "%d %d", $k,$x);
$val = array(); 
$val2 = array();
$sum = $k+$x-1;
$diff =$x-$k+1;
if(sum<= 1000000){
for($i = $diff;$i <= $sum; $i++){
$val[] = $i;
}
}elseif($sum >-1000000){
  for($i = $diff;$i <= 1000000; $i++){
$val[] = $i;
}
}elseif($diff <=-1000000){
  for($i = -1000000; $i <= $sum; $i++){
$val[] = $i;
}
}
$val2 = array_unique($val);

foreach($val2 as $value){
echo $value . " ";
   if($value !== end($val2)){
        echo "";
    }
}

?>

Measured memory_bytes: 3828
#include <iostream>

using namespace std;

int main(){
    int w, h, n;
    int x1, x2, y1, y2;
    int tmp[3];

    cin >> w >> h >> n;
    x1 = 0; x2 = w; y1 = 0; y2 = h;
    
    for(int i = 0; i < n; i++){
        cin >> tmp[0] >> tmp[1] >> tmp[2];
        switch(tmp[2]){
            case 1:
            if(x1 < tmp[0]) x1 = tmp[0];
            break;
            
            case 2:
            if(x2 > tmp[0]) x2 = tmp[0];
            break;

            case 3:
            if(y1 < tmp[1]) y1 = tmp[1];
            break;

            case 4:
            if(y2 > tmp[1]) y2 = tmp[1];
        }
    }

    int area = 0;
    if((x2 - x1) > 0 and (y2 - y1) > 0)
        area = (x2 - x1) * (y2 - y1);

    cout << area << endl;


    return 0;
}



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

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> VI;
typedef vector<VI> VVI;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = numeric_limits<int>::max() / 2;
const int NEG_INF = numeric_limits<int>::min() / 2;
const int MOD = 1e9 + 7;

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

	ll m, n; cin >> n >> m;
	vector<int> path[200000];
	for (int i = 0; i < m; i++) {
		int a, b; cin >> a >> b;
		a--; b--;
		path[a].push_back(b);
		path[b].push_back(a);
	}
	vector<int> dis(n, INF);
	queue<int> q;
	q.push(0);
	dis[0] = 0;
	while (!q.empty()) {
		int p = q.front(); q.pop();
		for (int i = 0; i < path[p].size(); i++) {
			int next = path[p][i];
			if (dis[next] != INF) continue;
			dis[next] = dis[p] + 1;
			q.push(next);
		}
	}
	if (dis[n - 1] <= 2) cout << "POSSIBLE" << endl;
	else cout << "IMPOSSIBLE" << endl;
}


Measured memory_bytes: 13296
#include<stdio.h>
#include<string.h>

int start_a=0, start_b=0, start_c=0, end_a, end_b, end_c, turn;
char sa[101]={0,}, sb[101]={0,}, sc[101]={0,};

int f(int k)
{
	char nextTurn;
	if(k==1){
		nextTurn = sa[start_a];
		start_a++;
		
	} 
	else if(k==2){
		nextTurn = sb[start_b];
		start_b++;		
	}
	else if(k==3){
		nextTurn = sc[start_c];
		start_c++;		
	}
	
	return nextTurn - 'a' + 1;
}

main()
{

	scanf("%s%s%s",&sa,&sb,&sc);
	
	end_a = strlen(sa);
	end_b = strlen(sb);
	end_c = strlen(sc);
	
	turn = 1;
	
	while(1)
	{
		if(start_a==end_a && turn==1){
			printf("A");
			break;
		}
		if(start_b==end_b && turn==2){
			printf("B");
			break;
		}
		if(start_c==end_c && turn==3){
			printf("C");
			break;
		}
		
		turn = f(turn) ;
	}
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std ;

void print_2d_vector(vector<vector <long long int> > &a){
    for (int i=0 ; i<a.size() ; i++){
        for (int j=0 ; j<a[0].size() ; j++)
            cout << a[i][j] << " " ;
        cout << "\n" ;
    }
}

int main(){
    int N, W ;
    cin >> N >> W ;
    int w[N], v[N] ;
    
    for (int i=0 ; i<N ; i++)
        cin >> w[i] >> v[i] ;
    
    vector< vector<long long int> > a(W+1, vector<long long int> (N+1, 0) ) ;
    
    for (int wt=1 ; wt<=W ; wt++){
        for (int i=1 ; i<=N ; i++){
            if (w[i-1] <= wt)
                a[wt][i] = max(a[wt-w[i-1]][i-1] + v[i-1], a[wt][i-1]) ;
            else
                a[wt][i] = a[wt][i-1] ;
        }
    }
    
    // print_2d_vector(a) ;
    
    cout << a[W][N] << "\n" ;
    
    return 0 ;
}


Measured memory_bytes: 84928
#include<bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int inf=1e9+7;
int main(){
    int n,h;cin>>n>>h;
    priority_queue<pii>pq;
    rep(i,n){
        int a,b;cin>>a>>b;
        pq.push(make_pair(a,0));
        pq.push(make_pair(b,1));
    }
    ll count=0;
    while(h>0){
        if(pq.top().second){
            h-=pq.top().first;
            pq.pop();
            count++;
        }
        else{
            count+=((h-1)/pq.top().first+1);
            h=0;
        }
    }
    cout<<count<<endl;
}

Measured memory_bytes: 2420
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define int long long
#define ll long long
//#define int  unsigned long long
#define pb push_back
#define double long double

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int N = 350000;
const int K = 19;
int n, q;
int mod =  1e9 + 7;
int s1[N], s2[N], a[N], ans[N], f[N], invf[N];
string t[N], d[N], s;
int binpow(int x, int y){
    if (y == 0) return 1;
    if (y % 2) return x * binpow(x, y - 1) % mod;
    int z = binpow(x, y / 2);
    return z * z % mod;
}
int c(int n, int k){
    if (k < 0) return 0;
    return f[n] * invf[k] % mod * invf[n - k] % mod;
}
int check (int x){
    for (int i = 1; i <= q; i++){
        if (s[x - 1] == t[i][0]){
            if (d[i] == "L"){
                if (x == 1) return -1;
                x--;
            } else{
                if (x == n) return 1;
                x++;
            }
        }
    }
    return 0;
}
main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt", "r", stdin);
    for (int i = 1; i <= 3; i++){
        int x, y;
        cin >> x >> y;
        a[x]++;
        a[y]++;
    }
    int x, y;
    x = y = 0;
    for (int i = 1; i <= 4; i++) if (a[i] == 1) x++; else if (a[i] == 2) y++;
    if (x == 2 && y == 2) cout << "YES"; else cout << "NO";
}


Measured memory_bytes: 8448
def num2alpha(num):
    if num<=26:
        return chr(64+num)
    elif num%26==0:
        return num2alpha(num//26-1)+chr(90)
    else:
        return num2alpha(num//26)+chr(64+num%26)

n = int(input())
u = num2alpha(n)
print(u.lower())

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

int main(){
  int N,M;
  cin >> N >> M;
  vector<int> L(M);
  vector<int> R(M);
  rep(i,M)
    cin >> L.at(i) >> R.at(i);
  sort(L.begin(),L.end());
  sort(R.begin(),R.end());
  if(L.at(M-1)>R.at(0))
    cout << "0" << endl;
  else
    cout << R.at(0)-L.at(M-1)+1 << endl;
  
}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i = 0; i < n; i++){
    cin >> a.at(i);
  }
  vector<int> li(100001, 0);
  long long out = 1;
  li.at(0) = 3;
  for(int i = 0; i < n; i++){
    out = (out * (li.at(a.at(i)) - li.at(a.at(i) + 1))) %1000000007; 
    li.at(a.at(i) + 1)++;
  }
  cout << out;
}

Measured memory_bytes: 1024
m, n = map(int, input().split())
A = [tuple(map(int, input().split())) for _ in range(m)]
b = [int(input()) for _ in range(n)]

result = []
for row in range(m):
    v = 0
    for col in range(n):
        v += (A[row][col] * b[col])
    result.append(v)

print('\n'.join(list(map(str,result))))


Measured memory_bytes: 5984
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>

#define _CRT_SECURE_NO_WARNINGS
#define TLong long long 

// fact(n)
int fact(int n){
	if(n == 1)	return 1;
	else return (n * fact(n - 1));
}

// combination(n,r)
int combination(int n, int r){
	if(r == 0 || r == n)	return 1;
	else if(r == 1)	return n;
	return (combination(n - 1, r - 1) + combination(n - 1, r));
}

// gcd(a,b)
int gcd(int a,int b){
	int ret;
	ret = (b == 0) ? a : gcd(b, a % b);
	return ret;
}

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

// qsort(array, size, sizeof(int),comp);
int comp(const int *a,const int *b){
	return (*a - *b);
}

// append(array,*size,addNum)
void append(int *array,int *size,int num){
	realloc(array, sizeof(int) * (*size + 1));
	array[(*size)] = num;
	++(*size);
}

// pop(array,*size) & nongetpop(array,*size)
int pop(int *array,int *size){
	int temp = array[(*size - 1)];
	realloc(array,sizeof(int) * (*size - 1));
	--(*size);
	return temp;
}

void nongetpop(int *array,int *size){
	realloc(array,sizeof(int) * (*size - 1));
	--(*size);
}

int main(int argc, char const *argv[])
{
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	if(a + b >= c)	puts("Yes");
	else puts("No");
	return 0;
}



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

#define rep(i, n) for(int i = 0; i < (n); i++)
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
template<class T> void cout_h(const vector<T>& c, int n=INT_MAX)
{ for (int i = 0; i < min(n, c.size()); i++) cout << c[i] << (i==c.size()-1?"\n":" "); }

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

    // eratosthenes
    int P_MAX=100000;
    char p[P_MAX+1];
    memset(p, 1, sizeof p);
    p[0] = p[1] = 0;
    for (int i = 4; i <= P_MAX; i+=2)
        p[i] = 0;
    for (int i = 3; i*i <= P_MAX; i+=2) {
        if (!p[i]) continue;
        for (int j = i*i; j <= P_MAX; j += i)
            p[j] = 0;
    }

    // 2017-like number
    int n2017[P_MAX+1];
    memset(n2017, 0, sizeof n2017);
    for (int i = 2; i <= P_MAX; i++) {
        if (!p[i]) continue;
        int n = 2 * i - 1;
        if (n > P_MAX) break;
        if (p[n]) n2017[n] = 1;
    }

    // cumulative sum
    int s[P_MAX+1];
    s[0] = 0;
    for (int i = 1; i <= P_MAX; i++) {
        s[i] = s[i-1] + n2017[i];
    }

    int Q; cin >>Q;
    rep(i, Q) {
        int l, r; cin >> l >> r;
        cout << (s[r] - s[l-1]) << endl;
    }
}



Measured memory_bytes: 1536
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <stack>
#define rep(i,o,u) for(int i = o;i < u; i++)
using namespace std;
stack <int> s;
int main(){
	char t[100];
	int a,b;
	int ans;
	while(scanf("%s", t) != EOF){
		if(t[0] == '+'){
			a = s.top();s.pop();
			b = s.top();s.pop();
			s.push(a + b);
		}else if(t[0] == '-'){
			b = s.top();s.pop();
			a = s.top();s.pop();
			s.push(a - b);
		}else if(t[0] == '*'){
			a = s.top();s.pop();
			b = s.top();s.pop();
			s.push(a * b);
		}else{
			s.push(atoi(t));
		}
	}
	cout << s.top() << endl;
	return 0;
}

Measured memory_bytes: 3160
import java.io.*;  

public class Main {
    public static void main(String[] args) throws IOException {
	                                         
    	
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	String buf = br.readLine();
    String[] x = buf.split(" ",0);
   
    	int a = Integer.parseInt(x[0]);
    	int b = Integer.parseInt(x[1]);
    	if(a<b)
          System.out.println("a < b"); 
    	else if(a>b)
          System.out.println("a > b"); 
    	else if(a==b)
          System.out.println("a == b"); 
	    
    }
    
}

Measured memory_bytes: 24140
#include<iostream>

using namespace std;

int keisan(int a, int b, int c, int k) {
	if (k <= a) return k;
	else if (k <= a + b) return a;
	else return a - (k - a - b);
}



int main() {
	int a, b, c, k, k_a, k_b, k_c , i;
	k_a = 0;
	k_b = 0;
	k_c = 0;
	
	cin >> a >> b >> c >> k;

	cout << keisan(a, b, c, k);
	


	return 0;
}

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


int main(){
string A;
cin >> A;
int a = A[0];
int b = A[1];
int c = A[2];
int d = A[3];
a -=48;
b -=48;
c -=48;
d -=48;

if(a+b+c+d == 7){
cout <<a<<"+"<<b<<"+"<<c<<"+"<<d<<"=7"<<endl;
return 0;
}
else if(a+b+c-d == 7){
cout <<a<<"+"<<b<<"+"<<c<<"-"<<d<<"=7"<<endl;
return 0;
}
else if(a+b-c+d == 7){
cout <<a<<"+"<<b<<"-"<<c<<"+"<<d<<"=7"<<endl;
return 0;
}
else if(a+b-c-d == 7){
cout <<a<<"+"<<b<<"-"<<c<<"-"<<d<<"=7"<<endl;
return 0;
}
else if(a-b+c+d == 7){
cout <<a<<"-"<<b<<"+"<<c<<"+"<<d<<"=7"<<endl;
return 0;
}
else if(a-b+c-d == 7){
cout <<a<<"-"<<b<<"+"<<c<<"-"<<d<<"=7"<<endl;
return 0;
}
else if(a-b-c+d == 7){
cout <<a<<"-"<<b<<"-"<<c<<"+"<<d<<"=7"<<endl;
return 0;
}
else if(a-b-c-d == 7){
cout <<a<<"-"<<b<<"-"<<c<<"-"<<d<<"=7"<<endl;
return 0;
}

}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <string>
#include <set>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <bitset>
#include <random>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <complex>
#include <functional>
using namespace std;
#define rep(i,a,b) for(int i = (a); i < int(b); ++i)
#define rrep(i,a,b) for(int i = (b); i --> int(a);)
#define all(v) v.begin(),v.end()
#define trav(x, v) for(auto &x : v)
#define sz(v) int((v).size())
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long double ld;

void fail(){
	puts("Impossible");
	exit(0);
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	int n;
	cin >> n;
	vi as(n);
	trav(a, as) cin >> a;
	sort(all(as));
	int cnt = 0, mn = as[0];
	while(cnt < n && as[cnt] == mn) ++cnt;
	if(cnt > 2) fail();
	if(cnt == 1 && as[n-1] != 2*mn) fail();
	if(cnt == 2 && as[n-1] != 2*mn-1) fail();
	vi bs(n+2);
	trav(a, as) ++bs[a];
	rep(val, mn+1, as[n-1]+1) if(bs[val] < 2) fail();
	puts("Possible");
}

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

#define f(i,a,b) for( ll  i = a; i < (ll) b ; i++ ) 
#define af(i,a,b) for( ll i = a; i >= b ; i--)
#define rep(i,a,b,k) for(ll i = a; i < b ; i+= k )
#define arep(i,a,b,k) for( ll i = a; i >= b ; i-= k)
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(a) (ll) a.size()
#define all(a) a.begin(), a.end()
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define inter   ios::sync_with_stdio(false);cin.tie(0)

// policy-based



using namespace std;


typedef long long ll; // int or long long
typedef long double ld;
typedef pair<ll,ll> ii ;
typedef vector<ll>  vi ;
typedef vector<ii> vii ;



 
const ll MAX = 2e5+1;
const ll inf = 1e9;
const ll mod = 998244353;

ll x[MAX],y[MAX],treex[MAX*2],treey[MAX*2],n;
bool ax[MAX],ay[MAX];
void build(){
	f(i,0,2*n) treex[i] = treey[i] = n;
}

ll query(ll tree[],ll v){
	ll ans = inf;
	v+=n;
	while(v) ans = min(ans,tree[v]),v>>=1;
	return ans; 
}
void update(ll tree[],ll l,ll r,ll val){
	for(l+=n,r+=n;l<r;l>>=1,r>>=1){
		if(l&1) tree[l] = min(tree[l],val),l++;
		if(r&1) r--,tree[r] = min(tree[r],val);
	}
}

int main(){
	fastio;
	ll q,t,a;
	cin >> n >> q;
	ll ans = (n-2)*(n-2);
	build();
	while(q--){
		cin >> t >> a;
		a--;
		if(t == 1){
			if(!ay[a]){
				ll dis = query(treex,a);
				ans -= (dis-2);
				update(treey,0,dis,a+1);
				ay[a] = true;
			}
		}
		else{
			if(!ax[a]){
				ll dis = query(treey,a);
				ans -= (dis-2);
				update(treex,0,dis,a+1);
				ax[a] = true;
			}
		}
	}
	cout << ans << endl;
	return 0;
} 

Measured memory_bytes: 10224
//C
#include <cassert>
//#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#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>

//ここまで標準include

using namespace std;

long aCb(long a, long b) {
	long out = 1;
	for (long i = 1; i <= b; i++) {
		out = out * (a + 1 - i) / i;
	}
	return out;
}

int main() {
	string s, t;
	cin >> s >> t;
	int ans = 0;
	for (int i = 0; i < 3; i++) {
		if (s.substr(i, 1) == t.substr(i, 1)) {
			ans++;
		}
	}
	cout << ans << endl;
}
	


Measured memory_bytes: 256
def cmpNum(a, b):
    if a < b:
        print('a < b')
    elif a > b:
        print('a > b')
    elif a == b:
        print('a == b')

def main():
    v = input()
    arr = v.split()
    cmpNum(int(arr[0]), int(arr[1]))

if __name__ == '__main__':
    main()


Measured memory_bytes: 5596
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i,n) for(long long i = 0; i < (n); ++i)
#define ll long long
#define P pair<ll,ll>
#define all(v) (v).begin(),(v).end()

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);

int main(void)
{
    ll n, m;
    cin >> n >> m;
    vector<ll> ac(n,false),pena(n,0);
    map<string,ll> mp;
    rep(i,m){
        ll a; string s;
        cin>>a>>s;
        a--;
        if(ac[a]) continue;
        if(s=="AC"){
            ac[a]=1;
        }else{
            pena[a]++;
        }
    }
    ll AC=0, WA=0;
    rep(i,n){
        AC += ac[i];
        if(ac[i]) WA += pena[i];
    }

    cout << AC << " " << WA << endl;
    return 0;
}

Measured memory_bytes: 4824
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> P;
typedef vector<vector<int>> Matrix;
static const int INF = 2000000000;


int main(){
  char x, y, ans;
  cin >> x >> y;
  if (x > y) ans = '>';
  else if (x < y) ans = '<';
  else ans = '=';
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; 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 ll long long
#define pb(a) push_back(a)

ll mod = 1e09;

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

  int n;
  cin >> n;

  int ans = n * 800 - 200 * (n / 15);
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define len(x) ((long long)(x).size())
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U>bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U>bool isin(T el, U container) { return find(all(container), el) != container.end(); }
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 (b < a) { a = b; return 1; } return 0; }
template<class T>bool even(T n) { return ! (n & 1); }
template<class T>bool odd(T n) { return n & 1; }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
ll intpow(ll a,ll n){ll p=1;while(n){if(n&1)p*=a;a*=a;n>>=1;}return p;}
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;



int main()
{
        ll N, M;
        cin >> N >> M;
        vll a(N+1);
        rep(i, 1, M+1) {
            ll x;
            cin >> x;
            a[x] = 1;
        }

        vll dp(N+1);
        dp[0] = 1;
        rep(i, 1, N+1) {
            if (a[i-1] != 1) {
                dp[i] = (dp[i] + dp[i-1]) % mod;
            }
            if (a[i-2] != 1 and i >= 2) {
                dp[i] = (dp[i] + dp[i-2]) % mod;
            }
        }
        cout << dp[N] << endl;
}



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

using namespace std;

int main(){

    
	int N,M;
	
	int c[N+1];

	cin >> N >> M;

	int a,b;

	for(int i = 0;i < M;i++){
		cin >> a >> b;
		c[a]++;
		c[b]++;
	}

	for(int i = 1;i <= N;i++){
		cout << c[i] << endl;
	}

}


Measured memory_bytes: 256
import numpy as np
import math

A, B, H, M = map(int, input().split())


def H_angle(H, M):
    return H * 30 + 0.5 * M

def M_angle(M):
    return M * 6

angle = abs(H_angle(H, M) - M_angle(M))
if angle >= 180:
    angle = abs(360 - angle)
angle = math.radians(angle)

def compute(A, B, angle):
    A2 = np.square(A)
    B2 = np.square(B)
    AB = A * B
    cos = np.cos(angle)
    return A2 + B2 - 2 * AB * cos


print(np.sqrt(compute(A, B, angle)))

Measured memory_bytes: 27244
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define rep(i,j,k) for(int i=j;i<k;i++)
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
const int  COMMAX = 510000;

long long fac[COMMAX], finv[COMMAX], inv[COMMAX];

// テーブルを作る前処理
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < COMMAX; i++){
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

// 二項係数計算
long long COM(int n, int k){
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

struct UnionFind {
  vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
  vector<int> rank;
  int num;
  UnionFind(int N) : par(N) , rank(N) { //最初は全てが根であるとして初期化
    num = N;
    for(int i = 0; i < N; i++){
      par[i] = i;
      rank[i] = 0;
    }
  }

  int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
    if (par[x] == x) return x;
    return par[x] = root(par[x]);
  }

  void unite(int x, int y) { // xとyの木を併合
    int rx = root(x); //xの根をrx
    int ry = root(y); //yの根をry
    if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
    if(rank[rx] < rank[ry]){
      par[rx] = ry;  
    }else{
      par[ry] = rx;
      if(rank[rx] == rank[ry])rank[rx]++;
    }
    num--;
  }

  bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
    return root(x) == root(y);
  }
};

const int MS = 2;
const long long mod[] = {999999937LL, 1000000007LL}, base = 9973;
struct rolling_hash {
    int n;
    vector<long long> hs[MS], pw[MS];
    rolling_hash(){}
    rolling_hash(const string &s) {
        n = s.size();
        for (int i = 0; i < MS; i++) {
            hs[i].assign(n+1,0);
            pw[i].assign(n+1,0);
            hs[i][0] = 0;
            pw[i][0] = 1;
            for (int j = 0; j < n; j++) {
                pw[i][j+1] = pw[i][j]*base%mod[i];
                hs[i][j+1] = (hs[i][j]*base+s[j])%mod[i];
            }
        }
    }

    long long hash(int l, int r, int i) { return ((hs[i][r]-hs[i][l]*pw[i][r-l])%mod[i]+mod[i])%mod[i]; }

    bool match(int l1, int r1, int l2, int r2) {
        bool ret = 1;
        for (int i = 0; i < MS; i++) ret &= hash(l1,r1,i)==hash(l2,r2,i);
        return ret;
    }

    bool match(int l, int r, long long h[]) {
        bool ret = 1;
        for (int i = 0; i < MS; i++) ret &= hash(l,r,i)==h[i];
        return ret;
    }
};

int main(){
  int n,m;
  cin >> n >> m;
  int a,b;
  a = max(n,m);
  b = min(n,m);
  string s = "";
  rep(i,0,a){
    s += to_string(b);
  }
  cout << s << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vii = vector<vi>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1e9+7;
const int INF = 2e9;
template<class T> void print(const T& t){ cout << t << endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main(){
  string s, t;
  cin >> s >> t;
  t.erase(sz(t)-1);
  if(s==t){
    print("Yes");
  }
  else{
    print("No");
  }
}

Measured memory_bytes: 3628
w = input()

dict_ = {}

for i in w:
    dict_.setdefault(i, 0)
    dict_[i] +=1

flg = True

for v in dict_.values():
    if v % 2 != 0:
        flg = False
        break
if flg:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 8972
#include<bits/stdc++.h>
using namespace std;
int main(){
	int k;
	cin>>k;
	int k1=k,a[10]={};
	int i=0;
	do{
		a[i]=k1%10;
		k1/=10;
		i++;
	}while(k1>=1);

	int cnt=0;
	for(int i=0;i<=9;i++)
		cnt+=a[i];
	if(k%cnt==0)
		cout<<"Yes";
	else
		cout<<"No";
		
	return 0;
}

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

using namespace std; 
const int MAX_N = 3005; 

long long dp[MAX_N][MAX_N]; 
long long a[MAX_N]; 
long long sum[MAX_N];
int n; 

int main () {
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%lld", &a[i]); 
		sum[i] = sum[i - 1] + a[i]; 
	}

	for (int i = 1; i <= n; i++) {
		dp[i][i] = a[i];
	}

	for (int j = 2; j <= n; j++) {
		for (int i = j - 1; i >= 1; i--) {
			dp[i][j] = sum[j] - sum[i - 1] - min(dp[i + 1][j], dp[i][j - 1]);  
		}
	}

	cout << 2 * dp[1][n] - sum[n]; 
	return 0; 
}

Measured memory_bytes: 70016
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define pli pair<ll, int>
#define pil pair<int, ll>
#define pll pair<ll, ll>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define endl '\n'
const int inf = 1000000007;
const ll INF = 1e18;
// int mod = 998244353;
int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
template<typename T, typename U> T pow_(T a, U b) { return b ? pow_(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<typename T> inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T, class T2> inline void add(T &a, T2 b) { a += b % mod; if (a >= mod) a -= mod; }
template<class T> void operator += (vector<T>& v, vector<T> v2) { rep(i, sz(v2)) v.eb(v2[i]); }

void solve();

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(12); // debuged
    int T;
    T = 1;
    while (T--) solve();
}

// 未証明
// https://atcoder.jp/contests/abc144/submissions/15299683
void solve() {
    int n; ll k;
    cin >> n >> k;
    vector<int> a(n), f(n);
    cin >> a >> f;
    vector<pll> b(n);
    sort(all(a));
    sort(all(f), greater<>());
    rep(i, n) b[i] = pll(a[i] * 1LL * f[i], f[i]);
    
    auto bin = [&](ll ok, ll ng) {
        auto check = [&](ll x) {
            ll cnt = 0; // debuged, int
            rep(i, n) {
                if (b[i].F <= x) continue;
                cnt += b[i].F / b[i].S - x / b[i].S;
            }
            if (cnt <= k) return 1;
            return 0;
        };
        while (abs(ok - ng) > 1) {
            ll mid = (ok + ng) / 2;
            // cerr << mid << endl;
            if (check(mid)) ok = mid;
            else ng = mid;
            // cerr << ok << " " << ng << endl;
        }
        cout << ok << endl;
    };
    bin(1000000000000, -1);
}


Measured memory_bytes: 7924
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


from collections import defaultdict
n,m = map(int, input().split())
ns = defaultdict(set)
for _ in range(m):
    u,v,c = map(int, input().split())
    u -= 1
    v -= 1
    ns[u].add((c,v))
    ns[v].add((-c,u))
vals = [None] * n
def dijkstra(start):
    import heapq
    h = [(0, start)] # (距離, ノード番号)
    vals[start] = 0
    ans = True
    while h:
        val, u = heapq.heappop(h)
        for d, v in ns[u]:
            if vals[v] is None:
                vals[v] = val+d
                heapq.heappush(h, (vals[v], v))
            else:
                if vals[v]!=val+d:
                    return False
    return ans

for start in range(n):
    if vals[start] is not None:
        continue
    res = dijkstra(start)
    if not res:
        print("No")
        break
else:
    print("Yes")

Measured memory_bytes: 138968
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	if n%1000 == 0 {
		fmt.Println(0)
	} else {
		fmt.Println(1000 - n%1000)
	}
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}


Measured memory_bytes: 1768
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

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

    vector<long long> a(n);
    long long sum = 0;
    for(long long i = 0; i < n; i++){
        cin >> a[i];
        a[i] -= i+1;
    }

    sort(a.begin(), a.end());

    long long mid = a[n/2];

    for(long long i = 0; i < n; i++){
       sum += abs(a[i]-mid);
    }
    cout << sum << endl;
    return 0;
}

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll k;
    std::cin >> k;
    
    ll r = 1e16;
    ll l = 0;
    
    // mid以下のルンルン数の数
    while(r-l>1){
                // std::cout << l<<" "<<r << std::endl;

        ll mid = (r+l)/2;
        
        // dp[i番目までみて][終わったときの数字][同じかどうか]
        vector<vector<vector<ll>>> dp(21,vector<vector<ll>>(10,vector<ll>(2,0)));
        
        dp[0][0][1] = 1;
        
        for (int i = 0; i < 20; i++) {
            ll now = (mid%(ll)pow(10,20-i))/pow(10,19-i);
            ll pre = (mid%(ll)pow(10,21-i))/pow(10,20-i);
            
            if(abs(now-pre)<=1||20-to_string(mid).size()==i) dp[i+1][now][1] = dp[i][pre][1];
            for (int j = 0; j < 10; j++) {
                if(j<now && (abs(j-pre)<=1||20-to_string(mid).size()==i)){
                    if(j==0&&20-to_string(mid).size()==i)continue;
                    dp[i+1][j][0] += dp[i][pre][1];
                }
                if(20-to_string(mid).size()<i&&j>0){
                    dp[i+1][j][0]++;
                }
                for (int kk = 0; kk < 10; kk++) {
                    if(abs(j-kk)<=1) dp[i+1][j][0] += dp[i][kk][0];
                }
            }
        }
        ll res = 0;
        for (int i = 0; i < 10; i++) {
            // std::cout <<" "<<dp[20][i][0]<<" "<<dp[20][i][1] << std::endl;
            res += dp[20][i][0]+dp[20][i][1];
        }
        
        if(res >= k){
            r = mid;
        }else{
            l = mid;
        }
    }
    
    std::cout << r << std::endl;
}



Measured memory_bytes: 512
//----------------------------------------------------------------------
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
//----------------------------------------------------------------------

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;

int main(void) {
    int k;
    cin >> k;
    vector<ll> a;
    for(int i = 1; i <= 9; ++i) a.push_back(i);

    while(1) {
        if(a.size()>=k) {
            cout << a[k-1] << endl;
            return 0;
        }
        k -= a.size();
        vector<ll> old;
        swap(old, a);
        for(ll v : old) {
            for(int i = -1; i <= 1; i++) {
                int add = v % 10;
                add += i;
                if(add < 0 || add > 9) continue;
                a.push_back(10*v+add);
            }
        }
    }
    return 0;
}

Measured memory_bytes: 1712
n = gets.to_i
num = gets.strip.split.map(&:to_i)
rec = Array.new(10**5+2,0)
for i in 0..n-1
  rec[num[i]] += 1
  rec[num[i]+1] += 1
  rec[num[i]+2] += 1
end
puts rec.max

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

int main(){
    int A,B,a,b,c,d,i;
    int res =0;
    cin >> A >> B;
    for (i=A;i<=B; ++i){
        a=i/10000;
        b=(i/1000)%10;
        c=(i/10)%10;
        d=i%10;
        if (a==d && b==c) ++res;
    }
    cout << res << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
using namespace std;

#define all(c) (c).begin(),(c).end()
#define endl "\n"
#define ff first
#define ss second
#define allr(c) (c).rbegin(),(c).rend()
#define ifr(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define pof pop_front
#define pob pop_back
#define pb emplace_back
#define pf emplace_front
#define fstm(m,n,r) m.reserve(n);m.max_load_factor(r)
#define mp make_pair
#define mt make_tuple
#define inf LLONG_MAX
#define os tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
//order_of_key (k) : Number of items strictly smaller than k .
//find_by_order(k) : K-th element in a set (counting from zero).
const double PI = acos(-1);
typedef complex<double> cd;
typedef long long ll;
ll gcd(){return 0ll;} template<typename T,typename... Args> T gcd(T a,Args... args) { return __gcd(a,(__typeof(a))gcd(args...)); }
typedef map<ll,ll> mll;
typedef map<string,ll> msll;
typedef unordered_map<ll,ll> umap;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
typedef long double ld;
#define mod 1000000007 

const int N = 1e5 + 2;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    // #ifndef ONLINE_JUDGE
    //     freopen("input.txt","r",stdin);
    // #endif
    
    // int T;cin>>T;while(T--) 
    {
        ll a, b, c;
        cin>>a>>b>>c;
        if(ceil((1.0*a)/c) <= b) cout<<"Yes\n";
        else cout<<"No\n";
    }
    return 0;
}

Measured memory_bytes: 3664
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int wa=0,ac=0,n,m,a,b,p[1000005];
bool ha[1000005];
string s;
int main(){
	scanf("%d%d",&n,&m);
	for(int i=0;i<m;i++){
		scanf("%d",&a);
		cin>>s;
		if(s=="AC"&&!ha[a]){
			ha[a]=1;
			ac++;
			wa+=p[a];
		}
		if(s=="WA"&&!ha[a]){
			p[a]++;
		}
	}
	printf("%d %d",ac,wa);
	return 0;
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
string a[810];
set<string> st;
int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++)cin>>a[i];
	for(int i=0;i<n;i++){
		if(i&&a[i-1][a[i-1].size()-1]!=a[i][0]){
			puts("No");
			return 0;
		}
		if(st.find(a[i])!=st.end()){
			puts("No");
			return 0;
		}
		st.insert(a[i]);
	}
	puts("Yes");
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        char[] input = Console.ReadLine().ToCharArray();
        int count = 0;
        for (int i = 0; i < input.Length; i++)
        {
            if (input[i] == 'x') count++;
        }
        if (count >= 8) { Console.WriteLine("NO"); }
        else { Console.WriteLine("YES"); }
        
    }
}


Measured memory_bytes: 13140
use proconio::{fastout, input};
use std::cmp::min;

#[fastout]
fn main() {
    input! {in_a: u64, in_b: u64, in_n: u64};
    let x = min(in_b - 1, in_n);
    let y = in_a * x / in_b - in_a * (x / in_b);

    println!("{}", y);
}


Measured memory_bytes: 2112
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<string> vs;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int, int> pii;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<pii> vpii;
typedef vector<vpii> vvpii;

inline bool valid(int x, int n) {
    return 0 <= x && x < n;
}

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

template <typename T>
inline T pop(queue<T>& q) {
    T front = q.front();
    q.pop();
    return front;
}

template <typename T>
inline T gcd(T a, T b) {
    for (; b; a %= b, swap(a, b));
    return a; 
}

template <typename T>
tuple<T, T, T> xgcd(T a, T b) {
    if (b == 0) return {1, 0, a};
    T x, y, g;
    tie(x, y, g) = xgcd(b, a%b);
    return {y, x-(a/b)*y, g};
}

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

    int D, S, T; cin >> D >> S >> T;
    if (S*T < D) cout << "No";
    else cout << "Yes";
}

Measured memory_bytes: 3648