akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cstdio>

using namespace std;

int main(){
    int n,m,k;

    while(cin >> n >> m >> k){
        if((n|m|k) == 0) break;
        double dp[n+1][n*m+1];

        fill((double *)dp, (double *)dp+(n+1)*(n*m+1), 0);

        dp[0][0] = 1;

        for(int i=0;i<n;i++){
            for(int j=0;j<=n*m;j++){
                for(int l=1;l<=m;l++){
                    if(j+l <= n*m){
                        dp[i+1][j+l] += dp[i][j] / m;
                    }
                }
            }
        }
        double ret = 0;

        for(int i=0;i<=n*m;++i){
            ret += dp[n][i] * max(1,(i-k));
        }
        printf("%.8f\n", ret);
    }
}

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

int main(){
	ll n,k;
	cin >> n >> k;
	vector<ll> a(n);
	rep(i,n) cin >> a[i];
	for (int i = k; i < n; ++i) {
		if(a[i-k] < a[i]) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
    return 0;
}



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

int main(){
    int n, k;
    cin >> n >> k;
    int h[100100] = {};
    for(int i=0; i<n; i++){
        cin >> h[i];
    }
    sort(h, h+n);
    int ans = INT_MAX;
    int tmp = INT_MAX;
    for(int i=0; i<=n-k; i++){
        tmp = h[k+i-1]-h[i];
        ans = min(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>
#include <iomanip>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9 + 7);

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

template<typename T> 
T lcm(T a, T b) {
	return (a / gcd(a, b)) * b;
}

int main(void) {
	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	
	ll l = lcm(c, d);
	ll na = a - 1LL;
	na -= ((a - 1LL) / c + (a - 1LL) / d);
	na += (a - 1LL) / l;
	
	ll nb = b;
	nb -= (b / c + b / d);
	nb += b / l;
	
	cout << nb - na << endl;
	
	return 0;
}


Measured memory_bytes: 3644
/*..........AAKASH GOYAL............*/
/*............DAIICT................*/
#pragma GCC optimize("O3", "unroll-loops")
#pragma GCC target("avx2")
#include <bits/stdc++.h>
using namespace std;

#define    int                      long long int

#define    f(i,j,n)                 for(int i = j; i <= n; i++)
#define    r(i,n,j)                 for(int i = n; i >= j; i--)
#define    mod                      1000000007
#define    speed                    ios_base::sync_with_stdio(false);
#define    upp                      cin.tie(NULL);
#define    pb                       push_back
#define    mp                       make_pair
#define    T                        int tt; cin >> tt; while(tt--)
#define    ff                       first
#define    ss                       second
#define    all(container)           container.begin() , container.end()
#define    sz(container)            (int)container.size()
#define    pii                      pair <int , int>
#define    pll                      pair <long long int , long long int>
#define    ppl                      pair <int , pii>               
#define    sp(x)                    setprecision(x)

int fen[300000];
void update(int x,int val)
{
    for(;x<=200009;x+=x&-x)
        fen[x]+=val;
}
int query(int x)
{
    int sum=0;
    for(;x>0;x-=x&-x)
        sum+=fen[x];
    return sum;
}

int32_t main()
{
    speed upp
    int n,d,k,x,y,c,ans=0;
    cin>>n>>d>>k;
    vector<pii>v;
    map<int,int>m,id;
    m[1e18]=0;
    id[1e18]=200005;
    map<int,int>:: iterator it;
    f(i,1,n)
    {
        cin>>x>>y;
        v.pb(mp(x,y));
    }
    sort(all(v));
    f(i,0,n-1)
    {
        it=m.lower_bound(v[i].ff);
        int sum=0;
        if(i>0)
        {
            int s=id[it->first];
            // cout<<s<<"   ";
            sum=query((int)200005)-query(s-1);
        }
        v[i].ss-=sum*k;
        if(v[i].ss>0)
        {
            c=(v[i].ss + k -1)/k;
            ans+=c;
            m[v[i].ff + 2*d]=c;
            update(i+1,c);
            id[v[i].ff + 2*d]=i+1;
        }
    }
    cout<<ans;
}


Measured memory_bytes: 30188
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

int main(){
  int n,m,x;
  cin>>n>>m>>x;
  int a=0,b=0;
  rep(i,0,m){
    int c;
    cin>>c;
    if(c<x) a++;
    else b++;
  }
  cout<<min(a,b)<<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)

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; }

typedef long long ll;
typedef pair<int, int> P;

const int MAX = 200005;
const int INF = 1001001001;
const int MOD = 1000000007;

ll dp[3005][3005][2];
bool flg[3005][3005][2];

ll f(int i, int j, bool k, vector<int> &A) {
    if (flg[i][j][k]) return dp[i][j][k];
    if (i == j) {
        if (k) {
            flg[i][j][k] = 1;
            return dp[i][j][k] = -A[i];
        } else {
            flg[i][j][k] = 1;
            return dp[i][j][k] = A[i];
        }
    }
    ll res = 0;
    if (k) {
        res = min(f(i+1, j, 0, A) - A[i], f(i, j-1, 0, A) - A[j]);
    } else {
        res = max(f(i+1, j, 1, A) + A[i], f(i, j-1, 1, A) + A[j]);
    }
    flg[i][j][k] = 1;
    return dp[i][j][k] = res;
}

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

    vector<int> A(N);
    for (int &i : A) cin >> i;

    cout << f(0, N-1, 0, A) << endl;
}

Measured memory_bytes: 158208
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int h=0, w=0;
		while (true) {
			int H = sc.nextInt();
			int W = sc.nextInt();
			if (H == 0 && W == 0){
				break;
			}
			for (h = 0; h < H; h++) {
				for (w = 0; w < W; w++) {
					System.out.print("#");
				}
				System.out.println("");
			}
			System.out.println("");
		}

	}

}

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

using namespace std;

int main() {

    int h, w;
    cin >> h >> w;

    vector<string> s;
    string temp;

    for (int i = 0; i < h; i++){
        cin >> temp;
        s.push_back(temp);
    }

    for (int i = 0; i < h; i++){
        cout << s[i] << endl;
        cout << s[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#define rep(i, a, n) for(int i = a; i < n; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int mod = 1e9+7;

template <class Type> Type gcd(Type a, Type b){
    return b ? gcd(b, a%b) : a;
}
template <class Type> Type lcm(Type a, Type b){
    return a*b/gcd(a, b);
}

int main()
{
    int n;
    cin >> n;
    vector<int> p(n);
    int mn = 1e9;
    int ans = 0;
    rep(i, 0, n){
        cin >> p[i];
        
        if(p[i] <= mn){
            ans++;
        }
        mn = min(mn, p[i]);
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define fst first
#define snd second
#define ALL(obj) (obj).begin(), (obj).end()
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
//#define int long long int
const int MOD = 1000000007;
const ll LINF = (ll)1e18 - 1;
const int INF = 1e9 - 1;
const double EPS = 0.000000001;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
ll dp[111][101010] = {};
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;
  int k;
  cin >> n >> k;
  VL fac;
  for(int i = 1; i * i <= n; ++i){
    fac.push_back(i);
    fac.push_back(n / i);
  }
  fac.push_back(0);
  sort(ALL(fac));
  int s = fac.size();
  dp[0][0] = 1;
  REP(i, k){
    REP(j, s - 1) dp[i][j+1] = (dp[i][j+1] + dp[i][j]) % MOD;
    REP(j, s - 1){
      dp[i+1][j] = dp[i][s-j-2] * (fac[j+1] - fac[j]) % MOD;
    }
  }
  ll ans = 0;
  REP(i, s) ans += dp[k][i];
  out(ans % MOD);
  return 0;
}


Measured memory_bytes: 80120
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int[] a=new int[n];
    for(int i=0;i<n;i++){
      a[i]=sc.nextInt();
    }
    Arrays.sort(a);
    int ans=0;
    for(int i=1;i<n;i++){
      if(a[i]>a[i-1]){
        ans++;
      }
    }
    System.out.println(ans+1);
  }
}


Measured memory_bytes: 21204
import numpy as np
import pdb

def main():
    N = int(raw_input())
    pts = np.zeros(N)
    for k in range(N):
        pts[k] = int(raw_input())

    myanswer = solve(pts)
    
    print int(myanswer)

def solve(pts):
    N = len(pts)
    totalvalue = np.sum(pts)
    if np.mod(totalvalue, 10) != 0:
        return totalvalue

    notmultipleof10 = np.where(np.mod(pts, 10) > 0)[0]
    if len(notmultipleof10) == 0:
        return 0
    else:
        selection = pts[notmultipleof10]
        lost = np.min(selection)
        return totalvalue - lost




if __name__ == '__main__':
    main()


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

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define rep(i, n) repd(i, 0, n)

using namespace std;

using ll = long long;
using ul = unsigned long long;
ll mod = 1000000007;

class BIT {
  private:
    ll n;
    vector<ll> bit;

  public:
    BIT(ll num) {
        n = num;
        bit.resize(n + 1);
    }

    ll sum(ll i) {
        // 0-indexed->1-indexed
        i++;
        ll s = 0;
        while (i > 0) {
            s += bit[i];
            i -= i & -i;
        }
        return s;
    }
    ll add(ll i, ll x) {
        // 0-indexed->1-indexed
        i++;
        while (i <= n) {
            bit[i] += x;
            i += i & -i;
        }
    }
};

int main() {
source:
    ll n, k;
    cin >> n >> k;
    ll a[n];
    rep(i, n) { cin >> a[i]; }
    ll b[n + 1];
    b[0] = 0;
    repd(i, 1, n + 1) { b[i] = b[i - 1] + a[i - 1]; }

    rep(i, n + 1) { b[i] -= k * i; }

    map<ll, ll> m;
    rep(i, n + 1) { m[b[i]] = -1; }

    ll index = 0;
    for (auto iter = m.begin(); iter != m.end(); iter++) {
        iter->second = index;
        index++;
    }
    rep(i, n + 1) { b[i] = m[b[i]]; }

    BIT bit(n + 1);
    ll ans = 0;
    rep(i, n + 1) {
        ans += bit.sum(b[i]);
        bit.add(b[i], 1);
    }

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



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

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>

using namespace std;

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

    vector<long long> luc(N+1);
    luc[0] = 2, luc[1] = 1;
    for (int i = 2; i <= N; i++) {
        luc[i] = luc[i - 1] + luc[i - 2];
    }
    cout << luc[N] << endl;
}


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

int main() {
  int H, W;
  cin >> H >> W;

  vector<vector<char>> vec(H, vector<char>(W)); //入力される値

  vector<bool> vecH(H, false); // i行目に＃があるならtrue,ないならfalse
  vector<bool> vecW(W, false); // j列目に＃があるならtrue,ないならfalse


  for(int i=0; i<H; i++) {
      for(int j=0; j<W; j++) {
          cin >> vec.at(i).at(j);

          if(vec.at(i).at(j) == '#') {
              vecH.at(i) = true;
              vecW.at(j) = true;
          }

      }
  }

  for(int i=0; i<H; i++) {
      for(int j=0; j<W; j++) {
          if(vecH.at(i) && vecW.at(j)) {
              cout << vec.at(i).at(j);
          }
      }
      if(vecH.at(i)) cout << endl;
  }
}

Measured memory_bytes: 3624
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;




int main(){
    string s,t;
    cin>>s>>t;
    vector<ll> a(26,-1);
    vector<ll> b(26,0);
    for(int i=0;i<s.size();i++){
        if(a[s[i]-'a']!=-1 && a[s[i]-'a']!=t[i]-'a'){cout<<"No"<<endl; return 0;}
        if(a[s[i]-'a']==-1){
            a[s[i]-'a']=t[i]-'a';
            b[t[i]-'a']++;
            if(b[t[i]-'a']>1){cout<<"No"<<endl; return 0;}
        }
    }
    cout<<"Yes"<<endl;
    
    
    return 0;
}


Measured memory_bytes: 776
/*
    問題をよく読もう！
    論理的に考えよう！
    サンプルを確認しよう!
    絶対に諦めるな！
    工夫をしろ！
    配列は少し多めにとっておく

    Twitterは終わるまでログアウト！
    （間違えて解法をツイートしてはいけないから）

*/
//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include<cstring>
//namespace
using namespace std;
//繰り返し
#define REP(i, m, n) for(int i=(int)m; i<(int)n; ++i)
#define rep(i, n) REP(i, 0, n)
//イテレータ
#define all_range(C) begin(C), end(C)
//簡略化
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
typedef pair<string,int> pst;

const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
//最大最小
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) {if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) {if(a<b) a=b;}

//関数

//最大公約数を求める
ll my_gcd(ll x, ll y) {
  ll r;

  while(y!=0) {
    r = x%y;
    x = y;
    y = r;
  }

  return x;
}

//最小公約数を求める
ll my_lcm(ll x, ll y) {

  return (x*y)/my_gcd(x,y);
}

//xのy乗を求める ※参考：10^18乗まで
ll my_pow(ll x, ll y) {
  ll sum = 1;

  while(y>0) {
    sum *= x;
    --y;
  }

  return sum;
}

/*考えを書くスペース
  累乗和で解く

  ・総和を求める
  ・取り消すところの一つ先を見る
*/
//main.cpp----------------------------
#define max_n 10

void solve();

ll n;
double x[max_n+1];
string v[max_n+1];

int main() {
  cin >> n;
  rep(i, n) cin >> x[i] >> v[i];

  solve();

  return 0;
}

void solve() {
  double sum = 0;
  rep(i, n) {
    if(v[i]=="JPY") {
      sum += x[i];
    }else {
      sum += (380000.0)*x[i];
    }
  }

  cout << sum << endl;
}

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

int main() {
    std::vector<int> a;
    for (int i=0;i<3;++i) {
        int tmp;
        std::cin >> tmp;
        a.push_back(tmp);
    }
    std::sort(a.begin(), a.end());
    std::cout << a[0] << " " << a[1] << " " << a[2] << std::endl;
    return 0;
}


Measured memory_bytes: 3128
import java.util.Scanner;
class Main {

	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		int a=in.nextInt();
		int b=in.nextInt();
		int n=a-b;
		if(n>0) {
			System.out.println("a > b");
		}
		if(n<0) {
			System.out.println("a < b");
		}
		if(n==0) {
			System.out.println("a == b");
	}}

}



Measured memory_bytes: 26224
from __future__ import print_function
import numpy as np
import sys
import math,string,itertools,fractions,heapq,collections,re,array,bisect,copy,functools
# from itertools import accumulate
# from collections import deque
import random


def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)

N=int(input())
ans=0
for i in range(N):
    x,u=input().split()
    if u=="BTC":
        x=float(x)
        ans+=380000*x
    else:
        x=int(x)
        ans+=x
print(ans)

#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#


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

int main() {

    long long a, b, c; cin >> a >> b >> c;
    long long ab, cab;

    ab = a * b;
    cab = c - a - b;
    if (cab < 0) {
        cout << "No" << endl;
        return 0;
    }

    if (ab * 4 < cab * cab) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>

using namespace std;

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define CLR(a) memset((a), 0 ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//constants
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int INF = 1<<28;


int main(int argc, char **argv) {
    int N;
    cin >> N;
    vector<int> A;
    A.resize(100001, 0);
    int start=INF, end=0;
    REP(i, N){
        int a;
        cin >> a;
        A[a]++;
        if (A[a] > 1 and a < start)
            start = a;
        if (A[a] > 1 and a > end)
            end = a;
    }

    if (start==INF)
        goto end;

    while(start!=end){
        //debug(start);
        //debug(end);
        A[start]--;
        A[end]--;
        if (A[start] == 1){
            int i;
            for(i = start+1; i < end+1; i++){
                if(A[i] > 1){
                    start = i;
                    break;
                }
            }
            if(i==end+1)
                break;
        }
        if (A[end] == 1){
            for(int i = end-1; i >= start; i--)
                if(A[i] > 1){
                    end = i;
                    break;
                }
        }
    }

end:
    int ans = 0;
    if (start != INF){
        while(A[start] > 2)
            A[start] -= 2;
        if (A[start] == 2){
            A[start] = 1;
            ans--;
        }
    }

    REP(i, 100001)
        if (A[i] == 1){
            //cout << i << endl;
            ans++;
        }

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


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); ++i)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using Graph = vector<vi>;
using P = pair<int, int>;
const int MOD = 1e9+7;
const double EPS = 1e-9;

int main() {
  int n, k; cin >> n >> k;
  string s; cin >> s;

  Graph G(2);
  map<char, int> ctoi;
  ctoi['0'] = 0; ctoi['1'] = 1;
  int prev = ctoi[s[0]];
  G[prev].push_back(0);
  if (prev == 0) G[1].push_back(0);

  int tmp;
  rep(i,n-1) {
    tmp = ctoi[s[i+1]];
    if (tmp != prev) {
      prev = tmp;
      G[prev].push_back(i+1);
    }
  }

  G[0].push_back(n);

  if (k >= G[0].size()-1) {
    cout << n << endl;
    return 0;
  }

  int ans = 0;
  rep(i,G[0].size()-k) {
    ans = max(ans, G[0][i+k] - G[1][i]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1020
#include<bits/stdc++.h>
using namespace std;
int n, a[100005], ans;
bool flag;
int main()
{
  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }
  sort(a, a + n);
  if(n % 2){
    if(a[0] == 0){
      ans = 1;
    }
  }
  else{
    if(a[0] == a[1] && a[0] == 1){
      ans = 2;
    }
  }
  int j = n % 2 ? 2 : 3;
  for(int i = (n % 2 ? 2 : 3); i < n; i += 2){
    if(a[i] == a[i - 1] && i == j){
      ans = (ans * 2) % 1000000007;
      j +=2 ;
    }
    else flag = true;
  }
  if(flag)cout << 0 << endl;
  else cout << ans % 1000000007 << endl;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string.h>
#include <vector>
#include <cmath>
#include <iostream>
#include <unordered_map>
#include <queue>
using namespace std;
typedef unsigned long long ui64;
typedef long long i64;
void CakesandDonuts() {
	int N;
	cin >> N;
	bool yes = false;
	for (size_t i = 0; i <= 25; i++)
	{
		int b = i * 4;
		while (b <= N)
		{
			if (N == b) {
				yes = true;
				break;
			}
			b += 7;

		}
		if (yes) break;
	}
	cout << (yes ? "Yes" : "No");
}
int main() {
	CakesandDonuts();
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < n; i++)
#define rep2(i,x,n) for (int i = x; i < n; i++)
using ll = long long int;
int main() {
    ll mod = 1000000007;
    int s; cin >> s;
    vector<vector<ll>> A(s/3+1,vector<ll>(s+1,0));
    rep2(i,1,s/3+1) {
        for(int j=0; 3*i+j<=s; j++){
            if(i==1 && j==0) A.at(1).at(3) = 1;
            else A.at(i).at(3*i+j) = A.at(i).at(3*i+j-1)+A.at(i-1).at(3*(i-1)+j);
            if (A.at(i).at(3*i+j)>mod) A.at(i).at(3*i+j) %= mod;
        }
    }
    ll ans=0;
    rep2(i,1,s/3+1) {
        ans += A.at(i).at(s)%mod;
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 13688
open Batteries
open Printf
let () =
  let n = Scanf.scanf "%d " (fun a -> a) in
  let arr = Array.init n (fun _ -> (Scanf.scanf "%d " (fun a -> a))) in
  let visited = Array.init n (fun _ -> false) in

  let rec aux i cnt =
    let next = arr.(i) - 1 in
    if visited.(i) then -1 else
    if i = 1 then cnt else (
      visited.(i) <- true;
      aux next (cnt+1)
    )
  in

  Printf.printf "%d\n" @@
  aux 0 0 


Measured memory_bytes: 6784
#include<stdio.h>
#include<string.h>
#include<stdlib.h>

int main(void){
    char str[4];
    scanf("%s",str);
    if(str[0] == str[1] && str[1] == str[2] && str[0] == str[2]){
        puts("No");
        return 0;
    }
    puts("Yes");
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define MAX_V 6005
#define INF (1e9)
using namespace std;
typedef long long ll;

struct edge{int to, cap, rev;};

vector<edge> G[MAX_V];
bool used[MAX_V];

void add_edge(int from,int to,int cap){
  G[from].push_back((edge){to,cap,(int)G[to].size()});
  G[to].push_back((edge){from,0,(int)G[from].size()-1});  
}

int dfs(int v,int t,int f,int cnt=INF){
  if(v == t)return f;
  if(!cnt)return 0;
  used[v]=true;
  for(int i=0; i<G[v].size() ;i++){
    edge &e = G[v][i];
    if(!used[e.to] && e.cap > 0){
      int d = dfs(e.to ,t , min(f,e.cap),cnt-1);
      if(d > 0){
	e.cap -= d;
	G[e.to][e.rev].cap += d;
	return d;
      }
    }
  }
  return 0;
}

int max_flow(int s,int t){
  int flow = 0;
  for(;;){
    memset(used,0,sizeof(used));
    int f = dfs(s, t, INF);
    if(f == 0)return flow;
    flow += f;
  }
}

void flow_rev(int s,int t,int f){
  while(f){
    memset(used,0,sizeof(used));
    f-=dfs(s,t,f,2);
  }
}

ll n,k,x[MAX_V],y[MAX_V],s,t;

bool check_dis(int A,int B){
  return (x[A]-x[B])*(x[A]-x[B])+(y[A]-y[B])*(y[A]-y[B])<4;
}

void make_graph(){
    
  for(int i=0;i<n;i++)
    for(int j=0;j<n;j++)
      if(i!=j&&y[i]%2&&!(y[j]%2)&&check_dis(i,j))add_edge(i,j,INF);

  s=n, t=n+1;
  for(int i=0;i<n;i++)
    if(y[i]%2)add_edge(s,i,1);
    else add_edge(i,t,1);
  
}

vector<int> ans;

void solve(){
  int F=max_flow(s,t);
  
  if(n-F<k){
    cout<<-1<<endl;
    return;
  }

  for(int i=0;i<n;i++){
    
    if(y[i]%2){
      int idx;
      for(int j=0;j<G[s].size();j++)
	if(G[s][j].to==i)idx=j,G[s][j].cap+=INF;
      
      int add_F=max_flow(s,t);
      if(n-(F+add_F)>=k)ans.push_back(i+1),F+=add_F;
      else{
	edge &e=G[s][idx];
	e.cap-=INF-add_F;
	G[e.to][e.rev].cap-=add_F;
	
	flow_rev(t,i,add_F);
      }
      
    }else{
      int idx;
      for(int j=0;j<G[i].size();j++)
	if(G[i][j].to==t)idx=j,G[i][j].cap+=INF;
      
      int add_F=max_flow(s,t);
      if(n-(F+add_F)>=k)ans.push_back(i+1),F+=add_F;
      else{
	edge &e=G[i][idx];
	e.cap-=INF-add_F;
	G[e.to][e.rev].cap-=add_F;
	
	flow_rev(i,s,add_F);
      }
      
    }
    
  }
  for(int i=0;i<k;i++)cout<<ans[i]<<endl;
}

int main(){
  cin>>n>>k;
  for(int i=0;i<n;i++)cin>>x[i]>>y[i];
  
  make_graph();

  solve();
  
  return 0;
}

Measured memory_bytes: 4388
process.stdin.resume();
process.stdin.setEncoding('utf8');
// Here your code !
process.stdin.on('data', function (chunk) {
    var lines = chunk.toString().split('\n');
    var a =parseInt(lines[0]);
    var b =parseInt(lines[1]);
    var h =parseInt(lines[2]);
    
    var ans = (a+b)*h/2;
    console.log(ans);
    
});


Measured memory_bytes: 11596
a,b,c,d = map(int,input().split())
x,y = c,d

while y != 0:
	x,y =y,x%y
x = (c*d)//x

count1 = b - (b//c + b//d -b//x)
count2 = (a - 1) - ((a-1)//c + (a-1)//d -(a-1)//x) 
print(count1 - count2)

Measured memory_bytes: 3060
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n = I()
    p = [input().split() for i in range(n)]
    d = defaultdict(lambda : 0)
    s = 0
    for pi,i in p:
        s += int(i)
        d[pi] += s
    print(s-d[input()])
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 39408
public class Main {
    public static void main(String[] args) {

        int[][][] info = new int[4][3][10];
        for (int i = 0; i < 4; i ++) {
            for (int j = 0; j < 3; j ++) {
                for (int k = 0; k < 10; k ++) { info[i][j][k] = 0; }
            }
        }

        java.util.Scanner sc = new java.util.Scanner(System.in);
        int n = sc.nextInt();
        for (int i = 0; i < n; i ++) {
            int built = sc.nextInt();
            int floor = sc.nextInt();
            int room = sc.nextInt();
            int num = sc.nextInt();
            info[built - 1][floor - 1][room - 1] += num;
        }

        for (int i = 0; i < 4; i ++) {
            for (int j = 0; j < 3; j ++) {
                for (int k = 0; k < 10; k ++) {
                    System.out.print(" " + info[i][j][k]);
                }
                System.out.print("\n");
            }
            if (i != 4 - 1) { System.out.print("####################\n"); }
        }
    }
}

Measured memory_bytes: 30220
#include<bits/stdc++.h>
#define ll long long int 
#define fori(i,n) for(int i=0; i<n; ++i)
#define ford(i,n) for(int i=n-1; i>=0; --i)
#define vi vector<int> 
#define vs vector<string>
#define vll vector<ll>
#define di deque<int>
#define vpii vector<pair<int,int>>
#define vpll vector<pair<ll,ll>>
#define pqi priority_queue<int>
#define pqll priority_queue<ll>
#define mod1 1000000007
#define mod2 998244353
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define gcd __gcd

//Printing template
#define pf2(a,b) cout<<a<<" "<<b<<"\n"
#define pf3(a,b,c) cout<<a<<" "<<b<<" "<<c<<"\n"
#define pf4(a,b,c,d) cout<<a<<" "<<b<<" "<<c<<" "<<d<<"\n"

#define fast_cin() ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
using namespace std;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> i_set;
typedef tree<ll, null_type, less<ll>, rb_tree_tag,tree_order_statistics_node_update> ll_set; 
/* new_data_set p; */
/* *p.find_by_order(3); The value at third place */
/* p.order_of_key(7); The expected index in the set in sorted order */

bool sortbysec(pair<ll,ll> &p1, pair<ll, ll> &p2){
    return (p1.se<p2.se);
}

int main(int argc, char const *argv[]){
    fast_cin();
    ll i,j,h,n,in;
    cin>>h>>n;
    vll a(n),b(n),c(n),d(n);
    fori(i,n) cin>>a[i]>>b[i];
    ll dp[10001];
    for(i=1; i<=h; ++i){
        dp[i]=LLONG_MAX;
        for(j=0; j<n; ++j){
            in=i-a[j];
            if(in<=0) dp[i]=min(dp[i],b[j]);
            else dp[i]=min(dp[i],dp[in]+b[j]);
        }
    }
    cout<<dp[h]<<"\n";
    return 0;
}


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

int main(){
  int x, a;
  std::cin >> x >> a;
  if(x < a){
    std::cout << "0" << '\n';
  }
  else{
    std::cout << "10" << '\n';
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll =long long;
using namespace std;
using Graph=vector<vector<int>>;
using Field=vector<string>;
using P =pair<int,int>;
const ll mod=1000000007;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

int main(){
    ll n;
    cin>>n;
    ll x;
    cin>>x;
    vector<ll> v(n+1);
    v[n]=x;
    for(ll i=0;i<n;++i)cin>>v[i];
    sort(v.begin(),v.end());
    ll gcdx=v[1]-v[0];
    for(ll i=1;i<n;++i){
        ll diff=v[i+1]-v[i];
        gcdx=__gcd(diff,gcdx);
    }
    cout<<gcdx<<endl;
}




Measured memory_bytes: 4056
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <numeric>
#include <cctype>
#include <tuple>

#ifdef _MSC_VER
#include <agents.h>
#endif

#define FOR(i, a, b) for(int i = (a); i < (int)(b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define REV(v) v.rbegin(), v.rend()
#define MEMSET(v, s) memset(v, s, sizeof(v))
#define X first
#define Y second

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

int ans[52];
int num[14];

void dfs(int sum, int n){
	if (n == 0){
		if (sum == 0) throw 1;
		return;
	}
	FOR(i, 1, 14){
		if (!num[i]) continue;
		if (sum % i) continue;
		--num[i];
		ans[n-1] = i;
		dfs(sum - i, n - 1);
		++num[i];
	}
}

int main(){
	int n;
	while (cin >> n, n){
		MEMSET(num, 0);
		int sum = 0;
		rep(i, n){
			int x;
			cin >> x;
			sum += x;
			++num[x];
		}
		try{
			dfs(sum, n);
			cout << "No" << endl;
		}
		catch (int x){
			rep(i, n) cout << (i ? " ":"") << ans[i];
			cout << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 1268
#define DBG 0 //submit 0
#define ll long long
#if DBG
    #include <algorithm>
    #include <array>
    #include <ctime>
    #include <cstdlib>
    #include <string>
    #include <vector>
    #include <unordered_map>
    #include <iostream>
    #include <cmath>
    #include <queue>
    #include <numeric>
#else
    #include <bits/stdc++.h>
#endif
 
using namespace std;
 
 
int main(){
    int m,n,ans=0;
   
    cin >> n;

    //for(int i=0;i<n;i++) cin >> s[i];
    

    ans = n*n;
    
    //cout << (flag ? "Yes" : "No");
    cout << ans;
    //printf("%.10f",ans_d);

    cout << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)  
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

int main(){

  int a,b;
  cin>>a>>b;
  if(a<=8&&b<=8){
    cout<<"Yay!"<<endl;
  }
  else{
    cout<<":("<<endl;
  }


  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define sp ' '
#define nyan "(=^・ω・^=)"
#define mkp make_pair
#define intmax 2147483647
#define llmax 9223372036854775807
#define lP pair<ll,ll>
#define iP pair<int,int>
typedef long long ll;
using namespace std;
const int mod = 1000000007;
const int mod998 = 998244353;
const int D[9] = { 2, 5, 5, 4, 5, 6, 3, 7, 6 };

int N, M, A[9];
bool DP[11111][5555];

int main() {
	cin >> N >> M;
	for (int i = 0; i < M; ++i) {
		cin >> A[i];
		--A[i];
	}
	sort(A, A + M);
	DP[0][0] = true;
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < N / 2; ++j) {
			if (DP[i][j]) {
				for (int k = 0; k < M; ++k) {
					DP[i + D[A[k]]][j + 1] = true;
				}
			}
		}
	}
	for (int i = N / 2; i; --i) {
		if (DP[N][i]) {
			while (i) {
				--i;
				for (int j = M - 1; j >= 0; --j) {
					if (N - D[A[j]] >= 0 && DP[N - D[A[j]]][i]) {
						N -= D[A[j]];
						cout << A[j] + 1;
					}
				}
			}
			break;
		}
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 55168
#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 <functional>
#include <iomanip>
#include <numeric>
#include <climits> // LLONG_MAX, LLONG_MIN, INT_MIN, INT_MAX
#include <assert.h>

#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 rep(i, n) for (int i = 0; i < (n); ++i)
#define ll long long
//#define int ll
#define INF INT_MAX/10
#define MOD 1000000007

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

int Input[100100];

int main() {
  int N; cin >> N;
  string S; cin >> S;
  int ans = 1;
  for (int i = 1; i < N; i++) {
    if (S[i-1] == S[i]) {
      continue;
    } else {
      ans++;
    }
  }

  cout << ans << endl;
}


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

int main() {
	int n, t; cin >> n >> t;
	vector<int>tn(n);
	for (int i = 0; i < n; i++)cin >> tn[i];

	int ans = t;
	for (int i = 0; i < n-1; i++) {
		ans += min(t, tn[i+1]-tn[i]);
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1024
H, W = map(int, input().split())
c = [list(map(int, input().split())) for i in range(10)]
A = [list(map(int, input().split())) for i in range(H)]

# warshall floyd
for i in range(10):
    for j in range(10):
        for k in range(10):
            c[j][k] = min(c[j][k], c[j][i]+c[i][k])

ans = 0
for i in range(H):
    for j in range(W):
        if A[i][j] == -1 or A[i][j] == 1:
            continue
        else:
            ans += c[A[i][j]][1]

print(ans)

Measured memory_bytes: 3444
function main(input) {
  input=input.trim();
  const a = input.split("\n")[0].substr(0,1);
  const b = input.split("\n")[1].substr(1,1);
  const c = input.split("\n")[2].substr(2,1);



  console.log(a+b+c);

}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));



Measured memory_bytes: 7372
import java.util.*;

public class Main{
	public static void main(String args[]) {

		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long K = sc.nextLong();
		int[] A = new int[N]; 
		for(int i = 0; i < N; i++) {
			A[i] = sc.nextInt() - 1;
		}

		int[] time = new int[N];
		Arrays.fill(time, -1);

		int now = 0;
		int clock = 0;

		while(K > 0) {
			if(time[now] == -1) {
				time[now] = clock++;
				now = A[now];
				K--;
			}
			else {
				K %= clock - time[now];
				break;
			}
		}
		
		while(K > 0) {
				now = A[now];
				K--;
		}

		System.out.println(now+1);
		sc.close();
	}
}

Measured memory_bytes: 60080
from collections import Counter
import numpy as np

N = int(input())
A = list(map(int, input().split()))
Q = int(input())

d = dict(Counter(A))
ans = sum(A)
for i in range(Q):
    b, c = map(int, input().split())
    
    if(b not in d):
        d[b] = 0
    if(c not in d):
        d[c] = 0
    
    if(b >= c):
        n = d[b]*(c-b)
    else:
        n = d[b]*(c-b)
        
    ans += n
    
    if(c in d):
        d[c] += d[b]
    else:
        d[c] = d[b]
    d[b] = 0
    
    print(ans)    

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

int main()
{
    int res = 0;
    string n;
    cin >> n;

    for(int i = 0; i < n.size(); ++i)
    {
        res += n[i] - '0';
    }

    cout << (res % 9 == 0 ? "Yes" : "No") << "\n";  
    return 0;
}


Measured memory_bytes: 3720
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(v) v.begin(),v.end()

using namespace std;
typedef long long ll;




int main()
{
    string X;
    cin >> X;
    
    stack<char> A;
    rep(i,int(X.length())){
        if(A.empty()){
            A.push(X[i]);
            continue;
        }
        
       
        if(A.top() == 'S' && X[i] == 'T') A.pop();
        else A.push(X[i]);
        
        
    }
    
    cout << A.size() << endl;
    
    return 0;
}



Measured memory_bytes: 644
N=int(input())
S=input()

# Zアルゴリズムで解く

def z_algorithm(S):
    N=len(S)
    A = [N] + [0]*(N-1)
    
    left=1
    length=0
    
    while left < N:
        
        # prefixが同じ間length加算
        while left + length < N and S[length] == S[left+length]:
            length += 1
        
        # prefixの一致数保存
        A[left] = length
        
        # 一文字一致していなければ戻る
        if length == 0:
            left+=1
            continue
        
        # lengthの分だけleftとindexの間を埋めていく(はみ出ていないとこまで)
        k=1
        while k+left < N and k+A[k]<length:
            A[left+k] = A[k]
            k += 1
            
        left += k
        length -= k
    return A

c=0
max_num=0
for sub in range(len(S)):
    subS = S[sub:]
    A=z_algorithm(subS)
    for i,a in enumerate(A):
        if i>=a and max_num<a:
            max_num=a
print(max_num)

Measured memory_bytes: 51036
# -*- coding: utf-8 -*-

while True:
    line = map(str, raw_input().split())
    x = int(line[0])
    op = line[1]
    y = int(line[2])
    if op == "?":
        break
    elif op == "+":
        print x+y
    elif op == "-":
        print x-y
    elif op == "*":
        print x*y
    elif op == "/":
        print x/y

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

bool sb[10];
int n;
string ans;
string s[10];
int N[10][10];

void make(int m,int num,string S,int before)
{
  if(before!=-1){
    if(N[before][m]!=0)S+=s[m].substr(N[before][m]);
    else S+=s[m];
  }
  if(n==num){
    //cout<<S<<endl;
    if(ans==""){
      ans=S;
      return;
    }
    else {
      if(ans.length()>S.length())ans=S;
      else if(ans.length()==S.length() && ans>S)ans=S;
    }
    return;
  }
  else{
    for(int i=0;i<n;i++){
      if(sb[i])continue;
      sb[i]=true;
      make(i,num+1,S,m);
      sb[i]=false;
    }
  }
}

int main()
{
  string S;
  while(1){
    cin>>n;
    if(n==0)break;
    for(int i=0;i<n;i++)cin>>s[i];
    for(int i=0;i<n;i++)for(int j=0;j<n;j++)N[i][j]=0;

    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
	for(int k=1;k<=s[i].length() && k<=s[j].length();k++){
	  if(s[i].substr(s[i].length()-k,k)==s[j].substr(0,k) && i!=j){
	    N[i][j]=k;
	  }
	}
      }
    }
    for(int i=0;i<n;i++)sb[i]=false;
    int sum=1;
    for(int i=0;i<n;i++){
      for(int j=i+1;j<n;j++){
	if(s[i].length()==s[j].length()){
	  if(s[i]==s[j]){
	    if(sb[i])continue;
	    sb[i]=true;
	    sum++;
	  }
	}
	else if(s[i].length()>s[j].length()){
	  for(int k=0;k<=s[i].length()-s[j].length();k++){
	    if(s[i].substr(k,s[j].length())==s[j]){
	      if(sb[j])continue;
	      sb[j]=true;
	      sum++;
	      break;
	    }
	  }
	}
	else {
	  for(int k=0;k<=s[j].length()-s[i].length();k++){
	    if(s[j].substr(k,s[i].length())==s[i]){
	      if(sb[i])continue;
	      sb[i]=true;
	      sum++;
	      break;
	    }
	  }
	}
      }
    }
    ans="";
    for(int i=0;i<n;i++){
      if(sb[i])continue;
      sb[i]=true;
      make(i,sum,s[i],-1);
      sb[i]=false;
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 1220
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower
#include <iomanip>       // fixed, setprecision
using namespace std;

int main()
{
  int N;
  double a, s = 0;
  cin >> N;
  for (int i = 0; i < N; i++)
  {
    cin >> a;
    s += 1.0 / a;
  }
  cout << fixed << setprecision(10) << (1.0 / s) << endl;
}


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

int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  int p,q;
  p=(c+b-1)/b;
  q=(a+d-1)/d;

  if(p<=q) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


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

#define REP(i,num) for(ll i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=ll>
T in(){T x; cin >> x; return (x);}
template<typename T=ll,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

vll F;
ll Fib(ll n){
	if(F[n]>0) return F[n];
	return F[n]=Fib(n-1)+Fib(n-2);
}

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

	int N=in();
	F.resize(50,-1);
	F[0]=F[1]=1;

	out(Fib(N));
	return 0;
}



Measured memory_bytes: 3216
#include<iostream>
using namespace std;
int main()
{
    int S,i,j;
    cin>>S;
    i=S%100;
    j=S/100;
    if(i==0 && j==0)
    {
        cout<<"NA"<<endl;
    }
    else if((i==0 && j>12) || (i>12 && j==0))
    {
        cout<<"NA"<<endl;
    }
    else if(i!=0 && i<=12 && (j>12 || j==0))
    {
        cout<<"YYMM"<<endl;
    }
    else if(j!=0 && j<=12 && (i>12 || i==0))
    {
        cout<<"MMYY"<<endl;
    }
    else if(i!=0 && i<=12 && j!=0 && j<=12)
    {
        cout<<"AMBIGUOUS"<<endl;
    }
    else
    {
        cout<<"NA"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<ctime>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<vector>
#include<iostream>
#include<algorithm>
using namespace std;

int main() {
	int a[10];
	while (cin >> a[0]) {
		for (int i = 1; i < 6; i++) {
			cin >> a[i];
		}
		if (a[4] - a[0] > a[5]) {
			cout << ":(" << endl;
		}
		else {
			cout << "Yay!" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <queue>

#define WHITE 0
#define BLACK 1
#define MAXN 50

using namespace std;

struct {
  int i,j;
} typedef point;

int H,W;
int A[MAXN][MAXN];

bool judge ( void )
{
  for ( int i = 0; i < H; ++i ) {
    for ( int j = 0; j < W; ++j ) {
      if ( !A[i][j] ) continue;
      bool f = false;
      if ( i-1 >= 0 && A[i-1][j] == BLACK ) f = true;
      if ( i+1 < H && A[i+1][j] == BLACK ) f = true;
      if ( j-1 >= 0 && A[i][j-1] == BLACK ) f = true;
      if ( j+1 < W && A[i][j+1] == BLACK ) f = true;
      if ( !f ) return false;
    }
  }

  return true;
}

int main()
{
  cin >> H >> W;

  for ( int i = 0; i < H; ++i ) {
    string s;
    cin >> s;
    for ( int j = 0; j < s.size(); ++j ) {
      if ( s[j] == '.' ) A[i][j] = WHITE;
      else A[i][j] = BLACK;
    }
  }

  if ( judge() ) cout << "Yes\n";
  else cout << "No\n";
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <cassert>
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <utility>
#include <queue>
#include <climits>
using namespace std;

#define int long long
#define pii pair<int, int>
#define ld long double

#define form(i, n) for (int i = 0; i < (n); ++i)
#define form2(i, a, b) for (int i = (a); i < (b); ++i)
#define ford(i, n) for (int i = (n-1); i >= 0; --i)
#define ford2(i, a, b) for (int i = (a-1); i >= (b); --i)

#define chmax(x, v) x = max(x, (v));
#define chmin(x, v) x = min(x, (v));

void solve();
signed main()
{
#ifdef LOCAL_HUGO
	freopen("in.txt", "r", stdin);
#else
	ios::sync_with_stdio(false);
	cin.tie(0);
#endif
	solve();
}

const int UNDEF = -1;
const int borne = 1005;
const int b2 = 20005;
typedef pair<pii, pii> quad;
quad blocs[borne];
int n;
vector<int> valMax;

void solve()
{
	cin >> n;
	form(i, n) {
		int w, s, v;
		cin >> w >> s >> v;
		blocs[i] = { {w + s, s}, {w, v} };
	}
	sort(blocs, blocs + n);
	valMax.assign(b2, 0);
	valMax[0] = 0;
	vector<int> tmp = valMax;
	form(i, n) {
		int s = blocs[i].first.second;
		int w = blocs[i].second.first;
		int v = blocs[i].second.second;
		form(j, s + 1) {
			if (j + w < b2) {
				chmax(tmp[j + w], valMax[j] + v);
			}
		}
		form(i, b2 - 1) chmax(tmp[i+1], tmp[i]);
		valMax = tmp;
	}
	cout << valMax[b2 - 1] << '\n';
}

Measured memory_bytes: 640
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    putchar_unlocked(c[i]);
  }
}
int main(){
  int N;
  int M;
  rd(N);
  rd(M);
  if(N==M){
    wt_L("Yes");
    wt_L('\n');
  }
  else{
    wt_L("No");
    wt_L('\n');
  }
  return 0;
}
// cLay varsion 20200119-1

// --- original code ---
// {
//   int N, M;
//   rd(N,M);
//   wt(if[N==M,"Yes","No"]);
// }


Measured memory_bytes: 256
N=int(input())
L=[[0 for i in range(10)] for j in range(10)]
for i in range(1,N+1):
    x=int(str(i)[0])
    y=int(str(i)[-1])
    L[x][y]+=1
ans=0
for i in range(10):
    for j in range(10):
        ans+=L[i][j]*L[j][i]
print(ans)


Measured memory_bytes: 41708
#include <bits/stdc++.h>
using namespace std;
const long double PI = acos(-1);
typedef long long ll;
typedef pair<int64_t,int64_t> pll;
int dx[]={1,-1,0,0,1,-1,1,-1};
int dy[]={0,0,1,-1,1,-1,-1,1};
#define INF (2147483647)
#define mod (1000000007)
#define limit (7368791)
#define rep(i,a,b) for (int64_t i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define ALL(a) begin(a),end(a)
#define sz(s) (s).size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second

 
void solve()
{
    ll n,k;cin>>n>>k;
    ll a[n];REP(i,n)cin>>a[i];
    ll sum1=0,sum2=0;
    REP(i,n)REP(j,n)
    {
        if(a[i]>a[j])sum1++;
        if(a[i]>a[j]&&i<j)sum2++;
        sum1%=mod;sum2%=mod;
    }
    ll ka=k*(k-1)/2;ka%=mod;
    ll ans=sum1*ka;ans%=mod;
    ans+=sum2*k;ans%=mod;
    cout<<ans<<endl;

}

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

Measured memory_bytes: 256