akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <unordered_map>
#include <cmath>
#include <utility> // pair make_pair
#include <algorithm>
#include <iomanip>
#include <climits> // LLONG_MAX, LLONG_MIN, INT_MIN, INT_MAX

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define ll long long
//#define int ll
#define INF INT_MAX/10

using namespace std;
using Pi = pair<int, int>;
using Graph = vector<vector<int> >;
using WeightGraph = vector<vector<Pi> >;

int main() {
  int N, M; cin >> N >> M;
  int x = 0;
  while (x * (N-1) + 1 < M) {
    x++;
  }
  cout << x << endl;
}


Measured memory_bytes: 256
cache = {}

def main():
    def lucas(x):
        if x == 0:
            return 2
        elif x == 1:
            return 1
        elif x in cache:
            return cache[x]
        else:
            cache[x] = lucas(x-1) + lucas(x-2)
            return cache[x]

    N = int(input())
    print(lucas(N))


if __name__ == '__main__':
    main()


Measured memory_bytes: 61604
import java.util.*; 
import java.lang.*; 


public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
                
                int K = scan.nextInt();
                String S = scan.next();
                
                if(S.length()<=K){
                    System.out.println(S);
                }else{           
                    String U = S.substring(0,K);

                    System.out.println(U+"...");
                }
        }
}

Measured memory_bytes: 38624
/* nuttela - Soham Chakrabarti */
 
#include <bits/stdc++.h>
 
using namespace std;
 
#define io ios_base::sync_with_stdio(false);cin.tie(NULL)
#define all(v) v.begin(),v.end()
#define pb push_back
#define ins insert
#define rep(i,j,k) for(ll i=j;i<k;i++)
#define per(i,j,k) for(ll i=j;i>=k;--i)
#define in freopen("input.txt","r",stdin);
#define out freopen("output.txt","w",stdout);
#define ff first
#define ss second
 
typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair <ll,ll> pll;
 
const int N = 1e5 + 5;
const int M = 1e5 + 1;
const int inf = INT_MAX;
const int mod = 1e9 + 7;


int32_t main() {
    io;
    // in; out;
    // ll t;
    // cin>>t;
    // while(t--) {
        ll h1,m1,h2,m2,k;
        cin>>h1>>m1>>h2>>m2>>k;
        ll mins=(h2-h1)*60;
        mins+=(m2-m1);
        cout<<max(0LL,mins-k)<<endl;
    // }
    return 0;
}
 


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

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int

int main(){
  ll r,D,x;
  cin>>r>>D>>x;
  rep(i,10){
    x=r*x-D;
    cout<<x<<endl;
  }


  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <cassert>
#include <iomanip>

using namespace std;

int manhattan(vector<int> &x,vector<int> &y){
	assert(x.size() == y.size());
	int sum = 0;
	for(int i = 0; i < x.size(); i++){
		sum += abs(x[i] - y[i]);
	}
	return sum;
}
double euclidean(vector<int> &x, vector<int> &y){
	assert(x.size() == y.size());	
	double sum = 0.0;
	for(int i = 0; i < x.size(); i++){
		int ab2 = (x[i] - y[i]) * (x[i] - y[i]);
		sum += ab2;
	}
	return sqrt(sum);
}
long double p3(vector<int> &x, vector<int> &y){
	assert(x.size() == y.size());	
	double sum = 0.0;
	for(int i = 0; i < x.size(); i++){
		int ab = abs(x[i] - y[i]);
		int ab3 = ab * ab * ab;
		sum += ab3;
	}
	return powl(sum, 1.0L / 3);
}
double chebishev(vector<int> &x, vector<int> &y){
	assert(x.size() == y.size());	
	double max = 0.0;
	for(int i = 0; i < x.size(); i++){
		int ab = abs(x[i] - y[i]);
		if(max < ab){
			max = ab;
		}
	}
	return max;
}
void input(int num,vector<int> &v){
	for(int i = 0; i < num; i++){	
		int x;
		cin >> x;
		v.push_back(x);
	}
}
void output(long double num){
	cout << fixed << fixed << std::setprecision(8) << num << endl;
}
int main(int argc, char *argv[])
{
	int num;
	cin >> num;
	vector<int> x,y;
	input(num, x);
	input(num, y);
	output(manhattan(x,y));
	output (euclidean(x,y));
	output (p3(x,y));
	output (chebishev(x,y));
	return 0;
}

Measured memory_bytes: 3472
program tsundoku
  implicit none
  integer :: n, m, i,j, h = 0, l, r, p
  integer(8) :: k, t
  integer(8), dimension(200000) :: a = 0, b = 0,c=0, x = 0, y = 0
  read(*,*) n
    do t=1,n
    m=int(sqrt(dble(t)))
    p=0
	do i=1,m
    	do j=1,i
        	do k=1,j
            	if((i+j)*(i+j)+(i+k)*(i+k)+(k+j)*(k+j)==2*t)then
                	if(i==j.and.j==k)then
                    p=p+1
                    else if(i==j.and.j>k)then
                    p=p+3
                    else if(i>j.and.j==k)then
                    p=p+3
                    else if(i>j.and.j>k)then
                    p=p+6
                    end if
                end if
            end do
        end do
    end do
    write(*,*)p
    end do
end program tsundoku

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

typedef long long ll;
typedef pair<int,int> pii;
typedef map<int,int> mkmap;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pii> vp;
typedef vector<vi> vv;

#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
const ll mod=1000000007;
const int sz=1000001;
#define endl "\n"
#define all(a) (a).begin(),(a).end()
#define rep(i,a,b) for(i=a;i<b;++i)
#define rrep(i,a,b) for(i=a;i>=b;--i)
#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define db(x) cout << (#x) << " = " << x << endl;

inline ll mult(ll a, ll b) {return (((a % mod) * (b % mod)) % mod);}



int main(){
    fast;
    int t,tt,tti,n,m,x,y,z,i,j,k,temp,count,o,e,f,ans,sum,l,r,mx,mn;
    ll lx,ly,lz,ltemp;
    double fx,fy,fz;
    string s;
    
    cin>>x>>y>>k;
    z=ceil(x/(float)k);
    x=y/k;
    if(x<z) cout<<0;
    else cout<<x-z+1;
}

/*
    
*/

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    string A;
    cin >> A;
    if(A== "abc" || A== "acb" || A=="bac" || A=="bca" || A=="cab" || A=="cba" ){
        cout << "Yes";
    } else {
        cout << "No";
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define INF 2100000000
#define MOD 1000000007

bool dbgflag = false; //debug

struct Node {
  int a;
  int len = -1;
  vector<int> branch;
  pii change; //(変わったインデックス・番号)
};

void dfs(int i, vector<Node>&tree, vector<int>&dp) {
  if (dbgflag) cout << "dfs: " << i << endl;
  auto it = lower_bound(dp.begin(), dp.end(), tree[i].a);
  tree[i].change.first = (int)(it - dp.begin());
  tree[i].change.second = (*it);
  (*it) = tree[i].a;
  tree[i].len = (int)(lower_bound(dp.begin(), dp.end(), INF) - dp.begin());

  for (int n: tree[i].branch) {
    if (tree[n].len != -1) continue;
    dfs(n, tree, dp);
  }

  dp[tree[i].change.first] = tree[i].change.second;
  return;
}

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

  int n;
  cin >> n;
  vector<int> dp(n, INF);
  vector<Node> tree(n);
  for (int i = 0; i < n; i++) cin >> tree[i].a;
  for (int i = 0; i < n-1; i++) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    tree[a].branch.push_back(b);
    tree[b].branch.push_back(a);
  }
  
  dfs(0, tree, dp);

  for (Node node: tree) {
    cout << node.len << endl;
  }
}


Measured memory_bytes: 26580
n=int(input())
x=list(map(int,input().split()))
xx=[]
for i in range(n):
    xx.append([x[i],i,""])
xx2=sorted(xx)
for i in range(n):
    if i<=(n//2-1):
        xx2[i][2]="l"
    else:
        xx2[i][2]="r"
l_num,r_num=xx2[n//2-1][0],xx2[n//2][0]
xx3=sorted(xx2,key=lambda x:x[1]) #最初の順番に戻す
for i in range(n):
    if xx3[i][2]=="l":
        print(r_num)
    else:
        print(l_num)

Measured memory_bytes: 46912
#include<iostream>
#define int long long
using namespace std;
int dp[101][100100] , v[101] , w[101] , n , W , i , j;
main(){ios::sync_with_stdio(false),cin.tie(0);
	cin >> n >> W;
	for(i=0 ; i<n ; ++i) cin >> w[i] >> v[i];
	for(i=0 ; i<n ; ++i)
		for(int j=0 ; j<100100 ; ++j)
			dp[i][j] = 1e13;
	for(i=0 ; i<n ; ++i) dp[i][0] = 0;
	for(dp[0][v[0]] = w[0] , i=1 ; i<n ; ++i)
		for(j=100099 ; j>=0 ; --j)
			j-v[i] >= 0 ? dp[i][j] = min(dp[i-1][j] , dp[i-1][j-v[i]]+w[i]) : dp[i][j] = dp[i-1][j];
	for(j=100099 ; j>=0 ; --j)	if(dp[n-1][j] <= W) return cout << j , 0;
}

Measured memory_bytes: 78464
#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>;

int main()
{
    int n, r;
    cin >> n >> r;
    int ans = 0;

    if (n < 10)
    {
        ans = 100 * (10 - n) + r;
    }
    else
    {
        ans = r;
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<ctype.h>
int count,d;
char screen[12][7];

void manuver(int x,int y,char c);
void delete(int x,int y,char c);
void recover(void);
void fall(int x,int y,char c);

int main(void){
  int i,j,p,q,t,del,block,ok,chain;
  scanf("%d",&t);
  while(t--){
    chain=0;
    for(i=0;i<12;i++) scanf("%s%*c",screen[i]);
    ok=1;
    while(ok){
      ok--;
      for(i=0;i<12;i++){
	for(j=0;j<6;j++){
	  //printf("%d %d\n",i,j);
	  if(screen[i][j]!='.'&&screen[i][j]!='O'&&(del=isupper(screen[i][j]))!=0){
	    block=screen[i][j];
	    screen[i][j]=tolower(screen[i][j]);
	    count=0;
	    manuver(i,j,block);
	    if(count>=3){
	      if(ok==0) ok++;
	      delete(i,j,screen[i][j]);
	    }
	  }
	  //puts("ok");
	}
      }
      if(ok==0) break;
      recover();
      chain++;
      for(j=0;j<6;j++){
	for(i=10;i>=0;i--){
	  if(screen[i][j]!='.'&&screen[i+1][j]=='.')
	    fall(i,j,screen[i][j]);
	}
      }
      /*printf("%d\n",chain);
      for(i=0;i<12;i++){
	for(j=0;j<6;j++){
	  putchar(screen[i][j]);
	}
	putchar('\n');
      }
      putchar('\n');*/
      //printf("%d\n",ok);
    }
    printf("%d\n",chain);
  }
  return 0;
}
    
void manuver(int x,int y,char c){
  //printf("%c\n",c);
  if(x!=11&&screen[x+1][y]==c){
    count++;
    //printf("%d %d\n",x,y);
    screen[x+1][y]=tolower(screen[x+1][y]);;
    manuver(x+1,y,c);
  }
  if(x!=0&&screen[x-1][y]==c){
    //printf("%d %d\n",x,y);
    count++;
    screen[x-1][y]=tolower(screen[x-1][y]);
    manuver(x-1,y,c);
  }
  if(y!=0&&screen[x][y-1]==c){
    count++;
   //printf("%d %d\n",x,y);
    screen[x][y-1]=tolower(screen[x][y-1]);
    manuver(x,y-1,c);
  }
  if(y!=5&&screen[x][y+1]==c){
    count++;
    //printf("%d %d\n",x,y);
    screen[x][y+1]=tolower(screen[x][y+1]);
    manuver(x,y+1,c);
  }
}

void delete(int x,int y,char c){
  char o='O';
  if(x!=11&&screen[x+1][y]==c){
    screen[x+1][y]='.';
    delete(x+1,y,c);
  }
  if(x!=0&&screen[x-1][y]==c){
    screen[x-1][y]='.';
    delete(x-1,y,c);
  }
  if(y!=0&&screen[x][y-1]==c){
    screen[x][y-1]='.';
    delete(x,y-1,c);
  }
  if(y!=5&&screen[x][y+1]==c){
    screen[x][y+1]='.';
    delete(x,y+1,c);
  }
  if(x!=11&&screen[x+1][y]==o){
    screen[x+1][y]='.';
  }
  if(x!=0&&screen[x-1][y]==o){
    screen[x-1][y]='.';
  }
  if(y!=0&&screen[x][y-1]==o){
    screen[x][y-1]='.';
  }
  if(y!=5&&screen[x][y+1]==o){
    screen[x][y+1]='.';
  }
}

void recover(void){
  int i,j;
  for(i=0;i<12;i++){
    for(j=0;j<6;j++){
      screen[i][j]=toupper(screen[i][j]);
    }
  }
}

void fall(int x,int y,char c){
  screen[x+1][y]=c;
  screen[x][y]='.';
  if(x!=10&&screen[x+2][y]=='.') fall(x+1,y,c);
}
      

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    int t,a;
    cin>>n>>t>>a;
    double diff = 1e5;
    int ans = -1;
    for(int i=0;i<n;i++){
        double h;
        cin>>h;
        if(diff>=abs(t-h*0.006-a)){
            diff = abs(t-h*0.006-a);
            ans = i+1;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
MOD = 10 ** 9 + 7

n, k = map(int, input().split())

a = sorted(list(map(int, input().split())))

b = sorted(a, reverse=True)
s = [1]
r = [1]
for i in range(1, n + 1):
    s.append(s[i - 1] * i % MOD)
    r.append(pow(s[i], MOD-2, MOD))
min = 0
max = 0
for i in range(n-k+1):
    tmp = (s[n - i - 1] * r[k-1] * r[n - k - i])%MOD
    min += a[i] * tmp % MOD
    max += b[i] * tmp % MOD
    min %= MOD
    max %= MOD
print((max - min) % MOD)

Measured memory_bytes: 16152
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;

main() {
    int64_t n, a, b;
    cin >> n >> a >> b;

    int64_t x{}, y{}, z{};
    for(auto _ : irange(0L, n)) {
        int64_t p;
        cin >> p;

        if (p <= a) {
            ++x;
        } else if (p <= b) {
            ++y;
        } else {
            ++z;
        }
    }

    cout << min({x, y, z}) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Sort(a) sort(a.begin(), a.end())
#define Reve(a) reverse(a.begin(), a.end())
#define PI 3.14159265359
typedef long long ll;
const ll MOD = 1e9+7;

ll gcd(ll a, ll b){
  if(b==0) return a;
  return gcd(b, a%b);
}
/*ll myPow(ll x, ll n, ll m){
  if(n == 0)
    return 1;
  if(n % 2 == 0)
    return myPow(x * x % m, n / 2, m);
  else
    return x * myPow(x, n - 1, m) % m;
}*/

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

//素数判定 O(√n)
bool is_prime(int64_t n){
  for(int64_t i = 2; i*i<=n; i++){
    if(n%i==0) return false;
  }
  return n!=1;
}

//約数の列挙 O(√n)
vector<int64_t> dividor(int64_t n){
  vector<int64_t> res;
  for(int64_t i=1; i*i<=n; i++){
    if(n%i==0){
      res.push_back(i);
      if(i != n/i) res.push_back(i);
    }
  }
  return res;
}

//素因数分解 O(√n)
map<int64_t, int64_t> prime_factor(int64_t n){
  map<int64_t, int64_t> res;
  for(int64_t i=2; i*i<=n; i++){
    while(n%i==0){
      res[i]++;
      n /= i;
    }
  }
  if(n != 1) res[n] = 1;
  return res;
}
struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    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の根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

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



int main(){
  /*int n;
  cin >> n; 
  vector<int> A(n);
  rep(i, n) cin >> A[i];*/ 
  int n, k, d, a; cin >> n >> k;
  vector<int> A(n);
  rep(i, k){
    cin >> d;
    rep(j, d){
      cin >> a;
      A[a-1]++;
    }
  }
  int ans = 0;
  rep(i, n){
    if(A[i]==0) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3636
N = int(input())
h = [int(i) for i in input().split()]

def check(l):
    for i, n in enumerate(l):
        if n == 0:
            yield i

def f(l):
    # print("a", l)

    a = min(l)
    l_ = [i - a for i in l]
    m = [-1]
    m.extend(list(check(l_)))
    m.append(len(l))

    # print(" ", a, l_, m)
    if not any(l):
        return a

    s = 0
    for x, y in zip(m, m[1:]):
        if y - x > 1:
            s += f(l_[x+1:y])
    return s + a

print(f(h))

Measured memory_bytes: 3188
<?php
list($n, $y) = explode(" ", trim(fgets(STDIN)));
for($a = 0; $a <= $n; $a++){
    for($b = 0; $b <= $n - $a; $b++){
        if($a * 10000 + $b * 5000 + ($n-$a-$b)*1000 == $y){
            echo $a." ".$b." ".($n-$a-$b);
            exit;
        }
    }
}
echo "-1 -1 -1";

Measured memory_bytes: 4728
#include<bits/stdc++.h>
using namespace std;
template<typename T>
inline void read(T &x)
{
	x=0;
	int f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9')
	{
		if(ch=='-') f=-1;
		ch=getchar();
}
	while(ch>='0'&&ch<='9') x=x*10+(ch^48),ch=getchar();
	x*=f;
	return;
}	
template<typename T>
void write(T x)
{
	if(x<0) putchar('-'),x=-x;
	if(x>=10) write(x/10);
	putchar(x%10+'0');
	return;
}
string s;
int main()
{
    cin>>s;
    for(int i=0;i<s.length();i++)
    if(i%2==0&&s[i]!='h'||i%2==1&&s[i]!='i')
    {
        cout<<"No"<<endl;
        return 0;
    }
    if(s.length()%2!=0)
    {
        cout<<"No"<<endl;
        return 0;
    }
    cout<<"Yes"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>
#define rep(i,n) for(int i = 0; i < n; i++)
typedef long long ll;
using namespace std;
#define llMAX numeric_limits<long long>::max()
#define intMAX numeric_limits<int>::max()
#define d_5 100000
#define d9_7 1000000007
#define vll vector<vector<long long>>
#define vl vector<long long>
#define vi vector<int>
#define vii vector<vector<int>>
#define pb push_back
#define pf push_front
int main(void){
  ll n,k;
  cin>>n>>k;
  vl x(n);
  vl y(n);
  vector<char> c(n);
  vll result(k*2,vl(k*2,0));//左上、の集合を記録
  rep(i,n){
    cin>>x[i]>>y[i]>>c[i];
  }
  rep(i,n){
    x[i]%=k*2;
    y[i]%=k*2;
    if(c[i]=='B'){
      x[i]+=k;
      x[i]%=2*k;
      //cout<<"e";
    }
    //cout<<"l";
    /*rep(ii,k){
      rep(j,k){
        int i2=k/2-ii+2*k;
        int j2=k/2-j+2*k;
        result[(i2+y[i])%(2*k)][(j2+x[i])%(2*k)]++;
      }
    }*/
    result[y[i]][x[i]]++;
  }
  vll result2(k*3,vl(k*3,0));
  rep(i,k*2){
    rep(j,k*2){
      result2[i][j]+=result[i][j];
      result2[(i+k)][(j+k)]+=result[i][j];
      result2[i][(j+k)]-=result[i][j];
      result2[(i+k)][j]-=result[i][j];
    }
  }
  //二次累積和
  rep(i,3*k){
    rep(j,3*k-1){
      result2[i][(j+1)]+=result2[i][(j)];
    }
  }
  rep(j,3*k){
    rep(i,3*k-1){
      result2[(i+1)][j]+=result2[(i)][j];
    }
  }
  //同じ部分をまとめる
  rep(i,k){
    rep(j,k){
      ll i2=i+k;
      ll j2=j+k;
      result2[i][j]+=result2[i2][j2];
      i2=i;
      j2=j+2*k;
      result2[i][j]+=result2[i2][j2];
      i2=i+2*k;
      j2=j;
      result2[i][j]+=result2[i2][j2];
      i2=i+2*k;
      j2=j+2*k;
      result2[i][j]+=result2[i2][j2];
    }
  }
  rep(i,k){
    rep(j,k){
      ll i2=i+k;
      ll j2=j;
      result2[i][j+k]+=result2[i2][j2];
      i2=i+2*k;
      j2=j+k;
      result2[i][j+k]+=result2[i2][j2];
      i2=i+k;
      j2=j+2*k;
      result2[i][j+k]+=result2[i2][j2];
    }
  }
  ll ans=0;
  rep(i,k){
    rep(j,k*2){
      ans=max(ans,result2[i][j]);
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 103680
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;

vector<pint> vp[500001];
int d[100001];
int inf=1000100010;
int v;
int dijkstra(int st){
    priority_queue<pint,vector<pint>,greater<pint> > pq;
    rep(i,v) d[i]=inf;
    d[st]=0;
    pq.push(make_pair(0,st));
    while(!pq.empty()){
        pint pi=pq.top();pq.pop();
        int t=pi.second;
        for(vector<pint>::iterator it=vp[t].begin();it!=vp[t].end();++it){
            if(d[it->second]>d[t]+it->first){
                d[it->second]=d[t]+it->first;
                pq.push(make_pair(d[it->second],it->second));
            }
        }
    }
}
int main(){
    int e,r,s,t,ds;
    cin>>v>>e>>r;
    rep(i,e){
        cin>>s>>t>>ds;
        vp[s].pb(mp(ds,t));
    }
    dijkstra(r);
    rep(i,v){
        if(d[i]<inf) cout<<d[i]<<endl;
        else cout<<"INF"<<endl;
    }
    return 0;
}

Measured memory_bytes: 22376
from itertools import product

# input
N, M = map(int, input().split())
switch = {}
for i in range(M):
    inp = list(map(int, input().split()))
    switch[i] = {
        "k": inp[0],
        "s": inp[1:]
    }
inp = list(map(int, input().split()))
for i, p in enumerate(inp):
    switch[i]["p"] = p

# check
case = list(product([0, 1], repeat=N))
for k in switch.keys():
    
    case = [
        c
        for c in case
        if sum(
            [
                n
                for i, n in enumerate(c)
                if i + 1 in switch[k]["s"]
            ]
        ) % 2 == switch[k]["p"]
    ]

    if len(case) == 0:
        break

print(len(case))

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

int main(){
  int N,A,B,C;
  cin >> N >> A >> B;
  C=abs(A-B);
  if(C%2==0){
    cout << "Alice" << endl;
  }
  else{
    cout << "Borys" << endl;
  }
}
    
  

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

typedef long long ll;
typedef unsigned long long ull;
#define endl "\n";
#define FASTER ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define POSITIVE_INFINITY 9223372036854775807
#define NEGATIVE_INFINITY -9223372036854775807
#define MOD 1000000007

int main()
{
    FASTER;

    int n, x, y;
    cin >> n >> x >> y;
    int cnt = 0;
    for (int i = 0; i < n; i++){
        int a, b;
        cin >> a >> b;
        if (x <= a && y <= b)
            cnt++;
    }
    cout << cnt << endl;

    return 0;
}


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

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()
#define endl "\n"

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
typedef long long ll;

void solve() {
    set<string> st;
    int N;
    cin >> N;
    REP(_,N) {
        string cmd, val;
        cin >> cmd >> val;
        if(cmd == "insert") {
            st.insert(val);
        } else {
            cout << ((st.count(val)) ? "yes" : "no") << endl;
        }
    }
}

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


Measured memory_bytes: 32124
#include <iostream>
#include <algorithm>
#include <string> 
#include <vector>
#include <iomanip>
#include <math.h>
#include <map>
using namespace std;

int main()
{
	string S;
	cin >> S;
	int count = 0;
	for (int i = 0; i < 4; i++) {
		if (S[i] == '2') {
			count++;
		}
	}
	cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(x) x.begin(),x.end()

int const N = 200001;
int n, v[N];

int main(){
    scanf("%d", &n);
    bool yes = true;
    for(int i = 0; i<n; ++i){
        scanf("%d", &v[i]);
        if(v[i] & 1 ^ 1){
            if(v[i] % 3 == 0 || v[i] % 5 == 0)continue;
            yes = false;
        }
    }
    if(yes)puts("APPROVED");
    else puts("DENIED");
} 

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

using namespace std;

long long n,k,h[200005],zr;

bool msf (long long a, long long b){
	return a>b;
}

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

cin >> n >> k;

for (int i = 0; i<n; i++)
	cin >> h[i];
	
sort (h,h+n,msf);

int q = 0;

for (int i = 0; i<k; i++)
	h[i] = 0;

sort (h,h+n);

for (int i = 0; i<n; i++)
	zr+= h[i];

cout << zr;

return 0;
}



Measured memory_bytes: 1792
#include<iostream>
using namespace std;
int main(){
    string N;
    cin>>N;
    int cont=1;
    for(int i=1;i<N.size();i++){
        if(N[i-1]==N[i])cont++;
        else cont=1;
        if(cont==3)break;
    }
    if(cont==3)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
n=int(input())
AB=[list(map(int,input().split())) for i in range(n)]
AB.sort(key=lambda A:A[1])
flag=0
cnt=0
for i in range(n):
    cnt+=AB[i][0]
    if cnt>AB[i][1]:
        flag=1
print('Yes' if flag==0 else 'No')

Measured memory_bytes: 53660
import sys
from math import ceil, floor, sqrt, sin, cos, pi
from itertools import accumulate, permutations, combinations
from fractions import gcd # 最大公約数
from collections import deque, Counter
from operator import itemgetter
from heapq import heappop,heappush
sys.setrecursionlimit(10**7)
def lcm(x, y): return ((x * y) // gcd(x, y)) # 最小公倍数
# list(map(int, input().split()))
n = int(input())
v = list(map(float, input().split()))

v.sort()
ans = v[0]
for i in range(1, n):
    ans = (ans + v[i])/2
print(ans)

Measured memory_bytes: 5048
#include <bits/stdc++.h>
using namespace std;
#define rep(i,j,k) for(int i = (int)j;i <= (int)k;i ++)
#define debug(x) cerr<<#x<<":"<<x<<endl
#define pb push_back

typedef long long ll;
typedef pair<int,int> pi;
const int MAXN = (int)1e6+7;

int N,K;
ll sum = 0;
int a[MAXN];
int b[MAXN];

bool OK(int m) {
    rep(i,1,N) {
        b[i] = a[i]%m;
    }
    sort(b+1,b+1+N);
    int l = 1,r = N;
    ll ci = 0;
    while (l < r) {
        if (b[l] == 0) {
            l ++;
            continue;
        }
        int gi = min(b[l],m-b[r]);
        b[l] -= gi;
        b[r] += gi;
        ci += gi;
        if (b[r] == m) r --;
        if (b[l] == 0) l ++;
    }
    if (ci <= K) return true;
    else         return false;
}

int main()
{
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    cin >> N >> K;
    rep(i,1,N) {
        cin >> a[i];
        sum += a[i];
    }
    int ans = 1;
    int sq = sqrt(sum+0.5);
    rep(i,2,sq) {
        if (sum%i==0) {
            if (OK(i))     ans = max(ans,i);
            if (OK(sum/i)) ans = max(ans,(int)sum/i);
        }
    }
    if (OK(sum)) ans = sum;
    cout << ans << endl;
}


Measured memory_bytes: 2304
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#define SF scanf
#define PF printf
#define MAXN 100010
using namespace std;
struct node{
	int x;
	node *nxt;	
}edge[MAXN*2];
node *head[MAXN],*ncnt=edge;
int son[MAXN],n;
void add_edge(int x,int y){
	ncnt++;
	ncnt->x=y;
	ncnt->nxt=head[x];
	head[x]=ncnt;
}
bool ans;
void dfs(int x,int f){
	int flag=0;
	for(node *v=head[x];v!=NULL;v=v->nxt){
		int u=v->x;
		if(u==f)
			continue;
		dfs(u,x);
		if(son[u]==1)
			flag++;	
	}
	if(flag>1){
		ans=1;
		return ;	
	}
	if(flag==1)
		son[x]=0;
	else
		son[x]=1;
}
int main(){
	int u,v;
	SF("%d",&n);
	for(int i=1;i<n;i++){
		SF("%d%d",&u,&v);
		add_edge(u,v);
		add_edge(v,u);
	}
	dfs(1,0);
	if(son[1]==1)
		ans=1;
	if(ans==1)
		PF("First");
	else
		PF("Second");
}

Measured memory_bytes: 4480
fun main(args: Array<String>) {
    val mod = 998244353L
    val n = readLine()!!.toInt()
    val d = readLine()!!.split(" ").map { it.toInt() }
    if (d[0] != 0 || d.count { it == 0 } != 1) {
        println(0)
        return
    }
    val da = IntArray(n)
    d.forEach { da[it]++ }
    var ans = 1L
    val max = d.max()!!
    for(i in 1..max){
        for (j in 1..da[i]) {
            ans *= da[i - 1].toLong()
            ans %= mod
        }
    }
    println(ans)
}

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

int main()
{
  int n, i, x, mil=-1, ans=0;
  vector<int> v;
  cin>>n;
  for(i=0; i<n; i++){
    cin>>x;
    v.push_back(x);
  }
  ans=1;
  mil=v[0];
  for(i=1; i<n; i++){
    if(mil>v[i]){
    	ans++;
      	mil = v[i];
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int i = n / 100;
  int j = n % 100;
  bool flg = 1 <= i && i <= 12;
  bool glg = 1 <= j && j <= 12;
  string ret;
  if (flg && glg) ret = "AMBIGUOUS";
  else if (flg && !glg) ret = "MMYY";
  else if (!flg && glg) ret = "YYMM";
  else ret = "NA";
  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 256
uu = list(map(int,input().split()))
h = uu[0]
w = uu[1]
arr = []
for i in range(0, h):
    arr.append(list(map(lambda x: x == "#", list(input()))))
res = True
for i in range(0, (h - 1)):
    for j in range (0, (w - 1)):
        if arr[i][j]:
            if not(arr[i + 1][j] or arr[i][j + 1] or arr[i - 1][j] or arr[i][j - 1]):
                res = False
                break
    if not res:
        break
if res:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
int main() {
 ll A,B,C,X;
  cin>>A>>B>>C>>X;
  ll ans=0;
  for(ll i=0;i<=A;i++) {
for(ll j=0;j<=B;j++) {
  for(ll h=0;h<=C;h++) {
    if(500*i+100*j+50*h==X) {
ans++;
    }
  }
}
  }
  
  
  
  cout<<ans<<endl;
}

  

Measured memory_bytes: 3644
// Standard I/O
#include <iostream>
#include <sstream>
#include <cstdio>
// Standard Library
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
// Template Class
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
// Container Control
#include <algorithm>

using namespace std;

#define rep( i, n ) for( int i = 0; i < n; ++i )
#define irep( i, n ) for( int i = n-1; i >= 0; --i )
#define reep( i, s, n ) for ( int i = s; i < n; ++i )
#define ireep( i, n, s ) for ( int i = n-1; i >= s; --i )
#define foreach(itr, x) for( typeof(x.begin()) itr = x.begin(); itr != x.end(); ++itr)

#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define all( v ) v.begin(), v.end()
#define fs first
#define sc second
#define vc vector

// for visualizer.html
double SCALE = 1.0;
double OFFSET_X = 0.0;
double OFFSET_Y = 0.0;
#define LINE(x,y,a,b) cerr << "line(" << SCALE*(x) + OFFSET_X << ","	\
	<< SCALE*(y) + OFFSET_Y << ","										\
	<< SCALE*(a) + OFFSET_X << ","										\
	<< SCALE*(b) + OFFSET_Y << ")" << endl;
#define CIRCLE(x,y,r) cerr << "circle(" << SCALE*(x) + OFFSET_X << ","	\
	<< SCALE*(y) + OFFSET_Y << ","										\
	<< SCALE*(r) << ")" << endl;

typedef long long ll;
typedef complex<double> Point;

typedef pair<int, int> pii;
typedef pair<int, pii> ipii;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector< vector<int> > vii;
typedef vector< vector<double> > vdd;

typedef vector<int>::iterator vi_itr;

const int IINF = 1 << 28;
const int MOD = 1e9+7;
const double INF = 1e30;
const double EPS = 1e-10;
const double PI = acos(-1.0);

// Direction : L U R D
const int dx[] = { -1, 0, 1, 0};
const int dy[] = { 0, -1, 0, 1 };

int gcd ( int x, int y ) {
    if ( y == 0 ) return x;
    return gcd(y, x%y);
}

int main()
{
    int n, k;
    int a[100000];

    cin >> n >> k;
    rep(i, n) cin >> a[i];

    sort(a, a+n);

    if ( a[n-1] < k ) {
        cout << "IMPOSSIBLE" << endl;
        return 0;
    }

    int x = a[0];
    set<int> s;
    rep(i, n) {
        x = gcd(x, a[i]);
    }

    bool ans = false;
    rep(i, n) {
        int c = (a[i] - k) / x;
        if ( c < 0 ) continue;

        if ( c*x == a[i] - k ) {
            ans = true;
            break;
        }
    }

    cout << (ans ? "POSSIBLE" : "IMPOSSIBLE") << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <string>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <tuple>
#include <numeric>
#include <functional>
#include <unordered_map>

using namespace std;

/*-----------------------------------------------------------------------------
　定義
 -------------------------------------------------------------------------------*/
#define ALL(a)			(a).begin(),(a).end()
#define REP(i, n)		for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n)	for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define INF				2e9
#define MOD				(1000 * 1000 * 1000 + 7)
#define Ceil(x, n)		(((((x))+((n)-1))/n))		/* Nの倍数に切り上げ割り算 */
#define CeilN(x, n)		(((((x))+((n)-1))/n)*n)		/* Nの倍数に切り上げ */
#define FloorN(x, n)	((x)-(x)%(n))				/* Nの倍数に切り下げ */
#define IsOdd(x)		(((x)&0x01UL) == 0x01UL)			
#define IsEven(x)		(!IsOdd((x)))						
#define M_PI			3.14159265358979323846
typedef long long		ll;
typedef pair<ll, ll>	P;

/*-----------------------------------------------------------------------------
　処理
 -------------------------------------------------------------------------------*/
int main()
{
	int N;
	cin >> N;
	vector<int> t(N + 1, 0), x(N + 1, 0), y(N + 1, 0);
	REPN(i, 1, N + 1) {
		cin >> t[i] >> x[i] >> y[i];
	}

	string ans = "Yes";
	REP(i, N) {
		int diff = abs(x[i + 1] - x[i]) + abs(y[i + 1] - y[i]);
		int nokori = (t[i + 1] - t[i]) - diff;
		if (nokori < 0 || IsOdd(nokori)) {
			ans = "No";
			break;
		}
	}

	cout << ans << endl;
	return 0;

}


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

int main(){
  vector<string> week = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
  string s; cin >> s;
  for (int i = 0; i < 7; i++){
    if (s == week.at(i)){
      cout << 7-i << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.ArrayList;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        Dice dice = new Dice(sc);
        int x = sc.nextInt();
        for(int i = 0; i < x; i++){
            int up = sc.nextInt();
            int front = sc.nextInt();
            for(int j = 0; j < 2; j++){
                if(dice.dice.get(0) == up){
                    break;
                }
                for(int k = 0; k < 3; k++){
                    if(dice.dice.get(0) == up){
                        break;
                    }else if(j == 0){
                        dice.roll('N');
                    }else{
                        dice.roll('W');
                    }
                }
            }
            while(dice.dice.get(1) != front){
                dice.zroll();
            }
            System.out.println(dice.dice.get(2));
        }
    }
}

class Dice{
    // dice<> 0??? 1??? 2??± 3?\? 4??? 5???
    static ArrayList<Integer> dice = new ArrayList<>();
    static final int[] EAST = {2,5,3,0};
    static final int[] WEST = {3,5,2,0};
    static final int[] SOUTH = {1,5,4,0};
    static final int[] NORTH = {4,5,1,0};
    static final int[] Z = {2,4,3,1};
    static Integer g;
    
    public Dice(Scanner sc){
        for(int i = 0; i < 6; i++){
            dice.add(sc.nextInt());
        }
    }
    public static void roll(char point){
        g = dice.get(0);
        switch(point){
            case 'E':
                for(int i:EAST){
                    g = dice.set(i,g);
                } break;
            case 'W':
                for(int i:WEST){
                    g = dice.set(i,g);
                } break;
            case 'S':
                for(int i:SOUTH){
                    g = dice.set(i,g);
                } break;
            case 'N':
                for(int i:NORTH){
                    g = dice.set(i,g);
                } break;
            default:
        }
    }
    public static void zroll(){
        g = dice.get(1);
        for(int i:Z){
            g = dice.set(i,g);
        }
    }
}

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

int main(){
    vector<vector<int>> c(3,vector<int>(3));
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            cin >> c[i][j];
        }
    }
    bool is_res = true;
    vector<int> a(3),b(3);
    a[0] = 0;
    for(int j=0;j<3;j++)b[j] = c[0][j] - a[0];
    a[1]=c[1][0]-b[0];
    a[2]=c[2][0]-b[0];
 
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            if(a[i]+b[j] != c[i][j])is_res = false;
        }
    }
    if(is_res)cout << "Yes"<< endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
)

func main() {
	var N, a, b int
	fmt.Scan(&N)
	arr := make([]int, N)
	for i := range arr {
		fmt.Scan(&arr[i])
	}
	sort.Sort(sort.Reverse(sort.IntSlice(arr)))
	for i := 0; i < N; i++ {
		if i%2 == 0 {
			a += arr[i]
		} else {
			b += arr[i]
		}
	}
	fmt.Println(a - b)

}

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

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

    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= n - i; j++) {
            int k = n - i - j;
            if (10000 * i + 5000 * j + 1000 * k == y) {
                cout << i << " " << j << " " << k << endl;
                return 0;
            }
        }
    }
    cout << "-1 -1 -1" << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int a = scanner.nextInt();
		int[][][] list = new int[4][3][10];
		for (int i = 0; i < a; i++) {
			int b = scanner.nextInt() - 1;
			int c = scanner.nextInt() - 1;
			int d = scanner.nextInt() - 1;
			int e = scanner.nextInt();
			list[b][c][d] += e;
		}

		for (int i = 0; i < 4; i++) {
			for (int j = 0; j < 3; j++) {
				for (int k = 0; k < 10; k++) {
					System.out.print(" " + list[i][j][k]);
				}
				System.out.println();
			}
			if (i != 3)
				System.out.println("####################");
		}

	}
}

Measured memory_bytes: 21080
#include <stdio.h>

int main(void) {
	int a, b;
	scanf("%d %d", &a, &b);
	if (a == b)
	{
		printf("a == b\n");
	}
	else if (a > b)
	{
		printf("a > b\n");
	}
	else if (a < b)
	{
		printf("a < b\n");
	}
	return 0;
}

Measured memory_bytes: 580
#include<bits/stdc++.h>
using namespace std;
int main(){
  ios_base::sync_with_stdio(false);cin.tie(0);
  char c1;
  char c2;
  char c3;
  set<char> s;
  cin>>c1;
  cin>>c2;
  cin>>c3;
  s.insert(c1);
  s.insert(c2);
  s.insert(c3);
  if(s.size() > 1){
    cout<<"Yes"<<'\n';
  }else{
    cout<<"No"<<'\n';
  }  
}

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

#define int long long
#define F first
#define S second
#define all(x) (x).begin(), (x).end()
#define allrev(x) (x).rbegin(), (x).rend()
#define pb push_back
#define pf push_front
#define fori(i, a, n) for(int i = a; i < n; ++i)
#define MAX(x) (*max_element(all(x)))
#define MIN(x) (*min_element(all(x)))
#define sortarr(a, n) sort(a, a + n)
#define sortvec(V) sort(all(V))

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

typedef unordered_map<int, int, custom_hash> u_map;
typedef unordered_set<int, int, custom_hash> u_set;
typedef vector<int> V;
typedef pair<int , int> pairi;
typedef set<int> seti;
typedef priority_queue<int> p_queue;
typedef deque<int> deqi;

const int MOD = 1e9+7;
const int INF = 1e9+8;
const double pi = 3.14159265359;

int binpow(int a, int b, int m) {
    a %= m;
    int res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}

void solve()
{
    int x, k, d, ans = 0;
    cin >> x >> k >> d;
    if(x < 0)   x = -x;
    int m = x/d;
    if(m >= k)  m = k;
    ans = x - d * m;
    k -= m;
    if(k % 2)   cout << abs(ans - d) << endl;
    else cout << ans << endl;
}

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    solve();
    cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n ";
}

Measured memory_bytes: 3732
#include "bits/stdc++.h"
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(s) s.begin(), s.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;
const ll mod = 1e9+7;

string s;

int main()
{
    cin >> s;
    if(s.substr(0,4) == "YAKI") puts("Yes");
    else puts("No");
}


Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;

using ll = long long;
using ld = long double;
const int INF = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

int main()
{
  long long N;
  scanf("%lld", &N);
  long long M;
  scanf("%lld", &M);
  std::vector<long long> A(M);
  std::vector<long long> B(M);
  vector<vector<int>> graph(N);
  for (int i = 0; i < M; i++)
  {
    scanf("%lld", &A[i]);
    scanf("%lld", &B[i]);
    A[i]--;
    B[i]--;
    graph[A[i]].push_back(B[i]);
    graph[B[i]].push_back(A[i]);
  }

  vector<bool> checked(N);
  auto dfs = [&](auto dfs, int v, vector<vector<int>> &graph, vector<bool> &checked, int &cnt) -> void {
    checked[v] = true;
    cnt++;
    for (auto &e : graph[v])
    {
      if (!checked[e])
      {
        dfs(dfs, e, graph, checked, cnt);
      }
    }
  };

  int ans = 0;
  for (int i = 0; i < N; ++i)
  {
    int cnt = 0;
    if (!checked[i])
    {
      dfs(dfs, i, graph, checked, cnt);
    }
    ans = max(ans, cnt);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 29744
#include<iostream>
using namespace std;
int main(){
  int N,S=0,a[10],b=0,c=0;
  cin>>N;
  for(long i=1;i<=1000000000;i*=10){
     if(N>=i*10){
       a[b]=N%(i*10);
       if(b==0)S+=a[b];
       else S+=(a[b]-a[b-1])/i;
	   c++;
     }
	 else if(c==b)S+=(N-a[b-1])/i;
    b++;
  }
  
  if(N%S==0)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(int argc, char const *argv[]) {
    int n;
    cin >> n;
    int a[n];

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

    int cnt=0;

    for(int i=0;i<n;i++){
        while(1){
            if(a[i]%2 == 0){
                a[i] /= 2;
                cnt++;
            }else {
                break;
            }
        }
    }

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
  long int ans=1,n,k,a,b;
  scanf("%ld %ld %ld",&k,&a,&b);
  if((2+a)<=b){
    n = k-(a-1);
    ans+=k-n;
    if(n%2==0){
      n/=2;
      ans+=(b-a)*n;
    }else{
      n/=2;
      ans+=(b-a)*n+1;
    }
  }else{
    ans=k+1;
  }
  printf("%ld\n",ans);
  return 0;
}

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

int abs(int x){
    return x>0?x:-x;
}

int main(){
    int n;
    cin>>n;
    vector<int> w(n);
    int sum=0;
    for(int i=0; i<n; i++){
        cin>>w[i];
        sum+=w[i];
    }
    vector<int> sa(n-1);
    for(int i=0; i<n-1; i++){
        int l=0;
        for(int j=0; j<=i; j++){
            l+=w[j];
        }
        sa[i]=abs(l-(sum-l));
    }
    int ans=1e5;
    for(int i=0; i<n-1; i++){
        ans=min(ans,sa[i]);
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a;
  cin>>a;
  int l,m,n;
  l=a%10;
  m=(a%100)/10;
  n=a/100;
  if(m==7 || l==7 || n==7)
  cout<<"Yes"<<endl;
  else
  	cout<<"No"<<endl;
  return 0;
}
  

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

struct point{
  double x, y;
};

void koch(int n, point p1, point p2){
  point  p3, p4, p5;
  double rad60=M_PI*60.0/180.0;
  
  if(n==0) return;
  
  p3.x=(2.0*p1.x+p2.x)/3.0;
  p3.y=(2.0*p1.y+p2.y)/3.0;

  p4.x=(p1.x+2.0*p2.x)/3.0;
  p4.y=(p1.y+2.0*p2.y)/3.0;

  p5.x=(p4.x-p3.x)*cos(rad60)-(p4.y-p3.y)*sin(rad60)+p3.x;
  p5.y=(p4.x-p3.x)*sin(rad60)+(p4.y-p3.y)*cos(rad60)+p3.y;

  koch(n-1, p1, p3);
  printf("%.8f %.8f\n", p3.x, p3.y);
  koch(n-1, p3, p5);
  printf("%.8f %.8f\n", p5.x, p5.y);
  koch(n-1, p5, p4);
  printf("%.8f %.8f\n", p4.x, p4.y);
  koch(n-1, p4, p2);
}

int main(void){
  int n;
  point p1, p2;
  
  scanf("%d", &n);

  p1.x=0.0; p1.y=0.0;
  p2.x=100.0; p2.y=0;
  
  printf("%.8f %.8f\n", p1.x, p1.y);
  koch(n, p1, p2);
  printf("%.8f %.8f\n", p2.x, p2.y);
  
  return 0;
}


Measured memory_bytes: 3152
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(), (c).end());
const long long MOD = 1e9 + 7;
typedef long long ll;

int char_to_int(char c){
	return c - '0';
}

int main(){
	string S;
	cin >> S;
	int ans = 1e8;
	for(int i = 0; i < S.size() - 2; i++){
		int a = char_to_int(S[i]) * 100;
		int b = char_to_int(S[i + 1]) * 10;
		int c = char_to_int(S[i + 2]);
		int X = a + b + c;
		ans = min(ans, abs(X - 753));
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cassert>
#include <complex>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <sstream>
#include <ctime>
#include <cctype>
#include <set>
#include <map>
#include <queue>
#include <bitset>
#include <deque>
#include <stack>
#include <memory.h>
using namespace std;
#define ll long long
int n,m;
vector<int> to;
bool ok[200010];
int main()
{
	memset(ok,0,sizeof(ok));
	cin>>n>>m;
	for(int i=0;i<m;i++){
		int x,y;
		cin>>x>>y;
		if(x==1&&y==n){
			cout<<"POSSIBLE";
			return 0;
		}
		if(x==1){
			ok[y]=1;
		}
		if(y==n){
			to.push_back(x);
		}
	}
	for(int i=0;i<to.size();i++){
		if(ok[to[i]]){
			cout<<"POSSIBLE";
			return 0;
		}
	}
	cout<<"IMPOSSIBLE";
    return 0;
}

Measured memory_bytes: 1020
#include<cstdio>
int a,b,c,d;
int main(){
	scanf("%d",&a);c=64;
	for(int i=1;i<=a;i++){
		scanf("%d",&b);d=0;
		while(b==((b>>1)<<1)) d++,b>>=1;
		if(c>d) c=d;
	}printf("%d\n",c);
}

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

using namespace std;

void solve()
{
	int N, K;
	cin >> N >> K;
	unsigned long long int ans = K;
	for (int i = 1; i < N; ++i)
	{
		ans *= (K - 1);
	}
	cout << ans << endl;
}

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

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

int main() {
#ifdef DEBUG
  ifstream ifs("in.txt");
  cin.rdbuf(ifs.rdbuf());
#endif
  int N, K;
  while (cin >> N >> K) {
    ll res = K;
    for (int i = 0; i < N - 1; i++) res *= (K - 1);
    cout << res << endl;
  }
  return 0;
}


Measured memory_bytes: 256